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 99CF5C7EE22 for ; Mon, 8 May 2023 11:28:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235770AbjEHL2t (ORCPT ); Mon, 8 May 2023 07:28:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235740AbjEHL21 (ORCPT ); Mon, 8 May 2023 07:28:27 -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 002603CD9A for ; Mon, 8 May 2023 04:28:09 -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 D318162E36 for ; Mon, 8 May 2023 11:28:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD0B4C433D2; Mon, 8 May 2023 11:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1683545289; bh=CPqYJM3/bse83eMz/FeEinnYs3/0/El4TpEx5F3NN0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n8IsqJIFKbJhTqf4w15BQV+M7fVoHQiNgorc5g4vS5dvwnE9DdjSbM0ELTNAvydw9 O7ndyAIMw3jrZ1XYKXWLvsg8zalHweN85kcgxXV9dXkfE4pW4hC0dEs9nlsaUVpfXa OgQp81aJixYLagXFPYiMfyAmTXVfe/kWGZiLbdC8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tobias Holl , Jens Axboe Subject: [PATCH 6.3 687/694] io_uring/rsrc: check for nonconsecutive pages Date: Mon, 8 May 2023 11:48:42 +0200 Message-Id: <20230508094458.678191803@linuxfoundation.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230508094432.603705160@linuxfoundation.org> References: <20230508094432.603705160@linuxfoundation.org> User-Agent: quilt/0.67 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: Tobias Holl commit 776617db78c6d208780e7c69d4d68d1fa82913de upstream. Pages that are from the same folio do not necessarily need to be consecutive. In that case, we cannot consolidate them into a single bvec entry. Before applying the huge page optimization from commit 57bebf807e2a ("io_uring/rsrc: optimise registered huge pages"), check that the memory is actually consecutive. Cc: stable@vger.kernel.org Fixes: 57bebf807e2a ("io_uring/rsrc: optimise registered huge pages") Signed-off-by: Tobias Holl [axboe: formatting] Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/rsrc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/io_uring/rsrc.c +++ b/io_uring/rsrc.c @@ -1230,7 +1230,12 @@ static int io_sqe_buffer_register(struct if (nr_pages > 1) { folio = page_folio(pages[0]); for (i = 1; i < nr_pages; i++) { - if (page_folio(pages[i]) != folio) { + /* + * Pages must be consecutive and on the same folio for + * this to work + */ + if (page_folio(pages[i]) != folio || + pages[i] != pages[i - 1] + 1) { folio = NULL; break; }