From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 58D9F282F5; Mon, 6 Jan 2025 15:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736179128; cv=none; b=DDdQKgZe7IW5mxoP/FTr/i4ZL2UCtMYgst1d3xcWaryyt+9LpAsHm6L7jWsldlVoqGMX2MT+oMhntEn7GinQutaGc7Kf/EwLM2y+r/BHABSOsSpIg5jaJRSzHzbQWKkgu3kmbKkgGGIurxcyzuxr136P6CQ40Kvj3JiFc4VdfEE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736179128; c=relaxed/simple; bh=Xd1jWLXuuBhq3N1d+m91S8F3dTdckB2HQMV54yUw/B0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CN6My+C0fR2vAx4zOEWjNQdappI86Z3czouOvohLX2gsSWm5RWUWeyj3z4PMCmKxY5FqPtSykqhGBIx+3oC8/cUMWCa/abiOJJRqewhwXRblraQ9FUdAWfSIEupxqsIenvmV4og+PrNTlpPWweLTch0o8O0EzL23+vvf4u2aPQ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=crrvzxfr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="crrvzxfr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84976C4CED6; Mon, 6 Jan 2025 15:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1736179127; bh=Xd1jWLXuuBhq3N1d+m91S8F3dTdckB2HQMV54yUw/B0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=crrvzxfrEmH75sxPJrgcFySlvJeocVP0PbZIymBzwZY4Z+qjPm7MhXNp3VoxWHYC/ Gu5pNTjVzgphWr3dyl1+AA1loyI/2rZ8oDO3t9Z52PNTbb9WRT6WJUbQWzsNaAs02S czH9ZA8kp8UaPTfI0Emgo8FWOT7gRGTItx4NPYhg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, NeilBrown , Jeff Layton , Chuck Lever , Sasha Levin Subject: [PATCH 5.4 35/93] nfsd: restore callback functionality for NFSv4.0 Date: Mon, 6 Jan 2025 16:17:11 +0100 Message-ID: <20250106151130.028513493@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106151128.686130933@linuxfoundation.org> References: <20250106151128.686130933@linuxfoundation.org> User-Agent: quilt/0.68 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 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: NeilBrown [ Upstream commit 7917f01a286ce01e9c085e24468421f596ee1a0c ] A recent patch inadvertently broke callbacks for NFSv4.0. In the 4.0 case we do not expect a session to be found but still need to call setup_callback_client() which will not try to dereference it. This patch moves the check for failure to find a session into the 4.1+ branch of setup_callback_client() Fixes: 1e02c641c3a4 ("NFSD: Prevent NULL dereference in nfsd4_process_cb_update()") Signed-off-by: NeilBrown Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/nfsd/nfs4callback.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 55128de1a89d..d490f28aa7f6 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -878,7 +878,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c args.authflavor = clp->cl_cred.cr_flavor; clp->cl_cb_ident = conn->cb_ident; } else { - if (!conn->cb_xprt) + if (!conn->cb_xprt || !ses) return -EINVAL; clp->cl_cb_session = ses; args.bc_xprt = conn->cb_xprt; @@ -1229,8 +1229,6 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb) ses = c->cn_session; } spin_unlock(&clp->cl_lock); - if (!c) - return; err = setup_callback_client(clp, &conn, ses); if (err) { -- 2.39.5