Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2110804lqo; Mon, 13 May 2024 08:10:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVE/o1mGWFuBAijF6QssB4bmwq1kCivxIzTXVry2IDrNi3Jod43Icyo6BeOTefenhFQPyTpITgqN55OT8RSUlcPSP+SrzuUs8K2KPieew== X-Google-Smtp-Source: AGHT+IFcPdFRk9RZgBBpSuGKRCbRS+RVV7b4kt/Y1/RLnzGhWLA1kfmdZouy8ZgSJEVsO4WYUANE X-Received: by 2002:a05:6808:eca:b0:3c9:6e4f:eeec with SMTP id 5614622812f47-3c9970bde8cmr13360933b6e.37.1715613021226; Mon, 13 May 2024 08:10:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715613021; cv=pass; d=google.com; s=arc-20160816; b=RW3e3aOC6GZ9jh/Essu5p3oM9t7awN0Ie2tYpURHF0+eeHSlRocBTZPXWdk5gu1Urk w4PX+6Fvpp5Z7ULsmHXEDlkkU0jzRdCVOaP3I6Ck1SWGHSKuMLgXg8xwIG/YXg9MxCdV HbXnULPO2zvsb018MTCKcQcwf/OZkQzcJs6I8qseeFLH6QUTMEJxc6vPYQrsluQ/fQMb wRl9GJV/iT2+XDO88yEvTIWX4PQhsAS2KRXDkRlHYp3GSL5gEroGlT9ejtazVYYEN6AF Y4VpHugDpC4pEBncObHTLG195nLNXj4JyPuxt/O0wIpub1RZmluxE7sp7tMhrpM7y/fA O3Yw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=2fye0wHuc/ux/aoME5fdHjKNLhC9VtAEvF2L4dmZ3qY=; fh=ycfNMw0bxmT8uPaNVcoYzYcE6cT+UbU73yVK3rKOHkI=; b=TnQnwxTlNpO9YmNIyu4g6kB5iTjJzyUN0aO/2b5/MPO/Aahpb2WxIzE/cR+THfEHg1 DSoGqvK+QfojmBNPTXc/Jmm0cwxvm39vA5uBYnC8JJOE8oGWgzA8chCjXLdLGA/pKmJ5 zzAJqyA4xDtfyLOsRMXjePQahSLESlBZYlyo9uF7t8TF0SyLfushBJqsmwC5M1qH9DR+ iCE3kxtq1yZRLid9I+H5PNuZYzprqHCqSq6DWhlAUmisxyX6chwVhImgUjNhUve3S+ht p6+oJan90JfLMjH0Jm1wj4oINkaNZ+10IWNfFZ1lrUu1PHUCa/b9nKxr28TYaB0nDSrB b/MQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=20jUb+OB; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-177731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ada2fe7eead31-4806cbaa864si1274791137.229.2024.05.13.08.10.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 08:10:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=20jUb+OB; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-177731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D3E711C215CE for ; Mon, 13 May 2024 15:10:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CDC2046BF; Mon, 13 May 2024 15:10:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="20jUb+OB" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D3D74C7B; Mon, 13 May 2024 15:10:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715613012; cv=none; b=NcH6nLpN66ZsA/b9Jc2ua6Iov7/UoolIgxGWnxzav8DaLTMuAxFg3TBHzAmGXQXLjqwASulRPulSnHSTEV6XyyLx4wduu4MEXYt9zRqaPakGLPl3BzrOCmIDdmyTFiYCw0K9Qe71MD2xdAfZT0qAxIdsPLy6RRn6H49R4BpeJZE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715613012; c=relaxed/simple; bh=2fye0wHuc/ux/aoME5fdHjKNLhC9VtAEvF2L4dmZ3qY=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=YmRuyW7LtjnQ2hStT651oODranldYpzRyvjSqZNIBi4GhrrYpRe7gbEnUeS658tj1/OQj0Iw0pYsW3BCb+TWwUm2EkkC0GVOSljdsDeIPhAU4R0lf7FMNVBS3Tf/xXTDm2OLTY0CSgcjBBzLGQ5AWTIfGDNiHItm1b3HFWQUd3s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=20jUb+OB; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1715613008; bh=2fye0wHuc/ux/aoME5fdHjKNLhC9VtAEvF2L4dmZ3qY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=20jUb+OBwb36eRW8hNE0AnCZuWbUe4dpPF+rKvuY3zoHfluKLWVNTK6lqLJx3bjW3 6h1eLEuWQ0cm7t8iDGra+nc7lrtPSosUIFx1Nfft674aVWIXSwzc7ZzH2Ot/fzekF+ e+cYPf1HcE4TMsQoDsaDTHgIK/402+702v8RgeBmmOBHxqFhJbDIW5PFdQfdB86/p6 tcLZ00tj6kJTyOfYJg8kYvr4ljF3iFVZM42iU7ijmcu+uccv6FBT32KH9SNJFRM5ey elkaPybAJhJ2I9GPtV/7WZKwlBEQhYfN9i8j1nRIj9dPY41IwXSV/N7k12HrcRz+sx RXcyDLhaUoRNA== Received: from nicolas-tpx395.localdomain (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: nicolas) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 06F99378216D; Mon, 13 May 2024 15:10:05 +0000 (UTC) Message-ID: Subject: Re: Safety of opening up /dev/dma_heap/* to physically present users (udev uaccess tag) ? From: Nicolas Dufresne To: Laurent Pinchart , Maxime Ripard Cc: Bryan O'Donoghue , Dmitry Baryshkov , Hans de Goede , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , Christian =?ISO-8859-1?Q?K=F6nig?= , Lennart Poettering , Robert Mader , Sebastien Bacher , Linux Media Mailing List , "dri-devel@lists.freedesktop.org" , linaro-mm-sig@lists.linaro.org, Linux Kernel Mailing List , Milan Zamazal , Andrey Konovalov Date: Mon, 13 May 2024 11:10:00 -0400 In-Reply-To: <20240513083417.GA18630@pendragon.ideasonboard.com> References: <3c0c7e7e-1530-411b-b7a4-9f13e0ff1f9e@redhat.com> <20240507183613.GB20390@pendragon.ideasonboard.com> <4f59a9d78662831123cc7e560218fa422e1c5eca.camel@collabora.com> <20240513-heretic-didactic-newt-1d6daf@penduick> <20240513083417.GA18630@pendragon.ideasonboard.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.1 (3.52.1-1.fc40) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Le lundi 13 mai 2024 =C3=A0 11:34 +0300, Laurent Pinchart a =C3=A9crit=C2= =A0: > On Mon, May 13, 2024 at 10:29:22AM +0200, Maxime Ripard wrote: > > On Wed, May 08, 2024 at 10:36:08AM +0200, Daniel Vetter wrote: > > > On Tue, May 07, 2024 at 04:07:39PM -0400, Nicolas Dufresne wrote: > > > > Hi, > > > >=20 > > > > Le mardi 07 mai 2024 =C3=A0 21:36 +0300, Laurent Pinchart a =C3=A9c= rit=C2=A0: > > > > > Shorter term, we have a problem to solve, and the best option we = have > > > > > found so far is to rely on dma-buf heaps as a backend for the fra= me > > > > > buffer allocatro helper in libcamera for the use case described a= bove. > > > > > This won't work in 100% of the cases, clearly. It's a stop-gap me= asure > > > > > until we can do better. > > > >=20 > > > > Considering the security concerned raised on this thread with dmabu= f heap > > > > allocation not be restricted by quotas, you'd get what you want qui= ckly with > > > > memfd + udmabuf instead (which is accounted already). > > > >=20 > > > > It was raised that distro don't enable udmabuf, but as stated there= by Hans, in > > > > any cases distro needs to take action to make the softISP works. Th= is > > > > alternative is easy and does not interfere in anyway with your futu= re plan or > > > > the libcamera API. You could even have both dmabuf heap (for Raspbi= an) and the > > > > safer memfd+udmabuf for the distro with security concerns. > > > >=20 > > > > And for the long term plan, we can certainly get closer by fixing t= hat issue > > > > with accounting. This issue also applied to v4l2 io-ops, so it woul= d be nice to > > > > find common set of helpers to fix these exporters. > > >=20 > > > Yeah if this is just for softisp, then memfd + udmabuf is also what I= was > > > about to suggest. Not just as a stopgap, but as the real official thi= ng. > > >=20 > > > udmabuf does kinda allow you to pin memory, but we can easily fix tha= t by > > > adding the right accounting and then either let mlock rlimits or cgro= ups > > > kernel memory limits enforce good behavior. > >=20 > > I think the main drawback with memfd is that it'll be broken for device= s > > without an IOMMU, and while you said that it's uncommon for GPUs, it's > > definitely not for codecs and display engines. >=20 > If the application wants to share buffers between the camera and a > display engine or codec, it should arguably not use the libcamera > FrameBufferAllocator, but allocate the buffers from the display or the > encoder. memfd wouldn't be used in that case. >=20 > We need to eat our own dogfood though. If we want to push the > responsibility for buffer allocation in the buffer sharing case to the > application, we need to modify the cam application to do so when using > the KMS backend. >=20 Agreed, and the new dmabuf feedback on wayland can also be used on top of t= his. You'll hit the same limitation as we hit in GStreamer, which is that KMS dr= iver only offer allocation for render buffers and most of them are missing alloc= ators for YUV buffers, even though they can import in these formats. (kms allocat= ors, except dumb, which has other issues, are format aware). Nicolas