Re: [syzbot] [netfs?] KASAN: slab-use-after-free Read in iov_iter_advance

From: Jeongjun Park
Date: Fri Sep 20 2024 - 13:14:22 EST


#syz test git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ master

---
fs/netfs/write_issue.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/netfs/write_issue.c b/fs/netfs/write_issue.c
index 04e66d587f77..8e708d1f7c9d 100644
--- a/fs/netfs/write_issue.c
+++ b/fs/netfs/write_issue.c
@@ -427,6 +427,8 @@ static int netfs_write_folio(struct netfs_io_request *wreq,
* Also skip uploading for data that's been read and just needs copying
* to the cache.
*/
+
+ spin_lock(&wreq->lock);
for (int s = 0; s < NR_IO_STREAMS; s++) {
stream = &wreq->io_streams[s];
stream->submit_off = foff;
@@ -488,6 +490,7 @@ static int netfs_write_folio(struct netfs_io_request *wreq,
for (int s = 0; s < NR_IO_STREAMS; s++)
netfs_issue_write(wreq, &wreq->io_streams[s]);

+ spin_unlock(&wreq->lock);
_leave(" = 0");
return 0;
}
--