]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
lockd: Plug nlm_file leak when nlm_do_fopen() fails
authorChuck Lever <chuck.lever@oracle.com>
Thu, 14 May 2026 20:56:04 +0000 (16:56 -0400)
committerChuck Lever <cel@kernel.org>
Tue, 9 Jun 2026 20:32:59 +0000 (16:32 -0400)
A client can repeatedly drive nlm_do_fopen() failures by presenting
file handles that the underlying export rejects. After kzalloc_obj()
succeeds in nlm_lookup_file(), the freshly allocated nlm_file is not
yet inserted into nlm_files[]. The nlm_do_fopen() failure path jumps
to out_unlock, which releases nlm_file_mutex and returns without
freeing the allocation, so each failure leaks one nlm_file.

Route the failure through out_free so kfree() runs before the
function returns.

Fixes: 7f024fcd5c97 ("Keep read and write fds with each nlm_file")
Cc: stable@vger.kernel.org
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/lockd/svcsubs.c

index e24bacea7e031c4f6aa3a15c0855bd88577c5f70..0b81d8db09191608ddbea36464ff803325316ece 100644 (file)
@@ -166,7 +166,7 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
 
        nfserr = nlm_do_fopen(rqstp, file, mode);
        if (nfserr)
-               goto out_unlock;
+               goto out_free;
 
        hlist_add_head(&file->f_list, &nlm_files[hash]);