[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YFqdaHCQak5ZM0Sf@google.com>
Date: Wed, 24 Mar 2021 11:01:12 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Ricardo Ribalda <ribalda@...omium.org>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Tomasz Figa <tfiga@...omium.org>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Hans Verkuil <hverkuil-cisco@...all.nl>,
Linux Media Mailing List <linux-media@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCHv3 5/6] media: uvcvideo: add UVC 1.5 ROI control
On (21/03/23 17:16), Ricardo Ribalda wrote:
[..]
> > +static bool validate_roi_bounds(struct uvc_streaming *stream,
> > + struct v4l2_selection *sel)
> > +{
> > + if (sel->r.left > USHRT_MAX ||
> > + sel->r.top > USHRT_MAX ||
> > + (sel->r.width + sel->r.left) > USHRT_MAX ||
> > + (sel->r.height + sel->r.top) > USHRT_MAX ||
> > + !sel->r.width || !sel->r.height)
> > + return false;
> > +
> > + if (sel->flags > V4L2_SEL_FLAG_ROI_AUTO_HIGHER_QUALITY)
> > + return false;
>
> Is it not allowed V4L2_SEL_FLAG_ROI_AUTO_IRIS |
> V4L2_SEL_FLAG_ROI_AUTO_HIGHER_QUALITY ?
Good question.
I don't know. Depends on what HIGHER_QUALITY can stand for (UVC doesn't
specify). But overall it seems like features there are mutually
exclusive. E.g. AUTO_FACE_DETECT and AUTO_DETECT_AND_TRACK.
I think it'll be better to replace this with
if (sel->flags > USHRT_MAX)
return false;
so that we don't let overflow happen and accidentally enable/disable
some of the features.
> > +
> > + return true;
> > +}
> > +
> > +static int uvc_ioctl_s_roi(struct file *file, void *fh,
> > + struct v4l2_selection *sel)
> > +{
> > + struct uvc_fh *handle = fh;
> > + struct uvc_streaming *stream = handle->stream;
> > + struct uvc_roi_rect *roi;
> > + int ret;
> > +
> > + if (!validate_roi_bounds(stream, sel))
> > + return -E2BIG;
>
> Not sure if this is the correct approach or if we should convert the
> value to the closest valid...
Well, at this point we know that ROI rectangle dimensions are out of
sane value range. I'd rather tell user-space about integer overflow.
Looking for the closest ROI rectangle that suffice can be rather
tricky. It may sounds like we can just use BOUNDARIES_MAX, but this
is what Firmware D returns for GET_MAX
ioctl(V4L2_SEL_TGT_ROI_BOUNDS_MAX)
0, 0, 65535, 65535
-ss
Powered by blists - more mailing lists