Message ID | 20230607-fs-empty-option-v1-1-20c8dbf4671b@weissschuh.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp379496vqr; Wed, 7 Jun 2023 10:54:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ46v53SB9pB8m5mNfcV+xhHcoNxCxoSsk5rbCN0SMsrJcBZZPYXKLDDrCyQfmGqZ/oiBJaP X-Received: by 2002:a05:6a00:b4b:b0:662:5146:c761 with SMTP id p11-20020a056a000b4b00b006625146c761mr2516077pfo.17.1686160467202; Wed, 07 Jun 2023 10:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686160467; cv=none; d=google.com; s=arc-20160816; b=rpW3RE6C/RDpejS8dR60pPnd1+57JVKHcxYH/Z9hoD2dlMKrl3D5leXHlJFBy02yqP wJpa6NgSFnpdZ0WuZa6wcTAHDHjDQjGGU3dcZoruisWmGNxtoV5cylncCjzPLAm2jQqY DieY4lgvooXW33Jb0SAuLXpzlahhhYnBVxXaSntJbcq6kx4dkaZXFqHhqrPRXHxQNnrc U6kJgDUIJ7bKmnPM83wdDwU96i4se5gmIy6i4Tpo6Zu1LpiHSe1XE0J+RnCCbpVTLeEX hMD013pbdoffySbyjzx0ldLgXeeP+SZi6gL+emXeHNErd9DkI46dMk2vvloO5aeSaoDn sYLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:dkim-signature:from; bh=rSFLDeg//MATy4wRPYzPvpAlJi/Om/Q2dfHBbonUMYg=; b=fOAfCGZsL6NV7TYbisTFBChEBVJ0MDvb9qA1hb2WUAoUNqVwDkUn+b+/lK1+YdqdAe 0hSSXTIhri9RzWuw7VbUenWXHrlgPE81NgyNNkWNYX1mZJCwgnxHxZCfnhRGB0xHG4uk 7Xr7f91Ynl0ENNmqCDmOO0Df1OnFdB14z+Yy8t0LaAU57siz5FBi9UKNnltOcbE2TceM F+dgxzhvlIUjrrFWwxoaRWX0zyXnhY91QIi9UoY4BhtDrqQkSL9KHvVLRtfB5arM+v+B fJ0HIzi9GlWJ/gqapJPf2mJ72bThbirzrTyJvbVKRnceTZMcnkTrASmymaDhRhqV+b+R xauA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=REuygNSS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z6-20020a63ac46000000b00543d2bba30fsi3945200pgn.575.2023.06.07.10.54.14; Wed, 07 Jun 2023 10:54:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=REuygNSS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230508AbjFGR27 (ORCPT <rfc822;literming00@gmail.com> + 99 others); Wed, 7 Jun 2023 13:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjFGR24 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 7 Jun 2023 13:28:56 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7F1A128; Wed, 7 Jun 2023 10:28:54 -0700 (PDT) From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= <linux@weissschuh.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1686158932; bh=vGUG5+5oObmVUMabCNgsKcKkHQm2lWjGYzZ1M+89FSk=; h=From:Date:Subject:To:Cc:From; b=REuygNSSwrT5jIxKvsN28vuZ/cs8XfMn+12DSgMfY5RxhC+sWXCL9vc0tEytMCjQb 05pt0RsH6dJanwO3393YuAXrE1zqO2ney6umLmXj3kDGfwVqlFC/RHjg0RNyCrbwdU eHtFD9DbByXTIhE8zIJxwvMM0Z0LZFEu3kmHU+5c= Date: Wed, 07 Jun 2023 19:28:48 +0200 Subject: [PATCH] fs: avoid empty option when generating legacy mount string MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20230607-fs-empty-option-v1-1-20c8dbf4671b@weissschuh.net> X-B4-Tracking: v=1; b=H4sIAE++gGQC/x2N0QqDMAxFf0XybKBGVmG/MnxoNc6Aq6VR2RD/3 bDHczmHe4JyEVZ4VicUPkRlTQZNXcEwh/RmlNEYyFHrvOtwUuRP3n645s1cJP/wRG3XmABWxaC MsYQ0zNalfVlszIUn+f5vXv113XtkcZx2AAAA To: Alexander Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org> Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, David Howells <dhowells@redhat.com>, Karel Zak <kzag@redhat.com>, stable@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= <linux@weissschuh.net> X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1686158931; l=1248; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=vGUG5+5oObmVUMabCNgsKcKkHQm2lWjGYzZ1M+89FSk=; b=xhti7ZhwZRPSH3Hgfw1or7/06qz18rCyqWGpAlyNjvbuso7uaeCsOL0oGQ/kvzetFYV78p9r5 vOP30ikcCPeC3hE7I9eZEjC4UjhTsX05D9hBZJk67VLhQwwASbWhNsn X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768066963251234880?= X-GMAIL-MSGID: =?utf-8?q?1768067397831481268?= |
Series |
fs: avoid empty option when generating legacy mount string
|
|
Commit Message
Thomas Weißschuh
June 7, 2023, 5:28 p.m. UTC
As each option string fragment is always prepended with a comma it would
happen that the whole string always starts with a comma.
This could be interpreted by filesystem drivers as an empty option and
may produce errors.
For example the NTFS driver from ntfs.ko behaves like this and fails when
mounted via the new API.
Link: https://github.com/util-linux/util-linux/issues/2298
Fixes: 3e1aeb00e6d1 ("vfs: Implement a filesystem superblock creation/configuration context")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
fs/fs_context.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
---
base-commit: 9561de3a55bed6bdd44a12820ba81ec416e705a7
change-id: 20230607-fs-empty-option-265622371023
Best regards,
Comments
On Wed, Jun 07, 2023 at 07:28:48PM +0200, Thomas Weißschuh wrote: > As each option string fragment is always prepended with a comma it would > happen that the whole string always starts with a comma. > This could be interpreted by filesystem drivers as an empty option and > may produce errors. > > For example the NTFS driver from ntfs.ko behaves like this and fails when > mounted via the new API. > > Link: https://github.com/util-linux/util-linux/issues/2298 Yeah, the old ntfs driver implements its own option parser. It overwrites/splits at ',' returning '\0' and then trips over this. Contrast with e.g., ovl_next_op() which does the same thing but skips over '\0' in ovl_parse_opt(). So arguably also a bug in ntfs parsing. But there's no reason we should prepend ',' for legacy mount option strings. And yeah, I can easily verify this... Using my custom move-mount tool I originally wrote for another patchset but which is handy to pass mount options via the new mount api _system_ calls and not via mount(): https://github.com/brauner/move-mount-beneath I can do: sudo ./move-mount -f overlay -olowerdir=/mnt/a:/mnt/b,upperdir=/mnt/upper,workdir=/mnt/work /mnt/merged and clearly see: > sudo bpftrace -e 'kfunc:legacy_get_tree { @m = args->fc; printf("%s\n", str(((struct legacy_fs_context *)@m->fs_private)->legacy_data)); }' Attaching 1 probe... ,lowerdir=/mnt/a:/mnt/b,upperdir=/mnt/upper,workdir=/mnt/work > Fixes: 3e1aeb00e6d1 ("vfs: Implement a filesystem superblock creation/configuration context") Should be: Fixes: commit 3e1aeb00e6d1 ("vfs: Implement a filesystem superblock creation/configuration context") and misses a: Cc: stable@vger.kernel.org I'll fix this up for you though.
On 2023-06-07 21:39:01+0200, Christian Brauner wrote: > On Wed, Jun 07, 2023 at 07:28:48PM +0200, Thomas Weißschuh wrote: > > As each option string fragment is always prepended with a comma it would > > happen that the whole string always starts with a comma. > > This could be interpreted by filesystem drivers as an empty option and > > may produce errors. > > > > For example the NTFS driver from ntfs.ko behaves like this and fails when > > mounted via the new API. > > > > Link: https://github.com/util-linux/util-linux/issues/2298 > > Yeah, the old ntfs driver implements its own option parser. It > overwrites/splits at ',' returning '\0' and then trips over this. > > Contrast with e.g., ovl_next_op() which does the same thing but skips > over '\0' in ovl_parse_opt(). > > So arguably also a bug in ntfs parsing. But there's no reason we should > prepend ',' for legacy mount option strings. > > And yeah, I can easily verify this... > > Using my custom move-mount tool I originally wrote for another patchset > but which is handy to pass mount options via the new mount api _system_ > calls and not via mount(): > https://github.com/brauner/move-mount-beneath > > I can do: > > sudo ./move-mount -f overlay -olowerdir=/mnt/a:/mnt/b,upperdir=/mnt/upper,workdir=/mnt/work /mnt/merged > > and clearly see: > > > sudo bpftrace -e 'kfunc:legacy_get_tree { @m = args->fc; printf("%s\n", str(((struct legacy_fs_context *)@m->fs_private)->legacy_data)); }' > Attaching 1 probe... > ,lowerdir=/mnt/a:/mnt/b,upperdir=/mnt/upper,workdir=/mnt/work > > > Fixes: 3e1aeb00e6d1 ("vfs: Implement a filesystem superblock creation/configuration context") > > Should be: > > Fixes: commit 3e1aeb00e6d1 ("vfs: Implement a filesystem superblock creation/configuration context") AFAIK the Fixes: tag does not use the "commit" keyword. Only inline commit references. This is how it's currently documented in Documentation/process/submitting-patches.rst. > and misses a: > > Cc: stable@vger.kernel.org This was fixed in v2. > I'll fix this up for you though. Thanks! Thomas
On Wed, 07 Jun 2023 19:28:48 +0200, Thomas Weißschuh wrote: > As each option string fragment is always prepended with a comma it would > happen that the whole string always starts with a comma. > This could be interpreted by filesystem drivers as an empty option and > may produce errors. > > For example the NTFS driver from ntfs.ko behaves like this and fails when > mounted via the new API. > > [...] Applied to the vfs.misc branch of the vfs/vfs.git tree. Patches in the vfs.misc branch should appear in linux-next soon. Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it. It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated. tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.misc [1/1] fs: avoid empty option when generating legacy mount string https://git.kernel.org/vfs/vfs/c/de3824801c82
diff --git a/fs/fs_context.c b/fs/fs_context.c index 24ce12f0db32..851214d1d013 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -561,7 +561,8 @@ static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param) return -ENOMEM; } - ctx->legacy_data[size++] = ','; + if (size) + ctx->legacy_data[size++] = ','; len = strlen(param->key); memcpy(ctx->legacy_data + size, param->key, len); size += len;