From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E36F4606A321 for ; Sat, 28 Nov 2026 20:15:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bIjAqVGN Received: by kanga.kvack.org (Postfix) id 9EA426B05B2; Sat, 28 Nov 2026 15:15:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 96F256B05B3; Sat, 28 Nov 2026 15:15:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 836B36B05B4; Sat, 28 Nov 2026 15:15:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EE59B6B05B2 for ; Sat, 28 Nov 2026 15:15:11 -0500 (EST) Received: from smtpin15.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5CBF7120709 for ; Sat, 28 Nov 2026 20:15:11 +0000 (UTC) X-FDA: 85485632022.15.3606A8A Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf14.hostedemail.com (Postfix) with ESMTP id A3735100002 for ; Sat, 28 Nov 2026 20:15:09 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=bIjAqVGN; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1795896909; b=ls9z4R3/DKAVjzO0iBlR5MhP2BSSHiP4lCiUYUG6CcA8/jMBK6TV4SpRBfDPh4wEXLUJkF 8FcCx888OSgzDo/d/F8fDhZuieUIVomYoshZSBgJ8+KaKKLqrylofeWxIm7atrRPUyQDtz t/HQe8anA7AHLak6acWkO9Fydm6U1RI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1795896909; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MDpXekE2pv0XGk9KZKNFtv9nmOULCWjqLEwiUs4oJS8=; b=YWwyHJ5+a4F5d30yqnTS7CMkgh+oKSbdBlca6CBHvuebhfEoOocEXdmSEOs35gT1zQjW7k hZDjkgjEXmZKkk1tch28+tBoIcPtkc6vOEfo3zywz+7J8mXNye5dqoatroaAGMXagDFWQ0 hIU/Uz4EGnb47Q5fAsFEpsRiJ24Epjs= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=bIjAqVGN; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id E62E343826; Sat, 28 Nov 2026 20:15:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE1481F00893; Sat, 28 Nov 2026 20:15:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795896908; bh=MDpXekE2pv0XGk9KZKNFtv9nmOULCWjqLEwiUs4oJS8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=bIjAqVGNKORPe/NJ00z5xEgDttLoWYpA9VNcGKLRDMBAPdEbEccWZM6XhTXhfYKWA /BEv8sbzDDP1Ab4T9g4Rbc1eYg2fvq/9bcgUjpishP3ZUokExmpoMe5lVoUdAoq8gj nmgpBXb3ygc6s/jCFWfhEmcs/hjqHklBAu30hZytPz6kH6alerRI2fviVZGuMbIWA/ BBjrAJfUSuZJheID3gjwqsn5B7n+R/q2sJAOGZMRdZ9NaazrUWJdy3dsqDIrM6ckWb VJ2MzECrD/As2OiHM8D24/ZQi5/EdceSAJg2DSFP4NDMra1nVgfzc167mb7OeQjlZp GW8jeS25MzECw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v10 06/10] objtool: Add .entry.text validation for static branches Reply-To: sashiko-reviews@lists.linux.dev To: "Valentin Schneider" , linux-mm@kvack.org, x86@kernel.org Cc: "Josh Poimboeuf" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , "H. Peter Anvin" , "Andy Lutomirski" , "Peter Zijlstra" , "Arnaldo Carvalho de Melo" , "Paolo Bonzini" , "Arnd Bergmann" , "Frederic Weisbecker" , "Paul E. McKenney" , "Jason Baron" , "Steven Rostedt" , "Ard Biesheuvel" , "Sami Tolvanen" , "David S. Miller" , "Neeraj Upadhyay" , "Joel Fernandes" , "Josh Triplett" , "Boqun Feng" , "Uladzislau Rezki" , "Mathieu Desnoyers" , "Mel Gorman" , "Andrew Morton" , "Masahiro Yamada" , "Han Shen" , "Rik van Riel" , "Jann Horn" , "Dan Carpenter" , "Oleg Nesterov" , "Juri Lelli" , "Clark Williams" , "Tomas Glozar" , "Yair Podemsky" , "Marcelo Tosatti" , "Daniel Wagner" , "Petr Tesarik" , "Shrikanth Hegde" , "Dan Beimborn" , "Pak Hung Vincent Chiu" In-Reply-To: <20261127201221.434876-7-vschneid@redhat.com> References: <20261127201221.434876-1-vschneid@redhat.com> <20261127201221.434876-7-vschneid@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 28 Nov 2026 20:15:05 +0000 X-Rspamd-Queue-Id: A3735100002 X-Stat-Signature: au48bxhxfw1g1nxqso73mnb3y489nd3o X-Rspam-User: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Rspamd-Server: rspam07 X-HE-Tag: 1795896909-680023 X-HE-Meta: U2FsdGVkX1/uYaejqtUU4ktanWep+IFpXRqhpCSJUqYDyPMB+37vsljJQnXpGThvL9RxnZ/P0tURugFBVORGu1eoJ6v94HtmJqOQxBMP1pGttIfpYWx5aSQ3kl19WrAVSFQgrc+S/SlFk/d/T1Yu4eE/LRqcxSSp6tceV4HM7vEUVAzDHLU7mgkZAPP2i6cfEjqtK+ElfAcrXVO+wyk0O7Qz0VPsYkar2jVQn8Kc+k6ly7+dK0MxGQwflFk54g9udLdt+KcoBdEjKB9KlmJQi2Xjfoq/4e28upeTVA6MRuG2gQ7pT5f00efXNF4qlN5ENU/IOYgQvgUjI2wXRfdXdQSw/Vh/LUQ6lBxkTRSrbiGBRzO6tdiDcah/e0GtlyaPPHdytt0PVL6DpWIYP9ILyj2gCpRVNWiII8GNgf9U3Qx6xlf5H86bL1qlJeBKMrRGXK0O49zJqdNqbcIq1pHcKEBFC+bd/9zPxSy3QfeMp9/7OJUym2izf76MNKJ99JCqY2P127S6mRlj09dVlOXomeEWPAHLvArCZo1G9FkE8V7KqHIgMaOL5Q/Pf6Aze9EDpnIErNfV7/GlaF3KhP94IzDbZ6OEdedODRwe2GDZs6JvVEDogj1juztkChU53qQRek34UPZMNV8linYltoGDSzIUy49gETCZRQ/a2ci3Kw2UPpgNjO93a9AFzOxtvMWJ8rxQekzfhku0A5WYtS5nscDmgvp8veitVorddvfUGNeHLYuiqHhMp6ejHnhxWjXJCdfNQ9Da8c+r5oqmbXt9y28HU1+PAAf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y0ImUo+oI2tme3pnZxGawtfwrg8nq9TxFxJhTzvKAtZ Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [High] objtool: broken jump_label NOP patching for embedded keys in get_alt_entry() - [Medium] objtool: missing state.entry update on cross-section jumps into .entry.text - [Low] objtool: stray vmlinux.o warning line in Documentation/objtool.txt - [Low] objtool: rebase leftovers in objtool.h and read_entry_allowed() -- commit 4d5983578f6c402f752685ea2eda9b0819f6691d Author: Josh Poimboeuf objtool: Add .entry.text validation for static branches This commit adds objtool validation to warn when a static branch in .entry.text uses a static key that has not been annotated with ANNOTATE_ENTRY_ALLOWED(). > diff --git a/include/linux/objtool.h b/include/linux/objtool.h > index af2e68e496e5d..e3d240a03e4c5 100644 > --- a/include/linux/objtool.h > +++ b/include/linux/objtool.h > @@ -34,6 +34,19 @@ > static void __used __section(".discard.func_stack_frame_non_standard") \ > *__func_stack_frame_non_standard_##func =3D func > =20 > +#define __ANNOTATE_ENTRY_ALLOWED(key) \ > + static void __used __section(".discard.entry_allowed") \ > + *__annotate_entry_allowed_##key =3D &key > + > +/* > + * This is used to tell objtool that a given static key is safe to be us= ed > + * within .noinstr code, and it doesn't need to generate a warning about= it. > + * > + * For more information, see tools/objtool/Documentation/objtool.txt, > + * "non-RO static key usage in entry code" > + */ > +#define ANNOTATE_ENTRY_ALLOWED(key) __ANNOTATE_ENTRY_ALLOWED(key) > + > /* > * STACK_FRAME_NON_STANDARD_FP() is a frame-pointer-specific function ig= nore > * for the case where a function is intentionally missing frame pointer = setup, > @@ -111,6 +124,9 @@ > #define UNWIND_HINT(type, sp_reg, sp_offset, signal) "\n\t" > #define STACK_FRAME_NON_STANDARD(func) > #define STACK_FRAME_NON_STANDARD_FP(func) > +#define __ASM_ANNOTATE(label, type) "" > +#define ASM_ANNOTATE(type) > +#define ANNOTATE_ENTRY_ALLOWED(key) > #else > .macro UNWIND_HINT type:req sp_reg=3D0 sp_offset=3D0 signal=3D0 > .endm [Severity: Low] This isn't a bug, but the !CONFIG_OBJTOOL block re-introduces a dead two-argument __ASM_ANNOTATE(label, type) macro and a duplicate ASM_ANNOTATE(type) definition that were moved to include/linux/annotate.h in d2c60bde1c0f ("objtool: Move ANNOTATE* macros to annotate.h") and updated in 305c8dc47717 ("objtool: Consolidate annotation macros"). Also, the comment above ANNOTATE_ENTRY_ALLOWED() still refers to .noinstr code rather than .entry.text, and the fatal return -1 paths in read_entry_allowed() in tools/objtool/check.c use WARN_FUNC() and WARN() instead of ERROR_FUNC() and ERROR() per 3e7be635937d ("objtool: Change "warning:" to "error: " for fatal errors"). > diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Docu= mentation/objtool.txt > index 9e97fc25b2d8a..bb35a422c9a80 100644 > --- a/tools/objtool/Documentation/objtool.txt > +++ b/tools/objtool/Documentation/objtool.txt > @@ -456,6 +456,21 @@ the objtool maintainers. > these special names and does not use module_init() / module_exit() > macros to create them. > =20 > +vmlinux.o: warning: objtool: entry_SYSCALL_64+0x108: housekeeping_overri= dden: non-RO static key usage in entry code > + > +13. file.o: warning: func()+0x2a: key: non-RO static key usage in entry = code [Severity: Low] Was the raw vmlinux.o warning line above item 13 left in by mistake? > diff --git a/tools/objtool/check.c b/tools/objtool/check.c > index 1b6fab9334566..2e1ad2247446c 100644 > --- a/tools/objtool/check.c > +++ b/tools/objtool/check.c > @@ -327,8 +327,10 @@ static void init_insn_state(struct objtool_file *fil= e, struct insn_state *state, > memset(state, 0, sizeof(*state)); > init_cfi_state(&state->cfi); > =20 > - if (opts.noinstr && sec) > + if (opts.noinstr && sec) { > state->noinstr =3D sec->noinstr; > + state->entry =3D sec->entry; > + } > } [ ... ] > @@ -3579,6 +3628,17 @@ static int validate_return(struct symbol *func, st= ruct instruction *insn, struct > return 0; > } > =20 > +static int validate_static_key(struct instruction *insn, struct insn_sta= te *state) > +{ > + if (state->entry && !insn->key->entry_allowed) { > + WARN_INSN(insn, "%s: non-RO static key usage in entry code", > + insn->key->name); > + return 1; > + } > + > + return 0; > +} [Severity: Medium] Can a cross-section jump from .text into .entry.text cause validate_static_key() to miss static keys in .entry.text? init_insn_state() sets state->entry from the section where validation start= s, and state->entry is never updated when following an intra-file jump into another section. On vmlinux.o builds, validate_file_unwind_hints() validat= es .text before .entry.text: in arch/x86/entry/entry_64.S, ret_from_fork_asm in .text starts with an unwind hint and jumps to swapgs_restore_regs_and_return_to_usermode (an inner label of common_interrupt_return) in .entry.text. Because that path is first traversed from .text with state.entry =3D=3D false and marked visited, the = later pass over .entry.text sees insn->visited already set and returns early without checking static keys along that shared return path. Could validate_static_key() check insn->sec->entry (or update state->entry = on cross-section jumps) so .entry.text instructions are still validated? [ ... ] > diff --git a/tools/objtool/special.c b/tools/objtool/special.c > index 2a533afbc69aa..adec1d0d8a5fe 100644 > --- a/tools/objtool/special.c > +++ b/tools/objtool/special.c > @@ -111,13 +111,26 @@ static int get_alt_entry(struct elf *elf, const str= uct special_entry *entry, > =20 > if (entry->key) { > struct reloc *key_reloc; > + struct symbol *key; > + s64 key_addend; > =20 > key_reloc =3D find_reloc_by_dest(elf, sec, offset + entry->key); > if (!key_reloc) { > ERROR_FUNC(sec, offset + entry->key, "can't find key reloc"); > return -1; > } > - alt->key_addend =3D reloc_addend(key_reloc); > + > + key =3D key_reloc->sym; > + key_addend =3D reloc_addend(key_reloc); > + > + if (key->type =3D=3D STT_SECTION) > + key =3D find_symbol_by_offset(key->sec, key_addend & ~3); > + > + /* embedded keys not supported */ > + if (key) { > + alt->key =3D key; > + alt->key_addend =3D key_addend; > + } > } > =20 > return 0; [Severity: High] Does guarding alt->key_addend =3D key_addend with if (key) break jump_label NOP patching for embedded static keys? When a static key is embedded at a non-zero offset inside a static struct (such as key.dd_key_false inside static struct _ddebug for every pr_debug() and dev_dbg() site under CONFIG_DYNAMIC_DEBUG=3Dy), the __jump_table key relocation uses STT_SECTION and find_symbol_by_offset(key->sec, key_addend & ~3) returns NULL. Leaving alt->key_addend as 0 causes handle_jump_alt() to skip the opts.hack_jump_label && special_alt->key_addend & 2 rewrite from an initial jmp to a NOP. As a result, all such initially-disabled static branches execute as unconditional jumps from boot, and toggling one at runtime triggers a BUG() in __jump_label_patch() when the instruction bytes do not match the expected NOP. Setting alt->key_addend =3D key_addend unconditionally outside if (key) wou= ld preserve the jump_label hack rewrite even when the symbol cannot be resolve= d. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261127201221.4348= 76-1-vschneid@redhat.com?part=3D6