Module Name:    src
Committed By:   kamil
Date:           Wed Jul  4 01:17:32 UTC 2018

Modified Files:
        src/sys/sys: mman.h

Log Message:
Avoid undefined operation in signed integer shift in MAP_ALIGNED()

Cast the shifted byte to unsigned int.

sys/uvm/uvm_mmap.c:914:19, left shift of 255 by 24 places cannot be represented 
in type 'int'

Detected with Kernel Undefined Behavior Sanitizer.

Reported by <Harry Pantazis>


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/sys/mman.h

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

Modified files:

Index: src/sys/sys/mman.h
diff -u src/sys/sys/mman.h:1.53 src/sys/sys/mman.h:1.54
--- src/sys/sys/mman.h:1.53	Wed Jan 24 09:04:45 2018
+++ src/sys/sys/mman.h	Wed Jul  4 01:17:32 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mman.h,v 1.53 2018/01/24 09:04:45 skrll Exp $	*/
+/*	$NetBSD: mman.h,v 1.54 2018/07/04 01:17:32 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1993
@@ -106,7 +106,7 @@ typedef	__off_t		off_t;		/* file offset 
  * Alignment (expressed in log2).  Must be >= log2(PAGE_SIZE) and
  * < # bits in a pointer (32 or 64).
  */
-#define	MAP_ALIGNED(n)		((n) << MAP_ALIGNMENT_SHIFT)
+#define	MAP_ALIGNED(n)		((unsigned int)(n) << MAP_ALIGNMENT_SHIFT)
 #define	MAP_ALIGNMENT_SHIFT	24
 #define	MAP_ALIGNMENT_MASK	MAP_ALIGNED(0xff)
 #define	MAP_ALIGNMENT_64KB	MAP_ALIGNED(16)	/* 2^16 */

Reply via email to