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=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_SANE_1 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 51B57C48BDB for ; Sun, 7 Jul 2019 20:42:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F58E2070D for ; Sun, 7 Jul 2019 20:42:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="BFEbX3np" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727451AbfGGUmA (ORCPT ); Sun, 7 Jul 2019 16:42:00 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45072 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727341AbfGGUmA (ORCPT ); Sun, 7 Jul 2019 16:42:00 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x67Kdg6j040664; Sun, 7 Jul 2019 20:41:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=tFrWHg/aAE67pxauKL0omt7gMkY1t0PbRirUnZNOjFA=; b=BFEbX3npPed4HkYp+Np8xDXCIBvbU4jZUtYeTUf4rGO4CCrpJn8aMtXHx2qnWARtQwj9 qk83CNMM/r2f10EVrcytEf96lHRdz1o6++hrMKFFGB/ey+aBdknesc9PWBfAC8Rngemt ZCV9wQ+k0ZpxY+KbQuexV+j/OP30UN5bm9loeCLOZuTTJDIO6/6i2LL5K1OLn6st/Y8n Ss4qtasRWvPWx37PZbSPFlgaNl77uma1leMPoBl5LoLo0ChXhV1TWbidOr3m/VX7Okhw l6pIDMnIctEFgjlmlKQYHL8wUoZcnkV3VbcxkZBa+8vbwUxD6U48M1qHKwx7qdAYoG2D xg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2tjm9qb80k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Jul 2019 20:41:44 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x67KcIiB014195; Sun, 7 Jul 2019 20:41:44 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2tjjyjx0mw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Jul 2019 20:41:44 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x67Kfh0C018360; Sun, 7 Jul 2019 20:41:43 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 07 Jul 2019 13:41:43 -0700 Date: Sun, 7 Jul 2019 13:41:39 -0700 From: "Darrick J. Wong" To: Eric Biggers Cc: Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 2/3] f2fs: use generic checking function for FS_IOC_FSSETXATTR Message-ID: <20190707204139.GJ1654093@magnolia> References: <20190701202630.43776-1-ebiggers@kernel.org> <20190701202630.43776-3-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190701202630.43776-3-ebiggers@kernel.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9311 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907070289 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9311 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907070289 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Mon, Jul 01, 2019 at 01:26:29PM -0700, Eric Biggers wrote: > From: Eric Biggers > > Make the f2fs implementation of FS_IOC_FSSETXATTR use the new VFS helper > function vfs_ioc_fssetxattr_check(), and remove the project quota check > since it's now done by the helper function. > > This is based on a patch from Darrick Wong, but reworked to apply after > commit 360985573b55 ("f2fs: separate f2fs i_flags from fs_flags and ext4 > i_flags"). > > Originally-from: Darrick J. Wong > Signed-off-by: Eric Biggers Looks ok, Reviewed-by: Darrick J. Wong --D > --- > fs/f2fs/file.c | 45 ++++++++++++++------------------------------- > 1 file changed, 14 insertions(+), 31 deletions(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index b5b941e6448657..ae1a54ecc9fccc 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -2857,52 +2857,32 @@ static inline u32 f2fs_xflags_to_iflags(u32 xflags) > return iflags; > } > > -static int f2fs_ioc_fsgetxattr(struct file *filp, unsigned long arg) > +static void f2fs_fill_fsxattr(struct inode *inode, struct fsxattr *fa) > { > - struct inode *inode = file_inode(filp); > struct f2fs_inode_info *fi = F2FS_I(inode); > - struct fsxattr fa; > > - memset(&fa, 0, sizeof(struct fsxattr)); > - fa.fsx_xflags = f2fs_iflags_to_xflags(fi->i_flags); > + simple_fill_fsxattr(fa, f2fs_iflags_to_xflags(fi->i_flags)); > > if (f2fs_sb_has_project_quota(F2FS_I_SB(inode))) > - fa.fsx_projid = (__u32)from_kprojid(&init_user_ns, > - fi->i_projid); > - > - if (copy_to_user((struct fsxattr __user *)arg, &fa, sizeof(fa))) > - return -EFAULT; > - return 0; > + fa->fsx_projid = from_kprojid(&init_user_ns, fi->i_projid); > } > > -static int f2fs_ioctl_check_project(struct inode *inode, struct fsxattr *fa) > +static int f2fs_ioc_fsgetxattr(struct file *filp, unsigned long arg) > { > - /* > - * Project Quota ID state is only allowed to change from within the init > - * namespace. Enforce that restriction only if we are trying to change > - * the quota ID state. Everything else is allowed in user namespaces. > - */ > - if (current_user_ns() == &init_user_ns) > - return 0; > - > - if (__kprojid_val(F2FS_I(inode)->i_projid) != fa->fsx_projid) > - return -EINVAL; > + struct inode *inode = file_inode(filp); > + struct fsxattr fa; > > - if (F2FS_I(inode)->i_flags & F2FS_PROJINHERIT_FL) { > - if (!(fa->fsx_xflags & FS_XFLAG_PROJINHERIT)) > - return -EINVAL; > - } else { > - if (fa->fsx_xflags & FS_XFLAG_PROJINHERIT) > - return -EINVAL; > - } > + f2fs_fill_fsxattr(inode, &fa); > > + if (copy_to_user((struct fsxattr __user *)arg, &fa, sizeof(fa))) > + return -EFAULT; > return 0; > } > > static int f2fs_ioc_fssetxattr(struct file *filp, unsigned long arg) > { > struct inode *inode = file_inode(filp); > - struct fsxattr fa; > + struct fsxattr fa, old_fa; > u32 iflags; > int err; > > @@ -2925,9 +2905,12 @@ static int f2fs_ioc_fssetxattr(struct file *filp, unsigned long arg) > return err; > > inode_lock(inode); > - err = f2fs_ioctl_check_project(inode, &fa); > + > + f2fs_fill_fsxattr(inode, &old_fa); > + err = vfs_ioc_fssetxattr_check(inode, &old_fa, &fa); > if (err) > goto out; > + > err = f2fs_setflags_common(inode, iflags, > f2fs_xflags_to_iflags(F2FS_SUPPORTED_XFLAGS)); > if (err) > -- > 2.22.0.410.gd8fdbe21b5-goog >