public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Josh Poimboeuf <jpoimboe@kernel.org>, Song Liu <song@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	peterz@infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.19] objtool/klp: Disable unsupported pr_debug() usage
Date: Tue, 17 Mar 2026 07:32:38 -0400	[thread overview]
Message-ID: <20260317113249.117771-7-sashal@kernel.org> (raw)
In-Reply-To: <20260317113249.117771-1-sashal@kernel.org>

From: Josh Poimboeuf <jpoimboe@kernel.org>

[ Upstream commit e476bb277cf91b7ac3ea803ec78a4f0791bddec3 ]

Instead of erroring out on unsupported pr_debug() (e.g., when patching a
module), issue a warning and make it inert, similar to how unsupported
tracepoints are currently handled.

Reviewed-and-tested-by: Song Liu <song@kernel.org>
Link: https://patch.msgid.link/3a7db3a5b7d4abf9b2534803a74e2e7231322738.1770759954.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

## Analysis

### Commit Overview
This commit fixes objtool's `klp-diff` subcommand to handle `pr_debug()`
usage in livepatch modules targeting kernel modules. Previously,
encountering a `pr_debug()` static branch key (identified by
`__UNIQUE_ID_ddebug_` symbol name) would hit the generic "unsupported
static branch key" error path and fail. The fix adds a specific check
for these symbols and treats them like tracepoints — issuing a warning
and making them inert (skipping the entry) rather than erroring out.

### Code Change Analysis
The change is small and surgical — **7 lines of new code** that follow
an identical pattern already used for tracepoints:

```c
if (strstr(reloc->sym->name, "__UNIQUE_ID_ddebug_")) {
    WARN("%s: disabling unsupported pr_debug()",
         code_sym->name);
    ret = 1;
    continue;
}
```

This mirrors the existing tracepoint handling at lines 1396-1401 of the
current file. The logic is simple: detect the dynamic debug symbol,
warn, and skip it instead of failing.

### Bug Classification
This is a **build/tool fix**: Without it, objtool errors out with a
misleading "unsupported static branch key" error when building livepatch
modules that use `pr_debug()`. The `pr_debug()` static branch key lives
in the target module and can't be resolved via klp relocation, but
disabling it is harmless (the debug output simply won't work in the
patched function). This is the same reasoning used for tracepoints.

### Applicability to Stable Trees
The file `tools/objtool/klp-diff.c` was **introduced in v6.19** (commit
`dd590d4d57ebe`, September 2025). This means:
- Older stable trees (6.6.y, 6.1.y, 5.15.y, etc.) **do not contain this
  file** — the patch is irrelevant for them.
- For **6.19.y stable**, this is a relevant fix that prevents a tool
  error for livepatch developers.

### Stable Criteria Assessment
- **Fixes a real bug**: Yes — objtool incorrectly rejects valid
  livepatch modules that use `pr_debug()`.
