Skip to contentSkip to conversation

Question about setsebool.c

DISCUSSION Yuichi Nakamura 4 participants 6 messages Nov 20, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hi, I looked at the latest policycoreutils code.
(policycoreutils-1.33.1-9.fc7.src.rpm)

And found strange code, in setsebool.c.

94 /* Apply (permanent) boolean changes to policy via libsemanage */ 95 static int semanage_set_boolean_list(size_t boolcnt,
96 SELboolean * boollist, int perm)
97 {
<snip>
117 } else if (managed == 0) {
118 if (selinux_set_boolean_list(boolcnt, boollist, 1) < 0)
119 goto err;
120 goto out;
121 }

Why 3rd arg for selinux_set_boolean_list is "1"?
Should it be "perm"?

Yuichi Nakamura

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 10 lines · Yuichi Nakamura

Hi, I looked at the latest policycoreutils code.
(policycoreutils-1.33.1-9.fc7.src.rpm)

And found strange code, in setsebool.c.

94 /* Apply (permanent) boolean changes to policy via libsemanage */ 95 static int semanage_set_boolean_list(size_t boolcnt,
96 SELboolean * boollist, int perm)
97 {
<snip>

Quoted 9 lines
   117          } else if (managed == 0) {
   118                  if (selinux_set_boolean_list(boolcnt, boollist, 1) < 0)
   119                          goto err;
   120                  goto out;
   121          }

Why 3rd arg for selinux_set_boolean_list is "1"?
Should it be "perm"?

Looks that way to me. Additionally, is it even possible to make non-permanent change to a boolean via semanage? If not, then this code path should check for that. Josh?

Karl

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#2 lore raw
Quoted 20 lines · Karl MacMillan
Quoted 19 lines · Yuichi Nakamura

Hi, I looked at the latest policycoreutils code.
(policycoreutils-1.33.1-9.fc7.src.rpm)

And found strange code, in setsebool.c.

94 /* Apply (permanent) boolean changes to policy via
libsemanage */
95 static int semanage_set_boolean_list(size_t boolcnt,
96 SELboolean * boollist,
int perm)

    97  {

<snip>
117 } else if (managed == 0) {
118 if (selinux_set_boolean_list(boolcnt,
boollist, 1) < 0)

   119                          goto err;
   120                  goto out;
   121          }
Quoted 6 lines
Quoted 3 lines

Why 3rd arg for selinux_set_boolean_list is "1"?
Should it be "perm"?

Looks that way to me. Additionally, is it even possible to make non-permanent change to a boolean via semanage? If not, then this code path should check for that. Josh?

libsemanage is only responsible for the persistent changes, sesetbool sets the non-persistent directly, in fact demonstrated by the code snippet above. This does look like a bug and if someone uses setsebool to set a non-persistent boolean on an unmanaged system it appears that it will indeed make it permanent.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#3 lore raw
Quoted 29 lines · Joshua Brindle
Quoted 20 lines · Karl MacMillan
Quoted 19 lines · Yuichi Nakamura

Hi, I looked at the latest policycoreutils code.
(policycoreutils-1.33.1-9.fc7.src.rpm)

And found strange code, in setsebool.c.

94 /* Apply (permanent) boolean changes to policy via
libsemanage */
95 static int semanage_set_boolean_list(size_t boolcnt,
96 SELboolean * boollist,
int perm)

    97  {

<snip>
117 } else if (managed == 0) {
118 if (selinux_set_boolean_list(boolcnt,
boollist, 1) < 0)

   119                          goto err;
   120                  goto out;
   121          }
Quoted 8 lines
Quoted 3 lines

Why 3rd arg for selinux_set_boolean_list is "1"?
Should it be "perm"?

Looks that way to me. Additionally, is it even possible to make non-permanent change to a boolean via semanage? If not, then this code path should check for that. Josh?

Quoted 5 lines

libsemanage is only responsible for the persistent changes, sesetbool sets the non-persistent directly, in fact demonstrated by the code snippet above. This does look like a bug and if someone uses setsebool to set a non-persistent boolean on an unmanaged system it appears that it will indeed make it permanent.

Point of clarification - if policy is managed, libsemanage does handle non-persistent booleans as well (the _active interfaces). But I agree that the above appears to be a bug in the unmanaged case.

