In the Linux kernel, the following vulnerability has been resolved:
bpf, sockmap: Prevent lock inversion deadlock in map delete elem
syzkaller started using corpuses where a BPF tracing program deletes elements from a sockmap/sockhash map. Because BPF tracing programs can be invoked from any interrupt context, locks taken during a mapdeleteelem operation must be hardirq-safe. Otherwise a deadlock due to lock inversion is possible, as reported by lockdep:
CPU0 CPU1
---- ----
lock(&htab->buckets[i].lock); localirqdisable(); lock(&host->lock); lock(&htab->buckets[i].lock); <Interrupt> lock(&host->lock);
Locks in sockmap are hardirq-unsafe by design. We expects elements to be deleted from sockmap/sockhash only in task (normal) context with interrupts enabled, or in softirq context.
Detect when mapdeleteelem operation is invoked from a context which is not hardirq-unsafe, that is interrupts are disabled, and bail out with an error.
Note that map updates are not affected by this issue. BPF verifier does not allow updating sockmap/sockhash from a BPF tracing program today.
{ "vanir_signatures": [ { "target": { "function": "sock_hash_delete_elem", "file": "net/core/sock_map.c" }, "digest": { "length": 523.0, "function_hash": "12786689980701657611710724345990080809" }, "id": "CVE-2024-35895-05b0b10a", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@d1e73fb19a4c872d7a399ad3c66e8ca30e0875ec" }, { "target": { "file": "net/core/sock_map.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "1074852223878148807561491524321676235", "213781024294962773714955814634849193168", "4581135675362318478123738937158476976", "333096522368397877642961394093726744419", "100986596065302635558474036783127207046", "259613030674731283397044054643298597240" ] }, "id": "CVE-2024-35895-0dfb75a7", "deprecated": false, "signature_type": "Line", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f7990498b05ac41f7d6a190dc0418ef1d21bf058" }, { "target": { "function": "sock_hash_delete_elem", "file": "net/core/sock_map.c" }, "digest": { "length": 523.0, "function_hash": "12786689980701657611710724345990080809" }, "id": "CVE-2024-35895-45015a11", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@668b3074aa14829e2ac2759799537a93b60fef86" }, { "target": { "function": "__sock_map_delete", "file": "net/core/sock_map.c" }, "digest": { "length": 336.0, "function_hash": "34679678572678843180978853196840482387" }, "id": "CVE-2024-35895-55bd377f", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a44770fed86515eedb5a7c00b787f847ebb134a5" }, { "target": { "function": "__sock_map_delete", "file": "net/core/sock_map.c" }, "digest": { "length": 336.0, "function_hash": "34679678572678843180978853196840482387" }, "id": "CVE-2024-35895-60783fe3", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ff91059932401894e6c86341915615c5eb0eca48" }, { "target": { "function": "__sock_map_delete", "file": "net/core/sock_map.c" }, "digest": { "length": 336.0, "function_hash": "34679678572678843180978853196840482387" }, "id": "CVE-2024-35895-649c1ad2", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f7990498b05ac41f7d6a190dc0418ef1d21bf058" }, { "target": { "function": "__sock_map_delete", "file": "net/core/sock_map.c" }, "digest": { "length": 336.0, "function_hash": "34679678572678843180978853196840482387" }, "id": "CVE-2024-35895-786a77eb", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@dd54b48db0c822ae7b520bc80751f0a0a173ef75" }, { "target": { "function": "__sock_map_delete", "file": "net/core/sock_map.c" }, "digest": { "length": 336.0, "function_hash": "34679678572678843180978853196840482387" }, "id": "CVE-2024-35895-950d4b1c", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@668b3074aa14829e2ac2759799537a93b60fef86" }, { "target": { "function": "__sock_map_delete", "file": "net/core/sock_map.c" }, "digest": { "length": 336.0, "function_hash": "34679678572678843180978853196840482387" }, "id": "CVE-2024-35895-9a7bb2e6", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6af057ccdd8e7619960aca1f0428339f213b31cd" }, { "target": { "function": "sock_hash_delete_elem", "file": "net/core/sock_map.c" }, "digest": { "length": 523.0, "function_hash": "12786689980701657611710724345990080809" }, "id": "CVE-2024-35895-9e2d948b", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a44770fed86515eedb5a7c00b787f847ebb134a5" }, { "target": { "function": "sock_hash_delete_elem", "file": "net/core/sock_map.c" }, "digest": { "length": 523.0, "function_hash": "12786689980701657611710724345990080809" }, "id": "CVE-2024-35895-a6e61e39", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@dd54b48db0c822ae7b520bc80751f0a0a173ef75" }, { "target": { "function": "__sock_map_delete", "file": "net/core/sock_map.c" }, "digest": { "length": 336.0, "function_hash": "34679678572678843180978853196840482387" }, "id": "CVE-2024-35895-abf561fd", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@d1e73fb19a4c872d7a399ad3c66e8ca30e0875ec" }, { "target": { "file": "net/core/sock_map.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "1074852223878148807561491524321676235", "213781024294962773714955814634849193168", "4581135675362318478123738937158476976", "242103061256389094850370763150010705994", "270301036901641726096058741157656320823", "259613030674731283397044054643298597240" ] }, "id": "CVE-2024-35895-b0a97152", "deprecated": false, "signature_type": "Line", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a44770fed86515eedb5a7c00b787f847ebb134a5" }, { "target": { "file": "net/core/sock_map.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "18072462441344506787349905394294938908", "72907990672945074088511432350399965994", "48167334349908533506800112087564649893", "242103061256389094850370763150010705994", "270301036901641726096058741157656320823", "201496650744256470649781076985400584180" ] }, "id": "CVE-2024-35895-c669f61f", "deprecated": false, "signature_type": "Line", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6af057ccdd8e7619960aca1f0428339f213b31cd" }, { "target": { "file": "net/core/sock_map.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "1074852223878148807561491524321676235", "213781024294962773714955814634849193168", "4581135675362318478123738937158476976", "242103061256389094850370763150010705994", "270301036901641726096058741157656320823", "259613030674731283397044054643298597240" ] }, "id": "CVE-2024-35895-c7f2c8a1", "deprecated": false, "signature_type": "Line", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@dd54b48db0c822ae7b520bc80751f0a0a173ef75" }, { "target": { "file": "net/core/sock_map.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "18072462441344506787349905394294938908", "72907990672945074088511432350399965994", "48167334349908533506800112087564649893", "242103061256389094850370763150010705994", "270301036901641726096058741157656320823", "201496650744256470649781076985400584180" ] }, "id": "CVE-2024-35895-ce3932c0", "deprecated": false, "signature_type": "Line", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ff91059932401894e6c86341915615c5eb0eca48" }, { "target": { "file": "net/core/sock_map.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "1074852223878148807561491524321676235", "213781024294962773714955814634849193168", "4581135675362318478123738937158476976", "242103061256389094850370763150010705994", "270301036901641726096058741157656320823", "259613030674731283397044054643298597240" ] }, "id": "CVE-2024-35895-ceb614d4", "deprecated": false, "signature_type": "Line", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@d1e73fb19a4c872d7a399ad3c66e8ca30e0875ec" }, { "target": { "function": "sock_hash_delete_elem", "file": "net/core/sock_map.c" }, "digest": { "length": 523.0, "function_hash": "12786689980701657611710724345990080809" }, "id": "CVE-2024-35895-d9d24086", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ff91059932401894e6c86341915615c5eb0eca48" }, { "target": { "function": "sock_hash_delete_elem", "file": "net/core/sock_map.c" }, "digest": { "length": 521.0, "function_hash": "299962751815897132550444785108729497844" }, "id": "CVE-2024-35895-f44b1af6", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f7990498b05ac41f7d6a190dc0418ef1d21bf058" }, { "target": { "function": "sock_hash_delete_elem", "file": "net/core/sock_map.c" }, "digest": { "length": 523.0, "function_hash": "12786689980701657611710724345990080809" }, "id": "CVE-2024-35895-fc4c3e66", "deprecated": false, "signature_type": "Function", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6af057ccdd8e7619960aca1f0428339f213b31cd" }, { "target": { "file": "net/core/sock_map.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "18072462441344506787349905394294938908", "72907990672945074088511432350399965994", "48167334349908533506800112087564649893", "242103061256389094850370763150010705994", "270301036901641726096058741157656320823", "201496650744256470649781076985400584180" ] }, "id": "CVE-2024-35895-fd87883c", "deprecated": false, "signature_type": "Line", "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@668b3074aa14829e2ac2759799537a93b60fef86" } ] }