提交 a2ae87d2 编写于 作者: J Jens Axboe 提交者: Zheng Zengkai

io_uring: fix xa_alloc_cycle() error return value check

stable inclusion
from stable-5.10.61
commit 695ab28a7fa107d0350ab19eba8ec89fac45a95d
bugzilla: 177029 https://gitee.com/openeuler/kernel/issues/I4EAXD

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=695ab28a7fa107d0350ab19eba8ec89fac45a95d

--------------------------------

[ upstream commit a30f895a ]

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: 61cf9370 ("io_uring: Convert personality_idr to XArray")
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 7b286885
...@@ -9601,11 +9601,12 @@ static int io_register_personality(struct io_ring_ctx *ctx) ...@@ -9601,11 +9601,12 @@ static int io_register_personality(struct io_ring_ctx *ctx)
ret = xa_alloc_cyclic(&ctx->personalities, &id, (void *)iod, ret = xa_alloc_cyclic(&ctx->personalities, &id, (void *)iod,
XA_LIMIT(0, USHRT_MAX), &ctx->pers_next, GFP_KERNEL); XA_LIMIT(0, USHRT_MAX), &ctx->pers_next, GFP_KERNEL);
if (!ret) if (ret < 0) {
return id; put_cred(iod->creds);
put_cred(iod->creds); kfree(iod);
kfree(iod); return ret;
return ret; }
return id;
} }
static int io_register_restrictions(struct io_ring_ctx *ctx, void __user *arg, static int io_register_restrictions(struct io_ring_ctx *ctx, void __user *arg,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册