Commit 353f798
committed
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>1 parent 543ce63 commit 353f798
1 file changed
Lines changed: 37 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
37 | 58 | | |
38 | 59 | | |
39 | 60 | | |
| |||
69 | 90 | | |
70 | 91 | | |
71 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
72 | 97 | | |
73 | 98 | | |
74 | 99 | | |
| |||
85 | 110 | | |
86 | 111 | | |
87 | 112 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | 113 | | |
92 | 114 | | |
93 | 115 | | |
| |||
203 | 225 | | |
204 | 226 | | |
205 | 227 | | |
206 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
207 | 232 | | |
208 | 233 | | |
209 | 234 | | |
| |||
462 | 487 | | |
463 | 488 | | |
464 | 489 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
470 | 496 | | |
471 | 497 | | |
472 | 498 | | |
| |||
520 | 546 | | |
521 | 547 | | |
522 | 548 | | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
| 549 | + | |
527 | 550 | | |
528 | 551 | | |
529 | | - | |
530 | | - | |
531 | 552 | | |
532 | 553 | | |
533 | 554 | | |
534 | 555 | | |
535 | 556 | | |
536 | | - | |
| 557 | + | |
537 | 558 | | |
538 | 559 | | |
539 | 560 | | |
| |||
0 commit comments