Skip to contentSkip to conversation

db conflict ?

DISCUSSION Tom 4 participants 32 messages Apr 12, 2002

Subsystems (2)
lore
Share & tools
lore

Tom

author
#0 lore raw

I have just installed a new SELinux test machine. It had an SELinux earlier, but I deleted that and installed a new one, from the Debian packages.

During boot, I get this error message:

security:  starting up (compiled Jan 12 2002)
security:  loading policy configuration from /ss_policy
security:  policydb version 8 does not match my version 7
security:  error while loading /ss_policy, cannot initialize.
SELinux:  Could not initialize
Freeing unused kernel memory: 208k freed
Adding Swap: 498004k swap-space (priority -1)
security_context_to_sid: called before initial load_policy on unknown context system_u:object_r:policy_config_t

something looks very wrong here. my /ss_policy is up-to-date:

-rw-r--r-- 1 root root 1291704 Apr 12 11:50 ss_policy

but my "make install" fails:

arkham:/etc/selinux# make install
install -m 644 -o root -g root policy /ss_policy
chsid system_u:object_r:policy_config_t /ss_policy
system_u:object_r:policy_config_t: Invalid argument
make: *** [install] Error 1

so that is probably the source of the problem. anyone got an idea what I'm doing wrong? the policy itself looks ok:

arkham:/etc/selinux# checkpolicy
checkpolicy:  loading policy configuration from policy.conf
security:  5 users, 5 roles, 488 types
security:  29 classes, 52901 rules
checkpolicy:  policy configuration loaded

I also have this error:

arkham:/etc/selinux# load_policy /ss_policy
security_load_policy: Invalid argument

maybe it's related. Since this fails, I can't relabel:

arkham:/etc/selinux# make relabel
/usr/bin/load_policy /ss_policy
security_load_policy: Invalid argument
make: *** [tmp/load] Error 2

I did remove the persistent label things:
rm -rf /...security /var/...security

I'll try a few more things, but I'm afraid the failed make install is the cause of all troubles, so any help would be appreciated...

Signature · 8 lines
http://web.lemuria.org/pubkey.html
pub  1024D/D88D35A6 2001-11-14 Tom Vogt <[email protected]>
     Key fingerprint = 276B B7BB E4D8 FCCE DB8F  F965 310B 811A D88D 35A6

--
You have received this message because you are subscribed to the selinux 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 · Tom

I have just installed a new SELinux test machine. It had an SELinux earlier, but I deleted that and installed a new one, from the Debian packages.

During boot, I get this error message:

something looks very wrong here. my /ss_policy is up-to-date:

-rw-r--r-- 1 root root 1291704 Apr 12 11:50 ss_policy

Quoted 7 lines

but my "make install" fails:

arkham:/etc/selinux# make install
install -m 644 -o root -g root policy /ss_policy
chsid system_u:object_r:policy_config_t /ss_policy
system_u:object_r:policy_config_t: Invalid argument
make: *** [install] Error 1

That's failing because you aren't running SE Linux at the time. But that's OK, merely having it copied in place by the "install" program is OK if you reboot afterwards.

Quoted 2 lines
arkham:/etc/selinux# load_policy /ss_policy
security_load_policy: Invalid argument

When you're not running SE Linux you can't load the policy, but if you booted an SE kernel in debugging mode with an invalid policy file then you should be able to use load_policy to enable SE mode.

Here's a quick and dirty hack for /etc/magic to support SE Linux policy:
0 lelong 7 SE Linux policy v7

0       lelong  8       SE Linux policy v8
>4      lelong  =1      MLS
>8      lelong  x       %d symbols
>12     lelong  x       %d ocons
Quoted 2 lines

I did remove the persistent label things:
rm -rf /...security /var/...security

That gains you nothing. The problem here is in the file /ss_policy.

Use file (after updating /etc/magic) to check /etc/selinux/policy, then make sure that the right checkpolicy program is getting run (the ancient versions would generate the old policy file). Try "make clean ; make install".

Steve, I think that we need an option in the policy.conf file to specify the version of the policydb. If we add it now then it'll break compatability with old versions of checkpolicy (which is desired). Then we can say "policy v8" in the config file and count on any older version refusing to compile it.

I think that if we already had such a feature then Tom would find his problems much easier to solve.

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
author
#2 lore raw
Quoted 9 lines · Russell Coker
Quoted 5 lines
arkham:/etc/selinux# make install
install -m 644 -o root -g root policy /ss_policy
chsid system_u:object_r:policy_config_t /ss_policy
system_u:object_r:policy_config_t: Invalid argument
make: *** [install] Error 1

That's failing because you aren't running SE Linux at the time. But that's OK, merely having it copied in place by the "install" program is OK if you reboot afterwards.

