HomeFreeBSD

Prevent cv_waiters wraparound.

Description

Prevent cv_waiters wraparound.

r282971 attempted to fix this problem by decrementing cv_waiters after
waking up from sleeping on a condition variable, but this can result in
a use-after-free if the CV is freed before all woken threads have had a
chance to run. Instead, avoid incrementing cv_waiters past INT_MAX, and
have cv_signal() explicitly check for sleeping threads once cv_waiters has
reached this bound.

Reviewed by: jhb
MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
Differential Revision: https://reviews.freebsd.org/D4822

Details

Provenance
markjAuthored on
Reviewer
jhb
Differential Revision
D4822: Fix cv_waiters wraparound bug
Parents
rS293457: Fix a mismerge.
Branches
Unknown
Tags
Unknown