Commit d03ef4da authored by Wang Shilong's avatar Wang Shilong Committed by Darrick J. Wong
Browse files

fs: forbid invalid project ID



fileattr_set_prepare() should check if project ID
is valid, otherwise dqget() will return NULL for
such project ID quota.

Signed-off-by: default avatarWang Shilong <wshilong@ddn.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent c500bee1
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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. */