From: Yingxin Cheng Date: Wed, 23 Nov 2022 05:46:47 +0000 (+0800) Subject: crimson/net: fix use-after-free during yielded closing X-Git-Tag: v18.1.0~832^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dea4ec6d9f736a95675701e46ddc8d5e6a86f42c;p=ceph.git crimson/net: fix use-after-free during yielded closing Signed-off-by: Yingxin Cheng --- 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