From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: linux-kernel@vger.kernel.org
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
Dominik Brodowski <linux@dominikbrodowski.net>,
Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 2/2] random: don't let 644 read-only sysctls be written to
Date: Mon, 28 Feb 2022 14:37:43 +0100 [thread overview]
Message-ID: <20220228133743.2243-2-Jason@zx2c4.com> (raw)
In-Reply-To: <20220228133743.2243-1-Jason@zx2c4.com>
We leave around these old sysctls for compatibility, and we keep them
"writable" for compatibility, but even after writing, we should keep
reporting the same value. This is consistent with how userspaces tend to
use sysctl_random_write_wakeup_bits, writing to it, and then later
reading from it and using the value.
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
drivers/char/random.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 116ebf50d791..06c6e15b5f3d 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1669,6 +1669,13 @@ static int proc_do_uuid(struct ctl_table *table, int write, void *buffer,
return proc_dostring(&fake_table, 0, buffer, lenp, ppos);
}
+/* The same as proc_dointvec, but writes don't change anything. */
+static int proc_do_rointvec(struct ctl_table *table, int write, void *buffer,
+ size_t *lenp, loff_t *ppos)
+{
+ return write ? 0 : proc_dointvec(table, write, buffer, lenp, ppos);
+}
+
static struct ctl_table random_table[] = {
{
.procname = "poolsize",
@@ -1689,14 +1696,14 @@ static struct ctl_table random_table[] = {
.data = &sysctl_random_write_wakeup_bits,
.maxlen = sizeof(int),
.mode = 0644,
- .proc_handler = proc_dointvec,
+ .proc_handler = proc_do_rointvec,
},
{
.procname = "urandom_min_reseed_secs",
.data = &sysctl_random_min_urandom_seed,
.maxlen = sizeof(int),
.mode = 0644,
- .proc_handler = proc_dointvec,
+ .proc_handler = proc_do_rointvec,
},
{
.procname = "boot_id",
--
2.35.1
next prev parent reply other threads:[~2022-02-28 13:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-28 13:37 [PATCH 1/2] random: give sysctl_random_min_urandom_seed a more sensible value Jason A. Donenfeld
2022-02-28 13:37 ` Jason A. Donenfeld [this message]
2022-03-01 5:16 ` [PATCH 2/2] random: don't let 644 read-only sysctls be written to Dominik Brodowski
2022-03-01 5:14 ` [PATCH 1/2] random: give sysctl_random_min_urandom_seed a more sensible value Dominik Brodowski
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=20220228133743.2243-2-Jason@zx2c4.com \
--to=jason@zx2c4.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@dominikbrodowski.net \
--cc=tytso@mit.edu \
/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®