[CRIU] [PATCH 11/16] sk-unix: Make sure the paired sockets are in good state

Cyrill Gorcunov gorcunov at openvz.org
Fri Dec 9 09:17:11 PST 2016


The connected unix socks are to be in TCP_ESTABLISHED
state, but since we get this data from image add a test.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 criu/sk-unix.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 7f4a3bf68c0b..a26a3529974d 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -1399,14 +1399,28 @@ struct collect_image_info unix_sk_cinfo = {
 	.flags		= COLLECT_SHARED,
 };
 
-static void interconnected_pair(struct unix_sk_info *ui, struct unix_sk_info *peer)
+static int interconnected_pair(struct unix_sk_info *ui, struct unix_sk_info *peer)
 {
 	struct fdinfo_list_entry *fle, *fle_peer;
+
 	/*
 	 * Select who will restore the pair. Check is identical to
 	 * the one in pipes.c and makes sure tasks wait for each other
 	 * in pids sorting order (ascending).
+	 *
+	 * If we're connecting the pair then they must be in
+	 * TCP_ESTABLISHED state.
 	 */
+
+	if (ui->ue->state != TCP_ESTABLISHED ||
+	    peer->ue->state != TCP_ESTABLISHED) {
+		pr_err("Sockets are not in tcp-established state "
+		       "ino %#x state %d ino %#x state %d\n",
+		       ui->ue->ino, ui->ue->state,
+		       peer->ue->ino, peer->ue->state);
+		return -1;
+	}
+
 	fle = file_master(&ui->d);
 	fle_peer = file_master(&peer->d);
 
@@ -1417,6 +1431,8 @@ static void interconnected_pair(struct unix_sk_info *ui, struct unix_sk_info *pe
 		peer->flags |= USK_PAIR_MASTER;
 		ui->flags |= USK_PAIR_SLAVE;
 	}
+
+	return 0;
 }
 
 static int resolve_unix_peers(void *unused)
@@ -1448,7 +1464,8 @@ static int resolve_unix_peers(void *unused)
 		peer->peer = ui;
 
 		/* socketpair or interconnected sockets */
-		interconnected_pair(ui, peer);
+		if (interconnected_pair(ui, peer))
+			return -1;
 	}
 
 	pr_info("Unix sockets:\n");
-- 
2.7.4



More information about the CRIU mailing list