This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] [BZ #17977] Fix potential hanging of gethostbyaddr_r/gethostbyname_r
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Tue, 23 Jun 2015 14:38:20 +0530
- Subject: Re: [PATCH v2] [BZ #17977] Fix potential hanging of gethostbyaddr_r/gethostbyname_r
- Authentication-results: sourceware.org; auth=none
- References: <20150619004907 dot GA11512 at altlinux dot org> <20150622024908 dot GN6315 at spoyarek dot pnq dot redhat dot com> <20150622113252 dot GA30510 at altlinux dot org>
On Mon, Jun 22, 2015 at 02:32:52PM +0300, Dmitry V. Levin wrote:
> When "reorder" resolver option is enabled, threads of a multi-threaded process
> could hang in gethostbyaddr_r, gethostbyname_r, or gethostbyname2_r.
>
> Due to a trivial bug in _res_hconf_reorder_addrs, simultaneous
> invocations of this function in a multi-threaded process could result to
> _res_hconf_reorder_addrs returning without releasing the lock it holds,
> causing other threads to block indefinitely while waiting for the lock
> that is not going to be released.
>
> [BZ #17977]
> * resolv/res_hconf.c (_res_hconf_reorder_addrs): Fix unlocking
> when initializing interface list, based on the bug analysis
> and the patch proposed by Eric Newton.
> * resolv/tst-res_hconf_reorder.c: New test.
> * resolv/Makefile [$(have-thread-library) = yes] (tests): Add
> tst-res_hconf_reorder.
> ($(objpfx)tst-res_hconf_reorder): Depend on $(libdl)
> and $(shared-thread-library).
> (tst-res_hconf_reorder-ENV): New variable.
Looks good to me.
Thanks,
Siddhesh