{"id":2219168,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2219168/?format=json","project":{"id":12,"url":"http://patchwork.ozlabs.org/api/1.0/projects/12/?format=json","name":"Linux CIFS Client","link_name":"linux-cifs-client","list_id":"linux-cifs.vger.kernel.org","list_email":"linux-cifs@vger.kernel.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260402141839.461257-7-huiwen.he@linux.dev>","date":"2026-04-02T14:18:32","name":"[v3,06/13] smb/client: check if ntstatus_to_dos_map is sorted","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"95031318ab772ccffa9d00e3429fb6558c61314f","submitter":{"id":93029,"url":"http://patchwork.ozlabs.org/api/1.0/people/93029/?format=json","name":null,"email":"huiwen.he@linux.dev"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260402141839.461257-7-huiwen.he@linux.dev/mbox/","series":[{"id":498490,"url":"http://patchwork.ozlabs.org/api/1.0/series/498490/?format=json","date":"2026-04-02T14:18:28","name":"smb: improve search speed of SMB1 maperror","version":3,"mbox":"http://patchwork.ozlabs.org/series/498490/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219168/checks/","tags":{},"headers":{"Return-Path":"\n <linux-cifs+bounces-10639-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-cifs@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256\n header.s=key1 header.b=Q5Sm5OvQ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-cifs+bounces-10639-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev\n header.b=\"Q5Sm5OvQ\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=91.218.175.185","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.dev","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=linux.dev"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fmkZN0CFzz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 03 Apr 2026 01:22:04 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 55F6D307A540\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  2 Apr 2026 14:20:12 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 52A943ED101;\n\tThu,  2 Apr 2026 14:20:02 +0000 (UTC)","from out-185.mta0.migadu.com (out-185.mta0.migadu.com\n [91.218.175.185])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id A90173EC2CE\n\tfor <linux-cifs@vger.kernel.org>; Thu,  2 Apr 2026 14:20:00 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775139602; cv=none;\n b=qpp+oE6+hYSkPiB2tROF3y/atBWBgANaxJaUpKJ999W/q/cF3JdV1mKHx1+71Qc5kcmIV6M98OniUGKY2Y4PWlQxeZYZD4BDfjoxPu/bIdp6McwY+wekUFs/pE7CzOavjC1lD2q3Cn6iewKmtgGx1ucxU8L93C7zaZWigwVcSs8=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775139602; c=relaxed/simple;\n\tbh=AdCAV8ae+czHkmacruOayVt3fhwt/uR1WOb2UB+8y3Q=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=eYX4qo1yvUoXtWbW8heuwe7CHjdHsUr+jxIQMNlaYiKBdHbXc62itwhRboTzP1lDpK87zTHF8rHw6j49BdAnYBhKhpNzJv2BWiJ9+HJKpEQXiHp42xfi0reMTBd39FKJcub3HAjCfUM9YTjTMOJB4HLPafnvEOk9hNV1CF0ya2I=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.dev;\n spf=pass smtp.mailfrom=linux.dev;\n dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev\n header.b=Q5Sm5OvQ; arc=none smtp.client-ip=91.218.175.185","X-Report-Abuse":"Please report any abuse attempt to abuse@migadu.com and\n include these headers.","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1;\n\tt=1775139598;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\t to:to:cc:cc:mime-version:mime-version:\n\t content-transfer-encoding:content-transfer-encoding:\n\t in-reply-to:in-reply-to:references:references;\n\tbh=XlRuE40CiHaHcbqmS8foEXRLt6XZb3Aw4UDwDwu2hl4=;\n\tb=Q5Sm5OvQQaFbTXLbKBdRP9wdk1HyfAh+DMGsVkdG6W0Qg/K+J3GgE9DBr4IqRp4uacUFQR\n\tl7ettg6MKb1yveAS+wDS6BIzHHYqa2uUrWDZC8A5Q8K+B/2iqVtAIfSh123UdOkSktrnnz\n\t+s+2wgmbbbIfdYroGU9VmOV3CBaDk90=","From":"huiwen.he@linux.dev","To":"smfrench@gmail.com,\n\tlinkinjeon@kernel.org,\n\tdhowells@redhat.com,\n\tchenxiaosong@kylinos.cn,\n\tchenxiaosong@chenxiaosong.com,\n\ttangyouling@kylinos.cn","Cc":"linux-cifs@vger.kernel.org","Subject":"[PATCH v3 06/13] smb/client: check if ntstatus_to_dos_map is sorted","Date":"Thu,  2 Apr 2026 14:18:32 +0000","Message-ID":"<20260402141839.461257-7-huiwen.he@linux.dev>","In-Reply-To":"<20260402141839.461257-1-huiwen.he@linux.dev>","References":"<20260402141839.461257-1-huiwen.he@linux.dev>","Precedence":"bulk","X-Mailing-List":"linux-cifs@vger.kernel.org","List-Id":"<linux-cifs.vger.kernel.org>","List-Subscribe":"<mailto:linux-cifs+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-cifs+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Migadu-Flow":"FLOW_OUT"},"content":"From: Youling Tang <tangyouling@kylinos.cn>\n\nAlthough the array is sorted at build time, verify the ordering again\nwhen cifs.ko is loaded to avoid potential regressions introduced by\nfuture script changes.\n\nWe are going to define 3 functions to check the sort results, introduce the\nmacro DEFINE_CHECK_SORT_FUNC() to reduce duplicate code.\n\nSigned-off-by: Youling Tang <tangyouling@kylinos.cn>\nReviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>\n---\n fs/smb/client/cifsfs.c       |  6 ++++++\n fs/smb/client/smb1maperror.c | 32 ++++++++++++++++++++++++++++++++\n fs/smb/client/smb1proto.h    |  1 +\n 3 files changed, 39 insertions(+)","diff":"diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c\nindex f4bed8d4a072..0541706c36c5 100644\n--- a/fs/smb/client/cifsfs.c\n+++ b/fs/smb/client/cifsfs.c\n@@ -1915,6 +1915,12 @@ init_cifs(void)\n {\n \tint rc = 0;\n \n+#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY\n+\trc = smb1_init_maperror();\n+\tif (rc)\n+\t\treturn rc;\n+#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */\n+\n \trc = smb2_init_maperror();\n \tif (rc)\n \t\treturn rc;\ndiff --git a/fs/smb/client/smb1maperror.c b/fs/smb/client/smb1maperror.c\nindex fb985d2fc0d9..66ceebbe535e 100644\n--- a/fs/smb/client/smb1maperror.c\n+++ b/fs/smb/client/smb1maperror.c\n@@ -256,3 +256,35 @@ map_and_check_smb_error(struct TCP_Server_Info *server,\n \n \treturn rc;\n }\n+\n+#define DEFINE_CHECK_SORT_FUNC(__array, __field)\t\t\t\\\n+static int __init __array ## _is_sorted(void)\t\t\t\t\\\n+{\t\t\t\t\t\t\t\t\t\\\n+\tunsigned int i;\t\t\t\t\t\t\t\\\n+\t\t\t\t\t\t\t\t\t\\\n+\t/* Check whether the array is sorted in ascending order */\t\\\n+\tfor (i = 1; i < ARRAY_SIZE(__array); i++) {\t\t\t\\\n+\t\tif (__array[i].__field >=\t\t\t\t\\\n+\t\t    __array[i - 1].__field)\t\t\t\t\\\n+\t\t\tcontinue;\t\t\t\t\t\\\n+\t\t\t\t\t\t\t\t\t\\\n+\t\tpr_err(#__array \" array order is incorrect\\n\");\t\t\\\n+\t\treturn -EINVAL;\t\t\t\t\t\t\\\n+\t}\t\t\t\t\t\t\t\t\\\n+\t\t\t\t\t\t\t\t\t\\\n+\treturn 0;\t\t\t\t\t\t\t\\\n+}\n+\n+/* ntstatus_to_dos_map_is_sorted */\n+DEFINE_CHECK_SORT_FUNC(ntstatus_to_dos_map, ntstatus);\n+\n+int __init smb1_init_maperror(void)\n+{\n+\tint rc;\n+\n+\trc = ntstatus_to_dos_map_is_sorted();\n+\tif (rc)\n+\t\treturn rc;\n+\n+\treturn rc;\n+}\ndiff --git a/fs/smb/client/smb1proto.h b/fs/smb/client/smb1proto.h\nindex 42569bbcf6fd..dd98d04e837a 100644\n--- a/fs/smb/client/smb1proto.h\n+++ b/fs/smb/client/smb1proto.h\n@@ -234,6 +234,7 @@ int cifs_verify_signature(struct smb_rqst *rqst,\n  * smb1maperror.c\n  */\n int map_smb_to_linux_error(char *buf, bool logErr);\n+int smb1_init_maperror(void);\n int map_and_check_smb_error(struct TCP_Server_Info *server,\n \t\t\t    struct mid_q_entry *mid, bool logErr);\n \n","prefixes":["v3","06/13"]}