Skip to contentSkip to conversation

2.6.11-rc3-mm2

DISCUSSION Jack O'Quin 10 participants 33 messages Feb 10, 2005 – Feb 14, 2005

lore
Share & tools
lore
#0 lore raw

[direct reply bounced, resending via gmail]

Quoted 12 lines · Andrew Morton
Quoted 11 lines · Christoph Hellwig
Quoted 8 lines · Andrew Morton

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.11-rc3/2.6.11-rc3-mm2/

- Added the mlock and !SCHED_OTHER Linux Security Module for the audio guys. It seems that nothing else is going to come along and this is completely encapsulated.

Quoted 7 lines
Quoted 4 lines

Even if we accept a module that grants capabilities to groups this isn't fine yet because it only supports two specific capabilities (and even those two in different ways!) instead of adding generic support to bind capabilities to groups.

I'm sure that got discussed somewhere in the 1000 emails which flew past last time. Jack?

[adding cc: for the main discussion participants]

Most people felt that a more general capabilities module would be nice to have. But, no one offered any code, or volunteered to work on it.

I have no objection to that approach, but am not willing or able to do it myself. My opinion is that expanding the scope of the LSM would significantly increase its security risk. That job needs to be done very carefully, by someone with a deep understanding of the kernel's internal use of capabilities.

Perhaps, Christoph's suggestion could become part of a more general module, which might replace the RT-LSM in the 2.8 timeframe. Our LSM is a modest solution aimed at solving the immediate needs of audio developers and users with minimal impact on kernel security or correctness.

#1 lore raw
Quoted 21 lines · Jack O'Quin

[direct reply bounced, resending via gmail]

Quoted 17 lines · Andrew Morton
Quoted 15 lines · Christoph Hellwig
Quoted 8 lines · Andrew Morton

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.11-rc3/2.6.11-rc3-mm2/

- Added the mlock and !SCHED_OTHER Linux Security Module for the audio guys. It seems that nothing else is going to come along and this is completely encapsulated.

Even if we accept a module that grants capabilities to groups this isn't fine yet because it only supports two specific capabilities (and even those two in different ways!) instead of adding generic support to bind capabilities to groups.

Quoted 7 lines
Quoted 2 lines

I'm sure that got discussed somewhere in the 1000 emails which flew past last time. Jack?

[adding cc: for the main discussion participants]

Most people felt that a more general capabilities module would be nice to have. But, no one offered any code, or volunteered to work on it.

What happened to the RT rlimit code from Chris?

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#2 lore raw
Quoted 1 line · * Matt Mackall ([email protected]) wrote:

What happened to the RT rlimit code from Chris?

I still have it, but I had the impression Ingo didn't like it as a long term solution/hack (albeit small) to the scheduler. Whereas the rt-lsm patch is wholly self-contained.

thanks,
-chris

Signature · 1 line
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net
#3 lore raw
Quoted 6 lines · Chris Wright
Quoted 1 line · * Matt Mackall ([email protected]) wrote:

What happened to the RT rlimit code from Chris?

I still have it, but I had the impression Ingo didn't like it as a long term solution/hack (albeit small) to the scheduler. Whereas the rt-lsm patch is wholly self-contained.

I think it's important to recognize that we're trying to address an issue that has a much wider potential audience than pro audio users, and not very far off - what is high end audio performance today will be expected desktop performance next year.

So I think it's critical that we find solution that's appropriate for _every single box_, because realistically vendors are going to ship with this "wholly self-contained" feature turned on by default next year, at which point the "containment" will be nil and whatever warts it has will be with us forever.

The rlimit stuff is not perfect, but it's a much better fit for the UNIX model generally, which is a fairly big win. Having it in the system unconditionally doesn't trigger the gag reflex in quite the same way as the LSM approach.

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#4 lore raw
Quoted 19 lines · Matt Mackall
Quoted 6 lines · Chris Wright
Quoted 1 line · * Matt Mackall ([email protected]) wrote:

What happened to the RT rlimit code from Chris?

I still have it, but I had the impression Ingo didn't like it as a long term solution/hack (albeit small) to the scheduler. Whereas the rt-lsm patch is wholly self-contained.

I think it's important to recognize that we're trying to address an issue that has a much wider potential audience than pro audio users, and not very far off - what is high end audio performance today will be expected desktop performance next year.

So I think it's critical that we find solution that's appropriate for _every single box_, because realistically vendors are going to ship with this "wholly self-contained" feature turned on by default next year, at which point the "containment" will be nil and whatever warts it has will be with us forever.

Quoted 5 lines

The rlimit stuff is not perfect, but it's a much better fit for the UNIX model generally, which is a fairly big win. Having it in the system unconditionally doesn't trigger the gag reflex in quite the same way as the LSM approach.

