Commit cca2c30
committed
Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put
jira VULN-155016
cve-pre CVE-2023-53305
commit-author Luiz Augusto von Dentz <[email protected]>
commit d0be834
This fixes the following trace which is caused by hci_rx_work starting up
*after* the final channel reference has been put() during sock_close() but
*before* the references to the channel have been destroyed, so instead
the code now rely on kref_get_unless_zero/l2cap_chan_hold_unless_zero to
prevent referencing a channel that is about to be destroyed.
refcount_t: increment on 0; use-after-free.
BUG: KASAN: use-after-free in refcount_dec_and_test+0x20/0xd0
Read of size 4 at addr ffffffc114f5bf18 by task kworker/u17:14/705
CPU: 4 PID: 705 Comm: kworker/u17:14 Tainted: G S W
4.14.234-00003-g1fb6d0bd49a4-dirty #28
Hardware name: Qualcomm Technologies, Inc. SM8150 V2 PM8150
Google Inc. MSM sm8150 Flame DVT (DT)
Workqueue: hci0 hci_rx_work
Call trace:
dump_backtrace+0x0/0x378
show_stack+0x20/0x2c
dump_stack+0x124/0x148
print_address_description+0x80/0x2e8
__kasan_report+0x168/0x188
kasan_report+0x10/0x18
__asan_load4+0x84/0x8c
refcount_dec_and_test+0x20/0xd0
l2cap_chan_put+0x48/0x12c
l2cap_recv_frame+0x4770/0x6550
l2cap_recv_acldata+0x44c/0x7a4
hci_acldata_packet+0x100/0x188
hci_rx_work+0x178/0x23c
process_one_work+0x35c/0x95c
worker_thread+0x4cc/0x960
kthread+0x1a8/0x1c4
ret_from_fork+0x10/0x18
Cc: [email protected]
Reported-by: Lee Jones <[email protected]>
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
Tested-by: Lee Jones <[email protected]>
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
(cherry picked from commit d0be834)
Signed-off-by: Roxana Nicolescu <[email protected]>1 parent 60be944 commit cca2c30
2 files changed
+49
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
847 | 847 | | |
848 | 848 | | |
849 | 849 | | |
| 850 | + | |
850 | 851 | | |
851 | 852 | | |
852 | 853 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
122 | | - | |
123 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
124 | 129 | | |
125 | 130 | | |
126 | 131 | | |
127 | 132 | | |
128 | 133 | | |
129 | 134 | | |
130 | | - | |
| 135 | + | |
131 | 136 | | |
132 | 137 | | |
133 | 138 | | |
| |||
136 | 141 | | |
137 | 142 | | |
138 | 143 | | |
139 | | - | |
140 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
141 | 150 | | |
142 | 151 | | |
143 | 152 | | |
| |||
162 | 171 | | |
163 | 172 | | |
164 | 173 | | |
165 | | - | |
166 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
167 | 180 | | |
168 | 181 | | |
169 | 182 | | |
| |||
497 | 510 | | |
498 | 511 | | |
499 | 512 | | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
500 | 523 | | |
501 | 524 | | |
502 | 525 | | |
| |||
1968 | 1991 | | |
1969 | 1992 | | |
1970 | 1993 | | |
1971 | | - | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
1972 | 1998 | | |
1973 | 1999 | | |
1974 | 2000 | | |
| |||
1983 | 2009 | | |
1984 | 2010 | | |
1985 | 2011 | | |
1986 | | - | |
| 2012 | + | |
1987 | 2013 | | |
1988 | 2014 | | |
1989 | 2015 | | |
| |||
4463 | 4489 | | |
4464 | 4490 | | |
4465 | 4491 | | |
| 4492 | + | |
4466 | 4493 | | |
4467 | 4494 | | |
4468 | 4495 | | |
| |||
4577 | 4604 | | |
4578 | 4605 | | |
4579 | 4606 | | |
| 4607 | + | |
4580 | 4608 | | |
4581 | 4609 | | |
4582 | 4610 | | |
| |||
5304 | 5332 | | |
5305 | 5333 | | |
5306 | 5334 | | |
| 5335 | + | |
5307 | 5336 | | |
5308 | 5337 | | |
5309 | 5338 | | |
| |||
5396 | 5425 | | |
5397 | 5426 | | |
5398 | 5427 | | |
| 5428 | + | |
5399 | 5429 | | |
5400 | 5430 | | |
5401 | 5431 | | |
| |||
5425 | 5455 | | |
5426 | 5456 | | |
5427 | 5457 | | |
| 5458 | + | |
5428 | 5459 | | |
5429 | 5460 | | |
5430 | 5461 | | |
| |||
5488 | 5519 | | |
5489 | 5520 | | |
5490 | 5521 | | |
| 5522 | + | |
5491 | 5523 | | |
5492 | 5524 | | |
5493 | 5525 | | |
| |||
5523 | 5555 | | |
5524 | 5556 | | |
5525 | 5557 | | |
| 5558 | + | |
5526 | 5559 | | |
5527 | 5560 | | |
5528 | 5561 | | |
| |||
5908 | 5941 | | |
5909 | 5942 | | |
5910 | 5943 | | |
5911 | | - | |
5912 | 5944 | | |
5913 | 5945 | | |
5914 | 5946 | | |
5915 | 5947 | | |
5916 | | - | |
| 5948 | + | |
5917 | 5949 | | |
5918 | 5950 | | |
5919 | 5951 | | |
| |||
5924 | 5956 | | |
5925 | 5957 | | |
5926 | 5958 | | |
| 5959 | + | |
5927 | 5960 | | |
| 5961 | + | |
5928 | 5962 | | |
5929 | 5963 | | |
5930 | 5964 | | |
| |||
7657 | 7691 | | |
7658 | 7692 | | |
7659 | 7693 | | |
| 7694 | + | |
7660 | 7695 | | |
7661 | 7696 | | |
7662 | 7697 | | |
| |||
8145 | 8180 | | |
8146 | 8181 | | |
8147 | 8182 | | |
8148 | | - | |
| 8183 | + | |
8149 | 8184 | | |
8150 | 8185 | | |
8151 | 8186 | | |
| |||
0 commit comments