|
Message-ID: <20160407184643.GI9862@port70.net> Date: Thu, 7 Apr 2016 20:46:43 +0200 From: Szabolcs Nagy <nsz@...t70.net> To: musl@...ts.openwall.com Subject: Re: recvmsg/sendmsg broken on mips64 * Sebastian Gottschall <s.gottschall@...wrt.com> [2016-04-07 13:42:17 +0200]: > >ok so the failure is in sendmsg and in the msg_control copy. > > > >does the call fail with ENOMEM (because >1024 bytes of ancillary data)? > >that would be easy to fix.. > > > >(libc has to make a copy, the struct is const and might be in > >readonly memory. a detailed bug report of the failure would > >be more useful than speculations about broken compilers.. > >e.g. strace log with and without the msg_control copying.) > how to make a more detailed report than just that all netlink operations in > iproute2 fail. so the whole ip command doesnt work. there are only two places where msg->msg_control is used in iproute2: bpf_scm.h and libnetlink.c, they both use a fixed char[1024] buffer, which should work with musl. one thing i noticed is that iproute2 fails to take cmsghdr alignment requirements into account, so it only works by accident. i think the musl struct has different alignment (4 byte instead of 8 byte) which may cause problems because the copy uses the musl alignment, i'm not sure if this can cause what you observed. so we still don't know what your problem was and what fails exactly. > i tracked it down to recvmsg / sendmsg which do not return in success for > some reason. if i send it more detailed, which means i debug out > the real cause would also mean submit a better patch. just had no time yet > to care about since my hack works. > > but does not fit to your philosophy. its easy to reproduce on any octeon > device using musl and iproute2. > > > > >>#if LONG_MAX > INT_MAX > >> struct msghdr h; > >> struct cmsghdr chbuf[1024/sizeof(struct cmsghdr)+1], *c; > >> if (msg) { > >> h = *msg; > >> h.__pad1 = h.__pad2 = 0; > >> msg = &h; > >> if (h.msg_controllen) { > >> if (h.msg_controllen > 1024) { > >> errno = ENOMEM; > >> return -1; > >> } > >> memcpy(chbuf, h.msg_control, h.msg_controllen); > >> h.msg_control = chbuf; > >> for (c=CMSG_FIRSTHDR(&h); c; c=CMSG_NXTHDR(&h,c)) > >> c->__pad1 = 0; > >> } > >> } > >>#endif >
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.