Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4169444rdh; Tue, 28 Nov 2023 13:58:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGOrY1V9XIh888agjCHmg0ehlQQkWuGcXVz5u4NgWnlOTtAz68OeL74mXZZbpCGMPXnsv2v X-Received: by 2002:a05:6a00:1ca6:b0:68a:5cf8:dae4 with SMTP id y38-20020a056a001ca600b0068a5cf8dae4mr22736179pfw.3.1701208719424; Tue, 28 Nov 2023 13:58:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701208719; cv=none; d=google.com; s=arc-20160816; b=WU8UVmOkAUsn94xz1VVBUkWct1LNeh6Nc//UbutbknBHMQJpbdpw3Q3qlF31QHz02y rMTZYLYjucMUgY1RarqYuvqlzSeyL7OyXUWS8t9ysf35fz8o0a/UEUjj3NOBeq/FTfLc BqhORxwN1pBptbGoSNG265TccYG/iQaH9WtrR+dU0WbUsu7IENVX7A/BSGA2eQu1AMxl 3Vh4NiRKiHsYqZhiA7mM4i4OY/Cx6lHnfSEZgyPMsE0s8O4edKUwQ9KG//M0bRlOMCtF 3KMmzLvrAjDqERkq9eAlaWZJBTsHF9NXVq1RZ2/11IqoGIk1wxgj6X2MdbzKdeLg0EKz doug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :message-id:date:cc:to:from:subject:dkim-signature; bh=NfapCPsnrnhytbk4kfrwW2+5vECtyd8WvaM9V93yU6E=; fh=xkJJ9G/tfqFUcIeP82drScMuFzbH6I4bp3/iFRpdd9E=; b=mbssdacGYnQPPE2BX/lRkao1VErsGBerLAZ6WJSwUtUhC3w+tQEHWmCGILEVprQ2qG iIJPCL7yyGBUJfUA11ZeiYcezcRwAO2OFYHp9F6E2vX4Z8r8Gag+N8EEKqjfwYP/63OO MNyPLsLBtiZT4D6y3r3YurBqzds5iuhyQBHbGasYxVZa84mz232PbLp0nDLy6POJZ/0/ YXT8Bwm98PTMcOqtDnnCiRgTCAkvJ2+ovFCQIOdZi3EsehYjOxib2h/vkUBNis5EaHRi Ym0tmI3vYOEknSt6QpPhiSIqXPNJO4K5c/8DLIy31ii27/1/xcMVQALdC2JHv7zKMk7z 5dtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZO+lp6Hz; spf=pass (google.com: domain of linux-nfs+bounces-137-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-137-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p126-20020a634284000000b005bdc61e1793si12759963pga.358.2023.11.28.13.58.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 13:58:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-137-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZO+lp6Hz; spf=pass (google.com: domain of linux-nfs+bounces-137-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-137-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1C3BE2825D7 for ; Tue, 28 Nov 2023 21:58:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1593F481A9; Tue, 28 Nov 2023 21:58:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZO+lp6Hz" X-Original-To: linux-nfs@vger.kernel.org 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 EAAE844390; Tue, 28 Nov 2023 21:58:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D08BC433C8; Tue, 28 Nov 2023 21:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701208715; bh=hy9i5dVyZ4mmSypRczPB/KL0szsFppsZJxEPHSzBYvw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ZO+lp6HzlC2tBNzWhPOHB3xAe7bEYMi6CExlAxrrbeZumh0zTF7E5nhZBcHiYdaVY xw/xp+erolnPO/7hYcpigB9sJZ0/2y5vy7ocS7YqlOlOXUi88J3ty1Hz+rKBePicJ6 u8hQe5U93ylXjtWhARuFxpRWbPiRcrlHaq6lh7cD2PmIYoMZtZKwPKpTt95pvNDU88 naEjO9suY/q/oEmyww9iOibXe9rOyXdFFXQDRFX2kSRk5LgQpBIbPiDeSROt6F4jBJ yLSf6JrrWgJoN7BnrHD/LisRL3zOc9tFqf3HHIeTvRuX2xU+eBTiahMxfjqYuRXkPL vZjhzeMnRlLBg== Subject: [PATCH 1/2] NFSD: Fix "start of NFS reply" pointer passed to nfsd_cache_update() From: Chuck Lever To: stable@vger.kernel.org Cc: linux-nfs@vger.kernel.org Date: Tue, 28 Nov 2023 16:58:34 -0500 Message-ID: <170120871426.1376.10151990384789497254.stgit@klimt.1015granger.net> In-Reply-To: <170120862772.1376.15036820033774301160.stgit@klimt.1015granger.net> References: <170120862772.1376.15036820033774301160.stgit@klimt.1015granger.net> User-Agent: StGit/1.5 Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit From: Chuck Lever [ Upstream commit 1caf5f61dd8430ae5a0b4538afe4953ce7517cbb ] The "statp + 1" pointer that is passed to nfsd_cache_update() is supposed to point to the start of the egress NFS Reply header. In fact, it does point there for AUTH_SYS and RPCSEC_GSS_KRB5 requests. But both krb5i and krb5p add fields between the RPC header's accept_stat field and the start of the NFS Reply header. In those cases, "statp + 1" points at the extra fields instead of the Reply. The result is that nfsd_cache_update() caches what looks to the client like garbage. A connection break can occur for a number of reasons, but the most common reason when using krb5i/p is a GSS sequence number window underrun. When an underrun is detected, the server is obliged to drop the RPC and the connection to force a retransmit with a fresh GSS sequence number. The client presents the same XID, it hits in the server's DRC, and the server returns the garbage cache entry. The "statp + 1" argument has been used since the oldest changeset in the kernel history repo, so it has been in nfsd_dispatch() literally since before history began. The problem arose only when the server-side GSS implementation was added twenty years ago. Reviewed-by: Jeff Layton Tested-by: Jeff Layton Signed-off-by: Chuck Lever --- fs/nfsd/nfssvc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index c7af1095f6b5..378ec82bd390 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -988,6 +988,7 @@ int nfsd_dispatch(struct svc_rqst *rqstp) const struct svc_procedure *proc = rqstp->rq_procinfo; __be32 *statp = rqstp->rq_accept_statp; struct nfsd_cacherep *rp; + __be32 *nfs_reply; /* * Give the xdr decoder a chance to change this if it wants @@ -1008,6 +1009,7 @@ int nfsd_dispatch(struct svc_rqst *rqstp) goto out_dropit; } + nfs_reply = xdr_inline_decode(&rqstp->rq_res_stream, 0); *statp = proc->pc_func(rqstp); if (test_bit(RQ_DROPME, &rqstp->rq_flags)) goto out_update_drop; @@ -1015,7 +1017,7 @@ int nfsd_dispatch(struct svc_rqst *rqstp) if (!proc->pc_encode(rqstp, &rqstp->rq_res_stream)) goto out_encode_err; - nfsd_cache_update(rqstp, rp, rqstp->rq_cachetype, statp + 1); + nfsd_cache_update(rqstp, rp, rqstp->rq_cachetype, nfs_reply); out_cached_reply: return 1;