This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] network: Fix cmsghdr padding in sendmsg (BZ#16919)
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: Joseph Myers <joseph at codesourcery dot com>, Mike Frysinger <vapier at gentoo dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 26 May 2016 16:03:06 -0300
- Subject: Re: [PATCH] network: Fix cmsghdr padding in sendmsg (BZ#16919)
- Authentication-results: sourceware.org; auth=none
- References: <1464273450-31507-1-git-send-email-adhemerval dot zanella at linaro dot org> <20160526161709 dot GH26300 at vapier dot lan> <alpine dot DEB dot 2 dot 20 dot 1605261626330 dot 18895 at digraph dot polyomino dot org dot uk>
On 26/05/2016 13:27, Joseph Myers wrote:
> On Thu, 26 May 2016, Mike Frysinger wrote:
>
>> i think it should do a length test -- if it's below a threshold, use
>> alloca, otherwise fall back to malloc+free. inserting our own limit
>> here feels wrong.
>
> sendmsg is required by POSIX to be AS-safe, so can't use malloc+free; it
> would have to allocate memory in some other AS-safe way.
And I think introducing AS-safe allocation here adds a lot of complexity
and performance issues (even using mmap or pool buffer in some way).
I do fell it might be wrong to add an arbitrary limit here, however the
usage of control buffer in these syscalls is quite limited and passing
large buffers is unusual. Also ENOMEM just instruct to use that it should
either send multiple messages or rework de application, which I fell it is
a tradeoff to implement the standard compliance fix.