Without considering the userspace aspect, RT rlimits is the best implementation I have seen. All others either break RT scheduling semantics, or don't allow any way for root to maintain control of the system after giving out RT privileges.

http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.

#5 lore raw
Quoted 30 lines · Nick Piggin
Quoted 21 lines · Matt Mackall
Quoted 7 lines · Chris Wright
Quoted 1 line · * Matt Mackall ([email protected]) wrote:

What happened to the RT rlimit code from Chris?

I still have it, but I had the impression Ingo didn't like it as a long term solution/hack (albeit small) to the scheduler. Whereas the rt-lsm patch is wholly self-contained.

I think it's important to recognize that we're trying to address an issue that has a much wider potential audience than pro audio users, and not very far off - what is high end audio performance today will be expected desktop performance next year.

So I think it's critical that we find solution that's appropriate for _every single box_, because realistically vendors are going to ship with this "wholly self-contained" feature turned on by default next year, at which point the "containment" will be nil and whatever warts it has will be with us forever.

Quoted 5 lines

The rlimit stuff is not perfect, but it's a much better fit for the UNIX model generally, which is a fairly big win. Having it in the system unconditionally doesn't trigger the gag reflex in quite the same way as the LSM approach.

Quoted 4 lines

Without considering the userspace aspect, RT rlimits is the best implementation I have seen. All others either break RT scheduling semantics, or don't allow any way for root to maintain control of the system after giving out RT privileges.

Personally, I think that the best approach to solving this problem is from the privileges aspect. The ability to grant privileges to only set RT policy is just an example of a general need for granting limited privileges to a program and/or a user. So a solution that involved a mechanism for granting a specified subset of root privileges to specified users when running specified programs would have wider application.

My limited understanding of SELinux (which may be mistaken) is that it provides a basic framework for this level of privilege control and perhaps the solution lies there.

Peter

Signature · 4 lines
Peter Williams                                   [email protected]

"Learning, n. The kind of ignorance distinguishing the studious."
 -- Ambrose Bierce
#6 lore raw

[ the best solution is .... ]

[ my preferred solution is ... ]

[ it would be better if ... ]

[ this is a kludge and it should be done instead like ... ]

did nobody read what andrew wrote and what JOQ pointed out?

after weeks of debating this, no other conceptual solution emerged that did not have at least as many problems as the RT LSM module, and all other proposed solutions were also more invasive of other aspects of kernel design and operations than RT LSM is.

--p

#7 lore raw
Quoted 6 lines · Paul Davis

[ the best solution is .... ]

[ my preferred solution is ... ]

[ it would be better if ... ]

Quoted 9 lines

[ this is a kludge and it should be done instead like ... ]

did nobody read what andrew wrote and what JOQ pointed out?

after weeks of debating this, no other conceptual solution emerged that did not have at least as many problems as the RT LSM module, and all other proposed solutions were also more invasive of other aspects of kernel design and operations than RT LSM is.

Sure, it is quick and easy. Suits some. At least I do prefer this to altering the semantics of realtime scheduling.

I can't say much about it because I'm not putting my hand up to do anything. Just mentioning that rlimit would be better if not for the userspace side of the equation. I think most were already agreed on that point anyway though.

Nick

#8 lore raw
Quoted 19 lines · Nick Piggin
Quoted 6 lines · Paul Davis

[ the best solution is .... ]

[ my preferred solution is ... ]

[ it would be better if ... ]

Quoted 9 lines

[ this is a kludge and it should be done instead like ... ]

did nobody read what andrew wrote and what JOQ pointed out?

after weeks of debating this, no other conceptual solution emerged that did not have at least as many problems as the RT LSM module, and all other proposed solutions were also more invasive of other aspects of kernel design and operations than RT LSM is.

Quoted 7 lines

Sure, it is quick and easy. Suits some. At least I do prefer this to altering the semantics of realtime scheduling.

I can't say much about it because I'm not putting my hand up to do anything. Just mentioning that rlimit would be better if not for the userspace side of the equation. I think most were already agreed on that point anyway though.

I think that the rlimits are a good idea in themselves but not as a solution to this problem. I.e. having a RT CPU rate rlimit should not be a sufficient (or necessary for that matter) condition to change policy to SCHED_OTHER or SCHED_RR but could still be used to limit the possibility of lock out. (But I guess even that is a violation of RT semantics?)

Peter
PS Zaphod's per task hard/soft CPU rate caps (which are the equivalent of an rlimit on CPU usage rate) are only enforced for SCHED_NORMAL tasks and should not (therefore) effect RT semantics.

Signature · 4 lines
Peter Williams                                   [email protected]

"Learning, n. The kind of ignorance distinguishing the studious."
 -- Ambrose Bierce
#9 lore raw
Quoted 7 lines · Peter Williams
Quoted 4 lines · Nick Piggin

