Networking in NSA Security-Enhanced Linux
The system_u user and object_r role are default values for system objects. It wouldn't make any sense for a port to have a real user or role; it's not owned by anyone and it doesn't initiate any actions that require a verdict from SELinux.
A socket is labeled by its associated inode and is categorized as either a generic socket or one of the following socket subclasses:
UNIX stream.
UNIX datagram.
TCP.
UDP.
Raw (includes ICMP and other non-TCP/UDP).
Netlink families.
Packet.
Key (pfkeyv2).
Subclasses of sockets can be distinguished in security policy, providing for fine-grained control and flexibility over different network protocols:
allow lpd_t printer_port_t:tcp_socket name_bind;
This rule allows only a TCP socket created in the lpd_t domain to bind to a port of type printer_port_t.
IPv4 and IPv6 ports are labeled implicitly within the kernel, as specified by policy. The format for labeling port types is:
portcon protocol { port number | port range }
context
The following defines a security context for labeling the standard printer port:
portcon tcp 515 system_u:object_r:printer_port_t
Each network interface (netif) is labeled with a security context, as specified in policy. Network interfaces are labeled as follows:
netifcon interface context default_msg_context
The default_msg_context parameter is intended to be used for labeling messages arriving on the interface, but is not currently used.
Here are some examples of netif labeling in policy:
netifcon eth0 system_u:object_r:netif_intranet_t [...] netifcon eth1 system_u:object_r:netif_extranet_t [...]
Under SELinux, a node refers to an IPv4 or IPv6 address and netmask. It allows host and network addresses to be labeled with security contexts via policy.
The format for labeling nodes is:
nodecon address mask context
Here are examples of labeling localhost addresses:
nodecon 127.0.0.1 255.255.255.255
system_u:object_r:node_lo_t
nodecon ::1 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
system_u:object_r:node_lo_t
Access-control hooks are implemented for every socket system call, allowing all socket-based network protocols to be mediated by SELinux policy. A few hooks are used only for housekeeping, but otherwise, hooks generally are used to check one or more access-control permissions.
As there are a large number of generic socket controls, see Table 1 for the relationships between the hooks, socket system calls and permissions.
Table 1. The Relationships between Hooks, Socket System Calls and Permissions
| Hook | System Call | SELinux Permission |
|---|---|---|
| selinux_socket_create | socket | create |
| selinux_socket_post_create | socket | n/a |
| selinux_socket_bind | bind | bind |
| selinux_socket_connect | connect | connect |
| selinux_socket_listen | listen | listen |
| selinux_socket_accept | accept | accept |
| selinux_socket_sendmsg | sendmsg, send, sendto | write |
| selinux_socket_recvmsg | recvmsg, recv, recvfrom | read |
| selinux_socket_getsockname | getsockname | getattr |
| selinux_socket_getpeername | getpeername | getattr |
| selinux_socket_setsockopt | setsockopt | setopt |
| selinux_socket_getsockopt | getsockopt | getopt |
| selinux_socket_shutdown | shutdown | shutdown |
Internally, the socket() system call is decomposed into two hooks. The selinux_socket_create hook is used to check whether the process can create a socket of the type requested. The selinux_socket_post_create management hook is used to assign a security label and socket class to the newly allocated inode associated with the socket.
The SELinux permissions also abstract the way system calls and other operations are viewed from a security point of view. Note, for example, that the getattr permission is used for the getsockname() and getpeername() system calls. They are seen to be equivalent security-wise by SELinux. Similarly, all of the sendmsg()- and recvmsg()-based system calls are reduced for security management purposes into simply read and write. For the curious, the code behind these hooks can be found in the 2.6 kernel, in security/selinux/hooks.c.
As sockets are also files, they inherit some of the access controls associated with files. Table 2 lists the file-specific hooks and permissions inherited by sockets.
Table 2. File-Specific Hooks and Permissions
| Hook | System Call | SELinux Permission |
|---|---|---|
| selinux_file_ioctl | ioctl | ioctl |
| selinux_inode_getattr | fstat | getattr |
| selinux_inode_setattr | fchmod, fchown | setattr |
| selinux_file_fcntl | fcntl | lock |
| selinux_file_lock | fcntl, flock | lock |
| selinux_file_permission | write, write, read | append, write, read |
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- New Products
- Linux Systems Administrator
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- Designing Electronics with Linux
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- Reply to comment | Linux Journal
2 hours 15 min ago - Reply to comment | Linux Journal
2 hours 32 min ago - Favorite (and easily brute-forced) pw's
4 hours 23 min ago - Have you tried Boxen? It's a
10 hours 15 min ago - seo services in india
14 hours 46 min ago - For KDE install kio-mtp
14 hours 47 min ago - Evernote is much more...
16 hours 47 min ago - Reply to comment | Linux Journal
1 day 1 hour ago - Dynamic DNS
1 day 2 hours ago - Reply to comment | Linux Journal
1 day 3 hours ago
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
Total bewilderment
What a wonderful example of why kernel hackers shouldn't write magazine articles! I really wanted to understand this SELinux stuff, but this is an impenetrable mess.
Here's how not to do it: first, ensure you don't define your audience. I initially thought this was aimed at developers, but now I think perhaps it's aimed at systems administrators. Second, throw in a whole load of acronyms, right the beginning: MAC, TE, RBAC DAC, LSM (trying to ensure you never use them again in the rest of the piece). Then make life hard for the reader by giving a "general form" containing 3 lines, followed by an example containing 1 line. Still with us? Great. Throw in a few more undefined terms, like "security context", "target context" and "source context", then a few references to system calls (a couple of dozen should be enough). Next present a config file that is longer than the source of the program it is supposed to protect, plus tweaks to 3 other obscure files, the purpose of each remaining unexplained. Then throw in a "make" command without explaining that either. Finish up with a set of obscure commands to prove the example works, carefully labelling it as a "simple demonstration". Job done!
Perhaps I'm in a flippant mood this morning. Perhaps it's because I'm an application developer, not a sysadmin. Perhaps I haven't had enough caffeine. Or perhaps, just possibly, this article is written from the inside out, and is therefore only accessible to those who already understand what the heck it's on about.
If you want to understand mor
If you want to understand more about the underlying concepts, I'd suggest looking at the Faye Coker article listed in the resources, http://www.linuxjournal.com/article/7864
The article is aimed at anyone interested in how SELinux works underneath, and documents a lot of previously undocumented aspects of the networking. I guess it may have been better to drop the introductory section (instead referring to other resources) and include a short glossary.
There is no Faye Cocker article
I looked at that link, http://www.linuxjournal.com/article/7864
There is no Faye Coker article listed on that page. I did a find on the entire web page for "faye" and "coker", nothing.