Skip to content

Commit d03ef4d

Browse files
Wang ShilongDarrick J. Wong
authored andcommitted
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: Wang Shilong <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent c500bee commit d03ef4d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/ioctl.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,14 @@ static int fileattr_set_prepare(struct inode *inode,
817817
if ((old_ma->fsx_xflags ^ fa->fsx_xflags) &
818818
FS_XFLAG_PROJINHERIT)
819819
return -EINVAL;
820+
} else {
821+
/*
822+
* Caller is allowed to change the project ID. If it is being
823+
* changed, make sure that the new value is valid.
824+
*/
825+
if (old_ma->fsx_projid != fa->fsx_projid &&
826+
!projid_valid(make_kprojid(&init_user_ns, fa->fsx_projid)))
827+
return -EINVAL;
820828
}
821829

822830
/* Check extent size hints. */

0 commit comments

Comments
 (0)