Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 1 Apr 2016 13:37:05 +0200
From: Sebastian Gottschall <s.gottschall@...wrt.com>
To: musl@...ts.openwall.com
Subject: Re: recvmsg/sendmsg broken on mips64

Am 01.04.2016 um 13:31 schrieb Szabolcs Nagy:
> * Sebastian Gottschall <s.gottschall@...wrt.com> [2016-04-01 12:29:35 +0200]:
>
>> Am 01.04.2016 um 11:49 schrieb Szabolcs Nagy:
>>> * Sebastian Gottschall <s.gottschall@...wrt.com> [2016-04-01 11:16:20 +0200]:
>>>> I discovered that the whole recvmsg/sendmsg code is broken in mips64
>>>> but i found also the solution
>>>> i throwed out all the _pad1, _pad2 crap in socket.h and the corrosponding
>>>> code in recvmsg.c etc.
>>>> and used size_t instead. this works at the end. i see no reason for this
>>>> padding, since using the correct datatype will handle it in the same way.
>>>> this solution may also work for other 64 bit targets. so proposal is fixing
>>>> the datatype instead of using int with padding in case of 64 bit
>>>>
>>> the padding is needed, i think __BIG_ENDIAN
>>> or __LITTLE_ENDIAN might not be defined properly.
>> i checked this already. it was defined properly. the only solution was using
>> the correct datatypes as defined in the kernel and i also checked uclibc. it
>> uses also just size_t and nothing else.
>> the padding results in the same datatype size, just clears the upper and
>> lower word. but this doesnt seem to be neccessary
>>> your fix is non-conforming and breaks both abi and api,
>>> the definition must match
>> socklen_t would result in the same 64bit datatype instead of int + pad
>> (which is 64 bit too). so its conforming.
>> i mached by header variant by reading the kernel headers which uses size_t
>> instead of socketlen_t
>> so i assume socketlen_t maches size_t
> msg_iovlen must be int
> msg_controllen and cmsg_len must be socklen_t
the kernel uses size_t
>
> the socklen_t typedef must match what the size
> the socket syscalls expect which is int.
>
> uclibc and linux uapi is known to be broken,
> linux uapi is not fixed because of abi compat
> but we can work this around in musl.
>
> if the endian macros are defined then the padding
> should work.
okay. but musl is a library used with linux only. so if linux uses 
size_t, then musl must use the same abi.
otherwise musl wont work with unimportant programs like "ip" for 64 bit 
targets (havent checked x64 yet)
>>> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html
>>>
>>>> this here is my working struct in mips64 (big endian)
>>>>
>>>> struct msghdr {
>>>>          void *msg_name;
>>>>          socklen_t msg_namelen;
>>>>          struct iovec *msg_iov;
>>>>          size_t msg_iovlen;
>>>>          void *msg_control;
>>>>          size_t msg_controllen;
>>>>          int msg_flags;
>>>> };
>>>>
>>>> struct cmsghdr {
>>>>          size_t cmsg_len;
>>>>          int cmsg_level;
>>>>          int cmsg_type;
>>>> };
>>>>
>>>>
>>>> Sebastian


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.