Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp123454lqb; Thu, 14 Mar 2024 07:09:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVvj/92GVgPPdDVLCTRUqE7Swd2YbGasRIA3p8Ho7ryJZ0qB8m+H11yIK5PsE49WUkCvkGAs4kY5k4Bbg0n2hvoaUJ1pyUOK2vSXW0yuQ== X-Google-Smtp-Source: AGHT+IEI5VXJc3IfYQbk9H+ewmDWEUan+oGWRHL0qu8eIixK6RbjHxQ1irgkWnaW0bD3ljpKh4kp X-Received: by 2002:a05:6808:14c2:b0:3c3:23a8:8d8e with SMTP id f2-20020a05680814c200b003c323a88d8emr911318oiw.8.1710425349195; Thu, 14 Mar 2024 07:09:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710425349; cv=pass; d=google.com; s=arc-20160816; b=NSAnKBFT7j5EmYx8dUAvVqT7nddNfSRn6DQDZSkY5AadknkbD33xKrz1JnXlMicZcc 9LaybMotONLu5sLxfo75ZZPZNfS/3ZmpIZRwrq0D9YU7gta62+QmOLfmR+qqsbRd0nud wW+GTuON4HgG5sWYpQ5/SxbOYAVCCqIImncnZgGAlaVydUFn4dIHp+8Bk+CicfAmapTn fy/O2YnCzqiKfwj1RYP2jMU/G7j7mfNSrHtYmxySB6J1T0grVF2VU/K+yiBTJLUx1ER0 Vt2+vUjOeUfGEnha5oWr06lbdjqwfoskQmyfLiMTuM5qmQOOuQrWnkm/Dqpoi4HwFXDw vcYg== 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=HpZtsrm6Tpuy/PbWaS0VYyJiBAwMQ4RunOzOX66506XVs4t+8LSvLzLUM/fxKTMvgy NCuh0vJ/t2BgbW+qubUE4T/qybGC/rChZaJroBYJ/L55umRTmebM2DpZsvPNWsSC7XBw DIzpTCqlnXsAsjRA+W00aXs8ffJWrcRLOwaOFwCEjh9gBxIWvE/FuuouBX5C3ctzRtU5 FFZ1P8u4QKXwmcxPfNPi5snNIcqj80UBCIuNWVcBPle50mMd8hVFnmbmhmjU+zmlgaxP 7VYbAH6ID56GFf57zEjXonylS1iFaRUQWx9zwdQEVGvQy/M+64/JtLkiUNorB4XJm0Ef pCfw==; 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-1644-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1644-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id je8-20020a056130680800b007d952bdee65si143726uab.22.2024.03.14.07.09.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 07:09:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1644-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-1644-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1644-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E005D1C2143D for ; Thu, 14 Mar 2024 14:09:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 185F271B28; Thu, 14 Mar 2024 14:07:57 +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 009166FBB8; Thu, 14 Mar 2024 14:07:54 +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=1710425276; cv=none; b=U+HWEr4YhF4FDRP6QJHjGansOKUg+FY2wKEKnYRBrdfAAG/tc55Fa8KCFKNdRAaMviaDrGVuhZXsG1huh2Wudyc0Zyr+/3JsBEKgHRq7Z2ZPY9iBNwLxRZ4lp47QiwU3IsN5PoKRi2EwaWFcgBT2tybTqrDCzzJ8Hcamr5pcUqQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710425276; c=relaxed/simple; bh=Z1PfTQCHqpaHAw0hjUIVt4fpmIlFDfWjpJ3N+/nqPNo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RbUInEbsi4kLesiBbWW9djbP8yAX4HKUUD3AwDZ/mtEwBYxWSuCUi1ZOuaF3ZYbkK8Lr6i13nq8n4ZJk88gXU72sDFrp/Yxkv/MZpjQZrzR+/gREzwBxABNq1y/7aIEh5SPtVY2E0stSNeJ/8/+TpVVuvz9W6qk4GP+wa4fyg7g= 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.88.234]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4TwTfk52fLz1QBPq; Thu, 14 Mar 2024 22:05:18 +0800 (CST) Received: from dggpeml500021.china.huawei.com (unknown [7.185.36.21]) by mail.maildlp.com (Postfix) with ESMTPS id 5130C1400DB; 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:46 +0800 From: Baokun Li To: CC: , , , , , , , , , , Subject: [PATCH v3 7/9] ext4: set type of ac_groups_linear_remaining to __u32 to avoid overflow Date: Thu, 14 Mar 2024 22:09:04 +0800 Message-ID: <20240314140906.3064072-8-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) 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