[CRIU] [PATCH 04/18] zdtm: Send two descriptors in two SCMs

Pavel Tikhomirov snorcht at gmail.com
Mon Aug 14 18:45:20 MSK 2017


It seem buf is not long enough, I get on Fedora:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  send_fd (fd2=7, fd1=6, via=4) at scm04.c:35
35        ch->cmsg_level = SOL_SOCKET;
Missing separate debuginfos, use: dnf debuginfo-install
glibc-2.25-7.fc26.x86_64
(gdb) bt
#0  send_fd (fd2=7, fd1=6, via=4) at scm04.c:35
#1  main (argc=<optimized out>, argv=<optimized out>) at scm04.c:117

https://ci.openvz.org/job/CRIU/job/CRIU-virtuozzo/job/criu-dev/2805 :

========================== Run zdtm/static/scm04 in h ==========================
Start test
./scm04 --pidfile=scm04.pid --outfile=scm04.out
make: *** [scm04.pid] Error 1
##################### Test zdtm/static/scm04 FAIL at start #####################



Best Regards, Tikhomirov Pavel.

2017-07-10 12:38 GMT+03:00 Pavel Emelyanov <xemul at virtuozzo.com>:

> Only the send code is altered, as upon receiving kernel
> merges all scm_rights int one. CRIU relies on this merge
> and this is to catch situations if the kernel suddenly
> stops doing this.
>
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
> ---
>  test/zdtm/static/Makefile   |  2 ++
>  test/zdtm/static/scm03.c    | 31 +++++++++++++++++++++++++++++--
>  test/zdtm/static/scm04.c    |  1 +
>  test/zdtm/static/scm04.desc |  1 +
>  4 files changed, 33 insertions(+), 2 deletions(-)
>  create mode 120000 test/zdtm/static/scm04.c
>  create mode 100644 test/zdtm/static/scm04.desc
>
> diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
> index 79963f3..dd77768 100644
> --- a/test/zdtm/static/Makefile
> +++ b/test/zdtm/static/Makefile
> @@ -157,6 +157,7 @@ TST_NOFILE  :=                              \
>                 scm01                           \
>                 scm02                           \
>                 scm03                           \
> +               scm04                           \
>                 aio00                           \
>                 aio01                           \
>                 fd                              \
> @@ -447,6 +448,7 @@ sigpending:         LDLIBS += -lrt
>  vdso01:                        LDLIBS += -lrt
>  scm01:                 CFLAGS += -DKEEP_SENT_FD
>  scm02:                 CFLAGS += -DSEND_BOTH
> +scm04:                 CFLAGS += -DSEPARATE
>  mntns_link_remap:      CFLAGS += -DZDTM_LINK_REMAP
>  mntns_shared_bind02:   CFLAGS += -DSHARED_BIND02
>  mntns_root_bind02:     CFLAGS += -DROOT_BIND02
> diff --git a/test/zdtm/static/scm03.c b/test/zdtm/static/scm03.c
> index 9e89628..881bdf8 100644
> --- a/test/zdtm/static/scm03.c
> +++ b/test/zdtm/static/scm03.c
> @@ -14,11 +14,30 @@ static int send_fd(int via, int fd1, int fd2)
>         struct msghdr h = {};
>         struct cmsghdr *ch;
>         struct iovec iov;
> -       char buf[CMSG_SPACE(2 * sizeof(int))], c = '\0';
> +#ifdef SEPARATE
> +       char buf[2 * CMSG_SPACE(sizeof(int))];
> +#else
> +       char buf[CMSG_SPACE(2 * sizeof(int))];
> +#endif
> +       char c = '\0';
>         int *fdp;
>
>         h.msg_control = buf;
>         h.msg_controllen = sizeof(buf);
> +#ifdef SEPARATE
> +       ch = CMSG_FIRSTHDR(&h);
> +       ch->cmsg_level = SOL_SOCKET;
> +       ch->cmsg_type = SCM_RIGHTS;
> +       ch->cmsg_len = CMSG_LEN(sizeof(int));
> +       fdp = (int *)CMSG_DATA(ch);
> +       fdp[0] = fd1;
> +       ch = CMSG_NXTHDR(&h, ch);
> +       ch->cmsg_level = SOL_SOCKET;
> +       ch->cmsg_type = SCM_RIGHTS;
> +       ch->cmsg_len = CMSG_LEN(sizeof(int));
> +       fdp = (int *)CMSG_DATA(ch);
> +       fdp[0] = fd2;
> +#else
>         ch = CMSG_FIRSTHDR(&h);
>         ch->cmsg_level = SOL_SOCKET;
>         ch->cmsg_type = SCM_RIGHTS;
> @@ -26,6 +45,7 @@ static int send_fd(int via, int fd1, int fd2)
>         fdp = (int *)CMSG_DATA(ch);
>         fdp[0] = fd1;
>         fdp[1] = fd2;
> +#endif
>         h.msg_iov = &iov;
>         h.msg_iovlen = 1;
>         iov.iov_base = &c;
> @@ -42,7 +62,8 @@ static int recv_fd(int via, int *fd1, int *fd2)
>         struct msghdr h = {};
>         struct cmsghdr *ch;
>         struct iovec iov;
> -       char buf[CMSG_SPACE(2 * sizeof(int))], c;
> +       char buf[CMSG_SPACE(2 * sizeof(int))];
> +       char c;
>         int *fdp;
>
>         h.msg_control = buf;
> @@ -55,6 +76,12 @@ static int recv_fd(int via, int *fd1, int *fd2)
>         if (recvmsg(via, &h, 0) <= 0)
>                 return -1;
>
> +       if (h.msg_flags & MSG_CTRUNC) {
> +               test_msg("CTR\n");
> +               return -2;
> +       }
> +
> +       /* No 2 SCM-s here, kernel merges them upon send */
>         ch = CMSG_FIRSTHDR(&h);
>         if (h.msg_flags & MSG_TRUNC)
>                 return -2;
> diff --git a/test/zdtm/static/scm04.c b/test/zdtm/static/scm04.c
> new file mode 120000
> index 0000000..f1f86dd
> --- /dev/null
> +++ b/test/zdtm/static/scm04.c
> @@ -0,0 +1 @@
> +scm03.c
> \ No newline at end of file
> diff --git a/test/zdtm/static/scm04.desc b/test/zdtm/static/scm04.desc
> new file mode 100644
> index 0000000..ded8987
> --- /dev/null
> +++ b/test/zdtm/static/scm04.desc
> @@ -0,0 +1 @@
> +{'flags': 'crfail'}
> --
> 2.1.4
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20170814/33b7ebf3/attachment-0001.html>


More information about the CRIU mailing list