Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Avoid signed integer overflow for -lwp where lwp is...



details:   https://anonhg.NetBSD.org/src/rev/40c6911d9234
branches:  trunk
changeset: 455262:40c6911d9234
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sat Oct 12 12:04:37 2019 +0000

description:
Avoid signed integer overflow for -lwp where lwp is INT_MIN

Reported-by: syzbot+68b80b44b898e66da3fc%syzkaller.appspotmail.com@localhost

diffstat:

 sys/kern/sys_ptrace_common.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (32 lines):

diff -r 2e580ef98455 -r 40c6911d9234 sys/kern/sys_ptrace_common.c
--- a/sys/kern/sys_ptrace_common.c      Sat Oct 12 10:55:23 2019 +0000
+++ b/sys/kern/sys_ptrace_common.c      Sat Oct 12 12:04:37 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_ptrace_common.c,v 1.66 2019/10/09 13:19:43 kamil Exp $     */
+/*     $NetBSD: sys_ptrace_common.c,v 1.67 2019/10/12 12:04:37 kamil Exp $     */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.66 2019/10/09 13:19:43 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.67 2019/10/12 12:04:37 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -1202,8 +1202,12 @@
                                signo = tmp;
                                tmp = 0;        /* don't search for LWP */
                        }
-               } else
+               } else if (tmp == INT_MIN) {
+                       error = ESRCH;
+                       break;
+               } else {
                        tmp = -tmp;
+               }
 
                if (tmp > 0) {
                        if (req == PT_DETACH) {



Home | Main Index | Thread Index | Old Index