In the Linux kernel, the following vulnerability has been resolved:
Bluetooth: Fix use-after-free bugs caused by scosocktimeout
When the sco connection is established and then, the sco socket is releasing, timeoutwork will be scheduled to judge whether the sco disconnection is timeout. The sock will be deallocated later, but it is dereferenced again in scosock_timeout. As a result, the use-after-free bugs will happen. The root cause is shown below:
Cleanup Thread | Worker Thread
scosockrelease | scosockclose | _scosockclose | scosocksettimer | scheduledelayedwork | scosockkill | (wait a time) sockput(sk) //FREE | scosocktimeout | sockhold(sk) //USE
The KASAN report triggered by POC is shown below:
[ 95.890016] ================================================================== [ 95.890496] BUG: KASAN: slab-use-after-free in scosocktimeout+0x5e/0x1c0 [ 95.890755] Write of size 4 at addr ffff88800c388080 by task kworker/0:0/7 ... [ 95.890755] Workqueue: events scosocktimeout [ 95.890755] Call Trace: [ 95.890755] <TASK> [ 95.890755] dumpstacklvl+0x45/0x110 [ 95.890755] printaddressdescription+0x78/0x390 [ 95.890755] printreport+0x11b/0x250 [ 95.890755] ? _virtaddrvalid+0xbe/0xf0 [ 95.890755] ? scosocktimeout+0x5e/0x1c0 [ 95.890755] kasanreport+0x139/0x170 [ 95.890755] ? updateloadavg+0xe5/0x9f0 [ 95.890755] ? scosocktimeout+0x5e/0x1c0 [ 95.890755] kasancheckrange+0x2c3/0x2e0 [ 95.890755] scosocktimeout+0x5e/0x1c0 [ 95.890755] processonework+0x561/0xc50 [ 95.890755] workerthread+0xab2/0x13c0 [ 95.890755] ? prcontwork+0x490/0x490 [ 95.890755] kthread+0x279/0x300 [ 95.890755] ? prcontwork+0x490/0x490 [ 95.890755] ? kthreadblkcg+0xa0/0xa0 [ 95.890755] retfromfork+0x34/0x60 [ 95.890755] ? kthreadblkcg+0xa0/0xa0 [ 95.890755] retfromforkasm+0x11/0x20 [ 95.890755] </TASK> [ 95.890755] [ 95.890755] Allocated by task 506: [ 95.890755] kasansavetrack+0x3f/0x70 [ 95.890755] _kasankmalloc+0x86/0x90 [ 95.890755] _kmalloc+0x17f/0x360 [ 95.890755] skprotalloc+0xe1/0x1a0 [ 95.890755] skalloc+0x31/0x4e0 [ 95.890755] btsockalloc+0x2b/0x2a0 [ 95.890755] scosockcreate+0xad/0x320 [ 95.890755] btsockcreate+0x145/0x320 [ 95.890755] _sockcreate+0x2e1/0x650 [ 95.890755] _syssocket+0xd0/0x280 [ 95.890755] _x64syssocket+0x75/0x80 [ 95.890755] dosyscall64+0xc4/0x1b0 [ 95.890755] entrySYSCALL64afterhwframe+0x67/0x6f [ 95.890755] [ 95.890755] Freed by task 506: [ 95.890755] kasansavetrack+0x3f/0x70 [ 95.890755] kasansavefreeinfo+0x40/0x50 [ 95.890755] poisonslabobject+0x118/0x180 [ 95.890755] _kasanslabfree+0x12/0x30 [ 95.890755] kfree+0xb2/0x240 [ 95.890755] _skdestruct+0x317/0x410 [ 95.890755] scosockrelease+0x232/0x280 [ 95.890755] sockclose+0xb2/0x210 [ 95.890755] _fput+0x37f/0x770 [ 95.890755] taskworkrun+0x1ae/0x210 [ 95.890755] getsignal+0xe17/0xf70 [ 95.890755] archdosignalorrestart+0x3f/0x520 [ 95.890755] syscallexittousermode+0x55/0x120 [ 95.890755] dosyscall64+0xd1/0x1b0 [ 95.890755] entrySYSCALL64afterhwframe+0x67/0x6f [ 95.890755] [ 95.890755] The buggy address belongs to the object at ffff88800c388000 [ 95.890755] which belongs to the cache kmalloc-1k of size 1024 [ 95.890755] The buggy address is located 128 bytes inside of [ 95.890755] freed 1024-byte region [ffff88800c388000, ffff88800c388400) [ 95.890755] [ 95.890755] The buggy address belongs to the physical page: [ 95.890755] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88800c38a800 pfn:0xc388 [ 95.890755] head: order:3 entiremapcount:0 nrpagesmapped:0 pincount:0 [ 95.890755] ano ---truncated---
[
{
"id": "CVE-2024-27398-017ddef5",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1b33d55fb7355e27f8c82cd4ecd560f162469249",
"target": {
"file": "net/bluetooth/sco.c"
},
"deprecated": false,
"signature_type": "Line",
"digest": {
"line_hashes": [
"112331891533894293697584866353874619378",
"261775201163560520263071237910260144688",
"106580885398398089633993832620806243604",
"249480883934655497862427251669960256888"
],
"threshold": 0.9
}
},
{
"id": "CVE-2024-27398-16804038",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@33a6e92161a78c1073d90e27abe28d746feb0a53",
"target": {
"file": "net/bluetooth/sco.c"
},
"deprecated": false,
"signature_type": "Line",
"digest": {
"line_hashes": [
"112331891533894293697584866353874619378",
"261775201163560520263071237910260144688",
"106580885398398089633993832620806243604",
"249480883934655497862427251669960256888"
],
"threshold": 0.9
}
},
{
"id": "CVE-2024-27398-22a5bd5a",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@483bc08181827fc475643272ffb69c533007e546",
"target": {
"file": "net/bluetooth/sco.c",
"function": "sco_sock_timeout"
},
"deprecated": false,
"signature_type": "Function",
"digest": {
"length": 436.0,
"function_hash": "276399393007131979490830543856209435219"
}
},
{
"id": "CVE-2024-27398-26fc5a46",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3212afd00e3cda790fd0583cb3eaef8f9575a014",
"target": {
"file": "net/bluetooth/sco.c",
"function": "sco_sock_timeout"
},
"deprecated": false,
"signature_type": "Function",
"digest": {
"length": 436.0,
"function_hash": "276399393007131979490830543856209435219"
}
},
{
"id": "CVE-2024-27398-3e84782f",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3212afd00e3cda790fd0583cb3eaef8f9575a014",
"target": {
"file": "net/bluetooth/sco.c"
},
"deprecated": false,
"signature_type": "Line",
"digest": {
"line_hashes": [
"112331891533894293697584866353874619378",
"261775201163560520263071237910260144688",
"106580885398398089633993832620806243604",
"249480883934655497862427251669960256888"
],
"threshold": 0.9
}
},
{
"id": "CVE-2024-27398-4199c6f8",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1b33d55fb7355e27f8c82cd4ecd560f162469249",
"target": {
"file": "net/bluetooth/sco.c",
"function": "sco_sock_timeout"
},
"deprecated": false,
"signature_type": "Function",
"digest": {
"length": 436.0,
"function_hash": "276399393007131979490830543856209435219"
}
},
{
"id": "CVE-2024-27398-462f5441",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@012363cb1bec5f33a7b94629ab2c1086f30280f2",
"target": {
"file": "net/bluetooth/sco.c",
"function": "sco_sock_timeout"
},
"deprecated": false,
"signature_type": "Function",
"digest": {
"length": 436.0,
"function_hash": "276399393007131979490830543856209435219"
}
},
{
"id": "CVE-2024-27398-7f398899",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6a18eeb1b3bbc67c20d9609c31dca6a69b4bcde5",
"target": {
"file": "net/bluetooth/sco.c"
},
"deprecated": false,
"signature_type": "Line",
"digest": {
"line_hashes": [
"112331891533894293697584866353874619378",
"261775201163560520263071237910260144688",
"106580885398398089633993832620806243604",
"249480883934655497862427251669960256888"
],
"threshold": 0.9
}
},
{
"id": "CVE-2024-27398-8bb09270",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@bfab2c1f7940a232cd519e82fff137e308abfd93",
"target": {
"file": "net/bluetooth/sco.c"
},
"deprecated": false,
"signature_type": "Line",
"digest": {
"line_hashes": [
"112331891533894293697584866353874619378",
"261775201163560520263071237910260144688",
"106580885398398089633993832620806243604",
"249480883934655497862427251669960256888"
],
"threshold": 0.9
}
},
{
"id": "CVE-2024-27398-8dd40e9b",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@50c2037fc28df870ef29d9728c770c8955d32178",
"target": {
"file": "net/bluetooth/sco.c",
"function": "sco_sock_timeout"
},
"deprecated": false,
"signature_type": "Function",
"digest": {
"length": 436.0,
"function_hash": "276399393007131979490830543856209435219"
}
},
{
"id": "CVE-2024-27398-921d14e0",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@50c2037fc28df870ef29d9728c770c8955d32178",
"target": {
"file": "net/bluetooth/sco.c"
},
"deprecated": false,
"signature_type": "Line",
"digest": {
"line_hashes": [
"112331891533894293697584866353874619378",
"261775201163560520263071237910260144688",
"106580885398398089633993832620806243604",
"249480883934655497862427251669960256888"
],
"threshold": 0.9
}
},
{
"id": "CVE-2024-27398-c10c486a",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@33a6e92161a78c1073d90e27abe28d746feb0a53",
"target": {
"file": "net/bluetooth/sco.c",
"function": "sco_sock_timeout"
},
"deprecated": false,
"signature_type": "Function",
"digest": {
"length": 436.0,
"function_hash": "276399393007131979490830543856209435219"
}
},
{
"id": "CVE-2024-27398-c28f6638",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@bfab2c1f7940a232cd519e82fff137e308abfd93",
"target": {
"file": "net/bluetooth/sco.c",
"function": "sco_sock_timeout"
},
"deprecated": false,
"signature_type": "Function",
"digest": {
"length": 436.0,
"function_hash": "276399393007131979490830543856209435219"
}
},
{
"id": "CVE-2024-27398-c73ae0b2",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@012363cb1bec5f33a7b94629ab2c1086f30280f2",
"target": {
"file": "net/bluetooth/sco.c"
},
"deprecated": false,
"signature_type": "Line",
"digest": {
"line_hashes": [
"112331891533894293697584866353874619378",
"261775201163560520263071237910260144688",
"106580885398398089633993832620806243604",
"249480883934655497862427251669960256888"
],
"threshold": 0.9
}
},
{
"id": "CVE-2024-27398-d7f797be",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6a18eeb1b3bbc67c20d9609c31dca6a69b4bcde5",
"target": {
"file": "net/bluetooth/sco.c",
"function": "sco_sock_timeout"
},
"deprecated": false,
"signature_type": "Function",
"digest": {
"length": 436.0,
"function_hash": "276399393007131979490830543856209435219"
}
},
{
"id": "CVE-2024-27398-ee63e940",
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@483bc08181827fc475643272ffb69c533007e546",
"target": {
"file": "net/bluetooth/sco.c"
},
"deprecated": false,
"signature_type": "Line",
"digest": {
"line_hashes": [
"112331891533894293697584866353874619378",
"261775201163560520263071237910260144688",
"106580885398398089633993832620806243604",
"249480883934655497862427251669960256888"
],
"threshold": 0.9
}
}
]