[PATCH v3] Linux: Simplify __opensock and fix race condition [BZ #28353]

Florian Weimer fweimer@redhat.com
Wed Nov 17 13:54:07 GMT 2021


* Adhemerval Zanella:

> On 27/09/2021 15:53, Florian Weimer via Libc-alpha wrote:
>> AF_NETLINK support is not quite optional on modern Linux systems
>> anymore, so it is likely that the first attempt will always succeed.
>> Consequently, there is no need to cache the result.  Keep AF_UNIX
>> and the Internet address families as a fallback, for the rare case
>> that AF_NETLINK is missing.  The other address families previously
>> probed are totally obsolete be now, so remove them.
>> 
>> Use this simplified version as the generic implementation, disabling
>> Netlink support as needed.
>
> It seems that defaulting to AF_NETLINKS fails for some operations on
> older kernels:
>
> $ uname -a
> Linux ubuntu16 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
> $ ./testrun.sh --tool=strace inet/test_ifindex --direct
> [...]
> socket(PF_NETLINK, SOCK_DGRAM|SOCK_CLOEXEC, NETLINK_ROUTE) = 3
> ioctl(3, SIOCGIFINDEX, {ifr_name="lo"}) = -1 EOPNOTSUPP (Operation not supported)
> close(3)                                = 0
>
> I am not sure if this something related to the system configuration or
> some security features, but AF_UNIX does work in this case.

Right.  I will send a patch.  I think it's not worth trying AF_NETLINK
at all.

Thanks,
Florian



More information about the Libc-alpha mailing list