{
  "affected": [
    {
      "ranges": [
        {
          "events": [
            {
              "introduced": "303cc571d107b3641d6487061b748e70ffe15ce4"
            },
            {
              "fixed": "85ecdfd12f4a6a2b91479ffe9dd7bd51f21a6f4f"
            },
            {
              "fixed": "43cbb8cdb829ef735824eff286a3ecd8e5c820e4"
            },
            {
              "fixed": "6097ae45077b4066e478f898653430c719ec8102"
            },
            {
              "fixed": "4de99588da937b13ed8fbb92369d19eee969700a"
            },
            {
              "fixed": "39b61af703ab5beb810edd5ac1f854e6fe3411ba"
            },
            {
              "fixed": "3ba6455f58f9bd307dc093e177fa302c19ba7da5"
            },
            {
              "fixed": "09a5a04a2d36c33881e323ddf7d84cf252bf6682"
            },
            {
              "fixed": "e08601d3a7b2236f4915497dca353dcf117bab5c"
            }
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "type": "GIT"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Linux",
        "name": "Kernel"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "5.8.0"
            },
            {
              "fixed": "5.10.275"
            }
          ],
          "type": "ECOSYSTEM"
        },
        {
          "events": [
            {
              "introduced": "5.11.0"
            },
            {
              "fixed": "5.15.226"
            }
          ],
          "type": "ECOSYSTEM"
        },
        {
          "events": [
            {
              "introduced": "5.16.0"
            },
            {
              "fixed": "6.1.193"
            }
          ],
          "type": "ECOSYSTEM"
        },
        {
          "events": [
            {
              "introduced": "6.2.0"
            },
            {
              "fixed": "6.6.163"
            }
          ],
          "type": "ECOSYSTEM"
        },
        {
          "events": [
            {
              "introduced": "6.7.0"
            },
            {
              "fixed": "6.12.119"
            }
          ],
          "type": "ECOSYSTEM"
        },
        {
          "events": [
            {
              "introduced": "6.13.0"
            },
            {
              "fixed": "6.18.65"
            }
          ],
          "type": "ECOSYSTEM"
        },
        {
          "events": [
            {
              "introduced": "6.19.0"
            },
            {
              "fixed": "7.3.6"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "database_specific": {
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/139xxx/CVE-2026-139215.json"
  },
  "details": "In the Linux kernel, the following vulnerability has been resolved:\n\nnsproxy: Fix cred leak in the error path of prepare_nsset()\n\nA task that calls setns() with CLONE_NEWUSER together with CLONE_NEWNS\nand at least one more namespace flag leaks a struct cred (and the\nuser_namespace, ucounts and group_info references it holds) whenever the\ncall fails at the fs_struct copy.  On a kernel with CONFIG_USER_NS the\nleak is one cred per failed setns(); under memory pressure, or driven by\na fault-injecting attacker, it accumulates and pins user namespaces that\ncan then never be freed.\n\nprepare_nsset() sets nsset-\u003eflags only on the success path:\n\n\tif (flags \u0026 CLONE_NEWUSER)\n\t\tnsset-\u003ecred = prepare_creds();\n\t...\n\t} else if (flags \u0026 CLONE_NEWNS) {\n\t\tnsset-\u003efs = copy_fs_struct(me-\u003efs);\n\t\tif (!nsset-\u003efs)\n\t\t\tgoto out;\t/* flags still 0 here */\n\t}\n\tnsset-\u003eflags = flags;\n\treturn 0;\nout:\n\tput_nsset(nsset);\n\nput_nsset() decides what to release from nsset-\u003eflags:\n\n\tif (flags \u0026 CLONE_NEWUSER)\n\t\tput_cred(nsset_cred(nsset));\n\nOn the copy_fs_struct() failure arm prepare_creds() has already\nallocated the cred, but nsset-\u003eflags is still the zero from the caller's\n\"struct nsset nsset = {}\", so put_nsset() does not see CLONE_NEWUSER and\nnever drops it.  The caller (__do_sys_setns) returns the error without\ntouching nsset, so the cred is lost.\n\nSet nsset-\u003eflags at the start of prepare_nsset(), before anything can\nfail, so every error exit through put_nsset() releases what was taken.\ncommit_nsset(), which clears nsset-\u003ecred on success, is unaffected.\n\nReproduced on x86_64 under QEMU with failslab aimed at the fs_struct\ncache and kmemleak enabled: 500 calls of\nsetns(pidfd, CLONE_NEWUSER | CLONE_NEWNS | CLONE_NEWUTS) each fail with\n-ENOMEM and leave 851 unreferenced cred objects allocated from\nprepare_creds() via setns() before the fix, and none after (the program\nis in the notes below).\n\nFound by formal verification of kernel/nsproxy.c.",
  "id": "CVE-2026-139215",
  "modified": "2026-12-01T20:45:40.244606941Z",
  "published": "2026-11-30T13:32:39.234Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/09a5a04a2d36c33881e323ddf7d84cf252bf6682"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/39b61af703ab5beb810edd5ac1f854e6fe3411ba"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/3ba6455f58f9bd307dc093e177fa302c19ba7da5"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/43cbb8cdb829ef735824eff286a3ecd8e5c820e4"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/4de99588da937b13ed8fbb92369d19eee969700a"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/6097ae45077b4066e478f898653430c719ec8102"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/85ecdfd12f4a6a2b91479ffe9dd7bd51f21a6f4f"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/e08601d3a7b2236f4915497dca353dcf117bab5c"
    },
    {
      "type": "ADVISORY",
      "url": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/139xxx/CVE-2026-139215.json"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-139215"
    },
    {
      "type": "PACKAGE",
      "url": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"
    }
  ],
  "schema_version": "1.9.2",
  "summary": "nsproxy: Fix cred leak in the error path of prepare_nsset()"
}