HomeFreeBSD

pfsync: Avoid transmitting uninitialized bytes in pfsync_sendout()

Description

pfsync: Avoid transmitting uninitialized bytes in pfsync_sendout()

When IPv6 support was added to pfsync, PFSYNC_MINPKT increased such that
we always allocate enough space for either IPv4 or IPv6 headers. IPv6
headers are 20 bytes larger than IPv4 headers. When pfsync_sendout()
does its thing, it ends up allocating enough space for either; thus when
transmitting an IPv4 packet, the last 20 bytes of the buffer are left
uninitialized.

Fix the problem by stashing the length in a local variable and adjusting
it depending on the address family in use.

While here, just zero the entire buffer in one go rather than being
careful to initialize each subheader. This seems simpler and less error
prone.

Approved by: re (gjb)
Approved by: so
Reported by: KMSAN
Reviewed by: kp
Fixes: 6fc7fc2dbb2b ("pfsync: transport over IPv6")
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D42461

(cherry picked from commit bd80263606d73c0391d3fa8a156fcca89a821810)
(cherry picked from commit 09cca16bfc26f669a5aea2a47e9891e34c3bebeb)

Details

Provenance
markjAuthored on Nov 4 2023, 2:28 PM
Reviewer
rG6fc7fc2dbb2b: pfsync: transport over IPv6
Differential Revision
D42461: pfsync: Avoid transmitting uninitialized bytes in pfsync_sendout()
Parents
rGd59533eaf942: release: update releng/14.0 to RC4
Branches
Unknown
Tags
Unknown