In the Linux kernel, the following vulnerability has been resolved:
vhost/scsi: null-ptr-dereference in vhostscsiget_req()
Since commit 3f8ca2e115e5 ("vhost/scsi: Extract common handling code from control queue handler") a null pointer dereference bug can be triggered when guest sends an SCSI AN request.
In vhostscsictlhandlevq(), vc.target is assigned with
&v_req.tmf.lun[1] within a switch-case block and is then passed to
vhostscsigetreq() which extracts vc->req and tpg. However, for
a VIRTIO_SCSI_T_AN_* request, tpg is not required, so vc.target is
set to NULL in this branch. Later, in vhostscsigetreq(),
vc->target is dereferenced without being checked, leading to a null
pointer dereference bug. This bug can be triggered from guest.
When this bug occurs, the vhost_worker process is killed while holding
vq->mutex and the corresponding tpg will remain occupied
indefinitely.
Below is the KASAN report: Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] CPU: 1 PID: 840 Comm: poc Not tainted 6.10.0+ #1 Hardware name: QEMU Ubuntu 24.04 PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:vhostscsigetreq+0x165/0x3a0 Code: 00 fc ff df 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 2b 02 00 00 48 b8 00 00 00 00 00 fc ff df 4d 8b 65 30 4c 89 e2 48 c1 ea 03 <0f> b6 04 02 4c 89 e2 83 e2 07 38 d0 7f 08 84 c0 0f 85 be 01 00 00 RSP: 0018:ffff888017affb50 EFLAGS: 00010246 RAX: dffffc0000000000 RBX: ffff88801b000000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff888017affcb8 RBP: ffff888017affb80 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: ffff888017affc88 R14: ffff888017affd1c R15: ffff888017993000 FS: 000055556e076500(0000) GS:ffff88806b100000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000200027c0 CR3: 0000000010ed0004 CR4: 0000000000370ef0 Call Trace: <TASK> ? showregs+0x86/0xa0 ? dieaddr+0x4b/0xd0 ? excgeneralprotection+0x163/0x260 ? asmexcgeneralprotection+0x27/0x30 ? vhostscsigetreq+0x165/0x3a0 vhostscsictlhandlevq+0x2a4/0xca0 ? _pfxvhostscsictlhandlevq+0x10/0x10 ? _switchto+0x721/0xeb0 ? _schedule+0xda5/0x5710 ? _kasancheckwrite+0x14/0x30 ? _rawspinlock+0x82/0xf0 vhostscsictlhandlekick+0x52/0x90 vhostrunworklist+0x134/0x1b0 vhosttaskfn+0x121/0x350 ... </TASK> ---[ end trace 0000000000000000 ]---
Let's add a check in vhostscsiget_req.
[whitespace fixes]
[
{
"signature_type": "Function",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@221af82f606d928ccef19a16d35633c63026f1be",
"digest": {
"length": 644.0,
"function_hash": "94430705098732401303114037164846448934"
},
"id": "CVE-2024-49863-13dee5da",
"signature_version": "v1",
"target": {
"function": "vhost_scsi_get_req",
"file": "drivers/vhost/scsi.c"
}
},
{
"signature_type": "Line",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@61517f33e76d2c5247c1e61e668693afe5b67e6f",
"digest": {
"line_hashes": [
"4772730930185664640046129182989016016",
"270214277887437396880516135347521947611",
"38018849822568286419963691794424909854",
"1721158324600397720397355278627412609",
"202760939933799847709588485220867156323",
"191467523125348009347697503117410129744",
"33901148518468035548253961552115479246",
"112147844211414086529035532129964417220",
"189277118379285861105642893258587877463",
"278713143845735982243435481410846053857",
"138850071481935580650067007934502744834",
"171305303088637565086410431522181368797",
"201541717412904143452260414197344225132",
"214458759938473386080683274034781997569"
],
"threshold": 0.9
},
"id": "CVE-2024-49863-21f98765",
"signature_version": "v1",
"target": {
"file": "drivers/vhost/scsi.c"
}
},
{
"signature_type": "Line",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6592347f06e2b19a624270a85ad4b3ae48c3b241",
"digest": {
"line_hashes": [
"4772730930185664640046129182989016016",
"270214277887437396880516135347521947611",
"38018849822568286419963691794424909854",
"1721158324600397720397355278627412609",
"202760939933799847709588485220867156323",
"191467523125348009347697503117410129744",
"33901148518468035548253961552115479246",
"112147844211414086529035532129964417220",
"189277118379285861105642893258587877463",
"278713143845735982243435481410846053857",
"138850071481935580650067007934502744834",
"171305303088637565086410431522181368797",
"201541717412904143452260414197344225132",
"214458759938473386080683274034781997569"
],
"threshold": 0.9
},
"id": "CVE-2024-49863-2748eb6e",
"signature_version": "v1",
"target": {
"file": "drivers/vhost/scsi.c"
}
},
{
"signature_type": "Function",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@46128370a72c431df733af5ebb065c4d48c9ad39",
"digest": {
"length": 644.0,
"function_hash": "94430705098732401303114037164846448934"
},
"id": "CVE-2024-49863-41d1e6ff",
"signature_version": "v1",
"target": {
"function": "vhost_scsi_get_req",
"file": "drivers/vhost/scsi.c"
}
},
{
"signature_type": "Line",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ace9c778a214da9c98d7b69d904d1b0816f4f681",
"digest": {
"line_hashes": [
"4772730930185664640046129182989016016",
"270214277887437396880516135347521947611",
"38018849822568286419963691794424909854",
"1721158324600397720397355278627412609",
"202760939933799847709588485220867156323",
"191467523125348009347697503117410129744",
"33901148518468035548253961552115479246",
"112147844211414086529035532129964417220",
"189277118379285861105642893258587877463",
"278713143845735982243435481410846053857",
"138850071481935580650067007934502744834",
"171305303088637565086410431522181368797",
"201541717412904143452260414197344225132",
"214458759938473386080683274034781997569"
],
"threshold": 0.9
},
"id": "CVE-2024-49863-4d943da5",
"signature_version": "v1",
"target": {
"file": "drivers/vhost/scsi.c"
}
},
{
"signature_type": "Line",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@25613e6d9841a1f9fb985be90df921fa99f800de",
"digest": {
"line_hashes": [
"4772730930185664640046129182989016016",
"270214277887437396880516135347521947611",
"38018849822568286419963691794424909854",
"1721158324600397720397355278627412609",
"202760939933799847709588485220867156323",
"191467523125348009347697503117410129744",
"33901148518468035548253961552115479246",
"112147844211414086529035532129964417220",
"189277118379285861105642893258587877463",
"278713143845735982243435481410846053857",
"138850071481935580650067007934502744834",
"171305303088637565086410431522181368797",
"201541717412904143452260414197344225132",
"214458759938473386080683274034781997569"
],
"threshold": 0.9
},
"id": "CVE-2024-49863-56689f43",
"signature_version": "v1",
"target": {
"file": "drivers/vhost/scsi.c"
}
},
{
"signature_type": "Line",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@00fb5b23e1c9cdbe496f5cd6b40367cb895f6c93",
"digest": {
"line_hashes": [
"4772730930185664640046129182989016016",
"270214277887437396880516135347521947611",
"38018849822568286419963691794424909854",
"1721158324600397720397355278627412609",
"202760939933799847709588485220867156323",
"191467523125348009347697503117410129744",
"33901148518468035548253961552115479246",
"112147844211414086529035532129964417220",
"189277118379285861105642893258587877463",
"278713143845735982243435481410846053857",
"138850071481935580650067007934502744834",
"171305303088637565086410431522181368797",
"201541717412904143452260414197344225132",
"214458759938473386080683274034781997569"
],
"threshold": 0.9
},
"id": "CVE-2024-49863-6b7fba4e",
"signature_version": "v1",
"target": {
"file": "drivers/vhost/scsi.c"
}
},
{
"signature_type": "Function",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@25613e6d9841a1f9fb985be90df921fa99f800de",
"digest": {
"length": 644.0,
"function_hash": "94430705098732401303114037164846448934"
},
"id": "CVE-2024-49863-701afb02",
"signature_version": "v1",
"target": {
"function": "vhost_scsi_get_req",
"file": "drivers/vhost/scsi.c"
}
},
{
"signature_type": "Function",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6592347f06e2b19a624270a85ad4b3ae48c3b241",
"digest": {
"length": 644.0,
"function_hash": "94430705098732401303114037164846448934"
},
"id": "CVE-2024-49863-9160f9c7",
"signature_version": "v1",
"target": {
"function": "vhost_scsi_get_req",
"file": "drivers/vhost/scsi.c"
}
},
{
"signature_type": "Line",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@46128370a72c431df733af5ebb065c4d48c9ad39",
"digest": {
"line_hashes": [
"4772730930185664640046129182989016016",
"270214277887437396880516135347521947611",
"38018849822568286419963691794424909854",
"1721158324600397720397355278627412609",
"202760939933799847709588485220867156323",
"191467523125348009347697503117410129744",
"33901148518468035548253961552115479246",
"112147844211414086529035532129964417220",
"189277118379285861105642893258587877463",
"278713143845735982243435481410846053857",
"138850071481935580650067007934502744834",
"171305303088637565086410431522181368797",
"201541717412904143452260414197344225132",
"214458759938473386080683274034781997569"
],
"threshold": 0.9
},
"id": "CVE-2024-49863-a394d274",
"signature_version": "v1",
"target": {
"file": "drivers/vhost/scsi.c"
}
},
{
"signature_type": "Function",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@00fb5b23e1c9cdbe496f5cd6b40367cb895f6c93",
"digest": {
"length": 644.0,
"function_hash": "94430705098732401303114037164846448934"
},
"id": "CVE-2024-49863-ac3fe2da",
"signature_version": "v1",
"target": {
"function": "vhost_scsi_get_req",
"file": "drivers/vhost/scsi.c"
}
},
{
"signature_type": "Function",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ace9c778a214da9c98d7b69d904d1b0816f4f681",
"digest": {
"length": 644.0,
"function_hash": "94430705098732401303114037164846448934"
},
"id": "CVE-2024-49863-d5dfb90f",
"signature_version": "v1",
"target": {
"function": "vhost_scsi_get_req",
"file": "drivers/vhost/scsi.c"
}
},
{
"signature_type": "Function",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@61517f33e76d2c5247c1e61e668693afe5b67e6f",
"digest": {
"length": 644.0,
"function_hash": "94430705098732401303114037164846448934"
},
"id": "CVE-2024-49863-dd6276f2",
"signature_version": "v1",
"target": {
"function": "vhost_scsi_get_req",
"file": "drivers/vhost/scsi.c"
}
},
{
"signature_type": "Line",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@221af82f606d928ccef19a16d35633c63026f1be",
"digest": {
"line_hashes": [
"4772730930185664640046129182989016016",
"270214277887437396880516135347521947611",
"38018849822568286419963691794424909854",
"1721158324600397720397355278627412609",
"202760939933799847709588485220867156323",
"191467523125348009347697503117410129744",
"33901148518468035548253961552115479246",
"112147844211414086529035532129964417220",
"189277118379285861105642893258587877463",
"278713143845735982243435481410846053857",
"138850071481935580650067007934502744834",
"171305303088637565086410431522181368797",
"201541717412904143452260414197344225132",
"214458759938473386080683274034781997569"
],
"threshold": 0.9
},
"id": "CVE-2024-49863-f080e10f",
"signature_version": "v1",
"target": {
"file": "drivers/vhost/scsi.c"
}
}
]