Skip to content

Commit b994ace

Browse files
committed
io_uring/waitid: fix KCSAN warning on io_waitid->head
Storing of the iw->head entry inside the wait_queue callback, or when removing a waitid item, really should use proper load/store acquire/release semantics, and KCSAN correctly warns of that. Ensure that they do so. Reported-by: syzbot+eb441775f4f948a0902f@syzkaller.appspotmail.com Fixes: a48c0cb ("io_uring/waitid: have io_waitid_complete() remove wait queue entry") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 4b97480 commit b994ace

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

io_uring/waitid.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ static void io_waitid_remove_wq(struct io_kiocb *req)
114114
struct io_waitid *iw = io_kiocb_to_cmd(req, struct io_waitid);
115115
struct wait_queue_head *head;
116116

117-
head = READ_ONCE(iw->head);
117+
head = smp_load_acquire(&iw->head);
118118
if (head) {
119119
struct io_waitid_async *iwa = req->async_data;
120120

121-
iw->head = NULL;
121+
smp_store_release(&iw->head, NULL);
122122
spin_lock_irq(&head->lock);
123123
list_del_init(&iwa->wo.child_wait.entry);
124124
spin_unlock_irq(&head->lock);
@@ -246,7 +246,7 @@ static int io_waitid_wait(struct wait_queue_entry *wait, unsigned mode,
246246
return 0;
247247

248248
list_del_init(&wait->entry);
249-
iw->head = NULL;
249+
smp_store_release(&iw->head, NULL);
250250

251251
/* cancel is in progress */
252252
if (atomic_fetch_inc(&iw->refs) & IO_WAITID_REF_MASK)

0 commit comments

Comments
 (0)