- **Obviously correct and tested**: Yes — reviewed and tested by Song
  Liu (Meta's livepatch maintainer). The pattern exactly mirrors
  existing tracepoint handling.
- **Small and contained**: Yes — 7 lines of new code in one file,
  following an existing pattern.
- **No new features**: Correct — this makes existing functionality work
  correctly, not adding new capability.
- **Risk**: Very low — the check is specific to `__UNIQUE_ID_ddebug_`
  symbols, and the behavior (warn + skip) matches the existing
  tracepoint handling.

### Author and Review
Josh Poimboeuf is the objtool maintainer and one of the key livepatch
developers. Song Liu provided "Reviewed-and-tested-by", confirming both
code correctness and functional testing.

### Verification
- Read `tools/objtool/klp-diff.c` at lines 1310-1420 to confirm the
  current state lacks the pr_debug() check and to verify the existing
  tracepoint handling pattern the fix mirrors.
- Verified via git log that `klp-diff.c` was introduced in commit
  `dd590d4d57ebe` in v6.19 — the file does not exist in older stable
  trees.
- Confirmed the current repo is at v6.19.8 and does not yet contain this
  fix.
- The fix adds the check between the tracepoint check (line 1396) and
  the generic error (line 1403), which is the correct location.
- The commit was authored by Josh Poimboeuf (objtool maintainer) and
  reviewed/tested by Song Liu (livepatch maintainer) — high confidence
  in correctness.

### Risk vs. Benefit
- **Benefit**: Fixes a real build-time error that prevents creating
  livepatch modules containing `pr_debug()` calls.
- **Risk**: Minimal — small, pattern-following change in a build tool,
  with maintainer review and testing.

This is a small, well-tested fix for a real functional issue in
objtool's livepatch support. It only applies to 6.19.y stable (the file
doesn't exist in older trees), but for that version it prevents a
legitimate build error.

**YES**

 tools/objtool/klp-diff.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index 9f1f4011eb9cd..4691f423fca5c 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -1334,18 +1334,18 @@ static bool should_keep_special_sym(struct elf *elf, struct symbol *sym)
  * be applied after static branch/call init, resulting in code corruption.
  *
  * Validate a special section entry to avoid that.  Note that an inert
- * tracepoint is harmless enough, in that case just skip the entry and print a
- * warning.  Otherwise, return an error.
+ * tracepoint or pr_debug() is harmless enough, in that case just skip the
+ * entry and print a warning.  Otherwise, return an error.
  *
- * This is only a temporary limitation which will be fixed when livepatch adds
- * support for submodules: fully self-contained modules which are embedded in
- * the top-level livepatch module's data and which can be loaded on demand when
- * their corresponding to-be-patched module gets loaded.  Then klp relocs can
- * be retired.
+ * TODO: This is only a temporary limitation which will be fixed when livepatch
+ * adds support for submodules: fully self-contained modules which are embedded
+ * in the top-level livepatch module's data and which can be loaded on demand
+ * when their corresponding to-be-patched module gets loaded.  Then klp relocs
+ * can be retired.
  *
  * Return:
  *   -1: error: validation failed
- *    1: warning: tracepoint skipped
+ *    1: warning: disabled tracepoint or pr_debug()
  *    0: success
  */
 static int validate_special_section_klp_reloc(struct elfs *e, struct symbol *sym)
@@ -1400,6 +1400,13 @@ static int validate_special_section_klp_reloc(struct elfs *e, struct symbol *sym
 				continue;
 			}
 
+			if (strstr(reloc->sym->name, "__UNIQUE_ID_ddebug_")) {
+				WARN("%s: disabling unsupported pr_debug()",
+				     code_sym->name);
+				ret = 1;
+				continue;
+			}
+
 			ERROR("%s+0x%lx: unsupported static branch key %s.  Use static_key_enabled() instead",
 			      code_sym->name, code_offset, reloc->sym->name);
 			return -1;
-- 
2.51.0


  parent reply	other threads:[~2026-03-17 11:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-17 11:32 [PATCH AUTOSEL 6.19-6.1] ALSA: hda/realtek: add HP Laptop 14s-dr5xxx mute LED quirk Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.6] spi: intel-pci: Add support for Nova Lake mobile SPI flash Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19] objtool: Use HOSTCFLAGS for HAVE_XXHASH test Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.18] powerpc64/ftrace: fix OOL stub count with clang Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.12] nvmet: move async event work off nvmet-wq Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.12] drm/amdgpu: fix gpu idle power consumption issue for gfx v12 Sasha Levin
2026-03-17 11:32 ` Sasha Levin [this message]
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19] ALSA: usb-audio: Add iface reset and delay quirk for SPACETOUCH USB Audio Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.1] usb: core: new quirk to handle devices with zero configurations Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.12] ALSA: hda/realtek: add quirk for ASUS UM6702RC Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.6] objtool: Handle Clang RSP musical chairs Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.12] sched_ext: Use WRITE_ONCE() for the write side of dsq->seq update Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.1] btrfs: set BTRFS_ROOT_ORPHAN_CLEANUP during subvol create Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.18] ALSA: hda/realtek: Add quirk for Gigabyte Technology to fix headphone Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.12] i3c: master: dw-i3c: Fix missing of_node for virtual I2C adapter Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-5.10] ALSA: hda/realtek: Add headset jack quirk for Thinkpad X390 Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260317113249.117771-7-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=peterz@infradead.org \
    --cc=song@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox