From: sashiko-bot@kernel.org
To: jikos@kernel.org, joe.lawrence@redhat.com, song@kernel.org,
mbenes@suse.cz, "Yafang Shao" <laoar.shao@gmail.com>,
jpoimboe@kernel.org, pmladek@suse.com
Cc: live-patching@vger.kernel.org
Subject: Re: [PATCH v8 4/9] livepatch: Call klp_init_patch_early() earlier
Date: Wed, 09 Sep 2026 02:56:24 +0000 [thread overview]
Message-ID: <20260909025625.110F31F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909024324.16002-5-laoar.shao@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Fatal UAF / Kernel Panic on module unload due to unparented kobjects triggering delayed work in freed memory.
--
commit 92da60558ebea290d37fbe304d56429622a3eb02
Author: Yafang Shao <laoar.shao@gmail.com>
livepatch: Call klp_init_patch_early() earlier
Invoke klp_init_patch_early() during early initialization to avoid
mixing for_each_() and for_each_*_static() variants later in the code.
> diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
> index c34306ecfb0bb..f088955de8557 100644
> --- a/kernel/livepatch/core.c
> +++ b/kernel/livepatch/core.c
[ ... ]
> @@ -1152,10 +1145,17 @@ int klp_enable_patch(struct klp_patch *patch)
>
> 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);
> + ret = -EINVAL;
> + goto err;
> + }
> +
[Severity: High]
This is a pre-existing issue, but moving the compatibility check after
klp_init_patch_early() makes it highly reachable when an incompatible
patch is loaded. Could this lead to a use-after-free and kernel panic
during module unload?
When klp_init_patch_early() runs, it calls kobject_init() for child obj
and func objects. However, their parent pointers are not set until later
in klp_init_patch() via kobject_add().
If klp_is_patch_compatible() fails here, the error path calls
klp_free_patch_start() which puts these unparented child kobjects. Under
CONFIG_DEBUG_KOBJECT_RELEASE, their release functions are scheduled
asynchronously with a random delay.
Because the children lack parent pointers, they do not hold a reference to
patch->kobj. As a result, klp_free_patch_finish() will complete immediately
when waiting on patch->finish, and module_put(patch->mod) allows the module
to unload, freeing the statically allocated obj and func structures.
Later, when delayed release functions like klp_kobj_release_object() finally
execute, they will dereference obj->dynamic in freed memory.
> ret = klp_init_patch(patch);
> if (ret)
> goto err;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909024324.16002-1-laoar.shao@gmail.com?part=4
next prev parent reply other threads:[~2026-09-09 2:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 2:43 [PATCH v8 0/9] livepatch: Add support for scoped atomic replace Yafang Shao
2026-09-09 2:43 ` [PATCH v8 1/9] selftests/livepatch: Clarify test module file names Yafang Shao
2026-09-09 5:22 ` Song Liu
2026-09-09 2:43 ` [PATCH v8 2/9] selftests/livepatch: Adapt atomic replace tests to provides/obsoletes Yafang Shao
2026-09-09 5:27 ` Song Liu
2026-09-09 6:59 ` Yafang Shao
2026-09-09 2:43 ` [PATCH v8 3/9] livepatch: Make klp_find_func() non static Yafang Shao
2026-09-09 2:43 ` [PATCH v8 4/9] livepatch: Call klp_init_patch_early() earlier Yafang Shao
2026-09-09 2:56 ` sashiko-bot [this message]
2026-09-09 3:44 ` Yafang Shao
2026-09-09 2:43 ` [PATCH v8 5/9] livepatch: Implement provides and obsoletes for scoped atomic replace Yafang Shao
2026-09-09 2:43 ` [PATCH v8 6/9] livepatch: Deprecate stack_order Yafang Shao
2026-09-09 2:43 ` [PATCH v8 7/9] selftests/livepatch: Add provides/obsoletes test scenarios Yafang Shao
2026-09-09 2:43 ` [PATCH v8 8/9] selftests/livepatch: Add state test for provides/obsoletes Yafang Shao
2026-09-09 2:57 ` sashiko-bot
2026-09-09 7:30 ` Yafang Shao
2026-09-09 2:43 ` [PATCH v8 9/9] selftests/livepatch: Add function " Yafang Shao
2026-09-09 2:56 ` sashiko-bot
2026-09-09 7:01 ` 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=20260909025625.110F31F00A3A@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.