From patchwork Thu Jul 9 18:30:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "T.J. Mercier" X-Patchwork-Id: 27360 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id DF5C9C3318 for ; Thu, 9 Jul 2026 18:30:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CBF44660F7; Thu, 9 Jul 2026 20:30:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="PqEOZC9n"; dkim-atps=neutral Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DF15E660E3 for ; Thu, 9 Jul 2026 20:30:53 +0200 (CEST) Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-c894c1c4aa9so177847a12.0 for ; Thu, 09 Jul 2026 11:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783621852; x=1784226652; darn=lists.libcamera.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=vSGK9CeAbi4IqaeyB3S8skUc+lL+s/l/Ze39ZEYbDI0=; b=PqEOZC9nHBPaDY236cvAz/6UnCiqBn1BHHevTOCsNiyLM05PKkPwlCtAjHLUPSF9N2 nJSXQJ+yr9KU+Zbdn++/yp88BV/47d4+NZmLyKzjBU4wGUuJTlxIoVmwo5U6zklN5gZy jY2451KQ1YmiAQg6ZbdM919c/Z5R815VYoamPaghoYeyNXRaAPG2jYGDYerY239gQ1p9 7p8RrIve/UT2puQgrwbUqsTbxCmnjAqxZDOZQGB56WeD3NRJ1O6C6s8rx84Op6dDZ+Lw 9EHPN8eFDyV39EflyYOvrB4NxuzWOsAc2SL4BsD3q7UK4mMZgBd4xZjn54y7zf3VMZIu I/4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783621852; x=1784226652; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=vSGK9CeAbi4IqaeyB3S8skUc+lL+s/l/Ze39ZEYbDI0=; b=nBuc/AU41CZ8iWoH9q2kCiuTmNiKXV+g7gSowYg2Z8cUY0vQrsB729RQmufCBZU73z h0lUElNixhsXqXOwQEJirkVqa1j+ZKEXgcyMswauHUVyfbSN4jQHMFeBiw1J3cuMfJS/ vAELuhMGqPowAwD2G7Bbd6ZuPDxwlG2N6XR97ADfjh66RY17UWgWbufbXfmZHUeQlbOl KpZpGKjOzQFdgk0tnslzD7tpjhaPwIu/cIen/VB9zri3sb90yk8G+f/PjIJT1lZkDDbQ 9kQ3idR38x4vhSc6Xy2CRMa0t6EkfrIra+G0XnudFOjocKXM4nVFcde3Bcsj/E6RjjEr D45Q== X-Gm-Message-State: AOJu0YwZ1sDvxc1Xygys+WWEPu9F6gyEI2TvmCBKWmevneXPLFRuKJCB KnxC+iD+MlbCIKmTzGZTJ3DPwahLDUq+gRuqIqmirihUkW3yH3nR79/Mq7G/GA+ORSlzr1PEhsp s6gWas3FlRQ04r3mz/M+7ecGOBa/TqOzwHt/bkKcUqIODOPSjjoZ0f6ATnr4a3XWfMYB0Y9LJWx JXIOPIxkFIAiiCJH95URt4K/nrhB79Ksvi0/S6FET6Q29CEwLNQtNikDaR8sc0vIfZQMYXpA== X-Received: from pgac17.prod.google.com ([2002:a05:6a02:2951:b0:c76:6c2f:89d4]) (user=tjmercier job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:10d:b0:3bc:5284:4859 with SMTP id adf61e73a8af0-3c0bce12ef1mr10648748637.13.1783621851351; Thu, 09 Jul 2026 11:30:51 -0700 (PDT) Date: Thu, 9 Jul 2026 11:30:45 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.795.g602f6c329a-goog Message-ID: <20260709183049.2282221-1-tjmercier@google.com> Subject: [PATCH] DmaBufAllocator: Open heap device files O_RDONLY From: "T.J. Mercier" To: libcamera-devel@lists.libcamera.org Cc: "T.J. Mercier" X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The write access mode is not required to issue ioctls and allocate dma-bufs from heaps. Applications should be opening them as O_RDONLY. Permission errors can be encountered while attempting to open() files in /dev/dma_heap/* on systems where write permissions are not available. So apply the principle of least privilege and remove the write access mode. Signed-off-by: T.J. Mercier --- src/libcamera/dma_buf_allocator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp index d8c62dd67..c673d23ec 100644 --- a/src/libcamera/dma_buf_allocator.cpp +++ b/src/libcamera/dma_buf_allocator.cpp @@ -100,7 +100,7 @@ DmaBufAllocator::DmaBufAllocator(DmaBufAllocatorFlags type) if (!(type & info.type)) continue; - int ret = ::open(info.deviceNodeName, O_RDWR | O_CLOEXEC, 0); + int ret = ::open(info.deviceNodeName, O_RDONLY | O_CLOEXEC, 0); if (ret < 0) { ret = errno; LOG(DmaBufAllocator, Debug)