I can't say much about it because I'm not putting my hand up to do anything. Just mentioning that rlimit would be better if not for the userspace side of the equation. I think most were already agreed on that point anyway though.

Quoted 5 lines

I think that the rlimits are a good idea in themselves but not as a solution to this problem. I.e. having a RT CPU rate rlimit should not be a sufficient (or necessary for that matter) condition to change policy to SCHED_OTHER or SCHED_RR but could still be used to limit the possibility of lock out.

Ah well that may be a good way to do it indeed. As I said, I don't know much about privileges etc.

But I just want to be clear that I'm not trying to stop RT-LSM going in (if only because I don't care one way or the other about it).

Quoted 3 lines

(But I guess even that is a violation of RT
semantics?)

I'd have to re-read the standard, but it may not be. For example, a compliant system advertises the minimum and maximum priority levels available - you may be able to adjust these based on what the rlimit is set to. On the other hand, yes it may violate the stanards.

Nick

#10 lore raw
In reply to Paul Davis
Quoted 6 lines · Paul Davis

[ the best solution is .... ]

[ my preferred solution is ... ]

[ it would be better if ... ]

Quoted 8 lines

[ this is a kludge and it should be done instead like ... ]

did nobody read what andrew wrote and what JOQ pointed out?

after weeks of debating this, no other conceptual solution emerged that did not have at least as many problems as the RT LSM module, and all other proposed solutions were also more invasive of other aspects of kernel design and operations than RT LSM is.

As I see it, what I said was in support of RT LSM (or at least the approach that RT LSM is taking) so why are you attacking me. I'm on your side :-)

Peter
PS I'm withdrawing the "unprivileged real time" feature from the spa_no_frills and zaphod schedulers in the PlugSched patch as a result of the discussions on SCHED_ISO and RT rlimits because the discussion convinced me that it's the wrong way to go.

Signature · 4 lines
Peter Williams                                   [email protected]

"Learning, n. The kind of ignorance distinguishing the studious."
 -- Ambrose Bierce
#11 lore raw
In reply to Paul Davis
Quoted 6 lines · Paul Davis

[ the best solution is .... ]

[ my preferred solution is ... ]

[ it would be better if ... ]

Quoted 8 lines

[ this is a kludge and it should be done instead like ... ]

did nobody read what andrew wrote and what JOQ pointed out?

after weeks of debating this, no other conceptual solution emerged that did not have at least as many problems as the RT LSM module, and all other proposed solutions were also more invasive of other aspects of kernel design and operations than RT LSM is.

Eh? Chris Wright's original rlimits patch was very straightforward (unlike some of the other rlimit-like patches that followed). I haven't heard the downsides of it yet.

simple rlimits:
logical extension of standard, flexible interface fine-grained per-process access to nice levels and priorities managed with standard tools
fairly broad possible applications
clean enough to be added unconditionally
already doing mlock this way!

RT LSM:
new, narrow magic group interface (module parameters!) boolean granularity of access to all RT levels and maybe mlock potential interesting interaction with other LSMs not orthogonal to mlock
not appropriate for every box out there
requires lsm and (sysfs or modprobe)

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#12 lore raw
Quoted 2 lines · Matt Mackall

Eh? Chris Wright's original rlimits patch was very straightforward [...]

the problem is that it didnt solve the problem (unprivileged user can lock up the system) in any way. So after it became visible that all the existing 'dont allow users to lock up' solutions are too invasive, we went to recommend the solution that introduces the least architectural
problems: RT-LSM.

Ingo

#13 lore raw
Quoted 8 lines · Ingo Molnar
Quoted 2 lines · Matt Mackall

Eh? Chris Wright's original rlimits patch was very straightforward [...]

the problem is that it didnt solve the problem (unprivileged user can lock up the system) in any way.

There are two separate but related problems:

a) need a way to give non-root access to SCHED_FIFO without other privileges

b) would like a way to have RT-like capabilities without risk of DoS

The original rlimits patch solves (a), which is the pressing concern.

The existence of a satisfactory solution to related problem (b) has yet to be demonstrated. And even if a solution for (b) is found that is satisfactory for, say, high end audio users, it may not necessarily be sufficient for everyone who might have wanted SCHED_FIFO for non-root processes. So we still need a solution for (a).

Quoted 4 lines

So after it became visible that all the
existing 'dont allow users to lock up' solutions are too invasive, we went to recommend the solution that introduces the least architectural
problems: RT-LSM.

RT-LSM introduces architectural problems in the form of bogus API. And I claim that if RT-LSM becomes part of the mainline kernel, it -will- become a default feature on the desktop in short order. The fact that it's implemented as an LSM is meaningless if Redhat and SuSE ship it on by default.

