From: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: kernel-dev@igalia.com, kernel@gpiccoli.net,
keescook@chromium.org, anton@enomsg.org, ccross@android.com,
tony.luck@intel.com, "Guilherme G. Piccoli" <gpiccoli@igalia.com>,
linux-efi@vger.kernel.org, Ard Biesheuvel <ardb@kernel.org>
Subject: [PATCH 8/8] efi: pstore: Add module parameter for setting the record size
Date: Thu, 6 Oct 2022 19:42:12 -0300 [thread overview]
Message-ID: <20221006224212.569555-9-gpiccoli@igalia.com> (raw)
In-Reply-To: <20221006224212.569555-1-gpiccoli@igalia.com>
By default, the efi-pstore backend hardcode the UEFI variable size
as 1024 bytes. That's not a big deal, but at the same time having
no way to change that in the kernel is a bit bummer for specialized
users - there is not such a limit in the UEFI specification.
So, add here a module parameter to enable advanced users to change
the UEFI record size for efi-pstore data collection.
Through empirical analysis we observed that extreme low values
(like 8 bytes) could eventually cause writing issues, so we limit
the low end to 1024 bytes (which is also the default).
Cc: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
---
drivers/firmware/efi/efi-pstore.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index 97a9e84840a0..78c27f6a83aa 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -10,7 +10,9 @@ MODULE_IMPORT_NS(EFIVAR);
#define DUMP_NAME_LEN 66
-#define EFIVARS_DATA_SIZE_MAX 1024
+static unsigned int record_size = 1024;
+module_param(record_size, uint, 0444);
+MODULE_PARM_DESC(record_size, "size of each pstore UEFI var (in bytes, min/default=1024)");
static bool efivars_pstore_disable =
IS_ENABLED(CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE);
@@ -30,7 +32,7 @@ static int efi_pstore_open(struct pstore_info *psi)
if (err)
return err;
- psi->data = kzalloc(EFIVARS_DATA_SIZE_MAX, GFP_KERNEL);
+ psi->data = kzalloc(record_size, GFP_KERNEL);
if (!psi->data)
return -ENOMEM;
@@ -52,7 +54,7 @@ static inline u64 generic_id(u64 timestamp, unsigned int part, int count)
static int efi_pstore_read_func(struct pstore_record *record,
efi_char16_t *varname)
{
- unsigned long wlen, size = EFIVARS_DATA_SIZE_MAX;
+ unsigned long wlen, size = record_size;
char name[DUMP_NAME_LEN], data_type;
efi_status_t status;
int cnt;
@@ -133,7 +135,7 @@ static ssize_t efi_pstore_read(struct pstore_record *record)
efi_status_t status;
for (;;) {
- varname_size = EFIVARS_DATA_SIZE_MAX;
+ varname_size = record_size;
/*
* If this is the first read() call in the pstore enumeration,
@@ -224,11 +226,14 @@ static __init int efivars_pstore_init(void)
if (efivars_pstore_disable)
return 0;
+ if (record_size < 1024)
+ record_size = 1024;
+
efi_pstore_info.buf = kmalloc(4096, GFP_KERNEL);
if (!efi_pstore_info.buf)
return -ENOMEM;
- efi_pstore_info.bufsize = 1024;
+ efi_pstore_info.bufsize = record_size;
if (pstore_register(&efi_pstore_info)) {
kfree(efi_pstore_info.buf);
--
2.38.0
next prev parent reply other threads:[~2022-10-06 22:45 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-06 22:42 [PATCH 0/8] Some pstore improvements Guilherme G. Piccoli
2022-10-06 22:42 ` [PATCH 1/8] pstore: Improve error reporting in case of backend overlap Guilherme G. Piccoli
2022-10-06 23:27 ` Kees Cook
2022-10-06 23:35 ` Guilherme G. Piccoli
2022-10-06 22:42 ` [PATCH 2/8] pstore: Expose kmsg_bytes as a module parameter Guilherme G. Piccoli
2022-10-06 23:32 ` Kees Cook
2022-10-12 15:33 ` Guilherme G. Piccoli
2022-10-12 17:58 ` Kees Cook
2022-11-01 19:08 ` Guilherme G. Piccoli
2022-10-06 22:42 ` [PATCH 3/8] pstore: Inform unregistered backend names as well Guilherme G. Piccoli
2022-10-06 22:42 ` [PATCH 4/8] pstore: Alert on backend write error Guilherme G. Piccoli
2022-10-06 23:27 ` Kees Cook
2022-10-06 23:34 ` Guilherme G. Piccoli
2022-10-06 23:44 ` Kees Cook
2022-10-06 22:42 ` [PATCH 5/8] pstore: Fix long-term implicit conversions in the compression routines Guilherme G. Piccoli
2022-10-06 23:36 ` Kees Cook
2022-10-07 8:47 ` Ard Biesheuvel
2022-10-07 19:37 ` Kees Cook
2022-10-08 14:14 ` Guilherme G. Piccoli
2022-10-08 15:53 ` Ard Biesheuvel
2022-10-08 16:03 ` Guilherme G. Piccoli
2022-10-08 17:52 ` Ard Biesheuvel
2022-10-08 18:12 ` Guilherme G. Piccoli
2022-10-08 19:44 ` Kees Cook
2022-10-10 7:24 ` Ard Biesheuvel
2022-10-06 22:42 ` [PATCH 6/8] MAINTAINERS: Add a mailing-list for the pstore infrastructure Guilherme G. Piccoli
2022-10-06 23:22 ` Kees Cook
2022-10-06 23:29 ` Luck, Tony
2022-10-06 23:37 ` Kees Cook
2022-10-07 16:19 ` Luck, Tony
2022-10-07 16:21 ` Colin Cross
2022-10-07 16:32 ` Guilherme G. Piccoli
2022-10-07 19:25 ` Kees Cook
2022-10-06 22:42 ` [PATCH 7/8] efi: pstore: Follow convention for the efi-pstore backend name Guilherme G. Piccoli
2022-10-06 23:16 ` Kees Cook
2022-10-07 8:47 ` Ard Biesheuvel
2022-10-14 17:41 ` (subset) " Kees Cook
2022-10-06 22:42 ` Guilherme G. Piccoli [this message]
2022-10-06 23:16 ` [PATCH 8/8] efi: pstore: Add module parameter for setting the record size Kees Cook
2022-10-07 9:11 ` Ard Biesheuvel
2022-10-07 13:00 ` Guilherme G. Piccoli
2022-10-07 13:19 ` Ard Biesheuvel
2022-10-07 13:45 ` Guilherme G. Piccoli
2022-10-07 15:06 ` Ard Biesheuvel
2022-10-07 17:01 ` Guilherme G. Piccoli
2022-10-07 19:32 ` Kees Cook
2022-10-07 23:29 ` Guilherme G. Piccoli
2022-10-08 2:36 ` Kees Cook
2022-10-06 23:24 ` [PATCH 0/8] Some pstore improvements Kees Cook
2022-10-12 15:50 ` Guilherme G. Piccoli
2022-10-12 17:59 ` Kees Cook
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=20221006224212.569555-9-gpiccoli@igalia.com \
--to=gpiccoli@igalia.com \
--cc=anton@enomsg.org \
--cc=ardb@kernel.org \
--cc=ccross@android.com \
--cc=keescook@chromium.org \
--cc=kernel-dev@igalia.com \
--cc=kernel@gpiccoli.net \
--cc=linux-efi@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).