{"id":"CVE-2026-23342","aliases":["CVE-2026-23342"],"related":[],"kind":"vulnerability","state":"published","title":"bpf: Fix race in cpumap on PREEMPT_RT","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Fix race in cpumap on PREEMPT_RT\n\nOn PREEMPT_RT kernels, the per-CPU xdp_bulk_queue (bq) can be accessed\nconcurrently by multiple preemptible tasks on the same CPU.\n\nThe original code assumes bq_enqueue() and __cpu_map_flush() run\natomically with respect to each other on the same CPU, relying on\nlocal_bh_disable() to prevent preemption. However, on PREEMPT_RT,\nlocal_bh_disable() only calls migrate_disable() (when\nPREEMPT_RT_NEEDS_BH_LOCK is not set) and does not disable\npreemption, which allows CFS scheduling to preempt a task during\nbq_flush_to_queue(), enabling another task on the same CPU to enter\nbq_enqueue() and operate on the same per-CPU bq concurrently.\n\nThis leads to several races:\n\n1. Double __list_del_clearprev(): after bq->count is reset in\n   bq_flush_to_queue(), a preempting task can call bq_enqueue() ->\n   bq_flush_to_queue() on the same bq when bq->count reaches\n   CPU_MAP_BULK_SIZE. Both tasks then call __list_del_clearprev()\n   on the same bq->flush_node, the second call dereferences the\n   prev pointer that was already set to NULL by the first.\n\n2. bq->count and bq->q[] races: concurrent bq_enqueue() can corrupt\n   the packet queue while bq_flush_to_queue() is processing it.\n\nThe race between task A (__cpu_map_flush -> bq_flush_to_queue) and\ntask B (bq_enqueue -> bq_flush_to_queue) on the same CPU:\n\n  Task A (xdp_do_flush)          Task B (cpu_map_enqueue)\n  ----------------------         ------------------------\n  bq_flush_to_queue(bq)\n    spin_lock(&q->producer_lock)\n    /* flush bq->q[] to ptr_ring */\n    bq->count = 0\n    spin_unlock(&q->producer_lock)\n                                   bq_enqueue(rcpu, xdpf)\n    <-- CFS preempts Task A -->      bq->q[bq->count++] = xdpf\n                                     /* ... more enqueues until full ... */\n                                     bq_flush_to_queue(bq)\n                                       spin_lock(&q->producer_lock)\n                                       /* flush to ptr_ring */\n                                       spin_unlock(&q->producer_lock)\n                                       __list_del_clearprev(flush_node)\n                                         /* sets flush_node.prev = NULL */\n    <-- Task A resumes -->\n    __list_del_clearprev(flush_node)\n      flush_node.prev->next = ...\n      /* prev is NULL -> kernel oops */\n\nFix this by adding a local_lock_t to xdp_bulk_queue and acquiring it\nin bq_enqueue() and __cpu_map_flush(). These paths already run under\nlocal_bh_disable(), so use local_lock_nested_bh() which on non-RT is\na pure annotation with no overhead, and on PREEMPT_RT provides a\nper-CPU sleeping lock that serializes access to the bq.\n\nTo reproduce, insert an mdelay(100) between bq->count = 0 and\n__list_del_clearprev() in bq_flush_to_queue(), then run reproducer\nprovided by syzkaller.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Fix race in cpumap on PREEMPT_RT\n\nOn PREEMPT_RT kernels, the per-CPU xdp_bulk_queue (bq) can be accessed\nconcurrently by multiple preemptible tasks on the same CPU.\n\nThe original code assumes bq_enqueue() and __cpu_map_flush() run\natomically with respect to each other on the same CPU, relying on\nlocal_bh_disable() to prevent preemption. However, on PREEMPT_RT,\nlocal_bh_disable() only calls migrate_disable() (when\nPREEMPT_RT_NEEDS_BH_LOCK is not set) and does not disable\npreemption, which allows CFS scheduling to preempt a task during\nbq_flush_to_queue(), enabling another task on the same CPU to enter\nbq_enqueue() and operate on the same per-CPU bq concurrently.\n\nThis leads to several races:\n\n1. Double __list_del_clearprev(): after bq->count is reset in\n   bq_flush_to_queue(), a preempting task can call bq_enqueue() ->\n   bq_flush_to_queue() on the same bq when bq->count reaches\n   CPU_MAP_BULK_SIZE. Both tasks then call __list_del_clearprev()\n   on the same bq->flush_node, the second call dereferences the\n   prev pointer that was already set to NULL by the first.\n\n2. bq->count and bq->q[] races: concurrent bq_enqueue() can corrupt\n   the packet queue while bq_flush_to_queue() is processing it.\n\nThe race between task A (__cpu_map_flush -> bq_flush_to_queue) and\ntask B (bq_enqueue -> bq_flush_to_queue) on the same CPU:\n\n  Task A (xdp_do_flush)          Task B (cpu_map_enqueue)\n  ----------------------         ------------------------\n  bq_flush_to_queue(bq)\n    spin_lock(&q->producer_lock)\n    /* flush bq->q[] to ptr_ring */\n    bq->count = 0\n    spin_unlock(&q->producer_lock)\n                                   bq_enqueue(rcpu, xdpf)\n    <-- CFS preempts Task A -->      bq->q[bq->count++] = xdpf\n                                     /* ... more enqueues until full ... */\n                                     bq_flush_to_queue(bq)\n                                       spin_lock(&q->producer_lock)\n                                       /* flush to ptr_ring */\n                                       spin_unlock(&q->producer_lock)\n                                       __list_del_clearprev(flush_node)\n                                         /* sets flush_node.prev = NULL */\n    <-- Task A resumes -->\n    __list_del_clearprev(flush_node)\n      flush_node.prev->next = ...\n      /* prev is NULL -> kernel oops */\n\nFix this by adding a local_lock_t to xdp_bulk_queue and acquiring it\nin bq_enqueue() and __cpu_map_flush(). These paths already run under\nlocal_bh_disable(), so use local_lock_nested_bh() which on non-RT is\na pure annotation with no overhead, and on PREEMPT_RT provides a\nper-CPU sleeping lock that serializes access to the bq.\n\nTo reproduce, insert an mdelay(100) between bq->count = 0 and\n__list_del_clearprev() in bq_flush_to_queue(), then run reproducer\nprovided by syzkaller.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta:\n\nbpf: Corrige condición de carrera en cpumap en PREEMPT_RT\n\nEn kernels PREEMPT_RT, la xdp_bulk_queue (bq) por CPU puede ser accedida concurrentemente por múltiples tareas preemptibles en la misma CPU.\n\nEl código original asume que bq_enqueue() y __cpu_map_flush() se ejecutan atómicamente una con respecto a la otra en la misma CPU, confiando en local_bh_disable() para prevenir la preemption. Sin embargo, en PREEMPT_RT, local_bh_disable() solo llama a migrate_disable() (cuando PREEMPT_RT_NEEDS_BH_LOCK no está configurado) y no deshabilita la preemption, lo que permite que la planificación CFS preempte una tarea durante bq_flush_to_queue(), permitiendo que otra tarea en la misma CPU entre en bq_enqueue() y opere en la misma bq por CPU concurrentemente.\n\nEsto conduce a varias condiciones de carrera:\n\n1. Doble __list_del_clearprev(): después de que bq-&gt;count se reinicia en bq_flush_to_queue(), una tarea preemptora puede llamar a bq_enqueue() -&gt; bq_flush_to_queue() en la misma bq cuando bq-&gt;count alcanza CPU_MAP_BULK_SIZE. Ambas tareas luego llaman a __list_del_clearprev() en el mismo bq-&gt;flush_node, la segunda llamada desreferencia el puntero prev que ya había sido establecido a NULL por la primera.\n\n2. Condiciones de carrera de bq-&gt;count y bq-&gt;q[]: bq_enqueue() concurrente puede corromper la cola de paquetes mientras bq_flush_to_queue() la está procesando.\n\nLa condición de carrera entre la tarea A (__cpu_map_flush -&gt; bq_flush_to_queue) y la tarea B (bq_enqueue -&gt; bq_flush_to_queue) en la misma CPU:\n\n  Tarea A (xdp_do_flush)          Tarea B (cpu_map_enqueue)\n  ----------------------         ------------------------\n  bq_flush_to_queue(bq)\n    spin_lock(&amp;q-&gt;producer_lock)\n    /* vaciar bq-&gt;q[] a ptr_ring */\n    bq-&gt;count = 0\n    spin_unlock(&amp;q-&gt;producer_lock)\n                                   bq_enqueue(rcpu, xdpf)\n  &lt;-- CFS preempte la Tarea A --&gt;  bq-&gt;q[bq-&gt;count++] = xdpf\n                                     /* ... más encolamientos hasta llenarse ... */\n                                     bq_flush_to_queue(bq)\n                                       spin_lock(&amp;q-&gt;producer_lock)\n                                       /* vaciar a ptr_ring */\n                                       spin_unlock(&amp;q-&gt;producer_lock)\n                                       __list_del_clearprev(flush_node)\n                                         /* establece flush_node.prev = NULL */\n  &lt;-- La Tarea A se reanuda --&gt;\n  __list_del_clearprev(flush_node)\n    flush_node.prev-&gt;next = ...\n    /* prev es NULL -&gt; kernel oops */\n\nSolucione esto añadiendo un local_lock_t a xdp_bulk_queue y adquiriéndolo en bq_enqueue() y __cpu_map_flush(). Estas rutas ya se ejecutan bajo local_bh_disable(), por lo que se usa local_lock_nested_bh() que en sistemas no-RT es una anotación pura sin sobrecarga, y en PREEMPT_RT proporciona un bloqueo de suspensión por CPU que serializa el acceso a la bq.\n\nPara reproducir, inserte un mdelay(100) entre bq-&gt;count = 0 y __list_del_clearprev() en bq_flush_to_queue(), luego ejecute el reproductor proporcionado por syzkaller.","source":"nvd"}],"published":"2026-03-25T10:27:30.285Z","modified":"2026-06-17T10:21:22.597Z","severity":{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H","score":4.7,"rating":"MEDIUM"},"severities":[{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H","score":4.7,"rating":"MEDIUM"}],"cwes":["CWE-362"],"affected":[{"ranges":[{"type":"git","introduced":"3253cb49cbad4772389d6ef55be75db1f97da910","fixed":"7466ae2aeed483de80c5d8dea0913cf74038b652","status":"affected"},{"type":"git","introduced":"3253cb49cbad4772389d6ef55be75db1f97da910","fixed":"e67299e1044349ad0088d52c6bc5764cc1816c06","status":"affected"},{"type":"git","introduced":"3253cb49cbad4772389d6ef55be75db1f97da910","fixed":"869c63d5975d55e97f6b168e885452b3da20ea47","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"6.18","status":"affected"},{"type":"semver","introduced":"0","fixed":"6.18","status":"unaffected"},{"type":"semver","introduced":"6.18.17","lastAffected":"6.18.*","status":"unaffected"},{"type":"semver","introduced":"6.19.7","lastAffected":"6.19.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"7.0","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"status":"affected","introduced":"6.18.1","fixed":"6.18.17"},{"status":"affected","introduced":"6.19","fixed":"6.19.7"},{"status":"affected","version":"6.18"},{"status":"affected","version":"7.0"},{"status":"affected","version":"7.0"},{"status":"affected","version":"7.0"},{"status":"affected","version":"7.0"},{"status":"affected","version":"7.0"},{"status":"affected","version":"7.0"},{"status":"affected","version":"7.0"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/7466ae2aeed483de80c5d8dea0913cf74038b652","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/e67299e1044349ad0088d52c6bc5764cc1816c06","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/869c63d5975d55e97f6b168e885452b3da20ea47","tags":["patch"],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-23342","url":"https://www.cve.org/CVERecord?id=CVE-2026-23342","licence":"CVE Terms of Use","modified":"2026-05-11T22:04:59.186Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-23342","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-23342","licence":"Public domain","modified":"2026-06-17T10:21:22.597Z"}],"updatedAt":"2026-11-25T22:59:16.679Z","epss":{"score":0.001,"percentile":0.00912,"date":"2026-12-01T12:00:22.000Z"}}