inet: Fix getnameinfo (NI_NOFQDN) race condition (BZ#28566)
commitc54d689269c7f10e7f7d28b1cb5b3a6a0dd5a889
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 10 Nov 2021 17:40:30 +0000 (10 14:40 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 8 Mar 2022 15:51:29 +0000 (8 12:51 -0300)
tree740094e56b211d8e3af5393129431fc05fc7ea7f
parentedddffc9df5ea5882192bca7ddaad8f6440bcc44
inet: Fix getnameinfo (NI_NOFQDN) race condition (BZ#28566)

The 'not_first' is accessed on nrl_domainname() in a non atomically
way, although it is only updated after the lock is taken.

This patch fix the double-checked locking by using acquire-release
atomic operation instead of plain load and by moving the 'not_first'
store only after 'domain' is actually set.

Checked on x86_64-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
inet/getnameinfo.c