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 4DA36CE79CF for ; Wed, 20 Sep 2023 11:43:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232318AbjITLnp (ORCPT ); Wed, 20 Sep 2023 07:43:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbjITLnp (ORCPT ); Wed, 20 Sep 2023 07:43:45 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45D45A3 for ; Wed, 20 Sep 2023 04:43:39 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CCF6C433C7; Wed, 20 Sep 2023 11:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695210218; bh=NN9qIWFUN0+6XgC7i0dSs4/8cWP1AIRxCYispwf3vAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TxDsS216CYSJDnMbD/B6p63ZXULWHB4GY0HOrl/1CC4HJ614WjCFYe0wpEqVh0ova wqc8YVKM5X9MXrFDMm58PC+lPBkVYenBoEibYSYvPlOO2MB0yKqoJWzNGQ0/pcKIqE zaGW8U+4fK3Gf0br5uoVeK7CnhQrS0snhDqquT9w= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Matthew Wilcox , "Ritesh Harjani (IBM)" , "Darrick J. Wong" , Sasha Levin Subject: [PATCH 6.5 001/211] iomap: Fix possible overflow condition in iomap_write_delalloc_scan Date: Wed, 20 Sep 2023 13:27:25 +0200 Message-ID: <20230920112845.904129842@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112845.859868994@linuxfoundation.org> References: <20230920112845.859868994@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 6.5-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ritesh Harjani (IBM) [ Upstream commit eee2d2e6ea5550118170dbd5bb1316ceb38455fb ] folio_next_index() returns an unsigned long value which left shifted by PAGE_SHIFT could possibly cause an overflow on 32-bit system. Instead use folio_pos(folio) + folio_size(folio), which does this correctly. Suggested-by: Matthew Wilcox Signed-off-by: Ritesh Harjani (IBM) Reviewed-by: Darrick J. Wong Signed-off-by: Sasha Levin --- fs/iomap/buffered-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 7d2f70708f37d..794fda5bd9bc6 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -927,7 +927,7 @@ static int iomap_write_delalloc_scan(struct inode *inode, * the end of this data range, not the end of the folio. */ *punch_start_byte = min_t(loff_t, end_byte, - folio_next_index(folio) << PAGE_SHIFT); + folio_pos(folio) + folio_size(folio)); } /* move offset to start of next folio in range */ -- 2.40.1