Commit 60f1692
committed
Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put
jira VULN-155527
cve-pre CVE-2022-50386
commit-author Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
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: 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>
(cherry picked from commit d0be834)
Signed-off-by: Brett Mastbergen <bmastbergen@ciq.com>1 parent ee704c4 commit 60f1692
2 files changed
+49
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
807 | 807 | | |
808 | 808 | | |
809 | 809 | | |
| 810 | + | |
810 | 811 | | |
811 | 812 | | |
812 | 813 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
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 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
127 | 132 | | |
128 | 133 | | |
129 | 134 | | |
130 | 135 | | |
131 | 136 | | |
132 | 137 | | |
133 | | - | |
| 138 | + | |
134 | 139 | | |
135 | 140 | | |
136 | 141 | | |
| |||
139 | 144 | | |
140 | 145 | | |
141 | 146 | | |
142 | | - | |
143 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
144 | 153 | | |
145 | 154 | | |
146 | 155 | | |
| |||
165 | 174 | | |
166 | 175 | | |
167 | 176 | | |
168 | | - | |
169 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
170 | 183 | | |
171 | 184 | | |
172 | 185 | | |
| |||
487 | 500 | | |
488 | 501 | | |
489 | 502 | | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
490 | 513 | | |
491 | 514 | | |
492 | 515 | | |
| |||
1800 | 1823 | | |
1801 | 1824 | | |
1802 | 1825 | | |
1803 | | - | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
1804 | 1830 | | |
1805 | 1831 | | |
1806 | 1832 | | |
| |||
1815 | 1841 | | |
1816 | 1842 | | |
1817 | 1843 | | |
1818 | | - | |
| 1844 | + | |
1819 | 1845 | | |
1820 | 1846 | | |
1821 | 1847 | | |
| |||
4190 | 4216 | | |
4191 | 4217 | | |
4192 | 4218 | | |
| 4219 | + | |
4193 | 4220 | | |
4194 | 4221 | | |
4195 | 4222 | | |
| |||
4302 | 4329 | | |
4303 | 4330 | | |
4304 | 4331 | | |
| 4332 | + | |
4305 | 4333 | | |
4306 | 4334 | | |
4307 | 4335 | | |
| |||
5026 | 5054 | | |
5027 | 5055 | | |
5028 | 5056 | | |
| 5057 | + | |
5029 | 5058 | | |
5030 | 5059 | | |
5031 | 5060 | | |
| |||
5118 | 5147 | | |
5119 | 5148 | | |
5120 | 5149 | | |
| 5150 | + | |
5121 | 5151 | | |
5122 | 5152 | | |
5123 | 5153 | | |
| |||
5147 | 5177 | | |
5148 | 5178 | | |
5149 | 5179 | | |
| 5180 | + | |
5150 | 5181 | | |
5151 | 5182 | | |
5152 | 5183 | | |
| |||
5210 | 5241 | | |
5211 | 5242 | | |
5212 | 5243 | | |
| 5244 | + | |
5213 | 5245 | | |
5214 | 5246 | | |
5215 | 5247 | | |
| |||
5245 | 5277 | | |
5246 | 5278 | | |
5247 | 5279 | | |
| 5280 | + | |
5248 | 5281 | | |
5249 | 5282 | | |
5250 | 5283 | | |
| |||
5630 | 5663 | | |
5631 | 5664 | | |
5632 | 5665 | | |
5633 | | - | |
5634 | 5666 | | |
5635 | 5667 | | |
5636 | 5668 | | |
5637 | 5669 | | |
5638 | | - | |
| 5670 | + | |
5639 | 5671 | | |
5640 | 5672 | | |
5641 | 5673 | | |
| |||
5648 | 5680 | | |
5649 | 5681 | | |
5650 | 5682 | | |
| 5683 | + | |
5651 | 5684 | | |
| 5685 | + | |
5652 | 5686 | | |
5653 | 5687 | | |
5654 | 5688 | | |
| |||
6970 | 7004 | | |
6971 | 7005 | | |
6972 | 7006 | | |
| 7007 | + | |
6973 | 7008 | | |
6974 | 7009 | | |
6975 | 7010 | | |
| |||
7374 | 7409 | | |
7375 | 7410 | | |
7376 | 7411 | | |
7377 | | - | |
| 7412 | + | |
7378 | 7413 | | |
7379 | 7414 | | |
7380 | 7415 | | |
| |||
0 commit comments