WSL2-Linux-Kernel/include/linux/lockd
Jeff Layton 2005f5b9c3 lockd: fix races in client GRANTED_MSG wait logic
After the wait for a grant is done (for whatever reason), nlmclnt_block
updates the status of the nlm_rqst with the status of the block. At the
point it does this, however, the block is still queued its status could
change at any time.

This is particularly a problem when the waiting task is signaled during
the wait. We can end up giving up on the lock just before the GRANTED_MSG
callback comes in, and accept it even though the lock request gets back
an error, leaving a dangling lock on the server.

Since the nlm_wait never lives beyond the end of nlmclnt_lock, put it on
the stack and add functions to allow us to enqueue and dequeue the
block. Enqueue it just before the lock/wait loop, and dequeue it
just after we exit the loop instead of waiting until the end of
the function. Also, scrape the status at the time that we dequeue it to
ensure that it's final.

Reported-by: Yongcheng Yang <yoyang@redhat.com>
Link: https://bugzilla.redhat.com/show_bug.cgi?id=2063818
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2023-04-26 09:05:00 -04:00
..
bind.h Keep read and write fds with each nlm_file 2021-08-23 18:05:31 -04:00
debug.h lockd: remove __KERNEL__ ifdefs 2019-11-12 11:43:29 -05:00
lockd.h lockd: fix races in client GRANTED_MSG wait logic 2023-04-26 09:05:00 -04:00
nlm.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
share.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xdr.h filelock: move file locking definitions to separate header file 2023-01-11 06:52:32 -05:00
xdr4.h lockd: set file_lock start and end when decoding nlm4 testargs 2023-03-14 14:00:55 -04:00