From patchwork Mon Oct 25 04:05:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 12580661 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF94AC433EF for ; Mon, 25 Oct 2021 04:05:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B191C60F46 for ; Mon, 25 Oct 2021 04:05:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231821AbhJYEHl (ORCPT ); Mon, 25 Oct 2021 00:07:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbhJYEHk (ORCPT ); Mon, 25 Oct 2021 00:07:40 -0400 Received: from smtp01.aussiebb.com.au (smtp01.aussiebb.com.au [IPv6:2403:5800:3:25::1001]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 045B4C061745; Sun, 24 Oct 2021 21:05:18 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id 16894100281; Mon, 25 Oct 2021 15:05:14 +1100 (AEDT) X-Virus-Scanned: Debian amavisd-new at smtp01.aussiebb.com.au Received: from smtp01.aussiebb.com.au ([127.0.0.1]) by localhost (smtp01.aussiebb.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 30-6G5htNg-C; Mon, 25 Oct 2021 15:05:14 +1100 (AEDT) Received: by smtp01.aussiebb.com.au (Postfix, from userid 116) id 06819100328; Mon, 25 Oct 2021 15:05:14 +1100 (AEDT) Received: from mickey.themaw.net (unknown [100.72.131.210]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id 51AAE100281; Mon, 25 Oct 2021 15:05:12 +1100 (AEDT) Subject: [PATCH 1/2] vfs: parse: deal with zero length string value From: Ian Kent To: Al Viro Cc: David Howells , Miklos Szeredi , Carlos Maiolino , linux-fsdevel , Kernel Mailing List Date: Mon, 25 Oct 2021 12:05:06 +0800 Message-ID: <163513470696.40352.1069626993439788071.stgit@mickey.themaw.net> User-Agent: StGit/0.23 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Ian Kent 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. Signed-off-by: Ian Kent --- fs/fs_context.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/fs_context.c b/fs/fs_context.c index b7e43a780a62..a949cceccbfd 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -175,9 +175,13 @@ int vfs_parse_fs_string(struct fs_context *fc, const char *key, }; if (value) { - param.string = kmemdup_nul(value, v_size, GFP_KERNEL); - if (!param.string) - return -ENOMEM; + if (!v_size) + param.string = NULL; + else { + param.string = kmemdup_nul(value, v_size, GFP_KERNEL); + if (!param.string) + return -ENOMEM; + } param.type = fs_value_is_string; }