All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Daniel Walsh <dwalsh@redhat.com>, Vivek Goyal <vgoyal@redhat.com>,
	Casey Schaufler <casey@schaufler-ca.com>,
	"Schaufler, Casey" <casey.schaufler@intel.com>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
	"virtio-fs@redhat.com" <virtio-fs@redhat.com>,
	"berrange@redhat.com" <berrange@redhat.com>,
	linux-security-module <linux-security-module@vger.kernel.org>,
	"selinux@vger.kernel.org" <selinux@vger.kernel.org>
Subject: Re: [RFC PATCH 0/1] xattr: Allow user.* xattr on symlink/special files if caller has CAP_SYS_RESOURCE
Date: Wed, 30 Jun 2021 16:01:42 +0100	[thread overview]
Message-ID: <YNyHVhGPe1bFAt+C@work-vm> (raw)
In-Reply-To: <YNyECw/1FzDCW3G8@mit.edu>

* Theodore Ts'o (tytso@mit.edu) wrote:
> On Wed, Jun 30, 2021 at 09:07:56AM +0100, Dr. David Alan Gilbert wrote:
> > * Theodore Ts'o (tytso@mit.edu) wrote:
> > > On Tue, Jun 29, 2021 at 04:28:24PM -0400, Daniel Walsh wrote:
> > > > All this conversation is great, and I look forward to a better solution, but
> > > > if we go back to the patch, it was to fix an issue where the kernel is
> > > > requiring CAP_SYS_ADMIN for writing user Xattrs on link files and other
> > > > special files.
> > > > 
> > > > The documented reason for this is to prevent the users from using XATTRS to
> > > > avoid quota.
> > > 
> > > Huh?  Where is it so documented?
> > 
> > man xattr(7):
> >        The  file permission bits of regular files and directories are
> >        interpreted differently from the file permission bits of special
> >        files and symbolic links.  For regular files and directories the
> >        file permission bits define access to the file's contents,
> >        while for device special files they define access to the device
> >        described by the special file.  The file permissions of symbolic
> >        links are not used in access checks.
> 
> All of this is true...
> 
> >         *** These differences would
> >        allow users to consume filesystem resources in a way not
> >        controllable by disk quotas for group or world writable special
> >        files and directories.****
> 
> Anyone with group write access to a regular file can append to the
> file, and the blocks written will be charged the owner of the file.
> So it's perfectly "controllable" by the quota system; if you have
> group write access to a file, you can charge against the user's quota.
> This is Working As Intended.
> 
> And the creation of device special files take the umask into account,
> just like regular files, so if you have a umask that allows newly
> created files to be group writeable, the same issue would occur for
> regular files as device files.  Given that most users have a umask of
> 0077 or 0022, this is generally Not A Problem.
> 
> I think I see the issue which drove the above text, though, which is
> that Linux's syscall(2) is creating symlinks which do not take umask
> into account; that is, the permissions are always mode ST_IFLNK|0777.
> 
> Hence, it might be that the right answer is to remove this fairly
> arbitrary restriction entirely, and change symlink(2) so that it
> creates files which respects the umask.  Posix and SUS doesn't specify
> what the permissions are that are used, and historically (before the
> advent of xattrs) I suspect since it didn't matter, no one cared about
> whether or not umask was applied.
> 
> Some people might object to such a change arguing that with
> pre-existing file systems where there are symlinks which
> world-writeable, this might cause people to be able to charge up to
> 32k (or whatever the maximum size of the xattr supported by the file
> system) for each symlink.  However, (a) very few people actually use
> quotas, and this would only be an issue for those users, and (b) the
> amount of quota "abuse" that could be carried out this way is small
> enough that I'm not sure it matters.

Even if you fix symlinks, I don't think it fixes device nodes or
anything else where the permissions bitmap isn't purely used as the
permissions on the inode.

Dave

>      	    	  	      	  - Ted
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


WARNING: multiple messages have this Message-ID (diff)
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: "berrange@redhat.com" <berrange@redhat.com>,
	"selinux@vger.kernel.org" <selinux@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"virtio-fs@redhat.com" <virtio-fs@redhat.com>,
	"Schaufler, Casey" <casey.schaufler@intel.com>,
	linux-security-module <linux-security-module@vger.kernel.org>,
	"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
	Casey Schaufler <casey@schaufler-ca.com>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	Vivek Goyal <vgoyal@redhat.com>
Subject: Re: [Virtio-fs] [RFC PATCH 0/1] xattr: Allow user.* xattr on symlink/special files if caller has CAP_SYS_RESOURCE
Date: Wed, 30 Jun 2021 16:01:42 +0100	[thread overview]
Message-ID: <YNyHVhGPe1bFAt+C@work-vm> (raw)
In-Reply-To: <YNyECw/1FzDCW3G8@mit.edu>

* Theodore Ts'o (tytso@mit.edu) wrote:
> On Wed, Jun 30, 2021 at 09:07:56AM +0100, Dr. David Alan Gilbert wrote:
> > * Theodore Ts'o (tytso@mit.edu) wrote:
> > > On Tue, Jun 29, 2021 at 04:28:24PM -0400, Daniel Walsh wrote:
> > > > All this conversation is great, and I look forward to a better solution, but
> > > > if we go back to the patch, it was to fix an issue where the kernel is
> > > > requiring CAP_SYS_ADMIN for writing user Xattrs on link files and other
> > > > special files.
> > > > 
> > > > The documented reason for this is to prevent the users from using XATTRS to
> > > > avoid quota.
> > > 
> > > Huh?  Where is it so documented?
> > 
> > man xattr(7):
> >        The  file permission bits of regular files and directories are
> >        interpreted differently from the file permission bits of special
> >        files and symbolic links.  For regular files and directories the
> >        file permission bits define access to the file's contents,
> >        while for device special files they define access to the device
> >        described by the special file.  The file permissions of symbolic
> >        links are not used in access checks.
> 
> All of this is true...
> 
> >         *** These differences would
> >        allow users to consume filesystem resources in a way not
> >        controllable by disk quotas for group or world writable special
> >        files and directories.****
> 
> Anyone with group write access to a regular file can append to the
> file, and the blocks written will be charged the owner of the file.
> So it's perfectly "controllable" by the quota system; if you have
> group write access to a file, you can charge against the user's quota.
> This is Working As Intended.
> 
> And the creation of device special files take the umask into account,
> just like regular files, so if you have a umask that allows newly
> created files to be group writeable, the same issue would occur for
> regular files as device files.  Given that most users have a umask of
> 0077 or 0022, this is generally Not A Problem.
> 
> I think I see the issue which drove the above text, though, which is
> that Linux's syscall(2) is creating symlinks which do not take umask
> into account; that is, the permissions are always mode ST_IFLNK|0777.
> 
> Hence, it might be that the right answer is to remove this fairly
> arbitrary restriction entirely, and change symlink(2) so that it
> creates files which respects the umask.  Posix and SUS doesn't specify
> what the permissions are that are used, and historically (before the
> advent of xattrs) I suspect since it didn't matter, no one cared about
> whether or not umask was applied.
> 
> Some people might object to such a change arguing that with
> pre-existing file systems where there are symlinks which
> world-writeable, this might cause people to be able to charge up to
> 32k (or whatever the maximum size of the xattr supported by the file
> system) for each symlink.  However, (a) very few people actually use
> quotas, and this would only be an issue for those users, and (b) the
> amount of quota "abuse" that could be carried out this way is small
> enough that I'm not sure it matters.

Even if you fix symlinks, I don't think it fixes device nodes or
anything else where the permissions bitmap isn't purely used as the
permissions on the inode.

Dave

>      	    	  	      	  - Ted
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


  reply	other threads:[~2021-06-30 15:01 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-25 19:12 [RFC PATCH 0/1] xattr: Allow user.* xattr on symlink/special files if caller has CAP_SYS_RESOURCE Vivek Goyal
2021-06-25 19:12 ` [Virtio-fs] " Vivek Goyal
2021-06-25 19:12 ` [PATCH 1/1] xattr: Allow user.* xattr on symlink/special files with CAP_SYS_RESOURCE Vivek Goyal
2021-06-25 19:12   ` [Virtio-fs] " Vivek Goyal
2021-06-28 12:33   ` Christian Brauner
2021-06-28 12:33     ` [Virtio-fs] " Christian Brauner
2021-06-28 15:00   ` Vivek Goyal
2021-06-28 15:00     ` [Virtio-fs] " Vivek Goyal
2021-06-29  3:13   ` [xattr] 8d8cd767b6: ltp.setxattr02.fail kernel test robot
2021-06-29  3:13     ` [Virtio-fs] " kernel test robot
2021-06-29  3:13     ` kernel test robot
2021-06-29  3:13     ` [LTP] " kernel test robot
2021-06-29 12:59     ` Vivek Goyal
2021-06-29 12:59       ` [Virtio-fs] " Vivek Goyal
2021-06-29 12:59       ` Vivek Goyal
2021-06-29 12:59       ` [LTP] " Vivek Goyal
2021-06-25 21:49 ` [RFC PATCH 0/1] xattr: Allow user.* xattr on symlink/special files if caller has CAP_SYS_RESOURCE Schaufler, Casey
2021-06-25 21:49   ` [Virtio-fs] " Schaufler, Casey
2021-06-28 11:58   ` Dr. David Alan Gilbert
2021-06-28 11:58     ` [Virtio-fs] " Dr. David Alan Gilbert
2021-06-28 13:17   ` Vivek Goyal
2021-06-28 13:17     ` [Virtio-fs] " Vivek Goyal
2021-06-28 13:36     ` Daniel Walsh
2021-06-28 13:36       ` [Virtio-fs] " Daniel Walsh
2021-06-28 16:04       ` Casey Schaufler
2021-06-28 16:04         ` [Virtio-fs] " Casey Schaufler
2021-06-28 16:28         ` Dr. David Alan Gilbert
2021-06-28 16:28           ` [Virtio-fs] " Dr. David Alan Gilbert
2021-06-28 17:41           ` Casey Schaufler
2021-06-28 17:41             ` [Virtio-fs] " Casey Schaufler
2021-06-29  9:00             ` Dr. David Alan Gilbert
2021-06-29  9:00               ` [Virtio-fs] " Dr. David Alan Gilbert
2021-06-29 14:38               ` Casey Schaufler
2021-06-29 14:38                 ` [Virtio-fs] " Casey Schaufler
2021-06-29 15:20                 ` Vivek Goyal
2021-06-29 15:20                   ` [Virtio-fs] " Vivek Goyal
2021-06-29 16:13                   ` Casey Schaufler
2021-06-29 16:13                     ` [Virtio-fs] " Casey Schaufler
2021-06-29 16:35                     ` Dr. David Alan Gilbert
2021-06-29 16:35                       ` [Virtio-fs] " Dr. David Alan Gilbert
2021-06-29 16:51                       ` Casey Schaufler
2021-06-29 16:51                         ` [Virtio-fs] " Casey Schaufler
2021-06-29 17:35                     ` Vivek Goyal
2021-06-29 17:35                       ` [Virtio-fs] " Vivek Goyal
2021-06-29 20:28                       ` Daniel Walsh
2021-06-29 20:28                         ` [Virtio-fs] " Daniel Walsh
2021-06-30  4:12                         ` Theodore Ts'o
2021-06-30  4:12                           ` [Virtio-fs] " Theodore Ts'o
2021-06-30  8:07                           ` Dr. David Alan Gilbert
2021-06-30  8:07                             ` [Virtio-fs] " Dr. David Alan Gilbert
2021-06-30 14:47                             ` Theodore Ts'o
2021-06-30 14:47                               ` [Virtio-fs] " Theodore Ts'o
2021-06-30 15:01                               ` Dr. David Alan Gilbert [this message]
2021-06-30 15:01                                 ` Dr. David Alan Gilbert
2021-06-30 19:59                                 ` Theodore Ts'o
2021-06-30 19:59                                   ` [Virtio-fs] " Theodore Ts'o
2021-06-30 20:32                                   ` Vivek Goyal
2021-06-30 20:32                                     ` [Virtio-fs] " Vivek Goyal
2021-07-01  8:48                                   ` Dr. David Alan Gilbert
2021-07-01  8:48                                     ` [Virtio-fs] " Dr. David Alan Gilbert
2021-07-01 12:21                                     ` Vivek Goyal
2021-07-01 12:21                                       ` [Virtio-fs] " Vivek Goyal
2021-07-01 13:10                                     ` Vivek Goyal
2021-07-01 13:10                                       ` [Virtio-fs] " Vivek Goyal
2021-07-01 16:58                                       ` Casey Schaufler
2021-07-01 16:58                                         ` [Virtio-fs] " Casey Schaufler
2021-06-30 16:09                               ` Vivek Goyal
2021-06-30 16:09                                 ` [Virtio-fs] " Vivek Goyal
2021-06-30 14:27                           ` Vivek Goyal
2021-06-30 14:27                             ` [Virtio-fs] " Vivek Goyal
2021-06-29 16:25                 ` Theodore Ts'o
2021-06-29 16:25                   ` [Virtio-fs] " Theodore Ts'o
2021-06-28 17:22         ` Vivek Goyal
2021-06-28 17:22           ` [Virtio-fs] " Vivek Goyal
2021-06-28 18:55         ` Daniel Walsh
2021-06-28 18:55           ` [Virtio-fs] " Daniel Walsh

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=YNyHVhGPe1bFAt+C@work-vm \
    --to=dgilbert@redhat.com \
    --cc=berrange@redhat.com \
    --cc=casey.schaufler@intel.com \
    --cc=casey@schaufler-ca.com \
    --cc=dwalsh@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=selinux@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=vgoyal@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=virtio-fs@redhat.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 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.