This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 1/3] Fix __check_pf()/make_request() stack overflow segfault (convert to malloc)


On 1/20/14, 6:41 AM, "Siddhesh Poyarekar" <siddhesh@redhat.com> wrote:

>On Fri, Jan 17, 2014 at 01:22:46AM +0100, Ondřej Bílka wrote:
>> which only copies list into malloced array while preserving ordering.
>> 
>> A better way would be to malloc result at start and write into in6ai
>> array directly, calling realloc to double size as necessary. At end we
>> could optionally trim memory at end.
>> 
>> This should also be more effective as one big copy is faster when you
>> need to copy same amount of data in small chunks.
>
>Interface configuration shouldn't change all the time, so the
>reallocation event ought to be infrequent enough that we need not
>worry about it.  In fact in the common case of the interfaces not
>changing, we should end up with just one allocation, with subsequent
>getaddrinfo calls resulting in only copies.
>
>nscd makes this even better by caching the interfaces so that the
>query itself is avoided.


That's only if glibc is built as part of nscd. In the normal path there is
no caching. The leak was introduced by the special casing for the nscd
build.

Also, remember that you can have thousands of interfaces that are dynamic.
The number of interfaces allowed in the kernel is likely a long. Multiply
by an often used library call, and it's clear why you can have crashing
and performance issues here.

-Deb


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]