From: Ye Bin <yebin10@huawei.com>
To: <axboe@kernel.dk>, <asml.silence@gmail.com>,
<io-uring@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Ye Bin <yebin10@huawei.com>
Subject: [PATCH -next] io_uring: use timespec64_valid() to verify time value
Date: Thu, 2 Dec 2021 14:49:46 +0800 [thread overview]
Message-ID: <20211202064946.1424490-1-yebin10@huawei.com> (raw)
It's better to use timespec64_valid() to verify time value.
Fixes: 2087009c74d4("io_uring: validate timespec for timeout removals")
Fixes: f6223ff79966("io_uring: Fix undefined-behaviour in io_issue_sqe")
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
fs/io_uring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 568729677e25..929ff732d6dc 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -6151,7 +6151,7 @@ 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)
+ if (!timespec64_valid(&tr->ts))
return -EINVAL;
} else if (tr->flags) {
/* timeout removal doesn't support flags */
@@ -6238,7 +6238,7 @@ static int io_timeout_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (get_timespec64(&data->ts, u64_to_user_ptr(sqe->addr)))
return -EFAULT;
- if (data->ts.tv_sec < 0 || data->ts.tv_nsec < 0)
+ if (!timespec64_valid(&data->ts))
return -EINVAL;
data->mode = io_translate_timeout_mode(flags);
--
2.31.1
next reply other threads:[~2021-12-02 6:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-02 6:49 Ye Bin [this message]
2021-12-09 2:15 ` [PATCH -next] io_uring: use timespec64_valid() to verify time value yebin
2021-12-16 13:15 ` yebin
2021-12-16 15:07 ` Muchun Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211202064946.1424490-1-yebin10@huawei.com \
--to=yebin10@huawei.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox