[{"id":29764,"web_url":"https://patchwork.libcamera.org/comment/29764/","msgid":"<53bc15d4-131a-4f6d-abf5-cb5c7a68201e@redhat.com>","date":"2024-06-05T08:04:29","subject":"Re: [PATCH] libcamera: dma_buf_allocator: Create memfd with CLOEXEC","submitter":{"id":102,"url":"https://patchwork.libcamera.org/api/people/102/","name":"Hans de Goede","email":"hdegoede@redhat.com"},"content":"Hi,\n\nOn 6/5/24 9:50 AM, Laurent Pinchart wrote:\n> Ensure that the memfd file descriptor won't be leaked to child processes\n> by creating it with MFD_CLOEXEC.\n> \n> Fixes: ea4baaacc325 (\"libcamera: DmaBufAllocator: Support allocating from /dev/udmabuf\")\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nThanks, patch looks good to me:\n\nReviewed-by: Hans de Goede <hdegoede@redhat.com>\n\nRegards,\n\nHans\n\n\n\n> ---\n>  src/libcamera/dma_buf_allocator.cpp | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp\n> index 5ae517210adf..5ec29949c66a 100644\n> --- a/src/libcamera/dma_buf_allocator.cpp\n> +++ b/src/libcamera/dma_buf_allocator.cpp\n> @@ -132,7 +132,7 @@ UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size)\n>  \tstd::size_t pageMask = sysconf(_SC_PAGESIZE) - 1;\n>  \tsize = (size + pageMask) & ~pageMask;\n>  \n> -\tint ret = memfd_create(name, MFD_ALLOW_SEALING);\n> +\tint ret = memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);\n>  \tif (ret < 0) {\n>  \t\tret = errno;\n>  \t\tLOG(DmaBufAllocator, Error)\n> \n> base-commit: 98071d3109c131820439f61d9380c0bd4cd2119a","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 88429BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Jun 2024 08:04:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 735876543E;\n\tWed,  5 Jun 2024 10:04:38 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2EFAB634B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jun 2024 10:04:37 +0200 (CEST)","from mail-ed1-f71.google.com (mail-ed1-f71.google.com\n\t[209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-679-EwG4fBy7NtmG41tilnwZKg-1; Wed, 05 Jun 2024 04:04:32 -0400","by mail-ed1-f71.google.com with SMTP id\n\t4fb4d7f45d1cf-57a50752cd2so629039a12.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 05 Jun 2024 01:04:32 -0700 (PDT)","from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec?\n\t(2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl.\n\t[2001:1c00:c32:7800:5bfa:a036:83f0:f9ec])\n\tby smtp.gmail.com with ESMTPSA id\n\t4fb4d7f45d1cf-57a31bb8247sm8771275a12.30.2024.06.05.01.04.30\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tWed, 05 Jun 2024 01:04:30 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"Shp/KZiy\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1717574675;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=898gmAPTmKaiwXBN0j50tOhsoeYRRQwQyjFa9RRBT8s=;\n\tb=Shp/KZiyR5Idseomc0UZy7u4mgxJzfdDkhGvAS8YI48RoD5ZC+hdOidfwKY+MNVUtPr722\n\t74/bult+l+BtWIAD13iX4oONLnSKA4tmSOrODNJhcFSpl0bCkCrnfgTgLkWZPn4SBTe1Bd\n\tq9XrG4ACzE6+pPJDd5TTo9LOin004RQ=","X-MC-Unique":"EwG4fBy7NtmG41tilnwZKg-1","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1717574671; x=1718179471;\n\th=content-transfer-encoding:in-reply-to:from:content-language\n\t:references:to:subject:user-agent:mime-version:date:message-id\n\t:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n\tbh=898gmAPTmKaiwXBN0j50tOhsoeYRRQwQyjFa9RRBT8s=;\n\tb=gxbtNOIcDCJ/Bb33KzLJDqxmnmcS+oPIW0ntgJxNjoU2ykfI2Tbm8m26NOOVjXGp5F\n\t+3mVEVYwLc1eQvbZedQSMC0Ybor7Le5Sm3qCYtXM0SiyzZG15AegIJsMqxVmDtECQxQE\n\tf0laWSwVr9A961fXTSpSk8UjYlLvmvtHMm5UA9uFswOaByO9k4kjX0VascF32mZ4MErG\n\tVeCh3JA0kqL8MY/PgmtiOlR/frzWsOSWIBecAb6skFz9QIAWLEHsi2R2U6dP4CcM112E\n\tFWg4buK0cjDHJnwX5JsIJGIhIdz9Rhv5qBdWn5nkScy9ejXYxzFUTB8o1SxOwz72VcaF\n\tuFCw==","X-Forwarded-Encrypted":"i=1;\n\tAJvYcCUqEPN4FtjT5JPW7CztPz3VeO1LxsM1hgA6yPtZ7LQJenskBBS/dPoQOFHlb9m4oezWJoV8pteiwXn1tX9V0ZMXI13iBPP7qz48Un1yxHXF5Fqi+A==","X-Gm-Message-State":"AOJu0Yzn7nHsz33pr+6qx/+PNcGFIfR8J5tavSs+iWslnsVbm+9uyaHq\n\tsr8zXgIoN+9Vx4h8V6AG+HKupweALaQMOViesiqV01t4I/iGvzHAa8imLS7PrV14WzTTDB5Yps8\n\tSYxQ5V0O/4n7avl91ijnDccXXRfSnuyXgxhQSx0+9PTEoL8T4ANkjWDO5+JlW81w3pMrVpe37Wm\n\tZ932c=","X-Received":["by 2002:a50:f689:0:b0:57a:79c2:e9d1 with SMTP id\n\t4fb4d7f45d1cf-57a8b6a6379mr1708056a12.8.1717574671287; \n\tWed, 05 Jun 2024 01:04:31 -0700 (PDT)","by 2002:a50:f689:0:b0:57a:79c2:e9d1 with SMTP id\n\t4fb4d7f45d1cf-57a8b6a6379mr1708038a12.8.1717574670889; \n\tWed, 05 Jun 2024 01:04:30 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IEix65LvxQD1/UAX7x/oHDrXLuGVAFYoBjIcH811T+LnL/E3ifg+XwQqHa4H7mHn7b2Uo9VFA==","Message-ID":"<53bc15d4-131a-4f6d-abf5-cb5c7a68201e@redhat.com>","Date":"Wed, 5 Jun 2024 10:04:29 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] libcamera: dma_buf_allocator: Create memfd with CLOEXEC","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20240605075055.18039-1-laurent.pinchart@ideasonboard.com>","From":"Hans de Goede <hdegoede@redhat.com>","In-Reply-To":"<20240605075055.18039-1-laurent.pinchart@ideasonboard.com>","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Language":"en-US, nl","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":29765,"web_url":"https://patchwork.libcamera.org/comment/29765/","msgid":"<171757503503.2248009.7031298850976084823@ping.linuxembedded.co.uk>","date":"2024-06-05T08:10:35","subject":"Re: [PATCH] libcamera: dma_buf_allocator: Create memfd with CLOEXEC","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2024-06-05 08:50:55)\n> Ensure that the memfd file descriptor won't be leaked to child processes\n> by creating it with MFD_CLOEXEC.\n> \n> Fixes: ea4baaacc325 (\"libcamera: DmaBufAllocator: Support allocating from /dev/udmabuf\")\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nOh yeah, we hit this before...\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/libcamera/dma_buf_allocator.cpp | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp\n> index 5ae517210adf..5ec29949c66a 100644\n> --- a/src/libcamera/dma_buf_allocator.cpp\n> +++ b/src/libcamera/dma_buf_allocator.cpp\n> @@ -132,7 +132,7 @@ UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size)\n>         std::size_t pageMask = sysconf(_SC_PAGESIZE) - 1;\n>         size = (size + pageMask) & ~pageMask;\n>  \n> -       int ret = memfd_create(name, MFD_ALLOW_SEALING);\n> +       int ret = memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);\n>         if (ret < 0) {\n>                 ret = errno;\n>                 LOG(DmaBufAllocator, Error)\n> \n> base-commit: 98071d3109c131820439f61d9380c0bd4cd2119a\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id F3031BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Jun 2024 08:10:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CAF496543C;\n\tWed,  5 Jun 2024 10:10:39 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 036D8634B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jun 2024 10:10:37 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6FD3C63B;\n\tWed,  5 Jun 2024 10:10:29 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"j5K3y9V5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717575029;\n\tbh=naHw1JTAlS6DHaNFkguZ0ZinUQt+Jjqi+XGKyGC7ODo=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=j5K3y9V5EYNDLJgiZuuqYX6hmYKLqVXNhbl3zf9eWo77vttOTOS5n1aknGYcoo7J1\n\trE15NwKsiJvgAaGxsX+WsrkK7iicKkOOgfJqUFxwiXSe2m7cV5SpCc6qmclm+HUgeu\n\tYyLYRfH5Z6sAJ8sv7ZBSr4g9BHJY2pegrDu8OCMA=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240605075055.18039-1-laurent.pinchart@ideasonboard.com>","References":"<20240605075055.18039-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH] libcamera: dma_buf_allocator: Create memfd with CLOEXEC","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Hans de Goede <hdegoede@redhat.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 05 Jun 2024 09:10:35 +0100","Message-ID":"<171757503503.2248009.7031298850976084823@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]