linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* "elf core dump: fix get_user use" breaks mips compilation
@ 2009-02-16 12:01 Martin Michlmayr
  2009-02-16 21:25 ` Roland McGrath
  2009-02-16 23:32 ` Ralf Baechle
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Michlmayr @ 2009-02-16 12:01 UTC (permalink / raw)
  To: Roland McGrath; +Cc: linux-kernel, Ralf Baechle

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

-- 
Martin Michlmayr
http://www.cyrius.com/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: "elf core dump: fix get_user use" breaks mips compilation
  2009-02-16 12:01 "elf core dump: fix get_user use" breaks mips compilation Martin Michlmayr
@ 2009-02-16 21:25 ` Roland McGrath
  2009-02-17  8:15   ` Martin Michlmayr
  2009-02-16 23:32 ` Ralf Baechle
  1 sibling, 1 reply; 6+ messages in thread
From: Roland McGrath @ 2009-02-16 21:25 UTC (permalink / raw)
  To: Martin Michlmayr; +Cc: linux-kernel, Ralf Baechle

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:

--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: "elf core dump: fix get_user use" breaks mips compilation
  2009-02-16 12:01 "elf core dump: fix get_user use" breaks mips compilation Martin Michlmayr
  2009-02-16 21:25 ` Roland McGrath
@ 2009-02-16 23:32 ` Ralf Baechle
  2009-02-17  7:42   ` Martin Michlmayr
  2009-02-17  8:15   ` Christian Borntraeger
  1 sibling, 2 replies; 6+ messages in thread
From: Ralf Baechle @ 2009-02-16 23:32 UTC (permalink / raw)
  To: Martin Michlmayr; +Cc: Roland McGrath, linux-kernel

On Mon, Feb 16, 2009 at 01:01:36PM +0100, Martin Michlmayr wrote:

> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: "elf core dump: fix get_user use" breaks mips compilation
  2009-02-16 23:32 ` Ralf Baechle
@ 2009-02-17  7:42   ` Martin Michlmayr
  2009-02-17  8:15   ` Christian Borntraeger
  1 sibling, 0 replies; 6+ messages in thread
From: Martin Michlmayr @ 2009-02-17  7:42 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Roland McGrath, linux-kernel

* Ralf Baechle <ralf@linux-mips.org> [2009-02-16 23:32]:
> 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?

Yes, gcc 4.1.
-- 
Martin Michlmayr
http://www.cyrius.com/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: "elf core dump: fix get_user use" breaks mips compilation
  2009-02-16 21:25 ` Roland McGrath
@ 2009-02-17  8:15   ` Martin Michlmayr
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Michlmayr @ 2009-02-17  8:15 UTC (permalink / raw)
  To: Roland McGrath; +Cc: linux-kernel, Ralf Baechle

* Roland McGrath <roland@redhat.com> [2009-02-16 13:25]:
> I imagine this would work around it:
> 
> --- a/fs/binfmt_elf.c
> +++ b/fs/binfmt_elf.c
> @@ -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;

Tested-by: Martin Michlmayr <tbm@cyrius.com>

-- 
Martin Michlmayr
http://www.cyrius.com/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: "elf core dump: fix get_user use" breaks mips compilation
  2009-02-16 23:32 ` Ralf Baechle
  2009-02-17  7:42   ` Martin Michlmayr
@ 2009-02-17  8:15   ` Christian Borntraeger
  1 sibling, 0 replies; 6+ messages in thread
From: Christian Borntraeger @ 2009-02-17  8:15 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Martin Michlmayr, Roland McGrath, linux-kernel

Am Tuesday 17 February 2009 00:32:16 schrieb Ralf Baechle:
> On Mon, Feb 16, 2009 at 01:01:36PM +0100, Martin Michlmayr wrote:
> > 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-02-17  8:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-16 12:01 "elf core dump: fix get_user use" breaks mips compilation Martin Michlmayr
2009-02-16 21:25 ` Roland McGrath
2009-02-17  8:15   ` Martin Michlmayr
2009-02-16 23:32 ` Ralf Baechle
2009-02-17  7:42   ` Martin Michlmayr
2009-02-17  8:15   ` Christian Borntraeger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).