From: sashiko-bot@kernel.org
To: jikos@kernel.org, pmladek@suse.com, song@kernel.org,
mbenes@suse.cz, jpoimboe@kernel.org, joe.lawrence@redhat.com
Cc: "Yafang Shao" <laoar.shao@gmail.com>, live-patching@vger.kernel.org
Subject: Re: [PATCH v2 2/4] livepatch: Support scoped atomic replace using replace_set
Date: Fri, 29 May 2026 04:32:11 +0000 [thread overview]
Message-ID: <20260529043212.1F2ED1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260529034542.68766-3-laoar.shao@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] A malformed livepatch module with a missing function `old_name` will cause a kernel panic during patch compatibility checking.
--
commit 48dd0b716d1f70f13c1e96b75bf54e1aba77be18
Author: Yafang Shao <laoar.shao@gmail.com>
livepatch: Support scoped atomic replace using replace_set
Convert the replace attribute from a boolean to a u32 to function as a
"replace set." A newly loaded livepatch will now atomically replace any
existing patch belonging to the same set. There can only ever be one active
livepatch for a given replace_set number.
Link: https://github.com/pmladek/linux/tree/klp-state-transfer-v1-iter12 [0]
> diff --git a/kernel/livepatch/state.c b/kernel/livepatch/state.c
> index 2565d039ade0a..a1ac466373360 100644
> --- a/kernel/livepatch/state.c
> +++ b/kernel/livepatch/state.c
[ ... ]
> @@ -85,34 +85,65 @@ EXPORT_SYMBOL_GPL(klp_get_prev_state);
[ ... ]
> + klp_for_each_object_static(patch, obj) {
> + klp_for_each_object(old_patch, old_obj) {
> + if (!!obj->name != !!old_obj->name)
> + continue;
> + if (obj->name && strcmp(obj->name, old_obj->name))
> + continue;
> + klp_for_each_func_static(obj, func) {
> + if (klp_find_func(old_obj, func))
> + return false;
> + }
> + }
> + }
[Severity: High]
Could a malformed livepatch module cause a kernel panic here during patch
compatibility checking?
Since klp_is_patch_compatible() is called in klp_enable_patch() before
klp_init_patch() validates the incoming patch structures, a malformed patch
might have func->old_name set to NULL but func->new_func populated.
In that scenario, klp_for_each_func_static() would still process the function
and pass it to klp_find_func(), where it is used as old_func:
kernel/livepatch/core.c:klp_find_func() {
...
klp_for_each_func(obj, func) {
if ((strcmp(old_func->old_name, func->old_name) == 0) &&
...
}
Would this result in a NULL pointer dereference when klp_find_func() attempts
to call strcmp() on the unvalidated function's old_name? While livepatch
modules are loaded by root, should they fail validation gracefully instead of
crashing the kernel?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260529034542.68766-1-laoar.shao@gmail.com?part=2
next prev parent reply other threads:[~2026-05-29 4:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 3:45 [PATCH v2 0/4] livepatch: Introduce replace set support Yafang Shao
2026-05-29 3:45 ` [PATCH v2 1/4] livepatch: Make klp_find_func() non-static Yafang Shao
2026-05-29 4:01 ` sashiko-bot
2026-05-29 9:07 ` Yafang Shao
2026-05-29 3:45 ` [PATCH v2 2/4] livepatch: Support scoped atomic replace using replace_set Yafang Shao
2026-05-29 4:32 ` sashiko-bot [this message]
2026-05-29 9:11 ` Yafang Shao
2026-05-29 3:45 ` [PATCH v2 3/4] livepatch: deprecate stack_order Yafang Shao
2026-05-29 4:54 ` sashiko-bot
2026-05-29 9:13 ` Yafang Shao
2026-05-29 3:45 ` [PATCH v2 4/4] selftests/livepatch: Update tests for replace_set Yafang Shao
2026-05-29 5:16 ` sashiko-bot
2026-05-29 9:12 ` Yafang Shao
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=20260529043212.1F2ED1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--cc=laoar.shao@gmail.com \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=pmladek@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.