mgmt-tester: Add a regression test hitting hci_sync bug
authorPauli Virtanen <pav@iki.fi>
Thu, 15 Jun 2023 20:02:51 +0000 (23:02 +0300)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 5 Jan 2024 13:34:03 +0000 (19:04 +0530)
commitc12727b37e9541f1515504c8bc74bb41e1c4fd8b
treeaa4e518c1b5ad7356ad4135e1f9d3a16986b6c63
parent5df7616e5c6646366de63d4c8715b7cb46988c4d
mgmt-tester: Add a regression test hitting hci_sync bug

Add a test "Add + Remove Device Nowait - Success" that hits a race
condition in kernel hci_sync.c.  On current kernels this causes

BUG: KASAN: slab-use-after-free in hci_update_passive_scan_sync+0x857/0x1230

due to unsafe iteration of hdev->pend_le_conns (in Linux <= 6.4-rc4).

This seems to hit the race condition also without the added emulator
delay (since the emulator runs in the same thread), but it's better to
add the delay since otherwise it'll depend on timings on kernel side.
tools/mgmt-tester.c