[{"id":3672674,"web_url":"http://patchwork.ozlabs.org/comment/3672674/","msgid":"<67df08d1-6bbf-560c-de40-9cf1e88c406a@huawei.com>","list_archive_url":null,"date":"2026-04-02T11:18:05","subject":"Re: [PATCH] ubifs: prefer kstrtobool_from_user() over custom helper","submitter":{"id":76854,"url":"http://patchwork.ozlabs.org/api/people/76854/","name":"Zhihao Cheng","email":"chengzhihao1@huawei.com"},"content":"在 2026/4/2 16:13, Dmitry Antipov 写道:\n> Adjust 'dfs_file_write()' and 'dfs_global_file_write()' to prefer generic\n> 'kstrtobool_from_user()' over an ad-hoc 'interpret_user_input()' helper,\n> thus making the latter not needed anymore.\n> \n> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>\n> ---\n>   fs/ubifs/debug.c | 44 ++++++++++----------------------------------\n>   1 file changed, 10 insertions(+), 34 deletions(-)\n> \n\nReviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>\n> diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c\n> index 160c16aa7b6e..252cf82012cf 100644\n> --- a/fs/ubifs/debug.c\n> +++ b/fs/ubifs/debug.c\n> @@ -2732,39 +2732,14 @@ static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count,\n>   \treturn provide_user_output(val, u, count, ppos);\n>   }\n>   \n> -/**\n> - * interpret_user_input - interpret user debugfs file input.\n> - * @u: user-provided buffer with the input\n> - * @count: buffer size\n> - *\n> - * This is a helper function which interpret user input to a boolean UBIFS\n> - * debugfs file. Returns %0 or %1 in case of success and a negative error code\n> - * in case of failure.\n> - */\n> -static int interpret_user_input(const char __user *u, size_t count)\n> -{\n> -\tsize_t buf_size;\n> -\tchar buf[8];\n> -\n> -\tbuf_size = min_t(size_t, count, (sizeof(buf) - 1));\n> -\tif (copy_from_user(buf, u, buf_size))\n> -\t\treturn -EFAULT;\n> -\n> -\tif (buf[0] == '1')\n> -\t\treturn 1;\n> -\telse if (buf[0] == '0')\n> -\t\treturn 0;\n> -\n> -\treturn -EINVAL;\n> -}\n> -\n>   static ssize_t dfs_file_write(struct file *file, const char __user *u,\n>   \t\t\t      size_t count, loff_t *ppos)\n>   {\n>   \tstruct ubifs_info *c = file->private_data;\n>   \tstruct ubifs_debug_info *d = c->dbg;\n>   \tstruct dentry *dent = file->f_path.dentry;\n> -\tint val;\n> +\tbool val;\n> +\tint ret;\n>   \n>   \tif (file->f_path.dentry == d->dfs_dump_lprops) {\n>   \t\tubifs_dump_lprops(c);\n> @@ -2781,9 +2756,9 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,\n>   \t\treturn count;\n>   \t}\n>   \n> -\tval = interpret_user_input(u, count);\n> -\tif (val < 0)\n> -\t\treturn val;\n> +\tret = kstrtobool_from_user(u, count, &val);\n> +\tif (unlikely(ret))\n> +\t\treturn ret;\n>   \n>   \tif (dent == d->dfs_chk_gen)\n>   \t\td->chk_gen = val;\n> @@ -2926,11 +2901,12 @@ static ssize_t dfs_global_file_write(struct file *file, const char __user *u,\n>   \t\t\t\t     size_t count, loff_t *ppos)\n>   {\n>   \tstruct dentry *dent = file->f_path.dentry;\n> -\tint val;\n> +\tbool val;\n> +\tint ret;\n>   \n> -\tval = interpret_user_input(u, count);\n> -\tif (val < 0)\n> -\t\treturn val;\n> +\tret = kstrtobool_from_user(u, count, &val);\n> +\tif (unlikely(ret))\n> +\t\treturn ret;\n>   \n>   \tif (dent == dfs_chk_gen)\n>   \t\tubifs_dbg.chk_gen = val;\n>","headers":{"Return-Path":"\n <linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=iNOgYhop;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256\n header.s=dkim header.b=4v+ah4Iy;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\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 4fmfW86gtXz1yGH\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 02 Apr 2026 22:18:57 +1100 (AEDT)","from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w8G4K-0000000HUj8-1mOe;\n\tThu, 02 Apr 2026 11:18:36 +0000","from canpmsgout12.his.huawei.com ([113.46.200.227])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w8G4E-0000000HUiJ-0T1X\n\tfor linux-mtd@lists.infradead.org;\n\tThu, 02 Apr 2026 11:18:33 +0000","from mail.maildlp.com (unknown [172.19.163.163])\n\tby canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4fmfLj0SYTznTtw;\n\tThu,  2 Apr 2026 19:11:41 +0800 (CST)","from kwepemk500005.china.huawei.com (unknown [7.202.194.90])\n\tby mail.maildlp.com (Postfix) with ESMTPS id 766D44048B;\n\tThu,  2 Apr 2026 19:18:06 +0800 (CST)","from [10.174.178.46] (10.174.178.46) by\n kwepemk500005.china.huawei.com (7.202.194.90) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.2.1544.11; Thu, 2 Apr 2026 19:18:05 +0800"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type:\n\tContent-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive:\n\tList-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From:\n\tReferences:CC:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date:\n\tResent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;\n\tbh=OrjRyY6KHHLt22QHO8vw1b7lN6b8Hh7OUvDUWCPhlSs=; b=iNOgYhopuN6D5gCdBG48LDEuF5\n\tAsIZSr6whVEO/y3dzDs2Q9o4GmM+0yqE2t5rtLAGK558BaRLvzYFOPvS5GZi3GQ7xNsyfxp/hxNC3\n\tWNjNN7fs8Q4n3rKa6kde5vpXa0uUS8yrGDcu1d0YIla9pylTzj9xS2S8J21/ppQ0aNf6oT4z709lW\n\tL4Fn2kuoCurrLOEOg+TV8E3eesROcfsqZifYf8rlyDHxbEK2rwc4X2JYG4bBNncoOWbVtmhKZMDGQ\n\t2ALC/alIhi38kNT7VA85tovLMx7sYVYn5+QxpGF2EyVidnt7YMFu7xhY6KslFTglad/1xnQ+z2qGv\n\tXxQPXryQ==;","v=1; a=rsa-sha256; d=huawei.com; s=dkim;\n\tc=relaxed/relaxed; q=dns/txt;\n\th=From;\n\tbh=hrvHFtWCk4lVdFE7TR5/Y397b4q9p9V8q32sVbcY68g=;\n\tb=4v+ah4IyGH+thHmjB8sRwEe1HaInjJ9AYioFsxpfkD2RcG+Mh56WXdth+tfbpnFxf8U2jR3+D\n\tw/P74EbUGPN44Fw5gtlKPsRMCrWMIKrKxAAhvStDDiMCg/ijCQ6slAGRQdRkYjGujA/546Z2eGC\n\t4EH+/Bk8Ay/+ESGEpv7COdA="],"dkim-signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type:\n\tContent-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive:\n\tList-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From:\n\tReferences:CC:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date:\n\tResent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;\n\tbh=OrjRyY6KHHLt22QHO8vw1b7lN6b8Hh7OUvDUWCPhlSs=; b=iNOgYhopuN6D5gCdBG48LDEuF5\n\tAsIZSr6whVEO/y3dzDs2Q9o4GmM+0yqE2t5rtLAGK558BaRLvzYFOPvS5GZi3GQ7xNsyfxp/hxNC3\n\tWNjNN7fs8Q4n3rKa6kde5vpXa0uUS8yrGDcu1d0YIla9pylTzj9xS2S8J21/ppQ0aNf6oT4z709lW\n\tL4Fn2kuoCurrLOEOg+TV8E3eesROcfsqZifYf8rlyDHxbEK2rwc4X2JYG4bBNncoOWbVtmhKZMDGQ\n\t2ALC/alIhi38kNT7VA85tovLMx7sYVYn5+QxpGF2EyVidnt7YMFu7xhY6KslFTglad/1xnQ+z2qGv\n\tXxQPXryQ==;","v=1; a=rsa-sha256; d=huawei.com; s=dkim;\n\tc=relaxed/relaxed; q=dns/txt;\n\th=From;\n\tbh=hrvHFtWCk4lVdFE7TR5/Y397b4q9p9V8q32sVbcY68g=;\n\tb=4v+ah4IyGH+thHmjB8sRwEe1HaInjJ9AYioFsxpfkD2RcG+Mh56WXdth+tfbpnFxf8U2jR3+D\n\tw/P74EbUGPN44Fw5gtlKPsRMCrWMIKrKxAAhvStDDiMCg/ijCQ6slAGRQdRkYjGujA/546Z2eGC\n\t4EH+/Bk8Ay/+ESGEpv7COdA="],"Subject":"Re: [PATCH] ubifs: prefer kstrtobool_from_user() over custom helper","To":"Dmitry Antipov <dmantipov@yandex.ru>, Richard Weinberger <richard@nod.at>","CC":"<linux-mtd@lists.infradead.org>","References":"<20260402081332.523352-1-dmantipov@yandex.ru>","From":"Zhihao Cheng <chengzhihao1@huawei.com>","Message-ID":"<67df08d1-6bbf-560c-de40-9cf1e88c406a@huawei.com>","Date":"Thu, 2 Apr 2026 19:18:05 +0800","User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101\n Thunderbird/68.5.0","MIME-Version":"1.0","In-Reply-To":"<20260402081332.523352-1-dmantipov@yandex.ru>","X-Originating-IP":"[10.174.178.46]","X-ClientProxiedBy":"kwepems100002.china.huawei.com (7.221.188.206) To\n kwepemk500005.china.huawei.com (7.202.194.90)","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20260402_041831_630709_D392697F ","X-CRM114-Status":"GOOD (  17.20  )","X-Spam-Score":"-4.4 (----)","X-Spam-Report":"=?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?=\n\t=?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?=\n\t=?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?=\n\t=?unknown-8bit?q?ginal?=\n\t=?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?=\n\t=?unknown-8bit?q?bel?=\n\t=?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?=\n\t=?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?=\n\t=?unknown-8bit?q?_?=\n\t=?unknown-8bit?b?IENvbnRlbnQgcHJldmlldzogIOWcqCAyMDI2LzQvMiAxNjoxMywgRG1p?=\n\t=?unknown-8bit?b?dHJ5IEFudGlwb3Yg5YaZ6YGTOiA+IEFkanVzdCAnZGZzX2ZpbGVfd3Jp?=\n\t=?unknown-8bit?b?dGUoKSc=?=\n\t=?unknown-8bit?b?IGFuZCAnZGZzX2dsb2JhbF9maWxlX3dyaXRlKCknIHRvIHByZWZlciBn?=\n\t=?unknown-8bit?b?ZW5lcmljID4gJ2tzdHJ0b2Jvb2xfZnJvbV91c2VyKCkn?=\n\t=?unknown-8bit?b?IG92ZXIgYW4gYWQtaG9jICdpbnRlcnByZXRfdXNlcl9pbnB1dCgpJyBo?=\n\t=?unknown-8bit?b?ZWxwZXIsID4gdGh1cyBbLi4uXSA=?=\n\t=?unknown-8bit?q?_?=\n\t=?unknown-8bit?q?_Content_analysis_details=3A___=28-4=2E4_points=2C_5=2E0_re?=\n\t=?unknown-8bit?q?quired=29?=\n\t=?unknown-8bit?q?_?=\n\t=?unknown-8bit?q?_pts_rule_name______________description?=\n\t=?unknown-8bit?q?_----_----------------------_------------------------------?=\n\t=?unknown-8bit?q?--------------------?=\n\t=?unknown-8bit?q?_0=2E0_RCVD=5FIN=5FVALIDITY=5FCERTIFIED=5FBLOCKED_RBL=3A_AD?=\n\t=?unknown-8bit?q?MINISTRATOR_NOTICE=3A_The?=\n\t=?unknown-8bit?q?_query_to_Validity_was_blocked=2E__See?=\n\t=?unknown-8bit?q?_https=3A//knowledge=2Evalidity=2Ecom/hc/en-us/articles/209?=\n\t=?unknown-8bit?q?61730681243?=\n\t=?unknown-8bit?q?_for_more_information=2E?=\n\t=?unknown-8bit?q?_=5B113=2E46=2E200=2E227_listed_in_sa-trusted=2Ebondedsende?=\n\t=?unknown-8bit?q?r=2Eorg=5D?=\n\t=?unknown-8bit?q?_0=2E0_RCVD=5FIN=5FVALIDITY=5FSAFE=5FBLOCKED_RBL=3A_ADMINIS?=\n\t=?unknown-8bit?q?TRATOR_NOTICE=3A_The_query_to?=\n\t=?unknown-8bit?q?_Validity_was_blocked=2E__See?=\n\t=?unknown-8bit?q?_https=3A//knowledge=2Evalidity=2Ecom/hc/en-us/articles/209?=\n\t=?unknown-8bit?q?61730681243?=\n\t=?unknown-8bit?q?_for_more_information=2E?=\n\t=?unknown-8bit?q?_=5B113=2E46=2E200=2E227_listed_in_sa-accredit=2Ehabeas=2Ec?=\n\t=?unknown-8bit?q?om=5D?=\n\t=?unknown-8bit?q?_0=2E0_RCVD=5FIN=5FVALIDITY=5FRPBL=5FBLOCKED_RBL=3A_ADMINIS?=\n\t=?unknown-8bit?q?TRATOR_NOTICE=3A_The_query_to?=\n\t=?unknown-8bit?q?_Validity_was_blocked=2E__See?=\n\t=?unknown-8bit?q?_https=3A//knowledge=2Evalidity=2Ecom/hc/en-us/articles/209?=\n\t=?unknown-8bit?q?61730681243?=\n\t=?unknown-8bit?q?_for_more_information=2E?=\n\t=?unknown-8bit?q?_=5B113=2E46=2E200=2E227_listed_in_bl=2Escore=2Esenderscore?=\n\t=?unknown-8bit?q?=2Ecom=5D?=\n\t=?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?=\n\t=?unknown-8bit?q?record?=\n\t=?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?=\n\t=?unknown-8bit?q?ish_an_SPF_Record?=\n\t=?unknown-8bit?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_si?=\n\t=?unknown-8bit?q?gnature=2C_not_necessarily_valid?=\n\t=?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM?=\n\t=?unknown-8bit?q?_or_DK_signature_from?=\n\t=?unknown-8bit?q?_envelope-from_domain?=\n\t=?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM?=\n\t=?unknown-8bit?q?_or_DK_signature_from_author=27s?=\n\t=?unknown-8bit?q?_domain?=\n\t=?unknown-8bit?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_v?=\n\t=?unknown-8bit?q?alid_DKIM_or_DK_signature?=\n\t=?unknown-8bit?q?_-1=2E9_BAYES=5F00_______________BODY=3A_Bayes_spam_probabi?=\n\t=?unknown-8bit?q?lity_is_0_to_1=25?=\n\t=?unknown-8bit?q?_=5Bscore=3A_0=2E0000=5D?=\n\t=?unknown-8bit?q?_-2=2E3_NICE=5FREPLY=5FA___________Looks_like_a_legit_reply?=\n\t=?unknown-8bit?q?_=28A=29?=","X-BeenThere":"linux-mtd@lists.infradead.org","X-Mailman-Version":"2.1.34","Precedence":"list","List-Id":"Linux MTD discussion mailing list <linux-mtd.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-mtd>,\n <mailto:linux-mtd-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-mtd/>","List-Post":"<mailto:linux-mtd@lists.infradead.org>","List-Help":"<mailto:linux-mtd-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n <mailto:linux-mtd-request@lists.infradead.org?subject=subscribe>","Content-Transfer-Encoding":"base64","Content-Type":"text/plain; charset=\"gbk\"; Format=\"flowed\"","Sender":"\"linux-mtd\" <linux-mtd-bounces@lists.infradead.org>","Errors-To":"linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"}}]