From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29760 invoked by alias); 13 May 2009 23:22:48 -0000 Received: (qmail 29739 invoked by uid 22791); 13 May 2009 23:22:47 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 May 2009 23:22:42 +0000 Received: from sunsite.mff.cuni.cz (localhost.localdomain [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.8/8.13.8) with ESMTP id n4DNXJYm028958; Thu, 14 May 2009 01:33:19 +0200 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.13.8/8.13.8/Submit) id n4DNXJPb028957; Thu, 14 May 2009 01:33:19 +0200 Date: Wed, 13 May 2009 23:22:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Fix nscd -K Message-ID: <20090513233319.GM16681@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2009-05/txt/msg00004.txt.bz2 Hi! When nscd runs with SELinux enabled, running nscd -K might segfault the daemon before exit, because avc_destroy is called in the thread calling termination_handler, but other threads might be busy doing other stuff and possibly calling something that expects the avc not to be destroyed yet. 2009-05-14 Jakub Jelinek * nscd/selinux.c (nscd_avc_destroy): Removed. * nscd/selinux.h (nscd_avc_destroy): Likewise. * nscd/nscd.c (termination_handler): Don't call nscd_avc_destroy. --- libc/nscd/nscd.c.jj 2009-02-16 14:47:30.000000000 +0100 +++ libc/nscd/nscd.c 2009-05-14 01:13:59.000000000 +0200 @@ -488,10 +488,6 @@ termination_handler (int signum) msync (dbs[cnt].head, dbs[cnt].memsize, MS_ASYNC); } - /* Shutdown the SELinux AVC. */ - if (selinux_enabled) - nscd_avc_destroy (); - _exit (EXIT_SUCCESS); } --- libc/nscd/selinux.c.jj 2007-12-10 09:05:34.000000000 +0100 +++ libc/nscd/selinux.c 2009-05-14 01:15:02.000000000 +0200 @@ -1,5 +1,5 @@ /* SELinux access controls for nscd. - Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Matthew Rickard , 2004. @@ -418,15 +418,4 @@ nscd_avc_print_stats (struct avc_cache_s cstats->cav_probes, cstats->cav_misses); } - -/* Clean up the AVC before exiting. */ -void -nscd_avc_destroy (void) -{ - avc_destroy (); -#ifdef HAVE_LIBAUDIT - audit_close (audit_fd); -#endif -} - #endif /* HAVE_SELINUX */ --- libc/nscd/selinux.h.jj 2007-04-23 10:54:02.000000000 +0200 +++ libc/nscd/selinux.h 2009-05-14 01:14:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Header for nscd SELinux access controls. - Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Matthew Rickard , 2004. @@ -35,8 +35,6 @@ struct avc_cache_stats; /* Initialize the userspace AVC. */ extern void nscd_avc_init (void); -/* Destroy the userspace AVC. */ -extern void nscd_avc_destroy (void); /* Determine if we are running on an SELinux kernel. */ extern void nscd_selinux_enabled (int *selinux_enabled); /* Check if the client has permission for the request type. */ @@ -55,7 +53,6 @@ extern void install_real_capabilities (c #else # define selinux_enabled 0 # define nscd_avc_init() (void) 0 -# define nscd_avc_destroy() (void) 0 # define nscd_selinux_enabled(selinux_enabled) (void) 0 # define nscd_request_avc_has_perm(fd, req) 0 # define nscd_avc_cache_stats(cstats) (void) 0 Jakub