16 ms·
Some problems I see from skimming the docs: > Calls which have no limitations, of which there are only a very few, for example zx_clock_get() and zx_nanosleep(
by naasking 9y ago
Some problems I see from skimming the docs:
> Calls which have no limitations, of which there are only a very few, for example zx_clock_get() and zx_nanosleep() may be called by any thread.
Having the clock be an ambient authority leaves the system open to easy timing attacks via implicit covert channels. I'm glad these kinds of timing attacks have gotten more attention with Spectre and Meltdown. Capability security folks have been pointing these out for decades.
> Calls which create new Objects but do not take a Handle, such as zx_event_create() and zx_channel_create(). Access to these (and limitations upon them) is controlled by the Job in which the calling Process is contained.
I'm hesitant to endorse any system calls with ambient authority, even if it's scoped by context like these. It's far too easy to introduce subtle vulnerabilities. For instance, these calls seem to permit a Confused Deputy attack as long as two processes are running in the same Job.
Other notes on the kernel:
* The focus on handles overall is good though. Some capability security lessons have finally seeped into common knowledge!
* I'm not sure why they went with C++. You shouldn't need dispatching or template metaprogramming in a microkernel, as code reuse is minimal since all primitives are supposed to be orthogonal to each other. That's the whole point of a microkernel. Shapiro learned this from building the the early versions of EROS in C++, then switching to C. C also has modelling and formal analysis tools, like Frama-C.
* I don't see any reification of scheduling as a handle or an object. Perhaps they haven't gotten that far.
Looks like they'll also support private namespacing ala Plan 9, which is great. I hope we can get a robust OS to replace existing antiquated systems with Google's resources. This looks like a good start.
- tines 9y ago> You shouldn't need dispatching or template metaprogramming in a microkernel, as code reuse is minimal since all primitives are supposed to be orthogonal to each other. Orthogonality doesn’t obviate the need for metaprogramming though. For example, there are lots of places you might need a linked list structure, where the nodes store different types. You might use templates over intrusive structures to gain some type safety without duplicating code for each contained type.
- ninkendo 9y agoMore evidence IMO that when people think they need template metaprogramming, what they probably really need is basic collections primitives. Go is a good example of this. (Strings, maps, lists, slices are just done once by the language, you don't get to write your own implementation because there's no generics, but in practice nobody cares.)
- wrinkl3 9y ago> but in practice nobody cares I haven't worked with Go personally, but "no generics" is probably the most commonly vocal complaint I hear about it, so clearly some people do care.
- rrcaptain 9y agoIt's kind of a meme at this point though. Shitting on other people's favorite language is a well honored SWE tradition.
- littlestymaar 9y ago“lol no generics” is the meme. But the lack of generics is a real problem that bothers a lot of people (and several already developed their own solution to work around this problem)
- Touche 9y ago> but in practice nobody cares. Not my observation at all.
- mickronome 9y agoPeople actually do care a lot about the fact that you can't have type safe and thread safe code, or abstractions without tons of synchronization code repeated ad nauseum throughout the code. Multiply that by 10 if you have several junior team members who have been told, and read, that concurrency and parallelism is easy in go.
- 9y ago
- lambda 9y ago> > Calls which have no limitations, of which there are only a very few, for example zx_clock_get() and zx_nanosleep() may be called by any thread. > > Having the clock be an ambient authority leaves the system open to easy timing attacks via implicit covert channels. I'm glad these kinds of timing attacks have gotten more attention with Spectre and Meltdown. Capability security folks have been pointing these out for decades. Is there a way that these could mediated by a capability without having to incur syscall overhead? One of the reasons that these are bare functions is likely that they are in the vDSO, and are just simple function calls which can access some shared memory which contains the clock time. I suppose you could simply not give some processes access to that memory, and have the functions in the vDSO just return an error in that case. I know that there was a time when the Linux kernel changed how their vDSO handling worked, so older glibcs would have to fall back to making an actual syscall for gettimeofday, and that seriously affected performance on some servers that updated the kernel without updating glibc. These functions are called quite often on servers for logging purposes, so adding overhead to make them go through a syscall can be a big performance hit. > I'm hesitant to endorse any system calls with ambient authority, even if it's scoped by context like these. It's far too easy to introduce subtle vulnerabilities. For instance, these calls seem to permit a Confused Deputy attack as long as two processes are running in the same Job. Yeah, this is a bit odd. In fact, it's not just these syscalls which have ambient authority, there's a whole list in https://fuchsia.googlesource.com/zircon/+/master/docs/syscalls/job_set_policy.md https://fuchsia.googlesource.com/zircon/+/master/docs/syscal... and it includes VMOs, ports, sockets, and so on. It does seem somewhat odd to have this capability system, but then ignore it for a number of actions which can only be limited at the job level.
- naasking 9y ago> Is there a way that these could mediated by a capability without having to incur syscall overhead? Is that even warranted? What applications can you imagine would make so many clock calls so as to incur noticeable overhead? Your example of logging costs might work, but I'm very skeptical that user/kernel transition costs for a clock call would drown out the costs of writing the log entry to disk. But to answer your question directly, the ability to access the clock in a shared memory segment can itself be reified as a handle that's granted to a process. The process would then issue a map operation and provide an address at which to map the clock (or you could just always map it at the same address too if that's preferable for some reason).
- eric_h 9y ago> seem to permit a Confused Deputy attack I'd never heard the terms "Confused Deputy" or "ambient authority" before, but it sent me on a pleasant and informative internet security tangent. https://en.wikipedia.org/wiki/Confused_deputy_problem https://en.wikipedia.org/wiki/Confused_deputy_problem
- naasking 9y agoIndeed, we've all seen the confused deputy in the wild. For instance, CSRF is a confused deputy vulnerability.
- framirez 9y agoMIT 6.858 Computer Systems Security, Fall 2014; Session 6: Capabilities https://www.youtube.com/watch?v=TQhmua7Z2cY&index=5&list=PLUl4u3cNGP62K2DjQLRxDNRi0z2IRWnNh https://www.youtube.com/watch?v=TQhmua7Z2cY&index=5&list=PLU... It is a good course.
- temac 9y ago> Having the clock be an ambient authority leaves the system open to easy timing attacks via implicit covert channels. "leaves the system open" are strong words. If you allow only threads you have got high precision clocks as a bonus in practice. Still it could be useful to have environments so restricted that even restricting clock services could be useful, but I would certainly not call the lack of capability there a very big issue. Plus designing those would be hard anyway: does not having this capa would mandatorily prevent from even creating threads (or pretty much all kind of objects which can be retargeted to infer time, which means tons of them, and maybe it being the case or not will depend on the implementation)? Maybe it is better to not pretend that a capability exists for getting the time if you will probably be able to get it without said capability?
- naasking 9y agoClock access via a handle has other uses beyond security. For instance, you could use it for deterministic replay of a process. The point being, any abilities that aren't reified as explicit handles are ambient in the environment, and so make isolation and virtualization harder. Consider how you would virtualize the clock now that it's part of the process's implicit environment instead of an invocation made via a handle.
- adrianratnapala 9y agoThis is a good point. I've seen in practice systems where in hindsight it would have been nice if we had used some virtual clock rather than the machine clock. An OS could help by making the virtualisable clock the default API. Still there will be applications that want a high-precision or low overhead clock. But those applications should buy into the trade-off explicitly.
- naasking 9y agoAgreed! For instance, a realtime clock like you mention could be reified as a clock factory handle, which you must be explicitly given and must invoke to install the clock at a fixed or configurable address (or something along those lines). This is opt-in, efficient and virtualizable.
- bsder 9y ago> Having the clock be an ambient authority leaves the system open to easy timing attacks via implicit covert channels. I'm glad these kinds of timing attacks have gotten more attention with Spectre and Meltdown. Capability security folks have been pointing these out for decades. And the Spectre and Meltdown vulnerabilities have shown that it doesn't matter. Taking access to a clock or sleep mechanism away doesn't stop the bad guys but makes common programmers lives much more difficult.
- naasking 9y ago> Taking access to a clock or sleep mechanism away doesn't stop the bad guys but makes common programmers lives much more difficult. You don't take it away, you reify the clock as a capability/handle. This has two benefits: 1. Those vulnerabilities have shown that you can mount timing attacks even without a clock, but a clock amplifies the timing attacks you can mount. For instance, there remain attacks with a clock even if Spectre and Meltdown and related vulnerabilities are fixed. 2. There are software engineering benefits. For instance, in principle you can replace the clock handle with a proxy that you can use to provide your own times. This helps considerably with testing, deterministic replay, etc.
- kllrnohj 9y agoC++ has far more to offer over C than just template metaprogramming. Basic memory management and error handling, for example, are radically easier and less error prone in C++ than in C. Less reliance on macros and goto's should be pretty obvious wins. There's really very little reason to ever use C over C++ with modern toolchains.
- naasking 9y ago> Basic memory management and error handling, for example, are radically easier and less error prone in C++ than in C. Microkernels don't need memory management. Dynamic memory management in a kernel is a denial of service attack vector. Fuschia is built on a microkernel, so I expect they will follow the property of every microkernel since the mid 90s: no dynamic memory allocation in the kernel, all memory needed is allocated at boot. Furthermore, you don't want exceptions in kernel code. That carries huge and surprising runtime execution and space costs. Simply put, there is no reason to choose C++ for a microkernel, and many, many reasons not to.
- stouset 9y agoLet’s say I take your assertions at face value. Supposedly qualified, intelligent engineers who were no doubt aware of these points still decided C++ was an appropriate language to implement this microkernel. Surely there’s a reason. Why?
- naasking 9y ago> Supposedly qualified, intelligent engineers who were no doubt aware of these points Are they aware of them? That's not so clear. There's a lot of literature in microkernel design. Lots of things have been tried which sound good but haven't worked out, and some things didn't work out well before would work well now. As usual, security also rarely gets the attention it deserves and it's doubly important at the kernel level.
- s2g 9y ago
- dblohm7 9y ago> The focus on handles overall is good though. Some capability security lessons have finally seeped into common knowledge! Huh? NT has done this for 25 years.
- naasking 9y agoI don't think these are the same thing, but please do provide a link discussing NT's use of handles.
- dblohm7 9y agohttps://msdn.microsoft.com/en-us/library/windows/desktop/ms724485(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms7...
- naasking 9y agoThanks. None of the creator functions take the handles needed, which is contrary to capability security. This leaves the system vulnerable to DoS attacks at the very least.
- dblohm7 9y agoCreation of those objects is also implicit on checking the current thread's access token and the current process's job (if present). So I think it has the same concerns that you outlined in an earlier comment about Fuchsia's creator functions.
- naasking 9y agoInteresting that the fuchsia kernel design seems to mimic the NT kernel in this regard...
- naasking 9y agoThere are also other issues I just remembered. Handles in a capability OS have no access control applied to them, ie. if you hold a handle, then you have permission to invoke operations on that handle. Attenuating authority involves deriving a new handle from an existing one with reduced rights, then passing that around. I believe the NT kernel still checks permissions against ACLs for handles. This violates capability security, but you can build a capability OS on top of ACLs: http://www.webstart.com/jed/papers/Managing-Domains/ http://www.webstart.com/jed/papers/Managing-Domains/