Page MenuHomeFreeBSD

getentropy(3): Fallback to kern.arandom sysctl on older kernels
ClosedPublic

Authored by cem on Mar 21 2018, 5:20 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 23, 7:56 PM
Unknown Object (File)
Mon, Nov 11, 2:19 PM
Unknown Object (File)
Sat, Nov 9, 8:18 AM
Unknown Object (File)
Oct 13 2024, 10:21 PM
Unknown Object (File)
Sep 30 2024, 12:19 PM
Unknown Object (File)
Sep 18 2024, 8:58 PM
Unknown Object (File)
Sep 11 2024, 4:38 AM
Unknown Object (File)
Sep 9 2024, 12:11 AM
Subscribers

Details

Summary

On older kernels, when userspace program disables SIGSYS, catch ENOSYS and
emulate getrandom(2) syscall with the kern.arandom sysctl (via existing
arc4_sysctl wrapper). Some special care is taken to faithfully emulate EFAULT
on NULL pointers, because sysctl(3) as used by kern.arandom ignores them.
(This was caught by getentropy(3) ATF tests.)

Test Plan

Run getentropy(3) ATF test suite against a new libc and old kernel. Observe
all tests pass.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 15692
Build 15721: arc lint + arc unit

Event Timeline

lib/libc/gen/Symbol.map
549

I do not understand why do you need this symbol exported.

Also, if you want to hide the symbol from static linking, put two '_' before the alphabetical symbol.

lib/libc/gen/Symbol.map
549

If it is not needed for the symbol to have visibility in getentropy.c, I will just remove it. I am not very familiar with how we use linker maps in libc, sorry.

Since linker maps apply only to dynamic libraries, you are suggesting the function be renamed to have two underscores, in addition to removing the entry from Symbol.map — right? I will go ahead and make both changes.

cem marked 2 inline comments as done.

Per kib:

  • Remove exported arc4_sysctl symbol
  • Use double-underscore in libc-private arc4_sysctl
This revision is now accepted and ready to land.Mar 21 2018, 8:57 PM
This revision was automatically updated to reflect the committed changes.