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)
Feb 1 2024, 11:43 PM
Unknown Object (File)
Feb 1 2024, 11:15 AM
Unknown Object (File)
Nov 25 2023, 8:48 PM
Unknown Object (File)
Nov 25 2023, 4:49 PM
Unknown Object (File)
Nov 22 2023, 5:07 PM
Unknown Object (File)
Nov 15 2023, 2:20 PM
Unknown Object (File)
Oct 25 2023, 1:35 AM
Unknown Object (File)
Oct 19 2023, 6:20 PM
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 Not Applicable
Unit
Tests Not Applicable

Event Timeline

lib/libc/gen/Symbol.map
549 ↗(On Diff #40553)

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 ↗(On Diff #40553)

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.