Skip to content

Commit 31d00f6

Browse files
committed
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
2 parents 643e69a + f26c08b commit 31d00f6

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

fs/io_uring.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ static bool io_identity_cow(struct io_kiocb *req)
12841284
*/
12851285
io_init_identity(id);
12861286
if (creds)
1287-
req->work.identity->creds = creds;
1287+
id->creds = creds;
12881288

12891289
/* add one for this request */
12901290
refcount_inc(&id->count);
@@ -9183,6 +9183,7 @@ static int io_uring_get_fd(struct io_ring_ctx *ctx)
91839183
{
91849184
struct file *file;
91859185
int ret;
9186+
int fd;
91869187

91879188
#if defined(CONFIG_UNIX)
91889189
ret = sock_create_kern(&init_net, PF_UNIX, SOCK_RAW, IPPROTO_IP,
@@ -9194,25 +9195,27 @@ static int io_uring_get_fd(struct io_ring_ctx *ctx)
91949195
ret = get_unused_fd_flags(O_RDWR | O_CLOEXEC);
91959196
if (ret < 0)
91969197
goto err;
9198+
fd = ret;
91979199

91989200
file = anon_inode_getfile("[io_uring]", &io_uring_fops, ctx,
91999201
O_RDWR | O_CLOEXEC);
92009202
if (IS_ERR(file)) {
9201-
err_fd:
9202-
put_unused_fd(ret);
9203+
put_unused_fd(fd);
92039204
ret = PTR_ERR(file);
92049205
goto err;
92059206
}
92069207

92079208
#if defined(CONFIG_UNIX)
92089209
ctx->ring_sock->file = file;
92099210
#endif
9210-
if (unlikely(io_uring_add_task_file(ctx, file))) {
9211-
file = ERR_PTR(-ENOMEM);
9212-
goto err_fd;
9211+
ret = io_uring_add_task_file(ctx, file);
9212+
if (ret) {
9213+
fput(file);
9214+
put_unused_fd(fd);
9215+
goto err;
92139216
}
9214-
fd_install(ret, file);
9215-
return ret;
9217+
fd_install(fd, file);
9218+
return fd;
92169219
err:
92179220
#if defined(CONFIG_UNIX)
92189221
sock_release(ctx->ring_sock);

0 commit comments

Comments
 (0)