From nobody Mon Feb 9 18:43:33 2026 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE99A7F7EF; Tue, 19 Mar 2024 11:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710847943; cv=none; b=hTTpo3zsY4tsam5EiC/RjQ3YjaBmJ6GnyciHGLUjchCnOK4Owodpdmcu+CiKpMpCeWOA94M31qum72gPAdoOS6Fgfe09l7zE6og+Ju+nSkhUD/XiBDrV8f32zhfYU5uVG/+qcHivFizQRd3RJryCGCEWuiHISINI+G4J70Mr8x4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710847943; c=relaxed/simple; bh=HUFyIyn2aR8nI6S7apzAbeRc6aQE+WXtA2u1lyTifaI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Aa9nYF1MMR8EsILcKA1Mkq6tJ1ZxVUOGqjbSOxdwS18GS6JoigG6V29eSNLHeicsC4X1UVRbKEkP8dKi4xfMkdEMr4KxxyKyiKCtWPT/AtnMifWgpBq+Ywv5+Ehh2OZPx7an13V5Gkvmee0NncD8IuQGnVDCUmhXGFiYEHnhZgM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TzTyt2Mx3zwPld; Tue, 19 Mar 2024 19:29:42 +0800 (CST) Received: from dggpeml500021.china.huawei.com (unknown [7.185.36.21]) by mail.maildlp.com (Postfix) with ESMTPS id EC85D1404D7; Tue, 19 Mar 2024 19:32:13 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggpeml500021.china.huawei.com (7.185.36.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 19 Mar 2024 19:32:13 +0800 From: Baokun Li To: CC: , , , , , , , , , Subject: [PATCH v4 8/9] ext4: set the type of max_zeroout to unsigned int to avoid overflow Date: Tue, 19 Mar 2024 19:33:24 +0800 Message-ID: <20240319113325.3110393-9-libaokun1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240319113325.3110393-1-libaokun1@huawei.com> References: <20240319113325.3110393-1-libaokun1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500021.china.huawei.com (7.185.36.21) Content-Type: text/plain; charset="utf-8" The max_zeroout is of type int and the s_extent_max_zeroout_kb is of type uint, and the s_extent_max_zeroout_kb can be freely modified via the sysfs interface. When the block size is 1024, max_zeroout may overflow, so declare it as unsigned int to avoid overflow. Signed-off-by: Baokun Li Reviewed-by: Jan Kara --- fs/ext4/extents.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index e57054bdc5fd..e067f2dd0335 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3402,9 +3402,10 @@ static int ext4_ext_convert_to_initialized(handle_t = *handle, struct ext4_extent *ex, *abut_ex; ext4_lblk_t ee_block, eof_block; unsigned int ee_len, depth, map_len =3D map->m_len; - int allocated =3D 0, max_zeroout =3D 0; int err =3D 0; int split_flag =3D EXT4_EXT_DATA_VALID2; + int allocated =3D 0; + unsigned int max_zeroout =3D 0; =20 ext_debug(inode, "logical block %llu, max_blocks %u\n", (unsigned long long)map->m_lblk, map_len); --=20 2.31.1