Commit e5856d4a authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

sfd: Don't forget to test sfd_map when closing old fds

is_any_service_fd didn't check for service file descriptor
being marked in sfd_map in result we may end up leaving
some garbage file obtained from the program executing
criu.

[root@sqvm0910 criu-stable.git]# ll /proc/354877/fd
lr-x------ 1 root root 64 May 16 19:03 114 -> /
lr-x------ 1 root root 64 May 16 19:03 115 -> /
l--------- 1 root root 64 May 16 19:03 117 -> /18311 (deleted)
lr-x------ 1 root root 64 May 16 19:03 119 -> /vzt/del/vzctl-rm-me.X1JH4vI (deleted)

We are to test if the file descriptor was indeed installed
explicitly.

https://jira.sw.ru/browse/PSBM-83892Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 5686613a
...@@ -636,8 +636,16 @@ int clone_service_fd(struct pstree_item *me) ...@@ -636,8 +636,16 @@ int clone_service_fd(struct pstree_item *me)
bool is_any_service_fd(int fd) bool is_any_service_fd(int fd)
{ {
return fd > __get_service_fd(SERVICE_FD_MAX, service_fd_id) && int sfd_min_fd = __get_service_fd(SERVICE_FD_MAX, service_fd_id);
fd < __get_service_fd(SERVICE_FD_MIN, service_fd_id); int sfd_max_fd = __get_service_fd(SERVICE_FD_MIN, service_fd_id);
if (fd > sfd_min_fd && fd < sfd_max_fd) {
int type = SERVICE_FD_MAX - (fd - sfd_min_fd);
if (type > SERVICE_FD_MIN && type < SERVICE_FD_MAX)
return !!test_bit(type, sfd_map);
}
return false;
} }
bool is_service_fd(int fd, enum sfd_type type) bool is_service_fd(int fd, enum sfd_type type)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment