From d81505b834105ee1c879a962a2911d08b14ad5fd Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 22 Dec 2022 04:01:20 +0200 Subject: libcamera: ipa_module: Relax ipaModuleInfo symbol size check When an IPA module is loaded, the loadIPAModuleInfo() function validates the ipaModuleInfo structure. As part of that process, it checks that the ipaModuleInfo symbol size matches the expected structure size. This check breaks with clang and ASan, as the LLVM's address sanitizer implementation includes the redzone after the structure in the symbol size, currently growing it by 156 bytes (on x86-64). This causes all IPA modules to fail to load. Fix the problem by relaxing the size check to only ensure that the symbol is large enough to contain the structure. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/ipa_module.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index c9ff7de3..c152153c 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -288,12 +288,12 @@ int IPAModule::loadIPAModuleInfo() } Span info = elfLoadSymbol(data, "ipaModuleInfo"); - if (info.size() != sizeof(info_)) { + if (info.size() < sizeof(info_)) { LOG(IPAModule, Error) << "IPA module has no valid info"; return -EINVAL; } - memcpy(&info_, info.data(), info.size()); + memcpy(&info_, info.data(), sizeof(info_)); if (info_.moduleAPIVersion != IPA_MODULE_API_VERSION) { LOG(IPAModule, Error) << "IPA module API version mismatch"; -- cgit v1.2.1