Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp128343lqb; Thu, 14 Mar 2024 07:15:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUYNdxs/HHL/N9xLwjQj0uwxJSffVZiT1omjZt6/3/AV0UtlI8WVWlqj37OdzDTsb4Q01GeuO9U0srIWtnYKEXNfp4uOakM6+axrl2TwQ== X-Google-Smtp-Source: AGHT+IEvZcTnP8LREgzcOV85orGiaIIDt4tkwOLSyfTABpjJs3NvkoiXmO2jIcBGrNl4mD8zcIRO X-Received: by 2002:a17:90a:a613:b0:29a:bdee:bc69 with SMTP id c19-20020a17090aa61300b0029abdeebc69mr7926163pjq.8.1710425719069; Thu, 14 Mar 2024 07:15:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710425719; cv=pass; d=google.com; s=arc-20160816; b=p8GDf3tfuXONdSUJ6hgaxy1mMEHDkoOe+cHnSEaLuuyNRqNEte3uZu8cVt+U9BM2Lq 8WM7xPql2I7kf08SBkh5tD2LewrefY9BeO+9QLbV8XlCWJEAoxTNsfH1lOnZz6WnU8to 0fxjffS1VxXgxo6cHXBzIRiWoXH3/EVbVYhzAoLyTriNeaUpfWqc3QXUK8XHrH95BKMn wa/cg0EqjHZMRIe913LHm1zW2xwa3cV1R7Nxe0gK2KnzMEKcPDXEMtcx/Hnr1AGFgaQW YwB2ZMfqyEFc6NePOVJv6r2fin9/ELIKqEFzww6PvPsuKuCzfiGl4FeE0hFD9DLwwbDm KodQ== 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=iQabChTdN49Fv96ZoYJU+y0QEjsCRE6G1eb1MsI7+Oy0F7evD3Jh18/lgwu0v8jvWY e0eKDTYO91Uw+18d8CHc6Q58AzxOT719FvEfqCBgU23wD/971kW55lh4//feZ2oGAh5N EsafneegfeubODK4tlaojypZ+9s06Nu1LjltDAaIOwa+rlORJRv1BslYobVoRS02nqaH +qrNpySfFUaw7HcleM4rwcqe8tNjs7VgYoUtoyvKTgF9IubIOZGwm+ma4NxCvY1G15E0 /CrwD94e1b/Yyp4aKy/LbNNLpTAo94BYxOAm62VvyXLMR2zpTcCG7kHUg04wt6Urmus6 oL7Q==; 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-1647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1647-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a1-20020a17090acb8100b0029bd2ab76cdsi706639pju.118.2024.03.14.07.15.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 07:15:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-1647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1647-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A7741B22AD6 for ; Thu, 14 Mar 2024 14:10:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A27437351B; Thu, 14 Mar 2024 14:07:59 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (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 054226FE03; Thu, 14 Mar 2024 14:07:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710425279; cv=none; b=SFsGN1NnTnUf+KMwtIMVPYdPkqK9RG44/2Vxo0UdlJfEhHfNQEdOZQP8xs/2ciK122DlGWYIIAYU/367CY7KhCyOd4tys7q4zs7iX/swXECU/eL53AHB4Dh/S2wbThlFJ8gp9ZmpYoR4nVCYUZq+/BZzriG5hOaMU6O5dL6SoM0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710425279; c=relaxed/simple; bh=HUFyIyn2aR8nI6S7apzAbeRc6aQE+WXtA2u1lyTifaI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Mk8inwzKbc4GY6U8YaI9yf6c+HgkHrFeMxKLNPr0kmi8Cr893a01hwBwjQwLVWU+vLed+uQB7981HkYjmtVxkutKiCl1lR87pyyJEdXB85ySQG4bMnaTuw3B25/cB7apuLSAaGQcNEc+np3rUv2sH4j/EH+tshTQpq0chLyqlVw= 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.189 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.194]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4TwTgX6hNnzNm2C; Thu, 14 Mar 2024 22:06:00 +0800 (CST) Received: from dggpeml500021.china.huawei.com (unknown [7.185.36.21]) by mail.maildlp.com (Postfix) with ESMTPS id DE9C614011B; Thu, 14 Mar 2024 22:07:47 +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; Thu, 14 Mar 2024 22:07:47 +0800 From: Baokun Li To: CC: , , , , , , , , , Subject: [PATCH v3 8/9] ext4: set the type of max_zeroout to unsigned int to avoid overflow Date: Thu, 14 Mar 2024 22:09:05 +0800 Message-ID: <20240314140906.3064072-9-libaokun1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240314140906.3064072-1-libaokun1@huawei.com> References: <20240314140906.3064072-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 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