mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Sebastian Gottschall <s.gottschall@dd-wrt.com>
To: musl@lists.openwall.com
Subject: Re: recvmsg/sendmsg broken on mips64
Date: Thu, 21 Apr 2016 21:30:37 +0200	[thread overview]
Message-ID: <57192A5D.90703@dd-wrt.com> (raw)
In-Reply-To: <20160421171608.GZ21636@brightrain.aerifal.cx>

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
>



  reply	other threads:[~2016-04-21 19:30 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-31 18:20 size_t and int64_t on a new platform Dan Gohman
2016-03-31 19:25 ` Rich Felker
2016-03-31 20:10   ` Szabolcs Nagy
2016-03-31 20:23     ` Alexander Monakov
2016-03-31 20:30       ` Rich Felker
2016-04-01  9:16         ` recvmsg/sendmsg broken on mips64 Sebastian Gottschall
2016-04-01  9:49           ` Szabolcs Nagy
2016-04-01 10:29             ` Sebastian Gottschall
2016-04-01 11:31               ` Szabolcs Nagy
2016-04-01 11:37                 ` Sebastian Gottschall
2016-04-01 12:21                   ` Masanori Ogino
2016-04-01 12:42                     ` Sebastian Gottschall
2016-04-01 13:17                       ` Szabolcs Nagy
2016-04-02  9:52                         ` Sebastian Gottschall
2016-04-07  9:48                           ` Szabolcs Nagy
2016-04-07 11:42                             ` Sebastian Gottschall
2016-04-07 18:46                               ` Szabolcs Nagy
2016-04-07 23:33                                 ` Sebastian Gottschall
2016-04-10 22:18                                   ` Rich Felker
2016-04-10 22:24                                     ` Sebastian Gottschall
2016-04-10 22:29                                       ` Rich Felker
2016-04-10 22:33                                         ` Sebastian Gottschall
2016-04-11  2:35                                           ` Rich Felker
2016-04-11  6:35                                             ` Sebastian Gottschall
2016-04-11 18:32                                               ` Rich Felker
2016-04-11 19:01                                                 ` Sebastian Gottschall
2016-04-14 14:10                                                 ` Sebastian Gottschall
2016-04-15 16:19                                                   ` Rich Felker
2016-04-21  1:37                                             ` Rich Felker
2016-04-21  7:22                                               ` Sebastian Gottschall
2016-04-21 15:36                                                 ` Rich Felker
2016-04-21 17:16                                                   ` Rich Felker
2016-04-21 19:30                                                     ` Sebastian Gottschall [this message]
2016-04-21 19:29                                                   ` Sebastian Gottschall
2016-04-01  0:35   ` size_t and int64_t on a new platform Dan Gohman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57192A5D.90703@dd-wrt.com \
    --to=s.gottschall@dd-wrt.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).