Skip to content

Commit 3c0f72b

Browse files
xiongzhongjiangZhengShunQian
authored andcommitted
kernel/signal.c: avoid undefined behaviour in kill_something_info
commit 4ea7701 upstream. When running kill(72057458746458112, 0) in userspace I hit the following issue. UBSAN: Undefined behaviour in kernel/signal.c:1462:11 negation of -2147483648 cannot be represented in type 'int': CPU: 226 PID: 9849 Comm: test Tainted: G B ---- ------- 3.10.0-327.53.58.70.x86_64_ubsan+ torvalds#116 Hardware name: Huawei Technologies Co., Ltd. RH8100 V3/BC61PBIA, BIOS BLHSV028 11/11/2014 Call Trace: dump_stack+0x19/0x1b ubsan_epilogue+0xd/0x50 __ubsan_handle_negate_overflow+0x109/0x14e SYSC_kill+0x43e/0x4d0 SyS_kill+0xe/0x10 system_call_fastpath+0x16/0x1b Add code to avoid the UBSAN detection. [[email protected]: tweak comment] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: zhongjiang <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Xishi Qiu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Cc: Guenter Roeck <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3eaafab commit 3c0f72b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kernel/signal.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,10 @@ static int kill_something_info(int sig, struct siginfo *info, pid_t pid)
13921392
return ret;
13931393
}
13941394

1395+
/* -INT_MIN is undefined. Exclude this case to avoid a UBSAN warning */
1396+
if (pid == INT_MIN)
1397+
return -ESRCH;
1398+
13951399
read_lock(&tasklist_lock);
13961400
if (pid != -1) {
13971401
ret = __kill_pgrp_info(sig, info,

0 commit comments

Comments
 (0)