[CRIU] [PATCH] p.haul: do not use getsockname() as a hash_name, v5

Ruslan Kuprieiev kupruser at gmail.com
Sun Nov 2 16:24:29 PST 2014


Currently xem_rpc is not proxy-resistant.
It means that if there is a proxy somewhere in
between client and server, p.haul will fail,
because getsockname() on client != getpeername()
on server.

v2, Pavel suggested to solve it like this:

1. On main rpc socket after init_rpc() the server
   reports back the name by which it sees the client
   socket.

2. After calling connect() on data socket the client
   should mix the name from step 1 to the data socket
   name to distinguish his data socket from those
   created by other clients.

v3, use rpc to transfer socket name
v4, use init option in _make_sk
v5, do not use init option

Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 xem_rpc.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/xem_rpc.py b/xem_rpc.py
index 9718eef..8bbdac7 100644
--- a/xem_rpc.py
+++ b/xem_rpc.py
@@ -3,6 +3,7 @@ import select
 import threading
 import traceback
 import util
+import struct
 
 rpc_port = 12345
 rpc_sk_buf = 256
@@ -55,8 +56,9 @@ class rpc_proxy:
 
 	def open_socket(self, uname):
 		sk = self._make_sk()
+		host = _rpc_proxy_caller(sk, RPC_CMD, "get_name")()
 		c = _rpc_proxy_caller(self._rpc_sk, RPC_CMD, "pick_channel")
-		c(sk.getsockname(), uname)
+		c(host, uname)
 		return sk
 
 
@@ -76,6 +78,9 @@ class _rpc_server_sk:
 	def hash_name(self):
 		return self._sk.getpeername()
 
+	def get_name(self, mgr):
+		return self.hash_name()
+
 	def work(self, mgr):
 		raw_data = self._sk.recv(rpc_sk_buf)
 		if not raw_data:
-- 
1.9.3



More information about the CRIU mailing list