Module Name: src Committed By: christos Date: Thu Sep 30 12:35:55 UTC 2021
Modified Files: src/lib/libc/resolv: res_init.c res_private.h Log Message: kqueue(2) file descriptors are not inherited across fork(2). A process that that calls getaddrinfo(3) will end up cacheing the kqueue(2) file descriptor in its res_state structure. If that process fork(2)s and calls getaddrinfo(3) again might end up closing that cached file descriptor which can end up pointing to a different file object than the kqueue(2) original one. To fix this, associate the kqueue(2) file descriptor with the process id that created it, and don't close(2) it if it is being closed from a different process. An alternative fix would be to attach the resolver to a fork(2) hook to cleanup the res_state, but handling it internally in the resolver is less intrusive. This was discovered by Dima Veselov when using the FreeRADIUS package. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/lib/libc/resolv/res_init.c cvs rdiff -u -r1.3 -r1.4 src/lib/libc/resolv/res_private.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.