From mboxrd@z Thu Jan 1 00:00:00 1970 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 24C6C43A80C; Tue, 21 Jul 2026 21:40:37 +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=1784670038; cv=none; b=lQw3xFH87eB3Oj3tlHZOcNSZqGNGE8M8ZTe4hI0Tk6X9HPhsx9pRss7UY6239CMZK93bWY7auKAWt25OCozRjWJX01TQkKAAr6+VIiX0m0B0R01Ovx+XV76EnkUhhlKifGUWNrw/8meufpI9jL39/FRiuLORdnSK3jk1S0A1ctY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784670038; c=relaxed/simple; bh=+MaaoNet0uFT7LeMaVcRA0DMndDTRLpv1+Th2cLJsUA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e0v6zl85vPASjAadu2fKHSfGo9Oh4e2pNHj60dCMDe76gLLY1EV1F539KZ5zrpqc0JF6yQU432d1UgE/xP17ON6Y0F4ysy2Bm5gm/u2ixQtFko9NicVR7I+5XGlO6qtHrD5GHCdH6n+zCqeiXs1zDW7kX3Gq/3nrDrBujX2bGn8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uuKCJgdP; 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="uuKCJgdP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B47E1F000E9; Tue, 21 Jul 2026 21:40:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784670037; bh=JMWmk8OYOAEsP+CdfAy/D4XbASjLO2X9j2wySdJgnwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uuKCJgdPWvqJCaLiPMV9wyKYlOXQG+bD9Kqmb/lojS7oLO6e5xwaL5BLoT5kMVvh5 KfWD+4a3GNtbKqnY5vlNC/63HFgN3n90uh5QlGeNfJHvkjxVmoAD+1AHtdnlJtmX9T 998zTwW4NkBK7LUom/qI7orsfcFJzypRtHiBEBG0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chuck Lever Subject: [PATCH 6.1 0780/1067] lockd: Plug nlm_file refcount leak on cached nlm_do_fopen() failure Date: Tue, 21 Jul 2026 17:23:01 +0200 Message-ID: <20260721152442.019154160@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@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 6.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 @@ -123,6 +123,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);