Skip to content

Commit 657bdfb

Browse files
Eric Sandeendjwong
authored andcommitted
xfs: don't wrap ID in xfs_dq_get_next_id
The GETNEXTQOTA ioctl takes whatever ID is sent in, and looks for the next active quota for an user equal or higher to that ID. But if we are at the maximum ID and then ask for the "next" one, we may wrap back to zero. In this case, userspace may loop forever, because it will start querying again at zero. We'll fix this in userspace as well, but for the kernel, return -ENOENT if we ask for the next quota ID past UINT_MAX so the caller knows to stop. Signed-off-by: Eric Sandeen <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent a324cbf commit 657bdfb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/xfs/xfs_dquot.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,10 @@ xfs_dq_get_next_id(
710710
/* Simple advance */
711711
next_id = *id + 1;
712712

713+
/* If we'd wrap past the max ID, stop */
714+
if (next_id < *id)
715+
return -ENOENT;
716+
713717
/* If new ID is within the current chunk, advancing it sufficed */
714718
if (next_id % mp->m_quotainfo->qi_dqperchunk) {
715719
*id = next_id;

0 commit comments

Comments
 (0)