HomeFreeBSD

Clear non-x86 compat stat syscall kernel stack memory disclosure

Description

Clear non-x86 compat stat syscall kernel stack memory disclosure

32-bit architectures other than i386 have 64-bit time_t which results
in a struct timespec with 12 bytes for tv_sec and tv_nsec, and 4 bytes
of padding. Zero the padding holes in struct stat32 and struct
freebsd11_stat32.

i386 has 32-bit time_t; struct timespec is 8 bytes and has no padding.

Found by inspection, prompted by a report by Reno Robert of Trend Micro
Zero Day Initiative. The originally reported issue (ZDI-CAN-14538) is
already fixed in all supported FreeBSD versions (it was addressed
incidentally as part of the 64-bit inode project).

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34709

Details

Provenance
emasteAuthored on Mar 29 2022, 5:55 PM
Reviewer
markj
Differential Revision
Restricted Differential Revision
Parents
rGe123e2294cb5: pf: guard against DIOCADDRULE without DIOCXBEGIN
Branches
Unknown
Tags
Unknown

Event Timeline

emaste added an edge: Restricted Differential Revision.Mar 29 2022, 8:15 PM
arichardson added inline comments.
/sys/compat/freebsd32/freebsd32_misc.c
2185

Wouldn't it be easier to zero the entire struct and rely on the compiler optimizing the redundant zeroing away? Not 100% certain it will, there might be some threshold of number of analyzed stores.

/sys/compat/freebsd32/freebsd32_misc.c
2185

There's a few different approaches we could take and we can iterate on it in main. In fact I think we can avoid copy_stat entirely on little-endian 64-bit architectures other than x86, as I believe struct stat and struct stat32 have the same layout except that the upper bits of tv_nsec in stat are padding in stat32.