From: Andrew Lutomirski <luto@mit.edu>
To: Rakib Mullick <rakib.mullick@gmail.com>
Cc: mingo@elte.hu, hpa@zytor.com, tglx@linutronix.de, x86@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86, vsyscall: Fix build warning in vsyscall_64.c
Date: Sun, 12 Jun 2011 22:52:17 -0400 [thread overview]
Message-ID: <BANLkTimv6F8NsH0Lg7q6gi1-oiBv8nUrSA@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi=yEo9fcXW8SqUCtSOag7Mn_+Ni9Q@mail.gmail.com>
On Sun, Jun 12, 2011 at 1:12 AM, Rakib Mullick <rakib.mullick@gmail.com> wrote:
> On Sat, Jun 11, 2011 at 5:01 PM, Andrew Lutomirski <luto@mit.edu> wrote:
>> On Sat, Jun 11, 2011 at 3:31 AM, Rakib Mullick <rakib.mullick@gmail.com> wrote:
>>> Due to commit 5cec93c216db77 (x86-64: Emulate legacy vsyscalls), we get the following warning:
>>>
>>> arch/x86/kernel/vsyscall_64.c: In function ‘do_emulate_vsyscall’:
>>> arch/x86/kernel/vsyscall_64.c:111:7: warning: ‘ret’ may be used uninitialized in this function
>>
>> What's the code path that uses ret without initializing it?
>>
> In case of, vsyscall_nr is default it might gets uninitialized. And
> current code already treats it as a bug.
>
>>> - if (ret == -EFAULT) {
>>> + if (ret == -EFAULT || ret == -EINVAL) {
>>> /*
>>> * Bad news -- userspace fed a bad pointer to a vsyscall.
>>> *
>>
>> EINVAL doesn't seem like grounds to fault. (I'm not sure how to get
>> EINVAL from time, gettimeofday, or getcpu, but in case there is, we
>> should return it back to userspace.)
>>
> If ret = EINVAL, then it means vsyscall_nr doesn't any of
> gettimeofday, time or getcpu. So, I grounds it into fault. In case of
> gettimeofday, EINVAL may gets return. But, maybe not in case of time
> or getcpu. So, maybe we need to check EINVAL in case of gettimeofday
> and maybe should separate EINVAL and EFAULT.
I think there are three separate issues here:
1. Can ret be used uninitialized? I say no, even as seen by the
compiler. If vsyscall_nr is 0, 1, or 2, then ret is initialized. If
vsyscall_nr is 3, then the BUG gets hit. BUG is defined as some
assembly magic followed by unreachable(), and the compiler is supposed
to know that code after unreachable() is qunreachable. So how can ret
be used uninitialized?
What version of gcc do you have? gcc (GCC) 4.6.0 20110530 (Red Hat
4.6.0-9) does not produce this warning.
2. Is the BUG correct? I say yes. vsyscall_nr can only be 0, 1, 2,
or 3 (see the function that generates it), and the only way that 3
could happen is if regs->ip == 0xffffffffff600c02. That can't happen
because the instruction at ...601 is int3.
3. Should the test for EFAULT be changed to EINVAL? I can't see why.
We need to preserve userspace ABI, and userspace expects vsyscalls
that fail for reasons other than a fault to return an error, not
segfault the caller.
Note that regs->as *is* the return value, so we're not ignoring errors.
--Andy
next prev parent reply other threads:[~2011-06-13 2:52 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-11 7:31 Rakib Mullick
2011-06-11 11:01 ` Andrew Lutomirski
2011-06-12 5:12 ` Rakib Mullick
2011-06-13 2:52 ` Andrew Lutomirski [this message]
2011-06-13 4:54 ` Rakib Mullick
2011-06-13 8:45 ` Rakib Mullick
2011-06-13 18:06 ` Andrew Lutomirski
2011-06-14 17:43 ` Rakib Mullick
2011-06-14 18:03 ` Andy Lutomirski
2011-06-14 21:16 ` Ingo Molnar
2011-06-14 21:24 ` Linus Torvalds
2011-06-14 21:31 ` Ingo Molnar
2011-06-14 21:33 ` Andrew Lutomirski
2011-06-15 5:59 ` Rakib Mullick
2011-06-15 7:25 ` Ingo Molnar
2011-06-15 18:49 ` Linus Torvalds
2011-06-15 19:24 ` Andrew Lutomirski
2011-06-15 19:32 ` Linus Torvalds
2011-06-15 19:51 ` Andrew Lutomirski
2011-06-13 9:29 ` Ingo Molnar
2011-06-13 13:03 ` Andrew Lutomirski
2011-06-13 14:14 ` Ingo Molnar
2011-06-13 14:18 ` Andrew Lutomirski
2011-06-13 17:05 ` Rakib Mullick
2011-06-13 17:06 ` Andrew Lutomirski
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=BANLkTimv6F8NsH0Lg7q6gi1-oiBv8nUrSA@mail.gmail.com \
--to=luto@mit.edu \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rakib.mullick@gmail.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
all inboxes | Powered by JetHome®