"Running SELinux" means not only having an LSM kernel with the NSA module loaded running, does it? Because I have that, at least according to dmesg.

Quoted 6 lines
Quoted 2 lines
arkham:/etc/selinux# load_policy /ss_policy
security_load_policy: Invalid argument

When you're not running SE Linux you can't load the policy, but if you booted an SE kernel in debugging mode with an invalid policy file then you should be able to use load_policy to enable SE mode.

See above. Then again, this may be the db version problem, which I found lies in the kernel. It appears I had to patch it again after updating the lsm package, so my bad.

I'm updating the kernel now and will report back when I got it done. It's a little fight for an unrelated reason, so it may take a while.

Quoted 8 lines

Steve, I think that we need an option in the policy.conf file to specify the version of the policydb. If we add it now then it'll break compatability with old versions of checkpolicy (which is desired). Then we can say "policy v8" in the config file and count on any older version refusing to compile it.

I think that if we already had such a feature then Tom would find his problems much easier to solve.

Maybe as simple as an improved output that includes the version number of the created/checked policy file. Knowing that the problem lies with the versioning of /ss_policy would've saved me an hour or two.

Signature · 8 lines
http://web.lemuria.org/pubkey.html
pub  1024D/D88D35A6 2001-11-14 Tom Vogt <[email protected]>
     Key fingerprint = 276B B7BB E4D8 FCCE DB8F  F965 310B 811A D88D 35A6

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#9 lore raw
In reply to Tom
Quoted 6 lines · Tom

I have just installed a new SELinux test machine. It had an SELinux earlier, but I deleted that and installed a new one, from the Debian packages.

During boot, I get this error message:

Quoted 8 lines
security:  starting up (compiled Jan 12 2002)
security:  loading policy configuration from /ss_policy
security:  policydb version 8 does not match my version 7
security:  error while loading /ss_policy, cannot initialize.
SELinux:  Could not initialize
Freeing unused kernel memory: 208k freed
Adding Swap: 498004k swap-space (priority -1)
security_context_to_sid: called before initial load_policy on unknown context system_u:object_r:policy_config_t

The policydb binary representation changed between the 2001121010 release (December) and the 2002011718 release (January). You need to rebuild your policy configuration with the current version of the checkpolicy policy compiler, so that the binary representation will be consistent with what the kernel expects. Make sure that you have rebuilt checkpolicy from the new packages and installed it, and then rebuild your policy.

Quoted 7 lines

but my "make install" fails:

arkham:/etc/selinux# make install
install -m 644 -o root -g root policy /ss_policy
chsid system_u:object_r:policy_config_t /ss_policy
system_u:object_r:policy_config_t: Invalid argument
make: *** [install] Error 1

