[PATCH AUTOSEL 6.19] objtool/klp: Disable unsupported pr_debug() usage
From: Sasha Levin
Date: Tue Mar 17 2026 - 07:34:09 EST
From: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
[ 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@xxxxxxxxxx>
Link: https://patch.msgid.link/3a7db3a5b7d4abf9b2534803a74e2e7231322738.1770759954.git.jpoimboe@xxxxxxxxxx
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
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