mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+e1dc29a4daf3f8051130@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [netfs?] KASAN: slab-use-after-free Write in io_submit_one
Date: Sat, 15 Feb 2025 13:15:46 +0800	[thread overview]
Message-ID: <tencent_08922ECA6EE0CCB467D606C852E9464B0906@qq.com> (raw)
In-Reply-To: <67aedac7.050a0220.21dd3.002d.GAE@google.com>

#syz test

diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c
index f65affa5a9e4..6f3c0404f4b8 100644
--- a/fs/netfs/read_collect.c
+++ b/fs/netfs/read_collect.c
@@ -207,6 +207,7 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)
 	 * in progress.  The issuer thread may be adding stuff to the tail
 	 * whilst we're doing this.
 	 */
+	spin_lock(&rreq->lock);
 	front = READ_ONCE(stream->front);
 	while (front) {
 		size_t transferred;
@@ -288,7 +289,6 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)
 
 		/* Remove if completely consumed. */
 		stream->source = front->source;
-		spin_lock(&rreq->lock);
 
 		remove = front;
 		trace_netfs_sreq(front, netfs_sreq_trace_discard);
@@ -296,12 +296,12 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)
 		front = list_first_entry_or_null(&stream->subrequests,
 						 struct netfs_io_subrequest, rreq_link);
 		stream->front = front;
-		spin_unlock(&rreq->lock);
 		netfs_put_subrequest(remove, false,
 				     notes & ABANDON_SREQ ?
 				     netfs_sreq_trace_put_abandon :
 				     netfs_sreq_trace_put_done);
 	}
+	spin_unlock(&rreq->lock);
 
 	trace_netfs_collect_stream(rreq, stream);
 	trace_netfs_collect_state(rreq, rreq->collected_to, notes);
@@ -369,12 +369,17 @@ static void netfs_rreq_assess_dio(struct netfs_io_request *rreq)
 		}
 	}
 
+	spin_lock(&rreq->lock);
 	if (rreq->iocb) {
 		rreq->iocb->ki_pos += rreq->transferred;
-		if (rreq->iocb->ki_complete)
+		if (rreq->iocb->ki_complete) {
 			rreq->iocb->ki_complete(
 				rreq->iocb, rreq->error ? rreq->error : rreq->transferred);
+			rreq->iocb = NULL;
+		}
 	}
+	spin_unlock(&rreq->lock);
+
 	if (rreq->netfs_ops->done)
 		rreq->netfs_ops->done(rreq);
 	if (rreq->origin == NETFS_DIO_READ)


  parent reply	other threads:[~2025-02-15  5:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-14  5:55 [syzbot] " syzbot
2025-02-14 12:46 ` Edward Adam Davis
2025-02-14 12:57   ` [syzbot] " syzbot
2025-02-15  0:59 ` Edward Adam Davis
2025-02-15  1:23   ` [syzbot] " syzbot
2025-02-15  2:00 ` Edward Adam Davis
2025-02-15  2:19   ` [syzbot] " syzbot
2025-02-15  2:36 ` Edward Adam Davis
2025-02-15  2:57   ` [syzbot] " syzbot
2025-02-15  3:50 ` Edward Adam Davis
2025-02-15  3:51   ` [syzbot] " syzbot
2025-02-15  4:10 ` Edward Adam Davis
2025-02-15  4:32   ` [syzbot] " syzbot
2025-02-15  5:15 ` Edward Adam Davis [this message]
2025-02-15  5:38   ` syzbot
2025-02-15  7:43 ` Hillf Danton
2025-02-15  8:10   ` syzbot
2025-02-15  9:42 ` [PATCH] netfs: Prevent race conditions between aio read and read collection worker Edward Adam Davis

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=tencent_08922ECA6EE0CCB467D606C852E9464B0906@qq.com \
    --to=eadavis@qq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+e1dc29a4daf3f8051130@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /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

all inboxes | Powered by JetHome®