From c52eb995e0d9c3bbb6d0293f5dacaeb511f37f96 Mon Sep 17 00:00:00 2001 From: Boris Ranto Date: Fri, 15 May 2015 15:18:05 +0200 Subject: [PATCH] Add initial SELinux support This patch modifies the build system and spec file to provide a support for SELinux enforcing in an opt-in matter via ceph-selinux package. Signed-off-by: Boris Ranto --- Makefile.am | 2 +- ceph.spec.in | 71 ++++++++- configure.ac | 23 ++- man/Makefile-server.am | 3 +- man/ceph_selinux.8 | 324 +++++++++++++++++++++++++++++++++++++++ selinux/Makefile.am | 22 +++ selinux/ceph.fc | 11 ++ selinux/ceph.if | 265 ++++++++++++++++++++++++++++++++ selinux/ceph.te | 71 +++++++++ selinux/ceph_selinux.8 | 340 +++++++++++++++++++++++++++++++++++++++++ 10 files changed, 1121 insertions(+), 11 deletions(-) create mode 100644 man/ceph_selinux.8 create mode 100644 selinux/Makefile.am create mode 100644 selinux/ceph.fc create mode 100644 selinux/ceph.if create mode 100644 selinux/ceph.te create mode 100644 selinux/ceph_selinux.8 diff --git a/Makefile.am b/Makefile.am index 69dbbb6a669e9..d6f7bbdf19edf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = gnu ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = autogen.sh ceph.spec.in ceph.spec install-deps.sh # the "." here makes sure check-local builds gtest and gmock before they are used -SUBDIRS = . src man doc systemd +SUBDIRS = . src man doc systemd selinux EXTRA_DIST += \ src/test/run-cli-tests \ diff --git a/ceph.spec.in b/ceph.spec.in index bc72bc12b50f2..bc7f014390589 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -1,14 +1,31 @@ +# vim: set noexpandtab ts=8 sw=8 : %bcond_with ocf %bcond_without cephfs_java %bcond_with tests %bcond_without tcmalloc %bcond_without libs_compat +%bcond_without selinux + %if (0%{?el5} || (0%{?rhel_version} >= 500 && 0%{?rhel_version} <= 600)) %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} %endif +%if %{with selinux} +# get selinux policy version +%{!?_selinux_policy_version: %global _selinux_policy_version %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp 2>/dev/null || echo 0.0.0)} + +%define relabel_files() \ +restorecon -R /usr/bin/ceph-mon > /dev/null 2>&1; \ +restorecon -R /usr/bin/ceph-osd > /dev/null 2>&1; \ +restorecon -R /usr/bin/ceph-mds > /dev/null 2>&1; \ +restorecon -R /etc/rc\.d/init\.d/ceph > /dev/null 2>&1; \ +restorecon -R /var/run/ceph > /dev/null 2>&1; \ +restorecon -R /var/lib/ceph > /dev/null 2>&1; \ +restorecon -R /var/log/ceph > /dev/null 2>&1; +%endif + %{!?_udevrulesdir: %global _udevrulesdir /lib/udev/rules.d} # Use systemd files on RHEL 7 and above and in SUSE/openSUSE. @@ -61,6 +78,11 @@ Requires: systemd %if 0%{with cephfs_java} BuildRequires: sharutils %endif +%if 0%{with selinux} +BuildRequires: checkpolicy +BuildRequires: selinux-policy-devel +BuildRequires: /usr/share/selinux/devel/policyhelp +%endif BuildRequires: gcc-c++ BuildRequires: boost-devel BuildRequires: cryptsetup @@ -394,6 +416,22 @@ This package contains the Java libraries for the Ceph File System. %endif +%if 0%{with selinux} + +%package selinux +Summary: SELinux support for Ceph MON, OSD and MDS +Group: System Environment/Base +Requires: %{name} +Requires: policycoreutils, libselinux-utils +Requires(post): selinux-policy >= %{_selinux_policy_version}, policycoreutils +Requires(postun): policycoreutils +%description selinux +This package contains SELinux support for Ceph MON, OSD and MDS. The package +also performs file-system relabelling which can take a long time on heavily +populated file-systems. + +%endif + %if 0%{with libs_compat} %package libs-compat @@ -493,6 +531,9 @@ export RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS | sed -e 's/i386/i486/'` --with-debug \ %if 0%{with cephfs_java} --enable-cephfs-java \ +%endif +%if 0%{with selinux} + --with-selinux \ %endif --with-librocksdb-static=check \ %if 0%{?rhel} || 0%{?fedora} @@ -664,7 +705,6 @@ mkdir -p %{_localstatedir}/run/ceph/ %insserv_cleanup %endif - ################################################################################# # files ################################################################################# @@ -1083,6 +1123,35 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1 %{_javadir}/libcephfs-test.jar %endif +################################################################################# +%if 0%{with selinux} +%files selinux +%defattr(-,root,root,-) +%attr(0600,root,root) %{_datadir}/selinux/packages/ceph.pp +%{_datadir}/selinux/devel/include/contrib/ceph.if +%{_mandir}/man8/ceph_selinux.8.* + +%post selinux +semodule -n -i %{_datadir}/selinux/packages/ceph.pp +if /usr/sbin/selinuxenabled ; then + /usr/sbin/load_policy + %relabel_files +fi +exit 0 + +%postun selinux +if [ $1 -eq 0 ]; then + semodule -n -r ceph + if /usr/sbin/selinuxenabled ; then + /usr/sbin/load_policy + %relabel_files + + fi; +fi; +exit 0 + +%endif + ################################################################################# %if 0%{with libs_compat} %files libs-compat diff --git a/configure.ac b/configure.ac index ebc69ab87c84e..930f76b3ce8eb 100644 --- a/configure.ac +++ b/configure.ac @@ -97,9 +97,7 @@ AC_PROG_LIBTOOL AC_SUBST(AM_CXXFLAGS) AM_CXXFLAGS="${AM_CXXFLAGS}" - -###### PATCH STARTS HERE ###### -# Find out what to build (default is all of these) +# Find out what to build (default is most of these) # rados? AC_ARG_WITH([rados], @@ -130,12 +128,22 @@ AM_CONDITIONAL(WITH_CEPHFS, test "$with_cephfs" = "yes") # radosgw? # radosgw requires rados AC_ARG_WITH([radosgw], - [AS_HELP_STRING([--with-radosgw], [build RADOS gateway])], - [], - [with_radosgw=check]) + [AS_HELP_STRING([--with-radosgw], [build RADOS gateway])], + [], + [with_radosgw=check]) # AM_CONDITIONAL is defined later -- we need to check whether we can enable radosgw if no option is present #AS_IF([test "$with_radosgw" = "yes"], [AC_DEFINE([WITH_RADOS, WITH_RADOSGW])]) +AC_ARG_WITH([selinux], + [AS_HELP_STRING([--with-selinux], [build SELinux policy])], + [], + [with_selinux=no]) +AM_CONDITIONAL(WITH_SELINUX, test "$with_selinux" = "yes") +if test "x$with_selinux" = x"yes"; then + AC_CHECK_FILE([/usr/share/selinux/devel/policyhelp], [true], [AC_MSG_FAILURE([No SELinux found])]) + AC_CHECK_FILE([/usr/share/selinux/devel/include/Makefile], [true], [AC_MSG_FAILURE([No SELinux Makefile found])]) +fi + # radosstriper? AC_ARG_WITH([radosstriper], [AS_HELP_STRING([--with-radosstriper], [build radosstriper files])], @@ -191,8 +199,6 @@ AS_IF([test "$enable_server" = "yes" -a \( "$with_osd" = "yes" -o "$with_mon" = # cond-check leveldb, necessary if server, osd or mon enabled AS_IF([test "$enable_server" = "yes" -a \( "$with_osd" = "yes" -o "$with_mon" = "yes" \)], [AC_CHECK_LIB([leveldb], [leveldb_open], [true], [AC_MSG_FAILURE([libleveldb not found])], [-lsnappy -lpthread])]) -###### PATCH ENDS HERE ###### - # Check for yasm AC_CHECK_PROG(YASM_CHECK, yasm, yes) @@ -1330,6 +1336,7 @@ AC_CONFIG_FILES([Makefile systemd/Makefile man/Makefile doc/Makefile + selinux/Makefile systemd/ceph-osd@.service systemd/ceph-rgw.tmpfiles.d ceph.spec]) diff --git a/man/Makefile-server.am b/man/Makefile-server.am index 3774d6e45aec6..6739c44e3221b 100644 --- a/man/Makefile-server.am +++ b/man/Makefile-server.am @@ -5,7 +5,8 @@ dist_man_MANS += \ mount.ceph.8 \ ceph-create-keys.8 \ ceph-rest-api.8 \ - ceph-debugpack.8 + ceph-debugpack.8 \ + ceph_selinux.8 if WITH_MON dist_man_MANS += \ diff --git a/man/ceph_selinux.8 b/man/ceph_selinux.8 new file mode 100644 index 0000000000000..de74807c8ed87 --- /dev/null +++ b/man/ceph_selinux.8 @@ -0,0 +1,324 @@ +.TH "ceph_selinux" "8" "15-06-17" "ceph" "SELinux Policy ceph" +.SH "NAME" +ceph_selinux \- Security Enhanced Linux Policy for the ceph processes +.SH "DESCRIPTION" + +Security-Enhanced Linux secures the ceph processes via flexible mandatory access control. + +The ceph processes execute with the ceph_t SELinux type. You can check if you have these processes running by executing the \fBps\fP command with the \fB\-Z\fP qualifier. + +For example: + +.B ps -eZ | grep ceph_t + + +.SH "ENTRYPOINTS" + +The ceph_t SELinux type can be entered via the \fBceph_exec_t\fP file type. + +The default entrypoint paths for the ceph_t domain are the following: + +/usr/bin/ceph-mon, /usr/bin/ceph-mds, /usr/bin/ceph-osd +.SH PROCESS TYPES +SELinux defines process types (domains) for each process running on the system +.PP +You can see the context of a process using the \fB\-Z\fP option to \fBps\bP +.PP +Policy governs the access confined processes have to files. +SELinux ceph policy is very flexible allowing users to setup their ceph processes in as secure a method as possible. +.PP +The following process types are defined for ceph: + +.EX +.B ceph_t +.EE +.PP +Note: +.B semanage permissive -a ceph_t +can be used to make the process type ceph_t permissive. SELinux does not deny access to permissive process types, but the AVC (SELinux denials) messages are still generated. + +.SH BOOLEANS +SELinux policy is customizable based on least access required. ceph policy is extremely flexible and has several booleans that allow you to manipulate the policy and run ceph with the tightest access possible. + + +.PP +If you want to allow users to resolve user passwd entries directly from ldap rather then using a sssd server, you must turn on the authlogin_nsswitch_use_ldap boolean. Disabled by default. + +.EX +.B setsebool -P authlogin_nsswitch_use_ldap 1 + +.EE + +.PP +If you want to allow all daemons to write corefiles to /, you must turn on the daemons_dump_core boolean. Disabled by default. + +.EX +.B setsebool -P daemons_dump_core 1 + +.EE + +.PP +If you want to enable cluster mode for daemons, you must turn on the daemons_enable_cluster_mode boolean. Disabled by default. + +.EX +.B setsebool -P daemons_enable_cluster_mode 1 + +.EE + +.PP +If you want to allow all daemons to use tcp wrappers, you must turn on the daemons_use_tcp_wrapper boolean. Disabled by default. + +.EX +.B setsebool -P daemons_use_tcp_wrapper 1 + +.EE + +.PP +If you want to allow all daemons the ability to read/write terminals, you must turn on the daemons_use_tty boolean. Disabled by default. + +.EX +.B setsebool -P daemons_use_tty 1 + +.EE + +.PP +If you want to deny any process from ptracing or debugging any other processes, you must turn on the deny_ptrace boolean. Disabled by default. + +.EX +.B setsebool -P deny_ptrace 1 + +.EE + +.PP +If you want to allow all domains to use other domains file descriptors, you must turn on the domain_fd_use boolean. Enabled by default. + +.EX +.B setsebool -P domain_fd_use 1 + +.EE + +.PP +If you want to allow all domains to have the kernel load modules, you must turn on the domain_kernel_load_modules boolean. Disabled by default. + +.EX +.B setsebool -P domain_kernel_load_modules 1 + +.EE + +.PP +If you want to allow all domains to execute in fips_mode, you must turn on the fips_mode boolean. Enabled by default. + +.EX +.B setsebool -P fips_mode 1 + +.EE + +.PP +If you want to enable reading of urandom for all domains, you must turn on the global_ssp boolean. Disabled by default. + +.EX +.B setsebool -P global_ssp 1 + +.EE + +.PP +If you want to allow confined applications to run with kerberos, you must turn on the kerberos_enabled boolean. Enabled by default. + +.EX +.B setsebool -P kerberos_enabled 1 + +.EE + +.PP +If you want to allow system to run with NIS, you must turn on the nis_enabled boolean. Disabled by default. + +.EX +.B setsebool -P nis_enabled 1 + +.EE + +.PP +If you want to allow confined applications to use nscd shared memory, you must turn on the nscd_use_shm boolean. Enabled by default. + +.EX +.B setsebool -P nscd_use_shm 1 + +.EE + +.SH "MANAGED FILES" + +The SELinux process type ceph_t can manage files labeled with the following file types. The paths listed are the default paths for these file types. Note the processes UID still need to have DAC permissions. + +.br +.B ceph_log_t + + /var/log/ceph(/.*)? +.br + +.br +.B ceph_var_lib_t + + /var/lib/ceph(/.*)? +.br + +.br +.B ceph_var_run_t + + /var/run/ceph(/.*)? +.br + +.br +.B cluster_conf_t + + /etc/cluster(/.*)? +.br + +.br +.B cluster_var_lib_t + + /var/lib/pcsd(/.*)? +.br + /var/lib/cluster(/.*)? +.br + /var/lib/openais(/.*)? +.br + /var/lib/pengine(/.*)? +.br + /var/lib/corosync(/.*)? +.br + /usr/lib/heartbeat(/.*)? +.br + /var/lib/heartbeat(/.*)? +.br + /var/lib/pacemaker(/.*)? +.br + +.br +.B cluster_var_run_t + + /var/run/crm(/.*)? +.br + /var/run/cman_.* +.br + /var/run/rsctmp(/.*)? +.br + /var/run/aisexec.* +.br + /var/run/heartbeat(/.*)? +.br + /var/run/cpglockd\.pid +.br + /var/run/corosync\.pid +.br + /var/run/rgmanager\.pid +.br + /var/run/cluster/rgmanager\.sk +.br + +.br +.B root_t + + / +.br + /initrd +.br + +.SH FILE CONTEXTS +SELinux requires files to have an extended attribute to define the file type. +.PP +You can see the context of a file using the \fB\-Z\fP option to \fBls\bP +.PP +Policy governs the access confined processes have to these files. +SELinux ceph policy is very flexible allowing users to setup their ceph processes in as secure a method as possible. +.PP + +.PP +.B STANDARD FILE CONTEXT + +SELinux defines the file context types for the ceph, if you wanted to +store files with these types in a diffent paths, you need to execute the semanage command to sepecify alternate labeling and then use restorecon to put the labels on disk. + +.B semanage fcontext -a -t ceph_var_run_t '/srv/myceph_content(/.*)?' +.br +.B restorecon -R -v /srv/myceph_content + +Note: SELinux often uses regular expressions to specify labels that match multiple files. + +.I The following file types are defined for ceph: + + +.EX +.PP +.B ceph_exec_t +.EE + +- Set files with the ceph_exec_t type, if you want to transition an executable to the ceph_t domain. + +.br +.TP 5 +Paths: +/usr/bin/ceph-mon, /usr/bin/ceph-mds, /usr/bin/ceph-osd + +.EX +.PP +.B ceph_initrc_exec_t +.EE + +- Set files with the ceph_initrc_exec_t type, if you want to transition an executable to the ceph_initrc_t domain. + + +.EX +.PP +.B ceph_log_t +.EE + +- Set files with the ceph_log_t type, if you want to treat the data as ceph log data, usually stored under the /var/log directory. + + +.EX +.PP +.B ceph_var_lib_t +.EE + +- Set files with the ceph_var_lib_t type, if you want to store the ceph files under the /var/lib directory. + + +.EX +.PP +.B ceph_var_run_t +.EE + +- Set files with the ceph_var_run_t type, if you want to store the ceph files under the /run or /var/run directory. + + +.PP +Note: File context can be temporarily modified with the chcon command. If you want to permanently change the file context you need to use the +.B semanage fcontext +command. This will modify the SELinux labeling database. You will need to use +.B restorecon +to apply the labels. + +.SH "COMMANDS" +.B semanage fcontext +can also be used to manipulate default file context mappings. +.PP +.B semanage permissive +can also be used to manipulate whether or not a process type is permissive. +.PP +.B semanage module +can also be used to enable/disable/install/remove policy modules. + +.B semanage boolean +can also be used to manipulate the booleans + +.PP +.B system-config-selinux +is a GUI tool available to customize SELinux policy settings. + +.SH AUTHOR +This manual page was auto-generated using +.B "sepolicy manpage". + +.SH "SEE ALSO" +selinux(8), ceph(8), semanage(8), restorecon(8), chcon(1), sepolicy(8) +, setsebool(8) \ No newline at end of file diff --git a/selinux/Makefile.am b/selinux/Makefile.am new file mode 100644 index 0000000000000..dbfb63c81de08 --- /dev/null +++ b/selinux/Makefile.am @@ -0,0 +1,22 @@ +EXTRA_DIST = \ + ceph.te \ + ceph.fc \ + ceph.if + +SELINUXROOT = $(DESTDIR)$(datadir)/selinux + +ceph.pp: ceph.te ceph.fc ceph.if + $(MAKE) -f $(datadir)/selinux/devel/Makefile ceph.pp + +if ENABLE_SERVER +if WITH_SELINUX +all-local: ceph.pp + +install-exec-local: + $(INSTALL) -d $(SELINUXROOT)/packages + $(INSTALL) -m 644 ceph.pp $(SELINUXROOT)/packages/ + $(INSTALL) -d $(SELINUXROOT)/devel/include/contrib + $(INSTALL) -m 644 ceph.if $(SELINUXROOT)/devel/include/contrib/ + +endif +endif diff --git a/selinux/ceph.fc b/selinux/ceph.fc new file mode 100644 index 0000000000000..2eeee223056ba --- /dev/null +++ b/selinux/ceph.fc @@ -0,0 +1,11 @@ +/etc/rc\.d/init\.d/ceph -- gen_context(system_u:object_r:ceph_initrc_exec_t,s0) + +/usr/bin/ceph-mon -- gen_context(system_u:object_r:ceph_exec_t,s0) +/usr/bin/ceph-mds -- gen_context(system_u:object_r:ceph_exec_t,s0) +/usr/bin/ceph-osd -- gen_context(system_u:object_r:ceph_exec_t,s0) + +/var/lib/ceph(/.*)? gen_context(system_u:object_r:ceph_var_lib_t,s0) + +/var/log/ceph(/.*)? gen_context(system_u:object_r:ceph_log_t,s0) + +/var/run/ceph(/.*)? gen_context(system_u:object_r:ceph_var_run_t,s0) diff --git a/selinux/ceph.if b/selinux/ceph.if new file mode 100644 index 0000000000000..ed747a82ae8b3 --- /dev/null +++ b/selinux/ceph.if @@ -0,0 +1,265 @@ + +## policy for ceph + +######################################## +## +## Execute ceph_exec_t in the ceph domain. +## +## +## +## Domain allowed to transition. +## +## +# +interface(`ceph_domtrans',` + gen_require(` + type ceph_t, ceph_exec_t; + ') + + corecmd_search_bin($1) + domtrans_pattern($1, ceph_exec_t, ceph_t) +') + +###################################### +## +## Execute ceph in the caller domain. +## +## +## +## Domain allowed access. +## +## +# +interface(`ceph_exec',` + gen_require(` + type ceph_exec_t; + ') + + corecmd_search_bin($1) + can_exec($1, ceph_exec_t) +') + +######################################## +## +## Execute ceph server in the ceph domain. +## +## +## +## Domain allowed access. +## +## +# +interface(`ceph_initrc_domtrans',` + gen_require(` + type ceph_initrc_exec_t; + ') + + init_labeled_script_domtrans($1, ceph_initrc_exec_t) +') +######################################## +## +## Read ceph's log files. +## +## +## +## Domain allowed access. +## +## +## +# +interface(`ceph_read_log',` + gen_require(` + type ceph_log_t; + ') + + logging_search_logs($1) + read_files_pattern($1, ceph_log_t, ceph_log_t) +') + +######################################## +## +## Append to ceph log files. +## +## +## +## Domain allowed access. +## +## +# +interface(`ceph_append_log',` + gen_require(` + type ceph_log_t; + ') + + logging_search_logs($1) + append_files_pattern($1, ceph_log_t, ceph_log_t) +') + +######################################## +## +## Manage ceph log files +## +## +## +## Domain allowed access. +## +## +# +interface(`ceph_manage_log',` + gen_require(` + type ceph_log_t; + ') + + logging_search_logs($1) + manage_dirs_pattern($1, ceph_log_t, ceph_log_t) + manage_files_pattern($1, ceph_log_t, ceph_log_t) + manage_lnk_files_pattern($1, ceph_log_t, ceph_log_t) +') + +######################################## +## +## Search ceph lib directories. +## +## +## +## Domain allowed access. +## +## +# +interface(`ceph_search_lib',` + gen_require(` + type ceph_var_lib_t; + ') + + allow $1 ceph_var_lib_t:dir search_dir_perms; + files_search_var_lib($1) +') + +######################################## +## +## Read ceph lib files. +## +## +## +## Domain allowed access. +## +## +# +interface(`ceph_read_lib_files',` + gen_require(` + type ceph_var_lib_t; + ') + + files_search_var_lib($1) + read_files_pattern($1, ceph_var_lib_t, ceph_var_lib_t) +') + +######################################## +## +## Manage ceph lib files. +## +## +## +## Domain allowed access. +## +## +# +interface(`ceph_manage_lib_files',` + gen_require(` + type ceph_var_lib_t; + ') + + files_search_var_lib($1) + manage_files_pattern($1, ceph_var_lib_t, ceph_var_lib_t) +') + +######################################## +## +## Manage ceph lib directories. +## +## +## +## Domain allowed access. +## +## +# +interface(`ceph_manage_lib_dirs',` + gen_require(` + type ceph_var_lib_t; + ') + + files_search_var_lib($1) + manage_dirs_pattern($1, ceph_var_lib_t, ceph_var_lib_t) +') + +######################################## +## +## Read ceph PID files. +## +## +## +## Domain allowed access. +## +## +# +interface(`ceph_read_pid_files',` + gen_require(` + type ceph_var_run_t; + ') + + files_search_pids($1) + read_files_pattern($1, ceph_var_run_t, ceph_var_run_t) +') + + +######################################## +## +## All of the rules required to administrate +## an ceph environment +## +## +## +## Domain allowed access. +## +## +## +## +## Role allowed access. +## +## +## +# +interface(`ceph_admin',` + gen_require(` + type ceph_t; + type ceph_initrc_exec_t; + type ceph_log_t; + type ceph_var_lib_t; + type ceph_var_run_t; + ') + + allow $1 ceph_t:process { signal_perms }; + ps_process_pattern($1, ceph_t) + + tunable_policy(`deny_ptrace',`',` + allow $1 ceph_t:process ptrace; + ') + + ceph_initrc_domtrans($1) + domain_system_change_exemption($1) + role_transition $2 ceph_initrc_exec_t system_r; + allow $2 system_r; + + logging_search_logs($1) + admin_pattern($1, ceph_log_t) + + files_search_var_lib($1) + admin_pattern($1, ceph_var_lib_t) + + files_search_pids($1) + admin_pattern($1, ceph_var_run_t) + optional_policy(` + systemd_passwd_agent_exec($1) + systemd_read_fifo_file_passwd_run($1) + ') +') diff --git a/selinux/ceph.te b/selinux/ceph.te new file mode 100644 index 0000000000000..3e2caa669177a --- /dev/null +++ b/selinux/ceph.te @@ -0,0 +1,71 @@ +policy_module(ceph, 1.0.0) + +######################################## +# +# Declarations +# + +type ceph_t; +type ceph_exec_t; +init_daemon_domain(ceph_t, ceph_exec_t) + +permissive ceph_t; + +type ceph_initrc_exec_t; +init_script_file(ceph_initrc_exec_t) + +type ceph_log_t; +logging_log_file(ceph_log_t) + +type ceph_var_lib_t; +files_type(ceph_var_lib_t) + +type ceph_var_run_t; +files_pid_file(ceph_var_run_t) + +######################################## +# +# ceph local policy +# + +allow ceph_t self:process { signal_perms }; +allow ceph_t self:fifo_file rw_fifo_file_perms; +allow ceph_t self:unix_stream_socket create_stream_socket_perms; + +manage_dirs_pattern(ceph_t, ceph_log_t, ceph_log_t) +manage_files_pattern(ceph_t, ceph_log_t, ceph_log_t) +manage_lnk_files_pattern(ceph_t, ceph_log_t, ceph_log_t) + +manage_dirs_pattern(ceph_t, ceph_var_lib_t, ceph_var_lib_t) +manage_files_pattern(ceph_t, ceph_var_lib_t, ceph_var_lib_t) +manage_lnk_files_pattern(ceph_t, ceph_var_lib_t, ceph_var_lib_t) + +manage_dirs_pattern(ceph_t, ceph_var_run_t, ceph_var_run_t) +manage_files_pattern(ceph_t, ceph_var_run_t, ceph_var_run_t) +manage_lnk_files_pattern(ceph_t, ceph_var_run_t, ceph_var_run_t) + +kernel_read_system_state(ceph_t) + +corenet_all_recvfrom_unlabeled(ceph_t) +corenet_all_recvfrom_netlabel(ceph_t) +corenet_udp_sendrecv_generic_if(ceph_t) +corenet_udp_sendrecv_generic_node(ceph_t) +corenet_udp_bind_generic_node(ceph_t) +corenet_tcp_bind_generic_node(ceph_t) + +corenet_sendrecv_cyphesis_server_packets(ceph_t) +corenet_tcp_bind_cyphesis_port(ceph_t) +corenet_tcp_sendrecv_cyphesis_port(ceph_t) + +corecmd_exec_bin(ceph_t) +corecmd_exec_shell(ceph_t) + +dev_read_urand(ceph_t) + +fs_getattr_all_fs(ceph_t) + +auth_use_nsswitch(ceph_t) + +logging_send_syslog_msg(ceph_t) + +sysnet_dns_name_resolve(ceph_t) diff --git a/selinux/ceph_selinux.8 b/selinux/ceph_selinux.8 new file mode 100644 index 0000000000000..5f6cc8e2b10ef --- /dev/null +++ b/selinux/ceph_selinux.8 @@ -0,0 +1,340 @@ +.TH "ceph_selinux" "8" "15-05-13" "ceph" "SELinux Policy ceph" +.SH "NAME" +ceph_selinux \- Security Enhanced Linux Policy for the ceph processes +.SH "DESCRIPTION" + +Security-Enhanced Linux secures the ceph processes via flexible mandatory access control. + +The ceph processes execute with the ceph_t SELinux type. You can check if you have these processes running by executing the \fBps\fP command with the \fB\-Z\fP qualifier. + +For example: + +.B ps -eZ | grep ceph_t + + +.SH "ENTRYPOINTS" + +The ceph_t SELinux type can be entered via the \fBceph_exec_t\fP file type. + +The default entrypoint paths for the ceph_t domain are the following: + +/usr/bin/ceph-mon, /usr/bin/ceph-mds, /usr/bin/ceph-osd +.SH PROCESS TYPES +SELinux defines process types (domains) for each process running on the system +.PP +You can see the context of a process using the \fB\-Z\fP option to \fBps\bP +.PP +Policy governs the access confined processes have to files. +SELinux ceph policy is very flexible allowing users to setup their ceph processes in as secure a method as possible. +.PP +The following process types are defined for ceph: + +.EX +.B ceph_t +.EE +.PP +Note: +.B semanage permissive -a ceph_t +can be used to make the process type ceph_t permissive. SELinux does not deny access to permissive process types, but the AVC (SELinux denials) messages are still generated. + +.SH BOOLEANS +SELinux policy is customizable based on least access required. ceph policy is extremely flexible and has several booleans that allow you to manipulate the policy and run ceph with the tightest access possible. + + +.PP +If you want to allow users to resolve user passwd entries directly from ldap rather then using a sssd server, you must turn on the authlogin_nsswitch_use_ldap boolean. Disabled by default. + +.EX +.B setsebool -P authlogin_nsswitch_use_ldap 1 + +.EE + +.PP +If you want to allow all daemons to write corefiles to /, you must turn on the daemons_dump_core boolean. Disabled by default. + +.EX +.B setsebool -P daemons_dump_core 1 + +.EE + +.PP +If you want to enable cluster mode for daemons, you must turn on the daemons_enable_cluster_mode boolean. Disabled by default. + +.EX +.B setsebool -P daemons_enable_cluster_mode 1 + +.EE + +.PP +If you want to allow all daemons to use tcp wrappers, you must turn on the daemons_use_tcp_wrapper boolean. Disabled by default. + +.EX +.B setsebool -P daemons_use_tcp_wrapper 1 + +.EE + +.PP +If you want to allow all daemons the ability to read/write terminals, you must turn on the daemons_use_tty boolean. Disabled by default. + +.EX +.B setsebool -P daemons_use_tty 1 + +.EE + +.PP +If you want to deny any process from ptracing or debugging any other processes, you must turn on the deny_ptrace boolean. Disabled by default. + +.EX +.B setsebool -P deny_ptrace 1 + +.EE + +.PP +If you want to allow all domains to use other domains file descriptors, you must turn on the domain_fd_use boolean. Enabled by default. + +.EX +.B setsebool -P domain_fd_use 1 + +.EE + +.PP +If you want to allow all domains to have the kernel load modules, you must turn on the domain_kernel_load_modules boolean. Disabled by default. + +.EX +.B setsebool -P domain_kernel_load_modules 1 + +.EE + +.PP +If you want to allow all domains to execute in fips_mode, you must turn on the fips_mode boolean. Enabled by default. + +.EX +.B setsebool -P fips_mode 1 + +.EE + +.PP +If you want to enable reading of urandom for all domains, you must turn on the global_ssp boolean. Disabled by default. + +.EX +.B setsebool -P global_ssp 1 + +.EE + +.PP +If you want to allow confined applications to run with kerberos, you must turn on the kerberos_enabled boolean. Enabled by default. + +.EX +.B setsebool -P kerberos_enabled 1 + +.EE + +.PP +If you want to allow system to run with NIS, you must turn on the nis_enabled boolean. Disabled by default. + +.EX +.B setsebool -P nis_enabled 1 + +.EE + +.PP +If you want to allow confined applications to use nscd shared memory, you must turn on the nscd_use_shm boolean. Enabled by default. + +.EX +.B setsebool -P nscd_use_shm 1 + +.EE + +.SH NSSWITCH DOMAIN + +.PP +If you want to allow users to resolve user passwd entries directly from ldap rather then using a sssd server for the ceph_t, you must turn on the authlogin_nsswitch_use_ldap boolean. + +.EX +.B setsebool -P authlogin_nsswitch_use_ldap 1 +.EE + +.PP +If you want to allow confined applications to run with kerberos for the ceph_t, you must turn on the kerberos_enabled boolean. + +.EX +.B setsebool -P kerberos_enabled 1 +.EE + +.SH "MANAGED FILES" + +The SELinux process type ceph_t can manage files labeled with the following file types. The paths listed are the default paths for these file types. Note the processes UID still need to have DAC permissions. + +.br +.B ceph_log_t + + /var/log/ceph(/.*)? +.br + +.br +.B ceph_var_lib_t + + /var/lib/ceph(/.*)? +.br + +.br +.B ceph_var_run_t + + /var/run/ceph(/.*)? +.br + +.br +.B cluster_conf_t + + /etc/cluster(/.*)? +.br + +.br +.B cluster_var_lib_t + + /var/lib/pcsd(/.*)? +.br + /var/lib/cluster(/.*)? +.br + /var/lib/openais(/.*)? +.br + /var/lib/pengine(/.*)? +.br + /var/lib/corosync(/.*)? +.br + /usr/lib/heartbeat(/.*)? +.br + /var/lib/heartbeat(/.*)? +.br + /var/lib/pacemaker(/.*)? +.br + +.br +.B cluster_var_run_t + + /var/run/crm(/.*)? +.br + /var/run/cman_.* +.br + /var/run/rsctmp(/.*)? +.br + /var/run/aisexec.* +.br + /var/run/heartbeat(/.*)? +.br + /var/run/cpglockd\.pid +.br + /var/run/corosync\.pid +.br + /var/run/rgmanager\.pid +.br + /var/run/cluster/rgmanager\.sk +.br + +.br +.B root_t + + / +.br + /initrd +.br + +.SH FILE CONTEXTS +SELinux requires files to have an extended attribute to define the file type. +.PP +You can see the context of a file using the \fB\-Z\fP option to \fBls\bP +.PP +Policy governs the access confined processes have to these files. +SELinux ceph policy is very flexible allowing users to setup their ceph processes in as secure a method as possible. +.PP + +.PP +.B STANDARD FILE CONTEXT + +SELinux defines the file context types for the ceph, if you wanted to +store files with these types in a diffent paths, you need to execute the semanage command to sepecify alternate labeling and then use restorecon to put the labels on disk. + +.B semanage fcontext -a -t ceph_exec_t '/srv/ceph/content(/.*)?' +.br +.B restorecon -R -v /srv/myceph_content + +Note: SELinux often uses regular expressions to specify labels that match multiple files. + +.I The following file types are defined for ceph: + + +.EX +.PP +.B ceph_exec_t +.EE + +- Set files with the ceph_exec_t type, if you want to transition an executable to the ceph_t domain. + +.br +.TP 5 +Paths: +/usr/bin/ceph-mon, /usr/bin/ceph-mds, /usr/bin/ceph-osd + +.EX +.PP +.B ceph_initrc_exec_t +.EE + +- Set files with the ceph_initrc_exec_t type, if you want to transition an executable to the ceph_initrc_t domain. + + +.EX +.PP +.B ceph_log_t +.EE + +- Set files with the ceph_log_t type, if you want to treat the data as ceph log data, usually stored under the /var/log directory. + + +.EX +.PP +.B ceph_var_lib_t +.EE + +- Set files with the ceph_var_lib_t type, if you want to store the ceph files under the /var/lib directory. + + +.EX +.PP +.B ceph_var_run_t +.EE + +- Set files with the ceph_var_run_t type, if you want to store the ceph files under the /run or /var/run directory. + + +.PP +Note: File context can be temporarily modified with the chcon command. If you want to permanently change the file context you need to use the +.B semanage fcontext +command. This will modify the SELinux labeling database. You will need to use +.B restorecon +to apply the labels. + +.SH "COMMANDS" +.B semanage fcontext +can also be used to manipulate default file context mappings. +.PP +.B semanage permissive +can also be used to manipulate whether or not a process type is permissive. +.PP +.B semanage module +can also be used to enable/disable/install/remove policy modules. + +.B semanage boolean +can also be used to manipulate the booleans + +.PP +.B system-config-selinux +is a GUI tool available to customize SELinux policy settings. + +.SH AUTHOR +This manual page was auto-generated using +.B "sepolicy manpage". + +.SH "SEE ALSO" +selinux(8), ceph(8), semanage(8), restorecon(8), chcon(1), sepolicy(8) +, setsebool(8) \ No newline at end of file -- 2.39.5