diff options
Diffstat (limited to 'fs/befs/linuxvfs.c')
-rw-r--r-- | fs/befs/linuxvfs.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index cf7f3c67c8b7..7f73a692bfd0 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/vfs.h> | 15 | #include <linux/vfs.h> |
16 | #include <linux/parser.h> | 16 | #include <linux/parser.h> |
17 | #include <linux/namei.h> | 17 | #include <linux/namei.h> |
18 | #include <linux/sched.h> | ||
18 | 19 | ||
19 | #include "befs.h" | 20 | #include "befs.h" |
20 | #include "btree.h" | 21 | #include "btree.h" |
@@ -352,9 +353,11 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino) | |||
352 | */ | 353 | */ |
353 | 354 | ||
354 | inode->i_uid = befs_sb->mount_opts.use_uid ? | 355 | inode->i_uid = befs_sb->mount_opts.use_uid ? |
355 | befs_sb->mount_opts.uid : (uid_t) fs32_to_cpu(sb, raw_inode->uid); | 356 | befs_sb->mount_opts.uid : |
357 | make_kuid(&init_user_ns, fs32_to_cpu(sb, raw_inode->uid)); | ||
356 | inode->i_gid = befs_sb->mount_opts.use_gid ? | 358 | inode->i_gid = befs_sb->mount_opts.use_gid ? |
357 | befs_sb->mount_opts.gid : (gid_t) fs32_to_cpu(sb, raw_inode->gid); | 359 | befs_sb->mount_opts.gid : |
360 | make_kgid(&init_user_ns, fs32_to_cpu(sb, raw_inode->gid)); | ||
358 | 361 | ||
359 | set_nlink(inode, 1); | 362 | set_nlink(inode, 1); |
360 | 363 | ||
@@ -674,10 +677,12 @@ parse_options(char *options, befs_mount_options * opts) | |||
674 | char *p; | 677 | char *p; |
675 | substring_t args[MAX_OPT_ARGS]; | 678 | substring_t args[MAX_OPT_ARGS]; |
676 | int option; | 679 | int option; |
680 | kuid_t uid; | ||
681 | kgid_t gid; | ||
677 | 682 | ||
678 | /* Initialize options */ | 683 | /* Initialize options */ |
679 | opts->uid = 0; | 684 | opts->uid = GLOBAL_ROOT_UID; |
680 | opts->gid = 0; | 685 | opts->gid = GLOBAL_ROOT_GID; |
681 | opts->use_uid = 0; | 686 | opts->use_uid = 0; |
682 | opts->use_gid = 0; | 687 | opts->use_gid = 0; |
683 | opts->iocharset = NULL; | 688 | opts->iocharset = NULL; |
@@ -696,23 +701,29 @@ parse_options(char *options, befs_mount_options * opts) | |||
696 | case Opt_uid: | 701 | case Opt_uid: |
697 | if (match_int(&args[0], &option)) | 702 | if (match_int(&args[0], &option)) |
698 | return 0; | 703 | return 0; |
699 | if (option < 0) { | 704 | uid = INVALID_UID; |
705 | if (option >= 0) | ||
706 | uid = make_kuid(current_user_ns(), option); | ||
707 | if (!uid_valid(uid)) { | ||
700 | printk(KERN_ERR "BeFS: Invalid uid %d, " | 708 | printk(KERN_ERR "BeFS: Invalid uid %d, " |
701 | "using default\n", option); | 709 | "using default\n", option); |
702 | break; | 710 | break; |
703 | } | 711 | } |
704 | opts->uid = option; | 712 | opts->uid = uid; |
705 | opts->use_uid = 1; | 713 | opts->use_uid = 1; |
706 | break; | 714 | break; |
707 | case Opt_gid: | 715 | case Opt_gid: |
708 | if (match_int(&args[0], &option)) | 716 | if (match_int(&args[0], &option)) |
709 | return 0; | 717 | return 0; |
710 | if (option < 0) { | 718 | gid = INVALID_GID; |
719 | if (option >= 0) | ||
720 | gid = make_kgid(current_user_ns(), option); | ||
721 | if (!gid_valid(gid)) { | ||
711 | printk(KERN_ERR "BeFS: Invalid gid %d, " | 722 | printk(KERN_ERR "BeFS: Invalid gid %d, " |
712 | "using default\n", option); | 723 | "using default\n", option); |
713 | break; | 724 | break; |
714 | } | 725 | } |
715 | opts->gid = option; | 726 | opts->gid = gid; |
716 | opts->use_gid = 1; | 727 | opts->use_gid = 1; |
717 | break; | 728 | break; |
718 | case Opt_charset: | 729 | case Opt_charset: |