From owner-dev-commits-src-all@freebsd.org Mon Aug 2 13:35:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D58816746A8; Mon, 2 Aug 2021 13:35:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GdfBl5CPPz4RXB; Mon, 2 Aug 2021 13:35:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 906B2208B4; Mon, 2 Aug 2021 13:35:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 172DZB6Y050675; Mon, 2 Aug 2021 13:35:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 172DZBO9050674; Mon, 2 Aug 2021 13:35:11 GMT (envelope-from git) Date: Mon, 2 Aug 2021 13:35:11 GMT Message-Id: <202108021335.172DZBO9050674@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alex Richardson Subject: git: 8185be330723 - main - libc: Disable ASAN for certain string functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8185be3307232d88ddd1b6468f4ddec54a993f54 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Aug 2021 13:35:11 -0000 The branch main has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=8185be3307232d88ddd1b6468f4ddec54a993f54 commit 8185be3307232d88ddd1b6468f4ddec54a993f54 Author: Alex Richardson AuthorDate: 2021-08-02 08:51:34 +0000 Commit: Alex Richardson 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"