Commit d255c86
Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put
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: 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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 9645f70 commit d255c86
2 files changed
+49
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
798 | 798 | | |
799 | 799 | | |
800 | 800 | | |
| 801 | + | |
801 | 802 | | |
802 | 803 | | |
803 | 804 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
| 117 | + | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
124 | | - | |
125 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
126 | 131 | | |
127 | 132 | | |
128 | 133 | | |
129 | 134 | | |
130 | 135 | | |
131 | 136 | | |
132 | | - | |
| 137 | + | |
133 | 138 | | |
134 | 139 | | |
135 | 140 | | |
| |||
138 | 143 | | |
139 | 144 | | |
140 | 145 | | |
141 | | - | |
142 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
143 | 152 | | |
144 | 153 | | |
145 | 154 | | |
| |||
164 | 173 | | |
165 | 174 | | |
166 | 175 | | |
167 | | - | |
168 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
169 | 182 | | |
170 | 183 | | |
171 | 184 | | |
| |||
491 | 504 | | |
492 | 505 | | |
493 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
494 | 517 | | |
495 | 518 | | |
496 | 519 | | |
| |||
1803 | 1826 | | |
1804 | 1827 | | |
1805 | 1828 | | |
1806 | | - | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
1807 | 1833 | | |
1808 | 1834 | | |
1809 | 1835 | | |
| |||
1818 | 1844 | | |
1819 | 1845 | | |
1820 | 1846 | | |
1821 | | - | |
| 1847 | + | |
1822 | 1848 | | |
1823 | 1849 | | |
1824 | 1850 | | |
| |||
4194 | 4220 | | |
4195 | 4221 | | |
4196 | 4222 | | |
| 4223 | + | |
4197 | 4224 | | |
4198 | 4225 | | |
4199 | 4226 | | |
| |||
4306 | 4333 | | |
4307 | 4334 | | |
4308 | 4335 | | |
| 4336 | + | |
4309 | 4337 | | |
4310 | 4338 | | |
4311 | 4339 | | |
| |||
5034 | 5062 | | |
5035 | 5063 | | |
5036 | 5064 | | |
| 5065 | + | |
5037 | 5066 | | |
5038 | 5067 | | |
5039 | 5068 | | |
| |||
5126 | 5155 | | |
5127 | 5156 | | |
5128 | 5157 | | |
| 5158 | + | |
5129 | 5159 | | |
5130 | 5160 | | |
5131 | 5161 | | |
| |||
5155 | 5185 | | |
5156 | 5186 | | |
5157 | 5187 | | |
| 5188 | + | |
5158 | 5189 | | |
5159 | 5190 | | |
5160 | 5191 | | |
| |||
5218 | 5249 | | |
5219 | 5250 | | |
5220 | 5251 | | |
| 5252 | + | |
5221 | 5253 | | |
5222 | 5254 | | |
5223 | 5255 | | |
| |||
5253 | 5285 | | |
5254 | 5286 | | |
5255 | 5287 | | |
| 5288 | + | |
5256 | 5289 | | |
5257 | 5290 | | |
5258 | 5291 | | |
| |||
5625 | 5658 | | |
5626 | 5659 | | |
5627 | 5660 | | |
5628 | | - | |
5629 | 5661 | | |
5630 | 5662 | | |
5631 | 5663 | | |
5632 | 5664 | | |
5633 | | - | |
| 5665 | + | |
5634 | 5666 | | |
5635 | 5667 | | |
5636 | 5668 | | |
| |||
5643 | 5675 | | |
5644 | 5676 | | |
5645 | 5677 | | |
| 5678 | + | |
5646 | 5679 | | |
| 5680 | + | |
5647 | 5681 | | |
5648 | 5682 | | |
5649 | 5683 | | |
| |||
6941 | 6975 | | |
6942 | 6976 | | |
6943 | 6977 | | |
| 6978 | + | |
6944 | 6979 | | |
6945 | 6980 | | |
6946 | 6981 | | |
| |||
7345 | 7380 | | |
7346 | 7381 | | |
7347 | 7382 | | |
7348 | | - | |
| 7383 | + | |
7349 | 7384 | | |
7350 | 7385 | | |
7351 | 7386 | | |
| |||
0 commit comments