This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2 1/3] Fix __check_pf()/make_request() stack overflow segfault (convert to malloc)
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: "Banerjee, Debabrata" <dbanerje at akamai dot com>
- Cc: OndÅej BÃlka <neleai at seznam dot cz>, "Pengcheng dot Chen at gmail dot com" <Pengcheng dot Chen at gmail dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, "Carlos O'Donell" <carlos at redhat dot com>
- Date: Tue, 21 Jan 2014 20:48:05 +0530
- Subject: Re: [PATCH v2 1/3] Fix __check_pf()/make_request() stack overflow segfault (convert to malloc)
- Authentication-results: sourceware.org; auth=none
- References: <524E4504 dot 6050603 at redhat dot com> <1383268213-14349-1-git-send-email-dbanerje at akamai dot com> <20140116225341 dot GA23189 at domone dot podge> <CEFDCD71 dot 2C670%dbanerje at akamai dot com> <20140117002246 dot GA14011 at domone dot podge> <20140120114139 dot GD5544 at spoyarek dot pnq dot redhat dot com> <CF03F25F dot 2C7FD%dbanerje at akamai dot com>
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