From patchwork Wed Oct 16 21:12:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 1998272 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ksiE/qJU; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=uV/w0oHO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XTNwP2BWzz1xw7 for ; Thu, 17 Oct 2024 08:12:53 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UuK0X+OAjWuxkl5H3q6cYbug0S4azhI2rDMTeszL9Fw=; b=ksiE/qJUGB3icoF/m+WyGjmWar o9Cr+34tCEj6wuvUSpdlxuipY7D4qpE7azlJZeghWWip7r7V2sVwjm7eXZCoVzbkCzlq6WaAH8+eR HnFNpzIMofJ+WvV6Gj++AofPiSiCQuRk2BbFmGsgqidD4gE4ITxqDAu67Llf/smpW3+ZoyOvIYS6q ak23tECYVQJFungV5yyik8oFQ+/o+E7h6uq8CElfGyLcQKZMC2jFJOhVsWCiGU0KTS/nBGkN6zRXf pKH07ZJiyLtsSeUHzsUf2cZ15SfBDXNtpGlP07q44mq280BQn+jxgX7VItDGMQXdMY8eoazGJqbEn KMUMpUaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1BK6-0000000D1Vp-39qj; Wed, 16 Oct 2024 21:12:50 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1BK4-0000000D1Uz-1H5F for linux-um@lists.infradead.org; Wed, 16 Oct 2024 21:12:49 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 52859A4285B; Wed, 16 Oct 2024 21:12:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E57AC4CECF; Wed, 16 Oct 2024 21:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729113166; bh=S/t7EO/pV80OVsSMddiDyh0HtBgYgcq4zwF02N632nI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uV/w0oHOwBQ+NDUL6z8FHft8RN4lgX3EMUBtvhnBIDFVDTtYXhSQOLnsDDHpooP3q jdHe97X/Nm2Jinkw91UtpvCCHe/vwDD0iFwo5d4v+dpc0S143iJgsFNWc6a5oYW1Hu XqOu/foVP1l6NnKmdib11PfJURzxrbUhaf85izGjGSrSrQo4yjizJ30YXpII9vhXF3 tVOwM2eacOKUoajpNotZXPn4xKMV/9a02aWLvU2TvgQkg1tZjZLmCM9oBj5PqUgN/h c84s1PBSIyonAW5v42CwWERYZNs46o6XbaKRmffqKo8deOUKroyg/ViGumFZRSlM56 6wp4LgFSsy+Cg== From: Nathan Chancellor Date: Wed, 16 Oct 2024 14:12:37 -0700 Subject: [PATCH 1/2] um: Fix passing '-n' to linker for stub_exe MIME-Version: 1.0 Message-Id: <20241016-uml-fix-stub_exe-clang-v1-1-3d6381dc5a78@kernel.org> References: <20241016-uml-fix-stub_exe-clang-v1-0-3d6381dc5a78@kernel.org> In-Reply-To: <20241016-uml-fix-stub_exe-clang-v1-0-3d6381dc5a78@kernel.org> To: Richard Weinberger , Anton Ivanov , Johannes Berg Cc: Nick Desaulniers , Bill Wendling , Justin Stitt , Benjamin Berg , linux-um@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1041; i=nathan@kernel.org; h=from:subject:message-id; bh=S/t7EO/pV80OVsSMddiDyh0HtBgYgcq4zwF02N632nI=; b=owGbwMvMwCUmm602sfCA1DTG02pJDOkCOj5tr/Y7uLt9WCLE69N5tTU4cW94sGH/pkzzBxtNN gSo89/pKGVhEONikBVTZKl+rHrc0HDOWcYbpybBzGFlAhnCwMUpABNh4GD4w3NAqMg9M28Oc3Wk TqHbYnudXwsmt9zb8YdjgYel60HJTEaGd/6rJ3SVddWu/cm0i7mp7Mi6S9V71lVmV8w777SxJOk 6LwA= X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241016_141248_440637_3BC99407 X-CRM114-Status: GOOD ( 10.38 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When building stub_exe with clang, there is an error because '-n' is not a recognized flag by the clang driver (which is being used to invoke the linker): clang: error: unknown argument: '-n' '-n' should be passed along to the linker, as it is the short flag for '--nmagic', so prefix it with '-Wl,'. Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [147.75.193.91 listed in sa-trusted.bondedsender.org] 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [147.75.193.91 listed in sa-accredit.habeas.com] -0.0 DKIMWL_WL_HIGH DKIMwl.org - High trust sender 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [147.75.193.91 listed in bl.score.senderscore.com] X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When building stub_exe with clang, there is an error because '-n' is not a recognized flag by the clang driver (which is being used to invoke the linker): clang: error: unknown argument: '-n' '-n' should be passed along to the linker, as it is the short flag for '--nmagic', so prefix it with '-Wl,'. Fixes: 32e8eaf263d9 ("um: use execveat to create userspace MMs") Signed-off-by: Nathan Chancellor --- arch/um/kernel/skas/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile index fbb61968055f44ac8a963d4c7d250e7c6bbbb321..f93db893b8236cf805edd01b41501d51dd8f0a35 100644 --- a/arch/um/kernel/skas/Makefile +++ b/arch/um/kernel/skas/Makefile @@ -27,7 +27,7 @@ quiet_cmd_stub_exe = STUB_EXE $@ $(KBUILD_CFLAGS) $(STUB_EXE_LDFLAGS) \ $(filter %.o,$^) -STUB_EXE_LDFLAGS = -n -static +STUB_EXE_LDFLAGS = -Wl,-n -static targets += stub_exe.dbg stub_exe $(stub_exe_objs-y) From patchwork Wed Oct 16 21:12:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 1998274 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=wldkXo0J; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=IY+/U/Ya; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XTNwP2DxZz1xw9 for ; Thu, 17 Oct 2024 08:12:53 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cESl8map77BIhxGbXYwJRcXfGHopDYUoQkhkvy0OIk8=; b=wldkXo0Ji2VcUzaQba2zsVk2Iv fS7COVfsjlvC3DDrVrIulYffKP9al8qjDBkT6swFVxnzU0ZJqFmuybk/4k0Z9GpvpPRilUKpf7oA2 lxGN1MbRKwrtZEmN4KHmozLbC1WyQpOnBQkQ3rZDVHFZ6Bui2Ne5QwaD8A6wFjTYFCR9/cYhzAhcb OgvkjfK2yBJ8k+lp9/fAjfTQR8tpa0ui1/BgVGxaQKENNbmSbcjjYWG6Bi2kNmKYLNhDRI6iywzoT 3oTUnFA4P3LZ+ubH74bie0gvI17NVzIY3gWeKAPUgF8kC2IdoFTpFUEtCJUEr1mfVhmpF75HAHz3+ 50FGsYGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1BK7-0000000D1Vv-0IeG; Wed, 16 Oct 2024 21:12:51 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1BK4-0000000D1V0-2t4q for linux-um@lists.infradead.org; Wed, 16 Oct 2024 21:12:50 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id CE409A40A4C; Wed, 16 Oct 2024 21:12:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F412AC4CED0; Wed, 16 Oct 2024 21:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729113167; bh=Tx5OAIRhuHpTGueX/fN7PxdVTqTqNhozXaD5BbCIjDA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IY+/U/YaQ+GHR6P5Z7HHUVSFRkhLvT18LgLID1Zi9JO6JCYlb4soAQT8gkX0uzRyN 9k4WdN5mqNF82g8R5E1kdpKzKIPjY8I7a8KzznAYRh7tib49w0vPEDXUInmqT/DuPe NTN10KXf3wQE8xxjZudaaGWTP1Jq40osfjJN9ACR6xDZcO6XpygX6qP0aa/sZuUS1Z y0f8lJkookgf4JmUEeC4vaeYqcU/+jpyvxHKt5RFtx8fSEJx07NS2aS+Z0lWi7nk6d MDih4wwBq75vhm9pHipCNP8Y+yy8xHmKrRarVebczynv1I+3esefwEdPtcghZvUedX MMFx6zcnnlk4w== From: Nathan Chancellor Date: Wed, 16 Oct 2024 14:12:38 -0700 Subject: [PATCH 2/2] um: Disable auto variable initialization for stub_exe.c MIME-Version: 1.0 Message-Id: <20241016-uml-fix-stub_exe-clang-v1-2-3d6381dc5a78@kernel.org> References: <20241016-uml-fix-stub_exe-clang-v1-0-3d6381dc5a78@kernel.org> In-Reply-To: <20241016-uml-fix-stub_exe-clang-v1-0-3d6381dc5a78@kernel.org> To: Richard Weinberger , Anton Ivanov , Johannes Berg Cc: Nick Desaulniers , Bill Wendling , Justin Stitt , Benjamin Berg , linux-um@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1734; i=nathan@kernel.org; h=from:subject:message-id; bh=Tx5OAIRhuHpTGueX/fN7PxdVTqTqNhozXaD5BbCIjDA=; b=owGbwMvMwCUmm602sfCA1DTG02pJDOkCOr69m9aqV71aunTbjgB9zSLGfX4hN5VE3i55yFbMm 7dQOPNVRykLgxgXg6yYIkv1Y9XjhoZzzjLeODUJZg4rE8gQBi5OAZhIdTMjwxzTLYtOP/s706bQ vOTp+4MdDw5mPS+2blv2uGye9KoKSxuG/8k7QpiUk23rz9kZJL9JErzYM4trAotg0+LrthPFH0j l8wMA X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241016_141248_839422_D044309D X-CRM114-Status: UNSURE ( 9.62 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When automatic variable initialization is enabled via CONFIG_INIT_STACK_ALL_{PATTERN,ZERO}, clang will insert a call to memset() to initialize an object created with __builtin_alloca(). This ultimatel [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When automatic variable initialization is enabled via CONFIG_INIT_STACK_ALL_{PATTERN,ZERO}, clang will insert a call to memset() to initialize an object created with __builtin_alloca(). This ultimately breaks the build when linking stub_exe because it is a standalone executable that does not include or link against memset(). ld: arch/um/kernel/skas/stub_exe.o: in function `_start': arch/um/kernel/skas/stub_exe.c:83:(.ltext+0x15): undefined reference to `memset' Disable automatic variable initialization for stub_exe.c by passing the default value of 'uninitialized' to '-ftrivial-auto-var-init', which avoids generating the call to memset(). This code is small and runs quickly as it is just designed to set up an environment, so stack variable initialization is unnecessary overhead for little gain. Fixes: 32e8eaf263d9 ("um: use execveat to create userspace MMs") Signed-off-by: Nathan Chancellor --- arch/um/kernel/skas/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile index f93db893b8236cf805edd01b41501d51dd8f0a35..f6a219074772283f3c6c6d8d6ccaa8a1cfc24e33 100644 --- a/arch/um/kernel/skas/Makefile +++ b/arch/um/kernel/skas/Makefile @@ -39,6 +39,11 @@ targets += stub_exe.dbg stub_exe $(stub_exe_objs-y) CFLAGS_stub.o := $(CFLAGS_NO_HARDENING) CFLAGS_stub_exe.o := $(CFLAGS_NO_HARDENING) + +# Clang will call memset() from __builtin_alloca() when stack variable +# initialization is enabled, which is used in stub_exe.c. +CFLAGS_stub_exe.o += $(call cc-option, -ftrivial-auto-var-init=uninitialized) + UNPROFILE_OBJS := stub.o stub_exe.o KCOV_INSTRUMENT := n