[PATCH v2] [BZ #17977] Fix potential hanging of gethostbyaddr_r/gethostbyname_r
Siddhesh Poyarekar
siddhesh@redhat.com
Tue Jun 23 09:52:00 GMT 2015
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
More information about the Libc-alpha
mailing list