{"id":4094,"url":"https://patchwork.libcamera.org/api/1.1/patches/4094/?format=json","web_url":"https://patchwork.libcamera.org/patch/4094/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20200619054123.19052-15-paul.elder@ideasonboard.com>","date":"2020-06-19T05:41:20","name":"[libcamera-devel,v2,14/17] v4l2: v4l2_camera_proxy: Check arg->index bounds for querybuf, qbuf, dqbuf","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"30945678d9a936b0e579cd2424f925708b18243e","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/4094/mbox/","series":[{"id":1017,"url":"https://patchwork.libcamera.org/api/1.1/series/1017/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1017","date":"2020-06-19T05:41:06","name":"Support v4l2-compliance","version":2,"mbox":"https://patchwork.libcamera.org/series/1017/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/4094/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/4094/checks/","tags":{},"headers":{"Return-Path":"<paul.elder@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F8D4609B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Jun 2020 07:42:06 +0200 (CEST)","from jade.flets-east.jp (unknown\n\t[IPv6:2400:4051:61:600:e972:d773:e99a:4f79])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1FE59556;\n\tFri, 19 Jun 2020 07:42:03 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"DEM+aRg2\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592545325;\n\tbh=b+SYRZB8mkMQgjcjO0CZfoF0cBbxQ7PSL4voYt6+5dw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=DEM+aRg2kfAPLJbJqB838avZsQt2ZxUoo6/pGNp4EZcflcCSdSl64NbtN2XR/BC/j\n\tYpgzs8cQVweYd4g3l4cMqle7o8GPXAoLxNtqyUGVcrDX3xMo6I59ZqlOBOAR+nQoL5\n\tCOebupB33prCijjLjluRvmroC7YhQLyNxGs/yjag=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 19 Jun 2020 14:41:20 +0900","Message-Id":"<20200619054123.19052-15-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200619054123.19052-1-paul.elder@ideasonboard.com>","References":"<20200619054123.19052-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 14/17] v4l2: v4l2_camera_proxy: Check\n\targ->index bounds for querybuf, qbuf, dqbuf","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>","X-List-Received-Date":"Fri, 19 Jun 2020 05:42:06 -0000"},"content":"There were no bounds checks for the index argument for VIDIOC_QUERYBUF,\nVIDIOC_QBUF, and VIDIOC_DQBUF. Add them.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\nNo change in v2\n---\n src/v4l2/v4l2_camera_proxy.cpp | 9 +++++++++\n 1 file changed, 9 insertions(+)","diff":"diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 2723450..8396f58 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -540,6 +540,9 @@ int V4L2CameraProxy::vidioc_querybuf(V4L2CameraFile *cf, struct v4l2_buffer *arg\n {\n \tLOG(V4L2Compat, Debug) << \"Servicing vidioc_querybuf fd = \" << cf->efd();\n \n+\tif (arg->index >= bufferCount_)\n+\t\treturn -EINVAL;\n+\n \tint ret = lock(cf);\n \tif (ret < 0)\n \t\treturn ret;\n@@ -560,6 +563,9 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *cf, struct v4l2_buffer *arg)\n \tLOG(V4L2Compat, Debug) << \"Servicing vidioc_qbuf, index = \"\n \t\t\t       << arg->index << \" fd = \" << cf->efd();\n \n+\tif (arg->index >= bufferCount_)\n+\t\treturn -EINVAL;\n+\n \tint ret = lock(cf);\n \tif (ret < 0)\n \t\treturn ret;\n@@ -586,6 +592,9 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *cf, struct v4l2_buffer *arg)\n \tif (!vcam_->isRunning())\n \t\treturn -EINVAL;\n \n+\tif (arg->index >= bufferCount_)\n+\t\treturn -EINVAL;\n+\n \tint ret = lock(cf);\n \tif (ret < 0)\n \t\treturn ret;\n","prefixes":["libcamera-devel","v2","14/17"]}