Commit 0e67287
Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put
BugLink: https://bugs.launchpad.net/bugs/1989228
commit d0be834 upstream.
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]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Kamal Mostafa <[email protected]>
Signed-off-by: Stefan Bader <[email protected]>1 parent aaee5cb commit 0e67287
2 files changed
+49
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
802 | 802 | | |
803 | 803 | | |
804 | 804 | | |
| 805 | + | |
805 | 806 | | |
806 | 807 | | |
807 | 808 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
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 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
123 | 128 | | |
124 | 129 | | |
125 | 130 | | |
126 | 131 | | |
127 | 132 | | |
128 | 133 | | |
129 | | - | |
| 134 | + | |
130 | 135 | | |
131 | 136 | | |
132 | 137 | | |
| |||
135 | 140 | | |
136 | 141 | | |
137 | 142 | | |
138 | | - | |
139 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
140 | 149 | | |
141 | 150 | | |
142 | 151 | | |
| |||
161 | 170 | | |
162 | 171 | | |
163 | 172 | | |
164 | | - | |
165 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
166 | 179 | | |
167 | 180 | | |
168 | 181 | | |
| |||
496 | 509 | | |
497 | 510 | | |
498 | 511 | | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
499 | 522 | | |
500 | 523 | | |
501 | 524 | | |
| |||
1812 | 1835 | | |
1813 | 1836 | | |
1814 | 1837 | | |
1815 | | - | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
1816 | 1842 | | |
1817 | 1843 | | |
1818 | 1844 | | |
| |||
1827 | 1853 | | |
1828 | 1854 | | |
1829 | 1855 | | |
1830 | | - | |
| 1856 | + | |
1831 | 1857 | | |
1832 | 1858 | | |
1833 | 1859 | | |
| |||
4221 | 4247 | | |
4222 | 4248 | | |
4223 | 4249 | | |
| 4250 | + | |
4224 | 4251 | | |
4225 | 4252 | | |
4226 | 4253 | | |
| |||
4334 | 4361 | | |
4335 | 4362 | | |
4336 | 4363 | | |
| 4364 | + | |
4337 | 4365 | | |
4338 | 4366 | | |
4339 | 4367 | | |
| |||
5062 | 5090 | | |
5063 | 5091 | | |
5064 | 5092 | | |
| 5093 | + | |
5065 | 5094 | | |
5066 | 5095 | | |
5067 | 5096 | | |
| |||
5154 | 5183 | | |
5155 | 5184 | | |
5156 | 5185 | | |
| 5186 | + | |
5157 | 5187 | | |
5158 | 5188 | | |
5159 | 5189 | | |
| |||
5183 | 5213 | | |
5184 | 5214 | | |
5185 | 5215 | | |
| 5216 | + | |
5186 | 5217 | | |
5187 | 5218 | | |
5188 | 5219 | | |
| |||
5246 | 5277 | | |
5247 | 5278 | | |
5248 | 5279 | | |
| 5280 | + | |
5249 | 5281 | | |
5250 | 5282 | | |
5251 | 5283 | | |
| |||
5281 | 5313 | | |
5282 | 5314 | | |
5283 | 5315 | | |
| 5316 | + | |
5284 | 5317 | | |
5285 | 5318 | | |
5286 | 5319 | | |
| |||
5653 | 5686 | | |
5654 | 5687 | | |
5655 | 5688 | | |
5656 | | - | |
5657 | 5689 | | |
5658 | 5690 | | |
5659 | 5691 | | |
5660 | 5692 | | |
5661 | | - | |
| 5693 | + | |
5662 | 5694 | | |
5663 | 5695 | | |
5664 | 5696 | | |
| |||
5669 | 5701 | | |
5670 | 5702 | | |
5671 | 5703 | | |
| 5704 | + | |
5672 | 5705 | | |
| 5706 | + | |
5673 | 5707 | | |
5674 | 5708 | | |
5675 | 5709 | | |
| |||
6983 | 7017 | | |
6984 | 7018 | | |
6985 | 7019 | | |
| 7020 | + | |
6986 | 7021 | | |
6987 | 7022 | | |
6988 | 7023 | | |
| |||
7386 | 7421 | | |
7387 | 7422 | | |
7388 | 7423 | | |
7389 | | - | |
| 7424 | + | |
7390 | 7425 | | |
7391 | 7426 | | |
7392 | 7427 | | |
| |||
0 commit comments