do_sigaltstack: avoid copying 'stack_t' as a structure to user space
commit108c7d85e4f7e2c5e01dd554d7a13bb0dbab7768
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 1 Aug 2009 17:34:56 +0000 (1 10:34 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 9 Sep 2009 03:33:50 +0000 (8 20:33 -0700)
treecc4a7bbcc315ff5be3e2f19e3d9ace9ca57042a4
parenteec3155c9187314b70ae4e495fea1de57ffe4783
do_sigaltstack: avoid copying 'stack_t' as a structure to user space

commit 0083fc2c50e6c5127c2802ad323adf8143ab7856 upstream.

Ulrich Drepper correctly points out that there is generally padding in
the structure on 64-bit hosts, and that copying the structure from
kernel to user space can leak information from the kernel stack in those
padding bytes.

Avoid the whole issue by just copying the three members one by one
instead, which also means that the function also can avoid the need for
a stack frame.  This also happens to match how we copy the new structure
from user space, so it all even makes sense.

[ The obvious solution of adding a memset() generates horrid code, gcc
  does really stupid things. ]

Reported-by: Ulrich Drepper <drepper@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
kernel/signal.c