1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

使用しない事にしているSELinuxについて

Last updated at Posted at 2020-06-25

SELinuxとはアクセス制御である

MACとDAC

  • MAC(Mandatory Access Contorol:強制アクセス制御)
  • DAC(Discretionary Access Contorol:任意アクセス制御)

従来のLinuxではファイルの所有者やrootユーザーがパーミッションを変更(DAC:任意アクセス制御)

MACではサーバー管理者によって定義されたセキュリティポリシーに従ってアクセス権がユーザーやプロセスに与えられる
(ファイルの所有者やrootユーザーであっても定義されている事以外は行えない)

MAC(強制アクセス制御)の代表的なもの

  • SELinux
  • SMACK(Simplified Mandatory Access Contorol Kernel)
  • AppArmor(Application Armor)

SElinuxとSMACKはセキュリティコンテキスト情報をファイルの拡張属性に保持
(ファイルシステムが対応している必要がある)
AppArmorはセキュリティコンテキスト情報をファイルパスで保持
(ファイルシステムを選ばない)

SELinuxの機能

TE(Type Enforcement)

ラベルを付与する事で細やかなアクセス制御を実現
プロセス→「ドメイン」
ファイル・ディレクトリ→「タイプ」

ドメイン遷移

子プロセスを親プロセスとは異なるドメイン(権限の範囲)に遷移させる
(必要なものだけに制限する)

RBAC(Role Based Access Control)

従来のLinuxでrootユーザーが持っていた絶対的な権限を分散し、「システム管理者」、「WEB管理者」といったロール(役割)をユーザーに割り当てる

# 現在のSELinuxの状態確認
[root@host ~]# getenforce
Permissive
[root@host ~]# setenforce 1
[root@host ~]# getenforce
Enforcing
[root@host ~]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          error (Success)
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      31
# Boolean値で示されるポリシー状態の取得
[root@host ~]# getsebool -a
abrt_anon_write --> off
abrt_handle_event --> off
abrt_upload_watch_anon_write --> on
antivirus_can_scan_system --> off
antivirus_use_jit --> off
auditadm_exec_content --> on
authlogin_nsswitch_use_ldap --> off
()
# ラベルを確認する
[root@host ~]# ps axZ
LABEL                             PID TTY      STAT   TIME COMMAND
system_u:system_r:kernel_t:s0       1 ?        Ss     0:00 /usr/lib/systemd/syst
system_u:system_r:kernel_t:s0       2 ?        S      0:00 [kthreadd]
system_u:system_r:kernel_t:s0       3 ?        S      0:00 [kworker/0:0]
system_u:system_r:kernel_t:s0       4 ?        S<     0:00 [kworker/0:0H]
system_u:system_r:kernel_t:s0       5 ?        S      0:00 [kworker/u2:0]
system_u:system_r:kernel_t:s0       6 ?        S      0:00 [ksoftirqd/0]
system_u:system_r:kernel_t:s0       7 ?        S      0:00 [migration/0]
system_u:system_r:kernel_t:s0       8 ?        S      0:00 [rcu_bh]
system_u:system_r:kernel_t:s0       9 ?        R      0:00 [rcu_sched]
system_u:system_r:kernel_t:s0      10 ?        S<     0:00 [lru-add-drain]
system_u:system_r:kernel_t:s0      11 ?        S      0:00 [watchdog/0]
system_u:system_r:kernel_t:s0      13 ?        S      0:00 [kdevtmpfs]
# ファイルのパーミッション、ラベルを確認
[root@host ~]# ls -Z
-rw-r--r--. root root system_u:object_r:unlabeled_t:s0 0527host02.log
-rw-------. root root system_u:object_r:admin_home_t:s0 anaconda-ks.cfg
-rw-r--r--. root root system_u:object_r:unlabeled_t:s0 newreq.pem
drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 mnfstest

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?