[{"id":18096,"web_url":"https://patchwork.libcamera.org/comment/18096/","msgid":"<9193e427-e10e-63b5-8b1b-2bf0c1558c57@ideasonboard.com>","date":"2021-07-12T07:55:01","subject":"Re: [libcamera-devel] [PATCH 3/3] libcamera: ipa_manager: Allow\n\tforcing IPA module isolation","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 12/07/2021 00:15, Laurent Pinchart wrote:\n> For test purpose it's useful to run open-source IPA modules in\n> isolation. This can already be done by deleting the corresponding\n> signature file, but that method can be inconvenient. Add a way to force\n> IPA module isolation through a new LIBCAMERA_IPA_FORCE_ISOLATION\n> environment variable.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  Documentation/environment_variables.rst | 5 +++++\n>  src/libcamera/ipa_manager.cpp           | 8 ++++++++\n>  2 files changed, 13 insertions(+)\n> \n> diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst\n> index d392fd26b87a..1e85befd538a 100644\n> --- a/Documentation/environment_variables.rst\n> +++ b/Documentation/environment_variables.rst\n> @@ -24,6 +24,11 @@ LIBCAMERA_IPA_CONFIG_PATH\n>  \n>     Example value: ``${HOME}/.libcamera/share/ipa:/opt/libcamera/vendor/share/ipa``\n>  \n> +LIBCAMERA_IPA_FORCE_ISOLATION\n> +   When set to a non-empty string, force process isolation of all IPA modules.\n> +\n> +   Example value: ``1``\n> +\n>  LIBCAMERA_IPA_MODULE_PATH\n>     Define custom search locations for IPA modules (`more <IPA module_>`__).\n>  \n> diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp\n> index 9533c8fadea6..028b2ce21779 100644\n> --- a/src/libcamera/ipa_manager.cpp\n> +++ b/src/libcamera/ipa_manager.cpp\n> @@ -276,6 +276,14 @@ IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion,\n>  bool IPAManager::isSignatureValid([[maybe_unused]] IPAModule *ipa) const\n>  {\n>  #if HAVE_IPA_PUBKEY\n> +\tchar *force = utils::secure_getenv(\"LIBCAMERA_IPA_FORCE_ISOLATION\");\n> +\tif (force && force[0] != '\\0') {\n\nWe're getting this pattern a lot. I wonder if we should have\nutils::secure_getenv return null if env[0] == '\\0' to simplify the code.\n\nOr otherwise, have an isSet() wrapper.\n\nBut anyway, that's not required here.\n\nI suspect that the users of this env won't extend beyond developers and\ntests, but I think even just for testing that provides a very valid use\ncase here, as we'll be able to create comparable tests using the same\nIPA but for both isolated, and non-isolated cases.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> +\t\tLOG(IPAManager, Debug)\n> +\t\t\t<< \"Isolation of IPA module \" << ipa->path()\n> +\t\t\t<< \" forced through environment variable\";\n> +\t\treturn false;\n> +\t}\n> +\n>  \tFile file{ ipa->path() };\n>  \tif (!file.open(File::ReadOnly))\n>  \t\treturn false;\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 D511FC3224\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Jul 2021 07:55:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3432468524;\n\tMon, 12 Jul 2021 09:55:05 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CA83268506\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Jul 2021 09:55:03 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 567D9CC;\n\tMon, 12 Jul 2021 09:55:03 +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=\"VLbfezk6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626076503;\n\tbh=JJXWR6ShIkJLCsNbn+2PgYWqlTxSn6kAIqn5fi5GONw=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=VLbfezk6x1CNF1nNUVrnkt4ftiNx3c4sgHvHvIOnp7O4j0Aji4ZPKGtqVrB3jtFP1\n\t6DyxeAkhZgMR4Ea5y0Lc+Uo2KGb94VEmy1WKS3VBipFIm4U6nDu06ncg1aKNBq67sX\n\t5nLj0rzSX0yWz+74jQIXSJx4719dpsHTfWx7aQEk=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210711231547.19664-1-laurent.pinchart@ideasonboard.com>\n\t<20210711231547.19664-4-laurent.pinchart@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<9193e427-e10e-63b5-8b1b-2bf0c1558c57@ideasonboard.com>","Date":"Mon, 12 Jul 2021 08:55:01 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<20210711231547.19664-4-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH 3/3] libcamera: ipa_manager: Allow\n\tforcing IPA module isolation","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":18155,"web_url":"https://patchwork.libcamera.org/comment/18155/","msgid":"<YOy8BkpnLG3Mbarp@pendragon.ideasonboard.com>","date":"2021-07-12T22:02:46","subject":"Re: [libcamera-devel] [PATCH 3/3] libcamera: ipa_manager: Allow\n\tforcing IPA module isolation","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nOn Mon, Jul 12, 2021 at 08:55:01AM +0100, Kieran Bingham wrote:\n> On 12/07/2021 00:15, Laurent Pinchart wrote:\n> > For test purpose it's useful to run open-source IPA modules in\n> > isolation. This can already be done by deleting the corresponding\n> > signature file, but that method can be inconvenient. Add a way to force\n> > IPA module isolation through a new LIBCAMERA_IPA_FORCE_ISOLATION\n> > environment variable.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  Documentation/environment_variables.rst | 5 +++++\n> >  src/libcamera/ipa_manager.cpp           | 8 ++++++++\n> >  2 files changed, 13 insertions(+)\n> > \n> > diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst\n> > index d392fd26b87a..1e85befd538a 100644\n> > --- a/Documentation/environment_variables.rst\n> > +++ b/Documentation/environment_variables.rst\n> > @@ -24,6 +24,11 @@ LIBCAMERA_IPA_CONFIG_PATH\n> >  \n> >     Example value: ``${HOME}/.libcamera/share/ipa:/opt/libcamera/vendor/share/ipa``\n> >  \n> > +LIBCAMERA_IPA_FORCE_ISOLATION\n> > +   When set to a non-empty string, force process isolation of all IPA modules.\n> > +\n> > +   Example value: ``1``\n> > +\n> >  LIBCAMERA_IPA_MODULE_PATH\n> >     Define custom search locations for IPA modules (`more <IPA module_>`__).\n> >  \n> > diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp\n> > index 9533c8fadea6..028b2ce21779 100644\n> > --- a/src/libcamera/ipa_manager.cpp\n> > +++ b/src/libcamera/ipa_manager.cpp\n> > @@ -276,6 +276,14 @@ IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion,\n> >  bool IPAManager::isSignatureValid([[maybe_unused]] IPAModule *ipa) const\n> >  {\n> >  #if HAVE_IPA_PUBKEY\n> > +\tchar *force = utils::secure_getenv(\"LIBCAMERA_IPA_FORCE_ISOLATION\");\n> > +\tif (force && force[0] != '\\0') {\n> \n> We're getting this pattern a lot. I wonder if we should have\n> utils::secure_getenv return null if env[0] == '\\0' to simplify the code.\n> \n> Or otherwise, have an isSet() wrapper.\n\nI wouldn't integrate it in utils::secure_getenv() as it would depart\nfrom the secure_getenv() (and getenv()) API, possibly leading to subtle\nbugs. A wrapper would be a better idea I think. I'm tempted to defer\naddressing this to when we'll need more helper functions to manage the\nenvironment variables.\n\n> But anyway, that's not required here.\n> \n> I suspect that the users of this env won't extend beyond developers and\n> tests, but I think even just for testing that provides a very valid use\n> case here, as we'll be able to create comparable tests using the same\n> IPA but for both isolated, and non-isolated cases.\n\nYes, this is really for testing. I got the idea from a DNI patch from\nUmang that hardcoded a return false; here for testing.\n\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> > +\t\tLOG(IPAManager, Debug)\n> > +\t\t\t<< \"Isolation of IPA module \" << ipa->path()\n> > +\t\t\t<< \" forced through environment variable\";\n> > +\t\treturn false;\n> > +\t}\n> > +\n> >  \tFile file{ ipa->path() };\n> >  \tif (!file.open(File::ReadOnly))\n> >  \t\treturn false;","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 B602BC3225\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Jul 2021 22:03:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E5CBD68524;\n\tTue, 13 Jul 2021 00:03:36 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7B33C6027F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jul 2021 00:03:33 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DEC8CCC;\n\tTue, 13 Jul 2021 00:03:32 +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=\"Lvo2cUNP\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626127413;\n\tbh=Pp++MA6ly0viIXZPMSYsuRJVufq/BKmnkTBMSntvEoQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Lvo2cUNPOhvuA0Rgq0X7LW52UkwYHOCu+hFqPxfAA3L05d+LN40bx2Ui4UwuLu1TJ\n\tj3X8j8rmdFGF2z000Ec9rIwu0qeRfO4Peh71xVVC1gURbKXXfe5f1A2eNbHryvipmU\n\tD7OUuOuAMwA2KKKG9rStFDayKeY5Un8Kk63vMTn8=","Date":"Tue, 13 Jul 2021 01:02:46 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<YOy8BkpnLG3Mbarp@pendragon.ideasonboard.com>","References":"<20210711231547.19664-1-laurent.pinchart@ideasonboard.com>\n\t<20210711231547.19664-4-laurent.pinchart@ideasonboard.com>\n\t<9193e427-e10e-63b5-8b1b-2bf0c1558c57@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<9193e427-e10e-63b5-8b1b-2bf0c1558c57@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 3/3] libcamera: ipa_manager: Allow\n\tforcing IPA module isolation","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":18221,"web_url":"https://patchwork.libcamera.org/comment/18221/","msgid":"<20210719032132.GI2395@pyrite.rasen.tech>","date":"2021-07-19T03:21:32","subject":"Re: [libcamera-devel] [PATCH 3/3] libcamera: ipa_manager: Allow\n\tforcing IPA module isolation","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Laurent,\n\nOn Mon, Jul 12, 2021 at 02:15:47AM +0300, Laurent Pinchart wrote:\n> For test purpose it's useful to run open-source IPA modules in\n> isolation. This can already be done by deleting the corresponding\n> signature file, but that method can be inconvenient. Add a way to force\n> IPA module isolation through a new LIBCAMERA_IPA_FORCE_ISOLATION\n> environment variable.\n\nOoh, that's convenient.\n\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  Documentation/environment_variables.rst | 5 +++++\n>  src/libcamera/ipa_manager.cpp           | 8 ++++++++\n>  2 files changed, 13 insertions(+)\n> \n> diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst\n> index d392fd26b87a..1e85befd538a 100644\n> --- a/Documentation/environment_variables.rst\n> +++ b/Documentation/environment_variables.rst\n> @@ -24,6 +24,11 @@ LIBCAMERA_IPA_CONFIG_PATH\n>  \n>     Example value: ``${HOME}/.libcamera/share/ipa:/opt/libcamera/vendor/share/ipa``\n>  \n> +LIBCAMERA_IPA_FORCE_ISOLATION\n> +   When set to a non-empty string, force process isolation of all IPA modules.\n> +\n> +   Example value: ``1``\n> +\n>  LIBCAMERA_IPA_MODULE_PATH\n>     Define custom search locations for IPA modules (`more <IPA module_>`__).\n>  \n> diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp\n> index 9533c8fadea6..028b2ce21779 100644\n> --- a/src/libcamera/ipa_manager.cpp\n> +++ b/src/libcamera/ipa_manager.cpp\n> @@ -276,6 +276,14 @@ IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion,\n>  bool IPAManager::isSignatureValid([[maybe_unused]] IPAModule *ipa) const\n>  {\n>  #if HAVE_IPA_PUBKEY\n> +\tchar *force = utils::secure_getenv(\"LIBCAMERA_IPA_FORCE_ISOLATION\");\n> +\tif (force && force[0] != '\\0') {\n> +\t\tLOG(IPAManager, Debug)\n> +\t\t\t<< \"Isolation of IPA module \" << ipa->path()\n> +\t\t\t<< \" forced through environment variable\";\n> +\t\treturn false;\n> +\t}\n> +\n>  \tFile file{ ipa->path() };\n>  \tif (!file.open(File::ReadOnly))\n>  \t\treturn false;\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 A82CEC0109\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Jul 2021 03:21:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ED7E06853A;\n\tMon, 19 Jul 2021 05:21:40 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1A3D260278\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Jul 2021 05:21:40 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A005B465;\n\tMon, 19 Jul 2021 05:21:38 +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=\"IzL/KWCk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626664899;\n\tbh=0bIeaq2t2XWbD7FrjAfowq4DkG4R3Cpj/MfO3bA4+gE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=IzL/KWCkZcOCePzi4D4iFdjKG02yDGBZa+yLfa3t4QwsNK9zwlzKVdbglslq1sdET\n\t2vOnZOYiWBSeMFrNtERtDPV0HF1E14f6ClAJaHE9wMMaWv/Efh+mfbtCGPhwcBqvuj\n\tWoEWqWJm4VTcfs95buZHXNNov/vl5yrrASFQ2M6w=","Date":"Mon, 19 Jul 2021 12:21:32 +0900","From":"paul.elder@ideasonboard.com","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20210719032132.GI2395@pyrite.rasen.tech>","References":"<20210711231547.19664-1-laurent.pinchart@ideasonboard.com>\n\t<20210711231547.19664-4-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20210711231547.19664-4-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 3/3] libcamera: ipa_manager: Allow\n\tforcing IPA module isolation","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]