14.3.1 Domain Structure
- A protection domain specifies the resources that a process may access.
- Each domain defines a set of objects and the types of operations that may be invoked on each object.
- An access right is the ability to execute an operation on an object.
- A domain is defined as a set of < object, { access right set } > pairs, as shown below. Note that some domains may be disjoint while others overlap.
Figure 14.1 - System with three protection domains.
- The association between a process and a domain may be static or dynamic.
- If the association is static, then the need-to-know principle requires a way of changing the contents of the domain dynamically.
- If the association is dynamic, then there needs to be a mechanism for domain switching.
- Domains may be realized in different fashions - as users, or as processes, or as procedures. E.g. if each user corresponds to a domain, then that domain defines the access of that user, and changing domains involves changing user ID.
14.3.2 An Example: UNIX
- UNIX associates domains with users.
- Certain programs operate with the SUID bit set, which effectively changes the user ID, and therefore the access domain, while the program is running. ( and similarly for the SGID bit. ) Unfortunately this has some potential for abuse.
- An alternative used on some systems is to place privileged programs in special directories, so that they attain the identity of the directory owner when they run. This prevents crackers from placing SUID programs in random directories around the system.
- Yet another alternative is to not allow the changing of ID at all. Instead, special privileged daemons are launched at boot time, and user processes send messages to these daemons when they need special tasks performed.
14.3.3 An Example: MULTICS
- The MULTICS system uses a complex system of rings, each corresponding to a different protection domain, as shown below:
Figure 14.2 - MULTICS ring structure.
- Rings are numbered from 0 to 7, with outer rings having a subset of the privileges of the inner rings.
- Each file is a memory segment, and each segment description includes an entry that indicates the ring number associated with that segment, as well as read, write, and execute privileges.
- Each process runs in a ring, according to the current-ring-number, a counter associated with each process.
- A process operating in one ring can only access segments associated with higher ( farther out ) rings, and then only according to the access bits. Processes cannot access segments associated with lower rings.
- Domain switching is achieved by a process in one ring calling upon a process operating in a lower ring, which is controlled by several factors stored with each segment descriptor:
- An access bracket, defined by integers b1 <= b2.
- A limit b3 > b2
- A list of gates, identifying the entry points at which the segments may be called.
- If a process operating in ring i calls a segment whose bracket is such that b1 <= i <= b2, then the call succeeds and the process remains in ring i.
- Otherwise a trap to the OS occurs, and is handled as follows:
- If i < b1, then the call is allowed, because we are transferring to a procedure with fewer privileges. However if any of the parameters being passed are of segments below b1, then they must be copied to an area accessible by the called procedure.
- If i > b2, then the call is allowed only if i <= b3 and the call is directed to one of the entries on the list of gates.
- Overall this approach is more complex and less efficient than other protection schemes.
Figure 14.3 - Access matrix.
Figure 14.4 - Access matrix of Figure 14.3 with domains as objects.
Figure 14.5 - Access matrix with copy rights.
Figure 14.6 - Access matrix with owner rights.
Figure 14.7 - Modified access matrix of Figure 14.4
14.5.1 Global Table
- The simplest approach is one big global table with < domain, object, rights > entries.
- Unfortunately this table is very large ( even if sparse ) and so cannot be kept in memory ( without invoking virtual memory techniques. )
- There is also no good way to specify groupings - If everyone has access to some resource, then it still needs a separate entry for every domain.
14.5.2 Access Lists for Objects
- Each column of the table can be kept as a list of the access rights for that particular object, discarding blank entries.
- For efficiency a separate list of default access rights can also be kept, and checked first.
14.5.3 Capability Lists for Domains
- In a similar fashion, each row of the table can be kept as a list of the capabilities of that domain.
- Capability lists are associated with each domain, but not directly accessible by the domain or any user process.
- Capability lists are themselves protected resources, distinguished from other data in one of two ways:
- A tag, possibly hardware implemented, distinguishing this special type of data. ( other types may be floats, pointers, booleans, etc. )
- The address space for a program may be split into multiple segments, at least one of which is inaccessible by the program itself, and used by the operating system for maintaining the process's access right capability list.
14.5.4 A Lock-Key Mechanism
- Each resource has a list of unique bit patterns, termed locks.
- Each domain has its own list of unique bit patterns, termed keys.
- Access is granted if one of the domain's keys fits one of the resource's locks.
- Again, a process is not allowed to modify its own keys.
14.5.5 Comparison
- Each of the methods here has certain advantages or disadvantages, depending on the particular situation and task at hand.
- Many systems employ some combination of the listed methods.
Figure 14.8 - Role-based access control in Solaris 10.
14.8.1 An Example: Hydra
- Hydra is a capability-based system that includes both system-defined rights and user-defined rights. The interpretation of user-defined rights is up to the specific user programs, but the OS provides support for protecting access to those rights, whatever they may be
- Operations on objects are defined procedurally, and those procedures are themselves protected objects, accessed indirectly through capabilities.
- The names of user-defined procedures must be identified to the protection system if it is to deal with user-defined rights.
- When an object is created, the names of operations defined on that object become auxiliary rights, described in a capability for an instance of the type. For a process to act on an object, the capabilities it holds for that object must contain the name of the operation being invoked. This allows access to be controlled on an instance-by-instance and process-by-process basis.
- Hydra also allows rights amplification, in which a process is deemed to be trustworthy, and thereby allowed to act on any object corresponding to its parameters.
- Programmers can make direct use of the Hydra protection system, using suitable libraries which are documented in appropriate reference manuals.
14.8.2 An Example: Cambridge CAP System
- The CAP system has two kinds of capabilities:
- Data capability, used to provide read, write, and execute access to objects. These capabilities are interpreted by microcode in the CAP machine.
- Software capability, is protected but not interpreted by the CAP microcode.
- Software capabilities are interpreted by protected ( privileged ) procedures, possibly written by application programmers.
- When a process executes a protected procedure, it temporarily gains the ability to read or write the contents of a software capability.
- This leaves the interpretation of the software capabilities up to the individual subsystems, and limits the potential damage that could be caused by a faulty privileged procedure.
- Note, however, that protected procedures only get access to software capabilities for the subsystem of which they are a part. Checks are made when passing software capabilities to protected procedures that they are of the correct type.
- Unfortunately the CAP system does not provide libraries, making it harder for an individual programmer to use than the Hydra system.
14.9.1 Compiler-Based Enforcement
- In a compiler-based approach to protection enforcement, programmers directly specify the protection needed for different resources at the time the resources are declared.
- This approach has several advantages:
- Protection needs are simply declared, as opposed to a complex series of procedure calls.
- Protection requirements can be stated independently of the support provided by a particular OS.
- The means of enforcement need not be provided directly by the developer.
- Declarative notation is natural, because access privileges are closely related to the concept of data types.
- Regardless of the means of implementation, compiler-based protection relies upon the underlying protection mechanisms provided by the underlying OS, such as the Cambridge CAP or Hydra systems.
- Even if the underlying OS does not provide advanced protection mechanisms, the compiler can still offer some protection, such as treating memory accesses differently in code versus data segments. ( E.g. code segments cant be modified, data segments can't be executed. )
- There are several areas in which compiler-based protection can be compared to kernel-enforced protection:
- Security. Security provided by the kernel offers better protection than that provided by a compiler. The security of the compiler-based enforcement is dependent upon the integrity of the compiler itself, as well as requiring that files not be modified after they are compiled. The kernel is in a better position to protect itself from modification, as well as protecting access to specific files. Where hardware support of individual memory accesses is available, the protection is stronger still.
- Flexibility. A kernel-based protection system is not as flexible to provide the specific protection needed by an individual programmer, though it may provide support which the programmer may make use of. Compilers are more easily changed and updated when necessary to change the protection services offered or their implementation.
- Efficiency. The most efficient protection mechanism is one supported by hardware and microcode. Insofar as software based protection is concerned, compiler-based systems have the advantage that many checks can be made off-line, at compile time, rather that during execution.
- The concept of incorporating protection mechanisms into programming languages is in its infancy, and still remains to be fully developed. However the general goal is to provide mechanisms for three functions:
- Distributing capabilities safely and efficiently among customer processes. In particular a user process should only be able to access resources for which it was issued capabilities.
- Specifying the type of operations a process may execute on a resource, such as reading or writing.
- Specifying the order in which operations are performed on the resource, such as opening before reading.
14.9.2 Protection in Java
- Java was designed from the very beginning to operate in a distributed environment, where code would be executed from a variety of trusted and untrusted sources. As a result the Java Virtual Machine, JVM incorporates many protection mechanisms
- When a Java program runs, it load up classes dynamically, in response to requests to instantiates objects of particular types. These classes may come from a variety of different sources, some trusted and some not, which requires that the protection mechanism be implemented at the resolution of individual classes, something not supported by the basic operating system.
- As each class is loaded, it is placed into a separate protection domain. The capabilities of each domain depend upon whether the source URL is trusted or not, the presence or absence of any digital signatures on the class ( Chapter 15 ), and a configurable policy file indicating which servers a particular user trusts, etc.
- When a request is made to access a restricted resource in Java, ( e.g. open a local file ), some process on the current call stack must specifically assert a privilege to perform the operation. In essence this method assumes responsibility for the restricted access. Naturally the method must be part of a class which resides in a protection domain that includes the capability for the requested operation. This approach is termed stack inspection, and works like this:
- When a caller may not be trusted, a method executes an access request within a doPrivileged( ) block, which is noted on the calling stack.
- When access to a protected resource is requested, checkPermissions( ) inspects the call stack to see if a method has asserted the privilege to access the protected resource.
- If a suitable doPriveleged block is encountered on the stack before a domain in which the privilege is disallowed, then the request is granted.
- If a domain in which the request is disallowed is encountered first, then the access is denied and a AccessControlException is thrown.
- If neither is encountered, then the response is implementation dependent.
- In the example below the untrusted applet's call to get( ) succeeds, because the trusted URL loader asserts the privilege of opening the specific URL lucent.com. However when the applet tries to make a direct call to open( ) it fails, because it does not have privilege to access any sockets.
Figure 14.9 - Stack inspection.