Commit a2ac591
Bluetooth: Fix UAF in hci_conn_hash_flush again
Commit 0614974 ("Bluetooth: hci_conn: Add support for linking
multiple hcon") reintroduced a previously fixed bug [1] ("KASAN:
slab-use-after-free Read in hci_conn_hash_flush"). This bug was
originally fixed by commit 5dc7d23 ("Bluetooth: hci_conn: Fix
possible UAF").
The hci_conn_unlink function was added to avoid invalidating the link
traversal caused by successive hci_conn_del operations releasing extra
connections. However, currently hci_conn_unlink itself also releases
extra connections, resulted in the reintroduced bug.
This patch follows a more robust solution for cleaning up all
connections, by repeatedly removing the first connection until there are
none left. This approach does not rely on the inner workings of
hci_conn_del and ensures proper cleanup of all connections.
Meanwhile, we need to make sure that hci_conn_del never fails. Indeed it
doesn't, as it now always returns zero. To make this a bit clearer, this
patch also changes its return type to void.
Reported-by: syzbot+8bb72f86fc823817bc5d@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-bluetooth/000000000000aa920505f60d25ad@google.com/
Fixes: 0614974 ("Bluetooth: hci_conn: Add support for linking multiple hcon")
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
Co-developed-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>1 parent 2910431 commit a2ac591
2 files changed
Lines changed: 23 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1327 | 1327 | | |
1328 | 1328 | | |
1329 | 1329 | | |
1330 | | - | |
| 1330 | + | |
1331 | 1331 | | |
1332 | 1332 | | |
1333 | 1333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1088 | 1088 | | |
1089 | 1089 | | |
1090 | 1090 | | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
1091 | 1099 | | |
1092 | 1100 | | |
1093 | 1101 | | |
| |||
1112 | 1120 | | |
1113 | 1121 | | |
1114 | 1122 | | |
1115 | | - | |
| 1123 | + | |
1116 | 1124 | | |
1117 | 1125 | | |
1118 | 1126 | | |
| |||
1163 | 1171 | | |
1164 | 1172 | | |
1165 | 1173 | | |
1166 | | - | |
1167 | | - | |
1168 | 1174 | | |
1169 | 1175 | | |
1170 | 1176 | | |
| |||
2465 | 2471 | | |
2466 | 2472 | | |
2467 | 2473 | | |
2468 | | - | |
2469 | | - | |
| 2474 | + | |
| 2475 | + | |
2470 | 2476 | | |
2471 | 2477 | | |
2472 | 2478 | | |
2473 | | - | |
2474 | | - | |
2475 | | - | |
2476 | | - | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
2477 | 2488 | | |
2478 | 2489 | | |
2479 | 2490 | | |
2480 | 2491 | | |
2481 | 2492 | | |
2482 | | - | |
2483 | | - | |
| 2493 | + | |
| 2494 | + | |
2484 | 2495 | | |
2485 | 2496 | | |
2486 | 2497 | | |
| |||
0 commit comments