Page MenuHomeFreeBSD

netlink: Zero-initialize mbuf messages
ClosedPublic

Authored by markj on Jan 17 2023, 2:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 30, 12:58 AM
Unknown Object (File)
Fri, Oct 25, 10:00 PM
Unknown Object (File)
Thu, Oct 24, 10:41 PM
Unknown Object (File)
Thu, Oct 24, 4:30 PM
Unknown Object (File)
Sep 29 2024, 2:27 AM
Unknown Object (File)
Sep 28 2024, 2:50 PM
Unknown Object (File)
Sep 27 2024, 1:21 PM
Unknown Object (File)
Sep 24 2024, 6:39 PM
Subscribers

Details

Summary

Some users of nlmsg_reserve_object() and nlmsg_reserve_data() are not
careful to fully initialize pad and reserved fields, allowing
uninitialized bytes to leak to userspace. For example, dump_nhgrp()
doesn't set nhm->resvd = 0.

Meanwhile, nlmsg_get_ns_buf() and nlmsg_get_ns_lbuf() zero-initialize
the buffer, so nlmsg_get_ns_mbuf() is inconsistent. Let's just make
them all behave the same here.

Reported by: KMSAN

Test Plan

netlink regression tests

Diff Detail

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

Event Timeline

markj requested review of this revision.Jan 17 2023, 2:08 PM
markj edited the test plan for this revision. (Show Details)

Thank you for working on that! It was on my list for quite some time. I was concerned a bit about performance & was thinking of measuring the different approaches. Anyway, let's make it safe first and work on improvements later.
Thank you again for addressing the security issue.

This revision is now accepted and ready to land.Jan 17 2023, 2:20 PM

Thank you for working on that! It was on my list for quite some time. I was concerned a bit about performance & was thinking of measuring the different approaches. Anyway, let's make it safe first and work on improvements later.

One other approach might be to instead make nlmsg_reserve_object() and nlmsg_reserve_data() zero the buffer area. I suspect the overhead of zeroing is pretty close to negligible in either case though?

This revision was automatically updated to reflect the committed changes.

Thank you for working on that! It was on my list for quite some time. I was concerned a bit about performance & was thinking of measuring the different approaches. Anyway, let's make it safe first and work on improvements later.

One other approach might be to instead make nlmsg_reserve_object() and nlmsg_reserve_data() zero the buffer area. I suspect the overhead of zeroing is pretty close to negligible in either case though?

Yep. Re overhead - it depends. Full-view dump is hundreds of megabytes, mainly consisting of the attributes (which don't require zeroing). Anyway, it shouldn't be a _huge_ difference and can be addressed later.