Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp65900pxv; Tue, 13 Jul 2021 22:08:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+yJNb5tjVizHqu3IQReD84uhp/CSUZVxEs7dPUeWSQNQwqhBGC4jhAdD2TSFz/IDCTfZy X-Received: by 2002:a05:6402:692:: with SMTP id f18mr10875418edy.327.1626239318073; Tue, 13 Jul 2021 22:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626239318; cv=none; d=google.com; s=arc-20160816; b=lKcoG7xtBWriLnHZ6d2L8x0RT3ml9h0HzmHAW/T5H5+j64Z+MTkQ8QY9WQGrJtd7LE LrUPFeXSyeJb27ydFfRVP+XgV9i22pM6FeuscQQJDqFrCUZvF9LCOdI6RllQxKXGGvGa HyVTkp4ew9fQQXRda73czLPVsa5OZV2WUGkrZzDOUrFEH9m9lmgEE3rVUsX2U9F+iFjU RL+FT6Uji0ULJVMrS0rbY1KvAGdSIo32u6c1WKkuez51VGJAcWzEYhxl5v5tVIcV+gx1 yhG5EKhplPJb0IIqTUTlJBFbV8z2NqhJZroDvUpYxnqnQ5ydalYwb3+7e7UWKqquRrMD PrTA== 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:dkim-signature; bh=ep25NXGaKy7iLmv/hLzAs5+NAintJ3fq7jB/7+yc6ZY=; b=OGR3oUDqBbNfJLg676kAxyn7ORUyHm5Q83PiMF2yGRtBYjcWyDeMTiy+5Ep2TYfDbp MTiynicuhYKY2Z42CSzqtw6/gAqwX1gNrAX9sERJ/YzvfTt7lF6GyvRJiebgblZzrvof h5W+0jvZVtGN40UWOb4GulI9P+p3j8NHbYGam0oo7zWZs0JL0QZXObrHJxFk0CEDidac cT9nPYb/PiVNOwmI7woMjc7P64W/jUL34IQ96Q9tVdJYvxZyVN/TH8Mx7Af9j+CwVisv sbTydtejkAueWR3He8pDKC+tBWpRFq2e35PLuJ1ohaF9bt/KWZ48/+Eq6ttHBPqzkluu 4nog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="UWnd/Yze"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v24si1365889ejv.518.2021.07.13.22.08.00; Tue, 13 Jul 2021 22:08:38 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="UWnd/Yze"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237864AbhGNFH2 (ORCPT + 99 others); Wed, 14 Jul 2021 01:07:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:39830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbhGNFH2 (ORCPT ); Wed, 14 Jul 2021 01:07:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 016B960FD8; Wed, 14 Jul 2021 05:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626239077; bh=Jc1sNtDQLolCUqZGQica4040YhI273wmJsvNWUazVMU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UWnd/YzekvcZgciRPDO2VDGc5jefYAa1w8p3Vjj4SV7C/lPk0nz0bWt6/xjz0r+LN /vsMehsZND0VXQBUpUt+yqOmVnh0nJnnv+5jeOHtFoErWyN5uO26GhuWQGXnZYFNtx rZxXFverfex9HCcHFguzDqBLrC7mc41WwHaKY51njN+ELp1nH80BNjSPGnY7xW1Wh8 WXJ/XCZ0IShzVBu2YPhe/z0Ytdvm3PViCRMF7DWftS9pUMgBxyyzamzDc1wq5GelGt I8To5FlidFdvSjJH5ie48P6mPDmR8ggS4bVkzvnSXWnzw4y1TT5TD1a3/A5cRrodnt 8Gl0faYQvuXbQ== Date: Tue, 13 Jul 2021 22:04:36 -0700 From: "Darrick J. Wong" To: Wang Shilong Cc: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Wang Shilong Subject: Re: [PATCH v4] fs: forbid invalid project ID Message-ID: <20210714050436.GH22402@magnolia> References: <20210710143959.58077-1-wangshilong1991@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210710143959.58077-1-wangshilong1991@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Sat, Jul 10, 2021 at 10:39:59PM +0800, Wang Shilong wrote: > From: Wang Shilong > > fileattr_set_prepare() should check if project ID > is valid, otherwise dqget() will return NULL for > such project ID quota. > > Signed-off-by: Wang Shilong > --- > v3->v3: > only check project Id if caller is allowed > to change and being changed. > > v2->v3: move check before @fsx_projid is accessed > and use make_kprojid() helper. > > v1->v2: try to fix in the VFS > fs/ioctl.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/fs/ioctl.c b/fs/ioctl.c > index 1e2204fa9963..d4fabb5421cd 100644 > --- a/fs/ioctl.c > +++ b/fs/ioctl.c > @@ -817,6 +817,14 @@ static int fileattr_set_prepare(struct inode *inode, > if ((old_ma->fsx_xflags ^ fa->fsx_xflags) & > FS_XFLAG_PROJINHERIT) > return -EINVAL; > + } else { > + /* > + * Caller is allowed to change the project ID. If it is being > + * changed, make sure that the new value is valid. > + */ > + if (old_ma->fsx_projid != fa->fsx_projid && > + !projid_valid(make_kprojid(&init_user_ns, fa->fsx_projid))) > + return -EINVAL; Hmm, for XFS this is sort of a userspace-breaking change in the sense that (technically) we've never rejected -1 before. xfs_quota won't have anything to do with that, and (assuming I read the helper/macro gooeyness correctly) the vfs quota code won't either, so Reviewed-by: Darrick J. Wong --D > } > > /* Check extent size hints. */ > -- > 2.27.0 >