Skip to contentSkip to conversation

Selinux on the "Lunar" linux distribution.

DISCUSSION forrest whitcher 2 participants 2 messages Jan 19, 2003 – Jan 20, 2003 SELinux security module

lore
Share & tools
lore
#0 lore raw

Summary:

Lunar linux (http://lunar-linux.org) is a source-based distribution which uses a set of bash scripts to provide package management and build recipes for various server and client applications. Lunar provides sysV init and FHS layout and strives for LSB compliance.

SELinux (http://www.nsa.gov/selinux) is a system impementing NSA's FLASK model, providing domain and type enforcement and tools for MAC/MLS policy development/implementation within the LSM (http://lsm.immunix.org) framework.

I have been running the SELinux kernel in the lunar distribution as a vmware guest OS for a considerable time. Here are some notes on how to build and run this kernel on the lunar distribution.

Config:

Lunar installed off of the 1.1.2 cd image. I expect this will work on later test images, probably with a couple fewer foibles. The latest work has been done runing gcc 3.2.1 and glibc 2.3.1. I'm not running/installing the current lunar kernel 2.4.20.

SELinux, kernel 2.4.19 version LSM patch and selinux sources. I don't have a particular need for the .20 kernel, however I think the .20 version of the sources will work find (and might not need some of the customizations below).

Generally, I think it's a good practice here to have as complete a setup as possible prior to installing the hardened kernel. This is particularly true of security-related applications or libraries as installation after starting the SELinux will not install with the correct SID/file contexts, requireing 'make relabel' which may in turn wipe out any changes made by hand to the setup.

Run 'lunar update' allowing everyting to rebuild *except linux*.

Prior to installing SELinux I installed all of the following (lin(1))

Linux-PAM
krb5
slang (which will force a gcc-rebuild)
tcp_wrappers
sysklogd

Customizatons:

Set Lunar integrity checking to 'find' and 'ldd' checks only, removing md5 checks.

Removed the devfs/devfsd from the configuration. I have not had good luck getting the selinux policies to work on Lunar with devfsd enabled.

*Remember* to edit /etc/fstab and /etc/lilo.conf to reflect /dev/hda|/dev/sda naming in place of the devfs names.

Rather than running 'lrm devfsd' I chose to move the configuration files:

/etc/devfsd.conf
/etc/modules.devfs

to backup locations.

Reboot, run 'lin makedev' to fully populate the /dev directory structure.

Required to build the selinux-provided openssh:

in /usr/lib:
ln -s libbsd-compat.a libbsd.a

I would strongly suggest rebuilding glibc *after* building gcc. and before building/installing SELinux. I had a few things fail due to *not* doing this which were cleared up by using the current build.

Apply ncurses patches, required to build 'more' in util-linux:

utils_makefile_uselargefile.diff, utils_libncurses.diff see the SELinux mailing list archive.

Quoted 1 line

From this point run 'make quickinstall' in /usr/src/selinux.

Caveats:

set GCCWRAPPERS=off in /etc/lunar/local/config. The GCC wrapper files have the wrong SID and will generate an avc: denied error in enforcing mode.

Consider linking ln -s /lib/libncurses.so.5.3 /usr/lib/libncurses.so The non-standard location used by Lunar causes build failures for some software.

Lunar, particularly 'lunar update' or 'lunar rebuild' may force update of modules not in use (e.g. the lunar-customized linux kernel) and may force update of components, even components that are 'held'.

I'm making no attempt to build this as an integrated or supported part of the lunar distribution. SELinux-custom utilities are installed in /usr/local/selinux/.

I'm presently running all of the following services:

sshd            0:off   1:off   2:off   3:on    4:on    5:on    6:off
ntp             0:off   1:off   2:off   3:on    4:on    5:on    6:off
klogd           0:off   1:off   2:on    3:on    4:off   5:off   6:off
syslogd         0:off   1:off   2:on    3:on    4:off   5:off   6:off
httpd           0:off   1:off   2:off   3:on    4:on    5:on    6:off
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
avc             0:off   1:off   2:off   3:on    4:on    5:on    6:off  /* switch to enforcing mode */
afs             0:off   1:off   2:off   3:on    4:on    5:on    6:off  /* afsd client */

New policy changes installed, I needed fewer changes ot enable basic function than under Slackware, more than on redhat 7.1:

/etc/security/selinux/src/policy/domains/program/

==> ssh.te <==

#

# iterative edits
#

allow sshd_t device_t:chr_file { getattr ioctl read write };
allow sshd_t sysadm_tty_device_t:chr_file { getattr ioctl read relabelfrom relabelto setattr write }; allow sshd_t tmpfs_t:file { lock read write };
allow sshd_t tty_device_t:chr_file { getattr ioctl read relabelfrom setattr write }; allow sshd_t user_tty_device_t:chr_file { getattr ioctl read relabelfrom relabelto setattr write };

==> ntpd.te <==

#

# iterative edits
#

allow initrc_t tmpfs_t:file { write };
allow ntpd_t tmpfs_t:dir { search };

==> klogd.te <==

#

# iterative edits
#

allow klogd_t file_t:file { getattr read };
allow klogd_t sysadm_tty_device_t:chr_file { read write }; allow klogd_t tmpfs_t:file { getattr lock read unlink write };

==> syslogd.te <==

#

# iterative edits
#

allow syslogd_t sysadm_tty_device_t:chr_file { read write }; allow syslogd_t tmpfs_t:file { create getattr lock unlink write };

--
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 2 lines · forrest whitcher

Removed the devfs/devfsd from the configuration. I have not had good luck getting the selinux policies to work on Lunar with devfsd enabled.

How exactly did it fail? What kernel version did it fail on?

I wrote the devfsd policy and the SE Linux plugin, and I've contributed devfsd code to Richard Gooch. I would like to see this problem solved, so please give me all available information off-list.

Quoted 2 lines

in /usr/lib:
ln -s libbsd-compat.a libbsd.a

Why not just change the "-lbsd" in utils/Makefile to "-lbsd-compat"?

Quoted 3 lines

set GCCWRAPPERS=off in /etc/lunar/local/config. The GCC wrapper files have the wrong SID and will generate an avc: denied error in enforcing mode.

What are these wrapper files? What are the error messages that are reported? Fixing this in policy should be easy enough, and it might even be something we want in the default policy.

"diff -ru" is really good for this...

Quoted 7 lines

==> ssh.te <==

#

# iterative edits
#

allow sshd_t device_t:chr_file { getattr ioctl read write };

Your labeling of /dev is broken. There should never be a character device node in use that's labeled as device_t.

Quoted 2 lines

allow sshd_t sysadm_tty_device_t:chr_file { getattr ioctl read relabelfrom relabelto setattr write };

After some discussion after OLS last year we decided that denying sshd the ability to transition to sysadm_t (and all related operations) was a good idea. Therefore the above should not be needed.

Quoted 1 line

allow sshd_t tmpfs_t:file { lock read write };

What operation causes that?

Quoted 3 lines

allow sshd_t tty_device_t:chr_file { getattr ioctl read relabelfrom setattr write }; allow sshd_t user_tty_device_t:chr_file { getattr ioctl read relabelfrom relabelto setattr write };

I think that you have the wrong contexts assigned to pseudo-tty devices. Are you failing to use Unix98 PTY's?

Quoted 8 lines

==> klogd.te <==

#

# iterative edits
#

allow klogd_t file_t:file { getattr read };
allow klogd_t tmpfs_t:file { getattr lock read unlink write };

What exactly is klogd doing that needs such access? The file_t thing suggests mis-labelling.

Signature · 10 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page


--
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.