So the comparison boils down to putting a magic gid in a sysfs file/module parameter or setting an rlimit with standard tools (PAM, etc). I'm really boggled that anyone could prefer the former, especially since we had almost this exact debate over what became the mlock rlimit!

Here's Chris' patch for reference:

http://groups-beta.google.com/group/linux.kernel/msg/6408569e13ed6e80

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#14 lore raw
Quoted 3 lines · Matt Mackall

Here's Chris' patch for reference:

http://groups-beta.google.com/group/linux.kernel/msg/6408569e13ed6e80

how does this patch solve the separation of 'negative nice values' and 'RT priority rlimits'? In one piece of code it handles the rlimit value as a 0-39 nice value, in another place it handles it as a limit for a 1-100 RT priority range. The two ranges overlap and have nothing to do with each other. [*]

anyway, as long as it doesnt touch the scheduler runtime code (and it doesnt), both types of solutions are fine to me - it's basically the security-subsystem people's call.

if the patch solves the negative-nice-value and the RT-priority issues at once, then it indeed looks more flexible (and more generic) than the LSM solution. [**]

Ingo

[*] one acceptable way to 'merge' the two priority ranges would be to
introduce a unified priority range of 0-139: 0-39 would be for nice values while 40-139 would be for RT priorities 1-99. NOTE: due to rlimit semantics (users can always lower them without any security checks), value 39 _must_ denote nice -20 and value 0 must denote nice +19. I.e. it must strictly in increasing priority order.

[**] in fact, the 'Gnome problem' wrt. suid/gid binaries would be solved
via the rlimit too.

#15 lore raw
Quoted 5 lines · Ingo Molnar
Quoted 2 lines · Matt Mackall

Here's Chris' patch for reference:

Quoted 7 lines
Quoted 1 line

http://groups-beta.google.com/group/linux.kernel/msg/6408569e13ed6e80

how does this patch solve the separation of 'negative nice values' and 'RT priority rlimits'? In one piece of code it handles the rlimit value as a 0-39 nice value, in another place it handles it as a limit for a 1-100 RT priority range. The two ranges overlap and have nothing to do with each other. [*]

Read more closely: there are two independent limits in the patch, RLIMIT_NICE and RLIMIT_RTPRIO. This lets us grant elevated nice without SCHED_FIFO.

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#16 lore raw
Quoted 3 lines · Matt Mackall

Read more closely: there are two independent limits in the patch, RLIMIT_NICE and RLIMIT_RTPRIO. This lets us grant elevated nice without SCHED_FIFO.

ok, indeed.

Ingo

#17 lore raw
In reply to Matt Mackall
Quoted 5 lines · Matt Mackall

So the comparison boils down to putting a magic gid in a sysfs file/module parameter or setting an rlimit with standard tools (PAM, etc). I'm really boggled that anyone could prefer the former, especially since we had almost this exact debate over what became the mlock rlimit!

the big difference to mlock is that for mlock there _is_ a _limit_. For RT scheduling the priority is _NOT_ a _limit_. Okay? So you give the false pretense of this being some kind of resource 'limit', while in fact allowing SCHED_FIFO prio 1 alone enables unprivileged users to lock up the system.

so i could agree with RLIMIT_NICE (which _is_ a limit), but RLIMIT_RTPRIO sends the wrong message. The proper rlimit would be RLIMIT_RT_CPU (the patch i did).

Ingo

#18 lore raw
Quoted 15 lines · Ingo Molnar
Quoted 5 lines · Matt Mackall

So the comparison boils down to putting a magic gid in a sysfs file/module parameter or setting an rlimit with standard tools (PAM, etc). I'm really boggled that anyone could prefer the former, especially since we had almost this exact debate over what became the mlock rlimit!

the big difference to mlock is that for mlock there _is_ a _limit_. For RT scheduling the priority is _NOT_ a _limit_. Okay? So you give the false pretense of this being some kind of resource 'limit', while in fact allowing SCHED_FIFO prio 1 alone enables unprivileged users to lock up the system.

Quoted 3 lines

so i could agree with RLIMIT_NICE (which _is_ a limit), but RLIMIT_RTPRIO sends the wrong message. The proper rlimit would be RLIMIT_RT_CPU (the patch i did).

It's not a perfect fit, I'll readily agree.

But consider this: with RLIMIT_RTPRIO, I can restrict a user to the lowest N RT priorities. Then at N+1, I have an RT watchdog taking care of runaways, tickled by a SCHED_NORMAL task. So it can still be looked at as a meaningful limit, just a bit different from the others.

The RT LSM gives full CAP_SYS_NICE out, so there's no way to guarantee that the watchdog has higher priority.

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#19 lore raw
In reply to Matt Mackall
Quoted 1 line

RT-LSM introduces architectural problems in the form of bogus API. And

