From 2087009c74d41ab8579f08157bca55b7d0857ee5 Mon Sep 17 00:00:00 2001
From: Ye Bin <yebin10@huawei.com>
Date: Mon, 29 Nov 2021 12:15:37 +0800
Subject: [PATCH] io_uring: validate timespec for timeout removals
Git-commit: 2087009c74d41ab8579f08157bca55b7d0857ee5
Patch-mainline: v5.17-rc1
References: bsc#1205205
Like commit f6223ff79966, timeout removal should also validate the
timespec that is being passed in.
Signed-off-by: Ye Bin <yebin10@huawei.com>
Link: https://lore.kernel.org/r/20211129041537.1936270-1-yebin10@huawei.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
---
fs/io_uring.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 08b1b3de9b3f..8b6bfed16f65 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -6111,6 +6111,8 @@ static int io_timeout_remove_prep(struct io_kiocb *req,
return -EINVAL;
if (get_timespec64(&tr->ts, u64_to_user_ptr(sqe->addr2)))
return -EFAULT;
+ if (tr->ts.tv_sec < 0 || tr->ts.tv_nsec < 0)
+ return -EINVAL;
} else if (tr->flags) {
/* timeout removal doesn't support flags */
return -EINVAL;
--
2.35.3