diff options
author | Thomas Weißschuh <linux@weissschuh.net> | 2023-06-07 19:28:48 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-07-19 16:36:54 +0200 |
commit | f80436e4f788625f24bdb6e872cb6cc66b06be17 (patch) | |
tree | 37cc2b9187ce3830f9fdf9cd8c03274479be8eab /fs | |
parent | fb306470cadac7178c58b0c0f8226f278df04fc4 (diff) | |
download | linux-stable-f80436e4f788625f24bdb6e872cb6cc66b06be17.tar.gz linux-stable-f80436e4f788625f24bdb6e872cb6cc66b06be17.tar.bz2 linux-stable-f80436e4f788625f24bdb6e872cb6cc66b06be17.zip |
fs: avoid empty option when generating legacy mount string
commit 62176420274db5b5127cd7a0083a9aeb461756ee upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fs_context.c | 3 |
1 files changed, 2 insertions, 1 deletions
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; |