Message ID | efdf0cfa5a2ffe1fb9e08d3e1918a9a84385384b.1629807216.git.asml.silence@gmail.com |
---|---|
State | New |
Headers | show |
Series | [5.10,backport] io_uring: fix xa_alloc_cycle() error return value check | expand |
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!
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,