提交 31d00f6e 编写于 作者: L Linus Torvalds

Merge tag 'io_uring-5.10-2020-12-11' of git://git.kernel.dk/linux-block

Pull io_uring fixes from Jens Axboe:
 "Two fixes in here, fixing issues introduced in this merge window"

* tag 'io_uring-5.10-2020-12-11' of git://git.kernel.dk/linux-block:
  io_uring: fix file leak on error path of io ctx creation
  io_uring: fix mis-seting personality's creds
...@@ -1284,7 +1284,7 @@ static bool io_identity_cow(struct io_kiocb *req) ...@@ -1284,7 +1284,7 @@ static bool io_identity_cow(struct io_kiocb *req)
*/ */
io_init_identity(id); io_init_identity(id);
if (creds) if (creds)
req->work.identity->creds = creds; id->creds = creds;
/* add one for this request */ /* add one for this request */
refcount_inc(&id->count); refcount_inc(&id->count);
...@@ -9183,6 +9183,7 @@ static int io_uring_get_fd(struct io_ring_ctx *ctx) ...@@ -9183,6 +9183,7 @@ static int io_uring_get_fd(struct io_ring_ctx *ctx)
{ {
struct file *file; struct file *file;
int ret; int ret;
int fd;
#if defined(CONFIG_UNIX) #if defined(CONFIG_UNIX)
ret = sock_create_kern(&init_net, PF_UNIX, SOCK_RAW, IPPROTO_IP, ret = sock_create_kern(&init_net, PF_UNIX, SOCK_RAW, IPPROTO_IP,
...@@ -9194,12 +9195,12 @@ static int io_uring_get_fd(struct io_ring_ctx *ctx) ...@@ -9194,12 +9195,12 @@ static int io_uring_get_fd(struct io_ring_ctx *ctx)
ret = get_unused_fd_flags(O_RDWR | O_CLOEXEC); ret = get_unused_fd_flags(O_RDWR | O_CLOEXEC);
if (ret < 0) if (ret < 0)
goto err; goto err;
fd = ret;
file = anon_inode_getfile("[io_uring]", &io_uring_fops, ctx, file = anon_inode_getfile("[io_uring]", &io_uring_fops, ctx,
O_RDWR | O_CLOEXEC); O_RDWR | O_CLOEXEC);
if (IS_ERR(file)) { if (IS_ERR(file)) {
err_fd: put_unused_fd(fd);
put_unused_fd(ret);
ret = PTR_ERR(file); ret = PTR_ERR(file);
goto err; goto err;
} }
...@@ -9207,12 +9208,14 @@ static int io_uring_get_fd(struct io_ring_ctx *ctx) ...@@ -9207,12 +9208,14 @@ static int io_uring_get_fd(struct io_ring_ctx *ctx)
#if defined(CONFIG_UNIX) #if defined(CONFIG_UNIX)
ctx->ring_sock->file = file; ctx->ring_sock->file = file;
#endif #endif
if (unlikely(io_uring_add_task_file(ctx, file))) { ret = io_uring_add_task_file(ctx, file);
file = ERR_PTR(-ENOMEM); if (ret) {
goto err_fd; fput(file);
put_unused_fd(fd);
goto err;
} }
fd_install(ret, file); fd_install(fd, file);
return ret; return fd;
err: err:
#if defined(CONFIG_UNIX) #if defined(CONFIG_UNIX)
sock_release(ctx->ring_sock); sock_release(ctx->ring_sock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册