From: Eric W. Biederman Date: Thu, 11 Oct 2018 01:29:44 +0000 (-0500) Subject: signal: Guard against negative signal numbers in copy_siginfo_from_user32 X-Git-Tag: rel_imx_4.19.35_1.1.0~8833 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=04eb71942e858c840d1e3a63d81d9bec83b157c5;p=linux.git signal: Guard against negative signal numbers in copy_siginfo_from_user32 commit a36700589b85443e28170be59fa11c8a104130a5 upstream. While fixing an out of bounds array access in known_siginfo_layout reported by the kernel test robot it became apparent that the same bug exists in siginfo_layout and affects copy_siginfo_from_user32. The straight forward fix that makes guards against making this mistake in the future and should keep the code size small is to just take an unsigned signal number instead of a signed signal number, as I did to fix known_siginfo_layout. Cc: stable@vger.kernel.org Fixes: cc731525f26a ("signal: Remove kernel interal si_code magic") Signed-off-by: "Eric W. Biederman" Signed-off-by: Greg Kroah-Hartman --- diff --git a/include/linux/signal.h b/include/linux/signal.h index 3d4cd5db30a9..e4d01469ed60 100644 --- a/include/linux/signal.h +++ b/include/linux/signal.h @@ -36,7 +36,7 @@ enum siginfo_layout { SIL_SYS, }; -enum siginfo_layout siginfo_layout(int sig, int si_code); +enum siginfo_layout siginfo_layout(unsigned sig, int si_code); /* * Define some primitives to manipulate sigset_t. diff --git a/kernel/signal.c b/kernel/signal.c index 092fb48ed845..edc28afc9fb4 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2847,7 +2847,7 @@ COMPAT_SYSCALL_DEFINE2(rt_sigpending, compat_sigset_t __user *, uset, } #endif -enum siginfo_layout siginfo_layout(int sig, int si_code) +enum siginfo_layout siginfo_layout(unsigned sig, int si_code) { enum siginfo_layout layout = SIL_KILL; if ((si_code > SI_USER) && (si_code < SI_KERNEL)) {