Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Disable __NO_STRICT_ALIGNMENT on amd64/i386 for UBS...



details:   https://anonhg.NetBSD.org/src/rev/7b7bdb917444
branches:  trunk
changeset: 459750:7b7bdb917444
user:      kamil <kamil%NetBSD.org@localhost>
date:      Mon Sep 23 23:06:26 2019 +0000

description:
Disable __NO_STRICT_ALIGNMENT on amd64/i386 for UBSan builds

This change allows to pick code paths in the kernel that are tuned for
alignment sensitive (and stricted in C meaning) code paths. In particular
the IPv6 code uses this heavily and skips whenever possible the process
of aligning of networking data.

With this modification all ATF tests are executed on amd64 without
triggering any UBSan reports in dmesg.

In theory __NO_STRICT_ALIGNMENT could be tuned for vax and m68k, however
these machines are still unsupported in LLVM sanitizers and syzkaller.

sys/netinet6/scope6.c:404:6, member access within misaligned address 0xfffffaea81276086 for type 'struct in6_addr' which requires 4 byte alignment
Reported-by: syzbot+a86f58d17685317b3df9%syzkaller.appspotmail.com@localhost

sys/net/rtsock_shared.c:629:41, member access within misaligned address 0xffffddb5db3ff04c for type 'struct rt_msghdr50' which requires 8 byte alignment
Reported-by: syzbot+0a3a022bc9d2b8880c16%syzkaller.appspotmail.com@localhost

diffstat:

 sys/arch/amd64/include/types.h |  5 ++++-
 sys/arch/i386/include/types.h  |  5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diffs (42 lines):

diff -r 194594f3702e -r 7b7bdb917444 sys/arch/amd64/include/types.h
--- a/sys/arch/amd64/include/types.h    Mon Sep 23 21:07:50 2019 +0000
+++ b/sys/arch/amd64/include/types.h    Mon Sep 23 23:06:26 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: types.h,v 1.61 2019/09/22 10:35:12 maxv Exp $  */
+/*     $NetBSD: types.h,v 1.62 2019/09/23 23:06:26 kamil Exp $ */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -74,8 +74,11 @@
 #define        __SIMPLELOCK_LOCKED     1
 #define        __SIMPLELOCK_UNLOCKED   0
 
+#if !__has_feature(undefined_behavior_sanitizer) && \
+       !defined(__SANITIZE_UNDEFINED__)
 /* The amd64 does not have strict alignment requirements. */
 #define        __NO_STRICT_ALIGNMENT
+#endif
 
 #define        __HAVE_NEW_STYLE_BUS_H
 #define        __HAVE_CPU_COUNTER
diff -r 194594f3702e -r 7b7bdb917444 sys/arch/i386/include/types.h
--- a/sys/arch/i386/include/types.h     Mon Sep 23 21:07:50 2019 +0000
+++ b/sys/arch/i386/include/types.h     Mon Sep 23 23:06:26 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: types.h,v 1.89 2019/04/06 03:06:25 thorpej Exp $       */
+/*     $NetBSD: types.h,v 1.90 2019/09/23 23:06:26 kamil Exp $ */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -99,8 +99,11 @@
 #define        __SIMPLELOCK_LOCKED     1
 #define        __SIMPLELOCK_UNLOCKED   0
 
+#if !__has_feature(undefined_behavior_sanitizer) && \
+       !defined(__SANITIZE_UNDEFINED__)
 /* The x86 does not have strict alignment requirements. */
 #define        __NO_STRICT_ALIGNMENT
+#endif
 
 #define        __HAVE_NEW_STYLE_BUS_H
 #define        __HAVE_CPU_DATA_FIRST



Home | Main Index | Thread Index | Old Index