From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F34C7C43334 for ; Fri, 1 Jul 2022 14:17:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230261AbiGAORz (ORCPT ); Fri, 1 Jul 2022 10:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229768AbiGAORy (ORCPT ); Fri, 1 Jul 2022 10:17:54 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93C1939170 for ; Fri, 1 Jul 2022 07:17:53 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id EB3DB608A; Fri, 1 Jul 2022 10:17:52 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org EB3DB608A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1656685072; bh=B9MZnGRTwYde4QoxzDBsp5SPVzYCVCm/rGuCLK4COtw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZkavusZuG0enUMdo/1koe/Ca094GzlxkGyq5I7yfyb5OX/+w15gql9qTZ+zHSVjE/ lwxsShmUJwsucGX0EniHASZabaTGIe0RfXScPVuKgDN5DCwabhsEZvnShEEkieyqF5 8S3yZRFqEQXxjic6DRvPr0O7ZltpZpgEFatdc+ag= Date: Fri, 1 Jul 2022 10:17:52 -0400 From: "J. Bruce Fields" To: Chuck Lever Cc: linux-nfs@vger.kernel.org, anna.schumaker@netapp.com, zlang@redhat.com Subject: Re: [PATCH v2] SUNRPC: Fix READ_PLUS crasher Message-ID: <20220701141752.GA13890@fieldses.org> References: <165662209842.1459.4593520026847863736.stgit@klimt.1015granger.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <165662209842.1459.4593520026847863736.stgit@klimt.1015granger.net> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This also gets through my tests without a crash.--b. On Thu, Jun 30, 2022 at 04:48:18PM -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(-) > > diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c > index f87a2d8f23a7..5d2b3e6979fb 100644 > --- a/net/sunrpc/xdr.c > +++ b/net/sunrpc/xdr.c > @@ -984,7 +984,7 @@ static noinline __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr, > p = page_address(*xdr->page_ptr); > xdr->p = p + frag2bytes; > space_left = xdr->buf->buflen - xdr->buf->len; > - if (space_left - nbytes >= PAGE_SIZE) > + if (space_left - frag1bytes >= PAGE_SIZE) > xdr->end = p + PAGE_SIZE; > else > xdr->end = p + space_left - frag1bytes; >