From: sashiko-bot@kernel.org
To: live-patching@vger.kernel.org, "Song Liu" <song@kernel.org>
Cc: jpoimboe@kernel.org, mbenes@suse.cz, jikos@kernel.org,
joe.lawrence@redhat.com, pmladek@suse.com
Subject: Re: [RFC] livepatch: Add integration tests for klp-build toolchain
Date: Sat, 03 Oct 2026 22:11:38 +0000 [thread overview]
Message-ID: <20261003221138.B514E1F0089B@smtp.kernel.org> (raw)
In-Reply-To: <20261003220433.1539629-1-song@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] livepatch: use-after-free in klp_test_module_init() via dangling klp_test_kobj pointer
- [Medium] livepatch: memory leak of klp_test_module_kobj on sysfs_create_group() failure
--
commit 440c68ecb776cce99d846849a24bfeacf1e70de3
Author: Song Liu <song@kernel.org>
Subject: livepatch: Add integration tests for klp-build toolchain
This commit adds integration tests for the klp-build toolchain, including
kernel side dummy code built into vmlinux and as a loadable module. It
provides sysfs interfaces to verify livepatches and exercises ThinLTO
suffix handling.
Link: https://lore.kernel.org/live-patching/20260226005436.379303-9-song@kernel.org/
[Severity: Medium]
In lib/livepatch/klp_test_module.c, inside klp_test_module_init() at line
95, the code returns the result of sysfs_create_group() directly. If this
function fails, does it bypass the cleanup for the recently created
klp_test_module_kobj? Should there be a call to
kobject_put(klp_test_module_kobj) on this error path to prevent a memory
leak?
[Severity: High]
In lib/livepatch/klp_test_vmlinux.c, inside klp_test_vmlinux_init() at
lines 105 and 126, there are error paths where klp_test_kobj is freed via
kobject_put(klp_test_kobj). However, the globally exported pointer
klp_test_kobj is not reset to NULL.
Since klp_test_vmlinux_init() is a late_initcall, an error here does not
halt the system boot. Later, when the klp_test_module is loaded,
klp_test_module_init() in lib/livepatch/klp_test_module.c at line 90
attempts to pass this dangling klp_test_kobj pointer to
kobject_create_and_add() as the parent.
Could this sequence trigger a use-after-free when the kobject core attempts
to access the freed parent's refcount? Should klp_test_kobj be explicitly
set to NULL on the error paths in klp_test_vmlinux_init(), and should
klp_test_module_init() check if klp_test_kobj is valid before using it?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261003220433.1539629-1-song@kernel.org?part=1
prev parent reply other threads:[~2026-10-03 22:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-03 22:04 [RFC] livepatch: Add integration tests for klp-build toolchain Song Liu
2026-10-03 22:11 ` sashiko-bot [this message]
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=20261003221138.B514E1F0089B@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--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