Signature · 8 lines
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 [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw
In reply to Joshua Brindle
Quoted 21 lines · Joshua Brindle
Quoted 20 lines · Karl MacMillan
Quoted 19 lines · Yuichi Nakamura

Hi, I looked at the latest policycoreutils code.
(policycoreutils-1.33.1-9.fc7.src.rpm)

And found strange code, in setsebool.c.

94 /* Apply (permanent) boolean changes to policy via
libsemanage */
95 static int semanage_set_boolean_list(size_t boolcnt,
96 SELboolean * boollist,
int perm)

    97  {

<snip>
117 } else if (managed == 0) {
118 if (selinux_set_boolean_list(boolcnt,
boollist, 1) < 0)

   119                          goto err;
   120                  goto out;
   121          }
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

Why 3rd arg for selinux_set_boolean_list is "1"?
Should it be "perm"?

Looks that way to me. Additionally, is it even possible to make non-permanent change to a boolean via semanage? If not, then this code path should check for that. Josh?

libsemanage is only responsible for the persistent changes,

That is not how the current setsebool.c code works - see:

if (perm

    && semanage_bool_modify_local(handle, bool_key, boolean) < 0)
	goto err;

Testing confirms that this allows setting non-persistent booleans via semanage using setsebool.

sesetbool

Quoted 2 lines

sets the non-persistent directly, in fact demonstrated by the code snippet above. This does look like a bug and if someone uses setsebool to set a non-persistent boolean on an unmanaged system it appears that it will indeed make it permanent.

What about this:

policycoreutils/setsebool/setsebool.c +1 -1
diff -r 130ab1cdcc3a policycoreutils/setsebool/setsebool.c
@@ -115,7 +115,7 @@ static int semanage_set_boolean_list(siz
 		goto err;
 
 	} else if (managed == 0) {
-		if (selinux_set_boolean_list(boolcnt, boollist, 1) < 0)
+		if (selinux_set_boolean_list(boolcnt, boollist, perm) < 0)
 			goto err;
 		goto out;
 	}

Signed-off-by Karl MacMillan <[email protected]>

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#5 lore raw
Quoted 63 lines · Karl MacMillan
Quoted 25 lines · Joshua Brindle
Quoted 24 lines · Karl MacMillan
Quoted 22 lines · Yuichi Nakamura

Hi, I looked at the latest policycoreutils code.
(policycoreutils-1.33.1-9.fc7.src.rpm)

And found strange code, in setsebool.c.

94 /* Apply (permanent) boolean changes to policy via
libsemanage */
95 static int semanage_set_boolean_list(size_t boolcnt,
96 SELboolean * boollist,
int perm)

    97  {

<snip>
117 } else if (managed == 0) {
118 if (selinux_set_boolean_list(boolcnt,
boollist, 1) < 0)

   119                          goto err;
   120                  goto out;
   121          }

Why 3rd arg for selinux_set_boolean_list is "1"?
Should it be "perm"?

Quoted 5 lines
Quoted 4 lines

Looks that way to me. Additionally, is it even possible to make non-permanent change to a boolean via semanage? If not, then this code path should check for that. Josh?

libsemanage is only responsible for the persistent changes,

That is not how the current setsebool.c code works - see:

if (perm

     && semanage_bool_modify_local(handle, bool_key, boolean) < 0)
	goto err;

Testing confirms that this allows setting non-persistent booleans via semanage using setsebool.

sesetbool

Quoted 5 lines

sets the non-persistent directly, in fact demonstrated by the code snippet above. This does look like a bug and if someone uses setsebool to set a non-persistent boolean on an unmanaged system it appears that it will indeed make it permanent.

What about this:

diff -r 130ab1cdcc3a policycoreutils/setsebool/setsebool.c

policycoreutils/setsebool/setsebool.c +1 -1
@@ -115,7 +115,7 @@ static int semanage_set_boolean_list(siz
  		goto err;
 
  	} else if (managed == 0) {
-		if (selinux_set_boolean_list(boolcnt, boollist, 1) < 0)
+		if (selinux_set_boolean_list(boolcnt, boollist, perm) < 0)
  			goto err;
  		goto out;
  	}
Quoted 1 line

Signed-off-by Karl MacMillan <[email protected]>

Signature · 8 lines
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 [email protected] with
the words "unsubscribe selinux" without quotes as the message.