Module Name:    src
Committed By:   kamil
Date:           Tue Jul  3 11:45:54 UTC 2018

Modified Files:
        src/sys/arch/x86/x86: intr.c

Log Message:
Avoid unportable signed integer left shift in intr_calculatemasks()

Detected with Kernel Undefined Behavior Sanitizer.

There were at least two places reported, for consistency fix all the
left shift bit shift.

src/sys/arch/x86/x86/intr.c:339:22, left shift of 1 by 31 places cannot be 
represented in type 'int'
src/sys/arch/x86/x86/intr.c:347:15, left shift of 1 by 31 places cannot be 
represented in type 'int'

Reported by <Harry Pantazis>


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sys/arch/x86/x86/intr.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/arch/x86/x86/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.126 src/sys/arch/x86/x86/intr.c:1.127
--- src/sys/arch/x86/x86/intr.c:1.126	Sun Jun 24 13:35:33 2018
+++ src/sys/arch/x86/x86/intr.c	Tue Jul  3 11:45:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.126 2018/06/24 13:35:33 jdolecek Exp $	*/
+/*	$NetBSD: intr.c,v 1.127 2018/07/03 11:45:54 kamil Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.126 2018/06/24 13:35:33 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.127 2018/07/03 11:45:54 kamil Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -334,18 +334,18 @@ intr_calculatemasks(struct cpu_info *ci)
 			continue;
 		}
 		for (q = ci->ci_isources[irq]->is_handlers; q; q = q->ih_next)
-			levels |= 1 << q->ih_level;
+			levels |= 1U << q->ih_level;
 		intrlevel[irq] = levels;
 		if (levels)
-			unusedirqs &= ~(1 << irq);
+			unusedirqs &= ~(1U << irq);
 	}
 
 	/* Then figure out which IRQs use each level. */
 	for (level = 0; level < NIPL; level++) {
 		int irqs = 0;
 		for (irq = 0; irq < MAX_INTR_SOURCES; irq++)
-			if (intrlevel[irq] & (1 << level))
-				irqs |= 1 << irq;
+			if (intrlevel[irq] & (1U << level))
+				irqs |= 1U << irq;
 		ci->ci_imask[level] = irqs | unusedirqs;
 	}
 

Reply via email to