diff options
author | Wang Shilong <wshilong@ddn.com> | 2021-08-06 09:06:00 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2021-09-12 17:02:38 -0700 |
commit | 58b39fb82fe5290cddcf5e067b7b3108292d9918 (patch) | |
tree | ce1079ba38e3196b263f05e1cd6da3113935d05f | |
parent | 7d2a07b769330c34b4deabeed939325c77a7ec2f (diff) |
fs: forbid invalid project IDvfs-5.15-merge_2021-09-12
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 <wshilong@ddn.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r-- | fs/ioctl.c | 8 |
1 files changed, 8 insertions, 0 deletions
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; } /* Check extent size hints. */ |