{"id":"CVE-2026-139677","state":"PUBLISHED","title":"kernfs: don't hold kernfs_rwsem across dir_emit()","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nkernfs: don't hold kernfs_rwsem across dir_emit()\n\nkernfs_fop_readdir() holds kernfs_rwsem for reading across the whole\nlisting, dir_emit() included.  dir_emit() copies to userspace, so it can\nfault into reclaim while holding the lock that every create, remove and\nrename in the hierarchy needs.  sysfs and cgroupfs have one per machine.\n\nUnder memory pressure the monitoring daemons fault on their own\ngetdents(2) buffer with it held:\n\n        below: page allocation stall for 120 secs: order:0,\n        mode:0x140dca(GFP_HIGHUSER_MOVABLE|__GFP_ZERO|__GFP_COMP)\n        nodemask=(null),cpuset=hostcritical.slice,mems_allowed=0\n        Call Trace:\n         <TASK>\n         dump_stack_lvl+0x5d/0x80\n         __alloc_frozen_pages_noprof+0x5f4d/0x6300\n         ? memcg_list_lru_alloc+0x73/0x320\n         ? ima_file_check+0xd0/0x7d0\n         vma_alloc_folio_noprof+0x145/0x560\n         handle_mm_fault+0x17c9/0x2720\n         ? find_vma+0x27/0x30\n         do_user_addr_fault+0x39f/0x6e0\n         exc_page_fault+0x8f/0x110\n         asm_exc_page_fault+0x22/0x30\n        RIP: 0010:filldir64+0xd7/0x1a0\n        [Code:/RSP:/RAX:..R15: register block elided]\n         kernfs_fop_readdir+0x2de/0x420\n         iterate_dir+0x8c/0x1f0\n         __se_sys_getdents64+0x61/0xe0\n         ? copy_page_from_iter+0x860/0x860\n         do_syscall_64+0x6a/0x250\n         entry_SYSCALL_64_after_hwframe+0x4b/0x53\n         </TASK>\n\nCommit 9aab10a0249e (\"kernfs: Don't re-lock kernfs_root::kernfs_rwsem in\nkernfs_fop_readdir().\") took the lock drop out because dir_emit() was\nhanded kernfs_node::name, which a rename can free.  The previous patch\nemits a copy instead, so drop the lock around dir_emit().\n\nA listing is no longer atomic within one getdents(2) call, which for\nmost sysfs and cgroup directories is all of it.  POSIX leaves that\nunspecified for an entry added or removed since opendir(3).","publishedAt":"2026-11-30T13:36:57.653Z","updatedAt":"2026-11-30T13:36:57.653Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"9aab10a0249eab4ec77c6a5e4f66442610c12a09","status":"affected","lessThan":"a8c18ee33f5892e753e74001dcfb802a2f280831","versionType":"git"},{"version":"9aab10a0249eab4ec77c6a5e4f66442610c12a09","status":"affected","lessThan":"18972293f131ef82eaf45f44c5599c3998292dfd","versionType":"git"},{"version":"9aab10a0249eab4ec77c6a5e4f66442610c12a09","status":"affected","lessThan":"341c65579de5b632eb7913bb68b3e375eeeb3ddf","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/kernfs/dir.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.15","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.15","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":["fs/kernfs/dir.c"]}],"references":["https://git.kernel.org/stable/c/a8c18ee33f5892e753e74001dcfb802a2f280831","https://git.kernel.org/stable/c/18972293f131ef82eaf45f44c5599c3998292dfd","https://git.kernel.org/stable/c/341c65579de5b632eb7913bb68b3e375eeeb3ddf"],"weaknesses":[],"ingestedAt":"2026-11-30T13:54:04.526Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/139xxx/CVE-2026-139677.json","commit":"8c2c22940a0de21d18737df980299c0488d5dc73","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-139677","state":"PUBLISHED","datePublished":"2026-11-30T13:36:57.653Z","dateUpdated":"2026-11-30T13:36:57.653Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-11-30T13:22:15.947Z"},"containers":{"cna":{"title":"kernfs: don't hold kernfs_rwsem across dir_emit()","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nkernfs: don't hold kernfs_rwsem across dir_emit()\n\nkernfs_fop_readdir() holds kernfs_rwsem for reading across the whole\nlisting, dir_emit() included.  dir_emit() copies to userspace, so it can\nfault into reclaim while holding the lock that every create, remove and\nrename in the hierarchy needs.  sysfs and cgroupfs have one per machine.\n\nUnder memory pressure the monitoring daemons fault on their own\ngetdents(2) buffer with it held:\n\n        below: page allocation stall for 120 secs: order:0,\n        mode:0x140dca(GFP_HIGHUSER_MOVABLE|__GFP_ZERO|__GFP_COMP)\n        nodemask=(null),cpuset=hostcritical.slice,mems_allowed=0\n        Call Trace:\n         <TASK>\n         dump_stack_lvl+0x5d/0x80\n         __alloc_frozen_pages_noprof+0x5f4d/0x6300\n         ? memcg_list_lru_alloc+0x73/0x320\n         ? ima_file_check+0xd0/0x7d0\n         vma_alloc_folio_noprof+0x145/0x560\n         handle_mm_fault+0x17c9/0x2720\n         ? find_vma+0x27/0x30\n         do_user_addr_fault+0x39f/0x6e0\n         exc_page_fault+0x8f/0x110\n         asm_exc_page_fault+0x22/0x30\n        RIP: 0010:filldir64+0xd7/0x1a0\n        [Code:/RSP:/RAX:..R15: register block elided]\n         kernfs_fop_readdir+0x2de/0x420\n         iterate_dir+0x8c/0x1f0\n         __se_sys_getdents64+0x61/0xe0\n         ? copy_page_from_iter+0x860/0x860\n         do_syscall_64+0x6a/0x250\n         entry_SYSCALL_64_after_hwframe+0x4b/0x53\n         </TASK>\n\nCommit 9aab10a0249e (\"kernfs: Don't re-lock kernfs_root::kernfs_rwsem in\nkernfs_fop_readdir().\") took the lock drop out because dir_emit() was\nhanded kernfs_node::name, which a rename can free.  The previous patch\nemits a copy instead, so drop the lock around dir_emit().\n\nA listing is no longer atomic within one getdents(2) call, which for\nmost sysfs and cgroup directories is all of it.  POSIX leaves that\nunspecified for an entry added or removed since opendir(3)."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"9aab10a0249eab4ec77c6a5e4f66442610c12a09","status":"affected","lessThan":"a8c18ee33f5892e753e74001dcfb802a2f280831","versionType":"git"},{"version":"9aab10a0249eab4ec77c6a5e4f66442610c12a09","status":"affected","lessThan":"18972293f131ef82eaf45f44c5599c3998292dfd","versionType":"git"},{"version":"9aab10a0249eab4ec77c6a5e4f66442610c12a09","status":"affected","lessThan":"341c65579de5b632eb7913bb68b3e375eeeb3ddf","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/kernfs/dir.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.15","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.15","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":["fs/kernfs/dir.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/a8c18ee33f5892e753e74001dcfb802a2f280831"},{"url":"https://git.kernel.org/stable/c/18972293f131ef82eaf45f44c5599c3998292dfd"},{"url":"https://git.kernel.org/stable/c/341c65579de5b632eb7913bb68b3e375eeeb3ddf"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-11-30T13:36:57.653Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.15","versionEndExcluding":"6.18.65"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.15","versionEndExcluding":"7.3.6"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.15","versionEndExcluding":"7.4-rc1"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}