that may be true of LSM, but not RT-LSM in particular. RT-LSM doesn't introduce *any* API whatsoever - it simply allows software to call various existing APIs (mostly from POSIX) and have them not fail as result of not being root and/or not running on a capabilities-enabled kernel without the required caps.

No audio apps "use" RT-LSM in any way - it just lets them do things they otherwise could not do. And all the alternatives to RT-LSM have this feature as well - controlling rlimits won't be done by the audio apps, but by some part of the security infrastructure.

Quoted 2 lines

it's implemented as an LSM is meaningless if Redhat and SuSE ship it on by default.

We haven't encouraged anyone to ship anything with it on by default:
the idea is for the module to be present and usable, not turned on.

--p

#20 lore raw
Quoted 7 lines · Paul Davis
Quoted 1 line

RT-LSM introduces architectural problems in the form of bogus API. And

that may be true of LSM, but not RT-LSM in particular. RT-LSM doesn't introduce *any* API whatsoever - it simply allows software to call various existing APIs (mostly from POSIX) and have them not fail as result of not being root and/or not running on a capabilities-enabled kernel without the required caps.

The API is the parameters to modprobe or sysfs.

Quoted 5 lines
Quoted 2 lines

it's implemented as an LSM is meaningless if Redhat and SuSE ship it on by default.

We haven't encouraged anyone to ship anything with it on by default:
the idea is for the module to be present and usable, not turned on.

On as in turned on for build in the kernel config and shipped. But I expect people will eventually actually ship it _on_ with a group called 'rt' and possibly even put the primary user in there on install unless you start slapping some big fat warnings on it. (I just noticed the new Debian installer is putting the primary user in audio, cdrom, video, etc.)

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#21 lore raw
Quoted 11 lines · Matt Mackall
Quoted 7 lines · Paul Davis
Quoted 1 line

RT-LSM introduces architectural problems in the form of bogus API. And

that may be true of LSM, but not RT-LSM in particular. RT-LSM doesn't introduce *any* API whatsoever - it simply allows software to call various existing APIs (mostly from POSIX) and have them not fail as result of not being root and/or not running on a capabilities-enabled kernel without the required caps.

The API is the parameters to modprobe or sysfs.

I think you are talking about the API for root to administer it vs. the (lack of) API for apps to use the RT capabilities. I think Paul's point is that we can transparently replace it with something better (IMO the RT rlimit is better) in the future, and the apps don't have to know about it at all. Comparing it to devfs/udev is bogus because those are way, way more complicated.

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

it's implemented as an LSM is meaningless if Redhat and SuSE ship it on by default.

We haven't encouraged anyone to ship anything with it on by default:
the idea is for the module to be present and usable, not turned on.

Quoted 7 lines

On as in turned on for build in the kernel config and shipped. But I expect people will eventually actually ship it _on_ with a group called 'rt' and possibly even put the primary user in there on install unless you start slapping some big fat warnings on it. (I just noticed the new Debian installer is putting the primary user in audio, cdrom, video, etc.)

Sorry, if the distros are so dumb they need a big fat warning to know that this is not a safe thing to enable by default, at least on anything you would ever consider a multiuser system, then they get what they deserve. If they have half a brain they will use the setgid approach that Ingo suggested, and only enable this for apps like JACK and cdrecord that have been farily well audited and can be trusted to use this feature (for example JACK has the internal watchdog to keep a bad client from locking the system). Really it only makes sense for a distro to enable this if the user selects the "low latency desktop" or "multimedia desktop" or whatever install option and makes clear that this profile is NOT suitable for a multiuser system.

Lee

#22 lore raw
In reply to Matt Mackall
Quoted 10 lines · Matt Mackall
Quoted 5 lines
Quoted 1 line

What happened to the RT rlimit code from Chris?

I still have it, but I had the impression Ingo didn't like it as a long term solution/hack (albeit small) to the scheduler. Whereas the rt-lsm patch is wholly self-contained.

I think it's important to recognize that we're trying to address an issue that has a much wider potential audience than pro audio users, and not very far off - what is high end audio performance today will be expected desktop performance next year.

i disagree that desktop performance tomorrow will necessarily have to utilize SCHED_FIFO. Today's desktop audio applications perform quite good at SCHED_NORMAL priorities [with the 2.6.11 kernel that has more interactivity/latency fixes such as PREEMPT_BKL].

I agree (and hope) that tomorrow's "stock" desktop will be based on today's pro audio architectures, but tomorrows CPUs will be much faster and tomorrows desktop apps dont want to spend 30%+ CPU time on creating audio.

the pro applications will always want to have a 100% guarantee (it really sucks to generate a nasty audio click during a live performance) and want to utilize as much CPU time for audio as needed. They are also clearly the most complex creators of audio so they go far above the normal (and reasonable) CPU-use/latency expectations and tradeoffs of the stock scheduler.

