In the Linux kernel, the following vulnerability has been resolved:
Bluetooth: btmtk: avoid UAF in btmtkprocesscoredump
hcidevcdappend may lead to the release of the skb, so it cannot be accessed once it is called.
================================================================== BUG: KASAN: slab-use-after-free in btmtkprocesscoredump+0x2a7/0x2d0 [btmtk] Read of size 4 at addr ffff888033cfabb0 by task kworker/0:3/82
CPU: 0 PID: 82 Comm: kworker/0:3 Tainted: G U 6.6.40-lockdep-03464-g1d8b4eb3060e #1 b0b3c1cc0c842735643fb411799d97921d1f688c Hardware name: Google YaviksUfs/YaviksUfs, BIOS GoogleYaviksUfs.15217.552.0 05/07/2024 Workqueue: events btusbrxwork [btusb] Call Trace: <TASK> dumpstacklvl+0xfd/0x150 printreport+0x131/0x780 kasanreport+0x177/0x1c0 btmtkprocesscoredump+0x2a7/0x2d0 [btmtk 03edd567dd71a65958807c95a65db31d433e1d01] btusbrecvaclmtk+0x11c/0x1a0 [btusb 675430d1e87c4f24d0c1f80efe600757a0f32bec] btusbrxwork+0x9e/0xe0 [btusb 675430d1e87c4f24d0c1f80efe600757a0f32bec] workerthread+0xe44/0x2cc0 kthread+0x2ff/0x3a0 retfromfork+0x51/0x80 retfromfork_asm+0x1b/0x30 </TASK>
Allocated by task 82: stacktracesave+0xdc/0x190 kasansettrack+0x4e/0x80 _kasanslaballoc+0x4e/0x60 kmemcachealloc+0x19f/0x360 skbclone+0x132/0xf70 btusbrecvaclmtk+0x104/0x1a0 [btusb] btusbrxwork+0x9e/0xe0 [btusb] workerthread+0xe44/0x2cc0 kthread+0x2ff/0x3a0 retfromfork+0x51/0x80 retfromfork_asm+0x1b/0x30
Freed by task 1733: stacktracesave+0xdc/0x190 kasansettrack+0x4e/0x80 kasansavefreeinfo+0x28/0xb0 __kasanslabfree+0xfd/0x170 kmemcachefree+0x183/0x3f0 hcidevcdrx+0x91a/0x2060 [bluetooth] workerthread+0xe44/0x2cc0 kthread+0x2ff/0x3a0 retfromfork+0x51/0x80 retfromfork_asm+0x1b/0x30
The buggy address belongs to the object at ffff888033cfab40 which belongs to the cache skbuffheadcache of size 232 The buggy address is located 112 bytes inside of freed 232-byte region [ffff888033cfab40, ffff888033cfac28)
The buggy address belongs to the physical page: page:00000000a174ba93 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x33cfa head:00000000a174ba93 order:1 entiremapcount:0 nrpagesmapped:0 pincount:0 anon flags: 0x4000000000000840(slab|head|zone=1) pagetype: 0xffffffff() raw: 4000000000000840 ffff888100848a00 0000000000000000 0000000000000001 raw: 0000000000000000 0000000080190019 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected
Memory state around the buggy address: ffff888033cfaa80: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc ffff888033cfab00: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
ffff888033cfab80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888033cfac00: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc
ffff888033cfac80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
Check if we need to call hcidevcdcomplete before calling hcidevcdappend. That requires that we check data->cdinfo.cnt >= MTKCOREDUMPNUM instead of data->cdinfo.cnt > MTKCOREDUMPNUM, as we increment data->cdinfo.cnt only once the call to hcidevcd_append succeeds.
{ "vanir_signatures": [ { "target": { "file": "drivers/bluetooth/btmtk.c", "function": "btmtk_process_coredump" }, "signature_version": "v1", "digest": { "length": 883.0, "function_hash": "129318404092335620282011670122398288291" }, "id": "CVE-2024-56653-00e6b280", "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b548f5e9456c568155499d9ebac675c0d7a296e8", "signature_type": "Function" }, { "target": { "file": "drivers/bluetooth/btmtk.c" }, "signature_version": "v1", "digest": { "threshold": 0.9, "line_hashes": [ "318434091406538274980478790899425449034", "309661916878606289375171195327237299483", "115527264333147166089047356539577619807", "79831777695047036664418283094426715132", "224019476984799952962733906334926689363", "95349911748326466342158559247086264217", "305053613467974279922422611353782134110", "318733821704120982228484939861110038833", "313435958741607436609255560211688410085", "338448916266391042329571449534294817351", "28600178698272099479356897437273721773", "180539902635826074899930644332070064664", "40584776914545087833614134141630362972", "50625970161735976019799793171283269876", "318549121672618072065131921198954800635", "329653033317071127434388048170924836821", "131626896306501676172126016561382152715", "107974468671408301127976837041725439319", "306789643481080601051252993730501328429" ] }, "id": "CVE-2024-56653-7fc9075f", "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b548f5e9456c568155499d9ebac675c0d7a296e8", "signature_type": "Line" }, { "target": { "file": "drivers/bluetooth/btmtk.c" }, "signature_version": "v1", "digest": { "threshold": 0.9, "line_hashes": [ "211090639320682045668233446706979406378", "279656770597310521450774911510678278056", "316407119192089143715698476304221921124", "79831777695047036664418283094426715132", "224019476984799952962733906334926689363", "95349911748326466342158559247086264217", "305053613467974279922422611353782134110", "318733821704120982228484939861110038833", "313435958741607436609255560211688410085", "338448916266391042329571449534294817351", "28600178698272099479356897437273721773", "180539902635826074899930644332070064664", "40584776914545087833614134141630362972", "50625970161735976019799793171283269876", "318549121672618072065131921198954800635", "329653033317071127434388048170924836821", "131626896306501676172126016561382152715", "107974468671408301127976837041725439319", "306789643481080601051252993730501328429" ] }, "id": "CVE-2024-56653-be91a202", "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ecdcaea0e4057171ea4c3783e1cc1c900ad99125", "signature_type": "Line" }, { "target": { "file": "drivers/bluetooth/btmtk.c", "function": "btmtk_process_coredump" }, "signature_version": "v1", "digest": { "length": 883.0, "function_hash": "129318404092335620282011670122398288291" }, "id": "CVE-2024-56653-cc566907", "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ecdcaea0e4057171ea4c3783e1cc1c900ad99125", "signature_type": "Function" } ] }