Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Add a check to prevent shift by -1. Not really impo...



details:   https://anonhg.NetBSD.org/src/rev/0e58de92bcfa
branches:  trunk
changeset: 943101:0e58de92bcfa
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Aug 26 16:36:32 2020 +0000

description:
Add a check to prevent shift by -1. Not really important in this case,
but to appease KUBSAN.

Reported-by: syzbot+4026e8201b6b484b8cb4%syzkaller.appspotmail.com@localhost

diffstat:

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

diffs (28 lines):

diff -r 128e1ee03d56 -r 0e58de92bcfa sys/kern/tty.c
--- a/sys/kern/tty.c    Wed Aug 26 16:33:03 2020 +0000
+++ b/sys/kern/tty.c    Wed Aug 26 16:36:32 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.288 2020/06/22 16:29:24 maxv Exp $   */
+/*     $NetBSD: tty.c,v 1.289 2020/08/26 16:36:32 maxv Exp $   */
 
 /*-
  * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.288 2020/06/22 16:29:24 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.289 2020/08/26 16:36:32 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -226,6 +226,9 @@
 static int
 tty_get_qsize(int *qsize, int newsize)
 {
+       if (newsize == 0)
+               return EINVAL;
+
        newsize = 1 << ilog2(newsize);  /* Make it a power of two */
 
        if (newsize < TTY_MINQSIZE || newsize > TTY_MAXQSIZE)



Home | Main Index | Thread Index | Old Index