Patch Detail
Show a patch.
GET /api/patches/18787/?format=api
{ "id": 18787, "url": "https://patchwork.libcamera.org/api/patches/18787/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18787/", "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": "<20230704232248.3861085-1-kieran.bingham@ideasonboard.com>", "date": "2023-07-04T23:22:48", "name": "[libcamera-devel] v4l2: v4l2_camera_proxy: Prevent ioctl sign-extensions", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "294ee449a57051d1cc00d6c3566a32d590766ba8", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18787/mbox/", "series": [ { "id": 3953, "url": "https://patchwork.libcamera.org/api/series/3953/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3953", "date": "2023-07-04T23:22:48", "name": "[libcamera-devel] v4l2: v4l2_camera_proxy: Prevent ioctl sign-extensions", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3953/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18787/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18787/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 0FC04BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 4 Jul 2023 23:22:54 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C012B628C2;\n\tWed, 5 Jul 2023 01:22:53 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BAAE1628BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 5 Jul 2023 01:22:52 +0200 (CEST)", "from Monstersaurus.local\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 518688CC;\n\tWed, 5 Jul 2023 01:22:08 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1688512973;\n\tbh=58B1n69bNB2QOwaet6E2oDoxYLixzgjJeIRy3NPNLcM=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=qIb4UeyppR5+p/KHU5bkBvcYw12FHji1fiLSjZ3FfbQVx5YWEnV0J3lhrBoABzGxf\n\taOXz+BPbMFSKgtdO+zAt2o057ySmrVDEoLD5dcuE9XKqYNaca//HH1uAb1CcPygSr4\n\tz/kT7U1r1I6v6AMnn2fcNX2r2V2CbmV5eSiiN4jdKvrPepK2pn4j7HhtH7LQM/+vcU\n\t6kZriOAvqRZ7CsXadCK/ZPOgDUtCjqxYgp7DSUM8FRe3WqQ63xgJ6LOOXMCh3NAQcR\n\tMSDW6vSB7aT2hPkq+MNAyk23LEAwcPsemUGLt4hrB6+IahC1pcUHlzkZGRq2mzB5e5\n\tTwDuDKfscv0vA==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1688512928;\n\tbh=58B1n69bNB2QOwaet6E2oDoxYLixzgjJeIRy3NPNLcM=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=XbnNEGl84J4mYO3cUZz8GTlsDx+IUKKlcWsbuQAph/bUa2KWud03Q8Dkl0ltWrqGX\n\tbEJ0H7rwlPeVz3wffTon75q7rCqm3wSPTz4WFb6/AXdJRqmcNkGDqhfbJ6FOqWzCqy\n\tu5ejsZvelWx8DwJuzW0gG70K0EGJHMRMmFu5z4Eg=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"XbnNEGl8\"; dkim-atps=neutral", "To": "libcamera devel <libcamera-devel@lists.libcamera.org>", "Date": "Wed, 5 Jul 2023 00:22:48 +0100", "Message-Id": "<20230704232248.3861085-1-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.34.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH] v4l2: v4l2_camera_proxy: Prevent ioctl\n\tsign-extensions", "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": "Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Handling ioctl's within applications is often wrapped with a helper such\nas xioctl. Unfortunately, there are many instances of xioctl which\nincorrectly handle the correct size of the ioctl request.\n\nThis leads to incorrect sign-extension of ioctl's which have bit-31 set,\nand can cause values to be passed into the libcamera's v4l2 adaptation\nlayer which no longer represent the true IOCTL code.\n\nMatch the implementation of the Linux kernel and ensure that only 32\nbits of the ioctl request are used by assigning to an unsigned int.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\nThis is a (simpler) rework of the previous patch [0]:\n v4l2: v4l2_camera_proxy: Detect ioctl sign-extensions \n\n[0] https://patchwork.libcamera.org/patch/18311/\n\n src/v4l2/v4l2_camera_proxy.cpp | 12 +++++++++++-\n 1 file changed, 11 insertions(+), 1 deletion(-)", "diff": "diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 55ff62cdb430..dfb672080219 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -778,10 +778,20 @@ const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {\n \tVIDIOC_STREAMOFF,\n };\n \n-int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *arg)\n+int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long longRequest, void *arg)\n {\n \tMutexLocker locker(proxyMutex_);\n \n+\t/*\n+\t * The Linux Kernel only processes 32 bits of an IOCTL.\n+\t *\n+\t * Prevent unexpected sign-extensions that could occur if applications\n+\t * use an unsigned int for the ioctl request, which would sign-extend\n+\t * to an incorrect value for unsigned longs on 64 bit architectures by\n+\t * explicitly casting as an unsigned int here.\n+\t */\n+\tunsigned int request = longRequest;\n+\n \tif (!arg && (_IOC_DIR(request) & _IOC_WRITE)) {\n \t\terrno = EFAULT;\n \t\treturn -1;\n", "prefixes": [ "libcamera-devel" ] }