git: 89e585b8a459 - stable/15 - pass(4): Don't drop the periph lock before selrecord() in passpoll()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 18 Nov 2026 18:03:11 UTC
The branch stable/15 has been updated by ken:
URL: https://cgit.FreeBSD.org/src/commit/?id=89e585b8a4592649d5edda9ca23167ed6fd6b502
commit 89e585b8a4592649d5edda9ca23167ed6fd6b502
Author: Kenneth D. Merry <ken@FreeBSD.org>
AuthorDate: 2026-11-11 14:26:19 +0000
Commit: Kenneth D. Merry <ken@FreeBSD.org>
CommitDate: 2026-11-18 17:37:11 +0000
pass(4): Don't drop the periph lock before selrecord() in passpoll()
passpoll() checked the done queue while holding the peripheral lock,
dropped the lock, and only then called selrecord(). A CCB completing
in the window between the unlock and the selrecord() call sent its
selwakeuppri() before the polling thread was on the selinfo list, so
the wakeup was lost and select(2) or poll(2) slept until another
completion arrived or the timeout expired.
Call selrecord() before dropping the lock. This lock order is
already established: passdone() calls selwakeuppri(), which takes
the selinfo lock, while holding the peripheral lock.
kqueue is not affected, since the knlist is backed by the peripheral
mutex.
Reported by: llm-postcr
Fixes: a9934668aa13
MFC after: 1 week
Sponsored by: Spectra Logic
Assisted-by: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit 88c5709e91ad2cc6df51380673837f0ebd8a2d50)
---
sys/cam/scsi/scsi_pass.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c
index 8164edd243fd..0be9daa1e36c 100644
--- a/sys/cam/scsi/scsi_pass.c
+++ b/sys/cam/scsi/scsi_pass.c
@@ -2121,9 +2121,9 @@ passpoll(struct cdev *dev, int poll_events, struct thread *td)
if (!TAILQ_EMPTY(&softc->done_queue)) {
revents |= poll_events & (POLLIN | POLLRDNORM);
}
- cam_periph_unlock(periph);
if (revents == 0)
selrecord(td, &softc->read_select);
+ cam_periph_unlock(periph);
}
return (revents);