HomeFreeBSD

rtsock: Avoid copying uninitialized padding bytes

Description

rtsock: Avoid copying uninitialized padding bytes

When copying sockaddrs out to userspace, we pad them to a multiple of
the platform alignment (sizeof(long)). However, some sockaddr sizes,
such as struct sockaddr_dl, are not an integer multiple of the
alignment, so we may end up copying out uninitialized bytes.

Fix this by always bouncing through a pre-zeroed sockaddr_storage.

Reported by: KASAN
Reviewed by: melifaro
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27729

Details

Provenance
markjAuthored on Dec 23 2020, 4:15 PM
Parents
rGa7a7c306bfb0: md: Fix a read-after-free in BIO_GETATTR handling
Branches
Unknown
Tags
Unknown