Message ID | 20230802110323.086971726@infradead.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp448435vqx; Wed, 2 Aug 2023 06:15:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlGvxY/kId6JXm9YX/gE/Af1vN6JvrzfT3Q9rMikUGlQ5AInAjdSfsZUTHsTfqtdA7BecRhc X-Received: by 2002:a05:6512:e84:b0:4f8:5cde:a44f with SMTP id bi4-20020a0565120e8400b004f85cdea44fmr4693336lfb.10.1690982115901; Wed, 02 Aug 2023 06:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690982115; cv=none; d=google.com; s=arc-20160816; b=xlRW87a36I32kjLKbmOOj5h2zltU4dwde2wo/o4itm22NPPhbKct/zRTWMDAYLSHL5 NvhgNyM5Kbn4czC5WC312avBwpfpSFT0SmjErAN5JFJh8ILTDEh3TBBQ81o4Be+pz7Ye ayodIgOH8DCJBcdXpwk0aJ/QvBhKUNq/eOA8wIlJd33jc4/z5FS2cgZvDY8+XgdWVZ+s qBGpHuvIP7fcXngtHohnzbs+yG3i7dG/TfTmtrrMCgO7AfHLNI4elEj5cpraxlphgSeP IIjJZoAQJWgr/JfU0U/3XNMcXS7eBC0i98U8JsVKDLwLHM4tKCgIlEZyI6faq6YSA3DL bnpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=apvcoInpYri3GsLvQN0fxRBQnpJkdbgo5+Z9wGvq+yo=; fh=IwK3LjPX56eu0FM8NtQeo2u9R5AUzZQlgvLLkSqFWCc=; b=aLU406w7hit7sQuTe1AEdTWeA18R3v2PiFTYTSn2Q8wdiUb0vdgR6m4OAojKa9Mboi i+xYfalEaZISGh8NC5qTSyIn52EgXURDXSWQ6KdZw+z9CoCq85+qCBP1OWml8xtSQFWJ pJVqGV9IrOe+5C15u9S+OIqLwlNF5EX7A9MIgSqMdI+88QMpn0g+ZiMR9e7n5zjudThT uEbbKUHMn0e0xFPNXXy7kCh2lGfbkQWJeDjWEl5VFjMTV36jrtuLun6PegrxZuQ8OMzq fXhjKpK4BL+Sm3mF8TWGCbj4rLMAQcuCR8osE7aGlN+4/j2WNdXEVv/GpyJJlRgenlON 3+PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=XEcRpPw5; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020aa7c747000000b0051e1a616e32si6806016eds.89.2023.08.02.06.14.47; Wed, 02 Aug 2023 06:15:15 -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=@infradead.org header.s=desiato.20200630 header.b=XEcRpPw5; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233960AbjHBLEU (ORCPT <rfc822;maxi.paulin@gmail.com> + 99 others); Wed, 2 Aug 2023 07:04:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232240AbjHBLES (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Aug 2023 07:04:18 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1CAD1FC3 for <linux-kernel@vger.kernel.org>; Wed, 2 Aug 2023 04:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=apvcoInpYri3GsLvQN0fxRBQnpJkdbgo5+Z9wGvq+yo=; b=XEcRpPw5c69fzYWh1h/qfPIB+K 8dBdsEFZr8Y/HzyE158xsbYYZ+OO4A1CRwh7L8WE2J59E2svQNy6f7U4Ze319MLlwCE2PkU+VjdtT RUgQ+93ftb8xEIouyffxoqfLJ5KkxH8opEY+RlimBq0xjpp5/VogA3ZKhiScFH9+v7uEtCMbK5ibz auTRVjsdudL4fnvMEYokZwNMUvCEeyuk0fKZn/yb/xHueCegsaJ4qdXgGBtFCcwNrVR0EYe4J6uUZ qXrT0aM2VkL0TM5SnpdEw6c9JdYy8GVJnU7KZCXyNMO3/yOAfzL1l42g/Dvm16d7RJ+wXVP54rLFS ObeSoyjg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qR9eE-00FtVq-1a; Wed, 02 Aug 2023 11:04:11 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 2659A3001DD; Wed, 2 Aug 2023 13:04:10 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id F3D4121000C9E; Wed, 2 Aug 2023 13:04:09 +0200 (CEST) Message-ID: <20230802110323.086971726@infradead.org> User-Agent: quilt/0.66 Date: Wed, 02 Aug 2023 12:55:47 +0200 From: Peter Zijlstra <peterz@infradead.org> To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, jpoimboe@kernel.org, andrew.cooper3@citrix.com, David.Kaplan@amd.com Subject: [PATCH 2/2] x86/ibt: Avoid duplicate ENDBR in __put_user_nocheck*() References: <20230802105545.594381530@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773123263527024558 X-GMAIL-MSGID: 1773123263527024558 |
Series |
x86/ibt: Fix some spurious ENDBR instances
|
|
Commit Message
Peter Zijlstra
Aug. 2, 2023, 10:55 a.m. UTC
Commit cb855971d717 ("x86/putuser: Provide room for padding") changed
__put_user_nocheck_*() into proper functions but failed to note that
SYM_FUNC_START() already provides ENDBR, rendering the explicit ENDBR
superfluous.
Fixes: cb855971d717 ("x86/putuser: Provide room for padding")
Reported-by: David Kaplan <David.Kaplan@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/lib/putuser.S | 4 ----
1 file changed, 4 deletions(-)
Comments
On Wed, Aug 02, 2023 at 12:55:47PM +0200, Peter Zijlstra wrote: > Commit cb855971d717 ("x86/putuser: Provide room for padding") changed > __put_user_nocheck_*() into proper functions but failed to note that > SYM_FUNC_START() already provides ENDBR, rendering the explicit ENDBR > superfluous. The below objtool thing reliably detects this pattern: vmlinux.o: warning: objtool: __put_user_nocheck_1+0x4: duplicate ENDBR vmlinux.o: warning: objtool: __put_user_nocheck_2+0x4: duplicate ENDBR vmlinux.o: warning: objtool: __put_user_nocheck_4+0x4: duplicate ENDBR vmlinux.o: warning: objtool: __put_user_nocheck_8+0x4: duplicate ENDBR --- tools/objtool/check.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 8936a05f0e5a..c6ba6e768b03 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4254,13 +4254,30 @@ static bool noendbr_range(struct objtool_file *file, struct instruction *insn) return insn->offset == sym->offset + sym->len; } -static int validate_ibt_insn(struct objtool_file *file, struct instruction *insn) +static int validate_ibt_insn(struct objtool_file *file, + struct instruction *insn, + struct instruction *prev) { struct instruction *dest; struct reloc *reloc; unsigned long off; int warnings = 0; + if (prev && prev->sym && prev->sym == insn->sym && + prev->type == INSN_ENDBR && insn->type == INSN_ENDBR) { + /* + * ___bpf_prog_run() is a maze of 'label as value' and + * 'computed goto' and GCC gets confused and emits back-to-back + * ENDBR due to failing to merge two labels. + * + * Don't warn about this until GCC is fixed or verbose. + */ + if (strcmp(insn->sym->name, "___bpf_prog_run") != 0 || opts.verbose) { + WARN_INSN(insn, "duplicate ENDBR"); + warnings++; + } + } + /* * Looking for function pointer load relocations. Ignore * direct/indirect branches: @@ -4382,11 +4399,13 @@ static int validate_ibt(struct objtool_file *file) { struct section *sec; struct reloc *reloc; - struct instruction *insn; + struct instruction *insn, *prev = NULL; int warnings = 0; - for_each_insn(file, insn) - warnings += validate_ibt_insn(file, insn); + for_each_insn(file, insn) { + warnings += validate_ibt_insn(file, insn, prev); + prev = insn; + } for_each_sec(file, sec) {
--- a/arch/x86/lib/putuser.S +++ b/arch/x86/lib/putuser.S @@ -56,7 +56,6 @@ SYM_FUNC_END(__put_user_1) EXPORT_SYMBOL(__put_user_1) SYM_FUNC_START(__put_user_nocheck_1) - ENDBR ASM_STAC 2: movb %al,(%_ASM_CX) xor %ecx,%ecx @@ -76,7 +75,6 @@ SYM_FUNC_END(__put_user_2) EXPORT_SYMBOL(__put_user_2) SYM_FUNC_START(__put_user_nocheck_2) - ENDBR ASM_STAC 4: movw %ax,(%_ASM_CX) xor %ecx,%ecx @@ -96,7 +94,6 @@ SYM_FUNC_END(__put_user_4) EXPORT_SYMBOL(__put_user_4) SYM_FUNC_START(__put_user_nocheck_4) - ENDBR ASM_STAC 6: movl %eax,(%_ASM_CX) xor %ecx,%ecx @@ -119,7 +116,6 @@ SYM_FUNC_END(__put_user_8) EXPORT_SYMBOL(__put_user_8) SYM_FUNC_START(__put_user_nocheck_8) - ENDBR ASM_STAC 9: mov %_ASM_AX,(%_ASM_CX) #ifdef CONFIG_X86_32