Page MenuHomeFreeBSD

netlink: Zero-initialize writer structures allocated on the stack
ClosedPublic

Authored by markj on Jan 26 2023, 3:07 PM.
Tags
None
Referenced Files
F167163589: D38213.id115784.diff
Wed, Aug 19, 2:40 PM
F167159501: D38213.id115786.diff
Wed, Aug 19, 2:00 PM
Unknown Object (File)
Tue, Aug 18, 8:41 PM
Unknown Object (File)
Tue, Aug 18, 10:14 AM
Unknown Object (File)
Mon, Aug 17, 7:54 PM
Unknown Object (File)
Sun, Aug 16, 9:30 PM
Unknown Object (File)
Sat, Aug 15, 9:59 PM
Unknown Object (File)
Tue, Aug 11, 3:30 PM
Subscribers

Details

Summary

The prevailing pattern seems to be to simply initialize all fields to
zero. Without this, it's possible to trigger a branch on uninitialized
memory. Specifically, when testing nw->ignore_limit in
nlmsg_refill_buffer().

Initialize the writer structure in a couple of functions where this is
necessary.

Reported by: KMSAN

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 49246
Build 46136: arc lint + arc unit

Event Timeline

markj requested review of this revision.Jan 26 2023, 3:07 PM

Ack, that's a good one!
My initial approach was to perform zero in the -> init() functions (e.g. nlmsg_get_ns_<mbuf|lbuf|buf>), preferably via explicit field initialisation. Apparently the latter one has failed.
ATM I'm leaning towards doing the explicit bzero() in all init functions, but need to think a bit more about it.
To unblock the fix, let's require the explicit writer initialisation for now.

This revision is now accepted and ready to land.Jan 26 2023, 3:24 PM