Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Set sc_mask correctly in selsysinit() to avoid unde...



details:   https://anonhg.NetBSD.org/src/rev/34c74a76eb42
branches:  trunk
changeset: 457986:34c74a76eb42
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Fri Jul 26 05:37:59 2019 +0000

description:
Set sc_mask correctly in selsysinit() to avoid undefined behavior.
Found by KUBSan.

diffstat:

 sys/kern/sys_select.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r aceb94369a59 -r 34c74a76eb42 sys/kern/sys_select.c
--- a/sys/kern/sys_select.c     Fri Jul 26 05:24:04 2019 +0000
+++ b/sys/kern/sys_select.c     Fri Jul 26 05:37:59 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_select.c,v 1.45 2019/05/08 00:55:18 christos Exp $ */
+/*     $NetBSD: sys_select.c,v 1.46 2019/07/26 05:37:59 msaitoh Exp $  */
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.45 2019/05/08 00:55:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.46 2019/07/26 05:37:59 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -826,7 +826,7 @@
                sc->sc_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SCHED);
                sleepq_init(&sc->sc_sleepq);
                sc->sc_ncoll = 0;
-               sc->sc_mask = (1 << index);
+               sc->sc_mask = __BIT(index);
                selcluster[index] = sc;
        }
        ci->ci_data.cpu_selcluster = sc;



Home | Main Index | Thread Index | Old Index