This is harmless (not the cause of your problem), although it differs from the upstream SELinux distribution. Russell appears to have modified the policy Makefile to always try to relabel /ss_policy after each install, and the chsid will fail when you install SELinux on a non-SELinux kernel (but this doesn't matter in that case). We have a separate relabel target in the policy Makefile for this purpose (so you can do 'make install relabel' in policy when on a SELinux kernel, or just 'make install' when on a non-SELinux kernel). We have the same kind of support in the utils Makefile so you can do 'make install relabel' in utils as well when re-installing the modified daemons and utilities on a SELinux kernel. It looks like Russell changed the policy Makefile's relabel target to refer to setfiles so that he could unify the policy and setfiles Makefiles.

Quoted 5 lines
arkham:/etc/selinux# checkpolicy
checkpolicy:  loading policy configuration from policy.conf
security:  5 users, 5 roles, 488 types
security:  29 classes, 52901 rules
checkpolicy:  policy configuration loaded

The policy.conf file may be fine, but if you are running the wrong version of checkpolicy, you'll generate the wrong binary representation. You need to build and install the new version of checkpolicy and then build your policy.

Quoted 4 lines

I also have this error:

arkham:/etc/selinux# load_policy /ss_policy
security_load_policy: Invalid argument

load_policy only works on a SELinux kernel, since you can't load a policy into a non-SELinux kernel.

Quoted 6 lines

maybe it's related. Since this fails, I can't relabel:

arkham:/etc/selinux# make relabel
/usr/bin/load_policy /ss_policy
security_load_policy: Invalid argument
make: *** [tmp/load] Error 2

I assume that this is specific to Russell's modified Makefile. 'make relabel' for setfiles should work fine on a non-SELinux kernel and shouldn't try to run load_policy.

Quoted 2 lines

I did remove the persistent label things:
rm -rf /...security /var/...security

You only need to do this if you were running the non-LSM version of SELinux, due to a change in the mappings between the non-LSM and LSM versions of SELinux.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#7 lore raw
In reply to Russell Coker
Quoted 5 lines · Russell Coker

Steve, I think that we need an option in the policy.conf file to specify the version of the policydb. If we add it now then it'll break compatability with old versions of checkpolicy (which is desired). Then we can say "policy v8" in the config file and count on any older version refusing to compile it.

The policy.conf file isn't necessarily tied to a particular version of the policydb (the binary representation). The change from policydb version 7 to policydb version 8 had no impact on policy.conf, just on the resulting policy (/ss_policy) file compiled by checkpolicy.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#8 lore raw
Quoted 11 lines · Stephen Smalley
Quoted 5 lines · Russell Coker

Steve, I think that we need an option in the policy.conf file to specify the version of the policydb. If we add it now then it'll break compatability with old versions of checkpolicy (which is desired). Then we can say "policy v8" in the config file and count on any older version refusing to compile it.

The policy.conf file isn't necessarily tied to a particular version of the policydb (the binary representation). The change from policydb version 7 to policydb version 8 had no impact on policy.conf, just on the resulting policy (/ss_policy) file compiled by checkpolicy.

I realise that, I'm sorry if I gave the impression that things are otherwise.

However what I would like to do is distribute a package of tools for version 8 and a policy.conf file to match which is resistant to errors that the user may make.

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#10 lore raw
In reply to Stephen Smalley
Quoted 11 lines · Stephen Smalley
Quoted 7 lines

but my "make install" fails:

arkham:/etc/selinux# make install
install -m 644 -o root -g root policy /ss_policy
chsid system_u:object_r:policy_config_t /ss_policy
system_u:object_r:policy_config_t: Invalid argument
make: *** [install] Error 1

This is harmless (not the cause of your problem), although it differs from the upstream SELinux distribution. Russell appears to have modified the policy Makefile to always try to relabel /ss_policy after each install,

Yes.

Although I now think that the correct thing to do is to have a file_auto_trans() rule to do it.

Quoted 3 lines

re-installing the modified daemons and utilities on a SELinux kernel. It looks like Russell changed the policy Makefile's relabel target to refer to setfiles so that he could unify the policy and setfiles Makefiles.

Correct. In the next version I'll amend this so that it doesn't abort the install.

Quoted 4 lines

The policy.conf file may be fine, but if you are running the wrong version of checkpolicy, you'll generate the wrong binary representation. You need to build and install the new version of checkpolicy and then build your policy.

Which is surprising. My package installs it unconditionally in /usr/bin and then calls it with a fully qualified path. So I don't know how this problem occurred.

Quoted 10 lines
Quoted 6 lines

maybe it's related. Since this fails, I can't relabel:

arkham:/etc/selinux# make relabel
/usr/bin/load_policy /ss_policy
security_load_policy: Invalid argument
make: *** [tmp/load] Error 2

I assume that this is specific to Russell's modified Makefile. 'make relabel' for setfiles should work fine on a non-SELinux kernel and shouldn't try to run load_policy.

I am changing this to have it run load_policy if it believes that it's necessary, but to ignore the return code.

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux 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
In reply to Tom
Quoted 6 lines · Tom
Quoted 2 lines

I think that if we already had such a feature then Tom would find his problems much easier to solve.

Maybe as simple as an improved output that includes the version number of the created/checked policy file. Knowing that the problem lies with the versioning of /ss_policy would've saved me an hour or two.

True.

Also it would be good if we had a signature that can be recognised by file(1).

Having SE Linux code in /etc/magic for 0x6, 0x7, or 0x8, etc as the first long of the file is not viable, eventually we'll hit a conflict.

This is why I have intentionally not submitted my /etc/magic changes to the maintainer of the "file" package.

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#11 lore raw
In reply to Russell Coker
Quoted 2 lines · Russell Coker

Although I now think that the correct thing to do is to have a file_auto_trans() rule to do it.

The problem with using a file_type_auto_trans rule to label /ss_policy is that you don't want all files created by sysadm_t in the root directory to end up with policy_config_t. However, we could relocate /ss_policy into a subdirectory of the root directory, and label that subdirectory with policy_config_t so that subsequent installs will always pick up that type automatically without needing any type transition rules.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

author
#18 lore raw
In reply to Russell Coker

It looks like I solved the problem, at least it now boots and appears to run fine, except that I can't log in remotely, but ssh localhost works. I'll inspect that later.

It appears the problem was mostly mine, possibly with a feature request for better error handling/reporting.

My kernel was db version 7, the tools 8. The reason being that I did update all packages, including the lsm kernel patch, but did not re-apply it correctly. Or at least that's what I suspect. After cleaning the kernel sources and starting from scratch, it worked fine.

So from what I have seen, it looks like all the Debian packages did exactly what they should do, except that uninstalling the old flask package did not clear out /etc/selinux, even though I uninstalled doing purge (i.e. _ not - in dselect).

One thing that I noticed during this setup was that the patched login and ssh tools do not appear to work if they run on a non-lsm kernel. While this is probably the right thing to do security-wise, it also means that keeping a non-SELinux kernel as "rescue system" on-disk doesn't help a thing.
As said: Security-wise I understand this, but maybe there is a better way, at least for development purposes?

I'll go and spank sshd now. :)

Thanks to everyone for the quick help and the work done.

Signature · 8 lines
http://web.lemuria.org/pubkey.html
pub  1024D/D88D35A6 2001-11-14 Tom Vogt <[email protected]>
     Key fingerprint = 276B B7BB E4D8 FCCE DB8F  F965 310B 811A D88D 35A6

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#19 lore raw
Quoted 5 lines · Tom

One thing that I noticed during this setup was that the patched login and ssh tools do not appear to work if they run on a non-lsm kernel. While this is probably the right thing to do security-wise, it also means that keeping a non-SELinux kernel as "rescue system" on-disk doesn't help a thing.

I can't speak for the Debian selinux packages, but the upstream SELinux modified daemons and utilities run fine on non-SELinux kernels and non-LSM kernels. They simply fall back to the ordinary processing in that case.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#20 lore raw
Quoted 10 lines · Stephen Smalley
Quoted 5 lines · Tom

One thing that I noticed during this setup was that the patched login and ssh tools do not appear to work if they run on a non-lsm kernel. While this is probably the right thing to do security-wise, it also means that keeping a non-SELinux kernel as "rescue system" on-disk doesn't help a thing.

I can't speak for the Debian selinux packages, but the upstream SELinux modified daemons and utilities run fine on non-SELinux kernels and non-LSM kernels. They simply fall back to the ordinary processing in that case.

That is my aim too, and as of my last test they worked.

I'll have to test the latest versions of those packages.

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#12 lore raw
In reply to Stephen Smalley
Quoted 7 lines · Stephen Smalley
Quoted 2 lines · Russell Coker

Although I now think that the correct thing to do is to have a file_auto_trans() rule to do it.

The problem with using a file_type_auto_trans rule to label /ss_policy is that you don't want all files created by sysadm_t in the root directory to end up with policy_config_t.

In normal operation there is no reason for creating any file other than ss_policy in the root directory.

Installing a new kernel creates a new /vmlinux symlink, but I can easily write some policy to not do the auto_trans thing for lnk_file objects.

Quoted 4 lines

However, we could relocate /ss_policy into
a subdirectory of the root directory, and label that subdirectory with policy_config_t so that subsequent installs will always pick up that type automatically without needing any type transition rules.

So what directory would we use? /etc/selinux?

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux 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 Russell Coker
Quoted 5 lines · Russell Coker

Having SE Linux code in /etc/magic for 0x6, 0x7, or 0x8, etc as the first long of the file is not viable, eventually we'll hit a conflict.

This is why I have intentionally not submitted my /etc/magic changes to the maintainer of the "file" package.

Yes, you originally asked for a magic number back in January. Sorry. How about the same magic number we use to distinguish the SELinux module's system calls and security structures, 0xf97cff8c? This number follows a convention suggested by David Wheeler for security modules - see
http://marc.theaimsgroup.com/?l=linux-security-module&m=99842987214848&w=2.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#13 lore raw
In reply to Russell Coker
Quoted 1 line · Russell Coker

So what directory would we use? /etc/selinux?

Probably not. You are using /etc/selinux to store the policy source files, right (and using the policy_src_t type)? It seems preferable to keep the compiled policy in a separate directory and type (policy_config_t). That should ultimately allow us to set up a direct pipeline enforced by the kernel from the policy sources through checkpolicy to the compiled policy. I was thinking of a direct subdirectory of /, e.g. /selinux.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

author
#21 lore raw
In reply to Stephen Smalley
Quoted 9 lines · Stephen Smalley
Quoted 5 lines

One thing that I noticed during this setup was that the patched login and ssh tools do not appear to work if they run on a non-lsm kernel. While this is probably the right thing to do security-wise, it also means that keeping a non-SELinux kernel as "rescue system" on-disk doesn't help a thing.

I can't speak for the Debian selinux packages, but the upstream SELinux modified daemons and utilities run fine on non-SELinux kernels and non-LSM kernels. They simply fall back to the ordinary processing in that case.

I didn't spot any differences in the diff file, and I've just looked through it trying to find my remote login bug.

Anyway, I dig both ways of doing it, and I can always keep a rescue CD near, I'm just used to having a 2nd kernel around.

Signature · 8 lines
http://web.lemuria.org/pubkey.html
pub  1024D/D88D35A6 2001-11-14 Tom Vogt <[email protected]>
     Key fingerprint = 276B B7BB E4D8 FCCE DB8F  F965 310B 811A D88D 35A6

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
author
#22 lore raw
In reply to Tom
Quoted 3 lines · Tom

It looks like I solved the problem, at least it now boots and appears to run fine, except that I can't log in remotely, but ssh localhost works. I'll inspect that later.

Funny thing, I guess I found the revers of "NoRootLogin" :)

