HomeFreeBSD

ipsec: Clear pad bytes in PF_KEY messages

Description

ipsec: Clear pad bytes in PF_KEY messages

Various handlers for SADB messages will allocate a new mbuf and populate
some structures in it. Some of these structures, such as struct
sadb_supported, contain small reserved fields that are not initialized
and are thus leaked to userspace.

Fix the problem by adding a helper to allocate zeroed mbufs. This
reduces code duplication and the overhead of zeroing these messages
isn't harmful.

Reviewed by: zlei, melifaro
Reported by: KMSAN
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D38068

(cherry picked from commit 8a9495517b0ad54da9759a7ba2cc0b56f8e7c8f9)

Details

Provenance
markjAuthored on Jan 16 2023, 3:46 PM
Reviewer
zlei
Differential Revision
D38068: ipsec: Clear pad bytes in PF_KEY messages
Parents
rG9eea81e59641: usr.bin/stat: Fix error message formatting.
Branches
Unknown
Tags
Unknown