signal: Guard against negative signal numbers in copy_siginfo_from_user32
authorEric W. Biederman <ebiederm@xmission.com>
Thu, 11 Oct 2018 01:29:44 +0000 (20:29 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Thu, 11 Oct 2018 01:34:14 +0000 (20:34 -0500)
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" <ebiederm@xmission.com>
include/linux/signal.h
kernel/signal.c

index 706a499d1eb1d36f4afa33f4286c41f80e2601e3..200ed96a05afea6b72781960fd11e2f4a0b62217 100644 (file)
@@ -40,7 +40,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.
index 5f5bf374512b889ad360e2e0d59a061edca818ed..4fd431ce4f91e101f3d75d83cf9284407157d16a 100644 (file)
@@ -2879,7 +2879,7 @@ static bool known_siginfo_layout(unsigned sig, int si_code)
        return false;
 }
 
-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)) {