{"id":13060,"url":"https://patchwork.libcamera.org/api/patches/13060/?format=json","web_url":"https://patchwork.libcamera.org/patch/13060/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20210720102853.28541-1-paul.elder@ideasonboard.com>","date":"2021-07-20T10:28:53","name":"[libcamera-devel,RFC] ipa: IPADataSerializer: Fix FileDescriptor deserialization","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"5465222f6a57782f760f1d08f77f4f3e8e5b639d","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13060/mbox/","series":[{"id":2260,"url":"https://patchwork.libcamera.org/api/series/2260/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2260","date":"2021-07-20T10:28:53","name":"[libcamera-devel,RFC] ipa: IPADataSerializer: Fix FileDescriptor deserialization","version":1,"mbox":"https://patchwork.libcamera.org/series/2260/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13060/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13060/checks/","tags":{},"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 8D43DC322B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 20 Jul 2021 10:29:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 96CF068546;\n\tTue, 20 Jul 2021 12:29:04 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A13436853F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 20 Jul 2021 12:29:03 +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 C52AF443;\n\tTue, 20 Jul 2021 12:29:01 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"OWYDDxTc\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626776943;\n\tbh=wq1UefxZgfJgrVBj+J6uuS9slpCYoK6HfJFhoZVHJa0=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=OWYDDxTcM/IdJhRfKvyfxfNy73bfv0O8aeBLzOB7/vYL9kSJLN3wa8hiEusP+d5Wp\n\tjt+6qqT6XPgFaSUeimRra+R8hJ0ZBuTXX2DbQE2trz3gxhZGiMJE5DczqhW5dfEGTc\n\tKnikr7WIPWQABoy5G0P0IOXlVnDlaJX/lGBPiWD0=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 20 Jul 2021 19:28:53 +0900","Message-Id":"<20210720102853.28541-1-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH] ipa: IPADataSerializer: Fix\n\tFileDescriptor deserialization","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>"},"content":"Previously deserializing a FileDescriptor would use the copy\nconstructor, causing an fd leak. Fix this by copying the fd integer to\nforce the FileDescriptor to use the move constructor.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nUmang, could you please check if this fixes the issue?\n\nI'll remove the error message; it's just there for debugging (or we can\nkeep it to protect against unforseen errors?)\n---\n src/libcamera/ipa_data_serializer.cpp | 10 +++++++++-\n 1 file changed, 9 insertions(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/ipa_data_serializer.cpp b/src/libcamera/ipa_data_serializer.cpp\nindex fb941e6b..2a527d5d 100644\n--- a/src/libcamera/ipa_data_serializer.cpp\n+++ b/src/libcamera/ipa_data_serializer.cpp\n@@ -8,6 +8,7 @@\n #include \"libcamera/internal/ipa_data_serializer.h\"\n \n #include <libcamera/base/log.h>\n+#include <unistd.h>\n \n /**\n  * \\file ipa_data_serializer.h\n@@ -547,7 +548,14 @@ FileDescriptor IPADataSerializer<FileDescriptor>::deserialize(std::vector<uint8_\n \n \tASSERT(!(valid && std::distance(fdsBegin, fdsEnd) < 1));\n \n-\treturn valid ? FileDescriptor(*fdsBegin) : FileDescriptor();\n+\tint tmpfd = valid ? *fdsBegin : -1;\n+\tFileDescriptor fd = FileDescriptor(tmpfd);\n+\tif (valid && tmpfd != -1) {\n+\t\tLOG(IPADataSerializer, Error) << \"We probably leaked an fd\";\n+\t\tclose(tmpfd);\n+\t}\n+\n+\treturn fd;\n }\n \n template<>\n","prefixes":["libcamera-devel","RFC"]}