From: Joe Lawrence <joe.lawrence@redhat.com>
To: live-patching@vger.kernel.org
Cc: Josh Poimboeuf <jpoimboe@kernel.org>, Song Liu <song@kernel.org>,
Miroslav Benes <mbenes@suse.cz>, Petr Mladek <pmladek@suse.com>
Subject: [RFC 0/4] klp-build: simple OOT module support
Date: Tue, 12 May 2026 18:10:58 -0400 [thread overview]
Message-ID: <20260512221102.2720763-1-joe.lawrence@redhat.com> (raw)
This patchset introduces support for patching basic out-of-tree (OOT)
modules. The primary motivation is to streamline testing for objtool klp
diff by providing a flexible and stable environment.
While much of the objtool klp diff logic can be validated using standard
in-tree modules (avoiding the overhead of full kernel rebuilds), OOT
support provides significant value for reproducing and fixing specific
kernel code patterns. Standard in-tree drivers are subject to frequent
refactoring and API updates, making them unreliable for producing the
consistent binary patterns required for stable testing. While dedicated
test modules could be introduced into the kernel tree to ensure
stability, starting with OOT modules allows for faster iteration before
committing to a permanent in-tree landing spot.
For an example, I have inlined a module below used to verify Josh's
latest commit ("objtool/klp: Rewrite symbol correlation algorithm")
[1]. This specific test case confirms that his patch resolves the
thinLTO ambiguity issue originally reported by Song Liu in February [2].
[1] https://lore.kernel.org/live-patching/cq5uytz6edj75w53f2eubypvqm66hgh4eag7ec2vgqjefzzqts@lcnvt7fcrtmd/T/#mbfaf71b314b6600424f9c5504c415a2e3a87ade3
[2] https://lore.kernel.org/live-patching/20260226005436.379303-9-song@kernel.org
To make full use of the example OOT module, I have additional test-
harness code that automates fetching pre-built object files, integrating
with kselftests, etc. I chose to spin out this basic OOT support
first since it mostly stands alone and may have other helpful contexts.
-->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8--
==> Kbuild <==
obj-m := klp_test_ambig.o
klp_test_ambig-y := klp_test_ambig_a.o klp_test_ambig_b.o klp_test_ambig_c.o
==> klp_test_ambig_a.c <==
#include <linux/module.h>
#include <linux/kernel.h>
#include "klp_test_ambig.h"
static noinline int __helper(int x, int len)
{
int i, sum = x;
for (i = 0; i < len; i++)
sum += i + 5;
if (sum > 1000)
sum = 0;
return sum;
}
static int value_a;
int klp_test_ambig_func_a(int x)
{
value_a = __helper(value_a, x);
return value_a;
}
EXPORT_SYMBOL_GPL(klp_test_ambig_func_a);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("ThinLTO demangled ambiguity test module");
==> klp_test_ambig_b.c <==
#include <linux/module.h>
#include <linux/kernel.h>
#include "klp_test_ambig.h"
static noinline int __helper(int x, int len)
{
int i, sum = x;
for (i = 0; i < len; i++)
sum += i + 10;
if (sum > 1000)
sum = 0;
return sum;
}
static int value_b;
int klp_test_ambig_func_b(int x)
{
value_b = __helper(value_b, x);
return value_b;
}
EXPORT_SYMBOL_GPL(klp_test_ambig_func_b);
==> klp_test_ambig_c.c <==
#include <linux/module.h>
#include <linux/kernel.h>
#include "klp_test_ambig.h"
static int value_c;
int klp_test_ambig_func_c(int x)
{
value_c = klp_test_ambig_func_a(x) + klp_test_ambig_func_b(x);
return value_c;
}
EXPORT_SYMBOL_GPL(klp_test_ambig_func_c);
==> klp_test_ambig.h <==
#ifndef _KLP_TEST_AMBIG_H
#define _KLP_TEST_AMBIG_H
int klp_test_ambig_func_a(int x);
int klp_test_ambig_func_b(int x);
int klp_test_ambig_func_c(int x);
#endif
==> 0001-thin-lto-demangled-ambiguity.patch <==
From 2d208e686739b1ccccfe385e837b5a4a04a9526f Mon Sep 17 00:00:00 2001
From: klp-build-test <test@example.com>
Date: Sat, 28 Mar 2026 13:55:56 +0000
Subject: [PATCH] thin-lto-demangled-ambiguity
ThinLTO two __helper.llvm.* symbols with disjoint hashes; objtool correlates
---
klp_test_ambig_a.c | 2 +-
klp_test_ambig_b.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/klp_test_ambig_a.c b/klp_test_ambig_a.c
index cc4db70..4ee26a5 100644
--- a/klp_test_ambig_a.c
+++ b/klp_test_ambig_a.c
@@ -7,7 +7,7 @@ static noinline int __helper(int x, int len)
int i, sum = x;
for (i = 0; i < len; i++)
- sum += i + 5;
+ sum += i * 2 + 5;
if (sum > 1000)
sum = 0;
return sum;
diff --git a/klp_test_ambig_b.c b/klp_test_ambig_b.c
index ca114b0..1b7ce1a 100644
--- a/klp_test_ambig_b.c
+++ b/klp_test_ambig_b.c
@@ -7,7 +7,7 @@ static noinline int __helper(int x, int len)
int i, sum = x;
for (i = 0; i < len; i++)
- sum += i + 10;
+ sum += i * 2 + 10;
if (sum > 1000)
sum = 0;
return sum;
--
2.53.0
-->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8--
Applies on top of:
tree: git://git.kernel.org/pub/scm/linux/kernel/git/jpoimboe/linux.git
branch: klp-build-arm64
commit: fffce0ac08e0 ("klp-build: Add arm64 syscall patching macro")
Joe Lawrence (4):
objtool/klp: add --symvers option to klp diff
objtool/klp: allow special section entry size overrides
objtool/klp: add --arch option to display target architecture
livepatch/klp-build: add basic out-of-tree module patching support
scripts/livepatch/klp-build | 90 ++++++++++++++++++++++++++++---------
tools/objtool/Makefile | 3 +-
tools/objtool/klp-diff.c | 49 +++++++++++++++++---
3 files changed, 115 insertions(+), 27 deletions(-)
--
2.53.0
next reply other threads:[~2026-05-12 22:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 22:10 Joe Lawrence [this message]
2026-05-12 22:10 ` [RFC 1/4] objtool/klp: add --symvers option to klp diff Joe Lawrence
2026-05-12 22:11 ` [RFC 2/4] objtool/klp: allow special section entry size overrides Joe Lawrence
2026-05-12 22:11 ` [RFC 3/4] objtool/klp: add --arch option to display target architecture Joe Lawrence
2026-05-12 22:11 ` [RFC 4/4] livepatch/klp-build: add basic out-of-tree module patching support Joe Lawrence
2026-05-12 23:30 ` [RFC 0/4] klp-build: simple OOT module support Song Liu
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=20260512221102.2720763-1-joe.lawrence@redhat.com \
--to=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=pmladek@suse.com \
--cc=song@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