Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3058070pxv; Sun, 27 Jun 2021 17:40:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrr2J+vJdnaZRNX4NOLsiBGMyDOZk66ltKldnyN1OQxNAU26MNl1mThWfEFPcaYqgkq8Bk X-Received: by 2002:a17:906:2844:: with SMTP id s4mr21573973ejc.263.1624840836611; Sun, 27 Jun 2021 17:40:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624840836; cv=none; d=google.com; s=arc-20160816; b=uIesaJOA24cX9fhqUJkIc8MWNlKAi0kqbbh2L28GaKB4zilQMaQHdqVSBmwpyItHd1 k4M8+8akqUCwB8GyIjESykYBlaF+LBQ895sNgSTL+YpKhwIL1OjSv1aHk5v7jNSk/9rD Uy3qaLGkh3Ymzou4bt6y4HbDjudXbWRA/6Qj0hecSl0Mgk3El80NdSB2yVcu/E2W+gLG w56R6+dZ9VsXmpvrvx3+iOJEe58Vi93opFhPOx6KIAqkTZG0aSn/L2Zn/7QHEPRZZd7x xeiYEKOZBp+NPcHdy5ha3ZdtkIIl8lmjj9UH8E3k2sdA6XSCQiDlHL4vWATPIpL53f64 /r2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=pMZuH9dCCRNmuCCbatc5WOB5AN60SS3oMwtPLqqm5Ks=; b=PnEBMQGjtXMUQ+e97ZxVTTdgr0npRenDgcxpSgNuFLeHyveKGSXH8k2Bwt24BEnHyd gDnhqy7R+1Iy5E9XLlzTEdye6vWCdw+uCvd9N8VX1DyOXjYM9OiOa9lRYkqgXtTtG1fH qUnKCzNhK09XzYj96HZVvP8G8hrWew8pOpujFuZJRwj6jMefErpFS85mhtBgXc3fKXR/ aserYwoUh8rzU0VeTSBiMBSKNcOtUpD9QnYOlaAGFRIdebQVyEr0rGONk5AgpLSGXjJo 7naL2YgxPTS5AFA/XrSTa5PgstvDGbmmDe5tyfU1siGBM5jBKSgu/lYg65RCclt+FqJo qM4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j9si8009311edw.41.2021.06.27.17.39.59; Sun, 27 Jun 2021 17:40:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231709AbhF1AmW (ORCPT + 99 others); Sun, 27 Jun 2021 20:42:22 -0400 Received: from mail110.syd.optusnet.com.au ([211.29.132.97]:37016 "EHLO mail110.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231689AbhF1AmW (ORCPT ); Sun, 27 Jun 2021 20:42:22 -0400 Received: from dread.disaster.area (pa49-179-138-183.pa.nsw.optusnet.com.au [49.179.138.183]) by mail110.syd.optusnet.com.au (Postfix) with ESMTPS id 7D784107992; Mon, 28 Jun 2021 10:39:55 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1lxfJa-000Buk-6p; Mon, 28 Jun 2021 10:39:54 +1000 Date: Mon, 28 Jun 2021 10:39:54 +1000 From: Dave Chinner To: Wang Shilong Cc: Ext4 Developers List , Wang Shilong Subject: Re: [PATCH] ext4: forbid U32_MAX project ID Message-ID: <20210628003954.GM2419729@dread.disaster.area> References: <20210625124033.5639-1-wangshilong1991@gmail.com> <20210627224217.GL2419729@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=F8MpiZpN c=1 sm=1 tr=0 a=MnllW2CieawZLw/OcHE/Ng==:117 a=MnllW2CieawZLw/OcHE/Ng==:17 a=kj9zAlcOel0A:10 a=r6YtysWOX24A:10 a=7-415B0cAAAA:8 a=lB0dNpNiAAAA:8 a=9nCa61v3IhUg5NtY66YA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 a=c-ZiYqmG3AbHTdtsH08C:22 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Jun 28, 2021 at 07:13:04AM +0800, Wang Shilong wrote: > On Mon, Jun 28, 2021 at 6:42 AM Dave Chinner wrote: > > > > On Fri, Jun 25, 2021 at 08:40:33AM -0400, Wang Shilong wrote: > > > From: Wang Shilong > > > > > > U32_MAX is reserved for special purpose, > > > qid_has_mapping() will return false if projid is > > > 4294967295, dqget() will return NULL for it. > > > > > > So U32_MAX is unsupported Project ID, fix to forbid > > > it. > > > > Actually, it's INVALID_PROJID, not U32_MAX, and we already have a > > check function for that: > > > > static inline bool projid_valid(kprojid_t projid) > > { > > return !projid_eq(projid, INVALID_PROJID); > > } > > > > I was not aware of this, thanks for pointing it out. > > > > Signed-off-by: Wang Shilong > > > --- > > > fs/ext4/ioctl.c | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > > > diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c > > > index 31627f7dc5cd..f3a8d962c291 100644 > > > --- a/fs/ext4/ioctl.c > > > +++ b/fs/ext4/ioctl.c > > > @@ -744,6 +744,9 @@ int ext4_fileattr_set(struct user_namespace *mnt_userns, > > > u32 flags = fa->flags; > > > int err = -EOPNOTSUPP; > > > > > > + if (fa->fsx_projid >= U32_MAX) > > > + return -EINVAL; > > > + > > > > This should actually be calling qid_valid() or projid_valid(), > > and it should be in generic code because multiple filesystems > > support project quotas. i.e this should be checked in > > fileattr_set_prepare(), not in ext4 specific code. > > I tried to fix ext4/f2fs, i am not sure about XFS, it looks to me XFS > implemented quota mostly by itself. Yes, XFS is where project quotas originally come from - XFS has had project quotas since quotas were first implemented in XFS back in 1995, long before it was ported to Linux. Ext4 and other filesystems are very recent Linux re-implementations, hence the different quota infrastructure. As it is, XFS project quotas can be queried and controlled through the same generic linux quota APIs ithat ext4 uses as well as it's own.... But the above change is not in quota code - you're changing code in the FS_IOC_FSSETXATTR ioctl call (again, originally XFS code, but lifted to the VFS level so ext4 et al can manipulate project quotas). Hence parameter validity checks for parameters need to be done at the VFS layers... > Anyway, let me fix this in generic code. Thanks! Cheers, -Dave. -- Dave Chinner david@fromorbit.com