HomeFreeBSD

Use a consistent snapshot of the fd's rights in fget_mmap().

Description

Use a consistent snapshot of the fd's rights in fget_mmap().

fget_mmap() translates rights on the descriptor to a VM protection
mask. It was doing so without holding any locks on the descriptor
table, so a writer could simultaneously be modifying those rights.
Such a situation would be detected using a sequence counter, but
not before an inconsistency could trigger assertion failures in
the capability code.

Fix the problem by copying the fd's rights to a structure on the stack,
and perform the translation only once we know that that snapshot is
consistent.

Reported by: syzbot+ae359438769fda1840f8@syzkaller.appspotmail.com
Reviewed by: brooks, mjg
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20800

Details

Provenance
markjAuthored on
Reviewer
brooks
Differential Revision
D20800: Use a consistent snapshot of the fd's rights in fget_mmap().
Parents
rS349546: Fix mutual exclusion in pipe_direct_write().
Branches
Unknown
Tags
Unknown