]> git.baikalelectronics.ru Git - kernel.git/commit
watchqueue: make sure to serialize 'wqueue->defunct' properly
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 19 Jul 2022 18:09:01 +0000 (11:09 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 20 Jul 2022 17:46:07 +0000 (10:46 -0700)
commite58a2c354f8bf5c53065c5eb14846408c9d43dfd
tree9d783d2cd6d39d21d77767772558157c30c3d9be
parent7684e2e9a9e54dfff242b812df28cece14cef3c6
watchqueue: make sure to serialize 'wqueue->defunct' properly

When the pipe is closed, we mark the associated watchqueue defunct by
calling watch_queue_clear().  However, while that is protected by the
watchqueue lock, new watchqueue entries aren't actually added under that
lock at all: they use the pipe->rd_wait.lock instead, and looking up
that pipe happens without any locking.

The watchqueue code uses the RCU read-side section to make sure that the
wqueue entry itself hasn't disappeared, but that does not protect the
pipe_info in any way.

So make sure to actually hold the wqueue lock when posting watch events,
properly serializing against the pipe being torn down.

Reported-by: Noam Rathaus <noamr@ssd-disclosure.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/watch_queue.c