From: Petr Pavlu <petr.pavlu@suse.com>
To: "Marek Maślanka" <mmaslanka@google.com>
Cc: rppt@kernel.org, akpm@linux-foundation.org, mcgrof@kernel.org,
regressions@lists.linux.dev, linux-modules@vger.kernel.org,
linux-mm@kvack.org, live-patching@vger.kernel.org,
joe.lawrence@redhat.com, jpoimboe@kernel.org, pmladek@suse.com
Subject: Re: ROX allocations broke livepatch for modules since 6.13-rc1
Date: Sun, 5 Jan 2025 15:51:36 +0100 [thread overview]
Message-ID: <c37395e2-1ab5-4175-9920-5144cf60e25e@suse.com> (raw)
In-Reply-To: <CAGcaFA2hdThQV6mjD_1_U+GNHThv84+MQvMWLgEuX+LVbAyDxg@mail.gmail.com>
On 12/30/24 01:09, Marek Maślanka wrote:
> Hi Mike and others,
>
> I discovered that the patch "[v7,4/8] module: prepare to handle ROX allocations
> for text" has disrupted livepatch functionality. Specifically, this occurs when
> livepatch is prepared to patch a kernel module and when the livepatch module
> contains a "special" relocation section named
> ".klp.rela.<MODULE_NAME>.<SECTION_NAME>" to access local symbols.
Thank you for the report. It is possible for me to reproduce the issue
on my system. An annoying part is to create the
.klp.rela.<objname>.<secname> data, for which I eventually used one
floating variant of klp-convert [1]. To hit the problem, <objname> must
point to an object that is different from vmlinux. Such relocations are
processed by the livepatch code later than regular module relocations,
as you pointed out after mod->rw_copy is already reset.
I think the bug should be addressed in principle by Mike's recently
posted rework of the feature [2] but unfortunately, its current version
makes my system also unbootable [3].
My reproducer:
$ cat test_klp_livepatch.c
#include <linux/kernel.h>
#include <linux/livepatch.h>
#include <linux/module.h>
#include <linux/seq_file.h>
extern __attribute__((weak)) void *xfs_btree_new_root asm("\".klp.sym.rela.xfs.xfs.xfs_btree_new_root.0\"");
static int livepatch_cmdline_proc_show(struct seq_file *m, void *v) {
seq_printf(m, "live patched: xfs_btree_new_root=%p\n", &xfs_btree_new_root); return 0; }
static struct klp_func funcs[] = { { .old_name = "cmdline_proc_show", .new_func = livepatch_cmdline_proc_show }, { } };
static struct klp_func xfs_funcs[] = { { } };
static struct klp_object objs[] = { { .funcs = funcs, }, { .name = "xfs", .funcs = xfs_funcs, }, { } };
static struct klp_patch patch = { .mod = THIS_MODULE, .objs = objs, };
static int test_klp_livepatch_init(void) { return klp_enable_patch(&patch); }
static void test_klp_livepatch_exit(void) { }
module_init(test_klp_livepatch_init);
module_exit(test_klp_livepatch_exit);
MODULE_LICENSE("GPL");
MODULE_INFO(livepatch, "Y");
MODULE_AUTHOR("Petr Pavlu <petr.pavlu@suse.com>");
MODULE_DESCRIPTION("Livepatch test: livepatch module");
$ make ...
$ klp-convert test_klp_livepatch.ko test_klp_livepatch.conv.ko # [1]
# modprobe -a xfs ./test_klp_livepatch.conv.ko
[1] https://lore.kernel.org/live-patching/20240827123052.9002-3-lhruska@suse.cz/
[2] https://lore.kernel.org/linux-modules/20241227072825.1288491-1-rppt@kernel.org/
[3] https://lore.kernel.org/linux-modules/86eba318-464b-4b9b-a79e-64039b17be34@lucifer.local/
--
Thanks,
Petr
next prev parent reply other threads:[~2025-01-05 14:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-30 0:09 Marek Maślanka
2025-01-05 14:51 ` Petr Pavlu [this message]
2025-01-06 19:45 ` Petr Pavlu
2025-01-07 15:34 ` [PATCH] module: Fix writing of livepatch relocations in ROX text Petr Pavlu
2025-01-09 8:06 ` Petr Mladek
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=c37395e2-1ab5-4175-9920-5144cf60e25e@suse.com \
--to=petr.pavlu@suse.com \
--cc=akpm@linux-foundation.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-modules@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=mmaslanka@google.com \
--cc=pmladek@suse.com \
--cc=regressions@lists.linux.dev \
--cc=rppt@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