Message ID | 20210614103409.3154127-5-arnd@kernel.org (mailing list archive) |
---|---|
State | Accepted, archived |
Delegated to: | Hans Verkuil |
Headers |
Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from <linux-media-owner@vger.kernel.org>) id 1lsk52-00GAFc-Al; Mon, 14 Jun 2021 10:44:32 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233490AbhFNKq3 (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Mon, 14 Jun 2021 06:46:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:47606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234187AbhFNKo1 (ORCPT <rfc822;linux-media@vger.kernel.org>); Mon, 14 Jun 2021 06:44:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6457A61404; Mon, 14 Jun 2021 10:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623666980; bh=ql1oV1rq//CRvUy0F7HDTW6q+eFb02wnUXlrJrXa2hs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KUruyy5gO6Rmb9YkIRNn/KwupM5Pb0ct4xe1wCoCaBnmYprT1PW9wqxiuu2Xunb7R qrEUnCiomDmSUCPgnyvv8y6bYDk0bcci3f2U0amKU/oKmuvJl9Z6RvPntny/JT3feD 2bYU8/RhCaW+A0ehXoiP+mktv7qyupCkZKNxkWLqj5vDAPICGNd1D5VMeNqIQzrMEd 0o1Ug/EUQeklXR3bH5p6MHpZlADgSxXUQ69J3l0Y/q2XlkKzT6N5skalKKc/0dEa1k 8uETFO7ZrPtTMoEUittl+hs7k5ywoQni8JuDoZULVXmVhfxA/Gxu1Kw+FXVhtB4eff +b0GHFN11F7lg== From: Arnd Bergmann <arnd@kernel.org> To: Hans Verkuil <hverkuil-cisco@xs4all.nl>, Mauro Carvalho Chehab <mchehab@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de>, "Lad, Prabhakar" <prabhakar.csengg@gmail.com>, Eduardo Valentin <edubezval@gmail.com>, Sakari Ailus <sakari.ailus@linux.intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Vaibhav Gupta <vaibhavgupta40@gmail.com>, Liu Shixin <liushixin2@huawei.com>, Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Jacopo Mondi <jacopo+renesas@jmondi.org>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v3 4/8] media: subdev: remove VIDIOC_DQEVENT_TIME32 handling Date: Mon, 14 Jun 2021 12:34:05 +0200 Message-Id: <20210614103409.3154127-5-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210614103409.3154127-1-arnd@kernel.org> References: <20210614103409.3154127-1-arnd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -3.8 (---) X-LSpam-Report: No, score=-3.8 required=5.0 tests=BAYES_00=-1.9,DKIMWL_WL_HIGH=0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DKIM_VALID_EF=-0.1,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_LOW=-0.7 autolearn=ham autolearn_force=no |
Series |
media: v4l2: compat ioctl fixes
|
|
Commit Message
Arnd Bergmann
June 14, 2021, 10:34 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de> Converting the VIDIOC_DQEVENT_TIME32/VIDIOC_DQEVENT32/ VIDIOC_DQEVENT32_TIME32 arguments to the canonical form is done in common code, but for some reason I ended up adding another conversion helper to subdev_do_ioctl() as well. I must have concluded that this does not go through the common conversion, but it has done that since the ioctl handler was first added. I assume this one is harmless as there should be no way to arrive here from user space, but since it is dead code, it should just get removed. Fixes: 1a6c0b36dd19 ("media: v4l2-core: fix VIDIOC_DQEVENT for time64 ABI") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/media/v4l2-core/v4l2-subdev.c | 24 ------------------------ 1 file changed, 24 deletions(-)
Comments
Hi Arnd, Thank you for the patch. On Mon, Jun 14, 2021 at 12:34:05PM +0200, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > Converting the VIDIOC_DQEVENT_TIME32/VIDIOC_DQEVENT32/ > VIDIOC_DQEVENT32_TIME32 arguments to the canonical form is done in common > code, but for some reason I ended up adding another conversion helper to > subdev_do_ioctl() as well. I must have concluded that this does not go > through the common conversion, but it has done that since the ioctl > handler was first added. > > I assume this one is harmless as there should be no way to arrive here > from user space, but since it is dead code, it should just get removed. If I'm not mistaken, this could be reached when !CONFIG_COMPAT_32BIT_TIME, can't it ? Still, there's no need for this code in that case, so it seems fine to me. > Fixes: 1a6c0b36dd19 ("media: v4l2-core: fix VIDIOC_DQEVENT for time64 ABI") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> With an updated commit message if the above is correct, Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > drivers/media/v4l2-core/v4l2-subdev.c | 24 ------------------------ > 1 file changed, 24 deletions(-) > > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c > index 956dafab43d4..bf3aa9252458 100644 > --- a/drivers/media/v4l2-core/v4l2-subdev.c > +++ b/drivers/media/v4l2-core/v4l2-subdev.c > @@ -428,30 +428,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg) > > return v4l2_event_dequeue(vfh, arg, file->f_flags & O_NONBLOCK); > > - case VIDIOC_DQEVENT_TIME32: { > - struct v4l2_event_time32 *ev32 = arg; > - struct v4l2_event ev = { }; > - > - if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS)) > - return -ENOIOCTLCMD; > - > - rval = v4l2_event_dequeue(vfh, &ev, file->f_flags & O_NONBLOCK); > - > - *ev32 = (struct v4l2_event_time32) { > - .type = ev.type, > - .pending = ev.pending, > - .sequence = ev.sequence, > - .timestamp.tv_sec = ev.timestamp.tv_sec, > - .timestamp.tv_nsec = ev.timestamp.tv_nsec, > - .id = ev.id, > - }; > - > - memcpy(&ev32->u, &ev.u, sizeof(ev.u)); > - memcpy(&ev32->reserved, &ev.reserved, sizeof(ev.reserved)); > - > - return rval; > - } > - > case VIDIOC_SUBSCRIBE_EVENT: > return v4l2_subdev_call(sd, core, subscribe_event, vfh, arg); >
On Mon, Jun 14, 2021 at 7:02 PM Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > > On Mon, Jun 14, 2021 at 12:34:05PM +0200, Arnd Bergmann wrote: > > From: Arnd Bergmann <arnd@arndb.de> > > > > Converting the VIDIOC_DQEVENT_TIME32/VIDIOC_DQEVENT32/ > > VIDIOC_DQEVENT32_TIME32 arguments to the canonical form is done in common > > code, but for some reason I ended up adding another conversion helper to > > subdev_do_ioctl() as well. I must have concluded that this does not go > > through the common conversion, but it has done that since the ioctl > > handler was first added. > > > > I assume this one is harmless as there should be no way to arrive here > > from user space, but since it is dead code, it should just get removed. > > If I'm not mistaken, this could be reached when > !CONFIG_COMPAT_32BIT_TIME, can't it ? Still, there's no need for this > code in that case, so it seems fine to me. Yes, that is correct, I missed that condition. We definitely should not handle the command in that case. Hans, since you mentioned you would pick up this patch, I assume you are going to reword the patch as you see fit. If you prefer me to resend it, let me know. Arnd
On 15/06/2021 10:43, Arnd Bergmann wrote: > On Mon, Jun 14, 2021 at 7:02 PM Laurent Pinchart > <laurent.pinchart@ideasonboard.com> wrote: >> >> On Mon, Jun 14, 2021 at 12:34:05PM +0200, Arnd Bergmann wrote: >>> From: Arnd Bergmann <arnd@arndb.de> >>> >>> Converting the VIDIOC_DQEVENT_TIME32/VIDIOC_DQEVENT32/ >>> VIDIOC_DQEVENT32_TIME32 arguments to the canonical form is done in common >>> code, but for some reason I ended up adding another conversion helper to >>> subdev_do_ioctl() as well. I must have concluded that this does not go >>> through the common conversion, but it has done that since the ioctl >>> handler was first added. >>> >>> I assume this one is harmless as there should be no way to arrive here >>> from user space, but since it is dead code, it should just get removed. I changed this to: "I assume this one is harmless as there should be no way to arrive here from user space if CONFIG_COMPAT_32BIT_TIME is set," If it is not set, then this will just fall into the default case and is handled as if it is a potential custom ioctl, as you would expect. Let me know if you have a better text, I can still update it. Regards, Hans >> >> If I'm not mistaken, this could be reached when >> !CONFIG_COMPAT_32BIT_TIME, can't it ? Still, there's no need for this >> code in that case, so it seems fine to me. > > Yes, that is correct, I missed that condition. We definitely should not handle > the command in that case. > > Hans, since you mentioned you would pick up this patch, I assume you > are going to reword the patch as you see fit. If you prefer me to resend it, > let me know. > > Arnd >
On Tue, Jun 15, 2021 at 10:48 AM Hans Verkuil <hverkuil-cisco@xs4all.nl> wrote: > > On 15/06/2021 10:43, Arnd Bergmann wrote: > > On Mon, Jun 14, 2021 at 7:02 PM Laurent Pinchart > > <laurent.pinchart@ideasonboard.com> wrote: > >> > >> On Mon, Jun 14, 2021 at 12:34:05PM +0200, Arnd Bergmann wrote: > >>> From: Arnd Bergmann <arnd@arndb.de> > >>> > >>> Converting the VIDIOC_DQEVENT_TIME32/VIDIOC_DQEVENT32/ > >>> VIDIOC_DQEVENT32_TIME32 arguments to the canonical form is done in common > >>> code, but for some reason I ended up adding another conversion helper to > >>> subdev_do_ioctl() as well. I must have concluded that this does not go > >>> through the common conversion, but it has done that since the ioctl > >>> handler was first added. > >>> > >>> I assume this one is harmless as there should be no way to arrive here > >>> from user space, but since it is dead code, it should just get removed. > > I changed this to: > > "I assume this one is harmless as there should be no way to arrive here > from user space if CONFIG_COMPAT_32BIT_TIME is set," > > If it is not set, then this will just fall into the default case and is > handled as if it is a potential custom ioctl, as you would expect. > > Let me know if you have a better text, I can still update it. Looks good. One more sentence I would add: "On a 64-bit architecture, as well as a 32-bit architecture without CONFIG_COMPAT_32BIT_TIME, handling this command is a mistake, and the kernel should return an error". Arnd
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 956dafab43d4..bf3aa9252458 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -428,30 +428,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg) return v4l2_event_dequeue(vfh, arg, file->f_flags & O_NONBLOCK); - case VIDIOC_DQEVENT_TIME32: { - struct v4l2_event_time32 *ev32 = arg; - struct v4l2_event ev = { }; - - if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS)) - return -ENOIOCTLCMD; - - rval = v4l2_event_dequeue(vfh, &ev, file->f_flags & O_NONBLOCK); - - *ev32 = (struct v4l2_event_time32) { - .type = ev.type, - .pending = ev.pending, - .sequence = ev.sequence, - .timestamp.tv_sec = ev.timestamp.tv_sec, - .timestamp.tv_nsec = ev.timestamp.tv_nsec, - .id = ev.id, - }; - - memcpy(&ev32->u, &ev.u, sizeof(ev.u)); - memcpy(&ev32->reserved, &ev.reserved, sizeof(ev.reserved)); - - return rval; - } - case VIDIOC_SUBSCRIBE_EVENT: return v4l2_subdev_call(sd, core, subscribe_event, vfh, arg);