Analysis: Logging in via ssh as root works, as a user not. i.e. "ssh -l tom testmachine" fails, "ssh -l root testmachine" works.

The error message in /var/log/auth.log is:

fatal: Could not obtain SID for user tom

The piece of code that triggers this appears to be:

if (!get_default_user_sid(pw->pw_name,

			  strlen(pw->pw_name),
			  &scontext,
			  &sid)) {
	fprintf(stderr, "Could not obtain SID for user %s\n",
		pw->pw_name);
	exit(1);
}

so I wonder why this fails, because my /etc/selinux/users says:

user user_u roles user_r;
user root roles { user_r sysadm_r };
user tom roles { user_r sysadm_r };

so tom should be more than covered. or am I just being dumb again?

Signature · 8 lines
http://web.lemuria.org/pubkey.html
pub  1024D/D88D35A6 2001-11-14 Tom Vogt <[email protected]>
     Key fingerprint = 276B B7BB E4D8 FCCE DB8F  F965 310B 811A D88D 35A6

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#23 lore raw
Quoted 19 lines · Tom

Analysis: Logging in via ssh as root works, as a user not. i.e. "ssh -l tom testmachine" fails, "ssh -l root testmachine" works.

The error message in /var/log/auth.log is:

fatal: Could not obtain SID for user tom

