From patchwork Mon Apr 27 03:17:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3553 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B23960AF0 for ; Mon, 27 Apr 2020 05:17:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Gp2XEtbO"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DCF7C97D for ; Mon, 27 Apr 2020 05:17:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587957453; bh=4K3q3LxITDScf4fk6mopnuQ3dB5mLsL2heWudNvKlRk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Gp2XEtbOZ3f3RjnupkZYXS3RAm6gp3X4I1cVzIDT+XG62f5lSvhqSP3tLgDPLN5kp Q1sluq2tS22iO/6zhpvgTvxWfSxb9bwRSWvkk/nAYF4OH3T/BGMDb6WTBNib4n5Zxz 0vFH3Xc7KCUMZ8H3ovU04oPdEUkZlEuo0jBBDjWQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 06:17:03 +0300 Message-Id: <20200427031713.14013-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> References: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 01/11] ipa: Name IPA modules after their source directory 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: , X-List-Received-Date: Mon, 27 Apr 2020 03:17:33 -0000 The IPAModuleInfo::name field is currently a free-formed string that has little use. Tighten its usage rules to make it suitable for building file system paths to IPA-specific resources by matching the directory name of the IPA module. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/ipa/rkisp1/rkisp1.cpp | 2 +- src/ipa/vimc/vimc.cpp | 2 +- src/libcamera/ipa_module.cpp | 20 ++++++++++++++++++++ test/ipa/ipa_module_test.cpp | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index acbbe58c7a2e..7f0ffb0a791f 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -274,7 +274,7 @@ const struct IPAModuleInfo ipaModuleInfo = { IPA_MODULE_API_VERSION, 1, "PipelineHandlerRkISP1", - "RkISP1 IPA", + "rkisp1", }; struct ipa_context *ipaCreate() diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp index d2267e11737f..cfdbd6f99155 100644 --- a/src/ipa/vimc/vimc.cpp +++ b/src/ipa/vimc/vimc.cpp @@ -126,7 +126,7 @@ const struct IPAModuleInfo ipaModuleInfo = { IPA_MODULE_API_VERSION, 0, "PipelineHandlerVimc", - "Dummy IPA for Vimc", + "vimc", }; struct ipa_context *ipaCreate() diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index 958ede74688e..52823e88a508 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -216,6 +217,11 @@ Span elfLoadSymbol(Span elf, const char *symbol) * \var IPAModuleInfo::name * \brief The name of the IPA module * + * The name may be used to build file system paths to IPA-specific resources. + * It shall only contain printable characters, and may not contain '/', '*', + * '?' or '\'. For IPA modules included in libcamera, it shall match the + * directory of the IPA module in the source tree. + * * \todo Allow user to choose to isolate open source IPAs */ @@ -287,6 +293,20 @@ int IPAModule::loadIPAModuleInfo() return -EINVAL; } + /* Validate the IPA module name. */ + std::string ipaName = info_.name; + auto iter = std::find_if_not(ipaName.begin(), ipaName.end(), + [](unsigned char c) -> bool { + return isprint(c) && c != '/' && + c != '?' && c != '*' && + c != '\\'; + }); + if (iter != ipaName.end()) { + LOG(IPAModule, Error) + << "Invalid IPA module name '" << ipaName << "'"; + return -EINVAL; + } + /* Load the signature. Failures are not fatal. */ File sign{ libPath_ + ".sign" }; if (!sign.open(File::ReadOnly)) { diff --git a/test/ipa/ipa_module_test.cpp b/test/ipa/ipa_module_test.cpp index d22c302fa726..e3aee190b410 100644 --- a/test/ipa/ipa_module_test.cpp +++ b/test/ipa/ipa_module_test.cpp @@ -58,7 +58,7 @@ protected: IPA_MODULE_API_VERSION, 0, "PipelineHandlerVimc", - "Dummy IPA for Vimc", + "vimc", }; count += runTest("src/ipa/vimc/ipa_vimc.so", testInfo);