Skip to contentSkip to conversation

"elf core dump: fix get_user use" breaks mips compilation

DISCUSSION Martin Michlmayr 4 participants 6 messages Feb 16, 2009 – Feb 17, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Roland,

Your change "elf core dump: fix get_user use" (which made it into 2.6.28.5) breaks the compilation on MIPS (which sets -Werror):

CC arch/mips/kernel/binfmt_elfn32.o
cc1: warnings being treated as errors
arch/mips/kernel/../../../fs/binfmt_elf.c: In function ‘vma_dump_size’:
arch/mips/kernel/../../../fs/binfmt_elf.c:1202: warning: ‘word’ may be used uninitialized in this function make[1]: *** [arch/mips/kernel/binfmt_elfn32.o] Error 1

Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#1 lore raw

That is either a compiler problem or a problem with how the asm magic used inside get_user() informs the compiler. The dynamics of the code are not actually much different than before the change.

I imagine this would work around it:

fs/binfmt_elf.c +1 -1
@@ -1211,7 +1211,7 @@ static unsigned long vma_dump_size(struc
 	if (FILTER(ELF_HEADERS) &&
 	    vma->vm_pgoff == 0 && (vma->vm_flags & VM_READ)) {
 		u32 __user *header = (u32 __user *) vma->vm_start;
-		u32 word;
+		u32 word = 0;
 		mm_segment_t fs = get_fs();
 		/*
 		 * Doing it this way gets the constant folded by GCC.
author Tested-by
#2 lore raw

fs/binfmt_elf.c static unsigned long vma_dump_size(struc · line 1214

Quoted 10 lines · Roland McGrath

I imagine this would work around it:

fs/binfmt_elf.c +1 -1
@@ -1211,7 +1211,7 @@ static unsigned long vma_dump_size(struc
 	if (FILTER(ELF_HEADERS) &&
 	    vma->vm_pgoff == 0 && (vma->vm_flags & VM_READ)) {
 		u32 __user *header = (u32 __user *) vma->vm_start;
-		u32 word;
+		u32 word = 0;
Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#3 lore raw
In reply to Martin Michlmayr
Quoted 10 lines · Martin Michlmayr

Hi Roland,

Your change "elf core dump: fix get_user use" (which made it into 2.6.28.5) breaks the compilation on MIPS (which sets -Werror):

CC arch/mips/kernel/binfmt_elfn32.o
cc1: warnings being treated as errors
arch/mips/kernel/../../../fs/binfmt_elf.c: In function ‘vma_dump_size’:
arch/mips/kernel/../../../fs/binfmt_elf.c:1202: warning: ‘word’ may be used uninitialized in this function make[1]: *** [arch/mips/kernel/binfmt_elfn32.o] Error 1

Partially expanding get_user() the code basically does this:

	int word;

	if (access_ok(...))
		__get_user(word, header);
	else
		word = 0;

And gcc is unable to figure out that word will always be assigned to by both paths of the if statement. Older gcc versions used to have that problem. I can't reproduce your problem with gcc 4.3.2 and I assume you're using something older than that?

Ralf

#4 lore raw
Quoted 9 lines · Ralf Baechle

Partially expanding get_user() the code basically does this:

	int word;

	if (access_ok(...))
		__get_user(word, header);
	else
		word = 0;
Quoted 4 lines

And gcc is unable to figure out that word will always be assigned to by both paths of the if statement. Older gcc versions used to have that problem. I can't reproduce your problem with gcc 4.3.2 and I assume you're using something older than that?

Yes, gcc 4.1.

Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#5 lore raw
In reply to Ralf Baechle

Am Tuesday 17 February 2009 00:32:16 schrieb Ralf Baechle:

Quoted 5 lines · Martin Michlmayr
Quoted 4 lines

Hi Roland,

Your change "elf core dump: fix get_user use" (which made it into 2.6.28.5) breaks the compilation on MIPS (which sets -Werror):

Since several gcc versions are known to produce false warning, the proper fix should be to remove -Werror, no?

Christian