From nobody Fri Jul 28 04:09:09 2023 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 4RBvK151tyz4phRM; Fri, 28 Jul 2023 04:09:09 +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 4RBvK14XYKz3xth; Fri, 28 Jul 2023 04:09:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690517349; 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=iKPqwtyyp83VmOqhuyr94+C9D9Zu71r/+0Ty4PgbGUM=; b=mlqFibrfT6ffYRupLhpDKVtZZ5TENbYz0RjhMEQ3NdQxvPvpE1aVH/j9ffVSTRYaSB43ek irP+7Tas7dr2PwjA5R0XifOxcsJJ6xWB0pFr7Yr4AL79zAZxbDfRk7HvZ+69UED2SbavIT u/o83PiD57DRtOy+LmTrN/SGFNQeLJ+QBarwqOF4P82qXvpJI/GBIz/iLdKxhzbHCKEsh7 sjeH4Wb7rHENFrx8lnRIMo0BldQidIn3bADdeYG0bm9lCvc9sEHGgvtU/wlsUwxZ/mDLfv dUui8ybm8m+uO41c9g3HN25n/fcfMIcot3Hn7hsZReDlH+jSCnQ+g16g/jU46A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690517349; 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=iKPqwtyyp83VmOqhuyr94+C9D9Zu71r/+0Ty4PgbGUM=; b=dT/yKFzGhBGYoVAy5kOCCnd8aOSCFeaYds6Fm4xdFv9zaKgZnjiOXLubxHxt3o1c3DRfTW 5he6w9a3oWc242MzcSxjacu5cwR/klRqD88n4CW3+rOFAOrdx8adNM1uketzV2XSP3UD/M HybeBnsLU8RBmd4nBNnvqVTN42KH3vI1HfTvFxKXRUoLDNGsERRvfdl1O93azjGP6Re0Ra 2iVHOW/VPDcwwPzIRf7qayGwHIjcMpnedhep16W1ekhAkJRImaTsoo9yjxvtWUPX+tPL+S seCo8E0yb6zuT372Eg7nXFSbbbfvJOiUAWoNHA41ztZ9SqmjPzaBrj2J+fVfcw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690517349; a=rsa-sha256; cv=none; b=YWI6GrVm1IUlf6QGezk1mtNp9wPVVKBxTn8K/3EikDsHMX4l4JB6US6ogP6FX14r2Di3BU ljbFwqEUwCV7KMF5PgFQzx78iDpKMZZ8bJKcGm/0E9kkxk6ib2cKODEdnj9V6jTz2UYpBL oroMASRQcorX+x8RZi81xrYIRPzK5am4x/kXQVqL9zoWaDoTmQ2yGBNHuDL1QWXrOw9TWe 1XQ1dWg6T3Re4hPZVOsfL8Pqm2PZc2KzpzzbEBfI4BumxxFq4w+LTBYrIJRfrh/Idirj26 PkXL5fjqjSEgi/85Fmim78qBoZ+sFwAdI5AUWS0H1y8Ix2sjRC3oalESaiQfbQ== 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 4RBvK13LSBzcXl; Fri, 28 Jul 2023 04:09:09 +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 36S499S8067328; Fri, 28 Jul 2023 04:09:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36S499H5067327; Fri, 28 Jul 2023 04:09:09 GMT (envelope-from git) Date: Fri, 28 Jul 2023 04:09:09 GMT Message-Id: <202307280409.36S499H5067327@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 8a6ab0f71f18 - main - Pre-quote macros passed to .incbin to avoid unwanted substitution 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: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8a6ab0f71f1857037233fae19991b972b430d83c Auto-Submitted: auto-generated The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=8a6ab0f71f1857037233fae19991b972b430d83c commit 8a6ab0f71f1857037233fae19991b972b430d83c Author: Jessica Clarke AuthorDate: 2023-07-28 04:08:43 +0000 Commit: Jessica Clarke CommitDate: 2023-07-28 04:08:43 +0000 Pre-quote macros passed to .incbin to avoid unwanted substitution Currently for the MFS, firmware and VDSO template assembly files we pass the path to include with .incbin unquoted and use __XSTRING within the assembly file to stringify it. However, __XSTRING doesn't just perform a single level of expansion, it performs the normal full expansion of the macro, and so if the path itself happens to tokenise to something that includes a defined macro in it that will itself be substituted. For example, with #define MACRO 1, a path like /path/containing/MACRO/in/it will expand to /path/containing/1/in/it and then, when stringified, end up as "/path/containing/1/in/it", not the intended string. Normally, macros have names that start or end witih underscores and are unlikely to appear in a tokenised path (even if technically they could), but now that we've switched to GNU C as of commit ec41a96daaa6 ("sys: Switch the kernel's C standard from C99 to GNU99.") there are a few new macros defined which don't start or end with underscores: unix, which is always defined to 1, and i386, which is defined to 1 on i386. The former probably doesn't appear in user paths in practice, but the latter has been seen to and is likely quite common in the wild. Fix this by defining the macro pre-quoted instead of using __XSTRING. Note that technically we don't need to do this for vdso_wrap.S today as all the paths passed to it are safe file names with no user-controlled prefix but we should do it anyway for consistency and robustness against future changes. This allows make tinderbox to pass when built with source and object directories inside ~/path-with-unix, which would otherwise expand to ~/path-with-1 and break. PR: 272744 Fixes: ec41a96daaa6 ("sys: Switch the kernel's C standard from C99 to GNU99.") --- sys/conf/kern.post.mk | 2 +- sys/conf/kern.pre.mk | 2 +- sys/conf/kmod.mk | 2 +- sys/dev/md/embedfs.S | 2 +- sys/kern/firmw.S | 2 +- sys/tools/amd64_ia32_vdso.sh | 2 +- sys/tools/amd64_vdso.sh | 2 +- sys/tools/vdso_wrap.S | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index 45df83e2d16b..5a9ac7ad2ed3 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -466,7 +466,7 @@ vnode_if_typedef.h: .if ${MFS_IMAGE:Uno} != "no" .if empty(MD_ROOT_SIZE_CONFIGURED) embedfs_${MFS_IMAGE:T:R}.o: ${MFS_IMAGE} $S/dev/md/embedfs.S - ${CC} ${CFLAGS} ${ACFLAGS} -DMFS_IMAGE="${MFS_IMAGE}" -c \ + ${CC} ${CFLAGS} ${ACFLAGS} -DMFS_IMAGE=\""${MFS_IMAGE}"\" -c \ $S/dev/md/embedfs.S -o ${.TARGET} .endif .endif diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk index 8314f4489ca8..33b7120144b8 100644 --- a/sys/conf/kern.pre.mk +++ b/sys/conf/kern.pre.mk @@ -200,7 +200,7 @@ NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \ NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC} NORMAL_FWO= ${CC:N${CCACHE_BIN}} -c ${ASM_CFLAGS} ${WERROR} -o ${.TARGET} \ - $S/kern/firmw.S -DFIRMW_FILE="${.ALLSRC:M*.fw}" \ + $S/kern/firmw.S -DFIRMW_FILE=\""${.ALLSRC:M*.fw}"\" \ -DFIRMW_SYMBOL="${.ALLSRC:M*.fw:C/[-.\/]/_/g}" # for ZSTD in the kernel (include zstd/lib/freebsd before other CFLAGS) diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index be571c2bcf10..e706b73c3d32 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -210,7 +210,7 @@ ${_firmw:C/\:.*$/.fwo/:T}: ${_firmw:C/\:.*$//} ${SYSDIR}/kern/firmw.S @${ECHO} ${_firmw:C/\:.*$//} ${.ALLSRC:M*${_firmw:C/\:.*$//}} ${CC:N${CCACHE_BIN}} -c -x assembler-with-cpp -DLOCORE \ ${CFLAGS} ${WERROR} \ - -DFIRMW_FILE="${.ALLSRC:M*${_firmw:C/\:.*$//}}" \ + -DFIRMW_FILE=\""${.ALLSRC:M*${_firmw:C/\:.*$//}}"\" \ -DFIRMW_SYMBOL="${_firmw:C/\:.*$//:C/[-.\/@]/_/g}" \ ${SYSDIR}/kern/firmw.S -o ${.TARGET} diff --git a/sys/dev/md/embedfs.S b/sys/dev/md/embedfs.S index f7574631a0c6..94b21e51f86e 100644 --- a/sys/dev/md/embedfs.S +++ b/sys/dev/md/embedfs.S @@ -38,7 +38,7 @@ .globl mfs_root .type mfs_root, %object mfs_root: - .incbin __XSTRING(MFS_IMAGE) + .incbin MFS_IMAGE .size mfs_root, . - mfs_root .globl mfs_root_end .type mfs_root_end, %object diff --git a/sys/kern/firmw.S b/sys/kern/firmw.S index 7a4ca1e45808..64d614684df6 100644 --- a/sys/kern/firmw.S +++ b/sys/kern/firmw.S @@ -41,7 +41,7 @@ .globl FIRMW_START(FIRMW_SYMBOL) .type FIRMW_START(FIRMW_SYMBOL), %object FIRMW_START(FIRMW_SYMBOL): - .incbin __XSTRING(FIRMW_FILE) + .incbin FIRMW_FILE .size FIRMW_START(FIRMW_SYMBOL), . - FIRMW_START(FIRMW_SYMBOL) .globl FIRMW_END(FIRMW_SYMBOL) .type FIRMW_END(FIRMW_SYMBOL), %object diff --git a/sys/tools/amd64_ia32_vdso.sh b/sys/tools/amd64_ia32_vdso.sh index e64c964219c3..59923749042f 100644 --- a/sys/tools/amd64_ia32_vdso.sh +++ b/sys/tools/amd64_ia32_vdso.sh @@ -55,7 +55,7 @@ fi ${CC} ${DEBUG} -x assembler-with-cpp -DLOCORE -fPIC -nostdinc -c \ -o elf-vdso32.so.o -I. -I"${S}" -include opt_global.h \ - -DVDSO_NAME=elf_vdso32_so_1 -DVDSO_FILE=elf-vdso32.so.1 \ + -DVDSO_NAME=elf_vdso32_so_1 -DVDSO_FILE=\"elf-vdso32.so.1\" \ "${S}"/tools/vdso_wrap.S ${NM} -D elf-vdso32.so.1 | ${AWK} \ diff --git a/sys/tools/amd64_vdso.sh b/sys/tools/amd64_vdso.sh index 1a0203e3e0a4..aec0694ebdb1 100644 --- a/sys/tools/amd64_vdso.sh +++ b/sys/tools/amd64_vdso.sh @@ -64,7 +64,7 @@ fi ${CC} ${DEBUG} -x assembler-with-cpp -DLOCORE -fPIC -nostdinc -c \ -o elf-vdso.so.o -I. -I"${S}" -include opt_global.h \ - -DVDSO_NAME=elf_vdso_so_1 -DVDSO_FILE=elf-vdso.so.1 \ + -DVDSO_NAME=elf_vdso_so_1 -DVDSO_FILE=\"elf-vdso.so.1\" \ "${S}"/tools/vdso_wrap.S ${NM} -D elf-vdso.so.1 | \ diff --git a/sys/tools/vdso_wrap.S b/sys/tools/vdso_wrap.S index 807dcf9c06f4..5a815fd6f499 100644 --- a/sys/tools/vdso_wrap.S +++ b/sys/tools/vdso_wrap.S @@ -39,7 +39,7 @@ .type VDSO_BLOB_START(VDSO_NAME), %object .size VDSO_BLOB_START(VDSO_NAME), 0 VDSO_BLOB_START(VDSO_NAME): - .incbin __XSTRING(VDSO_FILE) + .incbin VDSO_FILE .globl VDSO_BLOB_END(VDSO_NAME) .type VDSO_BLOB_END(VDSO_NAME), %object .size VDSO_BLOB_END(VDSO_NAME), 0