Re: [PATCH v2] livepatch: clear internal flags at init
From: Petr Mladek
Date: Tue Nov 24 2026 - 08:35:42 EST
On Mon 2026-11-23 10:40:00, Yafang Shao wrote:
> 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@xxxxxxx>
> Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx>
It looks a bit ad-hoc to initialize these two internal flags and
not the others, e.g. obj->patched. But maybe the other flags
just get assigned a value later.
I could live with this:
Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>
I am going to wait few more days for a possible feedback.
I will commit this patch by the end of this week unless
anyone complains.
Best Regards,
Petr