The branch main has been updated by arichardson:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=8185be3307232d88ddd1b6468f4ddec54a993f54

commit 8185be3307232d88ddd1b6468f4ddec54a993f54
Author:     Alex Richardson <arichard...@freebsd.org>
AuthorDate: 2021-08-02 08:51:34 +0000
Commit:     Alex Richardson <arichard...@freebsd.org>
CommitDate: 2021-08-02 13:33:24 +0000

    libc: Disable ASAN for certain string functions
    
    They deliberately read out-of-bounds values to avoid byte-by-byte
    loads and check multiple bytes at once. While this will work on x86,
    it is flagged as an out-of-bounds read with ASAN, so we have to
    disable instrumentation here. This also causes bounds errors for CHERI,
    so in CheriBSD we use implementations that avoid OOB reads.
    
    Differential Revision: https://reviews.freebsd.org/D31045
---
 lib/libc/string/Makefile.inc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/libc/string/Makefile.inc b/lib/libc/string/Makefile.inc
index 6945155812af..1df3d40e329f 100644
--- a/lib/libc/string/Makefile.inc
+++ b/lib/libc/string/Makefile.inc
@@ -29,6 +29,15 @@ MISRCS+=bcmp.c bcopy.c bzero.c explicit_bzero.c \
 
 SYM_MAPS+=     ${LIBC_SRCTOP}/string/Symbol.map
 
+.if ${MK_ASAN} != "no"
+# These source files deliberately read out of bounds since they assume that
+# out-of-bounds memory accesses that don't cross pages are always legal.
+# Note: While this is fine on x86, it does break when running with CHERI.
+CFLAGS.strlen.c+=              -fno-sanitize=address
+CFLAGS.strchrnul.c+=   -fno-sanitize=address
+CFLAGS.memchr.c+=              -fno-sanitize=address
+.endif
+
 
 # machine-dependent string sources
 .sinclude "${LIBC_SRCTOP}/${LIBC_ARCH}/string/Makefile.inc"
_______________________________________________
dev-commits-src-main@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"

Reply via email to