Patch Detail
Show a patch.
GET /api/1.1/patches/18311/?format=api
{ "id": 18311, "url": "https://patchwork.libcamera.org/api/1.1/patches/18311/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18311/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20230227203947.3964157-1-kieran.bingham@ideasonboard.com>", "date": "2023-02-27T20:39:47", "name": "[libcamera-devel] v4l2: v4l2_camera_proxy: Detect ioctl sign-extensions", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "6ae6f5ba0594c342044f39eae69d1eb88e75d1fb", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18311/mbox/", "series": [ { "id": 3772, "url": "https://patchwork.libcamera.org/api/1.1/series/3772/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3772", "date": "2023-02-27T20:39:47", "name": "[libcamera-devel] v4l2: v4l2_camera_proxy: Detect ioctl sign-extensions", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3772/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18311/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18311/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 DA46CBE08A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 27 Feb 2023 20:39:52 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4C77662682;\n\tMon, 27 Feb 2023 21:39:52 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7897C6265A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Feb 2023 21:39:51 +0100 (CET)", "from Monstersaurus.tail69b4.ts.net\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D7713B6C;\n\tMon, 27 Feb 2023 21:39:50 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1677530392;\n\tbh=+u8FEk7YJk4LFsAu76n1VZ5vxvx6FzJyjBfudTVNRbM=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=K4Pyn4X1u9yKpiUZTEDNKEAW+IhrNk1Tyn4PwHsB6ju/7ezXvOSgXy9cUAJLuoA4L\n\tIP/attLADgqlP7W7dHpp+sIiYcouBjuvX88WA3Hx66bcld1IM7YQbTN7LVipgAyY7w\n\tCyy09CrfNcQ8SidNaMWCi7RTc8w4ZxWfEcflW6UCZUEawvsDKsrI2wtZkpkltOM5aw\n\tnqfmuk8lFOnzLAA4fHUJBNkceuaY6fmvUCL7STOA5y2QAHoG3/1Q8MvdIA9zyGcham\n\tZWMxFt9HfL/o+nEN7/6XlfgBNuxDdP79cIT+vW2aA8sU1TEXET2mZTSiki09uDEM1l\n\tfDO2aObo1c/4Q==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1677530391;\n\tbh=+u8FEk7YJk4LFsAu76n1VZ5vxvx6FzJyjBfudTVNRbM=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=aDhf1GFXhfNAN71Ia+G9jxiu20oTdg6PSZVowBdQy9dbEhuWflz64vocoooib4qJ7\n\tOkWTmeCBfQ8uc7DPHRy+eD8Lvfz8BrxtXM+bCtp5UCX5j3fbh/UA9Vll9OQmqY4/Bb\n\tNdqEBttCovp5SvtlXLqWTbNqKVhzMB85dWHxxHS8=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"aDhf1GFX\"; dkim-atps=neutral", "To": "libcamera devel <libcamera-devel@lists.libcamera.org>", "Date": "Mon, 27 Feb 2023 20:39:47 +0000", "Message-Id": "<20230227203947.3964157-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: Detect 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\nWe can easily identify if an application has mistakenly sign-extended an\nioctl command request and mask out those bits.\n\nDo so and report the error loudly, but only once that the application\nshould be fixed.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n\nThis is a pain. It's not 'libcamera's' fault. But we can do something\nabout it.\n\nSee\n - https://github.com/kbingham/libcamera/issues/69\nand\n - https://github.com/Motion-Project/motion/discussions/1636\n\n\n\n src/v4l2/v4l2_camera_proxy.cpp | 18 ++++++++++++++++++\n 1 file changed, 18 insertions(+)", "diff": "diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 55ff62cdb430..75c53aedf2fa 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -782,6 +782,24 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar\n {\n \tMutexLocker locker(proxyMutex_);\n \n+\t/*\n+\t * Applications may easily find themselves incorrectly sign-extending\n+\t * ioctls on 64-bit systems which can cause hard to diagnose failures\n+\t * with the v4l2-adatation layer. Identify this failure, and work\n+\t * around it - but report the issue as it should be fixed in the\n+\t * application.\n+\t */\n+\tif (request & 0xffffffff00000000) {\n+\t\tstatic bool warnOnce = true;\n+\n+\t\tif (warnOnce) {\n+\t\t\tLOG(V4L2Compat, Error) << \"ioctl sign extension detected.\";\n+\t\t\tLOG(V4L2Compat, Error) << \"Please fix your application.\";\n+\t\t\twarnOnce = false;\n+\t\t}\n+\t\trequest &= 0xffffffff;\n+\t}\n+\n \tif (!arg && (_IOC_DIR(request) & _IOC_WRITE)) {\n \t\terrno = EFAULT;\n \t\treturn -1;\n", "prefixes": [ "libcamera-devel" ] }