userns: Convert affs to use kuid/kgid wherwe appropriate
Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
This commit is contained in:
@@ -88,8 +88,8 @@ struct affs_sb_info {
|
|||||||
u32 s_root_block; /* FFS root block number. */
|
u32 s_root_block; /* FFS root block number. */
|
||||||
int s_hashsize; /* Size of hash table. */
|
int s_hashsize; /* Size of hash table. */
|
||||||
unsigned long s_flags; /* See below. */
|
unsigned long s_flags; /* See below. */
|
||||||
uid_t s_uid; /* uid to override */
|
kuid_t s_uid; /* uid to override */
|
||||||
gid_t s_gid; /* gid to override */
|
kgid_t s_gid; /* gid to override */
|
||||||
umode_t s_mode; /* mode to override */
|
umode_t s_mode; /* mode to override */
|
||||||
struct buffer_head *s_root_bh; /* Cached root block. */
|
struct buffer_head *s_root_bh; /* Cached root block. */
|
||||||
struct mutex s_bmlock; /* Protects bitmap access. */
|
struct mutex s_bmlock; /* Protects bitmap access. */
|
||||||
|
@@ -80,17 +80,17 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
|
|||||||
if (id == 0 || sbi->s_flags & SF_SETUID)
|
if (id == 0 || sbi->s_flags & SF_SETUID)
|
||||||
inode->i_uid = sbi->s_uid;
|
inode->i_uid = sbi->s_uid;
|
||||||
else if (id == 0xFFFF && sbi->s_flags & SF_MUFS)
|
else if (id == 0xFFFF && sbi->s_flags & SF_MUFS)
|
||||||
inode->i_uid = 0;
|
i_uid_write(inode, 0);
|
||||||
else
|
else
|
||||||
inode->i_uid = id;
|
i_uid_write(inode, id);
|
||||||
|
|
||||||
id = be16_to_cpu(tail->gid);
|
id = be16_to_cpu(tail->gid);
|
||||||
if (id == 0 || sbi->s_flags & SF_SETGID)
|
if (id == 0 || sbi->s_flags & SF_SETGID)
|
||||||
inode->i_gid = sbi->s_gid;
|
inode->i_gid = sbi->s_gid;
|
||||||
else if (id == 0xFFFF && sbi->s_flags & SF_MUFS)
|
else if (id == 0xFFFF && sbi->s_flags & SF_MUFS)
|
||||||
inode->i_gid = 0;
|
i_gid_write(inode, 0);
|
||||||
else
|
else
|
||||||
inode->i_gid = id;
|
i_gid_write(inode, id);
|
||||||
|
|
||||||
switch (be32_to_cpu(tail->stype)) {
|
switch (be32_to_cpu(tail->stype)) {
|
||||||
case ST_ROOT:
|
case ST_ROOT:
|
||||||
@@ -193,13 +193,13 @@ affs_write_inode(struct inode *inode, struct writeback_control *wbc)
|
|||||||
tail->size = cpu_to_be32(inode->i_size);
|
tail->size = cpu_to_be32(inode->i_size);
|
||||||
secs_to_datestamp(inode->i_mtime.tv_sec,&tail->change);
|
secs_to_datestamp(inode->i_mtime.tv_sec,&tail->change);
|
||||||
if (!(inode->i_ino == AFFS_SB(sb)->s_root_block)) {
|
if (!(inode->i_ino == AFFS_SB(sb)->s_root_block)) {
|
||||||
uid = inode->i_uid;
|
uid = i_uid_read(inode);
|
||||||
gid = inode->i_gid;
|
gid = i_gid_read(inode);
|
||||||
if (AFFS_SB(sb)->s_flags & SF_MUFS) {
|
if (AFFS_SB(sb)->s_flags & SF_MUFS) {
|
||||||
if (inode->i_uid == 0 || inode->i_uid == 0xFFFF)
|
if (uid == 0 || uid == 0xFFFF)
|
||||||
uid = inode->i_uid ^ ~0;
|
uid = uid ^ ~0;
|
||||||
if (inode->i_gid == 0 || inode->i_gid == 0xFFFF)
|
if (gid == 0 || gid == 0xFFFF)
|
||||||
gid = inode->i_gid ^ ~0;
|
gid = gid ^ ~0;
|
||||||
}
|
}
|
||||||
if (!(AFFS_SB(sb)->s_flags & SF_SETUID))
|
if (!(AFFS_SB(sb)->s_flags & SF_SETUID))
|
||||||
tail->uid = cpu_to_be16(uid);
|
tail->uid = cpu_to_be16(uid);
|
||||||
|
@@ -188,7 +188,7 @@ static const match_table_t tokens = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s32 *root,
|
parse_options(char *options, kuid_t *uid, kgid_t *gid, int *mode, int *reserved, s32 *root,
|
||||||
int *blocksize, char **prefix, char *volume, unsigned long *mount_opts)
|
int *blocksize, char **prefix, char *volume, unsigned long *mount_opts)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
@@ -253,13 +253,17 @@ parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s
|
|||||||
case Opt_setgid:
|
case Opt_setgid:
|
||||||
if (match_int(&args[0], &option))
|
if (match_int(&args[0], &option))
|
||||||
return 0;
|
return 0;
|
||||||
*gid = option;
|
*gid = make_kgid(current_user_ns(), option);
|
||||||
|
if (!gid_valid(*gid))
|
||||||
|
return 0;
|
||||||
*mount_opts |= SF_SETGID;
|
*mount_opts |= SF_SETGID;
|
||||||
break;
|
break;
|
||||||
case Opt_setuid:
|
case Opt_setuid:
|
||||||
if (match_int(&args[0], &option))
|
if (match_int(&args[0], &option))
|
||||||
return 0;
|
return 0;
|
||||||
*uid = option;
|
*uid = make_kuid(current_user_ns(), option);
|
||||||
|
if (!uid_valid(*uid))
|
||||||
|
return 0;
|
||||||
*mount_opts |= SF_SETUID;
|
*mount_opts |= SF_SETUID;
|
||||||
break;
|
break;
|
||||||
case Opt_verbose:
|
case Opt_verbose:
|
||||||
@@ -301,8 +305,8 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
|
|||||||
int num_bm;
|
int num_bm;
|
||||||
int i, j;
|
int i, j;
|
||||||
s32 key;
|
s32 key;
|
||||||
uid_t uid;
|
kuid_t uid;
|
||||||
gid_t gid;
|
kgid_t gid;
|
||||||
int reserved;
|
int reserved;
|
||||||
unsigned long mount_flags;
|
unsigned long mount_flags;
|
||||||
int tmp_flags; /* fix remount prototype... */
|
int tmp_flags; /* fix remount prototype... */
|
||||||
@@ -527,8 +531,8 @@ affs_remount(struct super_block *sb, int *flags, char *data)
|
|||||||
{
|
{
|
||||||
struct affs_sb_info *sbi = AFFS_SB(sb);
|
struct affs_sb_info *sbi = AFFS_SB(sb);
|
||||||
int blocksize;
|
int blocksize;
|
||||||
uid_t uid;
|
kuid_t uid;
|
||||||
gid_t gid;
|
kgid_t gid;
|
||||||
int mode;
|
int mode;
|
||||||
int reserved;
|
int reserved;
|
||||||
int root_block;
|
int root_block;
|
||||||
|
@@ -928,7 +928,6 @@ config UIDGID_CONVERTED
|
|||||||
|
|
||||||
# Filesystems
|
# Filesystems
|
||||||
depends on 9P_FS = n
|
depends on 9P_FS = n
|
||||||
depends on AFFS_FS = n
|
|
||||||
depends on AFS_FS = n
|
depends on AFS_FS = n
|
||||||
depends on AUTOFS4_FS = n
|
depends on AUTOFS4_FS = n
|
||||||
depends on BFS_FS = n
|
depends on BFS_FS = n
|
||||||
|
Reference in New Issue
Block a user