{"id":1638,"url":"https://patchwork.libcamera.org/api/1.1/patches/1638/?format=json","web_url":"https://patchwork.libcamera.org/patch/1638/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190709184450.32023-6-paul.elder@ideasonboard.com>","date":"2019-07-09T18:44:48","name":"[libcamera-devel,v3,5/7] libcamera: ipa_manager: use proxy","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"bae15458c0ced5e56b3cafc9110bd47a3fecf768","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1638/mbox/","series":[{"id":410,"url":"https://patchwork.libcamera.org/api/1.1/series/410/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=410","date":"2019-07-09T18:44:43","name":"Add IPA process isolation","version":3,"mbox":"https://patchwork.libcamera.org/series/410/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1638/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1638/checks/","tags":{},"headers":{"Return-Path":"<paul.elder@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5044061577\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Jul 2019 20:45:09 +0200 (CEST)","from neptunite.amanokami.net (softbank126163157105.bbtec.net\n\t[126.163.157.105])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E403156A;\n\tTue,  9 Jul 2019 20:45:07 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1562697909;\n\tbh=clAf1sOjKATueylO+rV1uTb7i57z0xw/jFrkspTu7v0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=VyfEmqiRqyLZ2v/TdqWARHKUjwX6I0urbGAklMdIz3yRmW6jcd+Ahm2zVuzLhL9/D\n\tuszwwi3/jTx10apcbVZq3xiTaKya99ULuPpUus+NtCUFnRPdnG+0aPkrxgP3IVL3HQ\n\tJTootucByEvfWLjtaimqv+/tf5+A684KAE37R75I=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 10 Jul 2019 03:44:48 +0900","Message-Id":"<20190709184450.32023-6-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190709184450.32023-1-paul.elder@ideasonboard.com>","References":"<20190709184450.32023-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 5/7] libcamera: ipa_manager: use proxy","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Tue, 09 Jul 2019 18:45:09 -0000"},"content":"Make IPAManager isolate an IPA in a Proxy if the IPA's license is not\nopen source, before returning the IPA to the caller. For now, only use\nthe default Linux IPA proxy, and only LGPL 2.1+ is considered open\nsource.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\nChanges in v3:\n- license checking is done with SPDX license strings, and only LGPL 2.1+\n  is accepted for now\n\nNew in v2\n- replaces adding shims\n- since Proxies are not external shared objects like the shims in v1\n  were, there is no longer a list of shims that is treated like\n  IPAModules\n- instead the matching is done by searching the list of proxy factories\n\n src/libcamera/ipa_manager.cpp | 46 +++++++++++++++++++++++++++++++++--\n 1 file changed, 44 insertions(+), 2 deletions(-)","diff":"diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp\nindex 532b77d..49a12ca 100644\n--- a/src/libcamera/ipa_manager.cpp\n+++ b/src/libcamera/ipa_manager.cpp\n@@ -14,6 +14,7 @@\n #include \"ipa_module.h\"\n #include \"log.h\"\n #include \"pipeline_handler.h\"\n+#include \"ipa_proxy.h\"\n #include \"utils.h\"\n \n /**\n@@ -25,6 +26,18 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(IPAManager)\n \n+namespace {\n+\n+bool isOpenSource(const char *license)\n+{\n+\tif (!strcmp(license, \"LGPL-2.1-or-later\"))\n+\t\treturn true;\n+\n+\treturn false;\n+}\n+\n+} /* namespace */\n+\n /**\n  * \\class IPAManager\n  * \\brief Manager for IPA modules\n@@ -129,7 +142,7 @@ int IPAManager::addDir(const char *libDir)\n  * \\param[in] maxVersion Maximum acceptable version of IPA module\n  *\n  * \\return A newly created IPA interface, or nullptr if no matching\n- * IPA module is found\n+ * IPA module is found or if the IPA interface fails to initialize\n  */\n std::unique_ptr<IPAInterface> IPAManager::createIPA(PipelineHandler *pipe,\n \t\t\t\t\t\t    uint32_t maxVersion,\n@@ -144,7 +157,36 @@ std::unique_ptr<IPAInterface> IPAManager::createIPA(PipelineHandler *pipe,\n \t\t}\n \t}\n \n-\tif (!m || !m->load())\n+\tif (!m)\n+\t\treturn nullptr;\n+\n+\tif (!isOpenSource(m->info().license)) {\n+\t\tIPAProxyFactory *pf = nullptr;\n+\t\tstd::vector<IPAProxyFactory *> &factories = IPAProxyFactory::factories();\n+\n+\t\tfor (IPAProxyFactory *factory : factories) {\n+\t\t\t/* TODO: Better matching */\n+\t\t\tif (!strcmp(factory->name().c_str(), \"IPAProxyLinux\")) {\n+\t\t\t\tpf = factory;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (!pf) {\n+\t\t\tLOG(IPAManager, Error) << \"Failed to get proxy factory\";\n+\t\t\treturn nullptr;\n+\t\t}\n+\n+\t\tstd::unique_ptr<IPAProxy> proxy = pf->create(m);\n+\t\tif (!proxy->isValid()) {\n+\t\t\tLOG(IPAManager, Error) << \"Failed to load proxy\";\n+\t\t\treturn nullptr;\n+\t\t}\n+\n+\t\treturn proxy;\n+\t}\n+\n+\tif (!m->load())\n \t\treturn nullptr;\n \n \treturn m->createInstance();\n","prefixes":["libcamera-devel","v3","5/7"]}