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

Siddhesh Poyarekar siddhesh@redhat.com
Tue Jan 21 15:18:00 GMT 2014


On Tue, Jan 21, 2014 at 09:51:12AM -0500, Banerjee, Debabrata wrote:
> 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.

I know that the interfaces are dynamic and I added that it doesn't
necessarily mean that they're going to change for every getaddrinfo
call.  As a result, if we implement Ondrej's idea of allocating a page
and then doubling its size when needed, we will have these realloc
events only during the first getaddrinfo call.  Subsequent getaddrinfo
calls will only result in duplicated copies as long as the interfaces
don't change.  Besides, the realloc gets rid of the horrible
alloca/extend_alloca stuff that is just dangerous when used in
anything other than the most trivial cases.

When the interfaces do change, the extra performance hit is
unavoidable.  If there's an idea to avoid the copies as well, I'm sure
that would be welcome too.

Siddhesh



More information about the Libc-alpha mailing list