CVE-2026-139215: nsproxy: Fix cred leak in the error path of prepare_nsset()

Published Nov 30, 2026
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

nsproxy: Fix cred leak in the error path of preparensset()

A task that calls setns() with CLONENEWUSER together with CLONENEWNS and at least one more namespace flag leaks a struct cred (and the usernamespace, ucounts and groupinfo references it holds) whenever the call fails at the fsstruct copy. On a kernel with CONFIGUSERNS the leak is one cred per failed setns(); under memory pressure, or driven by a fault-injecting attacker, it accumulates and pins user namespaces that can then never be freed.

preparensset() sets nsset->flags only on the success path:

if (flags & CLONENEWUSER) nsset->cred = preparecreds(); ... } else if (flags & CLONENEWNS) { nsset->fs = copyfsstruct(me->fs); if (!nsset->fs) goto out; / flags still 0 here / } nsset->flags = flags; return 0; out: putnsset(nsset);

putnsset() decides what to release from nsset->flags:

if (flags & CLONENEWUSER) putcred(nssetcred(nsset));

On the copyfsstruct() failure arm preparecreds() has already allocated the cred, but nsset->flags is still the zero from the caller's "struct nsset nsset = {}", so putnsset() does not see CLONENEWUSER and never drops it. The caller (dosyssetns) returns the error without touching nsset, so the cred is lost.

Set nsset->flags at the start of preparensset(), before anything can fail, so every error exit through putnsset() releases what was taken. commitnsset(), which clears nsset->cred on success, is unaffected.

Reproduced on x8664 under QEMU with failslab aimed at the fsstruct cache and kmemleak enabled: 500 calls of setns(pidfd, CLONENEWUSER | CLONENEWNS | CLONENEWUTS) each fail with -ENOMEM and leave 851 unreferenced cred objects allocated from preparecreds() via setns() before the fix, and none after (the program is in the notes below).

Found by formal verification of kernel/nsproxy.c.

Affected Software

1 affected component
Linux Linux kernel

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Compensating control

    In prepare_nsset(), set nsset->flags at the start, before any operation can fail, so put_nsset() releases resources acquired on error paths.

Event History

Nov 30, 2026
CVE Published
via MITRE·01:32 PM
Data Sourced
via MITRE·01:32 PM
Description
Data Sourced
via NVD·02:18 PM
Description

Frequently Asked Questions

1

Which systems are exposed to this leak?

The leak occurs on kernels built with CONFIG_USER_NS. It affects a task that can invoke setns() with CLONE_NEWUSER, CLONE_NEWNS, and at least one additional namespace flag.

2

What conditions are required to trigger the resource leak?

The setns() call must fail while copying the task's fs_struct via copy_fs_struct(), after credentials have already been prepared. Each such failed call leaks one struct cred and retains references to its user namespace, ucounts, and group information.

3

What is the operational impact of repeated triggering?

Repeated failures accumulate leaked credentials. The retained references can pin user namespaces so they cannot be freed, especially under memory pressure or when failures are induced through fault injection.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203