The piece of code that triggers this appears to be:

if (!get_default_user_sid(pw->pw_name,

			  strlen(pw->pw_name),
			  &scontext,
			  &sid)) {
	fprintf(stderr, "Could not obtain SID for user %s\n",
		pw->pw_name);
	exit(1);
}
Quoted 7 lines

so I wonder why this fails, because my /etc/selinux/users says:

user user_u roles user_r;
user root roles { user_r sysadm_r };
user tom roles { user_r sysadm_r };

so tom should be more than covered. or am I just being dumb again?

You also need an entry for tom in /etc/security/default_context. This configuration file will be obsoleted in the future, but we're still waiting on a developer at NSA to finish the support necessary to eliminate it.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#14 lore raw
In reply to Stephen Smalley
Quoted 5 lines · Stephen Smalley
Quoted 1 line · Russell Coker

So what directory would we use? /etc/selinux?

Probably not. You are using /etc/selinux to store the policy source files, right (and using the policy_src_t type)?

I was not using policy_src_t as it's not referenced in file_contexts. My next version will change this.

Quoted 6 lines

It seems preferable to
keep the compiled policy in a separate directory and type (policy_config_t). That should ultimately allow us to set up a direct pipeline enforced by the kernel from the policy sources through checkpolicy to the compiled policy. I was thinking of a direct subdirectory of /, e.g. /selinux.

OK, that'll do.

Also while we're at it could we make the file names be "/selinux/ss_policy.%d", policy_version?

Then when we change policy versions we can easily switch between kernels that implement different versions of policy.

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux 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
In reply to Stephen Smalley
Quoted 4 lines · Stephen Smalley
Quoted 3 lines · Russell Coker

Having SE Linux code in /etc/magic for 0x6, 0x7, or 0x8, etc as the first long of the file is not viable, eventually we'll hit a conflict.

Quoted 8 lines
Quoted 2 lines

This is why I have intentionally not submitted my /etc/magic changes to the maintainer of the "file" package.

Yes, you originally asked for a magic number back in January. Sorry. How about the same magic number we use to distinguish the SELinux module's system calls and security structures, 0xf97cff8c? This number follows a convention suggested by David Wheeler for security modules - see
http://marc.theaimsgroup.com/?l=linux-security-module&m=99842987214848&w=2.

Sure, that sounds fine.

I suggest having that magic number followed by the string "SE Linux" (for people with out of date /etc/magic who are forced to use strings(1)), then the usual stuff.

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
author
#24 lore raw
In reply to Stephen Smalley
Quoted 4 lines · Stephen Smalley

You also need an entry for tom in /etc/security/default_context. This configuration file will be obsoleted in the future, but we're still waiting on a developer at NSA to finish the support necessary to eliminate it.

Works like charm. Thanks for helping a dumb newbie, I'll leave you alone now and try to compile a policy based on the /var/log/messages entries. That'll be fun. :)

Signature · 8 lines
http://web.lemuria.org/pubkey.html
pub  1024D/D88D35A6 2001-11-14 Tom Vogt <[email protected]>
     Key fingerprint = 276B B7BB E4D8 FCCE DB8F  F965 310B 811A D88D 35A6

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
author
#25 lore raw
In reply to Stephen Smalley
Quoted 6 lines · Stephen Smalley
Quoted 1 line

