In the Linux kernel, the following vulnerability has been resolved:
lockd: Fix use-after-free in nlmsvc_retry_blocked
nlmsvc_retry_blocked() examines the block at the head of nlm_blocked
under nlm_blocked_lock, then releases the lock before calling
nlmsvc_grant_blocked() or retry_deferred_block(). The nlm_blocked list
reference is all that keeps the block alive across that window.
nlmsvc_grant_blocked() does take one of its own, but not until after
the lock has been dropped. Unmounting the nfsd filesystem while a lock
request is still blocked reaches nlmsvc_traverse_blocks(), which drops
the list reference and frees the block along with the nlm_rqst hanging
off it.
BUG: KASAN: slab-use-after-free in nlm_async_call+0xd6/0x230
Read of size 8 at addr ffff88811b04c808 by task lockd/8377
nlm_async_call+0xd6/0x230
nlmsvc_retry_blocked+0x61c/0x800
lockd+0x144/0x1c0
Freed by task 8392:
nlmsvc_release_block+0x231/0x290
nlmsvc_traverse_blocks+0x139/0x1b0
nlm_traverse_files+0x1aa/0xa00
nlmsvc_free_host_resources+0x12/0x60
nlm_shutdown_hosts_net+0x127/0x280
lockd_down+0xd5/0x1c0
Take a reference before releasing nlm_blocked_lock and drop it once
the retry has run.
CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
CVSS Score: 9.8
AV:N - NLM on TCP or UDP carries the attack into lockd() → nlmsvc_retry_blocked. nlmsvc_proc_lock queues the nlm_block, NLMPROC_UNLOCK reaches nlmsvc_notify_blocked and makes b_when due, and nlmsvc_proc_free_all or nlmsvc_proc_cancel frees it in the window after nlmsvc_retry_blocked drops nlm_blocked_lock.
AC:L - One client sends the blocking NLMPROC_LOCK, the NLMPROC_UNLOCK that makes b_when due, and a concurrent NLMPROC_FREE_ALL or NLMPROC_CANCEL. Those calls run nlmsvc_free_host_resources or nlmsvc_cancel_blocked against the block nlmsvc_grant_blocked is about to use, and the client can repeat the exchange.
PR:N - lockd_authenticate() accepts RPC_AUTH_NULL and RPC_AUTH_UNIX, and nlm_fopen() sets NFSD_MAY_BYPASS_GSS so check_security_flavor() accepts those flavors. The LOCK uid is only asserted, and nlmsvc_proc_free_all calls nlmsvc_free_host_resources with that same unauthenticated RPC flavor.
UI:N - The attacker sends NLMPROC_LOCK, NLMPROC_UNLOCK, and NLMPROC_FREE_ALL or NLMPROC_CANCEL. lockd() then calls nlmsvc_retry_blocked from its own kernel thread.
S:U - The corrupted objects are this host's nlm_block and nlm_rqst in lockd, so the impact remains in the kernel that runs nfsd.
C:H - nlmsvc_grant_blocked() passes freed block->b_call to nlm_async_call(), which reads nlm_rqst.a_host, and encode_nlm_lock() then copies lock->caller and oh.data for oh.len bytes into NLMPROC_GRANTED_MSG. Reclaiming the nlm_rqst lets those pointers select kernel memory that is sent to the client.
I:H - nlmsvc_grant_blocked() kref_get()s the freed b_count, stores b_granted, and nlmsvc_unlink_block() calls locks_delete_block() on the file_lock in the freed nlm_rqst before nlmsvc_insert_block() relinks b_list. nlmsvc_grant_release() later kref_put()s a_block, so a reused slab turns those updates into attacker-controlled writes.
A:H - lockd() dereferences the freed nlm_rqst in nlm_async_call() from nlmsvc_retry_blocked(). That is the slab use-after-free reported by KASAN and it oopses the kernel.
| Attack Vector |
Network |
Scope |
Unchanged |
| Attack Complexity |
Low |
Confidentiality Impact |
High |
| Privileges Required |
None |
Integrity Impact |
High |
| User Interaction |
None |
Availability Impact |
High |
AV:N - NLM on TCP or UDP carries the attack into lockd() → nlmsvc_retry_blocked. nlmsvc_proc_lock queues the nlm_block, NLMPROC_UNLOCK reaches nlmsvc_notify_blocked and makes b_when due, and nlmsvc_proc_free_all or nlmsvc_proc_cancel frees it in the window after nlmsvc_retry_blocked drops nlm_blocked_lock.
AC:L - One client sends the blocking NLMPROC_LOCK, the NLMPROC_UNLOCK that makes b_when due, and a concurrent NLMPROC_FREE_ALL or NLMPROC_CANCEL. Those calls run nlmsvc_free_host_resources or nlmsvc_cancel_blocked against the block nlmsvc_grant_blocked is about to use, and the client can repeat the exchange.
PR:N - lockd_authenticate() accepts RPC_AUTH_NULL and RPC_AUTH_UNIX, and nlm_fopen() sets NFSD_MAY_BYPASS_GSS so check_security_flavor() accepts those flavors. The LOCK uid is only asserted, and nlmsvc_proc_free_all calls nlmsvc_free_host_resources with that same unauthenticated RPC flavor.
UI:N - The attacker sends NLMPROC_LOCK, NLMPROC_UNLOCK, and NLMPROC_FREE_ALL or NLMPROC_CANCEL. lockd() then calls nlmsvc_retry_blocked from its own kernel thread.
S:U - The corrupted objects are this host's nlm_block and nlm_rqst in lockd, so the impact remains in the kernel that runs nfsd.
C:H - nlmsvc_grant_blocked() passes freed block->b_call to nlm_async_call(), which reads nlm_rqst.a_host, and encode_nlm_lock() then copies lock->caller and oh.data for oh.len bytes into NLMPROC_GRANTED_MSG. Reclaiming the nlm_rqst lets those pointers select kernel memory that is sent to the client.
I:H - nlmsvc_grant_blocked() kref_get()s the freed b_count, stores b_granted, and nlmsvc_unlink_block() calls locks_delete_block() on the file_lock in the freed nlm_rqst before nlmsvc_insert_block() relinks b_list. nlmsvc_grant_release() later kref_put()s a_block, so a reused slab turns those updates into attacker-controlled writes.
A:H - lockd() dereferences the freed nlm_rqst in nlm_async_call() from nlmsvc_retry_blocked(). That is the slab use-after-free reported by KASAN and it oopses the kernel.
CVSS 3.1