Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2989048pxb; Mon, 18 Apr 2022 12:49:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJximnIOHYMw0+TUFfBT37vu74KnOKg8UvgvfY5wRudyejLw/ZfOphBlQw2+dC/9LG8o46fa X-Received: by 2002:a05:6402:c13:b0:41d:71e1:9b8c with SMTP id co19-20020a0564020c1300b0041d71e19b8cmr13656444edb.258.1650311348463; Mon, 18 Apr 2022 12:49:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650311348; cv=none; d=google.com; s=arc-20160816; b=DmzmQW90w/kbWEXfvHx8J97lX+HdokztY7GuzewEoz6FTiYSILG2vTrb2sFhUl4oEr LCuuvx5LabU5e9CgyDn54VAXTMkKQ1DXfDkSpV243WocyCh/tjzrALiAjSV3sM0nP3x1 wbXTZ0J/bh4SFpXxnhf2Uoz+kH5qNTAVwDGT18jfYxsykxFTdH4/7zaGuj2xW89oUbpt vkDfBBFJecyBdaD7GPm/5VWdUuHNXNpjan9laCD8SfkLreVVPmSk3cNSw0U8z0qRGcO4 BjIkED/j6VqD+E6YwnngU9zTlAPeRyo9vRHjNxuxvVfm53BQ2mfZClil+64DBHnCrfG4 3xLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pCaDV4OrkYu58x3F/sABIoMJKFjjiVAi+NdEGQDNs5U=; b=QWPVSgcgCHCwbm6pNrhH5L2lOtVs1rENVAPirgzuMALCEGGqDnvM0SkRXYIVbdjazn Id5SETN2PTStziis3A0JNS2ObI84BHLyXkOAw9vauAK8nMlxevFe3sp2a4sf9+Mf82Dw CUeqjZmbNlcUHTLADIYA6aCkUBw0snwoVKyHvMBH8I6W9RqYV84Wm+npbXpwQ+UTnNKY fOyzPrC9QZO+jHl/gIySWwSoNti55xlQVtvoli6eTiemtT6/KCbLpjSeZb9s+C9tWXNW 5prksCp5+Co64Xgh0aJ1RE1ncZ4PBkJRAFGR/IgBdpxLVSdUXG6Jl82dxdAehpDT3ebV kp1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AUILlO22; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wh10-20020a170906fd0a00b006e6d386bbaesi6382857ejb.995.2022.04.18.12.48.44; Mon, 18 Apr 2022 12:49:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AUILlO22; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239583AbiDRMhw (ORCPT + 99 others); Mon, 18 Apr 2022 08:37:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238921AbiDRMbk (ORCPT ); Mon, 18 Apr 2022 08:31:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6475C25585; Mon, 18 Apr 2022 05:24:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E8FD660EF4; Mon, 18 Apr 2022 12:24:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9F91C385A7; Mon, 18 Apr 2022 12:24:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284649; bh=DpGwT7U9k6J/dbvxtQEtc6aLI9JWfsI4SIqqDo2n0A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AUILlO22dKYt6gHSbbIY0J6lUAWvWN2cHYcjKnxMF24dwEtWyZfChJETSOK7CednE xqkmH1CUBshM8gUR9cfkQnMUqV1c6IS7BDSEJavdrtIzwODR+1yOhU2NDpdXdBRSFd Z28136OmiGX24uCwgNvPjiRm7S+pidNy0ODAETCI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Chuck Lever Subject: [PATCH 5.17 184/219] SUNRPC: Fix NFSDs request deferral on RDMA transports Date: Mon, 18 Apr 2022 14:12:33 +0200 Message-Id: <20220418121212.029241377@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chuck Lever commit 773f91b2cf3f52df0d7508fdbf60f37567cdaee4 upstream. Trond Myklebust reports an NFSD crash in svc_rdma_sendto(). Further investigation shows that the crash occurred while NFSD was handling a deferred request. This patch addresses two inter-related issues that prevent request deferral from working correctly for RPC/RDMA requests: 1. Prevent the crash by ensuring that the original svc_rqst::rq_xprt_ctxt value is available when the request is revisited. Otherwise svc_rdma_sendto() does not have a Receive context available with which to construct its reply. 2. Possibly since before commit 71641d99ce03 ("svcrdma: Properly compute .len and .buflen for received RPC Calls"), svc_rdma_recvfrom() did not include the transport header in the returned xdr_buf. There should have been no need for svc_defer() and friends to save and restore that header, as of that commit. This issue is addressed in a backport-friendly way by simply having svc_rdma_recvfrom() set rq_xprt_hlen to zero unconditionally, just as svc_tcp_recvfrom() does. This enables svc_deferred_recv() to correctly reconstruct an RPC message received via RPC/RDMA. Reported-by: Trond Myklebust Link: https://lore.kernel.org/linux-nfs/82662b7190f26fb304eb0ab1bb04279072439d4e.camel@hammerspace.com/ Signed-off-by: Chuck Lever Cc: Signed-off-by: Greg Kroah-Hartman --- include/linux/sunrpc/svc.h | 1 + net/sunrpc/svc_xprt.c | 3 +++ net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -412,6 +412,7 @@ struct svc_deferred_req { size_t addrlen; struct sockaddr_storage daddr; /* where reply must come from */ size_t daddrlen; + void *xprt_ctxt; struct cache_deferred_req handle; size_t xprt_hlen; int argslen; --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -1213,6 +1213,8 @@ static struct cache_deferred_req *svc_de dr->daddr = rqstp->rq_daddr; dr->argslen = rqstp->rq_arg.len >> 2; dr->xprt_hlen = rqstp->rq_xprt_hlen; + dr->xprt_ctxt = rqstp->rq_xprt_ctxt; + rqstp->rq_xprt_ctxt = NULL; /* back up head to the start of the buffer and copy */ skip = rqstp->rq_arg.len - rqstp->rq_arg.head[0].iov_len; @@ -1251,6 +1253,7 @@ static noinline int svc_deferred_recv(st rqstp->rq_xprt_hlen = dr->xprt_hlen; rqstp->rq_daddr = dr->daddr; rqstp->rq_respages = rqstp->rq_pages; + rqstp->rq_xprt_ctxt = dr->xprt_ctxt; svc_xprt_received(rqstp->rq_xprt); return (dr->argslen<<2) - dr->xprt_hlen; } --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c @@ -831,7 +831,7 @@ int svc_rdma_recvfrom(struct svc_rqst *r goto out_err; if (ret == 0) goto out_drop; - rqstp->rq_xprt_hlen = ret; + rqstp->rq_xprt_hlen = 0; if (svc_rdma_is_reverse_direction_reply(xprt, ctxt)) goto out_backchannel;