Abstract: This article offers a process to help you support your application within a zone (using the Solaris Zones feature of the Solaris 10 OS). The process includes software installation and configuration as well as zone limitations with workarounds. Also discussed are best practices for application vendors.
Contents:
"Will my software work in a Zone?" Having worked with many partners that are interested in integrating some of the new features of the Solaris 10 Operating System into their software, this is the single-most common question I am asked about supporting the Solaris Zones feature. While most software supported on the Solaris 10 OS will run properly in a non-global zone, this question is not an easy one to answer because there are very real issues that stand in the way of non-global zone support. Without a process to help guide vendors through non-global zone support, application vendors might be uncomfortable or unable to bring zones support to their products. The aim of this writing is to help you through the process of supporting your application within a zone. This process includes software installation and configuration as well as zone limitations with workarounds where possible. Also included is a discussion on best practices for application vendors desiring to support zones. Before we continue, a few words on the term "zone" are in order. Zones are the software partitioning technology used to virtualize operating system services and provide an isolated and secure environment for running applications. The Solaris 10 OS supports the notion of the global zone and the non-global zone. For all intents and purposes, a global zone is the global view of the Solaris operating environment. There is always one global zone per Solaris instance appropriately named global. Each software partition that is created within the Solaris instance is known as a non-global zone. Many non-global zones can exist within an instance of the Solaris OS, each with a unique name. For the remainder of this document, the term zone will refer to the latter. When a distinction is required between a non-global zone and the global zone, the fully qualified zone type will be used. The Simplest Answer
If you want to add zone support to your software, you would benefit from knowing the fastest way to get started. What problems will you encounter? How can you estimate the amount of effort it would take? Zones provide the standard Solaris interfaces and application environment, and do not impose a new ABI or API. Applications do not need to be recompiled in the vast majority of cases in order to work within a zone. That is big news and that fact alone probably qualifies your application. There are a small number of limitations imposed on processes that run in a zone which guarantee that software in a zone does not cause harm to other zones or the global zone. Each of these will be explored in detail later, but the common trait among all of these limitations is that they require privileges only available to the superuser (root) in prior releases of Solaris. If your software runs as an unprivileged user, the simple answer to the question "will my software run in a zone?" is yes. This is the easiest way to cut the zones support question down to size. For example, if your software ran under Solaris 8 or Solaris 9 as a non-root user, you know that you are not using any system or library calls that require the sort of permission that would be limited in a zone under the Solaris 10 OS. If this is the case, it is fantastic news for you, as you will not have to perform a full qualification cycle to verify that your software runs properly in a zone. That is a pretty simple answer, and covers most software that runs on Solaris, but there is a catch even in this simple case. The problem is that during installation, configuration, and administration of your application a privileged user is probably required to perform certain actions. Also, if your software includes executables with the If a privileged user is required to run your software, your software will likely work in a zone, but to be certain, you have to do a bit more investigation. The Harder Road
If your software does require a privileged user for execution, you have to do more investigation to determine whether or not your application will run correctly in a non-global zone. The problem is that you must determine if you are using any of the APIs that are restricted in ways that will not function as expected in a zone because of security reasons. The next section, titled Zone Limitations, lists all of the known system call limitations of zones. If you determine that you are using only APIs that are unrestricted in zones, your software will run correctly and completely in a zone. Rest assured that this is the case for most software. If you are using restricted APIs, your software will have limitations when running in a zone. If this is the case, it is possible to still support execution in a non-global zone. Perhaps the software will have known limitations. The application could be modified to be "zone aware" and behave in a slightly different way when executed in a zone. It would make sense to have an application turn off functionality or features when running in a zone to avoid running into problems. Because zones do not define a new ABI or API, most software that runs on the Solaris 10 OS will work correctly in a zone. This section is dedicated to those system calls and associated library calls that serve as exceptions to this rule. There are several ways to approach the problem of finding such limitations in your software. Automated searching through the source code will probably prove to be the most complete type of search, but it is also possible to catch issues solely through testing or at runtime with tools such as privilege debugging, This section is dedicated to describing as fully as practical what each of the limitations entails. In a subsequent section, the use of various system utilities to find these issues will be explored. Before we address the particulars of the various system call behaviors in non-global zones, discussions are in order around zone security, the new Process Rights Management framework introduced in the Solaris 10 OS, and zone resources and services virtualization. Zone Security
Each non-global zone has a security boundary around it. The security boundary is maintained by:
Process Rights Management
Process rights management enables processes to be restricted at the command, user, role, or system level. The Solaris OS implements process rights management through privileges. Privileges decrease the security risk that is associated with one user or one process having full superuser capabilities on a system. A privilege is a discrete right that a process requires to perform an operation. The right is enforced in the kernel. A program that operates within the bounds of the Solaris basic set of privileges operates within the bounds of the system security policy. Privileges discretely enumerate the kinds of operations that are possible on a system. Programs can be run with the exact privileges that enable the program to succeed. For example, a program that sets the date and writes the date to an administrative file might require the Historically, systems have not followed the privilege model. Rather, systems used the superuser model. In the superuser model, processes run as root or as a user. User processes were limited to acting on the user's directories and files. root processes could create directories and files anywhere on the system. A process that required creation of a directory outside the user's directory would run with a The privilege model provides greater security than the superuser model. Privileges that have been removed from a process cannot be exploited. Process privileges prevent a program or administrative account from gaining access to all capabilities. Process privileges can provide an additional safeguard for sensitive files, where DAC protections alone can be exploited to gain access. Privileges, then, can restrict programs and processes to just the capabilities that the program requires. This capability is called the principle of least privilege. On a system that implements least privilege, an intruder who captures a process has access to only those privileges that the process has. The rest of the system cannot be compromised. The For most privileges, absence of the privilege simply results in a failure ( Zone Process Privileges
All processes running in a zone are privilege aware. That means all processes in a zone are constrained by the privilege sets that are assigned to them when the process is created. When the system creates a non-global zone, an
It was previously stated that the "basic" privileges used to be always available to unprivileged processes, and by default, processes still have the basic privileges. Unprivileged processes executing in a non-global zone, share the same "basic" privilege set as unprivileged processes running in the global zone. This is the reason why from a privilege standpoint, your unprivileged software is guaranteed to run in a zone (provided the zone was configured properly). Of the privileges listed below the privileges Table 1 lists the privileges available in the Solaris 10 OS and whether they are available in a non-global zone. The set of privileges in a non-global zone are a subset of the privileges available in the global zone. The functionality that these missing privileges provide (with the exception of the DTrace privileges, which are new to the Solaris 10 OS) is only available to the superuser in prior releases of Solaris. Table 1: Solaris 10 Privileges and Their Non-Global Zone Availability
System Calls
Because of restricted privileges of a process in a non-global zone, certain system calls when called with certain parameters may return errors. In most cases, adjtime, stime, ntp_adjtime
Limitation: Cannot set the system's notion of time in a non-global zone. Required Privilege: Impact: Software that needs to adjust the system's idea of the current time (for example, to synchronize with another machine). Workaround: N/A Associated Command(s): creat, chmod, open
Limitation: Creating or changing a regular file with the Required Privilege: Impact: The sticky bit set on a regular file (that is, not a directory) that does not have the executable mode set indicates that the file is a swap file. Therefore, the system's page cache will not be used to hold the contents of the file with the sticky bit set. It is fair to assume the impact of this limitation is minimal, as not many applications create files with the sticky bit set. The impact is felt more by a system administrator who would use this mode directly - or perhaps indirectly through the use of Workaround: The sticky bit can only be applied to files within the file system from the global zone. No workaround for executing within a zone is known at this time. Operations that attempt to set the sticky bit on a regular file in a local zone will fail with no error or warning. Associated Command(s): ioctl
Limitation: Cannot pop a Required Privilege: Impact: An anchor ( Workaround: N/A Associated Command: link, unlink
Limitation: Cannot create a link or unlink a directory in a zone. Required Privilege: Impact: This could have an impact during the installation/configuration of software that creates links to directories. This also has an impact on software that may create temporary directories that are later removed with calls to Workaround: Symbolic links ( Associated Command(s): memcntl
Limitation: Required Privilege: Impact: This can impact on software that needs to lock memory. For instance, a database program may want to lock memory to keep data table buffers in non-pageable memory for performance reasons. Workaround: If you are locking a shared memory segment, refer to workaround section for mknod
Limitation: Cannot create a block ( Required Privilege: Impact: Software that needs to create device nodes on the fly (for example, Sun Ray Server Software) is impacted by this. Backup and restoration utilities (for example, Workaround: The special file creation could be omitted from the software. Instead, the zone's configuration as specified by Associated Command(s): msgctl
Limitation: Required Privilege: Impact: Software that dynamically sizes the message queue is affected by this. Workaround: The system-defined limit used to initialize nice
Limitation: This call will fail if the increment argument is negative or greater than 40. Required Privilege: Impact: Depending upon the nature of your application requirements, your software may need to set the scheduling priority. Calling the Workaround: If your software really wants to adjust (raise) its priority using Associated Command: p_online
Limitation: Required Privilege: Impact: This will impact software that needs to disable/enable CPUs. Workaround: N/A Associated Command: priocntl
Limitation: Changing the scheduling parameters of an LWP (using Required Privilege: Impact: Depending upon the nature of your application requirements, your software may need to set the kernel-level scheduling priority of a LWP. Workaround: N/A Associated Command: pset_create, pset_destroy, pset_assign, pset_bind, pset_setattr, processor_bind
Limitation: These functions control the creation and management of sets of processors. Since processors are systemwide resources, manipulation of them from within a zone is not allowed. Required Privilege: Impact: Software that takes advantage of SMP systems to bind LWPs to a specific set of processors for performance, concurrency or resource control reasons. Your software may limit itself to the number of processors it can run on for licensing reasons. Workaround: You can set up a resource pool using Associated Command: shmctl
Limitation: Required Privilege: Impact: This can have an impact on software that needs to lock memory. For instance, a database program may want to lock memory to keep data table buffers in non-pageable memory for performance reasons. Workaround: If the reason you are locking memory is for performance, you may want to investigate the use of the Intimate Shared Memory (ISM) feature of Solaris ( socket
Limitation: Attempts to create a raw socket with protocol set to Required Privilege: Impact: This will impact software that is using the raw socket interface to implement network protocols or software that needs to create/inspect TCP/IP headers. Workaround: N/A Associated Command: N/A swapctl
Limitation: Cannot add ( Required Privilege: Impact: Any software that needs to add or remove swap resources will be affected. This will most likely affect your installation and configuration. Workaround: Swap space is a systemwide resource, therefore it has to be configured from the global zone. Associated Command: uadmin
Limitation: The Required Privilege: Impact: This could impact software that may want to force a crash dump under certain conditions. Workaround: N/A Associated Command: Library Functions
Not unlike system calls, because of the restricted privileges of a process in a zone, certain library calls may return errors. In most cases, clock_settime
Limitation: Cannot set the Required Privilege: Impact: Realtime software is most likely affected by the inability to set the clock. Workaround: N/A cpc_bind_cpu
Limitation: This function binds the set to the specified CPU and measures events occurring on that CPU regardless of which LWP is running. This is not allowed in a zone because you could monitor the CPU events of processes not in your zone. The call fails because the function tries to open up a special file in the Required Privilege: Impact: This could impact your development environment. For instance, you could be making calls to Workaround: The mlock, munlock, mlockall, munlocall, plock
Limitation: Cannot use these library functions to lock and unlock memory. This is the same issue as for Required Privilege: Impact: This can have an impact on software that needs to lock memory. For instance, a database program may want to lock memory to keep data table buffers in non-pageable memory for performance reasons. It should be noted that locking memory can cause certain
Dynamic Reconfiguration events (for example, those invoked using the Workaround: If you are locking a shared memory segment, the workaround described in pthread_setschedparam
Limitation: Cannot change the underlying scheduling policy and parameters for a thread. This is the same issue as for Required Privilege: Impact: Depending upon the nature of your application requirements, your software may need to set the kernel-level scheduling priority of a thread and the underlying LWP. Workaround: N/A timer_create
Limitation: Cannot create a timer using the high-resolution system clock ( Required Privilege: Impact: Software that requires high-resolution timers. Workaround: N/A t_open
Limitation: The Required Privilege: Impact: This will also impact software that is using the Workaround: N/A Libraries
The API that the following list of libraries provide, is not supported in a zone. The shared objects are present in the zone's
Devices
Zones have a restricted set of devices, consisting primarily of pseudo devices that form part of the Solaris programming API. These include
The following list of devices are not visible in the namespace of a non-global zone. Except for
Networking
Each non-global zone has its own logical network and loopback interface. Bindings between upper layer streams and logical interfaces are restricted such that a stream may only establish bindings to logical interfaces in the same zone. Likewise, packets from a logical interface can only be passed to upper layer streams in the same zone as the logical interface. Bindings to the loopback address are kept within a zone with one exception: when a stream in one zone attempts to access the IP address of an interface in another zone. While applications within a zone can bind to privileged network ports, they have no control over the network configuration, including IP addresses and the routing table. Not all software works properly in a local zone. This section examines how to detect and diagnose the source of the execution problem and how to make the software work, perhaps by disabling features, when it is running in a local zone. Detecting Software Breakages in a Local Zone
When a system call fails with a permission error, it is not always immediately obvious what caused the problem. To debug such a problem, you can use a tool called privilege debugging. When privilege debugging is enabled for a process, the kernel reports missing privileges on the controlling terminal of the process. (Enable debugging for a process with the
The Solaris 10 OS offers a number of tools that you can use to identify and inspect at runtime the system/library calls that your application issues. We will explore three such tools, Once you have identified a system or library call that may not work in zone, you can inspect the argument list by using
The following example illustrates the use of
The
Same program using DTrace, executing from the global zone. The DTrace probe,
If a non-global zone is not available for testing, you could test your software in the global zone with the privileges not available in a non-global zone removed from the privilege set of the program using the Defensive Programming and Error Reporting
When Is It Sensible to Have Different Behavior in a Local Zone?
Some software cannot work in a non-global zone completely as it does in the global zone. An example is the This is an example of software that should work differently depending on if it is running in a global zone or a non-global zone. It would be great if the Similarly, it is easy to imagine applications that use other zone-restricted system calls could disable features when executed in a non-global zone. This allows the software to run properly to the extent that is possible while not pushing the burden of diagnosing the failure onto the user of that software. Detecting Execution in a Local Zone
Once the decision has been made that your software requires zone awareness, perhaps for the reasons mentioned above, an API is provided for zone identity.
A definition of the global zone ID,
Executing the code from the global zone:
Executing the code from a non-global zone redzone:
There are two issues that could cause the installation of your software to fail.
When a zone is created, two options are available to create the root file system of the zone, the Sparse Root and Whole Root models. The Whole Root model provides the maximum configurability by installing all of the required and any selected optional Solaris software packages into the private file systems of the zone. The advantages of this model include the ability for zone administrators to customize their zone's file-system layout (for example, creating a The Sparse Root model optimizes the sharing of objects by installing only a subset of the root packages (those with the Any installation software that needs to install components in The second issue deals with the CD-ROM device. There are a couple of ways to gain access to the CD-ROM. One popular method is to loopback mount the
If you use this method and your installation requires multiple CD volumes, you will need to eject CDs from the global zone. Any explicit ejects of the CD-ROM device ( Solaris Packages
Each zone maintains its own package and patch database. A package or a patch can be installed individually into a non-global zone or to all zones from the global zone. The behavior of packaging in a zone environment varies according to the following factors:
Table 2 shows the behavior of packaging in a zone environment, with variances according to factors.
Legend: An "invalid option combination" means the package attribute settings do not make sense - not all possible combinations of settings for these three attributes are legal. They should be caught by An "operation not allowed" means the Configuration Issues
Getting your software to work in a zone is only part of the challenge. System administrators must understand how to configure their zone appropriately for the software they intend to run. There are many possible configurations of zones, and this section does not go through all of the various possibilities. Instead, this section focuses on strategies for targeting useful configurations and communication of the required zone configuration to your software administration audience. Zones can be configured in many different ways. As mentioned before, a Sparse Root Zone takes advantage of files that are shared between the global zone and the non-global zone (such as The default zone configuration is a Sparse Root Zone with very few devices provisioned into the zone. The directories that are shared with the global zone (with a read-only loopback mount) are Starting from this default zone configuration, it is important to discover and document the configuration necessary to deploy your software successfully in a zone. If your installation includes writing to the read-only directories, a software modification should be considered. If the software cannot be modified to work around the problem, configure the zone accordingly. Remember that you are identifying the most restrictive environment in which your software can be installed and executed. From there, more liberal configurations will present no trouble. Be sure to keep track of all elements of the required zone configuration. This should include removing inherited directories, device configuration, and network requirements. This information should be included in your install documentation or any relevant configuration guides. The configuration details that fall out of using this strategy will aid system administrators who are faced with the task of configuring a single non-global zone for multiple software libraries and applications. By stating the minimum requirement for each piece of software, the minimum zone configuration for a set of software would simply be all of the minimum zone configuration requirements for each respective software package put together. This scheme simplifies the task of planning required resources for deployment of zones. Once you have identified the most restrictive zone configuration for the deployment of your software, you should verify that your software works correctly in that configuration. A non-global zone is a more restricted environment than the global zone. This is true in terms of permission to call various system calls as well as the ability to use specific devices or to modify the contents of specific directories. You can use this fact to your advantage as you move to support the Solaris 10 OS with global and non-global zones. Rather than potentially double your QA test matrix to add local zone support, you can do your QA only in the non-global zone. Rest assured that if the software works completely and correctly in the non-global zone, it will in the global zone as well. After the QA within the non-global zone, simply verify that the deployment works correctly in the global zone and you are all set.
Paul Lovvik, who has been with Sun for seven years, is lead engineer in a group in the Market Development Engineering organization focused on partner adoption of the Solaris OS for x86 Platforms. Paul and his engineering team have helped many partners add Solaris on x86 support to their products over the past year. Joseph Balenzano has been with Sun for seven years. His current role is engineer in a group in the Market Development Engineering organization focused on partner adoption of the Solaris OS for x86 Platforms. He has over 20 years of software development experience working for ISVs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||