Skip to contentSkip to conversation

random: go back to not blocking in /dev/urandom

PATCH In review Jason A. Donenfeld 2 participants 3 messages Mar 22, 2022

Subsystems (2)
lore
Share & tools
lore

Jason A. Donenfeld

author maintainer
#0 lore raw

PATCH 1/1 random: go back to not blocking in /dev/urandom

This reverts commit 6f98a4bfee72 ("random: block in /dev/urandom").

We tried this, but Guenter Roeck immediately reported issues after it hit mainline, on arm, m68k, microblaze, sparc32, and xtensa. So it sounds like we've got some more work to do on weird architectures in weird situations before we can make this change. Alas, but that's how it goes, as the kernel is quite strict about not intentionally breaking userspace, and here is some clear breakage.

---
 drivers/char/mem.c     |  2 +-
 drivers/char/random.c  | 70 ++++++++++++++++++++++++++++++++----------
 include/linux/random.h |  2 +-
 3 files changed, 56 insertions(+), 18 deletions(-)
drivers/char/mem.c +1 -1
index 9f586025dbe6..cc296f0823bd 100644
@@ -707,7 +707,7 @@ static const struct memdev {
 	 [5] = { "zero", 0666, &zero_fops, FMODE_NOWAIT },
 	 [7] = { "full", 0666, &full_fops, 0 },
 	 [8] = { "random", 0666, &random_fops, 0 },
-	 [9] = { "urandom", 0666, &random_fops, 0 },
+	 [9] = { "urandom", 0666, &urandom_fops, 0 },
 #ifdef CONFIG_PRINTK
 	[11] = { "kmsg", 0644, &kmsg_fops, 0 },
 #endif
drivers/char/random.c +54 -16

129 lines not on this page · raw message

include/linux/random.h +1 -1
index c0baffe7afb1..f673fbb838b3 100644
@@ -48,7 +48,7 @@ extern int unregister_random_ready_notifier(struct notifier_block *nb);
 extern size_t __must_check get_random_bytes_arch(void *buf, size_t nbytes);
 
 #ifndef MODULE
-extern const struct file_operations random_fops;
+extern const struct file_operations random_fops, urandom_fops;
 #endif
 
 u32 get_random_u32(void);
Signature · 1 line
2.35.1
#1 lore raw
Quoted 2 lines · Jason A. Donenfeld

This reverts commit 6f98a4bfee72 ("random: block in /dev/urandom").

Just a note that by the time I saw this, I already had my own revert in the tree.

It's pushed out now, as commit 0313bc278dac.

Linus

author maintainer
#2 lore raw

Hi Linus,

Quoted 9 lines · Linus Torvalds
Quoted 2 lines · Jason A. Donenfeld

This reverts commit 6f98a4bfee72 ("random: block in /dev/urandom").

Just a note that by the time I saw this, I already had my own revert in the tree.

It's pushed out now, as commit 0313bc278dac.

Saw that, no problem.

Jason