Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp802217lqt; Tue, 19 Mar 2024 04:33:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVyBe/OAOvKAiGakRflrRc+8hdoA+Sy18R+ffJBGEWokMvdeS72Cv/TajlhRttk9LqNyA65U8fsdtS0Us++wJvkwlF2odSnLwg+z0EelA== X-Google-Smtp-Source: AGHT+IHvjogWqhV6nZsjqNelHLfwIlBIeR7SMz94GZgLhgTThKRs5bs5N4N1mZmW872hr4iMyxRg X-Received: by 2002:a17:90a:1507:b0:29c:5ba6:c518 with SMTP id l7-20020a17090a150700b0029c5ba6c518mr12555229pja.6.1710848031694; Tue, 19 Mar 2024 04:33:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710848031; cv=pass; d=google.com; s=arc-20160816; b=zM6dvlbPVG3eDO4FdC1Kl1xS2iraM5srDn/4akhkpDfA7C/gKqiTWwtkprpqRQLxp2 ynqhGQQrGOdZ4AegffO/XKEHVx3izfhPZXcfaf6FrtXAcbjChw0GIy8AoUxwaG3p7NMm VMozQnwRBVxE1SoWo14BJzpNALB8nWANNQfBC8co/xCQ3EmiG0f3f5yoxVBN/DjsTuw/ V5RLHJpFPEzBTyg/HIf4CL19l/+Pk1wUlDjjhLMrNKonCQtm5a/FEwCr9R6R+F1sSYLF jji7N77sbDcI/32xwutGv7dFGkzvnvPX8NqUOGTNAFdqAoiJ01KjUxF2gZ0I2/HxxnVx 18TA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=7x1NGMS/pRWyq0E45QRN7mE8xPU83TueKFu8zLkXWu8=; fh=4vN4thPQ5z49h0k3wc47Ze2ZGwmxH293ZHjdupTAu0I=; b=DP45Hh3AebmmQTdG7vZG1oJbHg1GpHv6jBgG4e88WjNzEY7H4TauLSJaf5LbZ9VrXG 2B5QAHM8Sim6cbYlCA0F5oWjiOCy93HN5813YxXDZx5rzT59CMf2lkgU1MObvbb5m7mW rhU9FB5hYTd7Ea4tsbfZxccavU3l3WgsvPneBoPvRRu8l+beyfTpR7RJBCq1EbqXLMYb QY5EDL9FpnbC3xHAGSg05zXLHbNxy3bDV1hyb4TkdQaLIdBYVy7XxuZCzoa/bsXrYJT5 3GfGlpRWKshk6QFS6zS+1Gt7qE16KXG61D/PGYNQh6bHF+mm671wvMKg5n1C754ahqDN +ZsQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-ext4+bounces-1695-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1695-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id gp11-20020a17090adf0b00b0029bafb3a527si9978832pjb.151.2024.03.19.04.33.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 04:33:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1695-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-ext4+bounces-1695-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1695-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A9BD6280A8D for ; Tue, 19 Mar 2024 11:33:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5BA37EF1C; Tue, 19 Mar 2024 11:32:23 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org 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-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500021.china.huawei.com (7.185.36.21) 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 = map->m_len; - int allocated = 0, max_zeroout = 0; int err = 0; int split_flag = EXT4_EXT_DATA_VALID2; + int allocated = 0; + unsigned int max_zeroout = 0; ext_debug(inode, "logical block %llu, max_blocks %u\n", (unsigned long long)map->m_lblk, map_len); -- 2.31.1