{"id":17817,"url":"https://patchwork.libcamera.org/api/patches/17817/?format=json","web_url":"https://patchwork.libcamera.org/patch/17817/","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":"<20221120050629.144188-1-nicholas@rothemail.net>","date":"2022-11-20T05:06:29","name":"[libcamera-devel] android: Fix improper file descriptor enumeration","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"d2489517ed9c021278bf0f2fa1befe2368dce22d","submitter":{"id":137,"url":"https://patchwork.libcamera.org/api/people/137/?format=json","name":"Nicholas Roth","email":"nicholas@rothemail.net"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17817/mbox/","series":[{"id":3621,"url":"https://patchwork.libcamera.org/api/series/3621/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3621","date":"2022-11-20T05:06:29","name":"[libcamera-devel] android: Fix improper file descriptor enumeration","version":1,"mbox":"https://patchwork.libcamera.org/series/3621/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17817/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17817/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 336B7BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 20 Nov 2022 05:06:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6A7A7632F6;\n\tSun, 20 Nov 2022 06:06:44 +0100 (CET)","from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com\n\t[IPv6:2001:4860:4864:20::2d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 34C9A61F2C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 20 Nov 2022 06:06:42 +0100 (CET)","by mail-oa1-x2d.google.com with SMTP id\n\t586e51a60fabf-14263779059so9644941fac.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 19 Nov 2022 21:06:42 -0800 (PST)","from nroth-pc.attlocal.net\n\t([2600:1700:20:20c0:4d5a:6dd2:a2e5:7f2c])\n\tby smtp.gmail.com with ESMTPSA id\n\te18-20020a05683013d200b0063696cbb6bdsm3416295otq.62.2022.11.19.21.06.40\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 19 Nov 2022 21:06:40 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1668920804;\n\tbh=MjjszSbjycGcImtGvBbGm6j4vdRO2mQsS73UgvaoIF4=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=Tum814SJZrc27gUX+85rcj1zmzvQKDrfjO359D08ygqojgomMWjKhsRBzzeg3lnOT\n\tuMhUnOvWj3UEE1k5UC5i4TZ64MGCallL9B+SjFhaLD4fUu7J0eoStgtcHezSsqd7QC\n\tbxsoDMBRdrsZ7iQehrkORDkAhHrjfRkq2aWMc4EuE5Dc7nwaK83Rd3ZAvVYp64bvt4\n\tN4XhgT9eqFxssjFCCh4b4stuK34A/5j3rtIG7QoGsA/fO2/Fu1VH8B4L57H4ddtNXK\n\tghE3IJoaYJuehHmTvz999CwagGrM8DscA2PXN+AV1MFL0qDR2Fl/N25pcL2miDv63C\n\tFvSxwgK4jM8wQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=rothemail-net.20210112.gappssmtp.com; s=20210112;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=ZMN0OTP90y2gQcpuGI910HisZWNQFDNywIGWsPRD868=;\n\tb=ukY7DvkgC4R9K0JelQp2jB6IYTbn3sPKbGpgi1RZ/h53NgPTLbkVYXlPW2NpB0x5/7\n\tCWmzsgaKXooQd/4Ov5n7sK84/34gAsc93TjGwtrmthCracEj7mBUQgeSeWzgN2zUfIA9\n\t8F1/PWgVl4u0LNZqzR5qMJ1YpfUEFuUrRNOcWROe8zlGB/ZbOegjfNNOvfbJNJfarYYr\n\tVwTEZybU0Jp4DRy+2iJ2chWAyeUgLyL/3ymXN1wcd8pyAP1DJUoRYZ/kVxZe1UQ8A289\n\tlN/tDl+ZMdaMb7nKeivT/C8nGqDofzg2tNBDkQ7TPmNEGsyGqRtncjTlSmNyL4bYzriD\n\thKpQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=rothemail-net.20210112.gappssmtp.com\n\theader.i=@rothemail-net.20210112.gappssmtp.com header.b=\"ukY7Dvkg\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=ZMN0OTP90y2gQcpuGI910HisZWNQFDNywIGWsPRD868=;\n\tb=ymzZwWhMnhO45tXeVxnZudg1hQt6ugbYIaowt4OPvSZ2jgEGNhmC41GbLtXLiYeWMo\n\temz1anNlncDRKUWKuu5JedLjXpwkpHfdqMQfZDUfC6j42Z6he3uBGi4R4TUu4z9QILue\n\twKSLJy8x+uUzzVsEvx4DWb89Gz19A9dGm0qu3u68ijd4M7+vc4aIBRSI2gEqqVtNfGCk\n\t6YRv5qvZR88dVNEQfKqKmqGD7SHe/CDsY1psYEsivubwBOz8Y+0Dv5g9aWuRv6SESVsy\n\tUc0lZ/5zJne62x4y5HyI6uODLgewTAbnfvrMnaycSB7p8QofxihjGjDSSGW0euJYSuu6\n\tYTPw==","X-Gm-Message-State":"ANoB5pnTh+OOoERD2ikHrlSNzy3IA0bso69MJn2DWk5UtRsftb7RImR9\n\tBTzahyK3UfsPpe3tffjrVR7ZI5xsQgNM9Scq","X-Google-Smtp-Source":"AA0mqf76LMl7b6ofY3OqVuBm9555/Fbw7n9w5hTRIDhhq7BID1cj7ivfLH2NxcrGpOwS1qaSzyIlMg==","X-Received":"by 2002:a05:6870:ad05:b0:132:1c:9aad with SMTP id\n\tnt5-20020a056870ad0500b00132001c9aadmr7394333oab.168.1668920800614; \n\tSat, 19 Nov 2022 21:06:40 -0800 (PST)","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 19 Nov 2022 23:06:29 -0600","Message-Id":"<20221120050629.144188-1-nicholas@rothemail.net>","X-Mailer":"git-send-email 2.34.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] android: Fix improper file descriptor\n\tenumeration","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>","From":"Nicholas Roth via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Nicholas Roth <nicholas@rothemail.net>","Cc":"Nicholas Roth <nicholas@rothemail.net>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Currently, they way camera_device.cpp handles file descriptors in a\nbuffer_handle_t is incorrect. This can result in the HAL attempting to\ntreat uninitialized memory like file descriptors, usually resulting in\na crash.\n\nThis patch brings the behavior of camera_device.cpp in line with how\nCameraBuffer handles file descriptors and planes.\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=172\n\nSigned-off-by: Nicholas Roth <nicholas@rothemail.net>\n---\n src/android/camera_device.cpp | 16 ++++++++++------\n 1 file changed, 10 insertions(+), 6 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex b20e389b..1459d582 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -781,14 +781,18 @@ CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer,\n \t\treturn nullptr;\n \t}\n \n+\tif (camera3buffer->numFds > 1) {\n+\t\tLOG(HAL, Fatal) << \"Discontiguous planes are not supported\";\n+\t}\n+\n+\tSharedFD fd{ camera3buffer->data[0] };\n+\tif (!fd.isValid()) {\n+\t\tLOG(HAL, Fatal) << \"No valid fd\";\n+\t\treturn nullptr;\n+\t}\n+\n \tstd::vector<FrameBuffer::Plane> planes(buf.numPlanes());\n \tfor (size_t i = 0; i < buf.numPlanes(); ++i) {\n-\t\tSharedFD fd{ camera3buffer->data[i] };\n-\t\tif (!fd.isValid()) {\n-\t\t\tLOG(HAL, Fatal) << \"No valid fd\";\n-\t\t\treturn nullptr;\n-\t\t}\n-\n \t\tplanes[i].fd = fd;\n \t\tplanes[i].offset = buf.offset(i);\n \t\tplanes[i].length = buf.size(i);\n","prefixes":["libcamera-devel"]}