From patchwork Thu Apr 10 11:45:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 14046425 Received: from mr85p00im-zteg06021601.me.com (mr85p00im-zteg06021601.me.com [17.58.23.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 51694283C98 for ; Thu, 10 Apr 2025 11:46:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744285564; cv=none; b=hVZo33VRQiIecn5JHT2g0RASClsLlpiGTOJ+M7Y31Yfvqq5QkVoW36ZC6cTr38gWd7kgFJgZv8M7kAjKJt3VJ1I1xEFb4OXQG3S0fQ4+A55Ul7VDxw91F2CU8eAU+oLsLKD1sxLLqV8Nr7JGszQSzJ9OiyZ7lcZrnxdVi0B5YXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744285564; c=relaxed/simple; bh=f9qpikZGNzYBNk8FJCaVHkFKoG83Vw5bqouTnUPhpKc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W2TO53aSmBJGGKwixRD4QaHo6icPFix39cml49CyfA0F2qdw0+OFGE+G/r6Lio5M/Nx3LLChGuqjyuj9aabFnm8FvpOq7eLCz8Jkw1iLQ7efEgnzANGeeo2Ps5pWNIvkL+BOX4/9ZGFzg/+X0X5xoff0CihQKWoK2pi+8cpEYho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=uulJVwZC; arc=none smtp.client-ip=17.58.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="uulJVwZC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; bh=pepr9oDPPVIjbW97KHWR9Cogp5XUAGS7567ILCBA7M0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:x-icloud-hme; b=uulJVwZCqpgffvADKvG2GT8cOe1rIicAcETQQi/YJinv0zP9vzTo7Wo1swc7i3tmR fzRUCIDx25wW2HbvbG6o/Z9o21br5NTZVXiY1upXsTBKklb7nAMWepqimYLC0MSXUs 2oDuvqqHO51pkHw+YLB3cGIsaViAEMa4D8tCN9DOfiguBI2lPhFQCMfWyjiUBoZ4Ww W7LvRJhaVUMHvHDvY0G6Mesi2LxuRSp4eATgL3wVlm4namiOsIeYw2XqIsMpL0Q8f6 2Ju7XchIR1+UBXcb5s8069EcDQaAjbw/EvTVpHrNGmh0r/0Rgis32i7rCuixWEC51n kHV31ZLakoD1A== Received: from mr85p00im-zteg06021601.me.com (mr85p00im-zteg06021601.me.com [17.58.23.187]) by mr85p00im-zteg06021601.me.com (Postfix) with ESMTPS id 3C21430585BC; Thu, 10 Apr 2025 11:46:01 +0000 (UTC) Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021601.me.com (Postfix) with ESMTPSA id DF33B30585B7; Thu, 10 Apr 2025 11:45:58 +0000 (UTC) From: Zijun Hu Date: Thu, 10 Apr 2025 19:45:27 +0800 Subject: [PATCH 1/5] fs/filesystems: Fix potential unsigned integer underflow in fs_name() Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250410-fix_fs-v1-1-7c14ccc8ebaa@quicinc.com> References: <20250410-fix_fs-v1-0-7c14ccc8ebaa@quicinc.com> In-Reply-To: <20250410-fix_fs-v1-0-7c14ccc8ebaa@quicinc.com> To: Alexander Viro , Christian Brauner , Jan Kara , David Howells Cc: Zijun Hu , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: iZdleNWSw2lUlcGpHJetWjeVvzO4iEac X-Proofpoint-ORIG-GUID: iZdleNWSw2lUlcGpHJetWjeVvzO4iEac X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-10_02,2025-04-08_04,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 clxscore=1015 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2504100087 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu fs_name() has @index as unsigned int, so there is underflow risk for operation '@index--'. Fix by breaking the for loop when '@index == 0' which is also more proper than '@index <= 0' for unsigned integer comparison. Signed-off-by: Zijun Hu --- fs/filesystems.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/filesystems.c b/fs/filesystems.c index 58b9067b2391ce814e580709b518b405e0f9cb8a..95e5256821a53494d88f496193305a2e50e04444 100644 --- a/fs/filesystems.c +++ b/fs/filesystems.c @@ -156,15 +156,19 @@ static int fs_index(const char __user * __name) static int fs_name(unsigned int index, char __user * buf) { struct file_system_type * tmp; - int len, res; + int len, res = -EINVAL; read_lock(&file_systems_lock); - for (tmp = file_systems; tmp; tmp = tmp->next, index--) - if (index <= 0 && try_module_get(tmp->owner)) + for (tmp = file_systems; tmp; tmp = tmp->next, index--) { + if (index == 0) { + if (try_module_get(tmp->owner)) + res = 0; break; + } + } read_unlock(&file_systems_lock); - if (!tmp) - return -EINVAL; + if (res) + return res; /* OK, we got the reference, so we can safely block */ len = strlen(tmp->name) + 1; From patchwork Thu Apr 10 11:45:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 14046426 Received: from mr85p00im-zteg06021601.me.com (mr85p00im-zteg06021601.me.com [17.58.23.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 8C082284B25 for ; Thu, 10 Apr 2025 11:46:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744285567; cv=none; b=A0DPrV4K1lc07nJcA/Jg4DHdN59cM2EIPt2q1ahfXaNOSdGjzSVGNLmKakuBfpcktR72VBoJfxmdRA+Z0htpPQOuq5Jsx5CyTzw7sbvPxvGCR2pNqkyGBrMnAiYvVQ98Ap6QHqDCDnReMashu9AAnIe+7vC/XOhCSz2r+px7Mh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744285567; c=relaxed/simple; bh=Wbs1f7BkBrorZdVyU1I8hApBT0pFdloDvPlZEmsgsIM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LlT/ayRJ5XLKvjn0DMlAhnMV0royBg2nmvijAVHV8WXTiDUcRJ5O7zbtCtzyiZyvPVxPl/e7yL6EGE7P6DFdbCwBG1P6LhVQkoyO670YIMqquqCLPzqNamKkr3YmuP90g6eUdpji3WnM9miAwU3tDterqxaK6wyfxMIGF54iudE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=sWQj3OwI; arc=none smtp.client-ip=17.58.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="sWQj3OwI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; bh=u0JahMP7tuM8FXUTCsozXpgCMXPBrgvUcnz/9Uhu5lQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:x-icloud-hme; b=sWQj3OwIL8O3wW2u16MdLmQhX1pjYdALioshAkFfCHRVgO+4MCLVX3o/z7fRfpV2/ 639/p8KCo8dHfehGywx1Qg4vmUMQ6u6VfRDPRXxUhxQFwvcsnh7y1/sNhGFzay2O3G hEKcrJkJeJps5RyphI6FDpzq+/3vNKNQxMjYSkThArOXD+W2CFee0eU4TRuf5w3lFv ajTi+MCH0eanm8LN1TQKnIA3/zxSdiQ3aTwpAaorEOn115MfOEqyQlrC2/sAqKMpa2 NIKecHU0KMtTE4G0eq5iv21QMnyO3hyJp05RyHXZFODObi2G3jaNGaqKVmGnPcepQL IJSCy9wmuFF0Q== Received: from mr85p00im-zteg06021601.me.com (mr85p00im-zteg06021601.me.com [17.58.23.187]) by mr85p00im-zteg06021601.me.com (Postfix) with ESMTPS id 7D3CE3058606; Thu, 10 Apr 2025 11:46:03 +0000 (UTC) Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021601.me.com (Postfix) with ESMTPSA id 14950305855C; Thu, 10 Apr 2025 11:46:00 +0000 (UTC) From: Zijun Hu Date: Thu, 10 Apr 2025 19:45:28 +0800 Subject: [PATCH 2/5] fs/fs_parse: Fix macro fsparam_u32hex() definition Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250410-fix_fs-v1-2-7c14ccc8ebaa@quicinc.com> References: <20250410-fix_fs-v1-0-7c14ccc8ebaa@quicinc.com> In-Reply-To: <20250410-fix_fs-v1-0-7c14ccc8ebaa@quicinc.com> To: Alexander Viro , Christian Brauner , Jan Kara , David Howells Cc: Zijun Hu , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: wNOiCSmvxxg5rpxHXheK4ZTo8ERiFykr X-Proofpoint-ORIG-GUID: wNOiCSmvxxg5rpxHXheK4ZTo8ERiFykr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-10_02,2025-04-08_04,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=917 phishscore=0 mlxscore=0 spamscore=0 suspectscore=0 adultscore=0 malwarescore=0 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2504100087 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu Macro fsparam_u32hex() uses as type @fs_param_is_u32_hex which is never defined. Fix by using @fs_param_is_u32 instead as fsparam_u32oct() does. Fixes: 328de5287b10 ("turn fs_param_is_... into functions") Signed-off-by: Zijun Hu --- include/linux/fs_parser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h index 53e566efd5fd133d19e313e494b975612a227b77..ca76601d0bbdbaded76515cb6b2c06fa30127a06 100644 --- a/include/linux/fs_parser.h +++ b/include/linux/fs_parser.h @@ -126,7 +126,7 @@ static inline bool fs_validate_description(const char *name, #define fsparam_u32oct(NAME, OPT) \ __fsparam(fs_param_is_u32, NAME, OPT, 0, (void *)8) #define fsparam_u32hex(NAME, OPT) \ - __fsparam(fs_param_is_u32_hex, NAME, OPT, 0, (void *)16) + __fsparam(fs_param_is_u32, NAME, OPT, 0, (void *)16) #define fsparam_s32(NAME, OPT) __fsparam(fs_param_is_s32, NAME, OPT, 0, NULL) #define fsparam_u64(NAME, OPT) __fsparam(fs_param_is_u64, NAME, OPT, 0, NULL) #define fsparam_enum(NAME, OPT, array) __fsparam(fs_param_is_enum, NAME, OPT, 0, array) From patchwork Thu Apr 10 11:45:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 14046427 Received: from mr85p00im-zteg06021601.me.com (mr85p00im-zteg06021601.me.com [17.58.23.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 E72AF284B28 for ; Thu, 10 Apr 2025 11:46:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744285567; cv=none; b=E78CGzsoH2OutA01DZcu2yZKoSyJN8+UNcnWZYIM7TDOhfSWJPiCh/KpAnfzfNPw7yY5kVMkpUuB0SR8Shpnp5NK6RvO2UXovP8twxLHdWyKvQL/Bhq21U7fg+gcarzxz+sSJISBFy+RFRl9ThZdF+n1FSvr46NZuQOtO9fw5ko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744285567; c=relaxed/simple; bh=D49T6SLCejeoklZXpuLtznN1S9vbVJSgyfAthWsQsbI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Os3L0d9g9kO/ZfrCVZTSMkqNGsvfMsFGkrUFDm2QvMXMElxfLV5lWpC3JClob1JeM0dM7uqPJEc6gSp3GvqjQrka2sEd9XCwUw6TYRvhkgLSoo66MHG6ORkv8vKcrERPYXWQDSIMNFOs56JbBlqcOFX+Ao3bg22kh74JZ1W8lOY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=tRGm6gEx; arc=none smtp.client-ip=17.58.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="tRGm6gEx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; bh=zJST5uWP36CEOsCjl88kv0G84KCvrKxNsC6tp4ucGOk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:x-icloud-hme; b=tRGm6gExrESRuhHOugUr6E6aas5ITxhJuHtwrGMgrJQmdm+3/Mz7wZjoAj4L7lXfO NIU4QSfA1Qj8gnmlWuKt5BuDY6JdBGvx2aEhe11+CjI+uXoQq1MLhkL+CyEe7dnQgi hX4vcVMf36zWcgtFIJNjdyw65RasYFm8QAl10gm9TTYTX5ibpPMCrMtr/uhJeOCOB1 32kRAMVFDzO2wTSSKjwtuUZr+3xkDkvxnlmPzuCos3Y3ZGfrrfEAIYDDlxd2QlI5f6 Sa0QoksTsNPc0j8e4lAIKg4GHlcIpMksFyuHceF7QGGD3PgZL+0f5aG908JfwDljeB GDsNgzMBVXw0Q== Received: from mr85p00im-zteg06021601.me.com (mr85p00im-zteg06021601.me.com [17.58.23.187]) by mr85p00im-zteg06021601.me.com (Postfix) with ESMTPS id 316493058631; Thu, 10 Apr 2025 11:46:05 +0000 (UTC) Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021601.me.com (Postfix) with ESMTPSA id 3F051305839B; Thu, 10 Apr 2025 11:46:03 +0000 (UTC) From: Zijun Hu Date: Thu, 10 Apr 2025 19:45:29 +0800 Subject: [PATCH 3/5] fs/fs_parse: Fix 3 issues for validate_constant_table() Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250410-fix_fs-v1-3-7c14ccc8ebaa@quicinc.com> References: <20250410-fix_fs-v1-0-7c14ccc8ebaa@quicinc.com> In-Reply-To: <20250410-fix_fs-v1-0-7c14ccc8ebaa@quicinc.com> To: Alexander Viro , Christian Brauner , Jan Kara , David Howells Cc: Zijun Hu , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: hJQ1O_zxNEOTFTM_IY-WeKToB5rZlx7U X-Proofpoint-ORIG-GUID: hJQ1O_zxNEOTFTM_IY-WeKToB5rZlx7U X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-10_02,2025-04-08_04,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 clxscore=1015 spamscore=0 bulkscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2504100087 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu Constant table array array[] which must end with a empty entry and fix below issues for validate_constant_table(array, ARRAY_SIZE(array), ...): - Always return wrong value for good constant table array which ends with a empty entry. - Imprecise error message for missorted case. - Potential NULL pointer dereference. Fixes: 31d921c7fb96 ("vfs: Add configuration parser helpers") Signed-off-by: Zijun Hu --- fs/fs_parser.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/fs_parser.c b/fs/fs_parser.c index e635a81e17d965df78ffef27f6885cd70996c6dd..ef7876340a917876bc40df9cdde9232204125a75 100644 --- a/fs/fs_parser.c +++ b/fs/fs_parser.c @@ -399,6 +399,9 @@ bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size, } for (i = 0; i < tbl_size; i++) { + if (!tbl[i].name && (i + 1 == tbl_size)) + break; + if (!tbl[i].name) { pr_err("VALIDATE C-TBL[%zu]: Null\n", i); good = false; @@ -411,13 +414,13 @@ bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size, good = false; } if (c > 0) { - pr_err("VALIDATE C-TBL[%zu]: Missorted %s>=%s\n", + pr_err("VALIDATE C-TBL[%zu]: Missorted %s>%s\n", i, tbl[i-1].name, tbl[i].name); good = false; } } - if (tbl[i].value != special && + if (tbl[i].name && tbl[i].value != special && (tbl[i].value < low || tbl[i].value > high)) { pr_err("VALIDATE C-TBL[%zu]: %s->%d const out of range (%d-%d)\n", i, tbl[i].name, tbl[i].value, low, high); From patchwork Thu Apr 10 11:45:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 14046428 Received: from mr85p00im-zteg06021601.me.com (mr85p00im-zteg06021601.me.com [17.58.23.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 E7D9C2853E1 for ; Thu, 10 Apr 2025 11:46:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744285570; cv=none; b=WxH4TUUYWuCG7kWt3Zy8bINzReJaKH/5W7xwEQlYeohKq7tnPLvaVZqp4b4CmUevsDxG1BemhPGpglPkYi2v1uNeWdqodHGGuokfkv6TaqNZpk3V8K+ot/2Y6YrU3n3zOfkemMz+3LUD9ja+l21W3TIRqYAj58OEbvfLtm426vU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744285570; c=relaxed/simple; bh=DVnsjomPSF5bxb2nTDpMndwEoLHx/PKuaBexCy0g8c0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CROnPTZzHuKtABUExFBzfMKg6pwKGj2c+l/xQhZS+4nuRVzACqDRcGzizR1/xUVusRi3nG38lyd+kzk6ADW2HcyNvf83QL2PzvSUrUFgznJcADI3676nNloPU6HU4nrkUD20AnGh3Mgdt4nyEClOhRdTq/G8AVw2lc4RZ3Lg+hU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=Obq6f4i4; arc=none smtp.client-ip=17.58.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="Obq6f4i4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; bh=r4cwnM2naJBhys/ZEhnMP0ewYkylFqSW9802uv3re74=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:x-icloud-hme; b=Obq6f4i42jg2upEEt/Ai/0lYPqEeioHNjLPVrKl0QcJ7lwLU58CuYYy/xTri2VcqO dCgtuMNcWGGUu7cdLmeuAKSHkYOfgmZSQ0gXxFvnEofCtjrO96fLPssFK8VqLQXeyx azr0XVhPsFFQLiaFqSN6rRDycrScNkTQFRFaZgS+mDAo0y/ORYADplh0Cnjl5+5O+P KhInUXGK6KBClJVGxZW9CI+ABVXBicwoMaZwqxywRLZ/iomLX5/ETQwUGcz7HYmDir /n0VNX0QkoFebRwFt+tUSexR99HUYP3TQC64LAOoL14xmsY8d4hfjoNac0m5+Q/a2Z vAwINYBelMskw== Received: from mr85p00im-zteg06021601.me.com (mr85p00im-zteg06021601.me.com [17.58.23.187]) by mr85p00im-zteg06021601.me.com (Postfix) with ESMTPS id 8C9723058308; Thu, 10 Apr 2025 11:46:07 +0000 (UTC) Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021601.me.com (Postfix) with ESMTPSA id 68E97305859F; Thu, 10 Apr 2025 11:46:05 +0000 (UTC) From: Zijun Hu Date: Thu, 10 Apr 2025 19:45:30 +0800 Subject: [PATCH 4/5] fs/fs_parse: Correct comments of fs_validate_description() Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250410-fix_fs-v1-4-7c14ccc8ebaa@quicinc.com> References: <20250410-fix_fs-v1-0-7c14ccc8ebaa@quicinc.com> In-Reply-To: <20250410-fix_fs-v1-0-7c14ccc8ebaa@quicinc.com> To: Alexander Viro , Christian Brauner , Jan Kara , David Howells Cc: Zijun Hu , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: N2ScF9jyyauzOuQ-N56oq7nKtJVweg4Y X-Proofpoint-ORIG-GUID: N2ScF9jyyauzOuQ-N56oq7nKtJVweg4Y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-10_02,2025-04-08_04,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 spamscore=0 malwarescore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2504100087 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu For fs_validate_description(), its comments easily mislead reader that the function will search array @desc for duplicated entries with name specified by parameter @name, but @name is not used for search actually. Fix by marking name as owner's name of these parameter specifications. Signed-off-by: Zijun Hu --- fs/fs_parser.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/fs_parser.c b/fs/fs_parser.c index ef7876340a917876bc40df9cdde9232204125a75..77fd8133c1cf191158de13ec556a5e3c7c2bb12a 100644 --- a/fs/fs_parser.c +++ b/fs/fs_parser.c @@ -432,9 +432,9 @@ bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size, } /** - * fs_validate_description - Validate a parameter description - * @name: The parameter name to search for. - * @desc: The parameter description to validate. + * fs_validate_description - Validate a parameter specification array + * @name: Owner name of the parameter specification array + * @desc: The parameter specification array to validate. */ bool fs_validate_description(const char *name, const struct fs_parameter_spec *desc) From patchwork Thu Apr 10 11:45:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 14046429 Received: from mr85p00im-zteg06021601.me.com (mr85p00im-zteg06021601.me.com [17.58.23.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 5D322285405 for ; Thu, 10 Apr 2025 11:46:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744285572; cv=none; b=GS5b9BBdUG+r5Zyssa47oFtLRDjziLjzi50/AxvKK4Uaa2v40L98xP3R3iqxY+gt9KYb16Ty0FNJ2FjucGZXgxNwIAS36aV5LFFiy5CDZ40nZdhTW9qKE4s8CaO0aaNQmFfZ/ltHggY+nNXBwCunFC3QG7z4pTLGFGIYJd0toDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744285572; c=relaxed/simple; bh=swxv/69OXoGMQgh78vmQsv5ee1jjhh4aaX6GUHX0zD0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ClhV9KUHw/9TiP6VT7iXmTj+QvKpjlv2tCwbUYQE5qc06BX+gAw41ruOe7tWKTjrtzWqLldwYGM+0DucIk7P2Ngri5vGoTMrNUbE64kf6vqyt4sOFcUDLpV2GTDc28vilkgIKtHIPu2GJUquPrrFBVLlb/pFs1dyOJExUpx/YNQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=OFGIu3Gt; arc=none smtp.client-ip=17.58.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="OFGIu3Gt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; bh=7ogrfVUjfpDxF4h8Zei+Mv0WcYgXNX6lZECoUKIoJsg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:x-icloud-hme; b=OFGIu3GtVCOg5A+CFVJQN5Qpsfs1qDMCNZlLU2VYFM1KceLSfQyssCZp8kXTeOE0+ Ec+b7IW7Avh8V3HnHki/qbOAjdghbySXA43bwxAnCMCHwGL6jwUYrNvu3ZL4vb/b5U nfsFCseXzAU0ehuBL81vvkf5HOlkDotbcm8Ff3oD2CuA3c3pKsW4e2gpg/5kvoya9b J3r28tkwOtme7RlHPRRj/3W0upME644BnDwmu4aQwf9Y6byiWW8fOnaAFEkzM2QzuF sguMS1sgJe3N34fFJ8LcOx51hUQGqMnWQ9kdHXcd2fE0fBcuezXJOmi4MLpfHG6p5q w8ymdTuPMQXtw== Received: from mr85p00im-zteg06021601.me.com (mr85p00im-zteg06021601.me.com [17.58.23.187]) by mr85p00im-zteg06021601.me.com (Postfix) with ESMTPS id DC91930585D8; Thu, 10 Apr 2025 11:46:09 +0000 (UTC) Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021601.me.com (Postfix) with ESMTPSA id 9324D30583EB; Thu, 10 Apr 2025 11:46:07 +0000 (UTC) From: Zijun Hu Date: Thu, 10 Apr 2025 19:45:31 +0800 Subject: [PATCH 5/5] fs/fs_context: Mark an unlikely if condition with unlikely() in vfs_parse_monolithic_sep() Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250410-fix_fs-v1-5-7c14ccc8ebaa@quicinc.com> References: <20250410-fix_fs-v1-0-7c14ccc8ebaa@quicinc.com> In-Reply-To: <20250410-fix_fs-v1-0-7c14ccc8ebaa@quicinc.com> To: Alexander Viro , Christian Brauner , Jan Kara , David Howells Cc: Zijun Hu , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: bh0hhOatG7ST1xaITvng1aKmLh8pS4WA X-Proofpoint-ORIG-GUID: bh0hhOatG7ST1xaITvng1aKmLh8pS4WA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-10_02,2025-04-08_04,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 clxscore=1015 adultscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2504100087 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu There is no mount option with pattern "...,=key_or_value,...", so the if condition '(value == key)' in while loop of vfs_parse_monolithic_sep() is is unlikely true. Mark the condition with unlikely() to improve both performance and readability. Signed-off-by: Zijun Hu --- fs/fs_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/fs_context.c b/fs/fs_context.c index 582d33e8111739402d38dc9fc268e7d14ced3c49..284301d88bc90ef462a08c9ea893f822075a6d4d 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -222,7 +222,7 @@ int vfs_parse_monolithic_sep(struct fs_context *fc, void *data, char *value = strchr(key, '='); if (value) { - if (value == key) + if (unlikely(value == key)) continue; *value++ = 0; v_len = strlen(value);