-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
I detected this deficiency while working on gramineproject/gramine#1210 on the Gramine project. Gramine LibOS currently doesn't support ancillary data (cmsg).
recvmsg01.c test uses ancillary data in the setup process, in particular this:
ltp/testcases/kernel/syscalls/recvmsg/recvmsg01.c
Lines 508 to 514 in 7602a23
/* set up cmsghdr */ control = (struct cmsghdr *)snd_cbuf; memset(control, 0x00, sizeof(struct cmsghdr)); control->cmsg_len = sizeof(struct cmsghdr) + 4; control->cmsg_level = SOL_SOCKET; control->cmsg_type = SCM_RIGHTS; *(int *)CMSG_DATA(control) = tfd; ltp/testcases/kernel/syscalls/recvmsg/recvmsg01.c
Lines 522 to 526 in 7602a23
mh.msg_control = control; mh.msg_controllen = control->cmsg_len; /* do it */ (void)sendmsg(fd, &mh, 0);
The problem is on line 526 -- sendmsg() sends a message with the SCM_RIGHTS file descriptor. There is no error checking. Thus, the sender doesn't notice if this syscall fails (like it happens in Gramine). After that, the reader process is hanged on the blocking recvmsg() here. And the whole test gets broken because of this one case (this setup happens for subtest 8).
Could you add error handling? At least for this sendmsg()? But in general, there are several other places in this test that call non-trivial syscalls and do not check their return values.