From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9857 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: recvmsg/sendmsg broken on mips64 Date: Thu, 7 Apr 2016 11:48:06 +0200 Message-ID: <20160407094806.GE9862@port70.net> References: <20160331203004.GX21636@brightrain.aerifal.cx> <76c20e67-4d62-a929-9f1d-a3fc63758426@dd-wrt.com> <20160401094919.GT9862@port70.net> <02844173-9671-d0e9-a291-764b27899f44@dd-wrt.com> <20160401113146.GU9862@port70.net> <91bfe81c-73c4-9b25-6d9b-a97d4ee54e89@dd-wrt.com> <20160401131712.GV9862@port70.net> <4445e7a7-19f3-aa7c-04dc-3e329ef7fdac@dd-wrt.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1460022506 29547 80.91.229.3 (7 Apr 2016 09:48:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Apr 2016 09:48:26 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-9870-gllmg-musl=m.gmane.org@lists.openwall.com Thu Apr 07 11:48:23 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ao6Y2-0001W4-37 for gllmg-musl@m.gmane.org; Thu, 07 Apr 2016 11:48:22 +0200 Original-Received: (qmail 13451 invoked by uid 550); 7 Apr 2016 09:48:18 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 13430 invoked from network); 7 Apr 2016 09:48:17 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <4445e7a7-19f3-aa7c-04dc-3e329ef7fdac@dd-wrt.com> User-Agent: Mutt/1.5.24 (2015-08-30) Xref: news.gmane.org gmane.linux.lib.musl.general:9857 Archived-At: * Sebastian Gottschall [2016-04-02 11:52:32 +0200]: > i understand the reason why the datatypes are defined as is, but on the > other hand the argument is irrelevant > if it doesnt work portable or not. (for some reason which might be mips > specific) > but anyway. i dont want to discuss this to the deep and. i prefer to find > and fix the bug by keeping the original structures. "original structures" does not make sense. the next glibc will fix their bug and use exactly the same struct as musl: http://sourceware.org/ml/libc-alpha/2016-03/msg00661.html eventually uclibc will fix this too (assuming it's still maintained) (and hopefully at some point the kernel will introduce new syscalls that use the correct structs.) > i will do some debugging on this today > > > > >your fix does not explain that unless there is > >a >4G message somewhere which i think is not > >supported on the kernel side either. > > > >please send a proper bug report about what > >breaks, it sounds like the padding is at > >the wrong place. changing int,int to size_t > >should make no difference for iproute2. > it not just padding if you look at confusing codelines like this in sendmsg > for me it look like someone creates a copy of the buffer to work with it. > but i dont see a reason for it and is does also limit the maximum size of a > message > and code like this h = *msg; should be replaced by memcpy, since the > compiler may optimize that in a bad way . i have seen compiler introduced > bugs > in the past on lines like that. for me that code should be removed. clearing > padding is one thing, but why doing a copy? > 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.) > #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