CVE-2026-99950: ucount: take the rlimit reference before checking the limit
In the Linux kernel, the following vulnerability has been resolved:
ucount: take the rlimit reference before checking the limit
incrlimitgetucounts() takes the reference that pins a ucounts level while its rlimit count is non-zero only in the walk whose increment is the 0 -> 1 transition, and only after that walk passed the limit check. A walk that raises the count from zero and then fails the limit backs out without the reference, while a concurrent walk that raised it past one keeps its increment and never takes one either:
CPU0 (obeys the limit) CPU1 (overrides it) new = addreturn(1) -> 1 new = addreturn(1) -> 2 new != 1, no getucounts() new > max -> decunwind subreturn(1) -> 1 (no put)
The count is 1 with no reference held. When CPU1 drops its charge, decrlimitputucounts() takes the count to 0 and puts a reference nobody took, which frees the live struct ucounts, and the usernamespace it pins, with kfreercu(). The mirror interleaving leaks the reference instead.
An unprivileged user reaches this on a kernel with CONFIGUSERNS=y: in a user namespace with RLIMITSIGPENDING 0, one process taking synchronous SIGSEGVs (forced, so overriderlimit is set) races a second process in the same namespace and uid that queues real-time signals, which obey the limit. The two hold different sighand->siglock but charge the same per-namespace SIGPENDING ucounts. Unpatched, with rcuref debugging:
rcuref - imbalanced put() WARNING: lib/rcuref.c:266 at rcurefputslowpath+0xf4/0x120 putucounts+0x5a/0x180 dodecrlimitputucounts+0x70/0x90 sigqueuefree+0x33/0xc0 getsignal+0x56f/0xd20 archdosignalorrestart+0x87/0x380 irqentryexit+0x243/0x650 asmexcpagefault+0x26/0x30
Take the reference on the 0 -> 1 transition before the limit is checked, so the walk that raises the count from zero owns that level's reference even when its request is rejected, and unwind a rejected level through dodecrlimitputucounts(), which releases the reference when the count returns to 0. The getucounts() failure path is unchanged. With the patch the same interleaving, forced some 80000 times in a KASAN build, produces no warning and no KASAN report.