summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2022-02-28 16:00:52 +0300
committerJason A. Donenfeld <Jason@zx2c4.com>2022-03-13 04:00:56 +0300
commit77553cf8f44863b31da242cf24671d76ddb61597 (patch)
treee745a0927aff48b8851c0045f536601139cbf293 /drivers
parentd0efdf35a6a71d307a250199af6fce122a7c7e11 (diff)
downloadlinux-77553cf8f44863b31da242cf24671d76ddb61597.tar.xz
random: don't let 644 read-only sysctls be written to
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: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/random.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 612e45e88077..ede97649c5dd 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1631,6 +1631,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, 0, buffer, lenp, ppos);
+}
+
static struct ctl_table random_table[] = {
{
.procname = "poolsize",
@@ -1651,14 +1658,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",