From patchwork Mon Apr 5 04:04:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11838 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 DE5ABBD695 for ; Mon, 5 Apr 2021 04:04:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9BCAC68783; Mon, 5 Apr 2021 06:04:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ZXelNUSs"; dkim-atps=neutral Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6CB7468783 for ; Mon, 5 Apr 2021 06:04:37 +0200 (CEST) Received: by mail-pj1-x1030.google.com with SMTP id f2-20020a17090a4a82b02900c67bf8dc69so7232576pjh.1 for ; Sun, 04 Apr 2021 21:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ioGqGKyDg6AOPNWzJo4tzO6VhLhGKaeK7IlLaRXe6fE=; b=ZXelNUSsZrkojiCsTvzI5C2VoI312mXjY8pgFmu/32FvmaVrnnARgJ+BETI58HYawQ Q7e/kXwQTAU+JwSWPJi1f9+4emfzCWuU/swpRRW975NR7nm37hAI+ldR2VK3HEGYWj/z mu/cFsMtj22HlGmoXWeH809LMR9225ejqowK8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ioGqGKyDg6AOPNWzJo4tzO6VhLhGKaeK7IlLaRXe6fE=; b=jdSl2ChFG/345u2TNqy9W7lVO2OJ+VR2x/BZEst+IyNUhoQJLdFrgf7E3bbHAr5hrx zClMYbjBasULgfv5JqBftY/DBsySPtxgO6TrziLCVvQk20DGINQb6+7BMIopUnMXrHHW GRZpKzvvFkSfnkoXWJeieXd2psV6eOTGqdFl9koUw3gUyy72z1hKk7zf3OUrILJRHD6V pFrKIBensbrQCIVukWtI7HsHvglZ8sEi4pVOoYkdJ0gDygXEDj+cQYoqllvVho08pzQk 7srG8Ez0qZw8vK2kDCq0ZaU9enYI1WpJgJm+EEAXTIC2j7ZQlmlUOB2lyX7X1WkbdmeZ 3hdQ== X-Gm-Message-State: AOAM533jVmectdlNNKceC/AvbxJrpEdJWUiGu/lM68uWw9hv9IIFD404 bWcCwTFWzhGca3FuWPplbcUnWutuDcrqRw== X-Google-Smtp-Source: ABdhPJzxL88fIfZzctyOl3/tU1ONKxMHKT8GJM8hYZYIQ7QGnrn60WTUteDotBA3fM1/e5RIextgIw== X-Received: by 2002:a17:902:8a83:b029:e7:1029:8ddc with SMTP id p3-20020a1709028a83b02900e710298ddcmr22589290plo.2.1617595475367; Sun, 04 Apr 2021 21:04:35 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:2581:afba:2075:466f]) by smtp.gmail.com with ESMTPSA id bb16sm7543783pjb.17.2021.04.04.21.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Apr 2021 21:04:35 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 5 Apr 2021 13:04:24 +0900 Message-Id: <20210405040424.1929737-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog In-Reply-To: <20210405040424.1929737-1-hiroh@chromium.org> References: <20210405040424.1929737-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] android: CameraDevice: Validate buffer_handle by CameraBuffer::isValid() 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This adds a validation to buffer_handle provided in CameraDevice::processCaptureRequest() by using CameraBuffer::isValid(). Signed-off-by: Hirokazu Honda --- src/android/camera_device.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 89044efa..0fff5927 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -257,6 +257,7 @@ void sortCamera3StreamConfigs(std::vector &unsortedConfigs, } bool isValidRequest(camera3_capture_request_t *camera3Request) + { if (!camera3Request) { LOG(HAL, Error) << "No capture request provided"; @@ -293,6 +294,13 @@ bool isValidRequest(camera3_capture_request_t *camera3Request) << ") in buffer " << i; return false; } + + CameraBuffer cameraBuffer(*outputBuffer.buffer, + PROT_READ | PROT_WRITE, /*map=*/false); + if (!cameraBuffer.isValid()) { + LOG(HAL, Error) << "cameraBuffer is invalid"; + return false; + } } return true;