Quoted 5 lines

So I think it's critical that we find solution that's appropriate for _every single box_, because realistically vendors are going to ship with this "wholly self-contained" feature turned on by default next year, at which point the "containment" will be nil and whatever warts it has will be with us forever.

an "RT priorities rlimit" is still not adequate as a desktop solution, because it still allows the box to be locked up. Also, if it turns out to be a mistake then it's already codified into the ABI, while RT-LSM is much less 'persistent' and could be replaced much easier. RT-LSM is also more flexible and more practical. (an rlimit needs changes across a number of userspace components, delaying its adoptation.)

Quoted 2 lines

The rlimit stuff is not perfect, but it's a much better fit for the UNIX model generally, which is a fairly big win. [...]

a 'locked up box' is as far away from the UNIX model as it gets.

perhaps, if the need arises, we can add the RT-throttling sysctl (which still wont give RT priorities to unprivileged users and would serve as a way to throttle privileged RT tasks), which could thus make the RT-LSM solution pretty safe. Right now Jack has its own watchdog thread which should solve most of the lockup situations. Lets not overdesign the solution, especially when we dont yet know how the problem really looks like.

or an even simpler solution for the lockup problem would be a kernel-based RT watchdog. In fact 2.6.11-rc3-mm2 already includes such a watchdog (written by yours truly):

http://kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.11-rc3/2.6.11-rc3-mm2/broken-out/detect-soft-lockups.patch

right now softlockup-detect runs at SCHED_FIFO prio 99 and only prints a warning - but it could easily run at SCHED_FIFO prio 1 [to detect lockups generated by all RT tasks] and it could actively try to renice (or kill) tasks that run for too long. So very likely there will be an easy upstream mechanism for any problem that could arise out of RT-LSM.

Ingo

#23 lore raw
Quoted 6 lines · Ingo Molnar

an "RT priorities rlimit" is still not adequate as a desktop solution, because it still allows the box to be locked up. Also, if it turns out to be a mistake then it's already codified into the ABI, while RT-LSM is much less 'persistent' and could be replaced much easier. RT-LSM is also more flexible and more practical. (an rlimit needs changes across a number of userspace components, delaying its adoptation.)

Putting it into the tree means a gurantee we'll keep it going. It'd probably much better if Jack just keepts it separatly. Especially as his lack of even making it generic shows that he's unwilling to invest work into it that doesn't benfit him personally.

#24 lore raw
In reply to Ingo Molnar
Quoted 10 lines · Ingo Molnar
Quoted 5 lines

I think it's important to recognize that we're trying to address an issue that has a much wider potential audience than pro audio users, and not very far off - what is high end audio performance today will be expected desktop performance next year.

i disagree that desktop performance tomorrow will necessarily have to utilize SCHED_FIFO. Today's desktop audio applications perform quite good at SCHED_NORMAL priorities [with the 2.6.11 kernel that has more interactivity/latency fixes such as PREEMPT_BKL].

Desktop performance tomorrow will want realtime audio AND video. Think simultaneous record and playback of multiple high-definition video streams. There's a demand for this; my company already sells it.

Quoted 6 lines

the pro applications will always want to have a 100% guarantee (it really sucks to generate a nasty audio click during a live performance) and want to utilize as much CPU time for audio as needed. They are also clearly the most complex creators of audio so they go far above the normal (and reasonable) CPU-use/latency expectations and tradeoffs of the stock scheduler.

The pro will want to do his work on a stock desktop system. More importantly, the hobbyist will want to do exactly what the pro is doing on the same system.

Quoted 6 lines
Quoted 5 lines

So I think it's critical that we find solution that's appropriate for _every single box_, because realistically vendors are going to ship with this "wholly self-contained" feature turned on by default next year, at which point the "containment" will be nil and whatever warts it has will be with us forever.

Quoted 6 lines

an "RT priorities rlimit" is still not adequate as a desktop solution, because it still allows the box to be locked up. Also, if it turns out to be a mistake then it's already codified into the ABI, while RT-LSM is much less 'persistent' and could be replaced much easier. RT-LSM is also more flexible and more practical. (an rlimit needs changes across a number of userspace components, delaying its adoptation.)

I'm very suspicious about being able to rip out RT-LSM once it's introduced. See devfs. And I think the adoption barrier thing is a red herring as well: the current users are by and large compiling their own RT-tuned kernels.

Quoted 4 lines
Quoted 2 lines

The rlimit stuff is not perfect, but it's a much better fit for the UNIX model generally, which is a fairly big win. [...]

a 'locked up box' is as far away from the UNIX model as it gets.

Rlimits are already the favored tool for dealing with the classic UNIX DoS:
the fork bomb. Turn off process limits, tada, locked up box.

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#25 lore raw
Quoted 8 lines · Matt Mackall
Quoted 4 lines

