From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9938 Path: news.gmane.org!not-for-mail From: Sebastian Gottschall Newsgroups: gmane.linux.lib.musl.general Subject: Re: recvmsg/sendmsg broken on mips64 Date: Thu, 21 Apr 2016 21:30:37 +0200 Message-ID: <57192A5D.90703@dd-wrt.com> References: <20160407184643.GI9862@port70.net> <2656e404-f225-cd95-3989-a48df486d914@dd-wrt.com> <20160410221812.GP21636@brightrain.aerifal.cx> <20160410222947.GQ21636@brightrain.aerifal.cx> <20160411023522.GR21636@brightrain.aerifal.cx> <20160421013715.GX21636@brightrain.aerifal.cx> <57187FA8.8010806@dd-wrt.com> <20160421153637.GY21636@brightrain.aerifal.cx> <20160421171608.GZ21636@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1461267055 30616 80.91.229.3 (21 Apr 2016 19:30:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Apr 2016 19:30:55 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-9951-gllmg-musl=m.gmane.org@lists.openwall.com Thu Apr 21 21:30:50 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 1atKJN-00081W-FO for gllmg-musl@m.gmane.org; Thu, 21 Apr 2016 21:30:49 +0200 Original-Received: (qmail 7681 invoked by uid 550); 21 Apr 2016 19:30:47 -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 7663 invoked from network); 21 Apr 2016 19:30:46 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dd-wrt.com; s=mikd; h=Subject:Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:To; bh=X/Kw5jIQFNG4UAjo+6l8EUxSw/a6oZ99Q2AS7bO8duo=; b=hdVL3vGft4KDSzdbQjosGyKj0e6bc5F4fMIi9ax4sGwZo0iIyjkZYz1HovsLgjvjzOc/Mbw86k1csmTpU3I+76xr2F4y5giBPbJsbPsq+Na1y02MTEOq8wXz+dMpmaT628KIPKD5DfuAz058cuYtoukdltZ646rhKCHjjJvw+6s=; User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 In-Reply-To: <20160421171608.GZ21636@brightrain.aerifal.cx> X-SA-Exim-Connect-IP: 217.234.132.69 X-SA-Exim-Mail-From: s.gottschall@dd-wrt.com X-Spam-Checker-Version: SpamAssassin 3.1.9 (2007-02-13) on webmail.newmedia-net.de X-Spam-Level: X-Spam-Status: No, score=-2.5 required=4.0 tests=ALL_TRUSTED,BAYES_00, DNS_FROM_AHBL_RHSBL,RATWARE_GECKO_BUILD autolearn=no version=3.1.9, No X-SA-Exim-Version: 4.2.1 (built Thu, 26 May 2011 15:22:33 +0200) X-SA-Exim-Scanned: Yes (on webmail.newmedia-net.de) X-NMN-MailScanner-Information: Please contact the ISP for more information X-NMN-MailScanner-ID: 1atKJ7-0008Ep-Py X-NMN-MailScanner: Found to be clean X-NMN-MailScanner-From: s.gottschall@dd-wrt.com X-Received: from [217.234.132.69] (helo=[10.88.193.128]) by webmail.newmedia-net.de with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.72) (envelope-from ) id 1atKJ7-0008Ep-Py for musl@lists.openwall.com; Thu, 21 Apr 2016 21:30:34 +0200 Xref: news.gmane.org gmane.linux.lib.musl.general:9938 Archived-At: Am 21.04.2016 um 19:16 schrieb Rich Felker: > On Thu, Apr 21, 2016 at 11:36:37AM -0400, Rich Felker wrote: >>>> I've managed to track down the cause of the breakage. Somehow your >>>> iproute2 has been miscompiled. What I did was add debug logic to >>>> libc.so to print the contents of the msghdr struct passed in before >>>> fixups, after fixups, and after the syscall. The output I got was: >>>> >>>> msghdr: 0xffffd58e08 12 0xffffd58df8 1 0 0 0 0 0 >>>> msghdr: 0xffffd58e08 12 0xffffd58df8 0 0 0 0 0 0 >>>> msghdr: 0xffffd58e08 12 0xffffd58df8 0 0 0 0 0 32 >>>> >>>> The fields (including __pad1 and __pad2) are printed in order. So as >>>> you can see, ip passed in a structure with a 1 in __pad1 and a 0 in >>>> msg_iovlen. The source (libnetlink.c) stores 1 to msg_iovlen, so my >>>> guess is that somehow it ended up getting the wrong-endian version of >>>> the structure definition. You could confirm this by adding #error to >>>> the little-endian case in arch/mips64/bits/socket.h and recompiling. I >>>> suspect it's going to take some additional work to track down the >>>> cause, which is likely specific to something in your toolchain (it >>>> didn't happen for me when I built my own iproute2). >>> i tried that already before i contacted you. the #error case never >>> raises within the little endian case >> Was that when compiling musl or iproute2? The problem is in how >> iproute2 was built; your libc.so seems fine. >> >>> so your guess doesnt match reality. (i even tried it again right >>> now. all is fine. it only uses the big endian case) >> If it's not the endian tests, I don't know what else would have caused >> this. I'll get a disassembly dump of the function to show you. Is >> there any way I can reproduce your exact toolchain to see if I can get >> the same miscompilation to happen? > OK, I finally found the source you're building from and tracked down > the problem, which is simply that you have a buggy, 10-year-outdated > version of iproute2's libnetlink.c. The relevant code is here: > > https://github.com/mirror/dd-wrt/blob/25e48ec1931daf4ef98a91ada9623638d128f34d/src/router/iproute2/lib/libnetlink.c#L156 > > Rather than using designated initializers as the current code does: > > http://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/lib/libnetlink.c?id=4bf138d6d2747b198fc0a78f5fe4e1c9287e9e90#n220 > > it's simply assuming an order for the members of struct msghdr. There > are several ways you could fix this: > > 1. Update to a modern version of iproute2. This would probably fix a > lot of other bugs too. > > 2. Copy the designated-initializers approach from the modern code into > your version. > > 3. Just use a zero-initializer for the structure and then assign > values to individual members by name with ordinary assignments. okay. will try > > Let me know if you need any more info. > > Rich >