CVE-2026-93231: lockd: fix swapped arguments in nlmsvc_match_ip()
In the Linux kernel, the following vulnerability has been resolved:
lockd: fix swapped arguments in nlmsvcmatchip()
When releasing locks by server IP address via /proc/fs/nfsd/unlockip, nlmsvcunlockallbyip() calls nlmtraversefiles() with the server sockaddr as the opaque @data argument:
nlmtraversefiles(serveraddr, nlmsvcmatchip, NULL);
The match callback is later invoked from nlmtraverselocks() as:
match(lockhost, host);
where the first argument is the nlmhost that owns the lock, and the second argument is the @data that was originally passed down (here the server sockaddr). This is the convention every other match callback relies on (nlmsvcmarkhost(), nlmsvcsamehost(), nlmsvcisclient()): arg1 is the real nlmhost, arg2 is the caller-supplied reference value.
nlmsvcmatchip() has had these two arguments reversed ever since the unlock-by-IP feature was introduced in commit 4373ea84c84d ("lockd: unlock lockd locks associated with a given server ip"):
return rpccmpaddr(nlmsrcaddr(host), datap);
Here @host is actually the server sockaddr, so nlmsrcaddr(host) dereferences a struct sockaddr as a struct nlmhost and reads garbage at the offset of hsrcaddr; meanwhile @datap is actually the lock owner's nlmhost but is compared as a sockaddr. As a result the comparison practically never matches and locks are not released for the requested IP.
Swap the arguments so the lock owner's source address is compared against the requested server address:
return rpccmpaddr(nlmsrcaddr(datap), (struct sockaddr )host);
[ cel: fix the misleading typedef parameter names too ]
Affected Software
Event History
Frequently Asked Questions
When is the affected code path reached?
It is reached when locks are released by server IP address through /proc/fs/nfsd/unlock_ip. That operation calls nlmsvc_unlock_all_by_ip() and traverses lock state using the supplied server socket address.
What causes the unsafe access?
The callback receives an nlm_host as its first argument and the caller-supplied server socket address as its second argument, but nlmsvc_match_ip() treats them in reverse. As a result, it passes the server socket address to nlm_srcaddr() as though it were an nlm_host, causing it to read garbage at the h_srcaddr offset.