Skip to content

Commit 7015214

Browse files
committed
io_uring: abort file assignment prior to assigning creds
We need to either restore creds properly if we fail on the file assignment, or just do the file assignment first instead. Let's do the latter as it's simpler, should make no difference here for file assignment. Link: https://lore.kernel.org/lkml/000000000000a7edb305dca75a50@google.com/ Reported-by: syzbot+60c52ca98513a8760a91@syzkaller.appspotmail.com Fixes: 6bf9c47 ("io_uring: defer file assignment") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 7179c3c commit 7015214

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/io_uring.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7111,13 +7111,14 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
71117111
const struct cred *creds = NULL;
71127112
int ret;
71137113

7114+
if (unlikely(!io_assign_file(req, issue_flags)))
7115+
return -EBADF;
7116+
71147117
if (unlikely((req->flags & REQ_F_CREDS) && req->creds != current_cred()))
71157118
creds = override_creds(req->creds);
71167119

71177120
if (!io_op_defs[req->opcode].audit_skip)
71187121
audit_uring_entry(req->opcode);
7119-
if (unlikely(!io_assign_file(req, issue_flags)))
7120-
return -EBADF;
71217122

71227123
switch (req->opcode) {
71237124
case IORING_OP_NOP:

0 commit comments

Comments
 (0)