HomeFreeBSD

fsetown: Fix process lookup bugs

Description

fsetown: Fix process lookup bugs

  • pget()/pfind() will acquire the PID hash bucket locks, which are sleepable sx locks, but this means that the sigio mutex cannot be held while calling these functions. Instead, use pget() to hold the process, after which we lock the sigio and proc locks, respectively.
  • funsetownlst() assumes that processes cannot be registered for SIGIO once they have P_WEXIT set. However, pfind() will happily return exiting processes, breaking the invariant. Add an explicit check for P_WEXIT in fsetown() to fix this. [1]

Fixes: f52979098d3c ("Fix a pair of races in SIGIO registration")
Reported by: syzkaller [1]
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1d874ba4f8ba58296cd9df611f5346dad8e91664)

Details

Provenance
markjAuthored on Aug 25 2021, 8:18 PM
Parents
rG8fc67f27d09e: libsa: Fix a typo in source code comments
Branches
Unknown
Tags
Unknown