aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-02-10 13:51:24 -0500
committerEric W. Biederman <ebiederm@xmission.com>2012-09-21 06:13:08 -0400
commit31aba059bb9522ff730301a7d567117fcff0952c (patch)
tree71bcb1171eb84e7ea7b0c548239fcb858c18e6db /fs
parentc010d1ff4f69c9f4aa331dfd8266262fb1b478ce (diff)
userns: Convert befs to use kuid/kgid where appropriate
Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/befs/befs.h4
-rw-r--r--fs/befs/linuxvfs.c27
2 files changed, 21 insertions, 10 deletions
diff --git a/fs/befs/befs.h b/fs/befs/befs.h
index d9a40abda6b7..b26642839156 100644
--- a/fs/befs/befs.h
+++ b/fs/befs/befs.h
@@ -20,8 +20,8 @@ typedef u64 befs_blocknr_t;
20 */ 20 */
21 21
22typedef struct befs_mount_options { 22typedef struct befs_mount_options {
23 gid_t gid; 23 kgid_t gid;
24 uid_t uid; 24 kuid_t uid;
25 int use_gid; 25 int use_gid;
26 int use_uid; 26 int use_uid;
27 int debug; 27 int debug;
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: