From nobody Fri Jan 12 21:12:08 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TBZ3r4X3vz56Mtn; Fri, 12 Jan 2024 21:12:08 +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 4TBZ3r309hz4WW0; Fri, 12 Jan 2024 21:12:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705093928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qvmOfquxuus3Yf8MSZZ4XeSzIUdhwN/njRk+JHO4Qp0=; b=Qumt/FWpbfFmZWAM/X+oro1vLz6/4hJudCHsjQo0K3V+eQ5k2+dm3OPHZbaNAENtPw1j+j TdMjw03gtwk2qWo4lWRTlebNToNctYeO9PrWUentFJFKuvWhP1cmQCe0YU4NSrQPGf5FXh gV51h1k5kUfaMIXbREnBONPyiAPwUMYg365bM5h24GQbzJ7OPAi8IC5YB6WwoVdKQer6fV z35htDsLaJA6MTWnz43A9rGxNz02ViAULDodgGCxcnIlAv2dtnYKT+8vgRkVlig21zDAux gfde2rqNNDoDOUlshfIKlwzm2R40Qmi8LnLjk9BB+c1jAyPuzDW4CzyQrQj/Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705093928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qvmOfquxuus3Yf8MSZZ4XeSzIUdhwN/njRk+JHO4Qp0=; b=bpSBDAsLGma9gFRsG4HZxQyoMCPM7P+XFnZZR073Xwi/zHbkkm3puXQC2oIKHv1EL/SZWM g8hb0YIWR1OXfdJal6OCoJH6tSnUuigwEzozegMMEYYrI6Im1ZDrmkjBUZC3ma0RKuy2qs NjHYetD2Uzk0g/dEkOVyEKTmhujvCJixkLF/tfN/rTMYmCNrIHwWBPO0SWSUNBx7IyxK8P J0K0aTzttDQ8K+N2tuutCmEHgmdbuvvng7+2J3ZlGXm7sHASuPe9Rk+D8XSKsH97jkT3B1 9DJX53KyK69zye3pxh3CmVK18uaEsPC4K7H6Y9AJICsWDn68uU49oD81XMKGLQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705093928; a=rsa-sha256; cv=none; b=JiLgcjU6lMN6KJnSst3B5tyzZdpQy4Rw7xRL+ux6TUAxkXjg0J4XYZ2IVbj9/q0fEvMs0s e6lA64j176oqndUUsaIEwwkYkutnxpu38CSFF+DHV51NXUzYuFDe2fZalgYkvb1W7xyArP pzomSyedXB4rwqTTRJZ+yP0kgjzgHEQ5RDiUTXjACE4pRXwrjdcOe2GSBa21V6ccR7rO8y CHtWVUid2NvzBWoSxNeTCY6VF9QrG+i1BHOfnx6SqD6wtWnLIhh01BZ2wwyq+jY47+Rfd4 SnTFBfFqhPPtAhc642maLJ4wtJcN8EYmz0GKDEH9/PL/VolOVhENZwDNPJ7+/Q== 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 4TBZ3r25tqz1Hbb; Fri, 12 Jan 2024 21:12:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40CLC8p0039324; Fri, 12 Jan 2024 21:12:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40CLC8Tt039321; Fri, 12 Jan 2024 21:12:08 GMT (envelope-from git) Date: Fri, 12 Jan 2024 21:12:08 GMT Message-Id: <202401122112.40CLC8Tt039321@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 8e1a7e29b6cc - main - sanitizers: Avoid building genassym.c and genoffset.c with sanitizers List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8e1a7e29b6cc276a2763e61b5f61afebd4570bba Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8e1a7e29b6cc276a2763e61b5f61afebd4570bba commit 8e1a7e29b6cc276a2763e61b5f61afebd4570bba Author: Mark Johnston AuthorDate: 2023-10-10 18:14:46 +0000 Commit: Mark Johnston CommitDate: 2024-01-12 21:09:14 +0000 sanitizers: Avoid building genassym.c and genoffset.c with sanitizers Some, particularly KASAN, may insert redzones around global symbols, resulting in incorrect offset definitions because genassym.sh (ab)uses symbol sizes to assign semantic meaning. (Ideally I would be able to define this pattern in one place, but I haven't found a way to define a GENSYM_CFLAGS that actually works for all of the consumers (kern.post.mk, kmod.mk, sys/conf/files*).) MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: Juniper Networks, Inc. --- sys/conf/files.amd64 | 2 +- sys/conf/kern.post.mk | 10 ++++++---- sys/conf/kmod.mk | 4 ++-- sys/modules/linux/Makefile | 3 ++- sys/modules/linux64/Makefile | 3 ++- sys/modules/vmm/Makefile | 6 ++++-- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index de509e362b6d..5eae8a0de3c2 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -25,7 +25,7 @@ elf-vdso32.so.o optional compat_freebsd32 \ # ia32_genassym.o standard \ dependency "$S/compat/ia32/ia32_genassym.c offset.inc" \ - compile-with "${CC} ${CFLAGS:N-flto*:N-fno-common} -fcommon -c ${.IMPSRC}" \ + compile-with "${CC} ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} -fcommon -c ${.IMPSRC}" \ no-obj no-implicit-rule \ clean "ia32_genassym.o" # diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index 34877a01b7dd..5760ebd987f1 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -245,20 +245,22 @@ offset.inc: $S/kern/genoffset.sh genoffset.o NM='${NM}' NMFLAGS='${NMFLAGS}' sh $S/kern/genoffset.sh genoffset.o > ${.TARGET} genoffset.o: $S/kern/genoffset.c - ${CC} -c ${CFLAGS:N-flto*:N-fno-common} -fcommon $S/kern/genoffset.c + ${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} \ + -fcommon $S/kern/genoffset.c # genoffset_test.o is not actually used for anything - the point of compiling it # is to exercise the CTASSERT that checks that the offsets in the offset.inc # _lite struct(s) match those in the original(s). genoffset_test.o: $S/kern/genoffset.c offset.inc - ${CC} -c ${CFLAGS:N-flto*:N-fno-common} -fcommon -DOFFSET_TEST \ - $S/kern/genoffset.c -o ${.TARGET} + ${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} \ + -fcommon -DOFFSET_TEST $S/kern/genoffset.c -o ${.TARGET} assym.inc: $S/kern/genassym.sh genassym.o genoffset_test.o NM='${NM}' NMFLAGS='${NMFLAGS}' sh $S/kern/genassym.sh genassym.o > ${.TARGET} genassym.o: $S/$M/$M/genassym.c offset.inc - ${CC} -c ${CFLAGS:N-flto*:N-fno-common} -fcommon $S/$M/$M/genassym.c + ${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} \ + -fcommon $S/$M/$M/genassym.c OBJS_DEPEND_GUESS+= opt_global.h genoffset.o genassym.o vers.o: opt_global.h diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index 3dc83ce4c423..5cc0ff70c3e2 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -524,13 +524,13 @@ assym.inc: ${SYSDIR}/kern/genassym.sh sh ${SYSDIR}/kern/genassym.sh genassym.o > ${.TARGET} genassym.o: ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c offset.inc genassym.o: ${SRCS:Mopt_*.h} - ${CC} -c ${CFLAGS:N-flto*:N-fno-common} -fcommon \ + ${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} -fcommon \ ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c offset.inc: ${SYSDIR}/kern/genoffset.sh genoffset.o sh ${SYSDIR}/kern/genoffset.sh genoffset.o > ${.TARGET} genoffset.o: ${SYSDIR}/kern/genoffset.c genoffset.o: ${SRCS:Mopt_*.h} - ${CC} -c ${CFLAGS:N-flto*:N-fno-common} -fcommon \ + ${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} -fcommon \ ${SYSDIR}/kern/genoffset.c CLEANDEPENDFILES+= ${_ILINKS} diff --git a/sys/modules/linux/Makefile b/sys/modules/linux/Makefile index 88b3b8f5e123..8c720f8f9e65 100644 --- a/sys/modules/linux/Makefile +++ b/sys/modules/linux/Makefile @@ -135,7 +135,8 @@ linux${SFX}_support.o: linux${SFX}_support.S linux${SFX}_assym.h assym.inc .endif linux${SFX}_genassym.o: offset.inc - ${CC} -c ${CFLAGS:N-flto*:N-fno-common} -fcommon ${.IMPSRC} + ${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} \ + -fcommon ${.IMPSRC} .if !defined(KERNBUILDDIR) .warning Building Linuxulator outside of a kernel does not make sense diff --git a/sys/modules/linux64/Makefile b/sys/modules/linux64/Makefile index 9ac1944ad1a9..62e3b464d39f 100644 --- a/sys/modules/linux64/Makefile +++ b/sys/modules/linux64/Makefile @@ -101,7 +101,8 @@ linux_support.o: linux_support.S assym.inc linux_assym.h ${.ALLSRC:M*.S:u} -o ${.TARGET} linux_genassym.o: offset.inc - ${CC} -c ${CFLAGS:N-flto*:N-fno-common} -fcommon ${.IMPSRC} + ${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} \ + -fcommon ${.IMPSRC} .if !defined(KERNBUILDDIR) .warning Building Linuxulator outside of a kernel does not make sense diff --git a/sys/modules/vmm/Makefile b/sys/modules/vmm/Makefile index 46909dad6c71..a950c5a82d13 100644 --- a/sys/modules/vmm/Makefile +++ b/sys/modules/vmm/Makefile @@ -82,9 +82,11 @@ svm_support.o: ${.IMPSRC} -o ${.TARGET} vmx_genassym.o: offset.inc - ${CC} -c ${CFLAGS:N-flto*:N-fno-common} -fcommon ${.IMPSRC} + ${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} \ + -fcommon ${.IMPSRC} svm_genassym.o: offset.inc - ${CC} -c ${CFLAGS:N-flto*:N-fno-common} -fcommon ${.IMPSRC} + ${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} \ + -fcommon ${.IMPSRC} .include