]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs: avoid empty option when generating legacy mount string
authorThomas Weißschuh <linux@weissschuh.net>
Wed, 7 Jun 2023 17:28:48 +0000 (19:28 +0200)
committerChristian Brauner <brauner@kernel.org>
Wed, 7 Jun 2023 19:49:55 +0000 (21:49 +0200)
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
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Fixes: 3e1aeb00e6d1 ("vfs: Implement a filesystem superblock creation/configuration context")
Cc: stable@vger.kernel.org
Message-Id: <20230607-fs-empty-option-v1-1-20c8dbf4671b@weissschuh.net>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/fs_context.c

index 24ce12f0db32e5779d389ebcc8c49e9b35ecb9e0..851214d1d013dce8d385dddb31f331b03e7c9bf6 100644 (file)
@@ -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;