Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1799640rbb; Tue, 27 Feb 2024 01:12:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW3cdCaz/ZK0CPRsgiOdTbSzccNqU+B1d7uqwqrGxpfgs5VyRd7k/staJ+S0VS7vO++rB2rGP4ipZLV0JDQvwHMPF3yDezRkQRpL7OlHg== X-Google-Smtp-Source: AGHT+IFZMksmpCgtBQNg6mXjsG5cKuWSo2g/LTWYPLaD9Mfl6zQBayqxU2teab00G9sQMjsWtes8 X-Received: by 2002:a05:6402:31f1:b0:565:7bca:eebf with SMTP id dy17-20020a05640231f100b005657bcaeebfmr5784160edb.14.1709025126439; Tue, 27 Feb 2024 01:12:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709025126; cv=pass; d=google.com; s=arc-20160816; b=Jvalhnbm+gNlLwrhctbn11m2P6AZkCLPmlBgDD6yuBm5EerkoaZzT44aw6DoPiaJRn I2pfvW6jTKGu9ORX/pBUoE81ZVLptNZ8S69EId1gsn8EqvoUBD9FXpoptzXlSki2fIFi KzVJKH7IXlfDxvXNksxoXbyjD5ZrHhKamlIYuDybBPwxTzz05YFv+YrOHjQAwE7b451X z2zA++REifcCNh9eD4B9nt+sHlOFJ8W8hVsVziOOgtx2V4ZBGPHZAY0HsVC7+iTX9orl JGu3d1AhsXJdP3tdHZmZ5O49r5Gr94sCSGfYxWBG6uaOO9p+irTexIdwwUVgcWSgNMcA Ninw== 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=4r9Qk7zFOKk56bNgaf2oxiQHRk1eZKuE9/PZz5S9u/U=; fh=uX8qfKIKXQdFbtpE5iR7BNLnGOQ1snhbhH7wJjxmhEA=; b=RxD0UDTelOTU43g+DP4w2helcmPDuQrm/OzbtppYupECfODhjb8oKHH0j9ikmicKWT TcOO65Bmhlul92NoGPBUb0eoae5E0xgdsaTPnvxBssWVtH0Cpwq5Ld35QZ/2EEBPgR6L ikn/aiUCys19HnqupmJmVyHmMBa3rMU9uPgEGXLVlm0xfTmLZv1Com21w9Bj2XkFn2ci IESejUcIL5Zhrld5iBWL4NgKWtITlGvrXJ845LXqgIBhDlljN5DFMbjOhXb9IyVHBMvT UxAcmkF7/hpeTk1sH1zDTPDIP/1AwwS2CUVpYgUTEy7O2uP5UbfCxo5vhujsgqtU8QiU yP0w==; 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-1400-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1400-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.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 01:12:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1400-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-1400-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1400-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 D87451F21714 for ; Tue, 27 Feb 2024 09:11:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D39EF1386A8; Tue, 27 Feb 2024 09:10:15 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (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 1688613698F; Tue, 27 Feb 2024 09:10:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709025015; cv=none; b=mo/AQio8l5Nx9MrRmJDVnWN0xEhDgdiSec+lje8o96AXXmQf89wsjZjDkD/4XMEqSiWvUBWsndkOqFfuBcThix4hSaAeylTMc/nms8/cG83I9LIGdM6lV4qk9PZ4jF4JK18Uy3jLcuHhGu9NN1k+JDt34YOgZejLdcnBIpXUTvA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709025015; c=relaxed/simple; bh=Z1PfTQCHqpaHAw0hjUIVt4fpmIlFDfWjpJ3N+/nqPNo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Dxx+9nmogRRgMnodvsDCxJEs72bt4IDjHkAE80uJCzPRMzR8anSeYzhTgK6KPnpAUo7ZXni0u+dJZDOLaL2zVLxXGuBWYVMauXwK1vG+zzd9rubPdoVMOKTLPHvw2aRGk2Efnfm00VsBqU+QyEkxhUai8vJYCtKZaGHh2Hryyck= 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.35 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.112]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4TkWq01k0Jz1Q95B; Tue, 27 Feb 2024 17:07:56 +0800 (CST) Received: from dggpeml500021.china.huawei.com (unknown [7.185.36.21]) by mail.maildlp.com (Postfix) with ESMTPS id A2DCE1400F4; Tue, 27 Feb 2024 17:10:10 +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 7/9] ext4: set type of ac_groups_linear_remaining to __u32 to avoid overflow Date: Tue, 27 Feb 2024 17:11:46 +0800 Message-ID: <20240227091148.178435-8-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) Now ac_groups_linear_remaining is of type __u16 and s_mb_max_linear_groups is of type unsigned int, so an overflow occurs when setting a value above 65535 through the mb_max_linear_groups sysfs interface. Therefore, the type of ac_groups_linear_remaining is set to __u32 to avoid overflow. Fixes: 196e402adf2e ("ext4: improve cr 0 / cr 1 group scanning") CC: stable@kernel.org Signed-off-by: Baokun Li Reviewed-by: Zhang Yi Reviewed-by: Jan Kara --- fs/ext4/mballoc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/mballoc.h b/fs/ext4/mballoc.h index 56938532b4ce..7bfc5fb5a128 100644 --- a/fs/ext4/mballoc.h +++ b/fs/ext4/mballoc.h @@ -193,8 +193,8 @@ struct ext4_allocation_context { ext4_grpblk_t ac_orig_goal_len; __u32 ac_flags; /* allocation hints */ + __u32 ac_groups_linear_remaining; __u16 ac_groups_scanned; - __u16 ac_groups_linear_remaining; __u16 ac_found; __u16 ac_cX_found[EXT4_MB_NUM_CRS]; __u16 ac_tail; -- 2.31.1