News for hackers. Stuff that matters.
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.