]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
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)
committerAbhishek Lekshmanan <abhishek@suse.com>
Wed, 28 Aug 2019 13:56:12 +0000 (15:56 +0200)
`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>
src/rgw/rgw_asio_frontend.cc

index d4ea4483e54560ad906829e6f595cfbef27fac7c..ec74f10a9878f6ceefec35de74854490ec61214e 100644 (file)
@@ -146,9 +146,15 @@ void handle_connection(boost::asio::io_context& context,
       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 real_client{cct, stream, parser, yield, buffer, is_ssl,
                            socket.local_endpoint(),
-                           socket.remote_endpoint()};
+                           remote_endpoint};
 
       auto real_client_io = rgw::io::add_reordering(
                               rgw::io::add_buffering(cct,