tomoyotitle.png

ドメイン遷移

ドメイン遷移には2種類あります。1つはプログラムの実行要求( execve() システムコール)を伴うドメイン遷移です。もう1つはプログラムの実行要求を伴わないドメイン遷移です。

プログラム実行要求による遷移

この種類のドメイン遷移はアクセス制御のモードに依存します。プロセスがプログラムを実行しようとすると、以下の処理が行われます。

[source] は現在のドメイン名(例: <kernel> /usr/sbin/sshd /bin/bash )または現在のドメイン名の最後のパス名(例: /bin/bash )を表します。

[current_domain] は現在のドメイン名(例: <kernel> /usr/sbin/sshd /bin/bash )を表します。

[current_namespace] は現在のドメインの名前空間の名前(例: <kernel> /usr/sbin/sshd /bin/bash ドメインの場合は <kernel> )を表します。

[destination] はプログラムの実行要求が成功した場合に遷移するドメイン名(例: <kernel> /usr/sbin/sshd /bin/bash /bin/cat )を表します。

[candidate] はパーミッションのチェックの対象となるパス名(例: /bin/cat )を表します。

ステップ

内容

(1) プログラムのパス名を取得

要求されたプログラムのパス名を取得し、それを [candidate] とします。
シンボリックリンクとして提供されているプログラムに対処するために、パス名の最後のシンボリックリンクは解決しないようにします。

(2) aggregator ディレクティブのチェック

もし、例外ポリシーに
  aggregator [candidate] [pathname]
というエントリが存在している場合、 [pathname] を [candidate] にします。

(3) file execute ディレクティブのチェック

ドメインポリシーに
  file execute [candidate] keep
というエントリが存在している場合、 [current_domain] を [destination] にしてステップ (5) へ進みます。


ドメインポリシーに
  file execute [candidate] child
というエントリが存在している場合、 [current_domain] [candidate] を [destination] にしてステップ (5) へ進みます。


ドメインポリシーに
  file execute [candidate] reset
というエントリが存在している場合、 <[candidate]> を [destination] にしてステップ (5) へ進みます。


ドメインポリシーに
  file execute [candidate] initialize
というエントリが存在している場合、 [current_namespace] [candidate] を [destination] にしてステップ (5) へ進みます。


ドメインポリシーに
  file execute [candidate] parent
というエントリが存在している場合、 [current_domain] の親ドメインを [destination] にしてステップ (5) へ進みます。


ドメインポリシーに
  file execute [candidate] [domainname]
というエントリが存在している場合、 [domainname] を [destination] にしてステップ (5) へ進みます。


ドメインポリシーに
  file execute [candidate] [pathname]
というエントリが存在している場合、 [current_domain] [pathname] を [destination] にしてステップ (5) へ進みます。


ドメインポリシーに
  file execute [candidate]
というエントリが存在している場合、ステップ (4) に進みます。


その他の場合、プロファイルの CONFIG または CONFIG::file または CONFIG::file::execute (後者が前者より優先されます)で mode=enforcing という設定が行われていた場合にはプログラムの実行要求は拒否されます。

(4) デフォルトのドメイン遷移の決定

1番最初に、例外ポリシーに
  reset_domain [candidate] from [source]
  reset_domain any from [source]
  reset_domain any from any
の何れかのエントリが存在しており、かつ、
  no_reset_domain [candidate] from [source]
  no_reset_domain any from [source]
  no_reset_domain any from any
の何れのエントリも存在しない場合、 <[candidate]> を [destination] にしてステップ (5) へ進みます。


2番目に、例外ポリシーに
  initialize_domain [candidate] from [source]
  initialize_domain any from [source]
  initialize_domain any from any
の何れかのエントリが存在しており、かつ、
  no_initialize_domain [candidate] from [source]
  no_initialize_domain any from [source]
  no_initialize_domain any from any
の何れのエントリも存在しない場合、 [current_namespace] [candidate] を [destination] にしてステップ (5) へ進みます。


3番目に、例外ポリシーに
  keep_domain [candidate] from [source]
  keep_domain any from [source]
  keep_domain any from any
の何れかのエントリが存在しており、かつ、
  no_keep_domain [candidate] from [source]
  no_keep_domain any from [source]
  no_keep_domain any from any
の何れのエントリも存在しない場合、 [current_domain] を [destination] にしてステップ (5) へ進みます。


4番目に、 [current_domain] [candidate] を [destination] にします。

(5) 遷移先ドメインの作成

ステップ (3) または (4) で決定した [destination] が存在しない場合には作成します。


ステップ (3) で決定された [destination] を作成できなかった場合には、プログラムの実行要求は拒否されます。


reset_domain で決定された [destination] を作成できなかった場合には、プログラムの実行要求は拒否されます。


ステップ (4) で決定された [destination] を作成できなかった場合で、かつ、プロファイルの CONFIG または CONFIG::file または CONFIG::file::execute (後者が前者より優先されます)で mode=enforcing という設定が行われていた場合にはプログラムの実行要求は拒否されます。
そうではない場合、 transition_failed ディレクティブを設定して、ドメイン遷移を行わないまま実行要求の処理を継続します。

(6) 環境変数のチェック

もし、1個以上の環境変数の許可が [destination] ドメインに与えられておらず、かつ [destination] ドメインに割り当てられているプロファイル( CONFIG または CONFIG::misc または CONFIG::misc::env (後者が前者より優先されます))のモードが mode=enforcing の場合、実行要求は拒否されます。

(7) インタプリターのチェック

(インタプリタを必要とするプログラムの場合、)インタプリタに対する読み込み許可が [destination] ドメインに与えられておらず、かつ [destination] ドメインに割り当てられているプロファイル( CONFIG または CONFIG::file または CONFIG::file::open (後者が前者より優先されます))のモードが mode=enforcing の場合、実行要求は拒否されます。

(8) プログラムの実行

もし、カレントプロセスが要求されたプログラムによって正常に置き換えられた場合、カレントプロセスは [destination] ドメインへと遷移します。

プログラム実行要求によらない遷移

この種類のドメイン遷移はアクセス制御のモードに依存しません。ポリシーで許可されていないドメイン遷移要求は常に拒否されます。

もし、ドメインに対して task manual_domain_transition ディレクティブが指定されていた場合、カレントプロセスは /sys/kernel/security/tomoyo/self_domain インタフェースに対してこのディレクティブで指定されているドメイン名を書き込むことにより、そのドメインへと遷移します。