From: "Eric W. Biederman" <ebiederm@xmission.com>
To: <linux-fsdevel@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, Serge Hallyn <serge@hallyn.com>,
Linux Containers <containers@lists.linux-foundation.org>,
"Eric W. Biederman" <ebiederm@xmission.com>
Subject: [PATCH 08/25] userns: Convert befs to use kuid/kgid where appropriate
Date: Thu, 20 Sep 2012 04:41:49 -0700 [thread overview]
Message-ID: <1348141326-23355-8-git-send-email-ebiederm@xmission.com> (raw)
In-Reply-To: <1348141326-23355-1-git-send-email-ebiederm@xmission.com>
From: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
fs/befs/befs.h | 4 ++--
fs/befs/linuxvfs.c | 27 +++++++++++++++++++--------
init/Kconfig | 1 -
3 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/fs/befs/befs.h b/fs/befs/befs.h
index d9a40ab..b266428 100644
--- a/fs/befs/befs.h
+++ b/fs/befs/befs.h
@@ -20,8 +20,8 @@ typedef u64 befs_blocknr_t;
*/
typedef struct befs_mount_options {
- gid_t gid;
- uid_t uid;
+ kgid_t gid;
+ kuid_t uid;
int use_gid;
int use_uid;
int debug;
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index cf7f3c6..7f73a69 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -15,6 +15,7 @@
#include <linux/vfs.h>
#include <linux/parser.h>
#include <linux/namei.h>
+#include <linux/sched.h>
#include "befs.h"
#include "btree.h"
@@ -352,9 +353,11 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
*/
inode->i_uid = befs_sb->mount_opts.use_uid ?
- befs_sb->mount_opts.uid : (uid_t) fs32_to_cpu(sb, raw_inode->uid);
+ befs_sb->mount_opts.uid :
+ make_kuid(&init_user_ns, fs32_to_cpu(sb, raw_inode->uid));
inode->i_gid = befs_sb->mount_opts.use_gid ?
- befs_sb->mount_opts.gid : (gid_t) fs32_to_cpu(sb, raw_inode->gid);
+ befs_sb->mount_opts.gid :
+ make_kgid(&init_user_ns, fs32_to_cpu(sb, raw_inode->gid));
set_nlink(inode, 1);
@@ -674,10 +677,12 @@ parse_options(char *options, befs_mount_options * opts)
char *p;
substring_t args[MAX_OPT_ARGS];
int option;
+ kuid_t uid;
+ kgid_t gid;
/* Initialize options */
- opts->uid = 0;
- opts->gid = 0;
+ opts->uid = GLOBAL_ROOT_UID;
+ opts->gid = GLOBAL_ROOT_GID;
opts->use_uid = 0;
opts->use_gid = 0;
opts->iocharset = NULL;
@@ -696,23 +701,29 @@ parse_options(char *options, befs_mount_options * opts)
case Opt_uid:
if (match_int(&args[0], &option))
return 0;
- if (option < 0) {
+ uid = INVALID_UID;
+ if (option >= 0)
+ uid = make_kuid(current_user_ns(), option);
+ if (!uid_valid(uid)) {
printk(KERN_ERR "BeFS: Invalid uid %d, "
"using default\n", option);
break;
}
- opts->uid = option;
+ opts->uid = uid;
opts->use_uid = 1;
break;
case Opt_gid:
if (match_int(&args[0], &option))
return 0;
- if (option < 0) {
+ gid = INVALID_GID;
+ if (option >= 0)
+ gid = make_kgid(current_user_ns(), option);
+ if (!gid_valid(gid)) {
printk(KERN_ERR "BeFS: Invalid gid %d, "
"using default\n", option);
break;
}
- opts->gid = option;
+ opts->gid = gid;
opts->use_gid = 1;
break;
case Opt_charset:
diff --git a/init/Kconfig b/init/Kconfig
index 20ddf0d..d9bb344 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -936,7 +936,6 @@ config UIDGID_CONVERTED
depends on AFFS_FS = n
depends on AFS_FS = n
depends on AUTOFS4_FS = n
- depends on BEFS_FS = n
depends on BFS_FS = n
depends on BTRFS_FS = n
depends on CEPH_FS = n
--
1.7.5.4
next prev parent reply other threads:[~2012-09-20 11:43 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-20 11:40 [REVIEW][PATCH 00/25] userns: Trivial filesystem conversions Eric W. Biederman
2012-09-20 11:41 ` [PATCH 01/25] userns: Convert fat to use kuid/kgid where appropriate Eric W. Biederman
2012-09-20 11:41 ` [PATCH 02/25] userns: Convert gadgetfs to use kuid and kgid " Eric W. Biederman
2012-09-20 11:58 ` Greg Kroah-Hartman
2012-09-21 9:33 ` Felipe Balbi
2012-09-20 11:41 ` [PATCH 03/25] userns: Convert usb functionfs to use kuid/kgid " Eric W. Biederman
2012-09-20 11:58 ` Greg Kroah-Hartman
2012-09-21 9:32 ` Felipe Balbi
2012-09-20 11:41 ` [PATCH 04/25] userns: Convert devtmpfs to use GLOBAL_ROOT_UID and GLOBAL_ROOT_GID Eric W. Biederman
2012-09-20 11:58 ` Greg Kroah-Hartman
2012-09-20 11:41 ` [PATCH 05/25] userns: Convert hugetlbfs to use kuid/kgid where appropriate Eric W. Biederman
2012-09-20 11:41 ` [PATCH 06/25] userns: Convert xenfs to use kuid and kgid " Eric W. Biederman
2012-09-20 11:41 ` [PATCH 07/25] userns: Convert adfs " Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman [this message]
2012-09-20 11:41 ` [PATCH 09/25] userns: Convert cramfs to use kuid/kgid " Eric W. Biederman
2012-09-20 11:41 ` [PATCH 10/25] userns: Convert ecryptfs " Eric W. Biederman
2012-09-20 11:41 ` [PATCH 11/25] userns: Convert efs " Eric W. Biederman
2012-09-20 11:41 ` [PATCH 12/25] userns: Convert exofs " Eric W. Biederman
2012-09-20 12:20 ` Boaz Harrosh
2012-09-20 11:41 ` [PATCH 13/25] userns: Convert hfs to use kuid and kgid " Eric W. Biederman
2012-09-20 11:41 ` [PATCH 14/25] userns: Convert hfsplus " Eric W. Biederman
2012-09-20 11:41 ` [PATCH 15/25] userns: Convert isofs to use kuid/kgid " Eric W. Biederman
2012-09-20 11:41 ` [PATCH 16/25] userns: Convert logfs " Eric W. Biederman
2012-09-20 11:41 ` [PATCH 17/25] userns: Convert minix " Eric W. Biederman
2012-09-20 11:41 ` [PATCH 18/25] userns: Convert nillfs2 " Eric W. Biederman
2012-09-20 14:34 ` Ryusuke Konishi
2012-09-20 11:42 ` [PATCH 19/25] userns: Convert ntfs to use kuid and kgid " Eric W. Biederman
2012-09-20 11:42 ` [PATCH 20/25] userns: Convert omfs " Eric W. Biederman
2012-09-20 12:50 ` Bob Copeland
2012-09-20 13:13 ` Eric W. Biederman
2012-09-20 13:19 ` Bob Copeland
2012-09-20 11:42 ` [PATCH 21/25] userns: Convert the qnx4 filesystem to use kuid/kgid " Eric W. Biederman
2012-09-20 12:34 ` Anders Larsen
2012-09-20 11:42 ` [PATCH 22/25] userns: Convert the qnx6 " Eric W. Biederman
2012-09-20 11:42 ` [PATCH 25/25] userns: Convert ipathfs to use GLOBAL_ROOT_UID and GLOBAL_ROOT_GID Eric W. Biederman
2012-09-20 16:47 ` Marciniszyn, Mike
2012-09-20 11:55 ` [PATCH 01/25] userns: Convert fat to use kuid/kgid where appropriate OGAWA Hirofumi
2012-09-20 12:04 ` Eric W. Biederman
2012-09-20 12:28 ` OGAWA Hirofumi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1348141326-23355-8-git-send-email-ebiederm@xmission.com \
--to=ebiederm@xmission.com \
--cc=containers@lists.linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=serge@hallyn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®