Skip to content

Commit 31aba05

Browse files
committed
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>
1 parent c010d1f commit 31aba05

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

‎fs/befs/befs.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ typedef u64 befs_blocknr_t;
2020
*/
2121

2222
typedef struct befs_mount_options {
23-
gid_t gid;
24-
uid_t uid;
23+
kgid_t gid;
24+
kuid_t uid;
2525
int use_gid;
2626
int use_uid;
2727
int debug;

‎fs/befs/linuxvfs.c‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/vfs.h>
1616
#include <linux/parser.h>
1717
#include <linux/namei.h>
18+
#include <linux/sched.h>
1819

1920
#include "befs.h"
2021
#include "btree.h"
@@ -352,9 +353,11 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
352353
*/
353354

354355
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));
356358
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));
358361

359362
set_nlink(inode, 1);
360363

@@ -674,10 +677,12 @@ parse_options(char *options, befs_mount_options * opts)
674677
char *p;
675678
substring_t args[MAX_OPT_ARGS];
676679
int option;
680+
kuid_t uid;
681+
kgid_t gid;
677682

678683
/* Initialize options */
679-
opts->uid = 0;
680-
opts->gid = 0;
684+
opts->uid = GLOBAL_ROOT_UID;
685+
opts->gid = GLOBAL_ROOT_GID;
681686
opts->use_uid = 0;
682687
opts->use_gid = 0;
683688
opts->iocharset = NULL;
@@ -696,23 +701,29 @@ parse_options(char *options, befs_mount_options * opts)
696701
case Opt_uid:
697702
if (match_int(&args[0], &option))
698703
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)) {
700708
printk(KERN_ERR "BeFS: Invalid uid %d, "
701709
"using default\n", option);
702710
break;
703711
}
704-
opts->uid = option;
712+
opts->uid = uid;
705713
opts->use_uid = 1;
706714
break;
707715
case Opt_gid:
708716
if (match_int(&args[0], &option))
709717
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)) {
711722
printk(KERN_ERR "BeFS: Invalid gid %d, "
712723
"using default\n", option);
713724
break;
714725
}
715-
opts->gid = option;
726+
opts->gid = gid;
716727
opts->use_gid = 1;
717728
break;
718729
case Opt_charset:

‎init/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,6 @@ config UIDGID_CONVERTED
936936
depends on AFFS_FS = n
937937
depends on AFS_FS = n
938938
depends on AUTOFS4_FS = n
939-
depends on BEFS_FS = n
940939
depends on BFS_FS = n
941940
depends on BTRFS_FS = n
942941
depends on CEPH_FS = n

0 commit comments

Comments
 (0)