Skip to content

Commit 20be746

Browse files
author
Al Viro
committed
ufs: reject multiple conflicting -o ufstype=... on mount
Have ufs_parse_options() refuse to change an already set flavour, and move the "can't change the flavour" logics on remount there, while we are at it - the only difference is that flavour is already set. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent f8e7791 commit 20be746

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

fs/ufs/super.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static const match_table_t tokens = {
380380
{Opt_err, NULL}
381381
};
382382

383-
static int ufs_parse_options(char *options, unsigned *flavour, unsigned *on_err)
383+
static int ufs_parse_options(char *options, unsigned *flavour, unsigned *on_err, bool remount)
384384
{
385385
char * p;
386386

@@ -392,6 +392,7 @@ static int ufs_parse_options(char *options, unsigned *flavour, unsigned *on_err)
392392
while ((p = strsep(&options, ",")) != NULL) {
393393
substring_t args[MAX_OPT_ARGS];
394394
int token;
395+
unsigned int old = *flavour;
395396
if (!*p)
396397
continue;
397398

@@ -444,6 +445,15 @@ static int ufs_parse_options(char *options, unsigned *flavour, unsigned *on_err)
444445
pr_err("Invalid option: \"%s\" or missing value\n", p);
445446
return 0;
446447
}
448+
if (*flavour == old)
449+
continue;
450+
if (!old)
451+
continue;
452+
if (remount)
453+
pr_err("ufstype can't be changed during remount\n");
454+
else
455+
pr_err("conflicting ufstype options\n");
456+
return 0;
447457
}
448458
return 1;
449459
}
@@ -795,7 +805,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
795805
*/
796806
sbi->s_flavour = 0;
797807
sbi->s_on_err = UFS_MOUNT_ONERROR_LOCK;
798-
if (!ufs_parse_options(data, &sbi->s_flavour, &sbi->s_on_err)) {
808+
if (!ufs_parse_options(data, &sbi->s_flavour, &sbi->s_on_err, false)) {
799809
pr_err("wrong mount options\n");
800810
goto failed;
801811
}
@@ -1295,16 +1305,9 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
12951305
* Allow the "check" option to be passed as a remount option.
12961306
* It is not possible to change ufstype option during remount
12971307
*/
1298-
ufstype = 0;
1308+
ufstype = UFS_SB(sb)->s_flavour;
12991309
on_err = UFS_MOUNT_ONERROR_LOCK;
1300-
if (!ufs_parse_options(data, &ufstype, &on_err)) {
1301-
mutex_unlock(&UFS_SB(sb)->s_lock);
1302-
return -EINVAL;
1303-
}
1304-
if (!ufstype)
1305-
ufstype = UFS_SB(sb)->s_flavour;
1306-
else if (ufstype != UFS_SB(sb)->s_flavour) {
1307-
pr_err("ufstype can't be changed during remount\n");
1310+
if (!ufs_parse_options(data, &ufstype, &on_err, true)) {
13081311
mutex_unlock(&UFS_SB(sb)->s_lock);
13091312
return -EINVAL;
13101313
}

0 commit comments

Comments
 (0)