{"id":"CVE-2026-139204","state":"PUBLISHED","title":"bpf: Track borrowed iterator results by default","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Track borrowed iterator results by default\n\nAn open-coded iterator can return a struct pointer borrowed from its\ncurrent element. The verifier has not tied such results to iterator\nstate since the task_vma iterator was introduced, so a saved result\ncan still be used after destroy. Commit bee9ef4a40a27 (\"bpf: switch\ntask_vma iterator from mmap_lock to per-VMA locks\") also made next\nrelease the protection of the prior element. A later snapshot\nconversion made vm_file explicitly borrowed from that element.\n\nAssociate non-RCU, non-acquired struct results with the iterator\nreference by default. Invalidate dependents before next forks its\nNULL and non-NULL paths, while retaining the iterator itself. Let\ndestroy propagate child-reference errors. Add KF_ITER_RET_INDEPENDENT\nfor results that outlive the current element, preserving existing\nRCU and acquired-reference rules.\n\nTrusted pointer field loads also need to preserve the source lifetime.\nLoading a trusted field does not acquire a reference to the pointed-to\nobject. Set the field pointer's parent_id to the source's reference ID\nif the source is referenced, or inherit its parent_id if it is borrowed.\nThis is a generic rule, including accesses unrelated to iterators. For\nexample, the following access is now rejected:\n\n  file = bpf_get_task_exe_file(task);\n  if (!file)\n          return 0;\n  inode = file->f_inode;\n  bpf_put_file(file);\n  ino = inode->i_ino;\n\nThe inode pointer borrows the file's lifetime. Releasing the acquired\nfile reference removes that lifetime guarantee, so the verifier must\ninvalidate the derived inode pointer as well. This does not imply that\nbpf_put_file() immediately frees the file or inode. Reading the inode\nwhile the file reference is held remains valid. Fields with independent\nRCU protection retain their existing lifetime rules.\n\nFor an iterator result, the same propagation keeps trusted fields such\nas vm_file and f_inode tied to the current element. Propagate the backing\nobject's lifetime through dynptr construction too, so its descendants\nremain in the invalidation graph. Share the invalidation traversal\nbetween next and release, so advancing the iterator preserves its own\nreference.","publishedAt":"2026-11-30T13:32:32.554Z","updatedAt":"2026-11-30T13:32:32.554Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"4ac4546821584736798aaa9e97da9f6eaf689ea3","status":"affected","lessThan":"7162658a12e0cb2723ad886035be6b32b0afdd7c","versionType":"git"},{"version":"4ac4546821584736798aaa9e97da9f6eaf689ea3","status":"affected","lessThan":"d09c2aa3109f5cb1d0be7d382231ab5d58583cad","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["Documentation/bpf/bpf_iterators.rst","include/linux/btf.h","kernel/bpf/btf.c","kernel/bpf/verifier.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.7","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.7","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":["Documentation/bpf/bpf_iterators.rst","include/linux/btf.h","kernel/bpf/btf.c","kernel/bpf/verifier.c"]}],"references":["https://git.kernel.org/stable/c/7162658a12e0cb2723ad886035be6b32b0afdd7c","https://git.kernel.org/stable/c/d09c2aa3109f5cb1d0be7d382231ab5d58583cad"],"weaknesses":[],"ingestedAt":"2026-11-30T13:44:05.999Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/139xxx/CVE-2026-139204.json","commit":"8c2c22940a0de21d18737df980299c0488d5dc73","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-139204","state":"PUBLISHED","datePublished":"2026-11-30T13:32:32.554Z","dateUpdated":"2026-11-30T13:32:32.554Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-11-30T13:22:15.920Z"},"containers":{"cna":{"title":"bpf: Track borrowed iterator results by default","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Track borrowed iterator results by default\n\nAn open-coded iterator can return a struct pointer borrowed from its\ncurrent element. The verifier has not tied such results to iterator\nstate since the task_vma iterator was introduced, so a saved result\ncan still be used after destroy. Commit bee9ef4a40a27 (\"bpf: switch\ntask_vma iterator from mmap_lock to per-VMA locks\") also made next\nrelease the protection of the prior element. A later snapshot\nconversion made vm_file explicitly borrowed from that element.\n\nAssociate non-RCU, non-acquired struct results with the iterator\nreference by default. Invalidate dependents before next forks its\nNULL and non-NULL paths, while retaining the iterator itself. Let\ndestroy propagate child-reference errors. Add KF_ITER_RET_INDEPENDENT\nfor results that outlive the current element, preserving existing\nRCU and acquired-reference rules.\n\nTrusted pointer field loads also need to preserve the source lifetime.\nLoading a trusted field does not acquire a reference to the pointed-to\nobject. Set the field pointer's parent_id to the source's reference ID\nif the source is referenced, or inherit its parent_id if it is borrowed.\nThis is a generic rule, including accesses unrelated to iterators. For\nexample, the following access is now rejected:\n\n  file = bpf_get_task_exe_file(task);\n  if (!file)\n          return 0;\n  inode = file->f_inode;\n  bpf_put_file(file);\n  ino = inode->i_ino;\n\nThe inode pointer borrows the file's lifetime. Releasing the acquired\nfile reference removes that lifetime guarantee, so the verifier must\ninvalidate the derived inode pointer as well. This does not imply that\nbpf_put_file() immediately frees the file or inode. Reading the inode\nwhile the file reference is held remains valid. Fields with independent\nRCU protection retain their existing lifetime rules.\n\nFor an iterator result, the same propagation keeps trusted fields such\nas vm_file and f_inode tied to the current element. Propagate the backing\nobject's lifetime through dynptr construction too, so its descendants\nremain in the invalidation graph. Share the invalidation traversal\nbetween next and release, so advancing the iterator preserves its own\nreference."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"4ac4546821584736798aaa9e97da9f6eaf689ea3","status":"affected","lessThan":"7162658a12e0cb2723ad886035be6b32b0afdd7c","versionType":"git"},{"version":"4ac4546821584736798aaa9e97da9f6eaf689ea3","status":"affected","lessThan":"d09c2aa3109f5cb1d0be7d382231ab5d58583cad","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["Documentation/bpf/bpf_iterators.rst","include/linux/btf.h","kernel/bpf/btf.c","kernel/bpf/verifier.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.7","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.7","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":["Documentation/bpf/bpf_iterators.rst","include/linux/btf.h","kernel/bpf/btf.c","kernel/bpf/verifier.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/7162658a12e0cb2723ad886035be6b32b0afdd7c"},{"url":"https://git.kernel.org/stable/c/d09c2aa3109f5cb1d0be7d382231ab5d58583cad"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-11-30T13:32:32.554Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.7","versionEndExcluding":"7.3.6"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.7","versionEndExcluding":"7.4-rc1"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}