ipsec: Clear pad bytes in PF_KEY messages
authorMark Johnston <markj@FreeBSD.org>
Mon, 16 Jan 2023 15:46:20 +0000 (10:46 -0500)
committerMark Johnston <markj@FreeBSD.org>
Mon, 16 Jan 2023 16:27:54 +0000 (11:27 -0500)
commit8a9495517b0ad54da9759a7ba2cc0b56f8e7c8f9
tree41465fcfff2aa13e5c851f385790b39b134bca2b
parent9b7eddfeed465d4062dbad178261b806e97d6b62
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
sys/netipsec/key.c