From: "Ard Biesheuvel" <ardb@kernel.org>
To: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
Cc: linux-efi@vger.kernel.org, linux-hardening@vger.kernel.org,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Kees Cook" <kees@kernel.org>, "Tony Luck" <tony.luck@intel.com>,
stable@vger.kernel.org, kernel-dev@igalia.com,
kernel@gpiccoli.net
Subject: Re: [PATCH] efi: pstore: Fix pstore_disable parameter setting (if built as module)
Date: Wed, 09 Sep 2026 17:32:57 +0200 [thread overview]
Message-ID: <273c9217-4630-4585-8cb5-3c5c8f0b77d3@app.fastmail.com> (raw)
In-Reply-To: <20260906235838.2928815-1-gpiccoli@igalia.com>
Hello Guilherme,
On Mon, 7 Sep 2026, at 01:55, Guilherme G. Piccoli wrote:
> Commit a28655c330ab ("efi: pstore: Allow dynamic initialization based
> on module parameter")
> introduced the functionality of switching the pstore_disable parameter,
> effectively allowing efi-pstore to be used even if builtin and having
> pstore_disabled=Y (a lot of distros do that at Kconfig level).
>
> Well, it also introduced a bug if efi-pstore is built as module and loaded
> with pstore_disable=N parameter. On load time, load_module() -> parse_args()
> calls our mod_param callback efi_pstore_disable_set(), which initializes
> efi_pstore, registering it as a pstore backend. Happens that, slightly
> later in the module loading process, do_init_module() calls our module
> init function, which currently ... retries registering us as a pstore
> backend. Since this was done successfully before, in the module parameter
> parsing, pstore_register() refuses to re-register us and efi-pstore ends-up
> clearing some structures, like freeing its data buffer allocated memory
> and setting its size to 0.
>
> Net effect of that: efi-pstore ends-up in a weird state, partially
> initialized but with cleared structures. More than that, if we try to
> unload it, it won't call pstore_unregister() but will get the module
> unloaded, hence pstore writes on oops or with other frontends will
> trigger NULL pointer dereferences.
>
> Fix it by guarding efivars_pstore_init() against re-running if the
> driver was previously initialized - this is kind of an analog to
> what is already done on efivars_pstore_exit() and fixes the issue.
>
> Fixes: a28655c330ab ("efi: pstore: Allow dynamic initialization based
> on module parameter")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
> ---
>
>
> Hi folks, apologies for introducing this bug =|
No worries :-)
>
> drivers/firmware/efi/efi-pstore.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/firmware/efi/efi-pstore.c
> b/drivers/firmware/efi/efi-pstore.c
> index a5db3534f0a6..2e125db7d43b 100644
> --- a/drivers/firmware/efi/efi-pstore.c
> +++ b/drivers/firmware/efi/efi-pstore.c
> @@ -263,6 +263,9 @@ static int efivars_pstore_init(void)
> if (pstore_disable)
> return 0;
>
> + if (efi_pstore_info.bufsize)
> + return 0;
> +
Can we please address the root cause rather than paper over it here?
What is the point of having a) a pstore_disable= param on a module
(which can be blacklisted or simply not loaded) and b) having it
runtime writable so pstore-efi can be toggled on/off at will?
Also, the practice of controlling the functionality of a builtin
diagnostic feature by poking something under /sys/module/foo/params
is in rather poor taste IMNSHO.
> /*
> * Notice that 1024 is the minimum here to prevent issues with
> * decompression algorithms that were spotted during tests;
> --
> 2.50.1
next prev parent reply other threads:[~2026-09-09 15:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 23:55 [PATCH] efi: pstore: Fix pstore_disable parameter setting (if built as module) Guilherme G. Piccoli
2026-09-09 15:32 ` Ard Biesheuvel [this message]
2026-09-09 17:12 ` Guilherme G. Piccoli
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=273c9217-4630-4585-8cb5-3c5c8f0b77d3@app.fastmail.com \
--to=ardb@kernel.org \
--cc=gpiccoli@igalia.com \
--cc=ilias.apalodimas@linaro.org \
--cc=kees@kernel.org \
--cc=kernel-dev@igalia.com \
--cc=kernel@gpiccoli.net \
--cc=linux-efi@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tony.luck@intel.com \
/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