Linux Hardening
 help / color / mirror / Atom feed
From: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
To: kees@kernel.org
Cc: tony.luck@intel.com, gpiccoli@igalia.com,
	linux-hardening@vger.kernel.org, kernel-dev@igalia.com,
	kernel@gpiccoli.net
Subject: [PATCH 2/2] pstore: Allow kmsg_bytes parameter to be written at runtime
Date: Tue, 22 Sep 2026 18:19:02 -0300	[thread overview]
Message-ID: <20260922212532.98571-3-gpiccoli@igalia.com> (raw)
In-Reply-To: <20260922212532.98571-1-gpiccoli@igalia.com>

Currently the kmsg_bytes parameter is read-only in sysfs, though
it can be changed both via command-line at boot-time, and through
the pstore filesystem mount option, at runtime.

Add a module parameter callback in order for users to change kmsg_bytes
via the runtime sysfs interface, the same way they can do it using
the mount option.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
---
 fs/pstore/platform.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index f3a900cf2cfb..185afc3db1a4 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -93,7 +93,25 @@ MODULE_PARM_DESC(compress, "compression to use (deflate/none)");
 
 /* How much of the kernel log to snapshot */
 unsigned int kmsg_bytes = CONFIG_PSTORE_DEFAULT_KMSG_BYTES;
-module_param(kmsg_bytes, uint, 0444);
+static int param_set_kmsg_bytes(const char *val, const struct kernel_param *kp)
+{
+	unsigned int num;
+
+	if (kstrtouint(val, 0, &num))
+		return -EINVAL;
+
+	WRITE_ONCE(kmsg_bytes, num);
+
+	return 0;
+}
+
+static const struct kernel_param_ops kmsg_bytes_ops = {
+	.set = param_set_kmsg_bytes,
+	.get = param_get_uint,
+};
+
+module_param_cb(kmsg_bytes, &kmsg_bytes_ops, &kmsg_bytes, 0644);
+__MODULE_PARM_TYPE(kmsg_bytes, "uint");
 MODULE_PARM_DESC(kmsg_bytes, "amount of kernel log to snapshot (in bytes)");
 
 static void *compress_workspace;
-- 
2.50.1


  parent reply	other threads:[~2026-09-22 21:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 21:19 [PATCH 0/2] Small improvements on pstore user experience Guilherme G. Piccoli
2026-09-22 21:19 ` [PATCH 1/2] pstore: Consolidate compression handling in both init paths Guilherme G. Piccoli
2026-09-22 21:19 ` Guilherme G. Piccoli [this message]
2026-09-23  7:20 ` [PATCH 0/2] Small improvements on pstore user experience Kees Cook
2026-09-23 14:30   ` Guilherme G. Piccoli
2026-10-06 20:35     ` 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=20260922212532.98571-3-gpiccoli@igalia.com \
    --to=gpiccoli@igalia.com \
    --cc=kees@kernel.org \
    --cc=kernel-dev@igalia.com \
    --cc=kernel@gpiccoli.net \
    --cc=linux-hardening@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