From: ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org (Eric W. Biederman)
To: OGAWA Hirofumi
<hirofumi-UIVanBePwB70ZhReMnHkpc8NsWr+9BEh@public.gmane.org>
Cc: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Linux Containers
<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 01/25] userns: Convert fat to use kuid/kgid where appropriate
Date: Thu, 20 Sep 2012 05:04:02 -0700 [thread overview]
Message-ID: <87vcf8vr2l.fsf@xmission.com> (raw)
In-Reply-To: <87pq5gx60i.fsf-x/W9pkDDSe1TgC2z9Sl/nXf5DAMn2ifp@public.gmane.org> (OGAWA Hirofumi's message of "Thu, 20 Sep 2012 20:55:57 +0900")
OGAWA Hirofumi <hirofumi-UIVanBePwB70ZhReMnHkpc8NsWr+9BEh@public.gmane.org> writes:
> "Eric W. Biederman" <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org> writes:
>
>> struct fat_mount_options {
>> - uid_t fs_uid;
>> - gid_t fs_gid;
>> + kuid_t fs_uid;
>> + kgid_t fs_gid;
>> unsigned short fs_fmask;
>> unsigned short fs_dmask;
>> unsigned short codepage; /* Codepage for shortname conversions */
>
> I'm not reading this thread, so I may be wrong though. Doesn't this need
> to initialize opts->fs_uid/fs_gid by GLOBAL_ROOT_UID/GID?
Good question.
At the start of parse_options there is:
static int parse_options(struct super_block *sb, char *options, int is_vfat,
int silent, int *debug, struct fat_mount_options *opts)
{
char *p;
substring_t args[MAX_OPT_ARGS];
int option;
char *iocharset;
opts->isvfat = is_vfat;
opts->fs_uid = current_uid();
opts->fs_gid = current_gid();
So there should be no problems with initialization.
Eric
>> diff --git a/fs/fat/file.c b/fs/fat/file.c
>> index e007b8b..a62e0ec 100644
>> --- a/fs/fat/file.c
>> +++ b/fs/fat/file.c
>> @@ -352,7 +352,7 @@ static int fat_allow_set_time(struct msdos_sb_info *sbi, struct inode *inode)
>> {
>> umode_t allow_utime = sbi->options.allow_utime;
>>
>> - if (current_fsuid() != inode->i_uid) {
>> + if (!uid_eq(current_fsuid(), inode->i_uid)) {
>> if (in_group_p(inode->i_gid))
>> allow_utime >>= 3;
>> if (allow_utime & MAY_WRITE)
>> @@ -407,9 +407,9 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr)
>> }
>>
>> if (((attr->ia_valid & ATTR_UID) &&
>> - (attr->ia_uid != sbi->options.fs_uid)) ||
>> + (!uid_eq(attr->ia_uid, sbi->options.fs_uid))) ||
>> ((attr->ia_valid & ATTR_GID) &&
>> - (attr->ia_gid != sbi->options.fs_gid)) ||
>> + (!gid_eq(attr->ia_gid, sbi->options.fs_gid))) ||
>> ((attr->ia_valid & ATTR_MODE) &&
>> (attr->ia_mode & ~FAT_VALID_MODE)))
>> error = -EPERM;
>> diff --git a/fs/fat/inode.c b/fs/fat/inode.c
>> index 05e897f..47d9eb0 100644
>> --- a/fs/fat/inode.c
>> +++ b/fs/fat/inode.c
>> @@ -791,10 +791,12 @@ static int fat_show_options(struct seq_file *m, struct dentry *root)
>> struct fat_mount_options *opts = &sbi->options;
>> int isvfat = opts->isvfat;
>>
>> - if (opts->fs_uid != 0)
>> - seq_printf(m, ",uid=%u", opts->fs_uid);
>> - if (opts->fs_gid != 0)
>> - seq_printf(m, ",gid=%u", opts->fs_gid);
>> + if (!uid_eq(opts->fs_uid, GLOBAL_ROOT_UID))
>> + seq_printf(m, ",uid=%u",
>> + from_kuid_munged(&init_user_ns, opts->fs_uid));
>> + if (!gid_eq(opts->fs_gid, GLOBAL_ROOT_GID))
>> + seq_printf(m, ",gid=%u",
>> + from_kgid_munged(&init_user_ns, opts->fs_gid));
>> seq_printf(m, ",fmask=%04o", opts->fs_fmask);
>> seq_printf(m, ",dmask=%04o", opts->fs_dmask);
>> if (opts->allow_utime)
>> @@ -1037,12 +1039,16 @@ static int parse_options(struct super_block *sb, char *options, int is_vfat,
>> case Opt_uid:
>> if (match_int(&args[0], &option))
>> return 0;
>> - opts->fs_uid = option;
>> + opts->fs_uid = make_kuid(current_user_ns(), option);
>> + if (!uid_valid(opts->fs_uid))
>> + return 0;
>> break;
>> case Opt_gid:
>> if (match_int(&args[0], &option))
>> return 0;
>> - opts->fs_gid = option;
>> + opts->fs_gid = make_kgid(current_user_ns(), option);
>> + if (!gid_valid(opts->fs_gid))
>> + return 0;
>> break;
>> case Opt_umask:
>> if (match_octal(&args[0], &option))
>> diff --git a/init/Kconfig b/init/Kconfig
>> index 296d48b..60bdff2 100644
>> --- a/init/Kconfig
>> +++ b/init/Kconfig
>> @@ -952,7 +952,6 @@ config UIDGID_CONVERTED
>> depends on ECRYPT_FS = n
>> depends on EFS_FS = n
>> depends on EXOFS_FS = n
>> - depends on FAT_FS = n
>> depends on FUSE_FS = n
>> depends on GFS2_FS = n
>> depends on HFS_FS = n
WARNING: multiple messages have this Message-ID (diff)
From: ebiederm@xmission.com (Eric W. Biederman)
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: <linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Serge Hallyn <serge@hallyn.com>,
Linux Containers <containers@lists.linux-foundation.org>
Subject: Re: [PATCH 01/25] userns: Convert fat to use kuid/kgid where appropriate
Date: Thu, 20 Sep 2012 05:04:02 -0700 [thread overview]
Message-ID: <87vcf8vr2l.fsf@xmission.com> (raw)
In-Reply-To: <87pq5gx60i.fsf@devron.myhome.or.jp> (OGAWA Hirofumi's message of "Thu, 20 Sep 2012 20:55:57 +0900")
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> writes:
> "Eric W. Biederman" <ebiederm@xmission.com> writes:
>
>> struct fat_mount_options {
>> - uid_t fs_uid;
>> - gid_t fs_gid;
>> + kuid_t fs_uid;
>> + kgid_t fs_gid;
>> unsigned short fs_fmask;
>> unsigned short fs_dmask;
>> unsigned short codepage; /* Codepage for shortname conversions */
>
> I'm not reading this thread, so I may be wrong though. Doesn't this need
> to initialize opts->fs_uid/fs_gid by GLOBAL_ROOT_UID/GID?
Good question.
At the start of parse_options there is:
static int parse_options(struct super_block *sb, char *options, int is_vfat,
int silent, int *debug, struct fat_mount_options *opts)
{
char *p;
substring_t args[MAX_OPT_ARGS];
int option;
char *iocharset;
opts->isvfat = is_vfat;
opts->fs_uid = current_uid();
opts->fs_gid = current_gid();
So there should be no problems with initialization.
Eric
>> diff --git a/fs/fat/file.c b/fs/fat/file.c
>> index e007b8b..a62e0ec 100644
>> --- a/fs/fat/file.c
>> +++ b/fs/fat/file.c
>> @@ -352,7 +352,7 @@ static int fat_allow_set_time(struct msdos_sb_info *sbi, struct inode *inode)
>> {
>> umode_t allow_utime = sbi->options.allow_utime;
>>
>> - if (current_fsuid() != inode->i_uid) {
>> + if (!uid_eq(current_fsuid(), inode->i_uid)) {
>> if (in_group_p(inode->i_gid))
>> allow_utime >>= 3;
>> if (allow_utime & MAY_WRITE)
>> @@ -407,9 +407,9 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr)
>> }
>>
>> if (((attr->ia_valid & ATTR_UID) &&
>> - (attr->ia_uid != sbi->options.fs_uid)) ||
>> + (!uid_eq(attr->ia_uid, sbi->options.fs_uid))) ||
>> ((attr->ia_valid & ATTR_GID) &&
>> - (attr->ia_gid != sbi->options.fs_gid)) ||
>> + (!gid_eq(attr->ia_gid, sbi->options.fs_gid))) ||
>> ((attr->ia_valid & ATTR_MODE) &&
>> (attr->ia_mode & ~FAT_VALID_MODE)))
>> error = -EPERM;
>> diff --git a/fs/fat/inode.c b/fs/fat/inode.c
>> index 05e897f..47d9eb0 100644
>> --- a/fs/fat/inode.c
>> +++ b/fs/fat/inode.c
>> @@ -791,10 +791,12 @@ static int fat_show_options(struct seq_file *m, struct dentry *root)
>> struct fat_mount_options *opts = &sbi->options;
>> int isvfat = opts->isvfat;
>>
>> - if (opts->fs_uid != 0)
>> - seq_printf(m, ",uid=%u", opts->fs_uid);
>> - if (opts->fs_gid != 0)
>> - seq_printf(m, ",gid=%u", opts->fs_gid);
>> + if (!uid_eq(opts->fs_uid, GLOBAL_ROOT_UID))
>> + seq_printf(m, ",uid=%u",
>> + from_kuid_munged(&init_user_ns, opts->fs_uid));
>> + if (!gid_eq(opts->fs_gid, GLOBAL_ROOT_GID))
>> + seq_printf(m, ",gid=%u",
>> + from_kgid_munged(&init_user_ns, opts->fs_gid));
>> seq_printf(m, ",fmask=%04o", opts->fs_fmask);
>> seq_printf(m, ",dmask=%04o", opts->fs_dmask);
>> if (opts->allow_utime)
>> @@ -1037,12 +1039,16 @@ static int parse_options(struct super_block *sb, char *options, int is_vfat,
>> case Opt_uid:
>> if (match_int(&args[0], &option))
>> return 0;
>> - opts->fs_uid = option;
>> + opts->fs_uid = make_kuid(current_user_ns(), option);
>> + if (!uid_valid(opts->fs_uid))
>> + return 0;
>> break;
>> case Opt_gid:
>> if (match_int(&args[0], &option))
>> return 0;
>> - opts->fs_gid = option;
>> + opts->fs_gid = make_kgid(current_user_ns(), option);
>> + if (!gid_valid(opts->fs_gid))
>> + return 0;
>> break;
>> case Opt_umask:
>> if (match_octal(&args[0], &option))
>> diff --git a/init/Kconfig b/init/Kconfig
>> index 296d48b..60bdff2 100644
>> --- a/init/Kconfig
>> +++ b/init/Kconfig
>> @@ -952,7 +952,6 @@ config UIDGID_CONVERTED
>> depends on ECRYPT_FS = n
>> depends on EFS_FS = n
>> depends on EXOFS_FS = n
>> - depends on FAT_FS = n
>> depends on FUSE_FS = n
>> depends on GFS2_FS = n
>> depends on HFS_FS = n
next prev parent reply other threads:[~2012-09-20 12:04 UTC|newest]
Thread overview: 104+ 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
[not found] ` <877grox6ql.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
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 ` Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
[not found] ` <1348141326-23355-1-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-09-20 11:41 ` [PATCH 02/25] userns: Convert gadgetfs to use kuid and kgid " Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
[not found] ` <1348141326-23355-2-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-09-20 11:58 ` Greg Kroah-Hartman
2012-09-20 11:58 ` Greg Kroah-Hartman
2012-09-21 9:33 ` Felipe Balbi
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:41 ` Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
[not found] ` <1348141326-23355-3-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-09-20 11:58 ` Greg Kroah-Hartman
2012-09-20 11:58 ` Greg Kroah-Hartman
2012-09-21 9:32 ` Felipe Balbi
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:41 ` Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
[not found] ` <1348141326-23355-4-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-09-20 11:58 ` Greg Kroah-Hartman
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 ` Eric W. Biederman
2012-09-20 11:41 ` 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 ` Eric W. Biederman
2012-09-20 11:41 ` 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
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` [PATCH 08/25] userns: Convert befs to use kuid/kgid " Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` [PATCH 09/25] userns: Convert cramfs " Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` [PATCH 10/25] userns: Convert ecryptfs " Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` [PATCH 11/25] userns: Convert efs " Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` [PATCH 12/25] userns: Convert exofs " Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 12:20 ` Boaz Harrosh
[not found] ` <1348141326-23355-12-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
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 ` Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` [PATCH 14/25] userns: Convert hfsplus " Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` 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 ` Eric W. Biederman
2012-09-20 11:41 ` 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 11:41 ` Eric W. Biederman
2012-09-20 11:41 ` Eric W. Biederman
[not found] ` <1348141326-23355-18-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-09-20 14:34 ` Ryusuke Konishi
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 ` Eric W. Biederman
2012-09-20 11:42 ` Eric W. Biederman
2012-09-20 11:42 ` [PATCH 20/25] userns: Convert omfs " Eric W. Biederman
2012-09-20 11:42 ` Eric W. Biederman
2012-09-20 11:42 ` Eric W. Biederman
[not found] ` <1348141326-23355-20-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-09-20 12:50 ` Bob Copeland
2012-09-20 12:50 ` Bob Copeland
2012-09-20 13:13 ` Eric W. Biederman
2012-09-20 13:13 ` Eric W. Biederman
[not found] ` <87obl0vnu7.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-09-20 13:19 ` Bob Copeland
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 11:42 ` [PATCH 22/25] userns: Convert the qnx6 " Eric W. Biederman
2012-09-20 11:42 ` Eric W. Biederman
2012-09-20 11:42 ` Eric W. Biederman
2012-09-20 11:42 ` [PATCH 23/25] userns: Convert the sysv " Eric W. Biederman
2012-09-20 11:42 ` Eric W. Biederman
2012-09-20 11:42 ` [PATCH 24/25] userns: Convert freevxfs " Eric W. Biederman
2012-09-20 11:42 ` 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 11:42 ` Eric W. Biederman
2012-09-20 11:42 ` Eric W. Biederman
[not found] ` <1348141326-23355-25-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-09-20 16:47 ` Marciniszyn, Mike
2012-09-20 16:47 ` Marciniszyn, Mike
2012-09-20 11:41 ` [PATCH 16/25] userns: Convert logfs to use kuid/kgid where appropriate Eric W. Biederman
2012-09-20 11:41 ` [PATCH 17/25] userns: Convert minix " Eric W. Biederman
[not found] ` <1348141326-23355-17-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-09-25 9:17 ` Zhao Hongjiang
[not found] ` <506176B5.9020104-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-09-25 10:05 ` Eric W. Biederman
[not found] ` <87obkupgcr.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-09-25 10:42 ` Zhao Hongjiang
[not found] ` <50618A93.1040202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-09-25 10:51 ` Eric W. Biederman
2012-09-20 11:42 ` [PATCH 21/25] userns: Convert the qnx4 filesystem " Eric W. Biederman
[not found] ` <1348141326-23355-21-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-09-20 12:34 ` Anders Larsen
2012-09-20 12:34 ` Anders Larsen
2012-09-20 12:34 ` Anders Larsen
2012-09-20 11:55 ` [PATCH 01/25] userns: Convert fat " OGAWA Hirofumi
[not found] ` <87pq5gx60i.fsf-x/W9pkDDSe1TgC2z9Sl/nXf5DAMn2ifp@public.gmane.org>
2012-09-20 12:04 ` Eric W. Biederman [this message]
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=87vcf8vr2l.fsf@xmission.com \
--to=ebiederm-as9lmozglivwk0htik3j/w@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=hirofumi-UIVanBePwB70ZhReMnHkpc8NsWr+9BEh@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.