SELinuxでruncをcontainer_tに変換するには?

SELinuxでruncをcontainer_tに変換するには?

私は言及していますこのページFedora 36では、次の簡単なガイドラインに従ってください。

docker pull aflplusplus/aflplusplus:
docker run -ti -v /location/of/your/target:/src aflplusplus/aflplusplus

ただし、次のSELinuxエラーが発生します。

SELinux is preventing runc:[2:INIT] from using the transition access on a process.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that runc:[2:INIT] should be allowed transition access on processes labeled container_t by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'runc:[2:INIT]' --raw | audit2allow -M my-runc2INIT
# semodule -X 300 -i my-runc2INIT.pp

Additional Information:
Source Context                system_u:system_r:unconfined_service_t:s0
Target Context                system_u:system_r:container_t:s0:c149,c848
Target Objects                /usr/bin/bash [ process ]
Source                        runc:[2:INIT]
Source Path                   runc:[2:INIT]
Port                          <Unknown>
Host                          localhost.localdomain
Source RPM Packages           
Target RPM Packages           bash-5.2.15-1.fc36.x86_64
SELinux Policy RPM            selinux-policy-targeted-36.17-1.fc36.noarch
Local Policy RPM              selinux-policy-targeted-36.17-1.fc36.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     localhost.localdomain
Platform                      Linux localhost.localdomain 6.1.13-100.fc36.x86_64
                              #1 SMP PREEMPT_DYNAMIC Wed Feb 22 18:13:06 UTC
                              2023 x86_64 x86_64
Alert Count                   1
First Seen                    2023-07-23 01:36:16 PDT
Last Seen                     2023-07-23 01:36:16 PDT
Local ID                      c389e11d-1f68-4433-b24e-27b54adbb8a9

Raw Audit Messages
type=AVC msg=audit(1690101376.101:6745): avc:  denied  { transition } for  pid=2847426 comm="runc:[2:INIT]" path="/usr/bin/bash" dev="overlay" ino=2172597 scontext=system_u:system_r:unconfined_service_t:s0 tcontext=system_u:system_r:container_t:s0:c149,c848 tclass=process permissive=0


Hash: runc:[2:INIT],unconfined_service_t,container_t,process,transition

これをどのように許可しますか?私は以下を試しました:

sudo semanage fcontext -a -t container_t "/usr/bin/runc"
sudo semanage fcontext -a -t container_t "/usr/bin/bash"

また、エラーメッセージで一時修正を試みましたが失敗しました。

Failed to resolve allow statement at /var/lib/selinux/targeted/tmp/modules/200/container/cil:1245
Failed to resolve AST
semodule:  Failed!

Semanageコマンドも失敗し、以下を提供します。

ValueError: Type container_t is invalid, must be a file or device type

以下を出力するコマンドを実行しましたrpm -qa|grep selinux|sort

container-selinux-2.199.0-1.fc36.noarch
flatpak-selinux-1.12.7-5.fc36.noarch
libselinux-3.3-4.fc36.x86_64
libselinux-devel-3.3-4.fc36.x86_64
libselinux-utils-3.3-4.fc36.x86_64
python3-libselinux-3.3-4.fc36.x86_64
rpm-plugin-selinux-4.17.1-3.fc36.x86_64
selinux-policy-36.17-1.fc36.noarch
selinux-policy-targeted-36.17-1.fc36.noarch
snapd-selinux-2.57.6-2.fc36.noarch
tpm2-abrmd-selinux-2.3.1-5.fc36.noarch

ベストアンサー1

unconfined_service_tシステムは、からへの変換を許可する方法を教えてくれましたcontainer_t。引用したメッセージの次のセクションを参照してください。

Do allow this access for now by executing:
# ausearch -c 'runc:[2:INIT]' --raw | audit2allow -M my-runc2INIT
# semodule -X 300 -i my-runc2INIT.pp

先頭は、#コマンドが root として実行されることを示します。これはコマンドの一部ではなく、単にルートコマンドプロンプトを表します。行全体をコマンドにコピーして貼り付けると、シェルはそれを#コメント記号として解釈し、何もしません。

最初のコマンドは、ausearch -c 'runc:[2:INIT]' --raw | audit2allow -M my-runc2INIT監査ログで正しいイベントを見つけてそれを提供してSELinuxルールモジュール(ファイル)をaudit2allow生成します。my-runc2INITmy-runc2INIT.pp

2番目のコマンドは、ルールモジュールをインストールして適用します。

後でカスタムルールを削除するには、semodule -r my-runc2INIT削除する必要があります。

おすすめ記事