Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp747092pxb; Thu, 26 Aug 2021 13:42:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZRDqexv7GBw5W1zaMYhLve8SIYPjvaR2VLj9DXRyBMpLL9hVq3UiLRSEVxtic0zyhW2zo X-Received: by 2002:a02:85c2:: with SMTP id d60mr3667978jai.85.1630010562766; Thu, 26 Aug 2021 13:42:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630010562; cv=none; d=google.com; s=arc-20160816; b=tOpntB4oJ0ZTMmoT/y818ti/xPWKtxJwaGX/W1Pqv3shl1VaQE4SyeeEw2pBQfQjoS 4Ts1ng5SIFWbozPEuuIBjdCysXIqiMNQRZHj6U/fFwBFpru3d9Od+Cp2b934x6e5NOme Y/UUlePVkimFest01++S+sJGWu6ouTikjTAjqh97VRcEQf74sw/1bIMM6wrgeIpWJMgC r1PMOV7KMihaOb1OWJucA77i3QpeSygoiptEqxPBy71FPJHo5Ym3fvDUkteW/JV9UcMX q0RQIUEBIxyYmmdxdtuaeSS1gSGn8zCOEfTF1wS6YTRb97t3BeTZnagImhSP4qSdAf+P vt5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=q3Hk3rMUpa5k2bFG+qHeogZ2h3fa0xwj5jLDgwqR/l8=; b=T0L7G7n3C2AFpGQUe7sG2xSpYAInvGHjpePI040H1Oefw42hy+fe6hW5uFFZ+lsyh+ i61TSVW0rC+UP8Y1L34pdVjQObYfPTwa1KmYLMZUnb7KpMnruAcvmv2CY3ql3JNRLPrh 3zMj7AVCmZq9TEpieEGOf2udXN3IOSmgsjoHhU86zC7NLUKFDitWjQ8IzRf9n1xcSoGt 0v/JbXlHthTDFA5XW4djIL/CjZiE/OTYfigO0RDlvu0ub0KPIQjaQMsiDvtM5Xeg7Bav +aZDykFGcAGJeIrSAEH3gGMRe3O5O8/QGZ3xKtyFrnY+ZEf9SRl7HiOSUio8CMCs7hR+ 1vIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=i3K248OE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si3886024jak.117.2021.08.26.13.42.28; Thu, 26 Aug 2021 13:42:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=i3K248OE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234338AbhHZUnO (ORCPT + 99 others); Thu, 26 Aug 2021 16:43:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232115AbhHZUnK (ORCPT ); Thu, 26 Aug 2021 16:43:10 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7028DC061757 for ; Thu, 26 Aug 2021 13:42:22 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id E16AC61D7; Thu, 26 Aug 2021 16:42:21 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org E16AC61D7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1630010541; bh=q3Hk3rMUpa5k2bFG+qHeogZ2h3fa0xwj5jLDgwqR/l8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i3K248OEFV3DWa2QhJvuZs5gjypINwUcYCshSeTjiAr1Vjf0jwsehdlfPiWPhKUdP P5ZstmIMD5cwe4GJnPSUQbqqdVZMm1t+yxKPE+SslG2ZdAiTqsa5mZuyLd2DK/P0uL Xr2AiNjwcVS+aDpw7aeHEs4mGM2I8fLUOALL+HSM= Date: Thu, 26 Aug 2021 16:42:21 -0400 From: "J. Bruce Fields" To: Anna Schumaker Cc: Trond Myklebust , Linux NFS Mailing List Subject: Re: [PATCH] sunrpc: Avoid a KASAN slab-out-of-bounds bug in xdr_set_page_base() Message-ID: <20210826204221.GC10730@fieldses.org> References: <20210609210729.254578-1-Anna.Schumaker@Netapp.com> <20210614231440.GD16500@fieldses.org> <20210812203248.GA907@fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu, Aug 26, 2021 at 03:44:32PM -0400, Anna Schumaker wrote: > On Thu, Aug 12, 2021 at 4:32 PM J. Bruce Fields wrote: > > > > On Mon, Jun 14, 2021 at 07:14:40PM -0400, bfields wrote: > > > On Wed, Jun 09, 2021 at 05:07:29PM -0400, schumaker.anna@gmail.com wrote: > > > > From: Anna Schumaker > > > > > > > > This seems to happen fairly easily during READ_PLUS testing on NFS v4.2. > > > > > > Yep, I hit a KASAN warning here every time, and this fixes it, > > > thanks.--b. > > > > By the way, config NFS_V4_2_READ_PLUS still says: > > > > This is intended for developers only. The READ_PLUS operation > > has been shown to have issues under specific conditions and > > should not be used in production. > > > > But this warning was the only thing I was seeing. Is there another > > known issue remaining? > > I think it was an issue around using lseek to generate the reply. The > file contents could change between each call, leading to inconsistent > results (and a new failing xfstest that previously passed) OK, thanks, I see now that you mentioned in 21e31401fc45 "NFS: Disable READ_PLUS by default" that there were generic/091 and generic/263 failures. Looks like they're both testing concurrent direct and buffered IO. I don't know what we try to guarantee in that case. --b. > > Anna > > > > > --b. > > > > > > > > > I found that we could end up accessing xdr->buf->pages[pgnr] with a pgnr > > > > greater than the number of pages in the array. So let's just return > > > > early if we're setting base to a point at the end of the page data and > > > > let xdr_set_tail_base() handle setting up the buffer pointers instead. > > > > > > > > Signed-off-by: Anna Schumaker > > > > --- > > > > net/sunrpc/xdr.c | 7 +++---- > > > > 1 file changed, 3 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c > > > > index 3964ff74ee51..ca10ba2626f2 100644 > > > > --- a/net/sunrpc/xdr.c > > > > +++ b/net/sunrpc/xdr.c > > > > @@ -1230,10 +1230,9 @@ static unsigned int xdr_set_page_base(struct xdr_stream *xdr, > > > > void *kaddr; > > > > > > > > maxlen = xdr->buf->page_len; > > > > - if (base >= maxlen) { > > > > - base = maxlen; > > > > - maxlen = 0; > > > > - } else > > > > + if (base >= maxlen) > > > > + return 0; > > > > + else > > > > maxlen -= base; > > > > if (len > maxlen) > > > > len = maxlen; > > > > -- > > > > 2.32.0