Merging the realtime security module
The code in question is the realtime security module, which was covered briefly here last September. This module, when loaded, makes a simple change to the Linux protection mechanism: any process running with a designated group ID is given the CAP_SYS_NICE, CAP_IPC_LOCK, and CAP_SYS_RESOURCE capabilities. Thus, any user who has membership in the special group can raise priorities, lock pages into physical memory, and exceed resource limits. With these capabilities, a suitably aware audio application can ensure that it will be able to respond to events within the required time.
A couple of objections have been raised to the inclusion of the realtime module. One is that it is a specialized hack for a specific set of users which has no place in a general-purpose kernel. The GID-based mechanism is seen as being ugly and hard to administer in the long term. A few kernel hackers have been quite vocal in their opinion that, until these issues have been addressed, this module should not be merged. They have been less vocal, however, on just how audio users should satisfy their needs without offending the sensibilities of the kernel community.
Nonetheless, some progress has been made. The memory locking issue has been solved via the new resource limits which were added in 2.6.9. By setting the limits appropriately, a system administrator can allow otherwise unprivileged users to lock a bounded number of pages into physical memory. A bit of PAM configuration work should suffice to deal with that part of the problem.
The other issue, however, is response time from the CPU scheduler. Ingo Molnar has noted that the kernel's handling of regular "nice" levels is much improved in 2.6.10. Audio hacker Jack O'Quin checked it out and found that things had improved, though the maximum response time was still far worse than can be had by running in the SCHED_FIFO class. The reasons for this behavior are still being investigated; interference from high-priority kernel threads may be part of the problem. Even if the response were adequate, however, raising priorities is still a privileged operation.
That issue could, perhaps, be addressed via yet another resource limit which would allow individual users to raise their priorities within an administrator-set of bounds. If the remaining response time issues could be addressed, this new limit could be part of the overall solution, though it would take some time for updated utilities to get into the hands of the users who need them.
Another approach which has been mentioned would be to generalize the realtime module to address a wider range of needs. If it could be set up to hand out any set of capabilities to given users or groups, it would at least be useful to more people. It could, for example, replace the current group-based hack which gives access to the "hugetlb" mechanism. It would still be setting policies in the kernel by way of user and group IDs, which is not a popular idea, but it would not be quite the niche tool that it is now. A first pass at such a module has been posted by Olaf Dietsche; it takes an interesting approach by having much of the relevant information stored in the form of group ownership on sysfs attributes.
A more comprehensive solution would be to make capabilities work properly. After all, that is what capabilities are supposed to be for: to allow precisely-defined bits of privilege to be granted in the situations where they are needed. The problems there are that Linux capabilities are currently broken, fixing them is a tricky job that nobody seems to want to take on at the moment, and, in any case, administering a truly capability-based system is an exercise in complexity. Capabilities seem unlikely to be part of the solution anytime soon.
One interesting aspect of the discussion is what has not been mentioned. SELinux should be able to solve this problem; it exists to provide ultimate control over what every user and program can do. Nobody, however, has wanted to see what happens when musicians attempt to administer SELinux, it would seem. The realtime preemption work has also been strangely absent from the discussion - and from the kernel mailing lists in general.
As of this writing, no real solution seems to have been found. There are
enough kernel hackers sympathetic to the needs of audio hackers, however,
that some sort of resolution should be possible. Linux should be the
ultimate playground for audio developers; it would be a shame if the kernel
continued to get in their way. (For more background, see this history of the realtime LSM by Jack
O'Quin).
Index entries for this article | |
---|---|
Kernel | Latency |
Kernel | Modules/Security modules |
Kernel | Realtime |
Kernel | Security/Security modules |
(Log in to post comments)
The capabilities-based solution
Posted Jan 14, 2005 17:05 UTC (Fri) by giraffedata (guest, #1954) [Link]
A more comprehensive solution would be to make capabilities work properlyAs a promoter of capabilities, I'd like to expand on this.
The proper Linux alternative to hardcoding certain capabilities to a certain group ID in the kernel is a "setcap" program. That's the equivalent of a classic setuid program in a classic system where privileges are attached to uid (to wit, uid 0). The setcap program has capabilities attached to it. Any process that executes that program gets those capabilities. So you'd just install one of these and give execute permission to the group ID of your choice.
I have this running on my systems, with a few lines of change to the base kernel and a program interpreter loadable module. I feel a lot safer with virtually no "superuser" processes.
But I agree with the article that there seems to be little interest in fine-grained capabilities, and little hope that a usable capability system will show up in a mainstream Linux kernel in the foreseeable future.
The capabilities-based solution
Posted Jan 17, 2005 23:17 UTC (Mon) by Ross (guest, #4065) [Link]
One thing I have often wanted are capability flags for permissions whicharen't traditionally reserved for root. Things like opening sockets,
creating files, executing programs, running ptrace, forking, etc. I've
often wanted to take _away_ those capabilities but there really isn't a way
to do so...