]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
rgw: Fix segfault due to concurrent socket use at timeout
authorYixin Jin <yjin77@yahoo.ca>
Wed, 15 Feb 2023 17:08:19 +0000 (17:08 +0000)
committerKonstantin Shalygin <k0ste@k0ste.ru>
Fri, 3 Mar 2023 03:14:51 +0000 (10:14 +0700)
commit671de0a3923831224655c76bb365b56494670b55
tree00d9f3bbf1ffa7fec8ce7d9212e6e0236ef59833
parentc9d0a4620c69199e57b8401c49a54e84a8772c5a
rgw: Fix segfault due to concurrent socket use at timeout

This commit fixes a potential segfault risk when
rgw timeout handler works on the socket in one
thread while it is concurrently used by another.
The details of the fix are:

1. Instead of calling socket close(), which resets
descriptor_data in boost::asio socket and risks
segfault due to concurrent use of the socket,
the timeout handler now calls cancel() to abort
all pending ops followed by shutdown() to disable
the underlying transport. The eventual closure of
the socket will be done in the socket destructor.

2. Expose the actual boost::asio socket via get_socket()
from Connection so that the timeout handler can call
cancel() and shutdown() on it, although the socket data
member is already accessible. It allows future expansion
that wants to hide the socket even though it renders the
existing close() less useful.

Fixes: https://tracker.ceph.com/issues/58670
Signed-off-by: Yixin Jin <yjin77@yahoo.ca>
(cherry picked from commit 6d5988cbdab48705414e311217c61d3c798085d8)
src/rgw/rgw_asio_frontend.cc
src/rgw/rgw_asio_frontend_timer.h