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 EB188CCA47F for ; Tue, 5 Jul 2022 12:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229795AbiGEMNp (ORCPT ); Tue, 5 Jul 2022 08:13:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235796AbiGEMNI (ORCPT ); Tue, 5 Jul 2022 08:13:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C58321A395; Tue, 5 Jul 2022 05:10:44 -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 ams.source.kernel.org (Postfix) with ESMTPS id 34205B817CC; Tue, 5 Jul 2022 12:10:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88007C341C7; Tue, 5 Jul 2022 12:10:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657023041; bh=bQxN3bh++1R1mBIbbNcGTPNamM2kdxz0RwMIs1cqQhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ct9GPQxt6sD58WeG9rsP5rXQSZdTP9TV199heiSNA9qIqsCak18HQiyvWjBGiybgn tir522pA9pq/sB7GcYoYyL2rmVxc1apQFev2Oq1m5m1Ww4SIxakum7i/+58xYQircy zRfJhVwoLbCiZQUsYddsJAXiI34odcDycN8Re054= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bruce Fields , Zorro Lang , Chuck Lever Subject: [PATCH 5.15 17/98] SUNRPC: Fix READ_PLUS crasher Date: Tue, 5 Jul 2022 13:57:35 +0200 Message-Id: <20220705115618.074752079@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220705115617.568350164@linuxfoundation.org> References: <20220705115617.568350164@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Chuck Lever commit a23dd544debcda4ee4a549ec7de59e85c3c8345c upstream. 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 Signed-off-by: Greg Kroah-Hartman --- net/sunrpc/xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -979,7 +979,7 @@ static __be32 *xdr_get_next_encode_buffe */ xdr->p = (void *)p + frag2bytes; space_left = xdr->buf->buflen - xdr->buf->len; - if (space_left - nbytes >= PAGE_SIZE) + if (space_left - frag1bytes >= PAGE_SIZE) xdr->end = (void *)p + PAGE_SIZE; else xdr->end = (void *)p + space_left - frag1bytes;