Page MenuHomeFreeBSD

in_pcb_lport: Don't attempt to randomize if random(4) is unavailable
AbandonedPublic

Authored by cem on Apr 19 2019, 7:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 12, 6:10 AM
Unknown Object (File)
Sun, Apr 7, 4:09 PM
Unknown Object (File)
Sun, Apr 7, 12:42 PM
Unknown Object (File)
Sun, Apr 7, 10:59 AM
Unknown Object (File)
Sun, Apr 7, 8:59 AM
Unknown Object (File)
Fri, Mar 29, 12:34 AM
Unknown Object (File)
Fri, Mar 22, 4:36 PM
Unknown Object (File)
Mar 9 2024, 9:12 AM
Subscribers
None

Details

Summary

If kern.random.initial_seeding.bypass_before_seeding is disabled,
arc4rand(9) may block if/until the the random(4) device is initially
seeded. Probably we want to be able to create sockets in that case,
even if we cannot yet randomize the port, rather than blocking
indefinitely.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 23775
Build 22723: arc lint + arc unit

Event Timeline

cem added inline comments.
sys/conf/kern.mk
64–66 ↗(On Diff #56401)

Please ignore this portion — arc misfire. It is not included in the actual git commit.

Is this a case where 'not very random' PRNG output is still better than "sequential port assignment"? That is, if we had a variant of arc4random() that would fail to "weak output" rather than blocking?

In D19972#429343, @jhb wrote:

Is this a case where 'not very random' PRNG output is still better than "sequential port assignment"? That is, if we had a variant of arc4random() that would fail to "weak output" rather than blocking?

The hope is that after a few packets are exchanged, we will have gathered sufficient entropy that random will be seeded (and that state persists forever). I'm not sure how pernicious sequential port assignment is perceived to be. Note that ipport_tick can force us to drop to sequential port assignment after a certain number of random assignments in a given window, so there is some precedent for using sequential ports when it is convenient.

Will pursue available initial seeding in another way.