HomeFreeBSD

netlink: Zero-initialize mbuf messages

Description

netlink: Zero-initialize mbuf messages

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
Reviewed by: melifaro
Approved by: re(cperciva)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38098

(cherry picked from commit d91be0f1211b0196a0087cdfa237a6a0d2a43b65)
(cherry picked from commit 13e997289240c4697536f904167720a29abf7a58)

Details

Provenance
markjAuthored on Jan 17 2023, 2:36 PM
melifaroCommitted on Feb 20 2023, 7:47 PM
Reviewer
melifaro
Differential Revision
D38098: netlink: Zero-initialize mbuf messages
Parents
rGfbb102b2cec5: fusefs: fix some resource leaks
Branches
Unknown
Tags
Unknown