Re: [3.1 patch] x86: default to vsyscall=native

From: Andrew Lutomirski
Date: Thu Oct 06 2011 - 20:48:58 EST

On Thu, Oct 6, 2011 at 11:34 AM, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Thu, Oct 6, 2011 at 11:16 AM, Andrew Lutomirski <luto@xxxxxxx> wrote:
>> Fixing it will be annoying because the attached fancier version needs
>> to work, too.  I could implement the whole mess in software, but it
>> might be nicer to arrange for uaccess errors to stash some information
>> somewhere (like in the thread_struct cr2 variable).
> That should be easy enough to do. Just add it to the
> "fixup_exception()" case in no_context().

This code is rather messy. We stash the cr2, err, and trap fields of
sigcontext in thread_struct and we *never* reset them until the next
segfault. So userspace sees stale garbage on every signal that isn't
a (genuine) segfault. I can imagine this breaking UML is remarkably
bizarre ways even without vsyscall emulation because UML actually
seems to rely on that stuff to determine the source of a signal.

The nice fix would be to move this information into siginfo. cr2
appears to be duplicated by sa_addr. trap_no is apparently redundant
except for SIGTRAP. error_code is interesting. Any objection to
using some padding bytes to move this into siginfo and remove the
fields (except for uaccess) from thread_struct? Better ideas?

Without some kind of cleanup, I'm a bit worried about breakage if a
uaccess fault happens between something else setting the flags and a
signal getting delivered, resulting in corruption of the sigcontext,
unless I add more crud to thread_struct and waste memory for every

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at