Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2995501pxv; Sun, 27 Jun 2021 15:42:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJdlh6UlgL5wwoBoZFmHsBKupMaKEToa7Czv/Mw7Oib2yOneWAPTodd5NPHAWKbwxdVMIg X-Received: by 2002:a5e:9306:: with SMTP id k6mr19034220iom.157.1624833767982; Sun, 27 Jun 2021 15:42:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624833767; cv=none; d=google.com; s=arc-20160816; b=0nxvK5cW5QZbr+7R8k5aj2OfTF23QS5iJk8I/FYZ+tjmZGNo1Ecpl4hNCf7d/2rD/A A3qah8LtfkuajuRJiA6qH931nvcNLBfnuh40erLSpjzq7/bC5Vl/8ey8j8QvGHuhd2nm 1fbkFOe2FayKY/2ETP4XDCbrrkPfSU08/bdEP5u4w16XW+7aLaPsqk61HmToCkg/kYob iidWKbjX5Xv+0BmSvprp947vbFsIbi2dBZxWOwMdECcoT1FDu84fpaXsOhCWBwJwIBqP Q8z67c2LXKSdVU1f1V9H3NIykZYYkD807HnmKWarnPz3Wjp//IVZWiYDWd2rVYr7ZlKs l5+g== 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=BikRKmLm9lo0Knrq4QWzQ2/3x6COsa0xQQMOa+VzyCU=; b=N2fvoFmNxEcfF1iciufwaSmVNfDXAGEinojI3P8i7fU1fgTw9A1RJ5oYPMIbUPpJV0 x2svigdeW2PfG0yP0x03L8mD0wOfAVle9EMnecnf04KSp5tV0oy6e2Z/t4lGAnVRv7Om 5iHYOE014hrxSoHNXqDUR7mwLvO7VlO30isP/WJV7XYReyYZkdm/uz2kN59ToP7xME/r 9eruW0WnR/iD78QuHRcZd7FZdUuswH7r8r3NsG7GJ7/W95E1IAhpduwrEsIQFHLme10X e/LmhMKM8Z14a0ECepIyruDf0ooRuYhM6c38nZ15o1upXuHnaS4dGtWVTP/3ZYoRia9u WOaQ== 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 j20si14022295ilo.0.2021.06.27.15.42.24; Sun, 27 Jun 2021 15:42:47 -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 S231737AbhF0Woq (ORCPT + 99 others); Sun, 27 Jun 2021 18:44:46 -0400 Received: from mail108.syd.optusnet.com.au ([211.29.132.59]:45699 "EHLO mail108.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231644AbhF0Wop (ORCPT ); Sun, 27 Jun 2021 18:44:45 -0400 Received: from dread.disaster.area (pa49-179-138-183.pa.nsw.optusnet.com.au [49.179.138.183]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id A5D9F1B093D; Mon, 28 Jun 2021 08:42:18 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1lxdTl-0009vs-If; Mon, 28 Jun 2021 08:42:17 +1000 Date: Mon, 28 Jun 2021 08:42:17 +1000 From: Dave Chinner To: Wang Shilong Cc: linux-ext4@vger.kernel.org, Wang Shilong Subject: Re: [PATCH] ext4: forbid U32_MAX project ID Message-ID: <20210627224217.GL2419729@dread.disaster.area> References: <20210625124033.5639-1-wangshilong1991@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210625124033.5639-1-wangshilong1991@gmail.com> 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=lB0dNpNiAAAA:8 a=7-415B0cAAAA:8 a=olheZxfBlaoEw9cQjO0A:9 a=CjuIK1q_8ugA:10 a=c-ZiYqmG3AbHTdtsH08C:22 a=biEYGPWJfzWAr4FL6Ov7:22 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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); } > 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. Cheers, Dave. -- Dave Chinner david@fromorbit.com