[General Protection Fault] - Getting glibc error "cannot get entropy for arc4random" that forces reboot after 10s

Hello guys,

I am using the latest firmware-source 23.05 and I am getting a glibc error "cannot get entropy for arc4random" in runtime that is forcing a reboot every 10s in APU2 target.
In previous openwrt version this was not an issue (with glibc 2.34) since it was not using arc4random, also tested with glibc.2.36 and worked fine.

Target:

    CONFIG_TARGET_x86=y
    CONFIG_TARGET_x86_apu2=y
    CONFIG_TARGET_x86_apu2_DEVICE_apu2=y
    CONFIG_DEVEL=y

Dmesg log before reboot

[    8.327635] mount_root: loading kmods from internal overlay
[    8.398021] kmodloader: loading kernel modules from //etc/modules-boot.d/*
[    8.409498] kmodloader: done loading kernel modules from //etc/modules-boot.d/*
[    8.468357] block: attempting to load /etc/config/fstab
[    8.473980] block: unable to load configuration (fstab: Entry not found)
[    8.480993] block: no usable configuration
[    8.486063] loop0: detected capacity change from 0 to 212992
[    8.549812] loop0: detected capacity change from 212992 to 158720
[    8.576960] EXT4-fs (loop0): recovery complete
[    8.582652] EXT4-fs (loop0): mounted filesystem with ordered data mode. Opts: (null). Quota mode: disabled.
[    8.609181] block: attempting to load /etc/config/fstab
[    8.614922] block: unable to load configuration (fstab: Entry not found)
[    8.622177] block: no usable configuration
[    8.627929] mount_root: overlay filesystem has not been fully initialized yet
[    8.638566] mount_root: switching to ext4 overlay
[    8.650173] overlayfs: null uuid detected in lower fs '/', falling back to xino=off,index=off,nfs_export=off.
[    8.818025] EXT4-fs (sda1): warning: mounting unchecked fs, running e2fsck is recommended
[    8.829211] EXT4-fs (sda1): mounted filesystem without journal. Opts: (null). Quota mode: disabled.
[    8.848913] urandom-seed: Seed file not found (/etc/urandom.seed)
[    9.174986] procd: - early -
Fatal glibc erro[    9.320837] traps: procd[1] general protection fault ip:7f25702a13c4 sp:7ffe17ebe2e0 error:0 in libc.so.6[7f25702a1000+141000]
r: cannot get entropy for arc4random
[   11.510033] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[   11.550100] reboot: Restarting system
[   11.553867] reboot: machine restart

I did a little research and I noticed that the arc4random that glibc is using is different from the libbsd library, so I tried to use that lib ( with CONFIG_PACKAGE_libbsd=y) and this error didn't occur.
In previous version ( 22.03) this was not necessary! Am I missing some config? Anyone having same issue?

Thank you very much.

2 Likes

Thanks for your post -- it helped me track down this same issue. I am using 23.05.2 with glibc for the ESPRESSObin (v7 eMMC) and ESPRESSObin Ultra targets.

The kernel attempts to launch procd init and the json-c library is invoking arc4random() too early for glibc to handle. So init aborts and the machine restarts, just as you posted. With 23.05.2 we have commit 341121e which defines DISABLE_EXTRA_LIBS in libjson-c's CMake (so it won't use libbsd if enabled.) I tried hacking in libbsd and that is one solution. Another workaround is to patch libjson-c with a new DISABLE_ARC4RANDOM option that skips the arc4random() call and uses getrandom() instead (the next in its list.)

On a related note, BusyBox 1.36.1 now includes seedrng which can be invoked from the 81_urandom_seed preinit script, which may help the situation for this kernel.

1 Like