diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2010-01-24 00:04:07 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-01-26 22:22:24 -0500 |
commit | 29333920a5a46edcc9b728e2cf0134d5a9b516ee (patch) | |
tree | 2991b9f6d82d43c712278d6364da4faad4a0180d /fs/affs/super.c | |
parent | afc70ed05a07bfe171f7a5b8fdc80bdb073d314f (diff) |
Fix remount races with symlink handling in affs
A couple of fields in affs_sb_info is used in follow_link() and
symlink() for handling AFFS "absolute" symlinks. Need locking
against affs_remount() updates.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/affs/super.c')
-rw-r--r-- | fs/affs/super.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/fs/affs/super.c b/fs/affs/super.c index b2a5958c6191..be6a6e8ed7d6 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c | |||
@@ -221,8 +221,6 @@ parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s | |||
221 | *mount_opts |= SF_MUFS; | 221 | *mount_opts |= SF_MUFS; |
222 | break; | 222 | break; |
223 | case Opt_prefix: | 223 | case Opt_prefix: |
224 | /* Free any previous prefix */ | ||
225 | kfree(*prefix); | ||
226 | *prefix = match_strdup(&args[0]); | 224 | *prefix = match_strdup(&args[0]); |
227 | if (!*prefix) | 225 | if (!*prefix) |
228 | return 0; | 226 | return 0; |
@@ -311,6 +309,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) | |||
311 | return -ENOMEM; | 309 | return -ENOMEM; |
312 | sb->s_fs_info = sbi; | 310 | sb->s_fs_info = sbi; |
313 | mutex_init(&sbi->s_bmlock); | 311 | mutex_init(&sbi->s_bmlock); |
312 | spin_lock_init(&sbi->symlink_lock); | ||
314 | 313 | ||
315 | if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, | 314 | if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, |
316 | &blocksize,&sbi->s_prefix, | 315 | &blocksize,&sbi->s_prefix, |
@@ -518,14 +517,18 @@ affs_remount(struct super_block *sb, int *flags, char *data) | |||
518 | unsigned long mount_flags; | 517 | unsigned long mount_flags; |
519 | int res = 0; | 518 | int res = 0; |
520 | char *new_opts = kstrdup(data, GFP_KERNEL); | 519 | char *new_opts = kstrdup(data, GFP_KERNEL); |
520 | char volume[32]; | ||
521 | char *prefix = NULL; | ||
521 | 522 | ||
522 | pr_debug("AFFS: remount(flags=0x%x,opts=\"%s\")\n",*flags,data); | 523 | pr_debug("AFFS: remount(flags=0x%x,opts=\"%s\")\n",*flags,data); |
523 | 524 | ||
524 | *flags |= MS_NODIRATIME; | 525 | *flags |= MS_NODIRATIME; |
525 | 526 | ||
527 | memcpy(volume, sbi->s_volume, 32); | ||
526 | if (!parse_options(data, &uid, &gid, &mode, &reserved, &root_block, | 528 | if (!parse_options(data, &uid, &gid, &mode, &reserved, &root_block, |
527 | &blocksize, &sbi->s_prefix, sbi->s_volume, | 529 | &blocksize, &prefix, volume, |
528 | &mount_flags)) { | 530 | &mount_flags)) { |
531 | kfree(prefix); | ||
529 | kfree(new_opts); | 532 | kfree(new_opts); |
530 | return -EINVAL; | 533 | return -EINVAL; |
531 | } | 534 | } |
@@ -536,6 +539,14 @@ affs_remount(struct super_block *sb, int *flags, char *data) | |||
536 | sbi->s_mode = mode; | 539 | sbi->s_mode = mode; |
537 | sbi->s_uid = uid; | 540 | sbi->s_uid = uid; |
538 | sbi->s_gid = gid; | 541 | sbi->s_gid = gid; |
542 | /* protect against readers */ | ||
543 | spin_lock(&sbi->symlink_lock); | ||
544 | if (prefix) { | ||
545 | kfree(sbi->s_prefix); | ||
546 | sbi->s_prefix = prefix; | ||
547 | } | ||
548 | memcpy(sbi->s_volume, volume, 32); | ||
549 | spin_unlock(&sbi->symlink_lock); | ||
539 | 550 | ||
540 | if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) { | 551 | if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) { |
541 | unlock_kernel(); | 552 | unlock_kernel(); |