trouble shutting down avc netlink socket
Stephen Smalley
sds at epoch.ncsc.mil
Mon Aug 23 20:17:15 UTC 2004
On Mon, 2004-08-23 at 15:37, Colin Walters wrote:
> Hi,
>
> I'm having a problem where calling avc_destroy doesn't seem to close the
> netlink socket, because a subsequent avc_init is unable to bind to the
> socket, and gets an error "Address already in use".
>
> The attached test program lets me reproduce the problem - the very
> interesting thing is it seems to only happen about 50% of the time. Is
> there some race here in the kernel?
>
> As far as I can tell the close() is being called so the socket should be
> shut down.
Changing libselinux to not set the pid in the socket address (so that
the kernel auto-binds the socket) seems to avoid the problem, but this
may just be covering the underlying bug.
Index: libselinux/src/avc_internal.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/avc_internal.c,v
retrieving revision 1.14
diff -u -r1.14 avc_internal.c
--- libselinux/src/avc_internal.c 15 Jun 2004 18:47:10 -0000 1.14
+++ libselinux/src/avc_internal.c 23 Aug 2004 20:11:31 -0000
@@ -69,7 +69,6 @@
memset(&addr, 0, len);
addr.nl_family = AF_NETLINK;
- addr.nl_pid = getpid();
addr.nl_groups = SELNL_GRP_AVC;
if (bind(fd, (struct sockaddr *)&addr, len) < 0) {
--
Stephen Smalley <sds at epoch.ncsc.mil>
National Security Agency
More information about the fedora-selinux-list
mailing list