From: sashiko-bot@kernel.org
To: jpoimboe@kernel.org, jikos@kernel.org, mbenes@suse.cz,
pmladek@suse.com, joe.lawrence@redhat.com, song@kernel.org
Cc: live-patching@vger.kernel.org, "Yafang Shao" <laoar.shao@gmail.com>
Subject: Re: [RFC PATCH v4 2/4] livepatch: Call klp_init_patch_early() earlier
Date: Tue, 04 Aug 2026 07:03:35 +0000 [thread overview]
Message-ID: <20260804070336.5878F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804065010.44922-3-laoar.shao@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Moving klp_init_patch_early() before early failure checks violates the kobject API lifecycle and introduces missing cleanup on error paths.
--
--- Patch [2]: [RFC PATCH v4 2/4] livepatch: Call klp_init_patch_early() earlier ---
commit 6b8df20b82104d4c61053ebea3721f1d77891456
Author: Yafang Shao <laoar.shao@gmail.com>
livepatch: Call klp_init_patch_early() earlier
This commit moves the invocation of klp_init_patch_early() earlier in the
livepatch initialization process. This prepares the code for an upcoming
patch by avoiding mixing iteration variants later in the sequence.
> diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
> index e07c41a0f3ac8..c98cbcf59566d 100644
> --- a/kernel/livepatch/core.c
> +++ b/kernel/livepatch/core.c
> @@ -1135,6 +1135,8 @@ int klp_enable_patch(struct klp_patch *patch)
>
> mutex_lock(&klp_mutex);
>
> + klp_init_patch_early(patch);
> +
> if (!klp_is_patch_compatible(patch)) {
> pr_err("Livepatch patch (%s) is not compatible with the already installed livepatches.\n",
> patch->mod->name);
> @@ -1147,8 +1149,6 @@ int klp_enable_patch(struct klp_patch *patch)
> return -ENODEV;
> }
[Severity: Medium]
Since klp_init_patch_early() initializes kobjects for the patch, does
returning directly on compatibility or try_module_get() failures leak
these resources?
The kobject API requires that once kobject_init() is called, kobject_put()
must be used to release the object. Because klp_init_patch_early() is now
called before these checks, if we hit the early return paths in
klp_enable_patch(), we bypass cleaning up the initialized kobjects.
Also, would simply changing these early returns to jump to the err label
cause issues with klp_free_patch_finish()?
kernel/livepatch/core.c:klp_enable_patch() {
...
err:
klp_free_patch_start(patch);
mutex_unlock(&klp_mutex);
klp_free_patch_finish(patch);
return ret;
}
It looks like klp_free_patch_finish() calls module_put(patch->mod)
unconditionally. If try_module_get() failed, jumping to the err label
might underflow the module reference count.
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260804065010.44922-1-laoar.shao@gmail.com?part=2
next prev parent reply other threads:[~2026-08-04 7:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 6:50 [RFC PATCH v4 0/4] livepatch: Introduce replace set support Yafang Shao
2026-08-04 6:50 ` [RFC PATCH v4 1/4] livepatch: Make klp_find_func() non static Yafang Shao
2026-08-04 6:56 ` sashiko-bot
2026-08-04 8:04 ` Yafang Shao
2026-08-04 6:50 ` [RFC PATCH v4 2/4] livepatch: Call klp_init_patch_early() earlier Yafang Shao
2026-08-04 7:03 ` sashiko-bot [this message]
2026-08-04 8:00 ` Yafang Shao
2026-08-04 6:50 ` [RFC PATCH v4 3/4] livepatch: Implement replace set for scoped atomic replace Yafang Shao
2026-08-04 7:03 ` sashiko-bot
2026-08-04 7:15 ` Yafang Shao
2026-08-04 23:05 ` Song Liu
2026-08-05 2:54 ` Yafang Shao
2026-08-04 6:50 ` [RFC PATCH v4 4/4] livepatch: Deprecate stack_order 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=20260804070336.5878F1F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox