From: "tip-bot2 for Puranjay Mohan" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Puranjay Mohan <puranjay@kernel.org>,
Joe Lawrence <joe.lawrence@redhat.com>,
Song Liu <song@kernel.org>, Josh Poimboeuf <jpoimboe@kernel.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: objtool/core] objtool/klp: Reject changed functions without an ftrace call site
Date: Wed, 25 Nov 2026 08:40:47 -0000 [thread overview]
Message-ID: <179559604701.92412.13543579922017019723.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20261022171637.3298443-3-puranjay@kernel.org>
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: dee7e5a566e777ec9c5d1dfc61bc1320412cab46
Gitweb: https://git.kernel.org/tip/dee7e5a566e777ec9c5d1dfc61bc1320412cab46
Author: Puranjay Mohan <puranjay@kernel.org>
AuthorDate: Thu, 22 Oct 2026 10:16:35 -07:00
Committer: Josh Poimboeuf <jpoimboe@kernel.org>
CommitterDate: Sat, 21 Nov 2026 23:38:31 -08:00
objtool/klp: Reject changed functions without an ftrace call site
Livepatch redirects a function through its ftrace call site. If a
changed function doesn't have one, klp-build succeeds but the patch
module fails to load:
livepatch: failed to find location for function 'nsproxy_free'
livepatch: failed to patch object 'vmlinux'
livepatch: failed to enable patch 'livepatch_nsproxy'
This is easy to hit because the kernel's 'inline' implies notrace, so
any inline function which the compiler emits out of line can't be
patched.
Make klp diff fail for any changed function which has no __mcount_loc
entry in the original object.
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
Acked-by: Song Liu <song@kernel.org>
Link: https://patch.msgid.link/20261022171637.3298443-3-puranjay@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
tools/objtool/include/objtool/elf.h | 1 +-
tools/objtool/klp-diff.c | 44 ++++++++++++++++++++++++++++-
2 files changed, 45 insertions(+)
diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
index a82517a..f7e6a65 100644
--- a/tools/objtool/include/objtool/elf.h
+++ b/tools/objtool/include/objtool/elf.h
@@ -98,6 +98,7 @@ struct symbol {
u8 klp : 1;
u8 dont_correlate : 1;
u8 fake : 1;
+ u8 traceable : 1;
struct list_head pv_target;
struct reloc *relocs;
struct section *group_sec;
diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index 34da55e..95d0d86 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -1098,6 +1098,47 @@ static int mark_changed_functions(struct elfs *e)
return !changed ? 1 : 0;
}
+static void mark_traceable_functions(struct elf *elf)
+{
+ struct section *sec;
+ struct reloc *reloc;
+
+ sec = find_section_by_name(elf, "__mcount_loc");
+ if (!sec || !sec->rsec)
+ return;
+
+ for_each_reloc(sec->rsec, reloc) {
+ struct symbol *func;
+
+ func = find_func_containing(reloc->sym->sec,
+ reloc->sym->offset + reloc_addend(reloc));
+ if (func)
+ func->traceable = 1;
+ }
+}
+
+/*
+ * Livepatch redirects functions through their ftrace call sites, so a function
+ * without one can't be patched.
+ */
+static int validate_traceable_functions(struct elfs *e)
+{
+ struct symbol *patched_sym;
+ bool error = false;
+
+ mark_traceable_functions(e->orig);
+
+ for_each_sym(e->patched, patched_sym) {
+ if (!patched_sym->changed || patched_sym->twin->traceable)
+ continue;
+
+ ERROR("%s: no ftrace call site, can't patch", patched_sym->twin->name);
+ error = true;
+ }
+
+ return error ? -1 : 0;
+}
+
static int clone_included_functions(struct elfs *e)
{
struct symbol *patched_sym;
@@ -2260,6 +2301,9 @@ int cmd_klp_diff(int argc, const char **argv)
if (ret > 0)
return 0;
+ if (validate_traceable_functions(&e))
+ return -1;
+
e.out = elf_create_file(&e.orig->ehdr, argv[2]);
if (!e.out)
return -1;
parent reply other threads:[~2026-11-25 8:40 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20261022171637.3298443-3-puranjay@kernel.org>]
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=179559604701.92412.13543579922017019723.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=puranjay@kernel.org \
--cc=song@kernel.org \
--cc=x86@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
all inboxes | Powered by JetHome®