so tom should be more than covered. or am I just being dumb again?

You also need an entry for tom in /etc/security/default_context. This configuration file will be obsoleted in the future, but we're still waiting on a developer at NSA to finish the support necessary to eliminate it.

actually, one more question: What am I doing wrong if the generic user entries don't work? i.e. I create a new user - can't log in remotely. I add him to /etc/security/default_context - still no luck. I add him to the policy (/etc/selinux/users) and it works.

sounds like not good for systems with many users, so what is the right way to do it?

Signature · 8 lines
http://web.lemuria.org/pubkey.html
pub  1024D/D88D35A6 2001-11-14 Tom Vogt <[email protected]>
     Key fingerprint = 276B B7BB E4D8 FCCE DB8F  F965 310B 811A D88D 35A6

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#31 lore raw
In reply to Tom
Quoted 6 lines · Tom
Quoted 3 lines · Tom

It looks like I solved the problem, at least it now boots and appears to run fine, except that I can't log in remotely, but ssh localhost works. I'll inspect that later.

Funny thing, I guess I found the revers of "NoRootLogin" :)

Do you have an entry in /etc/security/default_context?

I think this may be a bug, but haven't looked into it deeply enough.

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#26 lore raw
In reply to Tom
Quoted 4 lines · Tom

actually, one more question: What am I doing wrong if the generic user entries don't work? i.e. I create a new user - can't log in remotely. I add him to /etc/security/default_context - still no luck. I add him to the policy (/etc/selinux/users) and it works.

At present, if you want to use the generic user support, you also need an entry for user_u in /etc/security/default_context (i.e. user_u:user_r:user_t). Such an entry is in the example default_context file in the upstream SELinux distribution.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

author
#27 lore raw
Quoted 4 lines · Stephen Smalley

At present, if you want to use the generic user support, you also need an entry for user_u in /etc/security/default_context (i.e. user_u:user_r:user_t). Such an entry is in the example default_context file in the upstream SELinux distribution.

I have that. However, trying to log in via ssh fails with the same SID error message I had earlier for tom when I didn't have tom in the default_context. So this was my first idea - but not luck. I also do have that user_u in the users role file (I didn't modify the default very much yet).

Signature · 8 lines
http://web.lemuria.org/pubkey.html
pub  1024D/D88D35A6 2001-11-14 Tom Vogt <[email protected]>
     Key fingerprint = 276B B7BB E4D8 FCCE DB8F  F965 310B 811A D88D 35A6

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#15 lore raw
In reply to Russell Coker

I think adding a magic number to the policy file is probably a good idea. I'm not quite as sure about the file name containing a version number, but it's probably a good idea as well. My reading of the FHS (v2.2) is that it prohibits /selinux/. My suggestion would be /etc/security/policy/ or /etc/security/policies/ with the thought that there might be at least multiple versions in the directory so plural might be appropriate.

Quoted 17 lines · Russell Coker
Quoted 5 lines · Stephen Smalley
Quoted 1 line · Russell Coker

So what directory would we use? /etc/selinux?

Probably not. You are using /etc/selinux to store the policy source files, right (and using the policy_src_t type)?

I was not using policy_src_t as it's not referenced in file_contexts. My next version will change this.

Quoted 6 lines

It seems preferable to
keep the compiled policy in a separate directory and type (policy_config_t). That should ultimately allow us to set up a direct pipeline enforced by the kernel from the policy sources through checkpolicy to the compiled policy. I was thinking of a direct subdirectory of /, e.g. /selinux.

Quoted 7 lines

OK, that'll do.

Also while we're at it could we make the file names be "/selinux/ss_policy.%d", policy_version?

Then when we change policy versions we can easily switch between kernels that implement different versions of policy.

--
Howard Holm <[email protected]>
Secure Systems Research Office
National Security Agency

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#28 lore raw
In reply to Tom
Quoted 5 lines · Tom

I have that. However, trying to log in via ssh fails with the same SID error message I had earlier for tom when I didn't have tom in the default_context. So this was my first idea - but not luck. I also do have that user_u in the users role file (I didn't modify the default very much yet).

Seems to work here for me. I added a user who has no entry in policy/users or /etc/security/default_contexts, then logged in as that user using ssh and ended up with my context as user_u:user_r:user_t. Again, this is with the upstream distribution, not the Debian selinux package.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#16 lore raw
In reply to Howard Holm
Quoted 6 lines · Howard Holm

I think adding a magic number to the policy file is probably a good idea. I'm not quite as sure about the file name containing a version number, but it's probably a good idea as well. My reading of the FHS (v2.2) is that it prohibits /selinux/. My suggestion would be /etc/security/policy/ or /etc/security/policies/ with the thought that there might be at least multiple versions in the directory so plural might be appropriate.

