From 941620b73367cd5b3c92ef61e83c38056435630f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 5 May 2021 15:23:49 +0200 Subject: [PATCH] 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. --- spa/plugins/v4l2/v4l2-utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index feefde004..8129d1074 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -1488,9 +1488,9 @@ mmap_init(struct impl *this, use_expbuf = true; } else { fallback: - d[0].type = SPA_DATA_MemFd; + d[0].type = SPA_DATA_MemPtr; 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].data = mmap(NULL, b->v4l2_buffer.length,