Skip to content

Commit 4462c85

Browse files
committed
fix(dump,unix sockets): if 'name' is relative, real 'path' does not include that 'name', but 'realpath(name)' resolves to 'path', use 'cwd' as 'name_dir'
1 parent 92c0cdc commit 4462c85

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

criu/sk-unix.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,37 @@ static int unix_resolve_name(int lfd, uint32_t id, struct unix_sk_desc *d, UnixS
693693

694694
d->deleted = strip_deleted(path, ret);
695695

696+
// "time=\"2025-11-07T17:46:45Z\" level=warning msg=\"
697+
// 1:Error (criu/sk-unix.c:698):
698+
// unix: Unable too cut
699+
// name=var/run/secrets/workload-spiffe-uds/socket
700+
// path=/run/secrets/workload-spiffe-uds/socket
701+
// " container_ids="[09a6920cfb6dda5a538594e8a8272ef2404c093f3dfbaad9677670e80ed51cbb a6b90ec2ffb79c7ddc6425d87f46ad94947f240e7a5ba36d2725054c0fd994f6]" pageserver_address="100.100.149.200:5005" max_iterations="50" container_count="2" fileserver_address="100.100.149.200:5006" intelligent_stopping="true" dirty_pages_threshold="12000" container_id="09a6920c" stage="dump" with_tcp="false"
702+
703+
//time=2025-11-11T00:44:49.289Z level=DEBUG msg="Error (criu/sk-unix.c:698): unix: Unable too cut ./var/run/sockets/uds/echo.sock from /run/sockets/uds/echo.sock" with_tcp=true max_iterations=50 handler=runc migration_id=1ad9903b-2f45-4731-8844-0373533bc51a container_count=1 pageserver_address=192.168.158.53:5005 fileserver_address=192.168.158.53:5006 intelligent_stopping=true pod_id=efd0ab01-6bd6-4828-97b8-d69d8f547326 container_ids=[04d20a2c443b7d57a8fcfaa282e3a3e59b72aa9d1dec047b70baf2a458fbaedb] container_id=04d20a2c443b7d57a8fcfaa282e3a3e59b72aa9d1dec047b70baf2a458fbaedb stage=dump method=sourceServer.performDumpIteration dirty_pages_threshold=12000 service=cri-proxy
704+
705+
// i think that:
706+
// 1. path is a 'real' path for the socket
707+
// 2. name is what was passed to bind() when creating the socket
708+
// 3. name_dir is a presumed 'work directory' when the socket was created
709+
// i think the idea during restore:
710+
// > copilot suggestion: "on restore, recreate the socket at name_dir/name" or "cd to name_dir and create the socket at name"
696711
if (name[0] != '/') {
697712
if (cut_path_ending(path, name)) {
713+
714+
char resolved[PATH_MAX];
715+
if (realpath(name, resolved) != NULL) {
716+
if (strcmp(real1, real2) == 0) {
717+
char cwd[PATH_MAX];
718+
if (getcwd(cwd, sizeof(cwd)) != NULL) {
719+
ue->name_dir = xstrdup(cwd);
720+
if (!ue->name_dir)
721+
goto out;
722+
goto set_name_dir;
723+
}
724+
}
725+
}
726+
698727
pr_err("Unable too cut %s from %s\n", name, path);
699728
goto out;
700729
}
@@ -703,6 +732,7 @@ static int unix_resolve_name(int lfd, uint32_t id, struct unix_sk_desc *d, UnixS
703732
if (!ue->name_dir)
704733
goto out;
705734

735+
set_name_dir:
706736
pr_debug("Resolved socket relative name %s to %s/%s\n", name, ue->name_dir, name);
707737
}
708738

0 commit comments

Comments
 (0)