From 95946336f7bb60c8b214abda38612dcc61be55d1 Mon Sep 17 00:00:00 2001 From: Younes Manton Date: Thu, 8 Jun 2023 09:53:50 -0700 Subject: [PATCH] pipe: Fall back to write() on vmsplice() EPERM vmsplice can be blocked via seccomp and currently is in Podman containers. Signed-off-by: Younes Manton --- criu/pipes.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/criu/pipes.c b/criu/pipes.c index daada88306..cf8ae1686a 100644 --- a/criu/pipes.c +++ b/criu/pipes.c @@ -148,6 +148,7 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash int ret; struct pipe_data_rst *pd; struct iovec iov; + bool try_vmsplice = true; for (pd = hash[id & PIPE_DATA_HASH_MASK]; pd != NULL; pd = pd->next) if (pd->pde->pipe_id == id) @@ -179,7 +180,17 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash iov.iov_len = pd->pde->bytes; while (iov.iov_len > 0) { - ret = vmsplice(pfd, &iov, 1, SPLICE_F_GIFT | SPLICE_F_NONBLOCK); + if (try_vmsplice) { + ret = vmsplice(pfd, &iov, 1, SPLICE_F_GIFT | SPLICE_F_NONBLOCK); + if (ret < 0 && errno == EPERM) { + pr_info("%#x: vmsplice() returned EPERM, falling back to write()\n", id); + try_vmsplice = false; + ret = write(pfd, iov.iov_base, iov.iov_len); + } + } + else + ret = write(pfd, iov.iov_base, iov.iov_len); + if (ret < 0) { pr_perror("%#x: Error splicing data", id); return -1;