CVE-2026-99528: SUNRPC: fix netns use-after-free in write_gssp()
In the Linux kernel, the following vulnerability has been resolved:
SUNRPC: fix netns use-after-free in writegssp()
While fuzzing with a customized syzkaller, I hit a refcount warning in xprtalloc(), reached from a write to /proc/net/rpc/use-gss-proxy:
refcountt: addition on 0; use-after-free. WARNING: lib/refcount.c:25 at refcountwarnsaturate+0xf8/0x120 CPU: 0 PID: 10404 Comm: syz.0.17 Not tainted 7.3.0-rc1-00096-gcfebfd3db73d Call Trace: <TASK> xprtalloc+0x83f/0x9d0 xssetupxprt+0xaf/0x3c0 xssetuplocal+0x47/0x7f0 xprtcreatetransport+0x16c/0x730 rpccreate+0x38e/0x7f0 gssprpccreate+0xe2/0x180 setgsspclnt+0xba/0x1b0 writegssp+0x200/0x310 procregwrite+0x240/0x330 vfswrite+0x2aa/0x1050 ksyswrite+0x12a/0x250 dosyscall64+0x117/0x750 entrySYSCALL64afterhwframe+0x77/0x7f </TASK>
createusegssproxyprocentry() stores the struct net pointer as the proc entry's private data without taking a reference on it, and an open file descriptor does not pin the namespace either, as procfs only pins the procdirentry. writegssp() reads that pointer back with pdedata() and hands it to setgsspclnt(), which reaches xprtinit():
xprt->xprtnet = getnettrack(net, &xprt->nstracker, GFPKERNEL);
getnettrack() -> getnet() -> refcountinc() is unconditional, so rpccreate() assumes its caller holds a reference on args.net. writegssp() does not.
Dropping the last ns.count reference does not make the file go away. putnet() only queues cleanupnet() on a workqueue, and the removeprocentry() that fences off further writes runs from the rpcsecgss pernet .exit method, that is, from inside cleanupnet(). A write landing between those two points increments a refcount that is already zero. cleanupnet() does not re-read ns.count, so the namespace is freed anyway and the rpcxprt -- along with the AFLOCAL socket opened for it -- is left pointing at freed memory. The resurrected count is visible to the rest of that teardown too: with CONFIGIPV6MROUTE the same cleanupnet() worker then trips !mrcanfreetable() in ip6mrfreetable(), which tests checknet() on the namespace it is freeing.
It reduces to opening /proc/net/rpc/use-gss-proxy inside a new network namespace, calling setns() back to the original one to drop the last reference, and then writing "1" to the still-open descriptor.
Take the reference in writegssp() itself and refuse the write when the namespace is already gone. This is what procfs does for every other /proc/net file: getprocnet() is maybegetnet(PDENET(PDE(inode))) and seqopennet() returns -ENXIO when it fails. PDENET() cannot be reused here because the parent directory /proc/net/rpc carries no namespace pointer. Adding a .preexit to rpcsecgssnetops so the entry is removed earlier would only narrow the window, since preexit also runs from cleanupnet().
Live namespaces are unaffected: a write still returns the error from setgsspclnt(), a write of "2" still returns -EINVAL, and reads are untouched.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.117 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.61 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.2 - Compensating control
In write_gssp(), take a reference on the network namespace and refuse the write if the namespace is already gone.