关于内存和上下文结构的 SELinux 策略创建错误

SELinux Policy Creation Error regarding Memory and Context Structure

我正在使用 RHEL 7。我在这里存储了另一台机器的日志文件。 我使用以下命令创建策略:

grep -inr "denied" audit.log* | audit2allow -M Policy_File_Name

使用此命令,我能够为许多日志文件创建策略。但在某些情况下我遇到了这个错误:

Traceback (most recent call last):
  File "/usr/bin/audit2allow", line 365, in <module>
    app.main()
  File "/usr/bin/audit2allow", line 352, in main
    self.__process_input()
  File "/usr/bin/audit2allow", line 180, in __process_input
    self.__avs = self.__parser.to_access()
  File "/usr/lib64/python2.7/site-packages/sepolgen/audit.py", line 591, in to_access
    avc.path = self.__restore_path(avc.name, avc.ino)
  File "/usr/lib64/python2.7/site-packages/sepolgen/audit.py", line 531, in __restore_path
    universal_newlines=True)
  File "/usr/lib64/python2.7/subprocess.py", line 568, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1224, in _execute_child
    self.pid = os.fork()
OSError: [Errno 12] Cannot allocate memory

我很少遇到这个错误:

libsepol.context_from_record: type celery_t is not defined
libsepol.context_from_record: could not create context structure
libsepol.context_from_string: could not create context structure
libsepol.sepol_context_to_sid: could not convert system_u:system_r:celery_t:s0 to sid

此处 'celery_t' 根据目标上下文更改。

系统条件:

[root@selinux-policy-creation abhisheklog]# free -h
           total       used        free      shared  buff/cache   available
 Mem:      31G         261M        27G        8.4M        3.1G         30GB
 Swap:      0B          0B          0B

请提供原因和解决方案。谢谢

此类错误消息意味着 file-system 中存在无效的 SE 模块,这可能是之前错误的卸载脚本的遗留物。手动删除这些文件通常可以消除这些错误消息;但在这种情况下似乎是相反的。虽然存在此类孤立的 SE 模块,但这可能会导致虚假错误消息 - 因此我什至不太确定 "cannot allocate memory" 消息。有感觉,这可能与 python2-celery (类型 celery_t 似乎来自哪里)有关。问题是 celery_t 类型进入了审核日志,但运行 audit2allow.

的机器不知道它
python2-celery-4.2.1-3.el7.noarch : Distributed Task Queue
Repo        : epel
Matched from:
Filename    : /usr/bin/celery

首先要尝试的可能是:

sudo yum install python2-celery

这可能会恢复丢失的类型 celery_t。我的意思是,如果这个日志文件来自另一台机器,那么这台机器可能安装了 python2-celery - 而运行 audit2allow 的机器可能只是缺少它。希望这是有道理的。