From: zhangjiao2 <zhangjiao2@cmss.chinamobile.com>
To: axboe@kernel.dk
Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org,
zhang jiao <zhangjiao2@cmss.chinamobile.com>
Subject: [PATCH] io_uring/mock: Modify the return value check
Date: Wed, 10 Sep 2025 17:03:47 +0800 [thread overview]
Message-ID: <20250910090347.2950-1-zhangjiao2@cmss.chinamobile.com> (raw)
From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
The return value of copy_from_iter and copy_to_iter can't be negative,
check whether the copied lengths are equal.
Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
---
io_uring/mock_file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/io_uring/mock_file.c b/io_uring/mock_file.c
index 45d3735b2708..bdbb1bd8e2c8 100644
--- a/io_uring/mock_file.c
+++ b/io_uring/mock_file.c
@@ -42,7 +42,7 @@ static int io_copy_regbuf(struct iov_iter *reg_iter, void __user *ubuf)
if (iov_iter_rw(reg_iter) == ITER_SOURCE) {
ret = copy_from_iter(tmp_buf, len, reg_iter);
- if (ret <= 0)
+ if (ret != len)
break;
if (copy_to_user(ubuf, tmp_buf, ret))
break;
@@ -50,7 +50,7 @@ static int io_copy_regbuf(struct iov_iter *reg_iter, void __user *ubuf)
if (copy_from_user(tmp_buf, ubuf, len))
break;
ret = copy_to_iter(tmp_buf, len, reg_iter);
- if (ret <= 0)
+ if (ret != len)
break;
}
ubuf += ret;
--
2.33.0
reply other threads:[~2025-09-10 9:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250910090347.2950-1-zhangjiao2@cmss.chinamobile.com \
--to=zhangjiao2@cmss.chinamobile.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