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=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=ham 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 6F947C4360F for ; Sun, 3 Mar 2019 23:01:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4927A20842 for ; Sun, 3 Mar 2019 23:01:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725981AbfCCXBO (ORCPT ); Sun, 3 Mar 2019 18:01:14 -0500 Received: from ipmail06.adl6.internode.on.net ([150.101.137.145]:65272 "EHLO ipmail06.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725933AbfCCXBO (ORCPT ); Sun, 3 Mar 2019 18:01:14 -0500 Received: from ppp59-167-129-252.static.internode.on.net (HELO dastard) ([59.167.129.252]) by ipmail06.adl6.internode.on.net with ESMTP; 04 Mar 2019 09:31:08 +1030 Received: from dave by dastard with local (Exim 4.80) (envelope-from ) id 1h0a6U-0005Yq-G0; Mon, 04 Mar 2019 10:01:06 +1100 Date: Mon, 4 Mar 2019 10:01:06 +1100 From: Dave Chinner To: Wang Shilong Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, lixi@ddn.com, adilger@dilger.ca, Wang Shilong Subject: Re: [PATCH 5/8] fs: add project support to statx Message-ID: <20190303230106.GS23020@dastard> References: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> <1551449141-7884-6-git-send-email-wshilong1991@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1551449141-7884-6-git-send-email-wshilong1991@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Mar 01, 2019 at 11:05:38PM +0900, Wang Shilong wrote: > From: Wang Shilong > > From: Wang Shilong > > Extend statx to support project ID and inherit attribute. > > Signed-off-by: Wang Shilong > --- > fs/stat.c | 1 + > include/linux/stat.h | 2 ++ > include/uapi/linux/stat.h | 8 ++++++-- > tools/include/uapi/linux/stat.h | 8 ++++++-- > 4 files changed, 15 insertions(+), 4 deletions(-) > > diff --git a/fs/stat.c b/fs/stat.c > index adbfcd86c81b..82d855c4647c 100644 > --- a/fs/stat.c > +++ b/fs/stat.c > @@ -551,6 +551,7 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer) > tmp.stx_rdev_minor = MINOR(stat->rdev); > tmp.stx_dev_major = MAJOR(stat->dev); > tmp.stx_dev_minor = MINOR(stat->dev); > + tmp.stx_projid = (u32)from_kprojid(&init_user_ns, stat->projid); If we are not in the init_user_ns, the project ID should be zero - it should not be changeable or visible at all. I'm guessing the next patches enforce this? Regardless, the cast to (u32) should not be necessary. Hmmmm. /me looks at from_kprojid_munged() and thinks it needs to be nuked from orbit. There is no such thing as an "overflow" project ID, and 65534 is a valid XFS project ID. > diff --git a/tools/include/uapi/linux/stat.h b/tools/include/uapi/linux/stat.h > index 7b35e98d3c58..21b542b3b061 100644 > --- a/tools/include/uapi/linux/stat.h > +++ b/tools/include/uapi/linux/stat.h > @@ -123,7 +123,9 @@ struct statx { > __u32 stx_dev_major; /* ID of device containing file [uncond] */ > __u32 stx_dev_minor; > /* 0x90 */ > - __u64 __spare2[14]; /* Spare space for future expansion */ > + __u32 stx_projid; /* Project ID of file */ > + __u32 __spare1[1]; > + __u64 __spare2[13]; /* Spare space for future expansion */ > /* 0x100 */ > }; > > @@ -148,7 +150,8 @@ struct statx { > #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ > #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ > #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ > -#define STATX_ALL 0x00000fffU /* All currently supported flags */ > +#define STATX_PROJID 0x00001000U /* Want/Got stx_projid */ > +#define STATX_ALL 0x00001fffU /* All currently supported flags */ > #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ > > /* > @@ -170,5 +173,6 @@ struct statx { > > #define STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */ > > +#define STATX_ATTR_PROJINHERIT 0x00002000 /* [I] File project inherit is set */ ^^^^ The project ID inherit attribute is only valid for directories, not files. Also, should probably be named STATX_ATTR_PROJID_INHERIT. Cheers, Dave. -- Dave Chinner david@fromorbit.com