Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Avoid -LONG_MIN msgtyp in msgrcv(2) and treat it as...



details:   https://anonhg.NetBSD.org/src/rev/d3ea59b08150
branches:  trunk
changeset: 845526:d3ea59b08150
user:      kamil <kamil%NetBSD.org@localhost>
date:      Fri Oct 04 23:20:22 2019 +0000

description:
Avoid -LONG_MIN msgtyp in msgrcv(2) and treat it as LONG_MAX

This logic (found in Linux) avoids undefined behavior.

Reported-by: syzbot+8af00519a8688d9903ca%syzkaller.appspotmail.com@localhost

diffstat:

 sys/kern/sysv_msg.c |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (26 lines):

diff -r 37b033698f1a -r d3ea59b08150 sys/kern/sysv_msg.c
--- a/sys/kern/sysv_msg.c       Fri Oct 04 23:06:19 2019 +0000
+++ b/sys/kern/sysv_msg.c       Fri Oct 04 23:20:22 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysv_msg.c,v 1.75 2019/08/07 00:38:02 pgoyette Exp $   */
+/*     $NetBSD: sysv_msg.c,v 1.76 2019/10/04 23:20:22 kamil Exp $      */
 
 /*-
  * Copyright (c) 1999, 2006, 2007 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysv_msg.c,v 1.75 2019/08/07 00:38:02 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_msg.c,v 1.76 2019/10/04 23:20:22 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sysv.h"
@@ -1100,6 +1100,7 @@
                                 */
 
                                if (msgtyp != msghdr->msg_type &&
+                                   msgtyp != LONG_MIN &&
                                    msghdr->msg_type > -msgtyp)
                                        continue;
 



Home | Main Index | Thread Index | Old Index