mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
lockd: Plug nlm_file refcount leak on cached nlm_do_fopen() failure
commit70a38f87beupstream. The cached-file path in nlm_lookup_file() reaches the found: label unconditionally, even when nlm_do_fopen() fails. At that label *result and file->f_count are updated before the error is returned. The wrappers nlm3svc_lookup_file() and nlm4svc_lookup_file() then bail out of their switch without copying *result back to their caller, so the proc handler's local nlm_file pointer remains NULL and the cleanup path skips nlm_release_file(). The f_count increment is never released, and nlm_traverse_files() can no longer reap the file because its refcount never returns to zero between requests. Short-circuit the cached path so neither *result nor f_count is touched when nlm_do_fopen() fails on a hashed nlm_file. Fixes:7f024fcd5c("Keep read and write fds with each nlm_file") Cc: stable@vger.kernel.org Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
ddfbd81627
commit
7ce4c23e78
@@ -123,6 +123,8 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
|
||||
mutex_lock(&file->f_mutex);
|
||||
nfserr = nlm_do_fopen(rqstp, file, mode);
|
||||
mutex_unlock(&file->f_mutex);
|
||||
if (nfserr)
|
||||
goto out_unlock;
|
||||
goto found;
|
||||
}
|
||||
nlm_debug_print_fh("creating file for", &lock->fh);
|
||||
|
||||
Reference in New Issue
Block a user