AlmaLinux 9
Sponsored Link

SELinux : ポリシータイプの設定2023/02/20

 
SELinux が [enforcing/permissive] で動作している場合、どのポリシータイプを適用するかを設定することができます。
設定したポリシータイプをベースに、必要に応じて、個別に要/不要なポリシーを追加/変更/削除して、カスタマイズ設定します。
ポリシータイプは [/etc/selinux/config] 設定ファイルで設定変更可能です。
デフォルトは [targeted] ポリシーです。
ただし、ポリシータイプを変更する場合、ポリシーファイルがインストールされている必要があります。
最小構成インストールの場合、デフォルトでは [targeted] ポリシーのみがインストールされています。
インストールされてないポリシータイプを指定すると、システムが起動しなくなるため、重々注意が必要です。
[1] ポリシータイプは [SELINUXTYPE=***] で設定します。
# デフォルトは [targeted] ポリシー

[root@dlp ~]#
cat /etc/selinux/config


# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# See also:
# https://docs.fedoraproject.org/en-US/quick-docs/getting-started-with-selinux/#getting-started-with-selinux-selinux-states-and-modes
#
# NOTE: In earlier Fedora kernel builds, SELINUX=disabled would also
# fully disable SELinux during boot. If you need a system with SELinux
# fully disabled instead of SELinux running with no policy loaded, you
# need to pass selinux=0 to the kernel command line. You can use grubby
# to persistently set the bootloader to boot with selinux=0:
#
#    grubby --update-kernel ALL --args selinux=0
#
# To revert back to SELinux enabled:
#
#    grubby --update-kernel ALL --remove-args selinux
#
SELINUX=enforcing
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

# 例として [mls] ポリシーに変更
# 事前にポリシーファイルをインストール

[root@dlp ~]#
dnf -y install selinux-policy-mls
# ポリシーファイルが [mls] ディレクトリ配下にインストールされる

[root@dlp ~]#
ll /etc/selinux

total 8
-rw-r--r--. 1 root root 1187 Nov 25 18:03 config
drwxr-xr-x. 6 root root  150 Mar 10 20:06 mls
-rw-r--r--. 1 root root 2668 Feb 15 05:45 semanage.conf
drwxr-xr-x. 5 root root  133 Mar 10 19:04 targeted

[root@dlp ~]#
vi /etc/selinux/config
# [SELINUXTYPE] 変更
# ポリシー変更の際は動作モードを [permissive] に変更
# * [enforcing] のまま再起動するとリラベリングできずシステムが起動しなくなるため注意

.....
.....
SELINUX=permissive
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are proo
tected.
#     mls - Multi Level Security protection.
SELINUXTYPE=mls

# 変更後はリラべリングをセットしてシステム再起動

[root@dlp ~]#
fixfiles -F onboot

System will relabel on next boot
[root@dlp ~]#
[root@dlp ~]#
sestatus

SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             mls
Current mode:                   permissive
Mode from config file:          permissive
Policy MLS status:              enabled
Policy deny_unknown status:     denied
Memory protection checking:     actual (secure)
Max kernel policy version:      33
[2]
パッケージとして提供されているポリシーは以下の 2 種類です。
ポリシー 説明
Targeted システム上で攻撃対象となる可能性の高いプロセスに対してアクセス制御を適用するポリシー (デフォルト)。
MLS Multilevel Security ポリシー。Bell–LaPadula (BLP) モデルを実装し、より細かなアクセス制御が適用可能。

関連コンテンツ