* [PATCH] xfs: don't wrap ID in xfs_dq_get_next_id
@ 2016-12-17 0:05 Eric Sandeen
2016-12-19 10:26 ` Christoph Hellwig
2017-01-13 22:48 ` Eric Sandeen
0 siblings, 2 replies; 3+ messages in thread
From: Eric Sandeen @ 2016-12-17 0:05 UTC (permalink / raw)
To: linux-xfs
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>
---
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 7a30b8f..dbeddd9 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -710,6 +710,10 @@
/* Simple advance */
next_id = *id + 1;
+ /* If we'd wrap past the max ID, stop */
+ if (next_id < *id)
+ return -ENOENT;
+
/* If new ID is within the current chunk, advancing it sufficed */
if (next_id % mp->m_quotainfo->qi_dqperchunk) {
*id = next_id;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: don't wrap ID in xfs_dq_get_next_id
2016-12-17 0:05 [PATCH] xfs: don't wrap ID in xfs_dq_get_next_id Eric Sandeen
@ 2016-12-19 10:26 ` Christoph Hellwig
2017-01-13 22:48 ` Eric Sandeen
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2016-12-19 10:26 UTC (permalink / raw)
To: Eric Sandeen; +Cc: linux-xfs
On Fri, Dec 16, 2016 at 06:05:20PM -0600, Eric Sandeen wrote:
> 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>
Looks fine,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: don't wrap ID in xfs_dq_get_next_id
2016-12-17 0:05 [PATCH] xfs: don't wrap ID in xfs_dq_get_next_id Eric Sandeen
2016-12-19 10:26 ` Christoph Hellwig
@ 2017-01-13 22:48 ` Eric Sandeen
1 sibling, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2017-01-13 22:48 UTC (permalink / raw)
To: Eric Sandeen, linux-xfs, djwong
On 12/16/16 6:05 PM, Eric Sandeen wrote:
> 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>
Ping on this? sorry for not noticing its absence sooner.
Has rvb:hch on the thread.
-Eric
> ---
>
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index 7a30b8f..dbeddd9 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -710,6 +710,10 @@
> /* Simple advance */
> next_id = *id + 1;
>
> + /* If we'd wrap past the max ID, stop */
> + if (next_id < *id)
> + return -ENOENT;
> +
> /* If new ID is within the current chunk, advancing it sufficed */
> if (next_id % mp->m_quotainfo->qi_dqperchunk) {
> *id = next_id;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-13 22:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-17 0:05 [PATCH] xfs: don't wrap ID in xfs_dq_get_next_id Eric Sandeen
2016-12-19 10:26 ` Christoph Hellwig
2017-01-13 22:48 ` Eric Sandeen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).