Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 394E4403E8A; Tue, 21 Jul 2026 17:20:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784654448; cv=none; b=nDxSqiT970gsATVxKUh0PUTkwwk6vszRb7K9JNoYdLmLFpGScBZgwKBv01PadAmhPzN79rYKzW2xJgTEvqxA5+093N71oIhVF4JhmIAZ0RkH4bkzCl60hBGak9YFZQJJTn+P239eYsJ1/jeG9NBlNd7Es8jPS9S3XeTJ3JL+dg0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784654448; c=relaxed/simple; bh=kn13JSFEFKuBqhAA2r1E5XbTn8m3M3fZpqMPucT0LHw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HmpDfDWqYi/fLb84BVzPHXZtSgZ4iN8HZSYkI7HqaJRKayfl9sOVFLrMDaclAanu3q1wqYny4ZawG1/1FiDHFE8OjYt/CJpsfWOmdsdGf6MwuCIcuEYpFsMffKdAWXSMN6nIeo9g1f9U9UUWTrkBoaHOjOm6f31XwB7JsGdDVsA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oZB51BDv; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="oZB51BDv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A04CE1F00A3A; Tue, 21 Jul 2026 17:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784654447; bh=uL9bOUrdfyXteMjyFffCltLe/UMbPnr2C+hUqgPh2vY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oZB51BDvwI9YS68MnzmbESdjl6ArqGhazkEPs8is//GrahIgIs9YtmGHVVI5Tjxk5 yJmHWvOHDuMTLiFt6uYIvJAw7pkd8LIa524ixMyRTrHUeBGlDxQ9fEcL1NsQ+3Bh6L SE0tURk+fylUfh50rHg2IlWnXxygAHVYBaM0wm0Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chuck Lever Subject: [PATCH 7.1 1665/2077] lockd: Plug nlm_file refcount leak on cached nlm_do_fopen() failure Date: Tue, 21 Jul 2026 17:22:18 +0200 Message-ID: <20260721152632.016451388@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152552.646164743@linuxfoundation.org> References: <20260721152552.646164743@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chuck Lever commit 70a38f87bed7f0694fd07988b47b2db1e10d8df3 upstream. 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: 7f024fcd5c97 ("Keep read and write fds with each nlm_file") Cc: stable@vger.kernel.org Signed-off-by: Chuck Lever Signed-off-by: Greg Kroah-Hartman --- fs/lockd/svcsubs.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -149,6 +149,8 @@ nlm_lookup_file(struct svc_rqst *rqstp, 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);