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.
[
{
"signature_version": "v1",
"target": {
"function": "sock_hash_delete_elem",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@d1e73fb19a4c872d7a399ad3c66e8ca30e0875ec",
"digest": {
"length": 523.0,
"function_hash": "12786689980701657611710724345990080809"
},
"deprecated": false,
"id": "CVE-2024-35895-05b0b10a",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f7990498b05ac41f7d6a190dc0418ef1d21bf058",
"digest": {
"line_hashes": [
"1074852223878148807561491524321676235",
"213781024294962773714955814634849193168",
"4581135675362318478123738937158476976",
"333096522368397877642961394093726744419",
"100986596065302635558474036783127207046",
"259613030674731283397044054643298597240"
],
"threshold": 0.9
},
"deprecated": false,
"id": "CVE-2024-35895-0dfb75a7",
"signature_type": "Line"
},
{
"signature_version": "v1",
"target": {
"function": "sock_hash_delete_elem",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@668b3074aa14829e2ac2759799537a93b60fef86",
"digest": {
"length": 523.0,
"function_hash": "12786689980701657611710724345990080809"
},
"deprecated": false,
"id": "CVE-2024-35895-45015a11",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"function": "__sock_map_delete",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a44770fed86515eedb5a7c00b787f847ebb134a5",
"digest": {
"length": 336.0,
"function_hash": "34679678572678843180978853196840482387"
},
"deprecated": false,
"id": "CVE-2024-35895-55bd377f",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"function": "__sock_map_delete",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ff91059932401894e6c86341915615c5eb0eca48",
"digest": {
"length": 336.0,
"function_hash": "34679678572678843180978853196840482387"
},
"deprecated": false,
"id": "CVE-2024-35895-60783fe3",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"function": "__sock_map_delete",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f7990498b05ac41f7d6a190dc0418ef1d21bf058",
"digest": {
"length": 336.0,
"function_hash": "34679678572678843180978853196840482387"
},
"deprecated": false,
"id": "CVE-2024-35895-649c1ad2",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"function": "__sock_map_delete",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@dd54b48db0c822ae7b520bc80751f0a0a173ef75",
"digest": {
"length": 336.0,
"function_hash": "34679678572678843180978853196840482387"
},
"deprecated": false,
"id": "CVE-2024-35895-786a77eb",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"function": "__sock_map_delete",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@668b3074aa14829e2ac2759799537a93b60fef86",
"digest": {
"length": 336.0,
"function_hash": "34679678572678843180978853196840482387"
},
"deprecated": false,
"id": "CVE-2024-35895-950d4b1c",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"function": "__sock_map_delete",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6af057ccdd8e7619960aca1f0428339f213b31cd",
"digest": {
"length": 336.0,
"function_hash": "34679678572678843180978853196840482387"
},
"deprecated": false,
"id": "CVE-2024-35895-9a7bb2e6",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"function": "sock_hash_delete_elem",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a44770fed86515eedb5a7c00b787f847ebb134a5",
"digest": {
"length": 523.0,
"function_hash": "12786689980701657611710724345990080809"
},
"deprecated": false,
"id": "CVE-2024-35895-9e2d948b",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"function": "sock_hash_delete_elem",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@dd54b48db0c822ae7b520bc80751f0a0a173ef75",
"digest": {
"length": 523.0,
"function_hash": "12786689980701657611710724345990080809"
},
"deprecated": false,
"id": "CVE-2024-35895-a6e61e39",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"function": "__sock_map_delete",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@d1e73fb19a4c872d7a399ad3c66e8ca30e0875ec",
"digest": {
"length": 336.0,
"function_hash": "34679678572678843180978853196840482387"
},
"deprecated": false,
"id": "CVE-2024-35895-abf561fd",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a44770fed86515eedb5a7c00b787f847ebb134a5",
"digest": {
"line_hashes": [
"1074852223878148807561491524321676235",
"213781024294962773714955814634849193168",
"4581135675362318478123738937158476976",
"242103061256389094850370763150010705994",
"270301036901641726096058741157656320823",
"259613030674731283397044054643298597240"
],
"threshold": 0.9
},
"deprecated": false,
"id": "CVE-2024-35895-b0a97152",
"signature_type": "Line"
},
{
"signature_version": "v1",
"target": {
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6af057ccdd8e7619960aca1f0428339f213b31cd",
"digest": {
"line_hashes": [
"18072462441344506787349905394294938908",
"72907990672945074088511432350399965994",
"48167334349908533506800112087564649893",
"242103061256389094850370763150010705994",
"270301036901641726096058741157656320823",
"201496650744256470649781076985400584180"
],
"threshold": 0.9
},
"deprecated": false,
"id": "CVE-2024-35895-c669f61f",
"signature_type": "Line"
},
{
"signature_version": "v1",
"target": {
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@dd54b48db0c822ae7b520bc80751f0a0a173ef75",
"digest": {
"line_hashes": [
"1074852223878148807561491524321676235",
"213781024294962773714955814634849193168",
"4581135675362318478123738937158476976",
"242103061256389094850370763150010705994",
"270301036901641726096058741157656320823",
"259613030674731283397044054643298597240"
],
"threshold": 0.9
},
"deprecated": false,
"id": "CVE-2024-35895-c7f2c8a1",
"signature_type": "Line"
},
{
"signature_version": "v1",
"target": {
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ff91059932401894e6c86341915615c5eb0eca48",
"digest": {
"line_hashes": [
"18072462441344506787349905394294938908",
"72907990672945074088511432350399965994",
"48167334349908533506800112087564649893",
"242103061256389094850370763150010705994",
"270301036901641726096058741157656320823",
"201496650744256470649781076985400584180"
],
"threshold": 0.9
},
"deprecated": false,
"id": "CVE-2024-35895-ce3932c0",
"signature_type": "Line"
},
{
"signature_version": "v1",
"target": {
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@d1e73fb19a4c872d7a399ad3c66e8ca30e0875ec",
"digest": {
"line_hashes": [
"1074852223878148807561491524321676235",
"213781024294962773714955814634849193168",
"4581135675362318478123738937158476976",
"242103061256389094850370763150010705994",
"270301036901641726096058741157656320823",
"259613030674731283397044054643298597240"
],
"threshold": 0.9
},
"deprecated": false,
"id": "CVE-2024-35895-ceb614d4",
"signature_type": "Line"
},
{
"signature_version": "v1",
"target": {
"function": "sock_hash_delete_elem",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ff91059932401894e6c86341915615c5eb0eca48",
"digest": {
"length": 523.0,
"function_hash": "12786689980701657611710724345990080809"
},
"deprecated": false,
"id": "CVE-2024-35895-d9d24086",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"function": "sock_hash_delete_elem",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f7990498b05ac41f7d6a190dc0418ef1d21bf058",
"digest": {
"length": 521.0,
"function_hash": "299962751815897132550444785108729497844"
},
"deprecated": false,
"id": "CVE-2024-35895-f44b1af6",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"function": "sock_hash_delete_elem",
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6af057ccdd8e7619960aca1f0428339f213b31cd",
"digest": {
"length": 523.0,
"function_hash": "12786689980701657611710724345990080809"
},
"deprecated": false,
"id": "CVE-2024-35895-fc4c3e66",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"file": "net/core/sock_map.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@668b3074aa14829e2ac2759799537a93b60fef86",
"digest": {
"line_hashes": [
"18072462441344506787349905394294938908",
"72907990672945074088511432350399965994",
"48167334349908533506800112087564649893",
"242103061256389094850370763150010705994",
"270301036901641726096058741157656320823",
"201496650744256470649781076985400584180"
],
"threshold": 0.9
},
"deprecated": false,
"id": "CVE-2024-35895-fd87883c",
"signature_type": "Line"
}
]