Thread (2 messages) flat view 2 messages, 2 authors, 2018-07-20
STALE2958d

[PATCH] /net/9p/trans_fd.c: fix race-condition by flushing workqueue before the kfree()

From: Tomas Bortoli <hidden>
Date: 2018-07-19 20:07:12
Also in: lkml
Subsystem: 9p file system, the rest · Maintainers: Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet, Linus Torvalds

The patch adds the flush in p9_mux_poll_stop() as it the function used by
p9_conn_destroy(), in turn called by p9_fd_close() to stop the async
polling associated with the data regarding the connection.

Signed-off-by: Tomas Bortoli <redacted>
Reported-by: syzbot+39749ed7d9ef6dfb23f6@syzkaller.appspotmail.com
---
As shown by Syzbot, it is possible to provoke a race between p9_fd_close() 
and p9_poll_workfn() that is called to take care of the async read/write work
to do. To make sure p9_fd_close() frees "trans" when it is not used anymore, 
it has to explicitly call flush_scheduled_work() before the kfree().

 net/9p/trans_fd.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index bf459ee0feab..76ae134c05d9 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -185,6 +185,8 @@ static void p9_mux_poll_stop(struct p9_conn *m)
 	spin_lock_irqsave(&p9_poll_lock, flags);
 	list_del_init(&m->poll_pending_link);
 	spin_unlock_irqrestore(&p9_poll_lock, flags);
+
+	flush_scheduled_work();
 }
 
 /**
-- 
2.11.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help