All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Dennis Wronka <linuxweb@gmx.net>
Cc: SELinux@tycho.nsa.gov, Joshua Brindle <jbrindle@tresys.com>,
	Chad Sellers <csellers@tresys.com>
Subject: Re: Policy loading problem
Date: Wed, 20 May 2009 11:10:14 -0400	[thread overview]
Message-ID: <1242832214.20082.410.camel@localhost.localdomain> (raw)
In-Reply-To: <200905202257.08555.linuxweb@gmx.net>

On Wed, 2009-05-20 at 22:57 +0800, Dennis Wronka wrote:
> Okay, here we go:
> 
> I unmounted /selinux and then got this:
> load_policy: Can't load policy: Invalid argument
> 
> I attached my kernel-config and the two traces (trace1 for the "Device or 
> resource busy"-error, trace2 for the "Invalid argument"-error).

Possible patch for libselinux to a) gracefully handle the situation
where selinuxfs is already mounted, b) report errors when switching to
permissive, and c) proceed with the policy load even if we cannot switch
to permissive mode as requested, as proceeding without a policy when the
kernel only supports enforcing mode is not desirable.

diff --git a/libselinux/src/load_policy.c b/libselinux/src/load_policy.c
index a3a28a0..a7800da 100644
--- a/libselinux/src/load_policy.c
+++ b/libselinux/src/load_policy.c
@@ -369,7 +369,7 @@ int selinux_init_load_policy(int *enforce)
 	 * Check for the existence of SELinux via selinuxfs, and 
 	 * mount it if present for use in the calls below.  
 	 */
-	if (mount("none", SELINUXMNT, "selinuxfs", 0, 0) < 0) {
+	if (mount("none", SELINUXMNT, "selinuxfs", 0, 0) < 0 && errno != EBUSY) {
 		if (errno == ENODEV) {
 			/*
 			 * SELinux was disabled in the kernel, either
@@ -416,8 +416,11 @@ int selinux_init_load_policy(int *enforce)
 		goto noload;
 	if (orig_enforce != *enforce) {
 		rc = security_setenforce(*enforce);
-		if (rc < 0)
-			goto noload;
+		if (rc < 0) {
+			fprintf(stderr, "SELinux:  Unable to switch to %s mode:  %s\n", (*enforce ? "enforcing" : "permissive"), strerror(errno));
+			if (*enforce)
+				goto noload;
+		}
 	}
 
 	/* Load the policy. */

-- 
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  parent reply	other threads:[~2009-05-20 15:10 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-18 10:19 avc: denied null Dominick Grift
2009-05-18 12:50 ` Stephen Smalley
2009-05-18 12:59   ` Dominick Grift
2009-05-18 18:52     ` Eamon Walsh
2009-05-20  3:11     ` Eamon Walsh
2009-05-20  7:21       ` Policy loading problem Dennis Wronka
2009-05-20 11:46         ` Stephen Smalley
2009-05-20 13:46           ` Dennis Wronka
2009-05-20 13:49             ` Stephen Smalley
2009-05-20 14:07               ` Dennis Wronka
2009-05-20 14:09                 ` Stephen Smalley
2009-05-20 14:21                   ` Stephen Smalley
2009-05-20 14:42                     ` Dennis Wronka
2009-05-20 14:40                       ` Stephen Smalley
2009-05-20 14:57                         ` Dennis Wronka
2009-05-20 14:59                           ` Stephen Smalley
2009-05-20 15:22                             ` Dennis Wronka
2009-05-20 15:44                             ` Dennis Wronka
2009-05-20 16:44                               ` Stephen Smalley
2009-05-20 21:01                                 ` Paul Howarth
2009-05-20 15:10                           ` Stephen Smalley [this message]
2009-07-07 15:53                             ` Joshua Brindle
2009-05-20 11:08       ` avc: denied null Dominick Grift
2009-05-21  2:36         ` Eamon Walsh
2009-05-21 12:19           ` Dominick Grift
2009-05-21 20:15           ` Dominick Grift

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1242832214.20082.410.camel@localhost.localdomain \
    --to=sds@tycho.nsa.gov \
    --cc=SELinux@tycho.nsa.gov \
    --cc=csellers@tresys.com \
    --cc=jbrindle@tresys.com \
    --cc=linuxweb@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.