From patchwork Thu Oct 13 17:52:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2119 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp403986wrs; Thu, 13 Oct 2022 10:54:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4E1Xf/W8M0r5ZlwVUvbDMeI8aWdL7Lr7C1ZNz/KyuWRefxiA5+redTD9ZnTymiiwXTBwdf X-Received: by 2002:a63:4c2:0:b0:460:869a:f5ba with SMTP id 185-20020a6304c2000000b00460869af5bamr915230pge.362.1665683652386; Thu, 13 Oct 2022 10:54:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665683652; cv=none; d=google.com; s=arc-20160816; b=geXQxuWJKUkWAvDr2LYFxBbnH239SVS1UKt3IDpE5AfLX/ot7Xv1euPwVUQ/i2YWcc thPV8vQr8ywPLf/O47hJi9VgGmgj5Tq6OAbb2bAF/rb5ScpB8fdziWFsX3talqJ6FqUp fP3YLYx7iRmdsAKLYOT/lD6aHDxpklYzwPzhdmHh/8Ub7WH7d3ZCuSref8X2krBwuL7W WuS22Ky4nm8cwPe3pTYwWmlluaeUdpdMYkCgwruRxCSJfuLBxdLZ2rpOw2V8HsRFxqBG OWItbFz6qrwpq4Ith/FnVfaNOnsdvdq4nykzceclUeHy+aIbCgzLEdqXfInl1yc4OH5h NkAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mDBPMG1vZOaePcRASRGJlBydbqh42TMaBtnzPEiFA4k=; b=G8GOY7bwqwlN3VIJVD1ivvf78guBsGfBlex36zquobtctYZGMJipD4+1silUwaCGZH rYMHcBXRWpHLwluGI0p11s8/WJqq+dpYQCSfcdzeWkezgiDDWbbTmzN+BdXFwakwFmjL ypZwuMAWyBpkvJNUDkWdmZfKoRPoXN/v2NVTIWYsv8TAPJFbaqmkS9OGDSUvn+VFwlYe 4mopDUTlGZTmde75/9QaWeD0/xXu8t/tyQPF2EOMdCQddMUiMbr47NYkspesAcbOs6kd aOtKuptQvrwvISKBZ6QoVn9V0cJDWsyt4ZH6wixJbUAcXnVdk3qSbiwUip4SY4P5g84r rCfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XVDC6UKU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oc3-20020a17090b1c0300b00200ad6b1554si7098207pjb.6.2022.10.13.10.54.00; Thu, 13 Oct 2022 10:54:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XVDC6UKU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229703AbiJMRw4 (ORCPT + 99 others); Thu, 13 Oct 2022 13:52:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbiJMRwu (ORCPT ); Thu, 13 Oct 2022 13:52:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECB2214FD34; Thu, 13 Oct 2022 10:52:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5742A618F7; Thu, 13 Oct 2022 17:52:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2934EC433C1; Thu, 13 Oct 2022 17:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683567; bh=ib1lQCV01pXW8JO0BmnZksOwhGMo3P498BUfkCHG5/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XVDC6UKUI7MjyaU5NMvDqjmIHvRW5vvSmZoWjcGHrpNP7CIctJRN6vv1zjJID1Vqi hPPmRNPPmlUq41jvOZDQtdGImf07cl2LXOxiNf+gW3fROxUolu1Pgq/eyNvMEsF1FR 2z3Q0CpZ7Kcqap4ZhYrsosiZd+Ag1vivAV3Mu23Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Gow , Lukas Straub , Richard Weinberger , Sasha Levin , Randy Dunlap Subject: [PATCH 5.4 12/38] arch: um: Mark the stack non-executable to fix a binutils warning Date: Thu, 13 Oct 2022 19:52:13 +0200 Message-Id: <20221013175144.682353616@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175144.245431424@linuxfoundation.org> References: <20221013175144.245431424@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746595901568820502?= X-GMAIL-MSGID: =?utf-8?q?1746595901568820502?= From: David Gow [ Upstream commit bd71558d585ac61cfd799db7f25e78dca404dd7a ] Since binutils 2.39, ld will print a warning if any stack section is executable, which is the default for stack sections on files without a .note.GNU-stack section. This was fixed for x86 in commit ffcf9c5700e4 ("x86: link vdso and boot with -z noexecstack --no-warn-rwx-segments"), but remained broken for UML, resulting in several warnings: /usr/bin/ld: warning: arch/x86/um/vdso/vdso.o: missing .note.GNU-stack section implies executable stack /usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker /usr/bin/ld: warning: .tmp_vmlinux.kallsyms1 has a LOAD segment with RWX permissions /usr/bin/ld: warning: .tmp_vmlinux.kallsyms1.o: missing .note.GNU-stack section implies executable stack /usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker /usr/bin/ld: warning: .tmp_vmlinux.kallsyms2 has a LOAD segment with RWX permissions /usr/bin/ld: warning: .tmp_vmlinux.kallsyms2.o: missing .note.GNU-stack section implies executable stack /usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker /usr/bin/ld: warning: vmlinux has a LOAD segment with RWX permissions Link both the VDSO and vmlinux with -z noexecstack, fixing the warnings about .note.GNU-stack sections. In addition, pass --no-warn-rwx-segments to dodge the remaining warnings about LOAD segments with RWX permissions in the kallsyms objects. (Note that this flag is apparently not available on lld, so hide it behind a test for BFD, which is what the x86 patch does.) Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ffcf9c5700e49c0aee42dcba9a12ba21338e8136 Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ba951afb99912da01a6e8434126b8fac7aa75107 Signed-off-by: David Gow Reviewed-by: Lukas Straub Tested-by: Lukas Straub Acked-by: Randy Dunlap # build-tested Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- arch/um/Makefile | 8 ++++++++ arch/x86/um/vdso/Makefile | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/um/Makefile b/arch/um/Makefile index 275f5ffdf6f0..773120be0f56 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -132,10 +132,18 @@ export LDS_ELF_FORMAT := $(ELF_FORMAT) # The wrappers will select whether using "malloc" or the kernel allocator. LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc +# Avoid binutils 2.39+ warnings by marking the stack non-executable and +# ignorning warnings for the kallsyms sections. +LDFLAGS_EXECSTACK = -z noexecstack +ifeq ($(CONFIG_LD_IS_BFD),y) +LDFLAGS_EXECSTACK += $(call ld-option,--no-warn-rwx-segments) +endif + LD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS),-Wl,$(opt)) # Used by link-vmlinux.sh which has special support for um link export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) +export LDFLAGS_vmlinux := $(LDFLAGS_EXECSTACK) # When cleaning we don't include .config, so we don't include # TT or skas makefiles and don't clean skas_ptregs.h. diff --git a/arch/x86/um/vdso/Makefile b/arch/x86/um/vdso/Makefile index 0caddd6acb22..bec115036f87 100644 --- a/arch/x86/um/vdso/Makefile +++ b/arch/x86/um/vdso/Makefile @@ -62,7 +62,7 @@ quiet_cmd_vdso = VDSO $@ -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \ sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' -VDSO_LDFLAGS = -fPIC -shared -Wl,--hash-style=sysv +VDSO_LDFLAGS = -fPIC -shared -Wl,--hash-style=sysv -z noexecstack GCOV_PROFILE := n #