Fix potential hanging of gethostbyaddr_r/gethostbyname_r
commitb57525f1a376149840f740a31535681c07152ba4
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 18 Jun 2015 21:40:46 +0000 (18 21:40 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 23 Jun 2015 09:37:28 +0000 (23 09:37 +0000)
treec520a3234fda67b9c99562eb1b06e090e9cc2bb5
parent47852c972d1ad80d8b38d9e94507b27df0ede421
Fix potential hanging of gethostbyaddr_r/gethostbyname_r

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.
ChangeLog
NEWS
resolv/Makefile
resolv/res_hconf.c
resolv/tst-res_hconf_reorder.c [new file with mode: 0644]