Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 21 Apr 2016 21:30:37 +0200
From: Sebastian Gottschall <>
Subject: Re: recvmsg/sendmsg broken on mips64

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
>>>> 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 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:
> Rather than using designated initializers as the current code does:
> 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

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.