<div dir="ltr">It seem buf is not long enough, I get on Fedora:<br><div><br>Program terminated with signal SIGSEGV, Segmentation fault.<br>#0 send_fd (fd2=7, fd1=6, via=4) at scm04.c:35<br>35 ch->cmsg_level = SOL_SOCKET;<br>Missing separate debuginfos, use: dnf debuginfo-install glibc-2.25-7.fc26.x86_64<br>(gdb) bt<br>#0 send_fd (fd2=7, fd1=6, via=4) at scm04.c:35<br>#1 main (argc=<optimized out>, argv=<optimized out>) at scm04.c:117<br><br><a href="https://ci.openvz.org/job/CRIU/job/CRIU-virtuozzo/job/criu-dev/2805">https://ci.openvz.org/job/CRIU/job/CRIU-virtuozzo/job/criu-dev/2805</a> :<br><pre class="gmail-console-output">========================== 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 #####################<br></pre></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><br>Best Regards, Tikhomirov Pavel.</div></div></div>
<br><div class="gmail_quote">2017-07-10 12:38 GMT+03:00 Pavel Emelyanov <span dir="ltr"><<a href="mailto:xemul@virtuozzo.com" target="_blank">xemul@virtuozzo.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Only the send code is altered, as upon receiving kernel<br>
merges all scm_rights int one. CRIU relies on this merge<br>
and this is to catch situations if the kernel suddenly<br>
stops doing this.<br>
<br>
Signed-off-by: Pavel Emelyanov <<a href="mailto:xemul@virtuozzo.com">xemul@virtuozzo.com</a>><br>
---<br>
test/zdtm/static/Makefile | 2 ++<br>
test/zdtm/static/scm03.c | 31 +++++++++++++++++++++++++++++-<wbr>-<br>
test/zdtm/static/scm04.c | 1 +<br>
test/zdtm/static/scm04.desc | 1 +<br>
4 files changed, 33 insertions(+), 2 deletions(-)<br>
create mode 120000 test/zdtm/static/scm04.c<br>
create mode 100644 test/zdtm/static/scm04.desc<br>
<br>
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile<br>
index 79963f3..dd77768 100644<br>
--- a/test/zdtm/static/Makefile<br>
+++ b/test/zdtm/static/Makefile<br>
@@ -157,6 +157,7 @@ TST_NOFILE := \<br>
scm01 \<br>
scm02 \<br>
scm03 \<br>
+ scm04 \<br>
aio00 \<br>
aio01 \<br>
fd \<br>
@@ -447,6 +448,7 @@ sigpending: LDLIBS += -lrt<br>
vdso01: LDLIBS += -lrt<br>
scm01: CFLAGS += -DKEEP_SENT_FD<br>
scm02: CFLAGS += -DSEND_BOTH<br>
+scm04: CFLAGS += -DSEPARATE<br>
mntns_link_remap: CFLAGS += -DZDTM_LINK_REMAP<br>
mntns_shared_bind02: CFLAGS += -DSHARED_BIND02<br>
mntns_root_bind02: CFLAGS += -DROOT_BIND02<br>
diff --git a/test/zdtm/static/scm03.c b/test/zdtm/static/scm03.c<br>
index 9e89628..881bdf8 100644<br>
--- a/test/zdtm/static/scm03.c<br>
+++ b/test/zdtm/static/scm03.c<br>
@@ -14,11 +14,30 @@ static int send_fd(int via, int fd1, int fd2)<br>
struct msghdr h = {};<br>
struct cmsghdr *ch;<br>
struct iovec iov;<br>
- char buf[CMSG_SPACE(2 * sizeof(int))], c = '\0';<br>
+#ifdef SEPARATE<br>
+ char buf[2 * CMSG_SPACE(sizeof(int))];<br>
+#else<br>
+ char buf[CMSG_SPACE(2 * sizeof(int))];<br>
+#endif<br>
+ char c = '\0';<br>
int *fdp;<br>
<br>
h.msg_control = buf;<br>
h.msg_controllen = sizeof(buf);<br>
+#ifdef SEPARATE<br>
+ ch = CMSG_FIRSTHDR(&h);<br>
+ ch->cmsg_level = SOL_SOCKET;<br>
+ ch->cmsg_type = SCM_RIGHTS;<br>
+ ch->cmsg_len = CMSG_LEN(sizeof(int));<br>
+ fdp = (int *)CMSG_DATA(ch);<br>
+ fdp[0] = fd1;<br>
+ ch = CMSG_NXTHDR(&h, ch);<br>
+ ch->cmsg_level = SOL_SOCKET;<br>
+ ch->cmsg_type = SCM_RIGHTS;<br>
+ ch->cmsg_len = CMSG_LEN(sizeof(int));<br>
+ fdp = (int *)CMSG_DATA(ch);<br>
+ fdp[0] = fd2;<br>
+#else<br>
ch = CMSG_FIRSTHDR(&h);<br>
ch->cmsg_level = SOL_SOCKET;<br>
ch->cmsg_type = SCM_RIGHTS;<br>
@@ -26,6 +45,7 @@ static int send_fd(int via, int fd1, int fd2)<br>
fdp = (int *)CMSG_DATA(ch);<br>
fdp[0] = fd1;<br>
fdp[1] = fd2;<br>
+#endif<br>
h.msg_iov = &iov;<br>
h.msg_iovlen = 1;<br>
iov.iov_base = &c;<br>
@@ -42,7 +62,8 @@ static int recv_fd(int via, int *fd1, int *fd2)<br>
struct msghdr h = {};<br>
struct cmsghdr *ch;<br>
struct iovec iov;<br>
- char buf[CMSG_SPACE(2 * sizeof(int))], c;<br>
+ char buf[CMSG_SPACE(2 * sizeof(int))];<br>
+ char c;<br>
int *fdp;<br>
<br>
h.msg_control = buf;<br>
@@ -55,6 +76,12 @@ static int recv_fd(int via, int *fd1, int *fd2)<br>
if (recvmsg(via, &h, 0) <= 0)<br>
return -1;<br>
<br>
+ if (h.msg_flags & MSG_CTRUNC) {<br>
+ test_msg("CTR\n");<br>
+ return -2;<br>
+ }<br>
+<br>
+ /* No 2 SCM-s here, kernel merges them upon send */<br>
ch = CMSG_FIRSTHDR(&h);<br>
if (h.msg_flags & MSG_TRUNC)<br>
return -2;<br>
diff --git a/test/zdtm/static/scm04.c b/test/zdtm/static/scm04.c<br>
new file mode 120000<br>
index 0000000..f1f86dd<br>
--- /dev/null<br>
+++ b/test/zdtm/static/scm04.c<br>
@@ -0,0 +1 @@<br>
+scm03.c<br>
\ No newline at end of file<br>
diff --git a/test/zdtm/static/scm04.desc b/test/zdtm/static/scm04.desc<br>
new file mode 100644<br>
index 0000000..ded8987<br>
--- /dev/null<br>
+++ b/test/zdtm/static/scm04.desc<br>
@@ -0,0 +1 @@<br>
+{'flags': 'crfail'}<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.4<br>
<br>
______________________________<wbr>_________________<br>
CRIU mailing list<br>
<a href="mailto:CRIU@openvz.org">CRIU@openvz.org</a><br>
<a href="https://lists.openvz.org/mailman/listinfo/criu" rel="noreferrer" target="_blank">https://lists.openvz.org/<wbr>mailman/listinfo/criu</a><br>
</font></span></blockquote></div><br></div>