{"id":"CVE-2026-139322","state":"PUBLISHED","title":"bpf: Reject sleepable programs for task_vma iterator","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Reject sleepable programs for task_vma iterator\n\nA sleepable \"iter.s/task_vma\" program can be attached, but its ->show()\ncallback runs with the mmap_lock of the iterated mm held for read. As soon\nas the program runs, bpf_iter_run_prog() calls might_fault(), and any\nbpf_copy_from_user() or bpf_copy_from_user_task() it does may really fault\nor take mmap_lock again. With lockdep this is reported as recursive\nlocking of mmap_lock. Without lockdep, a fault on the reader's own mm, or\naccess_process_vm() on the iterated mm, has to take mmap_lock for read\nagain. If a writer queued up in the meantime that blocks behind the\nwriter, which in turn waits for the read lock the iterator already holds,\nand the read() hangs:\n\n    reader (iter.s/task_vma)        other thread of the same mm\n    task_vma_seq_get_next()\n      mmap_read_lock(mm)\n                                    mmap_write_lock(mm)  <- waits\n    bpf prog: copy_from_user()\n      page fault\n        mmap_read_lock(mm)          <- queued behind the writer\n\nThe reader waits killable, so the hang lasts until it gets a fatal signal.\n\nbpf_iter_link_attach() allows sleepable programs for the targets that set\nBPF_ITER_RESCHED, and task_vma sets it because cond_resched() between VMAs\nis fine with mmap_lock held. Rescheduling between objects and running a\nsleepable program inside ->show() are different properties, though, and\ntask_vma only has the first one. The open-coded task_vma iterator does not\nhave this problem since it hands out a snapshot of the VMA and holds no\nlock when it returns to the program.\n\nThe vma handed to the program is only stable under mmap_lock, so the lock\ncan't be dropped around ->show(). Add a feature flag BPF_ITER_NOSLEEP for\ntargets which can't run sleepable programs although they can reschedule,\nand set it for task_vma.\n\nThe check at attach time is not enough. BPF_LINK_UPDATE replaces the\nprogram of a link, and bpf_iter_link_replace() only compares the type, the\nattach type and the BTF id of the two programs, which are the same for a\nsleepable and a non-sleepable one. Do the check there as well. That also\ncloses this way around the existing rule: so far a sleepable program could\nbe put on a link of a target that doesn't set BPF_ITER_RESCHED, like the\nhash map element iterator, which runs it under rcu_read_lock().\n\nBPF_LINK_CREATE of a sleepable program for the task_vma target, and\nBPF_LINK_UPDATE to one, now fail with -EINVAL, also for programs that\ndon't touch user memory and have been working since sleepable iterator\nprograms exist. The programs can still be loaded. They have to be\nloaded as non-sleepable programs, or use the open-coded iterator.","publishedAt":"2026-11-30T13:33:41.483Z","updatedAt":"2026-11-30T13:33:41.483Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"b77fb25dcb342788d72ad7533163c34b8b823a1d","status":"affected","lessThan":"e85ae2a3a50f5f358490ba347fec6a3dc2cc63b0","versionType":"git"},{"version":"b77fb25dcb342788d72ad7533163c34b8b823a1d","status":"affected","lessThan":"40b788f482d3d9c959210548848228b8bd571aa4","versionType":"git"},{"version":"b77fb25dcb342788d72ad7533163c34b8b823a1d","status":"affected","lessThan":"a6bf637ff9d78d20aa4955cfd58c72369dc8f9bd","versionType":"git"},{"version":"b77fb25dcb342788d72ad7533163c34b8b823a1d","status":"affected","lessThan":"dfcd1765911223df60845e288ad392d5237f47a3","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["include/linux/bpf.h","kernel/bpf/bpf_iter.c","kernel/bpf/task_iter.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.18","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.18","versionType":"semver"},{"version":"6.12.119","status":"unaffected","lessThanOrEqual":"6.12.*","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":["include/linux/bpf.h","kernel/bpf/bpf_iter.c","kernel/bpf/task_iter.c"]}],"references":["https://git.kernel.org/stable/c/e85ae2a3a50f5f358490ba347fec6a3dc2cc63b0","https://git.kernel.org/stable/c/40b788f482d3d9c959210548848228b8bd571aa4","https://git.kernel.org/stable/c/a6bf637ff9d78d20aa4955cfd58c72369dc8f9bd","https://git.kernel.org/stable/c/dfcd1765911223df60845e288ad392d5237f47a3"],"weaknesses":[],"ingestedAt":"2026-11-30T13:46:04.484Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/139xxx/CVE-2026-139322.json","commit":"8c2c22940a0de21d18737df980299c0488d5dc73","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-139322","state":"PUBLISHED","datePublished":"2026-11-30T13:33:41.483Z","dateUpdated":"2026-11-30T13:33:41.483Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-11-30T13:22:15.927Z"},"containers":{"cna":{"title":"bpf: Reject sleepable programs for task_vma iterator","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Reject sleepable programs for task_vma iterator\n\nA sleepable \"iter.s/task_vma\" program can be attached, but its ->show()\ncallback runs with the mmap_lock of the iterated mm held for read. As soon\nas the program runs, bpf_iter_run_prog() calls might_fault(), and any\nbpf_copy_from_user() or bpf_copy_from_user_task() it does may really fault\nor take mmap_lock again. With lockdep this is reported as recursive\nlocking of mmap_lock. Without lockdep, a fault on the reader's own mm, or\naccess_process_vm() on the iterated mm, has to take mmap_lock for read\nagain. If a writer queued up in the meantime that blocks behind the\nwriter, which in turn waits for the read lock the iterator already holds,\nand the read() hangs:\n\n    reader (iter.s/task_vma)        other thread of the same mm\n    task_vma_seq_get_next()\n      mmap_read_lock(mm)\n                                    mmap_write_lock(mm)  <- waits\n    bpf prog: copy_from_user()\n      page fault\n        mmap_read_lock(mm)          <- queued behind the writer\n\nThe reader waits killable, so the hang lasts until it gets a fatal signal.\n\nbpf_iter_link_attach() allows sleepable programs for the targets that set\nBPF_ITER_RESCHED, and task_vma sets it because cond_resched() between VMAs\nis fine with mmap_lock held. Rescheduling between objects and running a\nsleepable program inside ->show() are different properties, though, and\ntask_vma only has the first one. The open-coded task_vma iterator does not\nhave this problem since it hands out a snapshot of the VMA and holds no\nlock when it returns to the program.\n\nThe vma handed to the program is only stable under mmap_lock, so the lock\ncan't be dropped around ->show(). Add a feature flag BPF_ITER_NOSLEEP for\ntargets which can't run sleepable programs although they can reschedule,\nand set it for task_vma.\n\nThe check at attach time is not enough. BPF_LINK_UPDATE replaces the\nprogram of a link, and bpf_iter_link_replace() only compares the type, the\nattach type and the BTF id of the two programs, which are the same for a\nsleepable and a non-sleepable one. Do the check there as well. That also\ncloses this way around the existing rule: so far a sleepable program could\nbe put on a link of a target that doesn't set BPF_ITER_RESCHED, like the\nhash map element iterator, which runs it under rcu_read_lock().\n\nBPF_LINK_CREATE of a sleepable program for the task_vma target, and\nBPF_LINK_UPDATE to one, now fail with -EINVAL, also for programs that\ndon't touch user memory and have been working since sleepable iterator\nprograms exist. The programs can still be loaded. They have to be\nloaded as non-sleepable programs, or use the open-coded iterator."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"b77fb25dcb342788d72ad7533163c34b8b823a1d","status":"affected","lessThan":"e85ae2a3a50f5f358490ba347fec6a3dc2cc63b0","versionType":"git"},{"version":"b77fb25dcb342788d72ad7533163c34b8b823a1d","status":"affected","lessThan":"40b788f482d3d9c959210548848228b8bd571aa4","versionType":"git"},{"version":"b77fb25dcb342788d72ad7533163c34b8b823a1d","status":"affected","lessThan":"a6bf637ff9d78d20aa4955cfd58c72369dc8f9bd","versionType":"git"},{"version":"b77fb25dcb342788d72ad7533163c34b8b823a1d","status":"affected","lessThan":"dfcd1765911223df60845e288ad392d5237f47a3","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["include/linux/bpf.h","kernel/bpf/bpf_iter.c","kernel/bpf/task_iter.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.18","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.18","versionType":"semver"},{"version":"6.12.119","status":"unaffected","lessThanOrEqual":"6.12.*","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":["include/linux/bpf.h","kernel/bpf/bpf_iter.c","kernel/bpf/task_iter.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/e85ae2a3a50f5f358490ba347fec6a3dc2cc63b0"},{"url":"https://git.kernel.org/stable/c/40b788f482d3d9c959210548848228b8bd571aa4"},{"url":"https://git.kernel.org/stable/c/a6bf637ff9d78d20aa4955cfd58c72369dc8f9bd"},{"url":"https://git.kernel.org/stable/c/dfcd1765911223df60845e288ad392d5237f47a3"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-11-30T13:33:41.483Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.18","versionEndExcluding":"6.12.119"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.18","versionEndExcluding":"6.18.65"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.18","versionEndExcluding":"7.3.6"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.18","versionEndExcluding":"7.4-rc1"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}