Module Name:    src
Committed By:   riastradh
Date:           Sun Jul 10 13:57:14 UTC 2022

Modified Files:
        src/sys/compat/common: tty_43.c

Log Message:
tty_43: Do unsigned arithmetic to avoid shift into sign bits.

Omit input validation -- it's not a great idea for compatibility with
historical kernels, since they ignored the bits instead of rejecting
them if set.  With unsigned arithmetic, we get the same semantics as
was previously assumed (discarding bits that get shifted into the
sign bit or off into oblivion) without the formal undefined
behaviour.

Reported-by: syzbot+e408764cdd8c0c0ff...@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=8318f0039e68187cd8d27b2c520816fff3f7266a


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/compat/common/tty_43.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/common/tty_43.c
diff -u src/sys/compat/common/tty_43.c:1.39 src/sys/compat/common/tty_43.c:1.40
--- src/sys/compat/common/tty_43.c:1.39	Sat Oct 10 15:59:41 2020
+++ src/sys/compat/common/tty_43.c	Sun Jul 10 13:57:14 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty_43.c,v 1.39 2020/10/10 15:59:41 christos Exp $	*/
+/*	$NetBSD: tty_43.c,v 1.40 2022/07/10 13:57:14 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_43.c,v 1.39 2020/10/10 15:59:41 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_43.c,v 1.40 2022/07/10 13:57:14 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -220,11 +220,9 @@ compat_43_ttioctl(struct tty *tp, u_long
 	case TIOCLBIC:
 	case TIOCLSET: {
 		struct termios term;
-		int argbits, flags;
+		unsigned argbits, flags;
 
 		argbits = *(int *)data;
-		if (argbits < 0)
-			return EINVAL;
 
 		mutex_spin_enter(&tty_lock);
 		term = tp->t_termios;

Reply via email to