From: Petr Mladek <pmladek@suse.com>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: mbenes@suse.cz, jikos@kernel.org, joe.lawrence@redhat.com,
jpoimboe@kernel.org, live-patching@vger.kernel.org,
sashiko-bot@kernel.org, song@kernel.org
Subject: Re: [PATCH v2] livepatch: Fix NULL pointer dereference in klp_find_func()
Date: Tue, 30 Jun 2026 17:50:21 +0200 [thread overview]
Message-ID: <akPlvWVbZlI-TqUS@pathway.suse.cz> (raw)
In-Reply-To: <20260628114635.33572-1-laoar.shao@gmail.com>
On Sun 2026-06-28 19:46:35, Yafang Shao wrote:
> A NULL old_name in a newly loaded livepatch's function entry causes a
> NULL pointer dereference in strcmp():
>
> klp_init_patch()
> klp_add_nops()
> klp_find_func()
> strcmp(old_func->old_name, func->old_name)
>
> Add klp_check_patch() at the beginning of klp_enable_patch() to reject
> patches with NULL old_name before they reach this code path.
>
> Reported-by: sashiko-bot <sashiko-bot@kernel.org>
> Closes: https://lore.kernel.org/live-patching/20260529040130.95A9C1F00893@smtp.kernel.org/
> Suggested-by: Petr Mladek <pmladek@suse.com>
> Suggested-by: Miroslav Benes <mbenes@suse.cz>
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> Acked-by: Miroslav Benes <mbenes@suse.cz>
Looks good to me:
Reviewed-by: Petr Mladek <pmladek@suse.com>
Tested-by: Petr Mladek <pmladek@suse.com>
I think whether to rush this into 7.2-rcX or wait for 7.3.
On one hand, it is a possible security fix. On the other hand,
broken module could never get loaded and pass even a minimal QA.
I tend to push it for 7.2-rcX just to avoid questions from people
who ignore the real life vulnerabilty aspect.
Also see a nit below.
> --- a/kernel/livepatch/core.c
> +++ b/kernel/livepatch/core.c
> @@ -1092,6 +1089,25 @@ static int __klp_enable_patch(struct klp_patch *patch)
> return ret;
> }
>
> +static int klp_check_patch(struct klp_patch *patch)
> +{
> + struct klp_object *obj;
> + struct klp_func *func;
> +
> + if (!patch || !patch->mod || !patch->objs)
> + return -EINVAL;
> +
> + klp_for_each_object_static(patch, obj) {
> + if (!obj->funcs)
> + return -EINVAL;
Nit: I would add an empty line here to make it better readable.
Of course, this is a personal preference. But it seems that
most contributors to this code prefer visual separators
between misc code sections as well.
No need for v3. I could add the empty line when pushing
the change.
> + klp_for_each_func_static(obj, func) {
> + if (!func->old_name)
> + return -EINVAL;
> + }
> + }
> + return 0;
> +}
> +
> /**
> * klp_enable_patch() - enable the livepatch
> * @patch: patch to be enabled
Best Regards,
Petr
prev parent reply other threads:[~2026-06-30 15:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 9:16 [PATCH] livepatch: Fix NULL pointer dereference in klp_find_func() Yafang Shao
2026-06-25 13:24 ` Miroslav Benes
2026-06-28 11:46 ` [PATCH v2] " Yafang Shao
2026-06-30 15:50 ` Petr Mladek [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=akPlvWVbZlI-TqUS@pathway.suse.cz \
--to=pmladek@suse.com \
--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=sashiko-bot@kernel.org \
--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