i disagree that desktop performance tomorrow will necessarily have to utilize SCHED_FIFO. Today's desktop audio applications perform quite good at SCHED_NORMAL priorities [with the 2.6.11 kernel that has more interactivity/latency fixes such as PREEMPT_BKL].

Desktop performance tomorrow will want realtime audio AND video. Think simultaneous record and playback of multiple high-definition video streams. There's a demand for this; my company already sells it.

Tomorrow's hardware will have enough buffering as today's hardware has for simpler tasks. Repeat after me: it likely _wont_ _need_ SCHED_FIFO. Running tomorrow's hardware on today's boxes indeed pushes the system to its limits, but torrows hardware will be well-balanced just as much as today's is - if nothing else then due to kernel drivers providing a buffering guarantee.

think of SCHED_FIFO on the desktop as an ugly wart, a hammer, that destroys the careful balance of priorities of SCHED_OTHER tasks. Yes, it can be useful if you _need_ a scheduling guarantee due to physical constraints, and it can be useful if the hardware (or the kernel) cannot buffer enough, but otherwise, it only causes problems.

Quoted 2 lines

I'm very suspicious about being able to rip out RT-LSM once it's introduced. [...]

yeah, i somewhat share that view. (despite all the promises from the audio folks - if they are just half as agressive resisting removal as they were pushing integration then it will never be removed ;-)

but i'm not sure how rlimits will contain the whole problem - can rlimits be restricted to a single app (jackd)? The most canonical use of rlimits is per-user (per-group), so the rlimit could end up _widening_ the effects of the hack ...

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

The rlimit stuff is not perfect, but it's a much better fit for the UNIX model generally, which is a fairly big win. [...]

a 'locked up box' is as far away from the UNIX model as it gets.

Rlimits are already the favored tool for dealing with the classic UNIX
DoS: the fork bomb. Turn off process limits, tada, locked up box.

the big difference is that process limits are finegrained and it has a single value (unlimited) that allows the DoS - while the RT-rlimits have _one_ value that is safe, all the other values are unsafe!

Ingo

#26 lore raw
Quoted 6 lines · Ingo Molnar

think of SCHED_FIFO on the desktop as an ugly wart, a hammer, that destroys the careful balance of priorities of SCHED_OTHER tasks. Yes, it can be useful if you _need_ a scheduling guarantee due to physical constraints, and it can be useful if the hardware (or the kernel) cannot buffer enough, but otherwise, it only causes problems.

Agreed. I think something short of full SCHED_FIFO will make most desktop folks happy. But a) we still have to figure out exactly how to do that and b) we still have to make everyone else happy. The embedded folks (me included) would prefer to not run our realtime bits as root too..

Quoted 2 lines

but i'm not sure how rlimits will contain the whole problem - can rlimits be restricted to a single app (jackd)?

Yes. There's also the whole soft limit thing.

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#27 lore raw
Quoted 10 lines · Matt Mackall
Quoted 6 lines · Ingo Molnar

think of SCHED_FIFO on the desktop as an ugly wart, a hammer, that destroys the careful balance of priorities of SCHED_OTHER tasks. Yes, it can be useful if you _need_ a scheduling guarantee due to physical constraints, and it can be useful if the hardware (or the kernel) cannot buffer enough, but otherwise, it only causes problems.

Agreed. I think something short of full SCHED_FIFO will make most desktop folks happy. [...]

ah, but it's not the desktop folks who have to be happy but users :-) Really, if you ask any app designer then obviously 'the more CPU time we get for sure, the better our app behaves'. So in that sense SCHED_OTHER is a fair playground: if you behave nicely you'll have higher priority and shorter latencies.

(there are things like SCHED_ISO but how good of a solution they are is not yet clear.)

Quoted 3 lines

[...] But a) we still have to figure out exactly how to do that and b) we still have to make everyone else happy. The embedded folks (me included) would prefer to not run our realtime bits as root too..

you dont have to - you can drop root after startup.

Quoted 4 lines
Quoted 2 lines

but i'm not sure how rlimits will contain the whole problem - can rlimits be restricted to a single app (jackd)?

Yes. There's also the whole soft limit thing.

i'm curious, how does this 'per-app' rlimit thing work? If a user has jackd installed and runs it from X unprivileged, how does it get the elevated rlimit? (while the rest of his desktop still runs with a safe rlimit.) SELinux/RT-LSM could do this, but i'm not sure about how rlimits give this to you.

Ingo

#28 lore raw
Quoted 29 lines · Ingo Molnar
Quoted 10 lines · Matt Mackall
Quoted 6 lines · Ingo Molnar

