SELinux 和 cryptsetup:chown 失败并且无法访问临时密钥库

SELinux 和 cryptsetup:chown 失败并且无法访问临时密钥库

我正在尝试设置 SELinux 和一个加密的附加分区,我在启动时使用 systemd 服务安装该分区。

如果我在宽容模式下运行 SELinux,一切都运行正常(分区已正确安装,数据可以访问并且服务正常运行)。

如果我在强制模式 (enforcing=1) 下运行 SELinux,我将无法挂载此类分区并出现以下错误:

/dev/mapper/temporary-cryptsetup-1808: chown failed: Permission denied
sh[1777]: Failed to open temporary keystore device.
sh[1777]: Command failed with code 5: Input/output error

有什么想法可以解决这个问题吗?

Audit2allow 不返回任何要添加的附加规则

在 @AB 评论后编辑 1:

我用猫代替尾巴。 Audit2allow 建议没有额外的允许规则,但分析日志文件我发现一些拒绝兴趣:

type=AVC msg=audit(1624863678.748:72): avc:  denied  { getattr } for  pid=1894 comm="cryptsetup" path="/dev/dm-0" dev="devtmpfs" ino=5388 scontext=system_u:system_r:sysadm_t:s0-s15:c0.c1023 tcontext=system_u:object_r:fixed_disk_device_t:s15:c0.c1023 tclass=blk_file permissive=1
type=AVC msg=audit(1624863678.748:73): avc:  denied  { read } for  pid=1894 comm="cryptsetup" name="dm-0" dev="devtmpfs" ino=5388 scontext=system_u:system_r:sysadm_t:s0-s15:c0.c1023 tcontext=system_u:object_r:fixed_disk_device_t:s15:c0.c1023 tclass=blk_file permissive=1

在审核日志中搜索每个“cryptsetup”条目,我发现:

~# cat /var/log/audit/audit.log | grep "cryptsetup"
type=AVC msg=audit(1624863678.748:72): avc:  denied  { getattr } for  pid=1894 comm="cryptsetup" path="/dev/dm-0" dev="devtmpfs" ino=5388 scontext=system_u:system_r:sysadm_t:s0-s15:c0.c1023 tcontext=system_u:object_r:fixed_disk_device_t:s15:c0.c1023 tclass=blk_file permissive=1
type=SYSCALL msg=audit(1624863678.748:72): arch=14 syscall=195 success=yes exit=0 a0=bfebd34c a1=bfebd2e0 a2=bfebd2e0 a3=bfebd370 items=0 ppid=1891 pid=1894 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="cryptsetup" exe="/usr/sbin/cryptsetup" subj=system_u:system_r:sysadm_t:s0-s15:c0.c1023 key=(null)
type=AVC msg=audit(1624863678.748:73): avc:  denied  { read } for  pid=1894 comm="cryptsetup" name="dm-0" dev="devtmpfs" ino=5388 scontext=system_u:system_r:sysadm_t:s0-s15:c0.c1023 tcontext=system_u:object_r:fixed_disk_device_t:s15:c0.c1023 tclass=blk_file permissive=1
type=SYSCALL msg=audit(1624863678.748:73): arch=14 syscall=5 success=yes exit=6 a0=bfebf7ac a1=131000 a2=0 a3=10022cc0 items=0 ppid=1891 pid=1894 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="cryptsetup" exe="/usr/sbin/cryptsetup" subj=system_u:system_r:sysadm_t:s0-s15:c0.c1023 key=(null)

编辑 2:寻找 refpolicy 存储库中的任何更改,我发现2020 年 11 月提交2021 年 2 月承诺。我不知道他们是否可以适用于我手头的案例。

答案1

解决了分配给 cryptsetuplvm_exec_t上下文的问题。

lvm.fc文件 cryptsetup 中定义为/bin/cryptsetup但我必须将其更改为/usr/sbin/cryptsetup实际位置。

相关内容