mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yafang Shao <laoar.shao@gmail.com>
To: jpoimboe@kernel.org, mbenes@suse.cz, pmladek@suse.com,
	joe.lawrence@redhat.com, song@kernel.org
Cc: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH v2] livepatch: clear internal flags at init
Date: Mon, 23 Nov 2026 10:40:00 +0800	[thread overview]
Message-ID: <20261123024000.15130-1-laoar.shao@gmail.com> (raw)

func->nop and obj->dynamic are internal flags. However, a patch module can
set them in its static initializer and nothing validates that. The release
path uses them to decide whether kfree() has to be called, so with such a
patch the kernel ends up calling kfree() on memory it does not own.

Explicitly clear these flags during init to avoid that.

Suggested-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 kernel/livepatch/core.c | 2 ++
 1 file changed, 2 insertions(+)

---

v1->v2: clear these flag at init and simply the commit log (Miroslav)

v1: https://lore.kernel.org/live-patching/20261116130402.76743-1-laoar.shao@gmail.com/

diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 517fe427ff92..98a81ec203dc 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -952,6 +952,7 @@ static void klp_init_func_early(struct klp_object *obj,
 	kobject_get(&obj->kobj);
 	list_add_tail(&func->node, &obj->func_list);
 	func->obj = obj;
+	func->nop = false;
 }
 
 static void klp_init_object_early(struct klp_patch *patch,
@@ -962,6 +963,7 @@ static void klp_init_object_early(struct klp_patch *patch,
 	kobject_get(&patch->kobj);
 	list_add_tail(&obj->node, &patch->obj_list);
 	obj->patch = patch;
+	obj->dynamic = false;
 }
 
 static void klp_init_patch_early(struct klp_patch *patch)
-- 
2.52.0


                 reply	other threads:[~2026-11-23  2:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261123024000.15130-1-laoar.shao@gmail.com \
    --to=laoar.shao@gmail.com \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=pmladek@suse.com \
    --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

all inboxes | Powered by JetHome®