Amanieu d'Antras 3c00cb5e68 signal: fix information leak in copy_siginfo_from_user32
This function can leak kernel stack data when the user siginfo_t has a
positive si_code value.  The top 16 bits of si_code descibe which fields
in the siginfo_t union are active, but they are treated inconsistently
between copy_siginfo_from_user32, copy_siginfo_to_user32 and
copy_siginfo_to_user.

copy_siginfo_from_user32 is called from rt_sigqueueinfo and
rt_tgsigqueueinfo in which the user has full control overthe top 16 bits
of si_code.

This fixes the following information leaks:
x86:   8 bytes leaked when sending a signal from a 32-bit process to
       itself. This leak grows to 16 bytes if the process uses x32.
       (si_code = __SI_CHLD)
x86:   100 bytes leaked when sending a signal from a 32-bit process to
       a 64-bit process. (si_code = -1)
sparc: 4 bytes leaked when sending a signal from a 32-bit process to a
       64-bit process. (si_code = any)

parsic and s390 have similar bugs, but they are not vulnerable because
rt_[tg]sigqueueinfo have checks that prevent sending a positive si_code
to a different process.  These bugs are also fixed for consistency.

Signed-off-by: Amanieu d'Antras <amanieu@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-08-07 04:39:40 +03:00
..
2014-04-18 14:20:41 +02:00
2014-11-27 09:32:58 +11:00
2014-12-11 17:48:14 -08:00
2014-08-13 15:13:42 +10:00
2014-09-25 23:14:46 +10:00
2014-11-03 12:12:32 +11:00
2014-11-03 12:12:32 +11:00
2011-03-31 11:26:23 -03:00
2015-02-17 14:34:51 -08:00
2015-07-01 19:40:18 -07:00
2015-03-24 13:15:52 +11:00
2014-12-11 17:48:14 -08:00
2011-03-31 11:26:23 -03:00
2014-09-25 23:14:41 +10:00
2014-08-06 13:04:32 +02:00
2011-03-31 11:26:23 -03:00
2012-03-28 18:30:02 +01:00
2015-04-07 17:15:13 +10:00
2015-06-24 17:49:38 -07:00
2015-05-14 16:59:21 +10:00