{"id":"CVE-2026-139785","state":"PUBLISHED","title":"mm/vma: avoid losing atomic VMA flags when setting sticky VMA flags","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nmm/vma: avoid losing atomic VMA flags when setting sticky VMA flags\n\nvma_merge_existing_range() merges an existing VMA (middle) when its\nattributes have changed to match those of one or both adjacent VMAs.\n\nSticky flags are propagated if they are set in any of the merged VMAs. They\nare initialised from vmg->vma_flags, which is assumed to contain middle's\nsticky flags when the function is invoked.\n\nHowever, the VMA write lock is not held for middle when they are first\npopulated, so concurrent updates to atomic VMA flags may occur, which will\nbe lost upon merge.\n\nThis can result in fork failing to propagate guard region markers and (if\nfile-backed) THP collapse discarding them.\n\nResolve this by propagating the sticky flags after middle is locked.\n\nMake life easier by factoring this into propagate_sticky_flags(), which\ntreats vmg->vma_flags as its base (in case any sticky flags are set there),\nupdating it as sticky flags are accumulated from merged VMAs.\n\nAlso update vma_expand() to use propagate_sticky_flags() so all merge paths\nutilise it.\n\npropagate_sticky_flags() also asserts that the VMA write lock is held for\nthe VMA whose sticky flags are being read, with a comment explaining why.\n\nAnother means by which atomic VMA flags can fail to be observed is when the\nmerge is finalised in commit_merge().\n\nrmap locks are dropped in vma_complete() before the sticky flags are\nwritten, meaning an rmap walker can observe the VMA without sticky flags\nset, which can also result in retract_page_tables() discarding guard\nmarkers.\n\nResolve this by assigning the sticky flags before dropping rmap locks,\nfactored into commit_sticky_flags() with a write assert on the VMA being\nwritten to.\n\nAlso remove the vma_set_flags_mask() invocation at the end of\nvma_merge_existing_range() as this was introduced by commit\n64212ba02e66 (\"mm: implement sticky VMA flags\") to propagate sticky flags,\nwhich is now redundant with the introduction of commit_sticky_flags().\n\nThe vma_set_flags_mask() invocation at the end of vma_expand() setting\nsticky flags only is also removed for the same reason.\n\nAlso update vma_merge_existing_range()'s comment to reflect the fact that\nvmg->vma_flags gets updated.\n\nFinally, update the userland VMA tests to reflect a previously missed\nconst-ification in vma_assert_write_locked() which would otherwise cause a\nwarning when building them.","publishedAt":"2026-11-30T13:37:58.850Z","updatedAt":"2026-11-30T13:37:58.850Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"b836839c1fd94f9fc7ccdce153844fa26116ccc0","status":"affected","lessThan":"671d6e9b404f06c864e08e78123a4d4f84837ac0","versionType":"git"},{"version":"49e14dabed7a294427588d4b315f57fbfcab9990","status":"affected","lessThan":"54b29a37539f6f6649a135ba55565360dd0ea569","versionType":"git"},{"version":"49e14dabed7a294427588d4b315f57fbfcab9990","status":"affected","lessThan":"c386d799f423685952138cab8d89f0331825bdee","versionType":"git"},{"version":"6.18.37","status":"affected","lessThan":"6.18.65","versionType":"semver"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["mm/vma.c","tools/testing/vma/include/dup.h","tools/testing/vma/include/stubs.h"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.19","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.19","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-rc2","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["mm/vma.c","tools/testing/vma/include/dup.h","tools/testing/vma/include/stubs.h"]}],"references":["https://git.kernel.org/stable/c/671d6e9b404f06c864e08e78123a4d4f84837ac0","https://git.kernel.org/stable/c/54b29a37539f6f6649a135ba55565360dd0ea569","https://git.kernel.org/stable/c/c386d799f423685952138cab8d89f0331825bdee"],"weaknesses":[],"ingestedAt":"2026-11-30T13:56:04.579Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/139xxx/CVE-2026-139785.json","commit":"8c2c22940a0de21d18737df980299c0488d5dc73","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-139785","state":"PUBLISHED","datePublished":"2026-11-30T13:37:58.850Z","dateUpdated":"2026-11-30T13:37:58.850Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-11-30T13:22:15.953Z"},"containers":{"cna":{"title":"mm/vma: avoid losing atomic VMA flags when setting sticky VMA flags","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nmm/vma: avoid losing atomic VMA flags when setting sticky VMA flags\n\nvma_merge_existing_range() merges an existing VMA (middle) when its\nattributes have changed to match those of one or both adjacent VMAs.\n\nSticky flags are propagated if they are set in any of the merged VMAs. They\nare initialised from vmg->vma_flags, which is assumed to contain middle's\nsticky flags when the function is invoked.\n\nHowever, the VMA write lock is not held for middle when they are first\npopulated, so concurrent updates to atomic VMA flags may occur, which will\nbe lost upon merge.\n\nThis can result in fork failing to propagate guard region markers and (if\nfile-backed) THP collapse discarding them.\n\nResolve this by propagating the sticky flags after middle is locked.\n\nMake life easier by factoring this into propagate_sticky_flags(), which\ntreats vmg->vma_flags as its base (in case any sticky flags are set there),\nupdating it as sticky flags are accumulated from merged VMAs.\n\nAlso update vma_expand() to use propagate_sticky_flags() so all merge paths\nutilise it.\n\npropagate_sticky_flags() also asserts that the VMA write lock is held for\nthe VMA whose sticky flags are being read, with a comment explaining why.\n\nAnother means by which atomic VMA flags can fail to be observed is when the\nmerge is finalised in commit_merge().\n\nrmap locks are dropped in vma_complete() before the sticky flags are\nwritten, meaning an rmap walker can observe the VMA without sticky flags\nset, which can also result in retract_page_tables() discarding guard\nmarkers.\n\nResolve this by assigning the sticky flags before dropping rmap locks,\nfactored into commit_sticky_flags() with a write assert on the VMA being\nwritten to.\n\nAlso remove the vma_set_flags_mask() invocation at the end of\nvma_merge_existing_range() as this was introduced by commit\n64212ba02e66 (\"mm: implement sticky VMA flags\") to propagate sticky flags,\nwhich is now redundant with the introduction of commit_sticky_flags().\n\nThe vma_set_flags_mask() invocation at the end of vma_expand() setting\nsticky flags only is also removed for the same reason.\n\nAlso update vma_merge_existing_range()'s comment to reflect the fact that\nvmg->vma_flags gets updated.\n\nFinally, update the userland VMA tests to reflect a previously missed\nconst-ification in vma_assert_write_locked() which would otherwise cause a\nwarning when building them."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"b836839c1fd94f9fc7ccdce153844fa26116ccc0","status":"affected","lessThan":"671d6e9b404f06c864e08e78123a4d4f84837ac0","versionType":"git"},{"version":"49e14dabed7a294427588d4b315f57fbfcab9990","status":"affected","lessThan":"54b29a37539f6f6649a135ba55565360dd0ea569","versionType":"git"},{"version":"49e14dabed7a294427588d4b315f57fbfcab9990","status":"affected","lessThan":"c386d799f423685952138cab8d89f0331825bdee","versionType":"git"},{"version":"6.18.37","status":"affected","lessThan":"6.18.65","versionType":"semver"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["mm/vma.c","tools/testing/vma/include/dup.h","tools/testing/vma/include/stubs.h"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.19","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.19","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-rc2","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["mm/vma.c","tools/testing/vma/include/dup.h","tools/testing/vma/include/stubs.h"]}],"references":[{"url":"https://git.kernel.org/stable/c/671d6e9b404f06c864e08e78123a4d4f84837ac0"},{"url":"https://git.kernel.org/stable/c/54b29a37539f6f6649a135ba55565360dd0ea569"},{"url":"https://git.kernel.org/stable/c/c386d799f423685952138cab8d89f0331825bdee"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-11-30T13:37:58.850Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.18.37","versionEndExcluding":"6.18.65"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.19","versionEndExcluding":"7.3.6"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.19","versionEndExcluding":"7.4-rc2"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}