Commit d0be834
committed
Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put
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: stable@kernel.org
Reported-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tested-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>1 parent ef61b6e commit d0be834
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 | | |
| |||
5895 | 5928 | | |
5896 | 5929 | | |
5897 | 5930 | | |
5898 | | - | |
5899 | 5931 | | |
5900 | 5932 | | |
5901 | 5933 | | |
5902 | 5934 | | |
5903 | | - | |
| 5935 | + | |
5904 | 5936 | | |
5905 | 5937 | | |
5906 | 5938 | | |
| |||
5911 | 5943 | | |
5912 | 5944 | | |
5913 | 5945 | | |
| 5946 | + | |
5914 | 5947 | | |
| 5948 | + | |
5915 | 5949 | | |
5916 | 5950 | | |
5917 | 5951 | | |
| |||
7597 | 7631 | | |
7598 | 7632 | | |
7599 | 7633 | | |
| 7634 | + | |
7600 | 7635 | | |
7601 | 7636 | | |
7602 | 7637 | | |
| |||
8085 | 8120 | | |
8086 | 8121 | | |
8087 | 8122 | | |
8088 | | - | |
| 8123 | + | |
8089 | 8124 | | |
8090 | 8125 | | |
8091 | 8126 | | |
| |||
0 commit comments