From patchwork Fri Jan 26 08:57:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baokun Li X-Patchwork-Id: 1891207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=hr8i=je=vger.kernel.org=linux-ext4+bounces-926-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TLsmG60pdz23dy for ; Fri, 26 Jan 2024 20:27:26 +1100 (AEDT) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4TLsmG5XB2z4wcX for ; Fri, 26 Jan 2024 20:27:26 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4TLsmG5SwPz4wxx; Fri, 26 Jan 2024 20:27:26 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.48.161; helo=sy.mirrors.kernel.org; envelope-from=linux-ext4+bounces-926-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [147.75.48.161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4TLsmG5Msjz4wcX for ; Fri, 26 Jan 2024 20:27:26 +1100 (AEDT) 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 80D7EB2815D for ; Fri, 26 Jan 2024 09:27:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08D3F21365; Fri, 26 Jan 2024 08:54:54 +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 0F203208BA; Fri, 26 Jan 2024 08:54:51 +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=1706259293; cv=none; b=TLtGb+iWAGBJYoRAT9pK9xOFiOI00QytpSqWR0r4dai52kFajVAHnE4tHp5vPXCI9iGiWGWDhIeFN5/0Sh6+hZMZqjeakCkzgdTG0Mh6vQa02tNjuNg2FnDZMZFzcSFHfeOItEXx9KcmE+UOuvH4Xu5vTUQvg9i408kxrl+wEEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706259293; c=relaxed/simple; bh=DkiI7BUTL1eBPYg71PHFhBw8t/e1UJbhlPBGiuQ0t7A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=k+InNSjz/8T4jPioTRmT95a2bnXH4w+2btmAwNWFmZi13M23+RFJzZvohSlu3BwgjwShDG1tx1HkgC0aFc4arcXQwXU0tvwKozhgATC1oZ1sXnb6u09W6NBnzR2Tj5jNVgsxRHjlqxzCKDvXYg9dvccQqsHQTDYRBuMf4OSoQeM= 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.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TLs1N2Mf8zsWXw; Fri, 26 Jan 2024 16:53:44 +0800 (CST) Received: from dggpeml500021.china.huawei.com (unknown [7.185.36.21]) by mail.maildlp.com (Postfix) with ESMTPS id A7CD718001C; Fri, 26 Jan 2024 16:54:49 +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_128_GCM_SHA256) id 15.1.2507.35; Fri, 26 Jan 2024 16:54:49 +0800 From: Baokun Li To: CC: , , , , , , , , , Subject: [PATCH 7/7] ext4: set the type of max_zeroout to unsigned int to avoid overflow Date: Fri, 26 Jan 2024 16:57:16 +0800 Message-ID: <20240126085716.1363019-8-libaokun1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240126085716.1363019-1-libaokun1@huawei.com> References: <20240126085716.1363019-1-libaokun1@huawei.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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: Zhang Yi --- fs/ext4/extents.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 01299b55a567..8653b13e8248 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3425,10 +3425,8 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, struct ext4_extent zero_ex1, zero_ex2; 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; + unsigned int ee_len, depth, map_len = map->m_len, max_zeroout = 0; + int err = 0, allocated = 0, split_flag = EXT4_EXT_DATA_VALID2; ext_debug(inode, "logical block %llu, max_blocks %u\n", (unsigned long long)map->m_lblk, map_len);