{"id":"CVE-2026-139345","state":"PUBLISHED","title":"bpf: Prevent task work context reuse while irq_work is busy","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Prevent task work context reuse while irq_work is busy\n\nA bpf_task_work context can return to STANDBY before its scheduling\nirq_work handler returns.  Both callback completion and task_work_add()\nfailure can publish STANDBY while the irq_work is still BUSY.  A new\nround can then reinitialize and queue the same irq_work on another CPU\nwhile the old handler is still running.\n\nOne concrete interleaving is:\n\n  1. CPU 0 successfully queues ctx->work with task_work_add() and pauses\n     before its SCHEDULING-to-SCHEDULED cmpxchg.\n\n  2. The target task on CPU 1 completes the callback, resets ctx->task\n     and publishes STANDBY.\n\n  3. CPU 2 starts a new round, changes STANDBY to PENDING and queues the\n     same irq_work.  The new handler changes PENDING to SCHEDULING, but\n     task_work_add() returns -ESRCH because its target task has exited.\n     The handler has not yet reset the context or rolled back the state.\n\n  4. CPU 0 resumes and changes the new round's SCHEDULING to SCHEDULED,\n     even though no task work was queued for that round.\n\n  5. The new handler resets ctx->task, but its SCHEDULING-to-STANDBY\n     cmpxchg fails.  The context remains SCHEDULED with a NULL task, and\n     subsequent attempts to acquire this context fail with -EBUSY.\n\n  6. Map-value deletion observes SCHEDULED and queues asynchronous\n     cancellation, which passes the NULL ctx->task to task_work_cancel().\n\nOverlapping invocations also share one BUSY bit.  An invocation can clear\nthat bit while the other invocation is still running.\n\nInitialize the scheduling irq_work when the context is created and stop\nreinitializing it for each round.  After claiming the context with the\nSTANDBY-to-PENDING cmpxchg, check BUSY and reject reuse with -EBUSY if a\nprevious invocation is still in progress.  Checking after the cmpxchg\norders the BUSY read after the STANDBY publication.\n\nNo irq_work has been queued for the attempted round at this point, so\nthe rejection can roll PENDING back to STANDBY.  Use cmpxchg for that\nrollback to preserve FREED if a concurrent deletion has published it.\nOnce BUSY clears, scheduling can be retried.","publishedAt":"2026-11-30T13:33:54.186Z","updatedAt":"2026-11-30T13:33:54.186Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"38aa7003e369802f81a078f6673d10d97013f04f","status":"affected","lessThan":"120ccbbc27889969eabba94c069784d5597d3dfb","versionType":"git"},{"version":"38aa7003e369802f81a078f6673d10d97013f04f","status":"affected","lessThan":"a00b81c2b3b81d1dd67a4c20b40af322cacf99e2","versionType":"git"},{"version":"38aa7003e369802f81a078f6673d10d97013f04f","status":"affected","lessThan":"a36d9afe8d923ca00dd2001409f420202ee672da","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/helpers.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.18","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.18","versionType":"semver"},{"version":"6.18.65","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"7.3.6","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/helpers.c"]}],"references":["https://git.kernel.org/stable/c/120ccbbc27889969eabba94c069784d5597d3dfb","https://git.kernel.org/stable/c/a00b81c2b3b81d1dd67a4c20b40af322cacf99e2","https://git.kernel.org/stable/c/a36d9afe8d923ca00dd2001409f420202ee672da"],"weaknesses":[],"ingestedAt":"2026-11-30T13:48:04.491Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/139xxx/CVE-2026-139345.json","commit":"8c2c22940a0de21d18737df980299c0488d5dc73","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-139345","state":"PUBLISHED","datePublished":"2026-11-30T13:33:54.186Z","dateUpdated":"2026-11-30T13:33:54.186Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-11-30T13:22:15.928Z"},"containers":{"cna":{"title":"bpf: Prevent task work context reuse while irq_work is busy","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Prevent task work context reuse while irq_work is busy\n\nA bpf_task_work context can return to STANDBY before its scheduling\nirq_work handler returns.  Both callback completion and task_work_add()\nfailure can publish STANDBY while the irq_work is still BUSY.  A new\nround can then reinitialize and queue the same irq_work on another CPU\nwhile the old handler is still running.\n\nOne concrete interleaving is:\n\n  1. CPU 0 successfully queues ctx->work with task_work_add() and pauses\n     before its SCHEDULING-to-SCHEDULED cmpxchg.\n\n  2. The target task on CPU 1 completes the callback, resets ctx->task\n     and publishes STANDBY.\n\n  3. CPU 2 starts a new round, changes STANDBY to PENDING and queues the\n     same irq_work.  The new handler changes PENDING to SCHEDULING, but\n     task_work_add() returns -ESRCH because its target task has exited.\n     The handler has not yet reset the context or rolled back the state.\n\n  4. CPU 0 resumes and changes the new round's SCHEDULING to SCHEDULED,\n     even though no task work was queued for that round.\n\n  5. The new handler resets ctx->task, but its SCHEDULING-to-STANDBY\n     cmpxchg fails.  The context remains SCHEDULED with a NULL task, and\n     subsequent attempts to acquire this context fail with -EBUSY.\n\n  6. Map-value deletion observes SCHEDULED and queues asynchronous\n     cancellation, which passes the NULL ctx->task to task_work_cancel().\n\nOverlapping invocations also share one BUSY bit.  An invocation can clear\nthat bit while the other invocation is still running.\n\nInitialize the scheduling irq_work when the context is created and stop\nreinitializing it for each round.  After claiming the context with the\nSTANDBY-to-PENDING cmpxchg, check BUSY and reject reuse with -EBUSY if a\nprevious invocation is still in progress.  Checking after the cmpxchg\norders the BUSY read after the STANDBY publication.\n\nNo irq_work has been queued for the attempted round at this point, so\nthe rejection can roll PENDING back to STANDBY.  Use cmpxchg for that\nrollback to preserve FREED if a concurrent deletion has published it.\nOnce BUSY clears, scheduling can be retried."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"38aa7003e369802f81a078f6673d10d97013f04f","status":"affected","lessThan":"120ccbbc27889969eabba94c069784d5597d3dfb","versionType":"git"},{"version":"38aa7003e369802f81a078f6673d10d97013f04f","status":"affected","lessThan":"a00b81c2b3b81d1dd67a4c20b40af322cacf99e2","versionType":"git"},{"version":"38aa7003e369802f81a078f6673d10d97013f04f","status":"affected","lessThan":"a36d9afe8d923ca00dd2001409f420202ee672da","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/helpers.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.18","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.18","versionType":"semver"},{"version":"6.18.65","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"7.3.6","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/helpers.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/120ccbbc27889969eabba94c069784d5597d3dfb"},{"url":"https://git.kernel.org/stable/c/a00b81c2b3b81d1dd67a4c20b40af322cacf99e2"},{"url":"https://git.kernel.org/stable/c/a36d9afe8d923ca00dd2001409f420202ee672da"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-11-30T13:33:54.186Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.18","versionEndExcluding":"6.18.65"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.18","versionEndExcluding":"7.3.6"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.18","versionEndExcluding":"7.4-rc1"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}