From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35E8DC433FE for ; Tue, 18 Oct 2022 01:55:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230307AbiJRBzb (ORCPT ); Mon, 17 Oct 2022 21:55:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230304AbiJRBz1 (ORCPT ); Mon, 17 Oct 2022 21:55:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 074FC3887; Mon, 17 Oct 2022 18:55:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 93C7B612F4; Tue, 18 Oct 2022 01:55:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADB2EC433C1; Tue, 18 Oct 2022 01:55:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1666058125; bh=igcQugxTzwIP0PYHpWw1TgW9tEWJhVuc8WaXwlkC/Ok=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pWk9ZE6ZgxOhyz8+YbsYxk4DbRYG+eJfnTSaDfEw5L0oHwDlqnFhF7X2RKWCJ3xiw a+l7VKQAFH39/1QkFwV03tTCE/RYQwQVtIbVzFGePGML7pBVzLaEqfc9f313SRqAsB D4yiNzfpDPFoNp0yTNeFlOkoC6RaDOp0CNwC+NP4= Date: Mon, 17 Oct 2022 18:55:23 -0700 From: Andrew Morton To: Ian Kent Cc: Al Viro , Siddhesh Poyarekar , David Howells , Miklos Szeredi , Carlos Maiolino , linux-fsdevel , Kernel Mailing List Subject: Re: [REPOST PATCH v3 2/2] vfs: parse: deal with zero length string value Message-Id: <20221017185523.22f43b5d7f9fee1e1e3d872f@linux-foundation.org> In-Reply-To: <166365878918.39016.12757946948158123324.stgit@donald.themaw.net> References: <166365872189.39016.10771273319597352356.stgit@donald.themaw.net> <166365878918.39016.12757946948158123324.stgit@donald.themaw.net> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 20 Sep 2022 15:26:29 +0800 Ian Kent wrote: > Parsing an fs string that has zero length should result in the parameter > being set to NULL so that downstream processing handles it correctly. > For example, the proc mount table processing should print "(none)" in > this case to preserve mount record field count, but if the value points > to the NULL string this doesn't happen. > > ... > > --- a/fs/fs_parser.c > +++ b/fs/fs_parser.c > @@ -197,6 +197,8 @@ int fs_param_is_bool(struct p_log *log, const struct fs_parameter_spec *p, > struct fs_parameter *param, struct fs_parse_result *result) > { > int b; > + if (param->type == fs_value_is_empty) > + return 0; > if (param->type != fs_value_is_string) > return fs_param_bad_value(log, param); > if (!*param->string && (p->flags & fs_param_can_be_empty)) > @@ -213,6 +215,8 @@ int fs_param_is_u32(struct p_log *log, const struct fs_parameter_spec *p, > struct fs_parameter *param, struct fs_parse_result *result) > { > int base = (unsigned long)p->data; > + if (param->type == fs_value_is_empty) > + return 0; > if (param->type != fs_value_is_string) > return fs_param_bad_value(log, param); > if (!*param->string && (p->flags & fs_param_can_be_empty)) > > [etcetera] This feels wrong. Having to check for fs_value_is_empty in so many places makes me think "we just shouldn't have got this far". Am I right for once?