[{"id":26382,"web_url":"https://patchwork.libcamera.org/comment/26382/","msgid":"<20230130193142.zta72fefbrhosynd@uno.localdomain>","date":"2023-01-30T19:31:42","subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: camera: Ensure queued\n\trequests are prepared","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Kieran\n\nOn Mon, Jan 30, 2023 at 06:02:43PM +0000, Kieran Bingham via libcamera-devel wrote:\n> Invalid, or not correctly reset requests can cause undefined behaviour\n> in the pipeline handlers due to unexpected request state.\n>\n> If the status has not been reset to Request::RequestPending, it is\n> either not new, or has not been correctly procesed through\n> Request::reuse().\n>\n> This can be caught early by validating the status of the request when it\n> is queued to a camera.\n>\n> Reject invalid requests before processing them in the pipeline handlers.\n>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/libcamera/camera.cpp | 5 +++++\n>  1 file changed, 5 insertions(+)\n>\n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index 0da167a7bc51..48bf19b28979 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -1126,6 +1126,11 @@ int Camera::queueRequest(Request *request)\n>  \t\treturn -EXDEV;\n>  \t}\n>\n> +\tif (request->status() != Request::RequestPending) {\n> +\t\tLOG(Camera, Error) << request->toString() << \" is not prepared\";\n> +\t\treturn -EINVAL;\n> +\t}\n> +\n\nLooks useful\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\n>  \t/*\n>  \t * The camera state may change until the end of the function. No locking\n>  \t * is however needed as PipelineHandler::queueRequest() will handle\n> --\n> 2.34.1\n>","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 CFD44BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 Jan 2023 19:31:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0BBC9625E4;\n\tMon, 30 Jan 2023 20:31:48 +0100 (CET)","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 2B42D60482\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Jan 2023 20:31:46 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8205F8B8;\n\tMon, 30 Jan 2023 20:31:45 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1675107108;\n\tbh=C1m3Au5WSXbFe0NoIv+/odskNKXQEOh9jncGK9HZW+Y=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=giXiPEx7Je7YeM5yqYTrWsP4IcMBWA37Kleb86TYBtvnrt6fcrHyHXx4yoxs8bkeF\n\tOj9zg/0QLadOyFdj1bYEaWOuOoEu4B2rDl//nouIHrcdgtX172z/+w/IlsZf7d9WKR\n\tvjYbcZl1KAuKL8w1cl6wf9MOI3o/CYQLNGzIrhiqSCqOMxxnv4WgJ2jGa+Zx23r20e\n\txudL3dGtuPMa5+SSwwuaAGKswDorTXw/kCzM78xO9QuKWEkVcNDuCksZKChpFetj34\n\tD//uCx/NJFLlpU7ucpOKK+b1jHrYyv46MN/ZoqLwZoLBqHDFXp7aSiTrhmHIqfab3P\n\tIamlDUH0RSRHg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1675107105;\n\tbh=C1m3Au5WSXbFe0NoIv+/odskNKXQEOh9jncGK9HZW+Y=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Nx+tcB0w4UfnmpwHG2bzAPmcij6KnlN6u+pZ+bHWR6t22ZuWhica1WN2XobCn2Xwk\n\tUWtnTf59ao0ch+EZ4gq/q7Fkb+3C3oGnMNuJFgAcerbsOCxVgUmzGV4Vw3PmWH7hFB\n\tN/MCNfVPK9e58WE1ZMpHoR5dLg+FMR9tjIBoxsiI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Nx+tcB0w\"; dkim-atps=neutral","Date":"Mon, 30 Jan 2023 20:31:42 +0100","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<20230130193142.zta72fefbrhosynd@uno.localdomain>","References":"<20230130180244.2150205-1-kieran.bingham@ideasonboard.com>\n\t<20230130180244.2150205-2-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20230130180244.2150205-2-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: camera: Ensure queued\n\trequests are prepared","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":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26418,"web_url":"https://patchwork.libcamera.org/comment/26418/","msgid":"<Y+IiJ4Aqr0m61fLM@pyrite.rasen.tech>","date":"2023-02-07T10:04:23","subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: camera: Ensure queued\n\trequests are prepared","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Mon, Jan 30, 2023 at 06:02:43PM +0000, Kieran Bingham via libcamera-devel wrote:\n> Invalid, or not correctly reset requests can cause undefined behaviour\n> in the pipeline handlers due to unexpected request state.\n> \n> If the status has not been reset to Request::RequestPending, it is\n> either not new, or has not been correctly procesed through\n> Request::reuse().\n> \n> This can be caught early by validating the status of the request when it\n> is queued to a camera.\n> \n> Reject invalid requests before processing them in the pipeline handlers.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/libcamera/camera.cpp | 5 +++++\n>  1 file changed, 5 insertions(+)\n> \n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index 0da167a7bc51..48bf19b28979 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -1126,6 +1126,11 @@ int Camera::queueRequest(Request *request)\n>  \t\treturn -EXDEV;\n>  \t}\n>  \n> +\tif (request->status() != Request::RequestPending) {\n> +\t\tLOG(Camera, Error) << request->toString() << \" is not prepared\";\n> +\t\treturn -EINVAL;\n> +\t}\n> +\n>  \t/*\n>  \t * The camera state may change until the end of the function. No locking\n>  \t * is however needed as PipelineHandler::queueRequest() will handle\n> -- \n> 2.34.1\n>","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 7D9F1BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Feb 2023 10:04:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CEBEF625F3;\n\tTue,  7 Feb 2023 11:04:31 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2177E603BD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Feb 2023 11:04:31 +0100 (CET)","from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AB61D383;\n\tTue,  7 Feb 2023 11:04:29 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1675764271;\n\tbh=4FoZEN0UDafNdOF9TyyjmUYjDJRPPaYWQkKJIoTD+QU=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=DSYxSDoLsRmExwpfy+3NGkalK+De+cn6DCXi9xrT9s3znzN6eAE6XURj1f5KNNBW0\n\tDWFD4rZQWhgZvZW1MScXEWxEeQb5KuiMBf+HBBMAKS3XzXNp8LssrFFMCPv0Wsp+dY\n\tRF4ZZgp3lJUCDX/jpK4m7ufZQBWIYvE3VdoKaLBTrS1P88Ke4RsINm5PSo5KwGOkZw\n\t8s3vL4betb68CH2xlFG2gxvVI9afKgK+TgnNWgdD4JWBq+uW2diNV0rZ2YqmSXszUf\n\twh1k9kxrk322bUd4BFzEL25SjJBZiCAU6AB7/Db1QqQq2b3T0hA+aFKT506VtMb4vj\n\t421klT5g+nJSQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1675764270;\n\tbh=4FoZEN0UDafNdOF9TyyjmUYjDJRPPaYWQkKJIoTD+QU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=CNtREemzNZPl760S7Cno0sePmqWSln3TmD8i5DSJ05rdf3Iz7RBY74ZjL/Y8F8guX\n\twcF3OcFTr6ObLdOGs0clLUv9crfnh/3tkOrMqmcp3ikhDkbe9Qlfl5wquudPBHFeYF\n\tBxAunEj1MdflGVg+0gL0ZSAJ5kqdxE2uHF32IXmU="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"CNtREemz\"; dkim-atps=neutral","Date":"Tue, 7 Feb 2023 19:04:23 +0900","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<Y+IiJ4Aqr0m61fLM@pyrite.rasen.tech>","References":"<20230130180244.2150205-1-kieran.bingham@ideasonboard.com>\n\t<20230130180244.2150205-2-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20230130180244.2150205-2-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: camera: Ensure queued\n\trequests are prepared","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":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26420,"web_url":"https://patchwork.libcamera.org/comment/26420/","msgid":"<Y+Ikg1XsgztlPPjp@pendragon.ideasonboard.com>","date":"2023-02-07T10:14:27","subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: camera: Ensure queued\n\trequests are prepared","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Mon, Jan 30, 2023 at 06:02:43PM +0000, Kieran Bingham via libcamera-devel wrote:\n> Invalid, or not correctly reset requests can cause undefined behaviour\n> in the pipeline handlers due to unexpected request state.\n> \n> If the status has not been reset to Request::RequestPending, it is\n> either not new, or has not been correctly procesed through\n\ns/procesed/processed/\n\nor maybe s/procesed/reset/\n\n> Request::reuse().\n> \n> This can be caught early by validating the status of the request when it\n> is queued to a camera.\n> \n> Reject invalid requests before processing them in the pipeline handlers.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/libcamera/camera.cpp | 5 +++++\n>  1 file changed, 5 insertions(+)\n> \n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index 0da167a7bc51..48bf19b28979 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -1126,6 +1126,11 @@ int Camera::queueRequest(Request *request)\n>  \t\treturn -EXDEV;\n>  \t}\n>  \n> +\tif (request->status() != Request::RequestPending) {\n> +\t\tLOG(Camera, Error) << request->toString() << \" is not prepared\";\n\n\"prepared\" is the wrong word here. We have a prepared concept for\nrequests (see Request::Private::prepare()), and it's not related to\nthis. The same comment applies to the commit message.\n\nOther than this, the patch looks good to me.\n\n> +\t\treturn -EINVAL;\n> +\t}\n> +\n>  \t/*\n>  \t * The camera state may change until the end of the function. No locking\n>  \t * is however needed as PipelineHandler::queueRequest() will handle","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 7F22EBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Feb 2023 10:14:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AFCE5625F3;\n\tTue,  7 Feb 2023 11:14:30 +0100 (CET)","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 AF679603BD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Feb 2023 11:14:29 +0100 (CET)","from pendragon.ideasonboard.com (unknown [109.136.43.56])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2913A4AF;\n\tTue,  7 Feb 2023 11:14:29 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1675764870;\n\tbh=IocjH/nXicsWdYRD+fvo55E/i0bTYD1yuVWoYfOHqmw=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=vI/CXgQTczpundBd14gbKzOPA54f7NOqzY5JG/3QKRzdCweZnn5TeXN28qEIEOYJq\n\t0Du6vTLLKJNR08Z5litDgnSa7+wEU58UXAdq1nW0LwRJ3gIM28Qk3mvmeO5lQw33XE\n\tNV3a5Euzbvs4ni8bm/s78Gq3ZigvQRNHBRuo6N8UxL16owNchpWCY+7PnnOdVqJwRa\n\t5PwPqigLq9rvzGwk6Us4DN+r3c+kdX5czVaQtA964GQUuWPEIyd1BXNPC+a+e/7MMQ\n\t3x+i1F3wNa6erBtCwXU53JezZVu8bayl9bWB/BsDecjXSEWLl7hew2GrFjNsnXYz44\n\tuThccYT6KZrkQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1675764869;\n\tbh=IocjH/nXicsWdYRD+fvo55E/i0bTYD1yuVWoYfOHqmw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=W4aHNkVa2dlYiU/Mg1wnPZMOLe6ZOMPNGIsq7771dCrshgpgkv8jwayQru8M0eCa0\n\tVucDSrRjcKmUbDcPGyoS+t/MHHmT1PN2nH4K3eAZ3nK62LNIij9hfLqnZTr3fPNGAC\n\t9gEvza1RNc8Oi0lqE2LOX4He+nzKGLHyDFytFBC8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"W4aHNkVa\"; dkim-atps=neutral","Date":"Tue, 7 Feb 2023 12:14:27 +0200","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<Y+Ikg1XsgztlPPjp@pendragon.ideasonboard.com>","References":"<20230130180244.2150205-1-kieran.bingham@ideasonboard.com>\n\t<20230130180244.2150205-2-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20230130180244.2150205-2-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: camera: Ensure queued\n\trequests are prepared","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]