From dea4ec6d9f736a95675701e46ddc8d5e6a86f42c Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Wed, 23 Nov 2022 13:46:47 +0800 Subject: [PATCH] crimson/net: fix use-after-free during yielded closing Signed-off-by: Yingxin Cheng --- src/crimson/net/Protocol.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/crimson/net/Protocol.h b/src/crimson/net/Protocol.h index fb95a446432d..782b357b9df3 100644 --- a/src/crimson/net/Protocol.h +++ b/src/crimson/net/Protocol.h @@ -34,7 +34,8 @@ class Protocol { // seastar::parallel_for_each(). otherwise, we could erase a connection in // the container when seastar::parallel_for_each() is still iterating in // it. that'd lead to a segfault. - return seastar::yield().then([this, dispatch_reset] { + return seastar::yield( + ).then([this, dispatch_reset, conn_ref = conn.shared_from_this()] { close(dispatch_reset); // it can happen if close_clean() is called inside Dispatcher::ms_handle_reset() // which will otherwise result in deadlock -- 2.47.3