Skip to content

Commit 82bfa03

Browse files
committed
signalfd: use wake_up_pollfree()
jira VULN-63551 cve-pre CVE-2021-47505 commit-author Eric Biggers <[email protected]> commit 9537bae wake_up_poll() uses nr_exclusive=1, so it's not guaranteed to wake up all exclusive waiters. Yet, POLLFREE *must* wake up all waiters. epoll and aio poll are fortunately not affected by this, but it's very fragile. Thus, the new function wake_up_pollfree() has been introduced. Convert signalfd to use wake_up_pollfree(). Reported-by: Linus Torvalds <[email protected]> Fixes: d80e731 ("epoll: introduce POLLFREE to flush ->signalfd_wqh before kfree()") Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Eric Biggers <[email protected]> (cherry picked from commit 9537bae) Signed-off-by: Brett Mastbergen <[email protected]>
1 parent 9939b29 commit 82bfa03

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

fs/signalfd.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,7 @@
3535

3636
void signalfd_cleanup(struct sighand_struct *sighand)
3737
{
38-
wait_queue_head_t *wqh = &sighand->signalfd_wqh;
39-
/*
40-
* The lockless check can race with remove_wait_queue() in progress,
41-
* but in this case its caller should run under rcu_read_lock() and
42-
* sighand_cachep is SLAB_TYPESAFE_BY_RCU, we can safely return.
43-
*/
44-
if (likely(!waitqueue_active(wqh)))
45-
return;
46-
47-
/* wait_queue_entry_t->func(POLLFREE) should do remove_wait_queue() */
48-
wake_up_poll(wqh, EPOLLHUP | POLLFREE);
38+
wake_up_pollfree(&sighand->signalfd_wqh);
4939
}
5040

5141
struct signalfd_ctx {

0 commit comments

Comments
 (0)