未加星标

SELinux Security Policy Part2: Labels

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二05 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

From the previousblog we know that SElinux policy consists of rules, each of which describes an INTERACTION between processes and system resources.

In the second part of this blog series I will tell you more about LABELS. Where SELinux labels are stored and how they look in reality. Labels are an important part of SELinux since all SELinux decisions are based on them. As my colleague Dan Walsh says:

“SELinux is all about labels“

Where are SELinux labels stored?

SELinux labels are stored in extended attributes (abbreviated xattr) of file systems that support them ext2 , ext3 , ext4 and others.

How can I show labels placed in XATTR ?

# getfattr -n security.selinux /etc/passwd getfattr: Removing leading '/' from absolute path names # file: etc/passwd security.selinux="system_u:object_r:passwd_file_t:s0"

Is there another way to show it?

# ls -Z /etc/passwd system_u:object_r:passwd_file_t:s0 /etc/passwd

“ -Z ” option is your friend. In most cases it is related to SELinux and help us either show SELinux labels or modify them directly. You can check it for mv , cp , ps user commands for example.

From the above example of SELinux label you can see that SELinux labels consist of FOUR parts with the following template

SELinux user:SELinux role:SELinux type:SELinux category SELinux users Not the same as Linux users.
Several Linux users can be mapped to a single SELinux user.
object_u is a placeholder for Linux system resources.
system_u is a placeholder for Linux processes.
Can be limited to a set of SELinux roles. SELinux role SELinux users can have multiple roles but only one can be active.
object_r is a placeholder for Linux system resources.
system_r is a placeholder for system processes.
Can be limited to a set of SELinux types. SELinux type Security model known as TYPE ENFORCEMENT .
In 99% you care only about TYPES.
policy rules and interactions between types. SELinux category Allow users to mark resources with compartment tags (MCS1 , MCS2 ).
Used for RHEL virtualization and for container security.
s0 as the placeholder for default category.
s0:c1 can not access s0:c2.

In Fedora we ship TARGETED SELinux policy featuring mainly TYPE ENFORCEMENT. It means we mostly care only about TYPES . We can re-define the introductory statement of policy rules with this knowledge from

ALLOW LABEL1 LABEL2 :OBJECT_CLASS PERMISSION ;

to

ALLOW TYPE1 TYPE2 :OBJECT_CLASS PERMISSION ;

Where TYPE1 could be APACHE_T process type for apache processes and TYPE2 could be file type for apache logging files. In that case we declare the following SELinux policy rules

ALLOW APACHE_T APACHE_LOG_T:FILE READ;

Now you know that if we talk about TYPES, we talk about LABELS with respect to TARGETED policy, which is the default policy used in FEDORA.

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: LinuxTICTI
分页:12
转载请注明
本文标题:SELinux Security Policy Part2: Labels
本站链接:http://www.codesec.net/view/534262.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(42)