News for hackers. Stuff that matters.
Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @09:35AM (#9062365)
It's really nice to see that happening, but every time I raised the subject with the Gnome team to see how we could run VLC in it, it's a no-go.

Indeed, for a complete media player, I need:

- access to files not directly opened by the user (playlists, MKV, DCP, MXF),

- access (and unique probably) to raw devices read-only (DVD, AudioCD, Blu-Rays, webcams-v4l2, SDI, DVB),

- direct access to raw audio output,

- access to X11 for YUV output, or at least a direct OpenGL context,

- access to network.

For access to files and network, there seemed to be a solution with a manifest to get $home access; for audio, a solution might come with kdbus and pulseaudio; but for the others, they refuse blankly, saying that my "use case is irrelevant and dangerous".

I hope this will evolve (maybe it already has), but so far, it's a bit hard to make a complete media player, tbh.

Re:First fully sandboxed Linux desktop app by alexlarsson on Tuesday February 17, 2015 @10:37AM (#9062755)
It all depends on what your goal is. Allowing to run VLC as a bundle with more or less full access is certainly possible. However, that is not really "sandboxed" in any fashion.

For instance, once any client has any kind of X11 access they can snope any kind of keyboard events, including your password at the unlock screen.

If we want to support the full functionallity for a media player in a sandboxed way we need to start looking into each requirement and designing a safe way to access each item. This is gonna be a lot of work, but I don't see any way around that.

For your exact list:

Files access can either be granted to the app fully or partially. But we also want some kind of file selector service that runs in the session (outside the sandbox) that grants some kind of access to files the user chose.

Raw device access will not happen by just having the app open the raw device nodes. Instead we'll have some kind of service in the session that (via user interaction or "remembered" grants from the user) virtualizes access to these things. This could be all from e.g. passing a file descriptor of the opened dvd device to a complete replacement of the subsystem. For an example of the later, for webcams see the pulse-video project: https://github.com/wmanley/pulsevideo

Is raw audio output necessary? Why does not pulseaudio work?

OpenGL access is supported

Network access is (optionally, but i think this will be on for most apps) allowed

Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @11:11AM (#9062978)
> It all depends on what your goal is.

Well, we've seen sandboxes on other desktop platforms (OSX, WinRT, ChromeOS), and so far, they all are horribly limiting. So, I'm making sure the same does not happen on Linux, before we get kicked out of our own platform.

> kind of file selector service that runs in the session (outside the sandbox) that grants some kind of access to files the user chose.

This is not enough, as explained above.

> Raw device access will not happen by just having the app open the raw device nodes. Instead we'll have some kind of service in the session that (via user interaction or "remembered" grants from the user) virtualizes access to these things.

Well, this is a deal breaker so far. Are you going to do a pulsedvd, a pulsecd, a pulsedvb, a pulsesdi for all the access modules? Playing encrypted DVD requires direct access, as far as I know.

> For an example of the later, for webcams see the pulse-video project: https://github.com/wmanley/pulsevideo

Something using GStreamer in Vala to get indirect access to webcams? I don't see how this could even work: how do you control brightness or other webcam controls from two applications, how do you get direct H26x access with preview synchronized? (And asking someone to use a competitive project to get video input is also a bit rude, but that's beside the subject)

> Why does not pulseaudio work?

libpulse requires X, as far as I know.

> OpenGL access is supported

Through Wayland? How do I get YUV surfaces? What about overlay? What about VDPAU/VAAPI? I guess this will get a lot of improvement, because wayland, wl_scaler (et al) are very limited, so far.

We'll see how it fares, but from the past interactions, the answers were pretty dismissive; and therefore, I'm not that optimistic about the outcome.

Re:First fully sandboxed Linux desktop app by alexlarsson on Tuesday February 17, 2015 @12:17PM (#9063489)
>> kind of file selector service that runs in the session (outside the sandbox) that grants some kind of access to files the user chose. >This is not enough, as explained above.

Well, its hard to say that as this kind of stuff is not designed yet. Better to say that the requirements of VLC on the design of this are more complex than just the "allow access to single-picked-file" semantics. Hopefully we can take this into account when we look into the details here.

> Well, this is a deal breaker so far. Are you going to do a pulsedvd, a pulsecd, a pulsedvb, a pulsesdi for all the access modules? Playing encrypted DVD requires direct access, as far as I know.

Some of these need not necessarily be as complex as you imagine though. They could very well be some kind of thin service that enumerates the real devices and hands over the opened FD to your app after having verified that it is allowed.

> libpulse requires X, as far as I know.

Libpulse can optionally be built with X, but this is really only used to read back the pulse socket name from the x root property. It works just fine without X (witness the non-X, but pulseaudio using demo in the blog post for instance).

OpenGL access is via DRI, but yeah, output to the screen will have to happen via wayland. That could use subsurfaces with YUV surfaces, and it is then up to the compositor to use overlays if possible (i know weston does this for instance).

For VDPAU etc, i don't really know.

Re:First fully sandboxed Linux desktop app by greggman on Tuesday February 17, 2015 @04:34PM (#9065194)
Maybe I'm missing it but I don't see how DRI is really sandboxing OpenGL.

Note: I helped write the OpenGL sandbox in Chrome and it's certainly possible I don't know the details of DRI enough to understand how it sandboxes but I do know what we had to do to sandbox OpenGL in Chrome, that includes re-writing shaders since we can't trust the driver, clearing buffers since OpenGL doesn't and so you can read other processes' data, and many other things and as far as I can tell DRI isn't doing things like that.

Re:First fully sandboxed Linux desktop app by alexlarsson on Wednesday February 18, 2015 @02:38AM (#9067429)
At the moment we grant all of /dev/dri, but long term we want only the render nodes accessible. That gives us no modesetting or DRM master capabilities, only rendering.

It is true though that the drivers could very well have leaks in them, but the userspace sandbox is not the place to fix that, it is the drivers themselves. The intent is for the dri driver APIs to give guarantees about client separation, but I'm sure it needs work.

Re:First fully sandboxed Linux desktop app by greggman on Wednesday February 18, 2015 @05:30PM (#9071403)
The drivers will never be fixed. Chrome doesn't trust them. It's not in their interest to fix them since sales are determined by performance not by security.
Re:First fully sandboxed Linux desktop app by lunixbochs on Tuesday February 17, 2015 @05:06PM (#9065420)
I'm pretty sure DRI doesn't do anything special to the OpenGL calls, so they just get punted into the scary binary client library from your GPU vendor.
Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @03:13PM (#9064649)
> Hopefully we can take this into account when we look into the details here.

This is all I'm asking, and not the usual "I don't care about your usecase, you should just use GStreamer" that we get from the Gnome/RedHat/Systemd team.

Re:First fully sandboxed Linux desktop app by ANTSANTS on Tuesday February 17, 2015 @01:31PM (#9064041)
Yeah, the possibility of a "gatekeeper effect" is what's worrisome here. There's no way you can anticipate everything a user might want to do with their computer, so while opt-in sandboxing can only help, mandatory sandboxing could stifle the creativity of developers who must go through a gatekeeper (even a benevolent one) any time they want to ship a program that uses hardware or software abstractions in some unforeseen way.

Or alternatively, Joe User goes "[grumble grumble] guess I gotta delete that dang PulsePolicyD that's keepin' me from runnin' muh binaries [copies and pastes the first command found when googling "how i run X" into shell]" and it's all for naught.

Re:First fully sandboxed Linux desktop app by bkor on Wednesday February 18, 2015 @04:21AM (#9067649)
> I'm making sure the same does not happen on Linux, before we get kicked out of our own platform.

To make one thing very clear: Sandboxing is partly intended to be an additional way to distribute software. Majority of the packages come from your distribution. This sandboxing (together with other bits) would allow you to distribute your application eventually 80% of the various Linux distribution users. I think it'll take some time because there's a lot of things to work out (e.g. relying on Wayland, kdbus, change Pulseaudio to use kdbus, etc).

A user should have control on what an application can do, but that's something new and user might highly prefer such applications (e.g. not allowing an application to just modify ~/.bashrc and adding some evil sudo alias if it feels like it).

IMO at most you'd have some package software which shows for VLC: "unrestricted access". The intention is to offer more security where possible to the user while at the same time it's not too difficult for the developer.

Re:First fully sandboxed Linux desktop app by jbk on Wednesday February 18, 2015 @04:45AM (#9067718)
> To make one thing very clear: Sandboxing is partly intended to be an additional way to distribute software. Majority of the packages come from your distribution.

This is not what we understand from your GnomeOS talks and systemd "distributions are obsolete" posts.

Re:First fully sandboxed Linux desktop app by MaulingMonkey on Tuesday February 17, 2015 @01:57PM (#9064214)
>> kind of file selector service that runs in the session (outside the sandbox) that grants some kind of access to files the user chose.

> This is not enough, as explained above.

If the file chooser is powerful enough, couldn't it be?

I don't use VLC playlists at all, but I could e.g. grant read-only ~/music/.../*.mp3 (edit: apparently I can't double star) access, and that'd be enough for my music playlists as far as I'm concerned.

Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @03:15PM (#9064663)
> If the file chooser is powerful enough, couldn't it be?

Experience from OS X and WinRT is that they aren't powerful.

> I don't use VLC playlists at all, but I could e.g. grant read-only ~/music/.../*.mp3

What about mkv linked files or .mpc lossless complements? Or cue/bin complements?

What about m3u that have mp3, ogg and flac interleaved?

It's not that simple.

Re:First fully sandboxed Linux desktop app by MaulingMonkey on Tuesday February 17, 2015 @08:13PM (#9066422)
> Experience from OS X and WinRT is that they aren't powerful.

And I'm not suggesting that the current state of things is sufficient.

> What about mkv linked files or .mpc lossless complements? Or cue/bin complements? > What about m3u that have mp3, ogg and flac interleaved?

In my case? As I don't use these formats, these are signs of bad things are happening (fishing for file format specific overflows in the parser?), and it is that simple.

Presumably, if I did use those formats, the ability to grant ~/music/.../.{mp3,ogg,flac} or ~/music/ is not a huge step from granting access to *.mp3. If it is, your codebase is suffering from some serious bitrot... I sympathize, but whitelisting isn't the problem at that point.

We already deal with some of this, with dialogs prompting us about which file types we want to associate with our media players. Reuse and retool those, profit?

Re:First fully sandboxed Linux desktop app by jbk on Wednesday February 18, 2015 @04:48AM (#9067721)
> In my case? As I don't use these formats, these are signs of bad things are happening (fishing for file format specific overflows in the parser?), and it is that simple.

You don't use mkv or playlists with mixed content? You don't use subtitles?

> the ability to grant ~/music/.../.{mp3,ogg,flac} [...] If it is, your codebase is suffering from some serious bitrot... I sympathize, but whitelisting isn't the problem at that point.

Your first idea is that our codebase is bitrot? Seriously?

> which file types we want to associate with our media players. Reuse and retool those, profit?

And you know, it's been a long time we don't rely on extensions for format detection.

Sorry, but your comment is very arrogant (limit insulting), and you speak of things you don't understand.

Re:First fully sandboxed Linux desktop app by MaulingMonkey on Friday February 20, 2015 @10:35PM (#9084560)
> You don't use mkv or playlists with mixed content? You don't use subtitles?

No MKV, mp3-only playlists, and then only subtitles I use are those embedded within the .avi / .mp4. I'll certainly admit I'm not VLC power-user.

> Your first idea is that our codebase is bitrot? Seriously?

You've chopped far too much context. I'm assuming your codebase supports neither whitelist in it's current form - reasonable, nothing needs it yet. That is my first idea.

I'm also meaning to imply that you're overstating how difficult it would be, if your codebase did support interacting with the standbox to request .mp3 whitelisting, to request other formats as well. That is my second idea.

My third* idea, at best, is that your codebase has bitrot. This is not me intending to slight you, your project, your contributors, your former contributors, or any of the choices involved. This is not me saying I am better than any of that. This is me, where half of my last job was dealing with bitrot, some caused by my own hand - trying to relate, while trying to identify where such a hypothetical, assumed to be serious problem, would actually lay.

> And you know, it's been a long time we don't rely on extensions for format detection.

You might not, but windows still does. Is this dialog gone?

http://cdn5.howtogeek.com/wp-content/uploads/2013/02/vlc-fil...

> Sorry, but your comment is very arrogant (limit insulting), and you speak of things you don't understand.

I apologize if it came off that way, and for touching a nerve. But please understand me. The sin you're looking for is Envy, not Arrogance, within me if you've had that leisure - of dealing only with pristine codebases without serious problems.

Re:First fully sandboxed Linux desktop app by gknoy on Tuesday February 17, 2015 @04:21PM (#9065106)
Then you'd grant access to ~/my-media-collection/ , or to each of the filetypes in your collection.
Re:First fully sandboxed Linux desktop app by wlesieutre on Tuesday February 17, 2015 @02:55PM (#9064554)
Double star makes italics on whatever's in between them, but you should be able to escape them with backslashes like this * *.
Re:First fully sandboxed Linux desktop app by wlesieutre on Tuesday February 17, 2015 @02:58PM (#9064573)
That actually took a couple of edits with inconsistent results. Sometimes it actually prints the backslash? \* \*.

And it definitely likes having a space in between, otherwise the second slash gets styled in italics. Curious.

Re:First fully sandboxed Linux desktop app by MaulingMonkey on Tuesday February 17, 2015 @08:49PM (#9066542)
Yeah, double backslash was the first edit I tried :)
Re:First fully sandboxed Linux desktop app by weland on Tuesday February 17, 2015 @10:51AM (#9062845)
> Is raw audio output necessary? Why does not pulseaudio work?

I don't know if this applies to VLC, too, but raw audio output (or something that isn't PulseAudio) is necessary wherever low (or at least constant) latency is required.

Edit: oh - now that I look at your username, I believe congratulations are in order re. the subject of this thread :)?

Re:First fully sandboxed Linux desktop app by alexlarsson on Tuesday February 17, 2015 @10:56AM (#9062871)
PulseAudio can be very low latency. Here are some docs on how to set this up: http://www.freedesktop.org/wiki/Software/PulseAudio/Document...

That said, I don't think a video player needs low latencies. It can generally have pretty large buffers.

Re:First fully sandboxed Linux desktop app by pdkl95 on Tuesday February 17, 2015 @04:59PM (#9065368)
That link seems to encourage raising the latency, which suggests the needs of people like musicians are not being considered at all. Your use-cases are not the only use cases that exist.

The entire world of music production uses JACK, which got the design right well before PulseAudio even existed. It can provide synchronous operation to prevent drifting between audio tools. I include mplayer2 as one of those tools for s few things. More importantly, JACK guarantees a reliable very, very low latency audio path.

How "low latency" do I mean? Consider that in printed music, while somewhat uncommon, quite a few pieces have been written that use 128th notes. That would be anywhere from ~80ms to ~10ms note lengths, depending on the tempo. Larger latencies mean notes being heard as a different note from what was played, and I keep JACK down to about 5ms latency, and would set it lower if I could afford new hardware. Notes are not the only feature of musinc, and some headroom is needed. Any latencies higher than about 10ms-20ms I would consider broken and unusable.

(Incidentally - I cannot play GuitarHero/RockBand on most TVs either because of horrible latench. A (60Hz) video, a two frame delay is a "miss" on the harder songs. those 16.6ms latencies are nasty regardless which direction the latency is being added)

Beyond that, JACK is a great API. It makes it trivial to do a LOT of the common needs (i.e. "Just give me the audio samples..." or "just let me write new audio data and not have to worry about anything else... such as timing")

Re:First fully sandboxed Linux desktop app by alexlarsson on Wednesday February 18, 2015 @02:45AM (#9067439)
Raising the latency is what you want in many cases. For instance, the current discussion is about a video player. There is no need for a video player to submit new data every 10ms, because it knows exactly what it will be playing for the next N seconds (depending on the buffer size it uses). Waking up every 10ms just causes more cpu and power use and risks missing the deadline.

Of course, there are cases where you do need lower latencies, such as games where interactive feedback cause the sound to change, or when you pause a movie. In those cases you adjust the latency (possibly temporarily in the case of the pause).

That said, PulseAudio has a different set of requirements and thus design decisions from Jack. It is not meant to be used in music production, but then again, I doubt the music producers will use some sandboxed app to do music production either. So, I don't see the problem here.

Re:First fully sandboxed Linux desktop app by weland on Tuesday February 17, 2015 @12:49PM (#9063748)
I think VLC also does recording, but I'm certainly in no position to comment on it. I'm not familiar with their codebase and I don't want to lie :).

I don't know what PulseAudio considers "very low latency" and there aren't any numbers on that page to indicate it, but in my experience, PA's best latency possibilities are about an order of magnitude away from being useful for any kind of hardcore real-time processing. This isn't a problem as far as PA is concerned since it's not what it was conceived for, but it won't cut it for applications which need that kind of capability.

PA also doesn't really provide latency guarantees, either. In fact, it's mentioned on that page:

> So in summary: tell PA what latency you want, but program defensively so that you can deal with getting both lower or higher measured latencies.

I don't know if that has improved though. The last time I had to poke PulseAudio was a few months before that page's "Last Edited" timestamp.

Edit: For what it's worth: I never managed to get PA to consistently keep latency below 25-30 ms, which is at least 10-15 ms away from being adequate for real-time audio processing. I guess it is a cornercase though, and probably outside the Gnome project's interests. Reading the other comments in this thread, I assume VLC's problems with PA aren't related to latency.

Re:First fully sandboxed Linux desktop app by riskable on Tuesday February 17, 2015 @12:28PM (#9063575)
Just to clarify: No one cares if a video player has low-latency audio as long as the audio latency matches the video latency. As in, it totally sucks when the words coming out of an actor's mouth don't line up with the audio.

The only place where low-latency matters is real-time encoding situations. For example, video conferencing, composing music, streaming things live, etc but even in those situations "low" is a relative term. Low-latency video conferencing is anything under 200-500ms (depending on who you ask). Low-latency music composition is <20ms (again, depending on who you ask).

Re:First fully sandboxed Linux desktop app by banjax on Wednesday February 18, 2015 @04:31AM (#9067673)
Even <20ms is being somewhat generous. I'd just like to see progress TOWARD <20ms on the Android platform. I've been watching this ticket for six years: https://code.google.com/p/android/issues/detail?id=3434
Re:First fully sandboxed Linux desktop app by Torgo on Tuesday February 17, 2015 @11:01AM (#9062907)
>once any client has any kind of X11 access they can snope any kind of keyboard events, including your password at the unlock screen.

Wayland fixes this.

Re:First fully sandboxed Linux desktop app by asveikau on Tuesday February 17, 2015 @11:48AM (#9063249)
> For instance, once any client has any kind of X11 access they can snope any kind of keyboard events, including your password at the unlock screen

Is this true? Can you provide a proof of concept that can attack xscreensaver in this way? I was not under the impression that xscreensaver in particular is vulnerable to such an attack. I would like to see the code.

> Is raw audio output necessary? Why does not pulseaudio work?

Funny story, I have never gotten pulseaudio to successfully play any audio. Every so often I read somewhere that pulse makes audio scenario xyz really easy. I try it out and I cannot get any audio samples out to the sound card, period. The only other time I hear about pulse is when I'm telling people to kill it, which ends up fixing all their audio problems. So no thanks to pulse.

Meanwhile I can't help but think that Unix already has a security model for talking to devices, it is called enforcing security at open(2). What is bad about letting an app talk to alsa if it needs audio? If you can provide an example, is that not a privilege escalation in alsa that should be fixed?

It just strikes me that your article here is a technical solution in search of a problem. Apple did sandboxing so it must be right, huh?

Re:First fully sandboxed Linux desktop app by alexlarsson on Tuesday February 17, 2015 @12:28PM (#9063574)
> Is this true? Can you provide a proof of concept that can attack xscreensaver in this way?

I believe this should work: https://github.com/magcius/keylog

> What is bad about letting an app talk to alsa if it needs audio?

In general, audio output is not really a problem. However, input is much more problematic. For instance, your app could listen on your microphones and send the data over the network. Permissions on the audio device doesn't work here, especially considering that such permissions are per-user, not per-app.

Overall the security model in unix is pretty shit for the desktop. Its all about protecting root or other users from the user. However, if I'm on a single user laptop that is not overly interesting. The much more interesting part is protecting the user from the system. For instance by being able to run a game without it ever having the possibility of reading my personal email or web history.

Re:First fully sandboxed Linux desktop app by asveikau on Tuesday February 17, 2015 @01:15PM (#9063951)
> I believe this should work: https://github.com/magcius/keylog

Interesting. Only works if the RECORD extension is enabled, however. Seems some distros have that off by default and have for years.

Re:First fully sandboxed Linux desktop app by agwa on Tuesday February 17, 2015 @10:58AM (#9062883)
Instead of sandboxing the entire app, you should use privilege separation inside VLC. Low-risk code would run in processes with higher privileges, while the high-risk code (e.g. the decoders) would run in highly sandboxed processes and communicate with the privileged processes over a simple interface. This is the approach used by security-conscious server apps (e.g. openssh, postfix, dovecot) as well as Google Chrome, and I think it has more promise than trying to sandbox entire apps. Many apps have complex access requirements (much more than the game used as an example in this blog post) and trying to sandbox them will require granting so much privilege that the sandbox becomes almost meaningless.

I'm currently working on converting a PDF viewer to use privilege separation. I'd love to see a media player use privilege separation too. Does VLC currently have pretty clear separation between its various components? Do you think it be much work to spin security-conscious parts like the decoders into separate processes?

Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @11:18AM (#9063032)
It's a good question. But hard.

> Does VLC currently have pretty clear separation between its various components?

Very clear separation. One of the best, tbh.

> Do you think it be much work to spin security-conscious parts like the decoders into separate processes?

Extremely difficult. We've thought about it.

For a video player the 3 parts that are sensitive, are protocols (file, http), demuxers (mkv, avi) and decoders.

The crashes mostly happen in protocols and demuxers, but not in decoders (a contrario from what people think).

The main issue is that the video decoder MUST be in the same process than the video output, for performance reasons (buffer sharing: memcpy is murder) and for hardware decoders. And video output are usually with very high access in the kernels. Moreover video outputs are almost necessarily in the process with the UI thread.

For audio output, it's not good either, although some platforms are better (pulseaudio+Kdbus might work).

Re:First fully sandboxed Linux desktop app by chubot on Tuesday February 17, 2015 @11:45AM (#9063213)
The main issue is that the video decoder MUST be in the same process than the video output, for performance reasons (buffer sharing: memcpy is murder)

Why not used shared memory? I believe that's what Chrome uses for its rendering buffers. The renderer is sandboxed and shares buffers with the X11 process.

EDIT, used to use: https://codereview.chromium.org/298443002/

Still, it appears it used this method for a long time, so it seems feasible.

Also, Chrome has multiple video playing paths, including Flash, which is sandboxed, so I don't see the difference. The Flash video has to be decoded in a sandbox. I imagine HTML5 video is sandboxed somehow too.

It is very platform-specific and difficult, and performance is a prime concern, but not impossible.

Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @03:17PM (#9064677)
> Why not used shared memory?

Because this is not normal shared memory, this is GPU shared memory. This is hard to port.

Re:First fully sandboxed Linux desktop app by alexlarsson on Tuesday February 17, 2015 @03:22PM (#9064709)
Can you not use dma-buf and EXT_image_dma_buf_import?
Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @03:34PM (#9064776)
Maybe, but that's quite not portable, and driver specific, AFAIK.
Re:First fully sandboxed Linux desktop app by comex on Tuesday February 17, 2015 @03:49PM (#9064852)
Forgive me for a short rant, but this sort of thing is one reason I think other kernels should look at OS X's virtual memory interface for inspiration. There, you can always share any existing mapped page with another process, regardless of how it was allocated. Usually useful because it reduces the need to redo the way you allocate some (regular) memory just because you want to use it a certain way (sharing), but it works with driver-mapped pages too.
Re:First fully sandboxed Linux desktop app by alexlarsson on Tuesday February 17, 2015 @03:51PM (#9064875)
Sharing a normal memory mapping is not necessarily what is required here though. What you want is to share the same GPU-side memory buffer between two processes. It may not even be mappable to cpu side memory.
Re:First fully sandboxed Linux desktop app by comex on Tuesday February 17, 2015 @04:10PM (#9065031)
If it's mapped into the CPU address space, then it can be shared. If not, then there is a copy going on and you may as well just do it in the non-sandboxed process, no?
Re:First fully sandboxed Linux desktop app by alexlarsson on Wednesday February 18, 2015 @02:34AM (#9067417)
There is no copy. You have a reference to a GPU side buffer, and you want to pass a reference to that buffer to another process, where it will continue to use the GPU to access it.
Re:First fully sandboxed Linux desktop app by agwa on Tuesday February 17, 2015 @11:49AM (#9063261)
> The main issue is that the video decoder MUST be in the same process than the video output, for performance reasons (buffer sharing: memcpy is murder) and for hardware decoders.

I was afraid that this was the case. Might shared memory be a viable solution to buffer sharing?

In any case, it makes me really happy to know that you've thought about this!

Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @03:19PM (#9064690)
> I was afraid that this was the case. Might shared memory be a viable solution to buffer sharing?

It's GPU allocated memory, so not so sure.

> In any case, it makes me really happy to know that you've thought about this!

If you have ideas, we'd love to work on it, seriously.

Re:First fully sandboxed Linux desktop app by alexlarsson on Tuesday February 17, 2015 @12:33PM (#9063624)
> The main issue is that the video decoder MUST be in the same process than the video output, for performance reasons (buffer sharing: memcpy is murder) and for hardware decoders. And video output are usually with very high access in the kernels. Moreover video outputs are almost necessarily in the process with the UI thread.

Did you look into the new memfd support in the kernels? Seems like this is a pretty cool way to do process splitting while sharing memory in a "safe" way. (i.e. the recieving side can guarantee that the sending side is not playing silly-buggers with the buffers while you read them).

For hardware decoders, maybe using dmabuff buffers shared between multiple processes would work?

Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @03:18PM (#9064684)
> For hardware decoders, maybe using dmabuff buffers shared between multiple processes would work?

This is not portable, but this is a possible solution for Linux.

But this is far from being ready, which is one of my main point :)

Re:First fully sandboxed Linux desktop app by alexlarsson on Wednesday February 18, 2015 @02:47AM (#9067447)
Well, the sandboxing stuff is not ready either. We need work on all levels of the stack to make this stuff work.
Re:First fully sandboxed Linux desktop app by Estragon on Tuesday February 17, 2015 @12:40PM (#9063688)
I'm curious, have there been bugs in VLC which would allow arbitrary code execution on linux? What about the video player in google chrome?
Re:First fully sandboxed Linux desktop app by cocoablazing on Tuesday February 17, 2015 @12:58PM (#9063822)
Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @03:19PM (#9064697)
Yes for both.
Re:First fully sandboxed Linux desktop app by nhaehnle on Tuesday February 17, 2015 @02:08PM (#9064295)
Keep in mind that privilege separation does not cover all possible use cases of sandboxing.

Privilege separation is an answer to the question: "I have a program whose authors I trust even though they are fallible, and the program needs to process untrusted data"

In desktop scenarios, I really want an answer to the question: "I have a program whose authors I don't trust, but I want to run it anyway"

For that, you really need full sandboxing; privilege separation is not enough.

Re:First fully sandboxed Linux desktop app by bkor on Tuesday February 17, 2015 @10:19AM (#9062646)
If you want raw access to devices, X11, etc, then it is not so simple. The media players I use talk to Pulseaudio, not directly to audio. Various of your needs go pretty much against sandboxing. It's much easier to focus first on applications instead of these needs. For instance, fully sandboxing and X11 won't work anyway.

It seems pretty impossible to create something which: 1) does sandboxing 2) has no limitations on what an application can do

Edit: What I meant is: Is it possible to lower your requirements or change how VLC works/can do when it is sandboxed?

Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @11:22AM (#9063075)
> Is it possible to lower your requirements or change how VLC works/can do when it is sandboxed?

Maybe for some, but not for others. You really need to be able to open a file without file opener. Opening optical disks is really important too. I don't get why read-only access to a device poses so much threats but I'm probably missing something.

FYI, so far, libpulse links to x11.

Re:First fully sandboxed Linux desktop app by sp332 on Tuesday February 17, 2015 @11:47AM (#9063238)
Low-level access to a device would let you read data from files that you don't have permission to read at the filesystem level.
Re:First fully sandboxed Linux desktop app by asveikau on Tuesday February 17, 2015 @12:04PM (#9063390)
You can set different permissions for different devices, you are aware of that right? I can say my DVD drive is readable by gid x, but not the partitions on my hard disk... This is already what Linux distros are doing.
Re:First fully sandboxed Linux desktop app by edohyiez on Tuesday February 17, 2015 @12:16PM (#9063482)
Then the media player can read every DVD you put into your drive as long as its running. So you always have to close the media player before inserting a DVD containing private files. That probably isn't that important for DVDs, but for other devices (e.g. microphone, webcam) it certainly is.
Re:First fully sandboxed Linux desktop app by tormeh on Tuesday February 17, 2015 @04:43PM (#9065262)
>You really need to be able to open a file without file opener

What if you had read/write access to /home/user/music and /home/user/video ? Once we start adding blanket access like this we would probably need to add a /home/user/secret folder that no application can access unless invited to a specific file by a file opener.

Re:First fully sandboxed Linux desktop app by rogerbinns on Tuesday February 17, 2015 @10:39AM (#9062771)
Note that you are requiring all of this in the same/single app. Instead it could be broken down into multiple compartmentalized apps, each doing one thing with simple permissions, and all cooperating. For example one app could do the raw device access, but have no other access including networking. Another does networking but no local access. Another is the renderer to video and audio. Another does UI etc.
Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @11:19AM (#9063038)
And how do you share the buffers between the apps?
Re:First fully sandboxed Linux desktop app by rogerbinns on Tuesday February 17, 2015 @12:21PM (#9063522)
The desktop environment already has to provide a means of interprocess/component communication, so it gets solved there. You can already see something similar in Chrome where functionality like rendering is done in separate processes.
Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @03:22PM (#9064703)
No it has not. 0-copy shared buffer don't exist yet for most video usecases.
Re:First fully sandboxed Linux desktop app by rogerbinns on Tuesday February 17, 2015 @04:03PM (#9064961)
Are you saying it is completely impossible? Or that they haven't done it yet? The former would be a big problem, and the latter is just about the right apis, driver models etc.
Re:First fully sandboxed Linux desktop app by jbk on Wednesday February 18, 2015 @04:49AM (#9067725)
> Are you saying it is completely impossible?

Nothing is impossible, this is software. But it's far far far from being ready.

Re:First fully sandboxed Linux desktop app by em3rgent0rdr on Tuesday February 17, 2015 @03:41PM (#9064810)
for such security, you should use something like Qubes OS (https://qubes-os.org/) which uses Xen to sandbox apps into different domains (VMs), and keeps the networking stack in a seperate VM, disk storage in a seperate VM, DE in a seperate VM, etc.
Re:First fully sandboxed Linux desktop app by zanny on Tuesday February 17, 2015 @01:41PM (#9064102)
With Wayland and dbus and all the techs going into a modern Linux desktop, it is probably very doable to prompt users when a program tries to open a file with a simple "Application X wants to open file Y in location Z, let it? Yes / No / Allow for all contents of Z / Allow All Locations".

That would be a misnomer, because "important" file locations like ~/.config, ~/.share, etc would always prompt user acknowledgement when a program tries to open something in those and it is not the originator program (ie, VLC can open something like ~/.config/vlc or ~/.share/vlc, but if it tried to open ~/.config/mplayer or ~/.share/mplayer you would get a prompt notification of it.

> access (and unique probably) to raw devices read-only

I don't think this is hard at all, device permissions are something that mostly already works. Just say "App X wants to access device Y, allow? Yes / No / Always".

With good package management and distributors, you could have most of these "prompts" configured with sane defaults so you don't get spam when VLC opens files - the distro can just trust VLC in ~/Music and ~/Video all the time, and any user made directories, so just give it access everywhere except the config and share dirs, so on and so forth. When you install something it would make sense to tell users what it uses in the same way Android does upon installation, and if it tries to access something post-install you get a dialog about it (ie, VLC could say at install it uses the network, or it could ask at runtime if it tries to access the network).

Why would VLC need raw audio out? Route through pulseaudio, nobody should be opening raw audio devices anymore unless you are Ardour.

I think the real problem is nobody gives a shit about desktop security. I mean I run Archlinux where there isn't a single working MAC solution that does not require days of prep work. But having delved a lot into Mac and such, I have no faith in Apparmor or SELinux when PAX and Grsec is doing a much better job and nobody is using it. And they all have holes somewhere, either they don't have fine grained device permissions, or lack tunables, or don't harden the kernel enough to avoid simple exploits. Its a mess nobody is really trying to solve upstream of security implementations and distros are doing a half assed job about it across the board.

Re:First fully sandboxed Linux desktop app by thanksgiving on Tuesday February 17, 2015 @09:52AM (#9062465)
How do they expect you to access the network? Can a web browser or an FTP client be sand boxed in the current scheme?
Re:First fully sandboxed Linux desktop app by jbk on Tuesday February 17, 2015 @09:59AM (#9062511)
So far, I am not sure, but I think a flag in the manifest will allow a pure networking access ("Use the host network namespace").
Re:First fully sandboxed Linux desktop app by digi_owl on Thursday February 19, 2015 @12:00AM (#9072468)
Yeah, if this sandboxing is anything like the Storage Access Framework that Google introduced in Android 4.4, i'll pass...
Re:First fully sandboxed Linux desktop app by tracker1 on Tuesday February 17, 2015 @06:59PM (#9066081)
what's wrong with having a service layer that isn't sandboxed, and an application layer that is?

What's stopping you from running your filesystem and network requests through a local service... you can sandbox all the rendering and other access, and tighten controls on your service interface.

Re:First fully sandboxed Linux desktop app by upofadown on Tuesday February 17, 2015 @12:13PM (#9063469)
Why would you want to sandbox an open source program like VLC? This sort of thing is mostly useful to allow the running of proprietary binaries that could be hostile in some way. You are not going to care that much if you can trust a program not to attack other programs.
Re:First fully sandboxed Linux desktop app by ANTSANTS on Tuesday February 17, 2015 @01:00PM (#9063851)
Media players are rather large programs that users feed lots of untrusted data (gigabytes of pirated movies/tv shows/porn from suspect sources etc) into. All it takes is one exploitable bug in your media player of choice (or more likely, in a hardware-accelerated codec it uses) and one maliciously malformed video for your home directory to be nuked, keylogger to be installed, or worse.
Re:First fully sandboxed Linux desktop app by riskable on Tuesday February 17, 2015 @12:35PM (#9063641)
Don't think of it like, "I need to protect against hacking" think of it like, "I need to make sure processes cannot control each other unless explicitly allowed to do so."

Hypothetical: A vulnerability in Chrome could allow a remote attacker the ability to read/write arbitrary files on your filesystem. /tmp/.X11-unix/X0 for example. This could let them cause all sorts of havoc on your X11 display including controlling/compromising other running programs (and capturing your keystrokes).

If Chrome were sandboxed as described in the article such an attack would not be possible without first breaking out of the sandbox.

Re:First fully sandboxed Linux desktop app by cplease on Tuesday February 17, 2015 @12:32PM (#9063607)
Non "hostile," as you put it, software still has bugs. Attackers can use malicious inputs to exploit buggy software.

Unless you personally built software from trusted source with a trusted toolchain, or reverse-engineered and inspected the binary package you are installing, you have no more confidence that your installed binary package is not malicious than any proprietary binary blob. Even presuming the maintainer and packager is not malicious (and why would you trust a random open source maintainer more than a random proprietary maintainer?), there have been cases in the past where repositories have compromised and with malicious packages inserted. These are just the ones we know about. Signatures help but don't solve anything; especially with distributed projects, keys can be compromised in any number of ways. And don't help with malicious actors.

That said, I don't see sandboxing Linux apps as particularly revolutionary. Users, ACLs, and chroots have been around for ages. While not especially sugary, they are pretty effective. For full-on app sandboxing, Android is Linux, and they've been doing this since 2008. The average Linux desktop user has legitimate reasons they don't want to sandbox any given desktop app to this extent. On the server side, "sandboxing" in the form of "separation of privileges" has been standard best practice in the UNIX realm as long as Richard Stallman's beard. This is just not particularly interesting. More interesting to me is what has been done for sandboxing in the browser, most especially Chrome.

Re:First fully sandboxed Linux desktop app by edohyiez on Tuesday February 17, 2015 @12:36PM (#9063650)
> The average Linux desktop user has legitimate reasons they don't want to sandbox any given desktop app to this extent.

Could you expand on that?

Re:First fully sandboxed Linux desktop app by cplease on Tuesday February 17, 2015 @02:46PM (#9064506)
It depends on what you mean by "sandboxing" and "app." But basically, with a browser or mobile app, there's a limited number of functions that you may want to permit an app to access, and it's okay to isolate the rest of the app to its own little world. With desktop apps, you generally want to be able to use apply them broadly to all your user data, or you will quickly be frustrated with them.

Deeper-level sandboxing of splitting the app up into bipartite high and low-security/complexity components, as with the Chrome browser, requires a lot of engineering for the particular application and can't simply be dropped in place on a given off-the-shelf Linux app.

Coarser-level application-specific permissions in the form of AppArmor profiles, installing daemons as their own users with chroots etc, is already available and deployed. The technology to go further with it is already there.

Re:First fully sandboxed Linux desktop app by edohyiez on Tuesday February 17, 2015 @03:34PM (#9064768)
I actually don't want all desktop apps to be able to access all my data all the time. E.g. why should LibreOffice be able to access my browsing history, or Gimp be able to read the contacts in my address book, or VLC be able to read my e-mails? I don't see the difference between desktop and mobile/web apps in this respect.

Of course it's important that the sandbox doesn't frustrate you or lead you to blindly click "Allow" all the time. It would obviously be bad if you get a dialog asking "Application X wants to open file Y. Allow/Deny" whenever an app attemts to access a file. But I don't think that that's the only way to design a sandbox.

For the simple case of opening a file with an app, it could be enough if the app calls a trusted file-chooser outside the sandbox which then returns an opened fd to the file the user chose. Then the user wouldn't even notice that there was a sandbox. Of course that's not enough for all usecases (see some other comments from jbk about VLC).

Re:First fully sandboxed Linux desktop app by cplease on Tuesday February 17, 2015 @04:30PM (#9065163)
> I actually don't want all desktop apps to be able to access all my data all the time. E.g. why should LibreOffice be able to access my browsing history, or Gimp be able to read the contacts in my address book, or VLC be able to read my e-mails? I don't see the difference between desktop and mobile/web apps in this respect.

You do want LibreOffice, Gimp, VLC, and your webbrowser to be able to save and open their respective media files in your home folder, right? And you want might want them to be able to actually work together, right? Such as opening a file you downloaded in the browser. Whether the file chooser is inside your application or outside your application doesn't make it any safer, it's the fact that the application has the ability to open and read/write the files.

What you seem disturbed by is that one application can access configuration and state data belonging to another application. Because they are just files, belonging to the same user. Well, I suppose if such a policy made you feel better, you could always change the AppArmor profiles to only allow an application to modify its own dotfiles, dotdirectory, e.g., fooapp can't touch ~/.* except ~/.fooapp. That's not a terrible idea, although if you are so distrustful of it to begin with and still want to run it you should probably sandbox it in its own filesystem altogether. And this will break some interoperability.

Re:First fully sandboxed Linux desktop app by edohyiez on Tuesday February 17, 2015 @05:46PM (#9065669)
Yes, I want applications to be able to open files and to work together, but only if that's needed to achive what I want them to do. LibreOffice should be able to open (and read from and write to) any .odt-file that I want to edit. But since to do that it doesn't need to have access to my browsing history, I don't want it to have access to that. Is it weird that I want that?

> Whether the file chooser is inside your application or outside your application doesn't make it any safer, it's the fact that the application has the ability to open and read/write the files.

Yes, it does. If the file chooser is inside the application, it needs to be able to open the chosen file, i.e. an arbitrary path, at any time. If the file chooser is outside the sandbox, the application only gets the open fd and can't open files itself (open(2) would simply fail). That is a huge difference!

> What you seem disturbed by is that one application can access configuration and state data belonging to another application.

Yes, I am disturbed by that and I am certainly not alone. There simply is no reason why it should be that way, apart from backwards-compatibility. Why should I have to trust the hundreds of millions of lines of code in all the applications on my machine, if such a huge amount of trust is not necessary to achive the desired outcome?

And sure, application sandboxing can already be achived with AppArmor or SELinux (or a multitude of other systems), but it requires manual work (afaik no major distribution comes with this out of the box) and (as you correctly write) it breaks interoperability. The goal of this "Gnome app sandbox" isn't to be the first application sandbox, but to provide the possibility to enable this by default for certain applications and to keep interoperability. That last part is mostly a research project, so I don't expect this to be finished any time soon.

Re:First fully sandboxed Linux desktop app by detaro on Tuesday February 17, 2015 @05:41PM (#9065640)
A file chooser outside the application is safer if the sandbox enforces that only selected files are opened. Of course I want the app to be able to read files I told it to open, but it shouldn't be able to access files I haven't selected.
Re:First fully sandboxed Linux desktop app by pmontra on Tuesday February 17, 2015 @06:09PM (#9065814)
How about the sub files with the same name of the video file you selected? Some players open them automatically and it's very convenient. I'm sure there are other cases like that.
Re:First fully sandboxed Linux desktop app by detaro on Tuesday February 17, 2015 @06:37PM (#9065964)
Just because it can't cover every single case and application doesn't mean it isn't worth using it for those where it fits. It's an interesting question how far one would want to go to support these special cases, because doing so adds complexity to both code and the things the user has to understand, but the nice thing with an open system is: we don't have to use it for applications that don't fit the model very well or can allow exceptions where needed.
Re:First fully sandboxed Linux desktop app by cplease on Tuesday February 17, 2015 @09:42PM (#9066714)
You don't need a different file chooser widget for that. You can use AppArmor or other MAC systems.
Re:First fully sandboxed Linux desktop app by edohyiez on Tuesday February 17, 2015 @10:22PM (#9066818)
Can you really? With the external file chooser, the app has no access to user files before a file is picked, then has access to only this one particular file, and after it is closed returns to no access again.

How would you do this with a generic MAC system without using additional software that dynamically changes the MAC policy and/or relabels files and without bothering the user?

Re:First fully sandboxed Linux desktop app by davidgerard on Tuesday February 17, 2015 @11:09AM (#9062964)
>they refuse blankly, saying that my "use case is irrelevant and dangerous".

Because it's not like anyone uses media players in the real world.

Seriously, WHAT?