Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Correct unportable signed integer left shift in i38...



details:   https://anonhg.NetBSD.org/src/rev/6995772d3698
branches:  trunk
changeset: 363014:6995772d3698
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sat Jul 07 21:35:16 2018 +0000

description:
Correct unportable signed integer left shift in i386/amd64 tss code

Change the type of IOMAP_INVALOFF to unsigned int.

sys/arch/amd64/amd64/machdep.c:518:42, left shift of 65535 by 16 places cannot be represented in type 'int'

Detected with Kernel Undefined Behavior Sanitizer.

diffstat:

 sys/arch/amd64/include/tss.h |  4 ++--
 sys/arch/i386/include/tss.h  |  4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r 6c8b0106c03b -r 6995772d3698 sys/arch/amd64/include/tss.h
--- a/sys/arch/amd64/include/tss.h      Sat Jul 07 20:16:16 2018 +0000
+++ b/sys/arch/amd64/include/tss.h      Sat Jul 07 21:35:16 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tss.h,v 1.7 2018/01/04 14:02:23 maxv Exp $     */
+/*     $NetBSD: tss.h,v 1.8 2018/07/07 21:35:16 kamil Exp $    */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -63,7 +63,7 @@
  * I/O bitmap offset beyond TSS's segment limit means no bitmaps.
  * (i.e. any I/O attempt generates an exception.)
  */
-#define        IOMAP_INVALOFF  0xffff
+#define        IOMAP_INVALOFF  0xffffu
 
 /*
  * If we have an I/O bitmap, there is only one valid offset.
diff -r 6c8b0106c03b -r 6995772d3698 sys/arch/i386/include/tss.h
--- a/sys/arch/i386/include/tss.h       Sat Jul 07 20:16:16 2018 +0000
+++ b/sys/arch/i386/include/tss.h       Sat Jul 07 21:35:16 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tss.h,v 1.11 2018/01/04 14:02:23 maxv Exp $    */
+/*     $NetBSD: tss.h,v 1.12 2018/07/07 21:35:16 kamil Exp $   */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -74,7 +74,7 @@
  * I/O bitmap offset beyond TSS's segment limit means no bitmaps.
  * (i.e. any I/O attempt generates an exception.)
  */
-#define        IOMAP_INVALOFF  0xffff
+#define        IOMAP_INVALOFF  0xffffu
 
 /*
  * If we have an I/O bitmap, there is only one valid offset.



Home | Main Index | Thread Index | Old Index