linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lizhi Xu <lizhi.xu@windriver.com>
To: <syzbot+d2125fcb6aa8c4276fd2@syzkaller.appspotmail.com>
Cc: <brauner@kernel.org>, <jack@suse.cz>,
	<linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<syzkaller-bugs@googlegroups.com>, <viro@zeniv.linux.org.uk>
Subject: [PATCH] netfs: if extracting pages from user iterator fails return 0
Date: Fri, 24 May 2024 13:35:57 +0800	[thread overview]
Message-ID: <20240524053557.2702600-1-lizhi.xu@windriver.com> (raw)
In-Reply-To: <0000000000002fd2de0618de2e65@google.com>

When extracting the pages from a user iterator fails, netfs_extract_user_iter()
will return 0, this situation will result in an abnormal and oversized return 
value for netfs_unbuffered_writer_locked() (for example, 9223372036854775807).

Therefore, when the number of extracted pages is 0, set ret to 0 and jump to out.

Reported-and-tested-by: syzbot+d2125fcb6aa8c4276fd2@syzkaller.appspotmail.com
Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com>
---
 fs/netfs/direct_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/netfs/direct_write.c b/fs/netfs/direct_write.c
index 608ba6416919..d74761fb1876 100644
--- a/fs/netfs/direct_write.c
+++ b/fs/netfs/direct_write.c
@@ -69,7 +69,7 @@ static ssize_t netfs_unbuffered_write_iter_locked(struct kiocb *iocb, struct iov
 		 */
 		if (async || user_backed_iter(iter)) {
 			n = netfs_extract_user_iter(iter, len, &wreq->iter, 0);
-			if (n < 0) {
+			if (n <= 0) {
 				ret = n;
 				goto out;
 			}
-- 
2.43.0


  reply	other threads:[~2024-05-24  5:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-20  8:06 [syzbot] [fs?] general protection fault in iter_file_splice_write syzbot
2024-05-24  5:35 ` Lizhi Xu [this message]
2024-08-11 22:43 ` syzbot
2025-09-23 19:59 ` syzbot
2025-09-25 12:47   ` David Howells

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=20240524053557.2702600-1-lizhi.xu@windriver.com \
    --to=lizhi.xu@windriver.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+d2125fcb6aa8c4276fd2@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).