Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1799662rbb; Tue, 27 Feb 2024 01:12:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX9FUwBuOf6YMPBpumWoApaCSrW7ZXjUsGMz4cydtUmkPK0PdYtYR//M056RrIO8qtkmGKvD+oMS8sTsXluEeV6DGYQOD0YnQalbPAjVQ== X-Google-Smtp-Source: AGHT+IG/oJMdccBkla+g+dMGGZqVQnCyW4Pq6S70d7KdSw1MFAsxIcgQGmn5OuNScTCka5dS0ukn X-Received: by 2002:aa7:c0d1:0:b0:565:a266:45df with SMTP id j17-20020aa7c0d1000000b00565a26645dfmr5204757edp.42.1709025130203; Tue, 27 Feb 2024 01:12:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709025130; cv=pass; d=google.com; s=arc-20160816; b=x3PSbtasdTtkAayMGMeJbBG3J3peczz0gUdwAnqAXQeb4JtU+BmG0DvaB/yyfwzPf/ HM1V/Nn7EK7NYTG8VUJiF10f9RWnfL4TFMThComvgXDXibB1VXOG+F6EVCaSIfCjnCJm KkWWCxK4Cd1inIghj/+QLlhPSSrTevVZTBZ2hB867uIvWptaaVTmnsQCuNpyA+mwewhD FvjEfYt4lbSxA314iKKrqcSgnHk7dN/PpCLSILqxkYhfIZH8Xm0IJ4fZ61CF1oFd90yn gRft6ZrxIdS6cpswbxPBDBBDtn/B8iRcZkp/29EwJK0D7nry0O1LT8uCI7VM3jp24et7 ejiQ== 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=ho/mhILJLOTdKKeLx2RQyNy6xD90tWb9lADYPzQqsds=; fh=4vN4thPQ5z49h0k3wc47Ze2ZGwmxH293ZHjdupTAu0I=; b=SYhFDfJxl3AiXeCt6hJXKfGAXX8hmfamuW99iESORQV6O88el0ZcDf/33453ymeB4G Xp1+ARP8n9t9GFxLRIDYdEuCAI5ZsDiZJL3RxxqW+AvNX6lCQL70fEebb8rpvMYzm0vv oDtiCyZ4yB/nU0Ko/orauZA/lsMfx/xEEyhS6fyEdy10Up/8BF3J2Mo6ooNltkGlV39O on272UbW9mYO4PtlKpD3mP9kvP7u0wZ8crWVk6K+j/qm92ggf/IAq5XDv5aTEGnvbA97 Pk+8UdpNl73xePLoouf5v1EEWs+KfQmyGaHrSF+mOBx0kCSYvv4huau63V/PJqS2Ly6o bywA==; 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-1401-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1401-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e3-20020aa7d7c3000000b0056566dfc1ecsi549268eds.408.2024.02.27.01.12.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 01:12:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1401-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-1401-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1401-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5A58A1F22060 for ; Tue, 27 Feb 2024 09:12:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F0541386BD; Tue, 27 Feb 2024 09:10:16 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 84A151369BC; Tue, 27 Feb 2024 09:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709025015; cv=none; b=FiUGb2BzszdQa6JL/H+jXL88z2fobtdcikqxrYh0e/VE6RnBYFIdY7QpQEpUUqdYioi3B7fhZMxDNAzXs7WvP8AUKK0Xk0rx8WbGXCAJsJ0RmHDtnrlnpeyo0RQbkeakAiUATyOim5LCcUp2xtUejUMUj4ELw9ZQJYfDhl2NwZg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709025015; c=relaxed/simple; bh=auvj2vyhl+6K4+3J168wgzy9V0lHZKVX8umJ8KlD1/k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iu8ZxUno+BfjS1FAdLVRw9dvOcBzVwZUe2vS8V9N2hx2q+0CuY3cDw5U9cnh7qBqOyWUexBOoCvNbKfRLnNIpyJwSinVTKXkKfz6zEWbXs21OpUJab1Np8gfllsvLu9JxK+Kp8l/UeMNVHdmU+7aKcGlVGLDUS7xgLG17YjAJhg= 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.191 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.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TkWq12Rw4z1h0ld; Tue, 27 Feb 2024 17:07:57 +0800 (CST) Received: from dggpeml500021.china.huawei.com (unknown [7.185.36.21]) by mail.maildlp.com (Postfix) with ESMTPS id 3B7E61400DD; Tue, 27 Feb 2024 17:10:11 +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, 27 Feb 2024 17:10:10 +0800 From: Baokun Li To: CC: , , , , , , , , , Subject: [PATCH v2 8/9] ext4: set the type of max_zeroout to unsigned int to avoid overflow Date: Tue, 27 Feb 2024 17:11:47 +0800 Message-ID: <20240227091148.178435-9-libaokun1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240227091148.178435-1-libaokun1@huawei.com> References: <20240227091148.178435-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: dggems705-chm.china.huawei.com (10.3.19.182) 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 --- 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