rgw: asio: check the remote endpoint before processing requests
authorAbhishek Lekshmanan <abhishek@suse.com>
Wed, 7 Aug 2019 15:09:32 +0000 (17:09 +0200)
committerBastien Roucariès <rouca@debian.org>
Sat, 21 Oct 2023 16:42:26 +0000 (17:42 +0100)
`socket.remote_endpoint()` can throw exceptions corresponding to errors in the
`getpeername` syscall, make sure these are handled.

Fixes: CVE-2019-10222, https://tracker.ceph.com/issues/40018
Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
Origin: upstream, https://github.com/ceph/ceph/commit/6171399fdedd928b4249d135b4036e3de25079aa

Gbp-Pq: Name CVE-2019-10222.patch

src/rgw/rgw_asio_frontend.cc

index e974ae7bf8e0c686298a65bd0dd0b1481b250b67..d2dedd00461c8566481ae74f9944a1efe243f92d 100644 (file)
@@ -165,9 +165,15 @@ void handle_connection(RGWProcessEnv& env, Stream& stream,
     RGWRequest req{env.store->get_new_req_id()};
 
     auto& socket = stream.lowest_layer();
+    const auto& remote_endpoint = socket.remote_endpoint(ec);
+    if (ec) {
+        ldout(cct, 1) << "failed to connect client: " << ec.message() << dendl;
+        return;
+    }
+
     StreamIO<Stream> real_client{stream, parser, buffer, is_ssl,
                                  socket.local_endpoint(),
-                                 socket.remote_endpoint()};
+                                 remote_endpoint};
 
     auto real_client_io = rgw::io::add_reordering(
                             rgw::io::add_buffering(cct,