From patchwork Sun Nov 20 05:06:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Roth X-Patchwork-Id: 17817 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 336B7BD16B for ; Sun, 20 Nov 2022 05:06:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6A7A7632F6; Sun, 20 Nov 2022 06:06:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1668920804; bh=MjjszSbjycGcImtGvBbGm6j4vdRO2mQsS73UgvaoIF4=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Tum814SJZrc27gUX+85rcj1zmzvQKDrfjO359D08ygqojgomMWjKhsRBzzeg3lnOT uMhUnOvWj3UEE1k5UC5i4TZ64MGCallL9B+SjFhaLD4fUu7J0eoStgtcHezSsqd7QC bxsoDMBRdrsZ7iQehrkORDkAhHrjfRkq2aWMc4EuE5Dc7nwaK83Rd3ZAvVYp64bvt4 N4XhgT9eqFxssjFCCh4b4stuK34A/5j3rtIG7QoGsA/fO2/Fu1VH8B4L57H4ddtNXK ghE3IJoaYJuehHmTvz999CwagGrM8DscA2PXN+AV1MFL0qDR2Fl/N25pcL2miDv63C FvSxwgK4jM8wQ== Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 34C9A61F2C for ; Sun, 20 Nov 2022 06:06:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=rothemail-net.20210112.gappssmtp.com header.i=@rothemail-net.20210112.gappssmtp.com header.b="ukY7Dvkg"; dkim-atps=neutral Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-14263779059so9644941fac.1 for ; Sat, 19 Nov 2022 21:06:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothemail-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZMN0OTP90y2gQcpuGI910HisZWNQFDNywIGWsPRD868=; b=ukY7DvkgC4R9K0JelQp2jB6IYTbn3sPKbGpgi1RZ/h53NgPTLbkVYXlPW2NpB0x5/7 CWmzsgaKXooQd/4Ov5n7sK84/34gAsc93TjGwtrmthCracEj7mBUQgeSeWzgN2zUfIA9 8F1/PWgVl4u0LNZqzR5qMJ1YpfUEFuUrRNOcWROe8zlGB/ZbOegjfNNOvfbJNJfarYYr VwTEZybU0Jp4DRy+2iJ2chWAyeUgLyL/3ymXN1wcd8pyAP1DJUoRYZ/kVxZe1UQ8A289 lN/tDl+ZMdaMb7nKeivT/C8nGqDofzg2tNBDkQ7TPmNEGsyGqRtncjTlSmNyL4bYzriD hKpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZMN0OTP90y2gQcpuGI910HisZWNQFDNywIGWsPRD868=; b=ymzZwWhMnhO45tXeVxnZudg1hQt6ugbYIaowt4OPvSZ2jgEGNhmC41GbLtXLiYeWMo emz1anNlncDRKUWKuu5JedLjXpwkpHfdqMQfZDUfC6j42Z6he3uBGi4R4TUu4z9QILue wKSLJy8x+uUzzVsEvx4DWb89Gz19A9dGm0qu3u68ijd4M7+vc4aIBRSI2gEqqVtNfGCk 6YRv5qvZR88dVNEQfKqKmqGD7SHe/CDsY1psYEsivubwBOz8Y+0Dv5g9aWuRv6SESVsy Uc0lZ/5zJne62x4y5HyI6uODLgewTAbnfvrMnaycSB7p8QofxihjGjDSSGW0euJYSuu6 YTPw== X-Gm-Message-State: ANoB5pnTh+OOoERD2ikHrlSNzy3IA0bso69MJn2DWk5UtRsftb7RImR9 BTzahyK3UfsPpe3tffjrVR7ZI5xsQgNM9Scq X-Google-Smtp-Source: AA0mqf76LMl7b6ofY3OqVuBm9555/Fbw7n9w5hTRIDhhq7BID1cj7ivfLH2NxcrGpOwS1qaSzyIlMg== X-Received: by 2002:a05:6870:ad05:b0:132:1c:9aad with SMTP id nt5-20020a056870ad0500b00132001c9aadmr7394333oab.168.1668920800614; Sat, 19 Nov 2022 21:06:40 -0800 (PST) Received: from nroth-pc.attlocal.net ([2600:1700:20:20c0:4d5a:6dd2:a2e5:7f2c]) by smtp.gmail.com with ESMTPSA id e18-20020a05683013d200b0063696cbb6bdsm3416295otq.62.2022.11.19.21.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 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 Subject: [libcamera-devel] [PATCH] android: Fix improper file descriptor enumeration 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-Patchwork-Original-From: Nicholas Roth via libcamera-devel From: Nicholas Roth Reply-To: Nicholas Roth Cc: Nicholas Roth Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Currently, they way camera_device.cpp handles file descriptors in a buffer_handle_t is incorrect. This can result in the HAL attempting to treat uninitialized memory like file descriptors, usually resulting in a crash. This patch brings the behavior of camera_device.cpp in line with how CameraBuffer handles file descriptors and planes. Bug: https://bugs.libcamera.org/show_bug.cgi?id=172 Signed-off-by: Nicholas Roth --- src/android/camera_device.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index b20e389b..1459d582 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -781,14 +781,18 @@ CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer, return nullptr; } + if (camera3buffer->numFds > 1) { + LOG(HAL, Fatal) << "Discontiguous planes are not supported"; + } + + SharedFD fd{ camera3buffer->data[0] }; + if (!fd.isValid()) { + LOG(HAL, Fatal) << "No valid fd"; + return nullptr; + } + std::vector planes(buf.numPlanes()); for (size_t i = 0; i < buf.numPlanes(); ++i) { - SharedFD fd{ camera3buffer->data[i] }; - if (!fd.isValid()) { - LOG(HAL, Fatal) << "No valid fd"; - return nullptr; - } - planes[i].fd = fd; planes[i].offset = buf.offset(i); planes[i].length = buf.size(i);