Skip to content

Linux random poll panics when kernel returns POLLIN|POLLRDNORM #380

Description

@SebTardif

Bug

In library/std/src/sys/random/linux.rs:143, the code uses:

assert_eq!(fd.revents, libc::POLLIN);

The Linux kernel's random_poll() function returns EPOLLIN | EPOLLRDNORM. When the kernel sets both flags in revents, the strict equality assertion panics even though the poll succeeded normally.

This affects any Linux system where the RNG is not yet initialized during early boot (the poll-for-readiness path).

Fix

Use a bitwise check: assert!(fd.revents & libc::POLLIN != 0) to verify POLLIN is set without requiring it to be the only flag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ioI/O, stdio, buffered readersI-crashUnexpected panic or crashO-linuxLinux-specificP-mediumMedium impact: affects specific usage patterns

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions