All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5.10 backport] io_uring: fix xa_alloc_cycle() error return value check
@ 2021-08-24 12:15 Pavel Begunkov
  2021-08-24 15:30 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-08-24 12:15 UTC (permalink / raw)
  To: Sasha Levin, stable; +Cc: Jens Axboe

From: Jens Axboe <axboe@kernel.dk>

[ upstream commit a30f895ad3239f45012e860d4f94c1a388b36d14 ]

We currently check for ret != 0 to indicate error, but '1' is a valid
return and just indicates that the allocation succeeded with a wrap.
Correct the check to be for < 0, like it was before the xarray
conversion.

Cc: stable@vger.kernel.org
Fixes: 61cf93700fe6 ("io_uring: Convert personality_idr to XArray")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 fs/io_uring.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 8492b4e7c4d7..108b0ed31c11 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -9602,11 +9602,12 @@ static int io_register_personality(struct io_ring_ctx *ctx)
 
 	ret = xa_alloc_cyclic(&ctx->personalities, &id, (void *)iod,
 			XA_LIMIT(0, USHRT_MAX), &ctx->pers_next, GFP_KERNEL);
-	if (!ret)
-		return id;
-	put_cred(iod->creds);
-	kfree(iod);
-	return ret;
+	if (ret < 0) {
+		put_cred(iod->creds);
+		kfree(iod);
+		return ret;
+	}
+	return id;
 }
 
 static int io_register_restrictions(struct io_ring_ctx *ctx, void __user *arg,
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 5.10 backport] io_uring: fix xa_alloc_cycle() error return value check
  2021-08-24 12:15 [PATCH 5.10 backport] io_uring: fix xa_alloc_cycle() error return value check Pavel Begunkov
@ 2021-08-24 15:30 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2021-08-24 15:30 UTC (permalink / raw)
  To: Pavel Begunkov; +Cc: stable, Jens Axboe

On Tue, Aug 24, 2021 at 01:15:01PM +0100, Pavel Begunkov wrote:
>From: Jens Axboe <axboe@kernel.dk>
>
>[ upstream commit a30f895ad3239f45012e860d4f94c1a388b36d14 ]
>
>We currently check for ret != 0 to indicate error, but '1' is a valid
>return and just indicates that the allocation succeeded with a wrap.
>Correct the check to be for < 0, like it was before the xarray
>conversion.
>
>Cc: stable@vger.kernel.org
>Fixes: 61cf93700fe6 ("io_uring: Convert personality_idr to XArray")
>Signed-off-by: Jens Axboe <axboe@kernel.dk>
>Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>

Queued up, thanks!

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-24 15:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 12:15 [PATCH 5.10 backport] io_uring: fix xa_alloc_cycle() error return value check Pavel Begunkov
2021-08-24 15:30 ` Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.