public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Subrata Modak <subrata@linux.vnet.ibm.com>
To: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Balbir Singh <balbir@linux.vnet.ibm.com>,
	Andi Kleen <andi@firstfloor.org>, Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, Linux Kernel <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Sachin P Sant <sachinp@linux.vnet.ibm.com>,
	Andi Kleen <ak@linux.intel.com>, Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] Fix Warnining in arch/x86/kernel/signal.c
Date: Mon, 18 May 2009 12:08:12 +0530	[thread overview]
Message-ID: <1242628692.1750.1.camel@subratamodak.linux.ibm.com> (raw)
In-Reply-To: <4A10D7CE.90005@ct.jp.nec.com>

On Mon, 2009-05-18 at 12:36 +0900, Hiroshi Shimamoto wrote:
> Subrata Modak wrote:
> > On Fri, 2009-05-15 at 12:32 +0900, Hiroshi Shimamoto wrote:
> >> Subrata Modak wrote:
> >>> Hello Hiroshi-san,
> >>>
> >>> On Thu, 2009-05-14 at 09:24 +0900, Hiroshi Shimamoto wrote:
> >>> H. Peter Anvin wrote:
> >>>>> Ingo Molnar wrote:
> >>>>>>>>>  
> >>>>>>>>>         if (!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 ( (__copy_from_user(&set.sig[1], &frame->extramask,
> >>>>>>>>> +                sizeof(frame->extramask)) && _NSIG_WORDS > 1) || 
> >>>>>>>>> +                __get_user(set.sig[0], &frame->sc.oldmask))
> >>>>>>>>>                 goto badframe;
> >>>>>>>> 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.
> >>>>>>>
> >>>>>>>> I don't have enough time to look at this right now, sorry.
> >>>>>>>>
> >>>>>>>> Another question, __copy_from_user() will be called even if
> >>>>>>>> _NSIG_WORDS is 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.
> >>>>>>
> >>>>> This seriously looks wrong to me.  If _NSIG_WORDS == 1, then calling
> >>>>> __copy_from_user here is a serious error.
> >>>> Right. If _NSIG_WORDS is 1, sigset_t set 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 ;-)
> >> 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?
> > 
> > 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 will try to find out.

> I think arch/x86/kernel/signal.c and arch/x86/ia32/ia32_signal.c should
> have the same code.

Sure. Not a problem. Please drop the patch for the time being.

Regards--
Subrata

> 
> Thanks,
> Hiroshi


  reply	other threads:[~2009-05-18  6:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-14  9:12 Re:[PATCH] Fix Warnining in arch/x86/kernel/signal.c Subrata Modak
2009-05-15  2:57 ` [PATCH] " Hiroshi Shimamoto
2009-05-15  3:32 ` Hiroshi Shimamoto
2009-05-15 10:16   ` Subrata Modak
2009-05-18  3:36     ` Hiroshi Shimamoto
2009-05-18  6:38       ` Subrata Modak [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-05-14  6:30 Subrata Modak
2009-05-14  7:38 ` [PATCH] " Hiroshi Shimamoto
2009-05-12 15:56 Subrata Modak
2009-05-13  2:20 ` Hiroshi Shimamoto
2009-05-13  9:06   ` Subrata Modak
2009-05-13 13:53     ` Ingo Molnar
2009-05-13 20:23       ` H. Peter Anvin
2009-05-14  0:24         ` Hiroshi Shimamoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1242628692.1750.1.camel@subratamodak.linux.ibm.com \
    --to=subrata@linux.vnet.ibm.com \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=h-shimamoto@ct.jp.nec.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=sachinp@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox