linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Wang Shilong <wangshilong1991@gmail.com>
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Ext4 Developers List <linux-ext4@vger.kernel.org>,
	Andreas Dilger <adilger@dilger.ca>, Li Xi <lixi@ddn.com>,
	Wang Shilong <wshilong@ddn.com>
Subject: Re: [Project Quota]file owner could change its project ID?
Date: Wed, 16 Oct 2019 14:37:00 -0700	[thread overview]
Message-ID: <20191016213700.GH13108@magnolia> (raw)
In-Reply-To: <CAP9B-Q=SfhnA6iO7h1TWAoSOfZ+BvT7d8=OE4176FZ3GXiU-xw@mail.gmail.com>

On Wed, Oct 16, 2019 at 07:51:15PM +0800, Wang Shilong wrote:
> On Mon, Oct 14, 2019 at 12:41 AM Darrick J. Wong
> <darrick.wong@oracle.com> wrote:
> >
> > On Sat, Oct 12, 2019 at 02:33:36PM +0800, Wang Shilong wrote:
> > > Steps to reproduce:
> > > [wangsl@localhost tmp]$ mkdir project
> > > [wangsl@localhost tmp]$ lsattr -p project -d
> > >     0 ------------------ project
> > > [wangsl@localhost tmp]$ chattr -p 1 project
> > > [wangsl@localhost tmp]$ lsattr -p -d project
> > >     1 ------------------ project
> > > [wangsl@localhost tmp]$ chattr -p 2 project
> > > [wangsl@localhost tmp]$ lsattr -p -d project
> > >     2 ------------------ project
> > > [wangsl@localhost tmp]$ df -Th .
> > > Filesystem     Type  Size  Used Avail Use% Mounted on
> > > /dev/sda3      xfs    36G  4.1G   32G  12% /
> > > [wangsl@localhost tmp]$ uname -r
> > > 5.4.0-rc2+
> > >
> > > As above you could see file owner could change project ID of file its self.
> > > As my understanding, we could set project ID and inherit attribute to account
> > > Directory usage, and implement a similar 'Directory Quota' based on this.
> >
> > So the problem here is that the admin sets up a project quota on a
> > directory, then non-container users change the project id and thereby
> > break quota enforcement?  Dave didn't sound at all enthusiastic, but I'm
> > still wondering what exactly you're trying to prevent.
> 
> Yup, we are trying to prevent no-root users to change their project ID.
> As we want to implement 'Directory Quota':
> 
> If non-root users could change their project ID, they could always try
> to change its project ID to steal space when EDQUOT returns.
> 
> Yup, if mount option could be introduced to make this case work,
> that will be nice.

Well then we had better discuss and write down the exact behaviors of
this new directory quota feature and how it differs from ye olde project
quota.  Here's the existing definition of project quotas in the
xfs_quota manpage:

       10.    XFS  supports  the notion of project quota, which can be
              used to implement a form of directory tree  quota  (i.e.
              to  restrict  a directory tree to only being able to use
              up a component of the filesystems  available  space;  or
              simply  to  keep  track  of the amount of space used, or
              number of inodes, within the tree).

First, we probably ought to add the following to that definition to
reflect a few pieces of current reality:

"Processes running inside runtime environments using mapped user or
group ids, such as container runtimes, are not allowed to change the
project id and project id inheritance flag of inodes."

What do you all think of this starting definition for directory quotas:

       11.    XFS supports the similar notion of directory quota.  The
	      key difference between project and directory quotas is the
	      additional restriction that only a system administrator
	      running outside of a mapped user or group id runtime
	      environment (such as a container runtime) can change the
	      project id and project id inheritenace flag.  This means
	      that unprivileged users are never allowed to manage their
              own directory quotas.

We'd probably enable this with a new 'dirquota' mount option that is
mutually exclusive with the old 'prjquota' option.

--D

> 
> 
> >
> > (Which is to say, maybe we introduce a mount option to prevent changing
> > projid if project quota *enforcement* is enabled?)
> >
> > --D
> >

  parent reply	other threads:[~2019-10-16 21:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-12  6:33 [Project Quota]file owner could change its project ID? Wang Shilong
2019-10-12 20:51 ` Dave Chinner
2019-10-13 16:41 ` Darrick J. Wong
2019-10-16 11:51   ` Wang Shilong
2019-10-16 21:22     ` Dave Chinner
2019-10-16 21:37     ` Darrick J. Wong [this message]
2019-10-17  0:28       ` Andreas Dilger
2019-10-17 12:12         ` Theodore Y. Ts'o
2019-10-20 20:19           ` Andreas Dilger
2019-10-20 22:25             ` Theodore Y. Ts'o
2019-10-21 21:15               ` Andreas Dilger
2019-10-21 23:35         ` Dave Chinner
2019-10-23 23:01           ` Andreas Dilger

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=20191016213700.GH13108@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=adilger@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=lixi@ddn.com \
    --cc=wangshilong1991@gmail.com \
    --cc=wshilong@ddn.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;
as well as URLs for NNTP newsgroup(s).