Commit 4ea5763
HID: uhid: Fix worker destroying device without any protection
uhid has to run hid_add_device() from workqueue context while allowing
parallel use of the userspace API (which is protected with ->devlock).
But hid_add_device() can fail. Currently, that is handled by immediately
destroying the associated HID device, without using ->devlock - but if
there are concurrent requests from userspace, that's wrong and leads to
NULL dereferences and/or memory corruption (via use-after-free).
Fix it by leaving the HID device as-is in the worker. We can clean it up
later, either in the UHID_DESTROY command handler or in the ->release()
handler.
Cc: stable@vger.kernel.org
Fixes: 67f8ecc ("HID: uhid: fix timeout when probe races with IO")
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>1 parent e24aeff commit 4ea5763
1 file changed
Lines changed: 25 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
31 | 41 | | |
32 | 42 | | |
33 | 43 | | |
34 | 44 | | |
35 | 45 | | |
| 46 | + | |
36 | 47 | | |
37 | 48 | | |
38 | 49 | | |
| |||
63 | 74 | | |
64 | 75 | | |
65 | 76 | | |
66 | | - | |
67 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
68 | 87 | | |
| 88 | + | |
69 | 89 | | |
70 | 90 | | |
71 | 91 | | |
| |||
474 | 494 | | |
475 | 495 | | |
476 | 496 | | |
477 | | - | |
| 497 | + | |
478 | 498 | | |
479 | 499 | | |
480 | 500 | | |
| |||
556 | 576 | | |
557 | 577 | | |
558 | 578 | | |
559 | | - | |
| 579 | + | |
560 | 580 | | |
561 | 581 | | |
562 | 582 | | |
| |||
565 | 585 | | |
566 | 586 | | |
567 | 587 | | |
| 588 | + | |
568 | 589 | | |
569 | 590 | | |
570 | 591 | | |
| |||
0 commit comments