Page MenuHomeFreeBSD

if_wg: avoid sleeping under the net epoch
ClosedPublic

Authored by kevans on Mar 8 2021, 6:19 AM.

Details

Summary

No sleeping allowed here, so avoid it. Collect the subset of data we
want inside of the epoch, as we'll need extra allocations when we add
items to the nvlist.

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

This revision is now accepted and ready to land.Mar 8 2021, 8:04 AM
sys/dev/if_wg/module/module.c
73

Why NOISE_KEY_SIZE instead of WG_KEY_SIZE?

404–407

Perhaps assert that we're in the net epoch here?

434–436

How do you guarantee that the length of the list doesn't increase between the first loop and this one?

sys/dev/if_wg/module/module.c
73

Stole from the r_public member of struct noise_remote that we're copying into here; the distinction doesn't seem to make much sense to me, as we do use them interchangeably elsewhere (see: noise_local_keys() definition then usage over in wg_cloneattach()).

I'll switch it over to WG_KEY_SIZE, though.

434–436

Whoops, brain-o; will fix to stop at exp->aip_count and update it after.

kevans marked 3 inline comments as done.

Address feedback from @markj

This revision now requires review to proceed.Mar 8 2021, 6:50 PM
sys/dev/if_wg/module/module.c
499

Is it intentional that an error part-way though will result in this function returning success with a truncated list?

533

nvl is leaked in this error path, not a new bug though.

I think this is ok, my last questions are around preexisting behaviour.

This revision is now accepted and ready to land.Mar 8 2021, 9:06 PM
This revision was automatically updated to reflect the committed changes.
kevans marked 2 inline comments as done.