think of SCHED_FIFO on the desktop as an ugly wart, a hammer, that destroys the careful balance of priorities of SCHED_OTHER tasks. Yes, it can be useful if you _need_ a scheduling guarantee due to physical constraints, and it can be useful if the hardware (or the kernel) cannot buffer enough, but otherwise, it only causes problems.

Agreed. I think something short of full SCHED_FIFO will make most desktop folks happy. [...]

ah, but it's not the desktop folks who have to be happy but users :-) Really, if you ask any app designer then obviously 'the more CPU time we get for sure, the better our app behaves'. So in that sense SCHED_OTHER is a fair playground: if you behave nicely you'll have higher priority and shorter latencies.

(there are things like SCHED_ISO but how good of a solution they are is not yet clear.)

Quoted 3 lines

[...] But a) we still have to figure out exactly how to do that and b) we still have to make everyone else happy. The embedded folks (me included) would prefer to not run our realtime bits as root too..

you dont have to - you can drop root after startup.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

but i'm not sure how rlimits will contain the whole problem - can rlimits be restricted to a single app (jackd)?

Yes. There's also the whole soft limit thing.

i'm curious, how does this 'per-app' rlimit thing work? If a user has jackd installed and runs it from X unprivileged, how does it get the elevated rlimit?

It needs a setuid launcher. It would be nice to be able to elevate the rlimits of running processes but the API doesn't exist yet.

Quoted 1 line

From the POV of accidental elevation to RT, soft limits are

sufficient. But we can't stop a user from exploiting an app they own with RT privileges from elevating other apps via ptrace+exec or whatever. Nor with RT-LSM.

Quoted 3 lines

(while the rest of his desktop still runs with a safe rlimit.) SELinux/RT-LSM could do this, but i'm not sure about how rlimits give this to you.

How does it get done with RT-LSM? Setgid binaries? It only discriminates on a group granularity. Or are you saying "and SELinux" rather than "or SELinux"?

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#29 lore raw
Quoted 8 lines · Matt Mackall
Quoted 5 lines
Quoted 1 line

Yes. There's also the whole soft limit thing.

i'm curious, how does this 'per-app' rlimit thing work? If a user has jackd installed and runs it from X unprivileged, how does it get the elevated rlimit?

It needs a setuid launcher. It would be nice to be able to elevate the rlimits of running processes but the API doesn't exist yet.

With a setuid launcher you need _zero_ kernel help to get SCHED_FIFO: if you have a launcher then already today it can just give SCHED_FIFO to jackd and be done with it!

Ingo

#30 lore raw
Quoted 9 lines · Ingo Molnar
Quoted 6 lines · Matt Mackall
Quoted 5 lines
Quoted 1 line

Yes. There's also the whole soft limit thing.

i'm curious, how does this 'per-app' rlimit thing work? If a user has jackd installed and runs it from X unprivileged, how does it get the elevated rlimit?

Quoted 6 lines
Quoted 2 lines

It needs a setuid launcher. It would be nice to be able to elevate the rlimits of running processes but the API doesn't exist yet.

With a setuid launcher you need _zero_ kernel help to get SCHED_FIFO: if you have a launcher then already today it can just give SCHED_FIFO to jackd and be done with it!

I'm sure you know all this already but I'll spell it out so we're all clear:

a) rlimits are tracked per-process so they're fundamentally per-process
b) there are hard and soft limits, with soft always <= hard
c) only root can raise hard rlimits, but normal users can lower them
d) if a user owns a process, he can gain the privileges of that process by various means, so in the strict sense per-process privileges are meaningless - all privileges are per-uid
e) so we either need to segregate all privileged processes into separate uid domains
f) or we're assuming non-malicious users and soft limits are sufficient.

Now I suspect we don't want to insist people do (e) (though I'd certainly encourage them to try).

Don't forget that the rlimits approach allows us to reserve the highest priorities for root. I'm pretty sure an effective watchdog policy can thus be implemented in userspace, which RT-LSM can't really offer.

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#31 lore raw
In reply to Matt Mackall
Quoted 3 lines

introduced. See devfs. And I think the adoption barrier thing is a red herring as well: the current users are by and large compiling their own RT-tuned kernels.

not true. most people are using kernels built for specialized distros or addons, such as CCRMA, Demudi, Ubuntu, or dyne:bolic.

--p

#32 lore raw
In reply to Ingo Molnar
Quoted 2 lines · Ingo Molnar

the pro applications will always want to have a 100% guarantee (it really sucks to generate a nasty audio click during a live performance)

... and the "generic kernels" distributions use will follow just as swiftly, as soon as the feature appears stable enough. It even makes sense: no need to switch kernels if "pro audio" applications (or whatever else may end up wanting this) are added to the mix, and fewer configurations to test.

You can run, but you cannot hide :-)

- Werner

Signature · 3 lines
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         [email protected] /
/_http://www.almesberger.net/____________________________________________/