v4l2: don't expose the internal fd

When allocating memory, just export the mmaped memory and mark the
memory as MemPtr, not MemFd. Set the fd to -1.

Otherwise we might send this fd to the client, making the complete
device accessible to the client.
This commit is contained in:
Wim Taymans 2021-05-05 15:23:49 +02:00
parent ec331f4e4c
commit 941620b733

View file

@ -1488,9 +1488,9 @@ mmap_init(struct impl *this,
use_expbuf = true; use_expbuf = true;
} else { } else {
fallback: fallback:
d[0].type = SPA_DATA_MemFd; d[0].type = SPA_DATA_MemPtr;
d[0].flags = SPA_DATA_FLAG_READABLE; d[0].flags = SPA_DATA_FLAG_READABLE;
d[0].fd = dev->fd; d[0].fd = -1;
d[0].mapoffset = b->v4l2_buffer.m.offset; d[0].mapoffset = b->v4l2_buffer.m.offset;
d[0].data = mmap(NULL, d[0].data = mmap(NULL,
b->v4l2_buffer.length, b->v4l2_buffer.length,