From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D4A3C10F14 for ; Sat, 12 Oct 2019 20:51:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2059F21655 for ; Sat, 12 Oct 2019 20:51:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729445AbfJLUvk (ORCPT ); Sat, 12 Oct 2019 16:51:40 -0400 Received: from mail105.syd.optusnet.com.au ([211.29.132.249]:60883 "EHLO mail105.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728579AbfJLUvk (ORCPT ); Sat, 12 Oct 2019 16:51:40 -0400 Received: from dread.disaster.area (pa49-181-198-88.pa.nsw.optusnet.com.au [49.181.198.88]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id D0669362E26; Sun, 13 Oct 2019 07:51:36 +1100 (AEDT) Received: from dave by dread.disaster.area with local (Exim 4.92.2) (envelope-from ) id 1iJOMR-0007JM-WE; Sun, 13 Oct 2019 07:51:36 +1100 Date: Sun, 13 Oct 2019 07:51:35 +1100 From: Dave Chinner To: Wang Shilong Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Ext4 Developers List , Andreas Dilger , Li Xi , Wang Shilong Subject: Re: [Project Quota]file owner could change its project ID? Message-ID: <20191012205135.GS16973@dread.disaster.area> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=D+Q3ErZj c=1 sm=1 tr=0 a=ocld+OpnWJCUTqzFQA3oTA==:117 a=ocld+OpnWJCUTqzFQA3oTA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=XobE76Q3jBoA:10 a=7-415B0cAAAA:8 a=XQ-RyMWtx_6voXMgLtIA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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. Perfectly legal to do this. Working as designed, and intended. Project quotas have allowed this since they were introduced in the late 1980s on Irix... > As my understanding, we could set project ID and inherit attribute to account > Directory usage, and implement a similar 'Directory Quota' based on this. Yes, that is a -use- of project quotas, but not the -only- use. Users have always been allowed to select what project their files belong to - it's a method of accounting space even when users cannot access all of the project information. > But Directories could easily break this limit by change its file to > other project ID. Yes. But then users are using the project quotas as traditional project quotas, which is just fine. There are users out there that use this mix of behaviours - users have a default directory quota to limit unbound space usage of home directories, but for files that belong to a specific project they simply change the project ID and now the space in their home directory those project files take up is accounted to the project rather than the user. > And we used vfs_ioc_fssetxattr_check() to only allow init userspace to > change project quota: Right, that's so directory quotas can be enforced for container use cases, preventing the users inside a container from modifying the project quota and escaping the space usage limit set for the container. This means project quotas are unavailable for use inside user namespaces as they are used for container resource usage limiting. > Shall we have something like following to limit admin change for > Project state too? As per above, that will break many existing use cases for project quotas, so I don't think we will be doing that. Cheers, Dave. -- Dave Chinner david@fromorbit.com