From: Jens Axboe axboe@kernel.dk
mainline inclusion from mainline-5.6-rc2 commit 0b5faf6ba7fb78bb1fe7336d23ea1978386a6c3a category: feature bugzilla: https://bugzilla.openeuler.org/show_bug.cgi?id=27 CVE: NA ---------------------------
Don't just check for dirfd == -1, we should allow AT_FDCWD as well for relative lookups.
Signed-off-by: Jens Axboe axboe@kernel.dk Signed-off-by: yangerkun yangerkun@huawei.com Reviewed-by: zhangyi (F) yi.zhang@huawei.com Signed-off-by: Cheng Jian cj.chengjian@huawei.com --- fs/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c index 64faee19c82f..50576b9403df 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4479,7 +4479,7 @@ static int io_req_needs_file(struct io_kiocb *req, int fd) { if (!io_op_defs[req->opcode].needs_file) return 0; - if (fd == -1 && io_op_defs[req->opcode].fd_non_neg) + if ((fd == -1 || fd == AT_FDCWD) && io_op_defs[req->opcode].fd_non_neg) return 0; return 1; }