/etc/security/policy sounds good to me.

Having multiple versions of the same policy does not require a plural (IMHO). The plural would be required if we had a choice of policies that differed in some way other than the version number.

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#17 lore raw
In reply to Howard Holm
Quoted 6 lines · Howard Holm

I think adding a magic number to the policy file is probably a good idea. I'm not quite as sure about the file name containing a version number, but it's probably a good idea as well. My reading of the FHS (v2.2) is that it prohibits /selinux/. My suggestion would be /etc/security/policy/ or /etc/security/policies/ with the thought that there might be at least multiple versions in the directory so plural might be appropriate.

I primarily want to keep it separate from the policy sources (/etc/selinux in Russell's Debian package), yet clearly identified as being selinux-specific. It also needs to stay within the root filesystem, although that isn't a problem regardless of whether we go with /selinux or /etc/security/selinux or /etc/selinux/policy as the subdirectory name. The name for the file itself can be reduced to policy.VERSION once it is in a selinux-specific directory (the ss_ prefix was just to avoid conflicts with other potential non-SELinux policy files, ss == security server).

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

author
#29 lore raw
In reply to Stephen Smalley
Quoted 5 lines · Stephen Smalley

Seems to work here for me. I added a user who has no entry in policy/users or /etc/security/default_contexts, then logged in as that user using ssh and ended up with my context as user_u:user_r:user_t. Again, this is with the upstream distribution, not the Debian selinux package.

ok, I'll check again. I didn't notice any differences between the upstream and the debian version of ssh when I checked the diffs earlier today.

Signature · 8 lines
http://web.lemuria.org/pubkey.html
pub  1024D/D88D35A6 2001-11-14 Tom Vogt <[email protected]>
     Key fingerprint = 276B B7BB E4D8 FCCE DB8F  F965 310B 811A D88D 35A6

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#30 lore raw
Quoted 3 lines · Tom

ok, I'll check again. I didn't notice any differences between the upstream and the debian version of ssh when I checked the diffs earlier today.

The differences might be in libsecure rather than directly in ssh.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#6 lore raw
In reply to Stephen Smalley

Attached are some quick patches for experimentation that add a magic number and string identifier at the beginning of the binary policy, and relocate the binary policy to /etc/security/selinux/policy.VERSION. To use, apply the first patch to lsm-2.4 (cd lsm-2.4 && patch -p0 < ~/lsm-2.4.patch) and apply the second patch to selinux (cd selinux && patch -p0 < ~/selinux.patch). Then, build and install the new kernel, build and install the new checkpolicy, and build and install the policy using the new checkpolicy.

--
Stephen D. Smalley, NAI Labs
[email protected]

Index: security/selinux/ss/global.h
===================================================================
RCS file: /cvs/lsm/lsm-2.4/security/selinux/ss/global.h,v retrieving revision 1.3

selinux/ss/global.h +2 -0
diff -u -r1.3 global.h
@@ -42,6 +42,7 @@
 #include <linux/flask/security.h>
 #include <linux/flask/avc_ss.h>
 #include <linux/flask/av_permissions.h>
+#include <linux/flask/syscalls.h>
 
 #define NIPQUAD(addr) \
 	((unsigned char *)&addr)[0], \
@@ -76,6 +77,7 @@
 #include <linux/flask/avc.h>
 #include <linux/flask/avc_ss.h>
 #include <linux/flask/security.h>
+#include <linux/flask/syscalls.h>
 #include <asm/system.h>
 #include <linux/spinlock.h>
 #include <asm/uaccess.h>

Index: security/selinux/ss/init.c
===================================================================
RCS file: /cvs/lsm/lsm-2.4/security/selinux/ss/init.c,v retrieving revision 1.3

selinux/ss/init.c +11 -1
diff -u -r1.3 init.c
@@ -11,12 +11,22 @@
 #include "policydb.h"
 #include "services.h"
 
-char *policyfile = "/ss_policy";
+char *policyfile;
 
 int security_init(void)
 {
 	FILE *fp;
+	unsigned int len;
 	int rc;
+
+	len = strlen(POLICYDB_PATHPREFIX)+7;
+	policyfile = malloc(len);
+	if (!policyfile) {
+		printf("security:  cannot allocate space for policy path\n");
+		return -EINVAL;
+	}
+	snprintf(policyfile, len, "%s.%d", POLICYDB_PATHPREFIX, 
+		 POLICYDB_VERSION);
 
 	printf("security:  starting up (compiled " __DATE__ ")\n");
 	printf("security:  loading policy configuration from %s\n", policyfile);

Index: security/selinux/ss/policydb.c
===================================================================
RCS file: /cvs/lsm/lsm-2.4/security/selinux/ss/policydb.c,v retrieving revision 1.1

selinux/ss/policydb.c +51 -1

71 lines not on this page · raw message

Index: security/selinux/ss/policydb.h
===================================================================
RCS file: /cvs/lsm/lsm-2.4/security/selinux/ss/policydb.h,v retrieving revision 1.2

selinux/ss/policydb.h +5 -1
diff -u -r1.2 policydb.h
@@ -229,11 +229,15 @@
 
 #define PERM_SYMTAB_SIZE 32
 
-#define POLICYDB_VERSION 8
+#define POLICYDB_VERSION 9
 #define POLICYDB_CONFIG_MLS    1
 
 #define OBJECT_R "object_r"
 #define OBJECT_R_VAL 1
+
+#define POLICYDB_PATHPREFIX "/etc/security/selinux/policy"
+#define POLICYDB_MAGIC SELINUX_MAGIC
+#define POLICYDB_STRING "SE Linux"
 
 #endif	/* _POLICYDB_H_ */
 

Index: module/checkpolicy/checkpolicy.c
===================================================================
RCS file: /cvs/lsm/selinux/module/checkpolicy/checkpolicy.c,v retrieving revision 1.8

checkpolicy/checkpolicy.c +6 -3
diff -u -r1.8 checkpolicy.c
@@ -305,7 +305,7 @@
 	int ret, ch, nel;
 	FILE *fp, *outfp = NULL;
 
-	while ((ch = getopt(argc, argv, "o:db")) != EOF) {
+	while ((ch = getopt(argc, argv, "o:dbV")) != EOF) {
 		switch (ch) {
 		case 'o':
 			outfile = optarg;
@@ -317,6 +317,9 @@
 		case 'd':
 			debug = 1;
 			break;
+		case 'V':
+			printf("%d\n", POLICYDB_VERSION);
+			exit(0);
 		default:
 			usage(argv[0]);
 		}
@@ -383,8 +386,8 @@
 	printf("%s:  policy configuration loaded\n", argv[0]);
 
 	if (outfile) {
-		printf("%s:  writing binary representation to %s\n",
-		       argv[0], outfile);
+		printf("%s:  writing binary representation (version %d) to %s\n",
+		       argv[0], POLICYDB_VERSION, outfile);
 		outfp = fopen(outfile, "w");
 		if (!outfp) {
 			perror(outfile);

Index: policy/Makefile
===================================================================
RCS file: /cvs/lsm/selinux/policy/Makefile,v
retrieving revision 1.15

Makefile +14 -7
diff -u -r1.15 Makefile
@@ -17,6 +17,11 @@
 LOADPOLICY  = $(BINDIR)/load_policy
 CHECKPOLICY = $(BINDIR)/checkpolicy
 
+
+POLICYVER := policy.$(shell $(CHECKPOLICY) -V)
+INSTALLDIR = /etc/security/selinux
+LOADPATH = $(INSTALLDIR)/$(POLICYVER)
+
 POLICYFILES = $(addprefix /usr/local/selinux/flask/,security_classes initial_sids access_vectors)
 ifeq ($(MLS),y)
 POLICYFILES += mls
@@ -28,26 +33,28 @@
 
 TESTPOLICYFILES = $(subst all.te,test_all.te,$(POLICYFILES))
 
-policy:  policy.conf 
+$(POLICYVER):  policy.conf 
 	$(CHECKPOLICY) -o $@ policy.conf
 
 policy.conf: $(POLICYFILES)
 	m4 -Imacros -s $^ > policy.conf
 
-install: policy
-	install -m 644 -o root -g root policy /ss_policy
+install: $(POLICYVER)
+	mkdir -p $(INSTALLDIR)
+	install -m 644 -o root -g root $(POLICYVER) $(INSTALLDIR)
 
 load: install
-	$(BINDIR)/load_policy /ss_policy
+	$(BINDIR)/load_policy $(LOADPATH)
 
 testpolicy:  testpolicy.conf 
 	$(CHECKPOLICY) -o $@ testpolicy.conf
 
 testinstall:  testpolicy
-	install -m 644 -o root -g root testpolicy /ss_policy
+	mkdir -p $(INSTALLDIR)
+	install -m 644 -o root -g root testpolicy $(LOADPATH)
 
 testload:  testinstall
-	$(BINDIR)/load_policy /ss_policy
+	$(BINDIR)/load_policy $(LOADPATH)
 
 testpolicy.conf: $(TESTPOLICYFILES)
 	m4 -Imacros -s $^ > testpolicy.conf
@@ -70,7 +77,7 @@
 	cat $^ > $@
 
 clean:
-	rm -f policy policy.conf 
+	rm -f policy policy.conf $(POLICYVER)
 	rm -f all.te all_types.te all_domains.te test_domains.te
 	rm -f test_all.te test_all_domains.te testpolicy testpolicy.conf