kernel: report /dev/random and /dev/urandom as character devices #1140
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1140
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1140/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@NevesHenry on GitHub · 2026-10-07 13:45 UTC · original
NevesHenry:kernel/random-device-fstat→main· +17 −10 · 2 files · 1 commits · merged 2026-10-07 23:35 UTCSummary
KernelFstatreports every descriptor that isn't a directory as a regular file (S_IFREG). That includes/dev/randomand/dev/urandom, whichKernelOpenhandles asSpecialFile::Random. On FreeBSD these are character devices: devfs createsrandomwith mode 0644 and addsurandomas an alias of it (randomdev.c, releng/11.0).libsodium checks for this.
randombytes_sysrandom_random_dev_open()opens/dev/urandom, then/dev/random. It keeps a descriptor only whenfstatreportsS_ISCHRand closes it otherwise (source). If neither device passes,randombytes_sysrandom_init()callssodium_misuse()(source), which ends inabort()(source).This change makes
KernelFstatreport these descriptors asS_IFCHR | 0644.Evidence
#774 Warhammer Age of Sigmar: Realms of Ruin (PPSA06927, build
8b095ca) doesn't boot:Guest abort()atlibC.cpp:254. The log ends with that exact sequence. Each device is opened read-only, checked with fstat and closed, then the abort follows:I'm inferring libsodium from this call sequence; I haven't looked inside the game's binary. I don't have the game, so I can't say how far it gets with this change.
I also searched the other logs attached to issues here. 104 logs from 85 issues open
/dev/urandom, and #774 is the only one where the game aborts afterwards.Testing
CheckRandomDevicesintests/KernelFileSystemTests.cppopens both devices. It checks thatfstatreports a character device, reads 16 bytes from each and closes it.I used the same local-only setup as in #1109 to run
kernel_file_system_tests: an Ubuntu 24.04 container (clang 18) with no window or Vulkan device, andMemory::InvalidateMemoryreturning early when no GPU context is installed. Results:fileSystem.cpp, the test aborts at "random devices are readable character devices"In the same container,
kyty_emulatorandkyty_testsbuild, and the 35 ctest tests that don't need a Vulkan device pass. The other 15 all runshader_recompiler_compute_tests, which can't create a Vulkan instance there (ErrorIncompatibleDriver). They fail the same way with main'sfileSystem.cpp.The changed lines are clean under clang-format 22.1.3. Not built on Windows or macOS.
AI assistance
An AI coding assistant (Claude Code) helped me search the issue logs, compare the log with the libsodium and FreeBSD sources, write the change and the test, and run the builds above. I reviewed the code and the test results. All communication on this PR comes from me.
🤖 Generated with Claude Code
@coderabbitai[bot] on GitHub · 2026-10-07 13:51 UTC · original
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
76264cd9-4fff-461c-9ba9-3d04e17e1c4d📥 Commits
Reviewing files that changed from the base of the PR and between
d2413fc2eband 4b3984e5e3d69f98f6da484901357df58ee8a119.📒 Files selected for processing (2)
src/kernel/fileSystem.cpptests/KernelFileSystemTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough
KernelFstatnow reports special files with character-device mode while retaining zero size and block counts. The filesystem tests check that/dev/urandomand/dev/randomopen, report character-device mode, return 16 bytes, and close successfully.Suggested reviewers:
nmzikPriority: ⬇️ Low
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
4b398The change reports the two random-device paths as character devices and tests their status and readability; no actionable merge blocker is evident.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
/dev/randomand/dev/urandomas character devices.Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.