Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp861211iog; Thu, 30 Jun 2022 11:34:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vDRrB3GkcfpkhF0cto3fvhhAOCQXG518fXmUKK1CDPMw39GmuTixKP5AkQ01hI/nRIlf60 X-Received: by 2002:a17:902:d48f:b0:16a:755f:86db with SMTP id c15-20020a170902d48f00b0016a755f86dbmr16809824plg.77.1656614054192; Thu, 30 Jun 2022 11:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656614054; cv=none; d=google.com; s=arc-20160816; b=EqHkIaYa3bnV2kXbONlHJqCy9QGsWOXdLq9wh23eEa3CuWYoz/d06/q3VRTP5xttIp f4XEuNolizdOr55ZxsHO1ycgi5krRt8dVnsk5lqWrDsh796QS9kD4IwoW2dumOsOPGTe lSwDgWRx69KrAMYNu3Eq0gK3GPpGwNQ9KDELo4ixNaTK5iK6gl1eQQ29/z2OyXzR0IHB IpuZZWFC5SZqvc3PKXV7UaRlwDvY/FHJJTsYK37kp0sXj6l65kZ4WApKpPXLPERIKhq7 3txQ83qFIhcuM8bXivXXogXZHDPIgsd6NZzYqWMVSrXXKdxpAEYaZcT/nDjtxBLCaatF +Plg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=r1ghyLwkC+AxO+JPrROs67uiqDnYE6VvdlYbeN5vpEI=; b=s3jKblJ5Xq1KC0Wi5VLuywmI9SGp0R8rzq8LnON2E3za5RlyyGVky9Jz8ULUeuCWDt AWoZodZfR9irKvn1XQsOyOscqj+lmG7l7GYiB1Rx6P49WfQWjrcb1/z/NPq3VlHDtftP Bc7S11/G/nKWTSPbJT21Zf/lO1vaUw1fCe7E/N5xXvNPDyFK9ojD4K1wYZXop2tfFx6F OzSpPjwbfjh9AFx3aVkyxl+D+0hLaAV2hshK2D4fTvW79mU6HnTAfAW7PFKfve2c1p4x DrK3ofcKeFq+8EF7zUFrB9aCzOb9nE3VALlf/8vLB3+PajGiojXBjhQB97DPceTNdqY5 0MfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eW2Y46Ah; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r31-20020a635d1f000000b0040d6a7dbdfbsi87078pgb.416.2022.06.30.11.33.48; Thu, 30 Jun 2022 11:34:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@gmail.com header.s=20210112 header.b=eW2Y46Ah; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236556AbiF3Sbk (ORCPT + 99 others); Thu, 30 Jun 2022 14:31:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236387AbiF3Sbk (ORCPT ); Thu, 30 Jun 2022 14:31:40 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0ACE42A1B for ; Thu, 30 Jun 2022 11:31:37 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id v14so28514975wra.5 for ; Thu, 30 Jun 2022 11:31:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=r1ghyLwkC+AxO+JPrROs67uiqDnYE6VvdlYbeN5vpEI=; b=eW2Y46AhOFdrfyRhwz4vALCDUMDP1p8IerRDYUyE9XWzQubLVpyqsSDTkT8lRAWm5z wM8eDZGIhOiqLPQaJEIDQFIETEkytUCn8eu43a1U++1y2IQurSezzurLI33oa0IrsiKD nUb4nHxWD/t/9BOkTwypA34xjDODKolpUJkd1bm1ahn16P0q/Uw/BmWptOOZE7xTTj4z pTzkvsaEPRGWAfK1JyPhmMeQu/6VkiErd9AWBgkg5HDyVBWwGKX4lLmaRwuff2Y4DVmE LYMKAOx9DYsOduYL7ugSfwoiwglrLlIcbe2S9ESYqn3sd6lY4pfq8SwtCIk/WbaDuZqF CwiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=r1ghyLwkC+AxO+JPrROs67uiqDnYE6VvdlYbeN5vpEI=; b=kfhEQqqUTlj4duTVCup1dDrMcF2zXgGyckI9Pu5e85tSGTfrOow2zWGnDGqndavN3j hIXhphNOORtHT/bPfafJQI2Bpk+BNduxpk660JN892BOj4AK1Lpf0vF3RfcjndjR5U53 UGQygRwTFy73vEp58rUdxiyWgRvfSmtvz4lFrVEk85R6w17fUW3MU4tLh8zF4h8ZZ540 Qb+CXqsLL5qwhRbu42osPWzO1+Mtr5o3Kv/3zPMOhxxB6LBCG2+M5vKhh7WPeUf1wWNv BHfdDas7UV0OcYNUmnA5O/gSeZ/5C9hcjRlijh8983rgdOe4dHLiMgAyKMb7SEqDidXC fbVw== X-Gm-Message-State: AJIora9NTGLR/zBEKvIFWkX52fDMCT9+okN0YVZfTVd5XbAz1Tu/Uz63 h0PuG1CtKfGu5AbRWObdNhHsgvUaNXMN22EiAFaR0SRM X-Received: by 2002:a5d:4c90:0:b0:21b:8b2a:1656 with SMTP id z16-20020a5d4c90000000b0021b8b2a1656mr9742163wrs.249.1656613896303; Thu, 30 Jun 2022 11:31:36 -0700 (PDT) MIME-Version: 1.0 References: <165660978413.2453.15153844664543877314.stgit@klimt.1015granger.net> In-Reply-To: From: Anna Schumaker Date: Thu, 30 Jun 2022 14:31:20 -0400 Message-ID: Subject: Re: [PATCH v1] SUNRPC: Fix READ_PLUS crasher To: Trond Myklebust Cc: "linux-nfs@vger.kernel.org" , "chuck.lever@oracle.com" , "bfields@fieldses.org" , "anna.schumaker@netapp.com" , "zlang@redhat.com" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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-nfs@vger.kernel.org On Thu, Jun 30, 2022 at 2:09 PM Anna Schumaker wrote: > > On Thu, Jun 30, 2022 at 2:03 PM Trond Myklebust wrote: > > > > On Thu, 2022-06-30 at 13:24 -0400, Chuck Lever wrote: > > > Looks like there are still cases when "space_left - frag1bytes" can > > > legitimately exceed PAGE_SIZE. Ensure that xdr->end always remains > > > within the current encode buffer. > > > > > > Reported-by: Bruce Fields > > > Reported-by: Zorro Lang > > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=216151 > > > Fixes: 6c254bf3b637 ("SUNRPC: Fix the calculation of xdr->end in > > > xdr_get_next_encode_buffer()") > > > Signed-off-by: Chuck Lever > > > --- > > > net/sunrpc/xdr.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > Hi- > > > > > > I had a few minutes yesterday afternoon to look into this one. The > > > following one-liner seems to address the issue and passes my smoke > > > tests with NFSv4.1/TCP and NFSv3/RDMA. Any thoughts? > > > > > > > > > diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c > > > index f87a2d8f23a7..916659be2774 100644 > > > --- a/net/sunrpc/xdr.c > > > +++ b/net/sunrpc/xdr.c > > > @@ -987,7 +987,7 @@ static noinline __be32 > > > *xdr_get_next_encode_buffer(struct xdr_stream *xdr, > > > if (space_left - nbytes >= PAGE_SIZE) > > > xdr->end = p + PAGE_SIZE; > > > else > > > - xdr->end = p + space_left - frag1bytes; > > > + xdr->end = p + min_t(int, space_left - frag1bytes, > > > PAGE_SIZE); > > > > Since we know that frag1bytes <= nbytes (that is determined in > > xdr_reserve_space()), isn't this effectively the same thing as changing > > the condition to > > > > if (space_left - frag1bytes >= PAGE_SIZE) > > xdr->end = p + PAGE_SIZE; > > else > > xdr->end = p + space_left - frag1bytes; > > I added some printk's without this patch, and I'm seeing space_left > larger than PAGE_SIZE and frag1bytes set to 0 in that branch right > before the crash. So the min_t() will choose the PAGE_SIZE option > sometimes. Actually, ignore me. I initially misread what Trond said. After a reread I saw he changed "space_left - nbytes" to "space_left - frag1bytes" in the if condition. Trond's way fixes the crash for me, too. Anna > > Anna > > > > > ? > > > > > > xdr->buf->page_len += frag2bytes; > > > xdr->buf->len += nbytes; > > > > > > > > > > -- > > Trond Myklebust > > Linux NFS client maintainer, Hammerspace > > trond.myklebust@hammerspace.com > > > >