OSDN Git Service

xfs: don't wrap ID in xfs_dq_get_next_id
authorEric Sandeen <sandeen@redhat.com>
Thu, 2 Feb 2017 07:56:04 +0000 (08:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 4 Feb 2017 08:47:12 +0000 (09:47 +0100)
commitd062d90c35f292b3e6ee266746259e2e2950f940
tree1c6bb6ee1491d78200b3245593975415e01a3c63
parentd3201a14b36ae6ffb36b6b830e216f0ae4ebc184
xfs: don't wrap ID in xfs_dq_get_next_id

commit 657bdfb7f5e68ca5e2ed009ab473c429b0d6af85 upstream.

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 <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/xfs/xfs_dquot.c