Distributed Replicated Block Device (DRBD) development
 help / color / mirror / Atom feed
* [Drbd-dev] [PATCH] Fixed possible use after free in drbd_thread_setup
@ 2017-12-21 17:53 johannes
  2017-12-22 14:50 ` Lars Ellenberg
  0 siblings, 1 reply; 2+ messages in thread
From: johannes @ 2017-12-21 17:53 UTC (permalink / raw)
  To: drbd-dev

From: Johannes Thoma <johannes@johannesthoma.com>

drbd_thread might already be freed when complete returns,
hence we shouldn't access the drbd_thread object (thi)
after calling complete().

I am not 100% sure if this creates any further races,
alternative would be to acquire the lock before freeing
the thread object (so that spin_unlock_irqrestore() has
exited already). Please let me know what you think.

Signed-off-by: Johannes Thoma <johannes@johannesthoma.com>
---
 drbd/drbd_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c
index a2b5683..dbf2e41 100644
--- a/drbd/drbd_main.c
+++ b/drbd/drbd_main.c
@@ -563,8 +563,8 @@ restart:
 	else
 		drbd_info(resource, "Terminating %s thread\n", thi->name);
 
-	complete(&thi->stop);
 	spin_unlock_irqrestore(&thi->t_lock, flags);
+	complete(&thi->stop);
 
 	if (connection)
 		kref_put(&connection->kref, drbd_destroy_connection);
-- 
2.8.0-rc4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-22 14:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-21 17:53 [Drbd-dev] [PATCH] Fixed possible use after free in drbd_thread_setup johannes
2017-12-22 14:50 ` Lars Ellenberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox