Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp3299361rdb; Thu, 7 Sep 2023 10:17:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFaK4h2IT1kQxxoNG/6BzeTiJEFtzJ4C4gxMYpaYhXbeu2nLWSkWuM+ob5Q+3J6R1XU8y4I X-Received: by 2002:a19:a408:0:b0:4fe:5838:3dbf with SMTP id q8-20020a19a408000000b004fe58383dbfmr75027lfc.1.1694107040740; Thu, 07 Sep 2023 10:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694107040; cv=none; d=google.com; s=arc-20160816; b=iTYSMGvEoV6a/lAPYH6p9z2ZtC4w06AeTuG5ExvNzvV+USzOFaJhMNionUorABZQT0 ea2LmKFc9uJVOiJG1DliYny0EKPVd3Wj76z11VWZ4IvfeTCTn7pxy9eD3fTKLbbkTXI/ 7mF6zgfR1vKXQp1eIYeWpCQzDOD50MoVSB1KbApUkPAX5uWZFtBgXQ2GWhDiSFZt7OY6 Y4wcVObbYfbWyxRlgYlhiA2luleV1iheejxPRFknLJFCRD/6n/xvw56UfTKRS8o/dDWg qVk6PACCLgtcXAMHfPeMhkHa1ZbZiFcg+hTMMpYpx6xklZDgL4od7FTUlj0X7GFxhyJq L/Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=uRLSWIhkfLmZxNHOyNw7S0b8YtkCoYagvVAjBfg/Jog=; fh=ZnguuNyKQBpxg0mYEQ7OpQ6jjbsPXgi9wcxFIVU5evY=; b=IHIfrFPa/orWYvA+HgKz9ag1SgL+ellowr8piZ4O+oBEw2AnJfRcY7zggSYheRUl6p n6b5uJAuuVcbECQOYlBQeBMHBVz71D+yYt4D46FMsaMNF5cB1Rpu4vyLBb6HvMskdqzK kYUfYwH7BHabrodFz6EPbC8GsK0/dSALo8vWEvGmQ8Ks5q1bkkndG1QgSVmD8uTPpbVu 62uDuvLjF6mIC8VJzC4mImY3n6NZfoy+wteMfk6Q9Oj/nPRp6OOoxCHhLCQE5XFqi3Fd CLvUlnNhtC9pKG7nuu09t7SDSJeRxBzILQ2xXhMXmI/vbMKs4qGhKrpuhkqVf3e7KWls N/uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KaYk0o3b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q5-20020aa7cc05000000b005233ded4188si21522edt.432.2023.09.07.10.16.50; Thu, 07 Sep 2023 10:17:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KaYk0o3b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239711AbjIGQTE (ORCPT + 99 others); Thu, 7 Sep 2023 12:19:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242305AbjIGQSG (ORCPT ); Thu, 7 Sep 2023 12:18:06 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 991FDB189; Thu, 7 Sep 2023 08:46:39 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86183C4AF69; Thu, 7 Sep 2023 15:43:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694101432; bh=KktTyNPU1YnBoEEJ9R4u/lyHf76cmL8N7OemSGxaDss=; h=From:To:Cc:Subject:Date:From; b=KaYk0o3beak81s6CoJh0JCf41Y969HBJhHt5t9ENsHm6Ms5bKGvh7shRjUst5K9Tt 5trqH5sG24GrUHRO6vJQXRQ72yYR37E37ywpKKS69zb05OdkaiOdlmKe0eCuhaVLk3 6TvRDFzAFqZ19JDePFnmk71HnlO2Fy0vhUTFmXQdJQxvx6vWQZfWvgueSZsLVwzMdl Ga+wKzUF8C/Wdw4cFblot0qQx0vMmveJTq0ajMqi4ck7RX5A/UYRoj0YTIqThay5lH ey0dD7k2xLFAkqwgEGPrLzuWMAoGos7M3Qhwq24QNz/f5vDt+wbHCkn0HdFORkFBC9 kL+4JeW1YZCiQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Ritesh Harjani (IBM)" , Matthew Wilcox , "Darrick J . Wong" , Sasha Levin , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 6.4 1/5] iomap: Fix possible overflow condition in iomap_write_delalloc_scan Date: Thu, 7 Sep 2023 11:43:45 -0400 Message-Id: <20230907154349.3421707-1-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.4.15 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 063133ec77f49..5e5bffa384976 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -929,7 +929,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