Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Avoid undefined operation in signed integer shift in...
details: https://anonhg.NetBSD.org/src/rev/2222cd4af62c
branches: trunk
changeset: 991245:2222cd4af62c
user: kamil <kamil%NetBSD.org@localhost>
date: Wed Jul 04 01:17:32 2018 +0000
description:
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>
diffstat:
sys/sys/mman.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diffs (18 lines):
diff -r d6fe2d253dcd -r 2222cd4af62c sys/sys/mman.h
--- a/sys/sys/mman.h Wed Jul 04 00:35:33 2018 +0000
+++ b/sys/sys/mman.h Wed Jul 04 01:17:32 2018 +0000
@@ -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 @@
* 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 */
Home |
Main Index |
Thread Index |
Old Index