We currently migrate to MediaWiki from our old installation, but not all content has been migrated yet. Take a look at the Wiki Team page for instructions how to help or browse through our new wiki at wiki.linux-vserver.org to find the information already migrated.

03. Existing Infrastructure

Recent Linux Kernels already provide many security features that are utilized by Linux-VServer to do its work. Especially features such as the Linux Capability System, Resource Limits, File Attributes and the Change Root Environment. The following sections will give a short overview about each of these.

03.0. Linux Capability System

In computer science, a capability is a token used by a process to prove that it is allowed to perform an operation on an object. The Linux Capability System is based on "POSIX Capabilities", a somewhat different concept, designed to split up the all powerful root privilege into a set of distinct privileges.

03.0.0. POSIX Capabilities

A process has three sets of bitmaps called the inheritable(I), permitted(P), and effective(E) capabilities. Each capability is implemented as a bit in each of these bitmaps that is either set or unset.

When a process tries to do a privileged operation, the operating system will check the appropriate bit in the effective set of the process (instead of checking whether the effective uid of the process is 0 as is normally done).

For example, when a process tries to set the clock, the Linux kernel will check that the process has the CAP_SYS_TIME bit (which is currently bit 25) set in its effective set.

The permitted set of the process indicates the capabilities the process can use. The process can have capabilities set in the permitted set that are not in the effective set.

This indicates that the process has temporarily disabled this capability. A process is allowed to set a bit in its effective set only if it is available in the permitted set. The distinction between effective and permitted exists so that processes can "bracket" operations that need privilege.

The inheritable capabilities are the capabilities of the current process that should be inherited by a program executed by the current process. The permitted set of a process is masked against the inheritable set during exec(). Nothing special happens during fork() or clone(). Child processes and threads are given an exact copy of the capabilities of the parent process.

The implementation in Linux stopped at this point, whereas POSIX Capabilities[U5] requires the addition of capability sets to files too, to replace the SUID flag (at least for executables)

03.0.1. Capability Overview

The list of POSIX Capabilities used with Linux is long, and the 32 available bits are almost used up. While the detailed list of all capabilities can be found in /usr/include/linux/capability.h on most Linux systems, an overview of important capabilities is given here.

change file ownership and group.
send a signal to a process with a different real or effective user ID
permit setgid(2), setgroups(2), and forged gids on socket credentials passing
permit set*uid(2), and forged uids on socket credentials passing
transfer/remove any capability in permitted set to/from any pid
allow modification of S_IMMUTABLE and S_APPEND file attributes
permit broadcasting and listening to multicast
permit interface configuration, IP firewall, masquerading, accounting, socket debugging, routing tables, bind to any address, enter promiscuous mode, multicasting, ...
permit usage of RAW and PACKET sockets
insert and remove kernel modules
permit chroot(2)
permit ptrace() of any process
this list would be too long, it basically allows to do everything else, not mentioned in another capability.
permit reboot(2)
allow raising priority and setting priority on other processes, modify scheduling
override resource limits, quota, reserved space on fs, ...
permit the privileged aspects of mknod(2) \

Also see Examples [E01] , [E02], and [E03]

03.1. Resource Limits

Resources for each process can be limited by specifying a Resource Limit. Similar to the Linux Capabilities, there are two different limits, a Soft Limit and a Hard Limit.

The soft limit is the value that the kernel enforces for the corresponding resource. The hard limit acts as a ceiling for the soft limit: an unprivileged process may only set its soft limit to a value in the range from zero up to the hard limit, and (irreversibly) lower its hard limit. A privileged process may make arbitrary changes to either limit value, as long as the soft limit stays below the hard limit.

03.1.0. Limit-able Resource Overview

The list of all defined resource limits can be found in /usr/include/asm/resource.h on most Linux systems, an overview of relevant resource limits is given here.

CPU time in seconds. process is sent a SIGXCPU signal after reaching the soft limit, and SIGKILL on hard limit.
maximum size of core files generated
number of pages the process's resident set can consume (the number of virtual pages resident in RAM)
The maximum number of processes that can be created for the real user ID of the calling process.
Specifies a value one greater than the maximum file descriptor number that can be opened by this process.
The maximum number of virtual memory pages that may be locked into RAM using mlock() and mlockall().
The maximum number of virtual memory pages available to the process (address space limit). \

Also see Examples [E11] and [E12].

03.2. File Attributes

Originally, this feature was only available with ext2, but now all major filesystems implement a basic set of File Attributes that permit certain properties to be changed. Here again is a short overview of the possible attributes, and what they mean.

When a file with this attribute set is deleted, its blocks are zeroed and written back to the disk.
When a file with this attribute set is deleted, its contents are saved.
files marked with this attribute are automatically compressed on write and uncompressed on read. (not implemented yet)
A file with this attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file.
files with this attribute set can only be opened in append mode for writing.
if this flag is set, the file is not candidate for backup with the dump utility.
updates to the file contents are done synchronously.
prevents updating the atime record on files when they are accessed or modified.
A file with the t attribute will not have a partial block fragment at the end of the file merged with other files.
changes to a directory having this attribute set will be done synchronously.
Also see Examples [E13] and [E14].

03.3. The chroot(1) Command

chroot allows you to run a command with a different directory acting as the root directory. This means that all filesystem lookups are done with '/' referring to the substitute root directory and not to the original one.

While the Linux chroot implementation isn't very secure, it increases the isolation of processes with regards to the filesystem, and, if used properly, can create a filesystem "jail" for a single process or a restricted user, daemon or service.

See Example [E15]

[Summary] [Go Back] [Next]