[patch] [PATCH] Don't write undefined values to disk

Bernhard Walle bwalle at suse.de
Thu Sep 11 08:14:03 EDT 2008


Because of structure member alignment, the simple structure

    struct kdump_sub_header {
            unsigned long   phys_base;
            int             dump_level;     
    };  

is 16 bytes large on x86_64. So if you fill the two members phys_base and
dump_level with values, you still have uninitialised memory if you write
sizeof(struct kdump_sub_header) to disk.

This patch initialises everything with zero first to get rid of that problem.
The patch fixes valgrind warning

    ==24152== Syscall param write(buf) points to uninitialised byte(s)
    ==24152==    at 0x4EEFFC0: write (in /lib64/libc-2.8.so)
    ==24152==    by 0x40A97D: (within /bin/makedumpfile)
    ==24152==    by 0x40ACEF: (within /bin/makedumpfile)
    ==24152==    by 0x41896C: (within /bin/makedumpfile)
    ==24152==    by 0x4191AA: (within /bin/makedumpfile)
    ==24152==    by 0x4E48435: (below main) (in /lib64/libc-2.8.so)
    ==24152==  Address 0x7fefffbfc is on thread 1's stack


Signed-off-by: Bernhard Walle <bwalle at suse.de>

---
 makedumpfile.c |    1 +
 1 file changed, 1 insertion(+)

--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -4707,6 +4707,7 @@ write_kdump_header(void)
 	/*
 	 * Write sub header
 	 */
+	memset(&sub_dump_header, 0, sizeof(struct kdump_sub_header));
 	sub_dump_header.phys_base  = info->phys_base;
 	sub_dump_header.dump_level = info->dump_level;
 	size = sizeof(struct kdump_sub_header);



More information about the kexec mailing list