Fix Warnining in arch/x86/kernel/signal.c
Hello Hiroshi-san,
Quoted 33 lines · On Thu, 2009-05-14 at 09:24 +0900, Hiroshi Shimamoto wrote: H. Peter Anvin…
Quoted 24 lines
Quoted 23 lines · Ingo Molnar
Quoted 23 lines
Quoted 11 lines
Review
Quoted 11 lines
if (!access_ok(VERIFY_READ, frame,
sizeof(*frame)))
goto badframe;(quoted diff) +4
-3- if (__get_user(set.sig[0], &frame->sc.oldmask) || (_NSIG_WORDS > 1 - && __copy_from_user(&set.sig[1], &frame->extramask, - sizeof(frame->extramask)))) + + if ( (__copy_from_user(&set.sig[1], &frame->extramask, + sizeof(frame->extramask)) && _NSIG_WORDS > 1) || + __get_user(set.sig[0], &frame->sc.oldmask)) goto badframe;Quoted 2 lines
I'm not sure why this eliminates that warning.
set.sig[0] may not be initialized too, if__copy_from_user()failed.True, but only when either or both of
__copy_from_user()and (_NSIG_WORDS> 1) fails. But in all instances set.sig[1] gets initialized.Quoted 6 lines
I don't have enough time to look at this right now, sorry.
Another question,
__copy_from_user()will be called even if_NSIG_WORDSis less than 2, perhaps it never occurs.
I think, to check_NSIG_WORDS> 1 before calling__copy_from_user()is better.Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Fine. Let Ingo/Thomas/Peter decide whether they would like this fix or drop it.
If you get the Acked-by from Hiroshi-san it looks good to me. He modified this code last.
This seriously looks wrong to me. If
_NSIG_WORDS== 1, then calling__copy_from_userhere is a serious error.
Quoted 8 lines
Right. If
_NSIG_WORDSis 1,sigset_tset has only sig[0], writing to set.sig[1] means stack corruption.Subrata, could you try like this?
if ((_NSIG_WORDS> 1 &&__copy_from_user(&set.sig[1], ...)||__get_user(set.sig[0], ...))
How about now ? Thanks for pointing that out. My mistake ;-)
To: Hiroshi Shimamoto <[email protected]>,
Cc: H. Peter Anvin <[email protected]>,
Cc: Ingo Molnar <[email protected]>,
Cc: [email protected],
Cc: Sachin P Sant <[email protected]>,
Cc: Andi Kleen <[email protected]>,
Cc: Andi Kleen <[email protected]>,
Cc: Linux Kernel <[email protected]>,
Cc: Balbir Singh <[email protected]>,
Cc: Thomas Gleixner <[email protected]>,
Cc: Ingo Molnar <[email protected]>
Subject: Re:[PATCH] Fix Warnining in arch/x86/kernel/signal.c
---
arch/x86/kernel/signal.c +3 -3
@@ -576,9 +576,9 @@ unsigned long sys_sigreturn(struct pt_reif (!access_ok (VERIFY_READ , frame,sizeof (*frame))) goto badframe; -if (__get_user (set.sig[0 ], &frame->sc.oldmask) || (_NSIG_WORDS >1 - &&__copy_from_user (&set.sig[1 ], &frame->extramask, -sizeof (frame->extramask)))) +if ((_NSIG_WORDS >1 &&__copy_from_user (&set.sig[1 ], + &frame->extramask,sizeof (frame->extramask))) || +__get_user (set.sig[0 ], &frame->sc.oldmask)) goto badframe;sigdelsetmask (&set, ~_BLOCKABLE);
---
Regards--
Subrata
Quoted 7 lines
I wonder whether gcc really complains about the case of
__get_user(set.sig[0], ...)failure.
Why, the case which sig[0] initialized and sig[1] uninitialized is NG and the case which sig[0] uninitialized and sig[1] initialized is OK.Thanks,
Hiroshi
Hiroshi Shimamoto
Acked-byQuoted 44 lines · Subrata Modak
Hello Hiroshi-san,
Quoted 29 lines · On Thu, 2009-05-14 at 09:24 +0900, Hiroshi Shimamoto wrote: H. Peter Anvin…
Quoted 29 lines
Quoted 28 lines · Ingo Molnar
Quoted 17 lines
Quoted 11 lines
arch/x86/kernel/signal.c unsigned long sys_sigreturn(struct pt_re · line 582
Quoted 11 lines
if (!access_ok(VERIFY_READ, frame,
sizeof(*frame)))
goto badframe;arch/x86/kernel/signal.c +4
-3-if (__get_user (set.sig[0 ], &frame->sc.oldmask) || (_NSIG_WORDS >1 - &&__copy_from_user (&set.sig[1 ], &frame->extramask, -sizeof (frame->extramask)))) + +if ( (__copy_from_user (&set.sig[1 ], &frame->extramask, +sizeof (frame->extramask)) && _NSIG_WORDS >1 ) || +__get_user (set.sig[0 ], &frame->sc.oldmask)) goto badframe;Quoted 2 lines
I'm not sure why this eliminates that warning.
set.sig[0] may not be initialized too, if__copy_from_user()failed.True, but only when either or both of
__copy_from_user()and (_NSIG_WORDS> 1) fails. But in all instances set.sig[1] gets initialized.Quoted 8 lines
Quoted 6 lines
I don't have enough time to look at this right now, sorry.
Another question,
__copy_from_user()will be called even if_NSIG_WORDSis less than 2, perhaps it never occurs.
I think, to check_NSIG_WORDS> 1 before calling__copy_from_user()is better.Fine. Let Ingo/Thomas/Peter decide whether they would like this fix or drop it.
If you get the Acked-by from Hiroshi-san it looks good to me. He modified this code last.
Quoted 10 lines
Quoted 2 lines
This seriously looks wrong to me. If
_NSIG_WORDS== 1, then calling__copy_from_userhere is a serious error.Right. If
_NSIG_WORDSis 1,sigset_tset has only sig[0], writing to set.sig[1] means stack corruption.Subrata, could you try like this?
if ((_NSIG_WORDS> 1 &&__copy_from_user(&set.sig[1], ...)||__get_user(set.sig[0], ...))
Quoted 4 lines
How about now ? Thanks for pointing that out. My mistake ;-)
Signed-off-by Subrata Modak <[email protected]>To: Hiroshi Shimamoto <[email protected]>,
looks good to me.
BTW who writes the description?
Quoted 41 lines
Cc: H. Peter Anvin <[email protected]>,
Cc: Ingo Molnar <[email protected]>,
Cc: [email protected],
Cc: Sachin P Sant <[email protected]>,
Cc: Andi Kleen <[email protected]>,
Cc: Andi Kleen <[email protected]>,
Cc: Linux Kernel <[email protected]>,
Cc: Balbir Singh <[email protected]>,
Cc: Thomas Gleixner <[email protected]>,
Cc: Ingo Molnar <[email protected]>
Subject: Re:[PATCH] Fix Warnining inarch/x86/kernel/signal.c
---arch/x86/kernel/signal.c +3
-4@@ -576,9 +576,9 @@ unsigned long sys_sigreturn(struct pt_reif (!access_ok (VERIFY_READ , frame,sizeof (*frame))) goto badframe; -if (__get_user (set.sig[0 ], &frame->sc.oldmask) || (_NSIG_WORDS >1 - &&__copy_from_user (&set.sig[1 ], &frame->extramask, -sizeof (frame->extramask)))) +if ((_NSIG_WORDS >1 &&__copy_from_user (&set.sig[1 ], + &frame->extramask,sizeof (frame->extramask))) || +__get_user (set.sig[0 ], &frame->sc.oldmask)) goto badframe;sigdelsetmask (&set, ~_BLOCKABLE); ---Regards--
SubrataQuoted 7 lines
I wonder whether gcc really complains about the case of
__get_user(set.sig[0], ...)failure.
Why, the case which sig[0] initialized and sig[1] uninitialized is NG and the case which sig[0] uninitialized and sig[1] initialized is OK.Thanks,
Hiroshi
Quoted 38 lines · Subrata Modak
Hello Hiroshi-san,
Quoted 34 lines · On Thu, 2009-05-14 at 09:24 +0900, Hiroshi Shimamoto wrote: H. Peter Anvin…
Quoted 24 lines
Quoted 23 lines · Ingo Molnar
Quoted 23 lines
Quoted 11 lines
arch/x86/kernel/signal.c unsigned long sys_sigreturn(struct pt_re · line 582
Quoted 11 lines
if (!access_ok(VERIFY_READ, frame,
sizeof(*frame)))
goto badframe;arch/x86/kernel/signal.c +4
-3-if (__get_user (set.sig[0 ], &frame->sc.oldmask) || (_NSIG_WORDS >1 - &&__copy_from_user (&set.sig[1 ], &frame->extramask, -sizeof (frame->extramask)))) + +if ( (__copy_from_user (&set.sig[1 ], &frame->extramask, +sizeof (frame->extramask)) && _NSIG_WORDS >1 ) || +__get_user (set.sig[0 ], &frame->sc.oldmask)) goto badframe;Quoted 2 lines
I'm not sure why this eliminates that warning.
set.sig[0] may not be initialized too, if__copy_from_user()failed.True, but only when either or both of
__copy_from_user()and (_NSIG_WORDS> 1) fails. But in all instances set.sig[1] gets initialized.Quoted 6 lines
I don't have enough time to look at this right now, sorry.
Another question,
__copy_from_user()will be called even if_NSIG_WORDSis less than 2, perhaps it never occurs.
I think, to check_NSIG_WORDS> 1 before calling__copy_from_user()is better.Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Fine. Let Ingo/Thomas/Peter decide whether they would like this fix or drop it.
If you get the Acked-by from Hiroshi-san it looks good to me. He modified this code last.
This seriously looks wrong to me. If
_NSIG_WORDS== 1, then calling__copy_from_userhere is a serious error.Right. If
_NSIG_WORDSis 1,sigset_tset has only sig[0], writing to set.sig[1] means stack corruption.
Quoted 7 lines
Quoted 5 lines
Subrata, could you try like this?
if ((_NSIG_WORDS> 1 &&__copy_from_user(&set.sig[1], ...)||__get_user(set.sig[0], ...))How about now ? Thanks for pointing that out. My mistake ;-)
Hi Subrata, I have a question.
Have you tried to compile on x86_64 whether the compiler claims the similar code in sys32_sigreturn() in arch/x86/ia32/ia32_signal.c?
Thanks,
Hiroshi
Quoted 45 lines · Hiroshi Shimamoto
Quoted 44 lines · Subrata Modak
Hello Hiroshi-san,
Quoted 39 lines · On Thu, 2009-05-14 at 09:24 +0900, Hiroshi Shimamoto wrote: H. Peter Anvin…
Quoted 24 lines
Quoted 23 lines · Ingo Molnar
Quoted 23 lines
Quoted 11 lines
arch/x86/kernel/signal.c unsigned long sys_sigreturn(struct pt_re · line 582
Quoted 11 lines
if (!access_ok(VERIFY_READ, frame,
sizeof(*frame)))
goto badframe;arch/x86/kernel/signal.c +4
-3-if (__get_user (set.sig[0 ], &frame->sc.oldmask) || (_NSIG_WORDS >1 - &&__copy_from_user (&set.sig[1 ], &frame->extramask, -sizeof (frame->extramask)))) + +if ( (__copy_from_user (&set.sig[1 ], &frame->extramask, +sizeof (frame->extramask)) && _NSIG_WORDS >1 ) || +__get_user (set.sig[0 ], &frame->sc.oldmask)) goto badframe;Quoted 2 lines
I'm not sure why this eliminates that warning.
set.sig[0] may not be initialized too, if__copy_from_user()failed.True, but only when either or both of
__copy_from_user()and (_NSIG_WORDS> 1) fails. But in all instances set.sig[1] gets initialized.Quoted 6 lines
I don't have enough time to look at this right now, sorry.
Another question,
__copy_from_user()will be called even if_NSIG_WORDSis less than 2, perhaps it never occurs.
I think, to check_NSIG_WORDS> 1 before calling__copy_from_user()is better.Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Fine. Let Ingo/Thomas/Peter decide whether they would like this fix or drop it.
If you get the Acked-by from Hiroshi-san it looks good to me. He modified this code last.
This seriously looks wrong to me. If
_NSIG_WORDS== 1, then calling__copy_from_userhere is a serious error.Right. If
_NSIG_WORDSis 1,sigset_tset has only sig[0], writing to set.sig[1] means stack corruption.Subrata, could you try like this?
if ((_NSIG_WORDS> 1 &&__copy_from_user(&set.sig[1], ...)||__get_user(set.sig[0], ...))
Quoted 5 lines
Quoted 1 line
How about now ? Thanks for pointing that out. My mistake ;-)
Hi Subrata, I have a question.
Have you tried to compile onx86_64whether the compiler claims the similar code insys32_sigreturn()inarch/x86/ia32/ia32_signal.c?
Oops. No, the compiler does not complain here. It simply compiles fine.
So, do you want to take a different view for the patch against arch/x86/kernel/signal.c, or, i would resend it with the following things fixed:
Quoted 5 lines
looks good to me.
BTW who writes the description?
Regards--
Subrata
Quoted 3 lines
Thanks,
Hiroshi
Quoted 50 lines · Subrata Modak
Quoted 44 lines · Hiroshi Shimamoto
Quoted 43 lines · Subrata Modak
Hello Hiroshi-san,
Quoted 39 lines · On Thu, 2009-05-14 at 09:24 +0900, Hiroshi Shimamoto wrote: H. Peter Anvin…
Quoted 24 lines
Quoted 23 lines · Ingo Molnar
Quoted 23 lines
Quoted 11 lines
arch/x86/kernel/signal.c unsigned long sys_sigreturn(struct pt_re · line 582
Quoted 11 lines
if (!access_ok(VERIFY_READ, frame,
sizeof(*frame)))
goto badframe;arch/x86/kernel/signal.c +4
-3-if (__get_user (set.sig[0 ], &frame->sc.oldmask) || (_NSIG_WORDS >1 - &&__copy_from_user (&set.sig[1 ], &frame->extramask, -sizeof (frame->extramask)))) + +if ( (__copy_from_user (&set.sig[1 ], &frame->extramask, +sizeof (frame->extramask)) && _NSIG_WORDS >1 ) || +__get_user (set.sig[0 ], &frame->sc.oldmask)) goto badframe;Quoted 2 lines
I'm not sure why this eliminates that warning.
set.sig[0] may not be initialized too, if__copy_from_user()failed.True, but only when either or both of
__copy_from_user()and (_NSIG_WORDS> 1) fails. But in all instances set.sig[1] gets initialized.Quoted 6 lines
I don't have enough time to look at this right now, sorry.
Another question,
__copy_from_user()will be called even if_NSIG_WORDSis less than 2, perhaps it never occurs.
I think, to check_NSIG_WORDS> 1 before calling__copy_from_user()is better.Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Fine. Let Ingo/Thomas/Peter decide whether they would like this fix or drop it.
If you get the Acked-by from Hiroshi-san it looks good to me. He modified this code last.
This seriously looks wrong to me. If
_NSIG_WORDS== 1, then calling__copy_from_userhere is a serious error.Right. If
_NSIG_WORDSis 1,sigset_tset has only sig[0], writing to set.sig[1] means stack corruption.Subrata, could you try like this?
if ((_NSIG_WORDS> 1 &&__copy_from_user(&set.sig[1], ...)||__get_user(set.sig[0], ...))Quoted 4 lines
Quoted 1 line
How about now ? Thanks for pointing that out. My mistake ;-)
Hi Subrata, I have a question.
Have you tried to compile onx86_64whether the compiler claims the similar code insys32_sigreturn()inarch/x86/ia32/ia32_signal.c?
Quoted 5 lines
Oops. No, the compiler does not complain here. It simply compiles fine.
So, do you want to take a different view for the patch against
arch/x86/kernel/signal.c, or, i would resend it with the following things fixed:
If you don't think this fix is urgent, could you please check whether that warning is false positive on 32bit or gcc for 64bit has an issue not to complain against ia32 part?
I think arch/x86/kernel/signal.c and arch/x86/ia32/ia32_signal.c should have the same code.
Thanks,
Hiroshi
Quoted 53 lines · Hiroshi Shimamoto
Quoted 52 lines · Subrata Modak
Quoted 44 lines · Hiroshi Shimamoto
Quoted 43 lines · Subrata Modak
Hello Hiroshi-san,
Quoted 39 lines · On Thu, 2009-05-14 at 09:24 +0900, Hiroshi Shimamoto wrote: H. Peter Anvin…
Quoted 24 lines
Quoted 23 lines · Ingo Molnar
Quoted 23 lines
Quoted 11 lines
arch/x86/kernel/signal.c unsigned long sys_sigreturn(struct pt_re · line 582
Quoted 11 lines
if (!access_ok(VERIFY_READ, frame,
sizeof(*frame)))
goto badframe;arch/x86/kernel/signal.c +4
-3-if (__get_user (set.sig[0 ], &frame->sc.oldmask) || (_NSIG_WORDS >1 - &&__copy_from_user (&set.sig[1 ], &frame->extramask, -sizeof (frame->extramask)))) + +if ( (__copy_from_user (&set.sig[1 ], &frame->extramask, +sizeof (frame->extramask)) && _NSIG_WORDS >1 ) || +__get_user (set.sig[0 ], &frame->sc.oldmask)) goto badframe;Quoted 2 lines
I'm not sure why this eliminates that warning.
set.sig[0] may not be initialized too, if__copy_from_user()failed.True, but only when either or both of
__copy_from_user()and (_NSIG_WORDS> 1) fails. But in all instances set.sig[1] gets initialized.Quoted 6 lines
I don't have enough time to look at this right now, sorry.
Another question,
__copy_from_user()will be called even if_NSIG_WORDSis less than 2, perhaps it never occurs.
I think, to check_NSIG_WORDS> 1 before calling__copy_from_user()is better.Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Fine. Let Ingo/Thomas/Peter decide whether they would like this fix or drop it.
If you get the Acked-by from Hiroshi-san it looks good to me. He modified this code last.
This seriously looks wrong to me. If
_NSIG_WORDS== 1, then calling__copy_from_userhere is a serious error.Right. If
_NSIG_WORDSis 1,sigset_tset has only sig[0], writing to set.sig[1] means stack corruption.Subrata, could you try like this?
if ((_NSIG_WORDS> 1 &&__copy_from_user(&set.sig[1], ...)||__get_user(set.sig[0], ...))Quoted 4 lines
Quoted 1 line
How about now ? Thanks for pointing that out. My mistake ;-)
Hi Subrata, I have a question.
Have you tried to compile onx86_64whether the compiler claims the similar code insys32_sigreturn()inarch/x86/ia32/ia32_signal.c?Oops. No, the compiler does not complain here. It simply compiles fine.
Quoted 8 lines
Quoted 3 lines
So, do you want to take a different view for the patch against
arch/x86/kernel/signal.c, or, i would resend it with the following things fixed:If you don't think this fix is urgent, could you please check whether that warning is false positive on 32bit or gcc for 64bit has an issue not to complain against ia32 part?
I will try to find out.
Quoted 2 lines
I think
arch/x86/kernel/signal.candarch/x86/ia32/ia32_signal.cshould have the same code.
Sure. Not a problem. Please drop the patch for the time being.
Regards--
Subrata
Quoted 3 lines
Thanks,
Hiroshi