Patch Detail
Show a patch.
GET /api/patches/8405/?format=api
{ "id": 8405, "url": "https://patchwork.libcamera.org/api/patches/8405/?format=api", "web_url": "https://patchwork.libcamera.org/patch/8405/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200624145256.48266-8-paul.elder@ideasonboard.com>", "date": "2020-06-24T14:52:41", "name": "[libcamera-devel,v4,07/22] v4l2: v4l2_camera_proxy: Check for null arg values in main ioctl handler", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "a06c3d727e387b094dd2956aaeeea9ca5836429c", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/8405/mbox/", "series": [ { "id": 1041, "url": "https://patchwork.libcamera.org/api/series/1041/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1041", "date": "2020-06-24T14:52:34", "name": "Support v4l2-compliance", "version": 4, "mbox": "https://patchwork.libcamera.org/series/1041/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/8405/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/8405/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 5AED460103\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Jun 2020 16:53:32 +0200 (CEST)", "from jade.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:8147:f2a2:a8c6:9087])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6AACB2A8;\n\tWed, 24 Jun 2020 16:53:30 +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=\"sCg0us9d\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593010411;\n\tbh=G36meBW3/oabvoBeWi92FPqTWw9anNR8EVNw9Ert6l8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=sCg0us9d7VMBotLFcJQUNmbLnZVtOXSrk6u9LjkCb8AlLAwaHLSNhs2KODPRekDSa\n\tcBHjVgGWCfrIcsM6fQpOgNWrr6SrKXWe5TJSQ+Xcxo35j/g+MpglqT6MF43TlNZB2N\n\tnf2Z+q3OPqbAiAGRpU3DrD1ue3yhW5lNr4YAdqXg=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 24 Jun 2020 23:52:41 +0900", "Message-Id": "<20200624145256.48266-8-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200624145256.48266-1-paul.elder@ideasonboard.com>", "References": "<20200624145256.48266-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 07/22] v4l2: v4l2_camera_proxy: Check\n\tfor null arg values in main ioctl handler", "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": "Wed, 24 Jun 2020 14:53:32 -0000" }, "content": "The ioctl handlers currently don't check if arg is null, so if it ever\nis, it will cause a segfault. Check that arg is null and return -EFAULT\nin the main vidioc ioctl handler.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\nNo change in v4\n\nChanges in v3:\n- check ioctl rw flags for proper return value error\n- cosmetic changes\n\nChanges in v2:\n- moved !arg check to main ioctl handler, and added a set of supported\n ioctls\n- use !arg instead of arg == nullptr\n---\n src/v4l2/v4l2_camera_proxy.cpp | 30 ++++++++++++++++++++++++++++++\n src/v4l2/v4l2_camera_proxy.h | 3 +++\n 2 files changed, 33 insertions(+)", "diff": "diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 66feb77..011e4a4 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -11,6 +11,7 @@\n #include <array>\n #include <errno.h>\n #include <linux/videodev2.h>\n+#include <set>\n #include <string.h>\n #include <sys/mman.h>\n #include <unistd.h>\n@@ -523,8 +524,37 @@ int V4L2CameraProxy::vidioc_streamoff(V4L2CameraFile *file, int *arg)\n \treturn ret;\n }\n \n+const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {\n+\tVIDIOC_QUERYCAP,\n+\tVIDIOC_ENUM_FMT,\n+\tVIDIOC_G_FMT,\n+\tVIDIOC_S_FMT,\n+\tVIDIOC_TRY_FMT,\n+\tVIDIOC_REQBUFS,\n+\tVIDIOC_QUERYBUF,\n+\tVIDIOC_QBUF,\n+\tVIDIOC_DQBUF,\n+\tVIDIOC_STREAMON,\n+\tVIDIOC_STREAMOFF,\n+};\n+\n int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *arg)\n {\n+\tif (!arg && (_IOC_DIR(request) & _IOC_WRITE)) {\n+\t\terrno = EFAULT;\n+\t\treturn -1;\n+\t}\n+\n+\tif (supportedIoctls_.find(request) == supportedIoctls_.end()) {\n+\t\terrno = ENOTTY;\n+\t\treturn -1;\n+\t}\n+\n+\tif (!arg && (_IOC_DIR(request) & _IOC_READ)) {\n+\t\terrno = EFAULT;\n+\t\treturn -1;\n+\t}\n+\n \tint ret;\n \tswitch (request) {\n \tcase VIDIOC_QUERYCAP:\ndiff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\nindex 36d1dbc..86c1a7d 100644\n--- a/src/v4l2/v4l2_camera_proxy.h\n+++ b/src/v4l2/v4l2_camera_proxy.h\n@@ -11,6 +11,7 @@\n #include <linux/videodev2.h>\n #include <map>\n #include <memory>\n+#include <set>\n #include <sys/mman.h>\n #include <sys/types.h>\n #include <vector>\n@@ -68,6 +69,8 @@ private:\n \tstatic PixelFormat v4l2ToDrm(uint32_t format);\n \tstatic uint32_t drmToV4L2(const PixelFormat &format);\n \n+\tstatic const std::set<unsigned long> supportedIoctls_;\n+\n \tunsigned int refcount_;\n \tunsigned int index_;\n \n", "prefixes": [ "libcamera-devel", "v4", "07/22" ] }