Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp738592pxf; Wed, 24 Mar 2021 14:57:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSVyegww7EGamWeosx/aoZtPMGJhjo2U5gkU60URe1J/BHxnX9eZ5gy9VDfg0E2oY+V5kO X-Received: by 2002:a05:6402:6ca:: with SMTP id n10mr5751467edy.312.1616623023860; Wed, 24 Mar 2021 14:57:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616623023; cv=none; d=google.com; s=arc-20160816; b=uaZ0z23VvD5FasW6Eiv6tzk8sCIDwhRsTaqtCdB2rdcLHecZ+AxxbRDUDwR9nR6Fi7 p4j2A21IkucZaOZjsRgjQD0oFGHU6czXHnbnq9pR4WzQiTDirO6H56QcM2uj4aOoHTeY 3su1gPT6o/QH9Mt6FL7zY6r9fqrYQoKlPddEJ3TwYvEV/w+9iqFxu7W71MqJO6nBzIlo Ae6KVC9U+kxFCE6gOZdhc3PpDa+OAMQ+PdO0Qjkr4pXgYimsrKfSrNN34RTkDyHPP2xv MlArpmQ8jTNj1BoQkuGLRTwuKyug9d/JEZY6NYY32Sr3sJ9m48lf8BeuJXT79ZVeUvYI xGGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=smeNo2nLOzLoAqQ0eDu45bUTA0pWmhws44H491W9z+0=; b=HQzgMNBEIt0jhbYjI9+JeV2020ZII+Cb34Vswl2NTrvAm3gsqL/Okhw6wARin9lGPs D1/3S3vwzSexlBDrx9sbk4GYnsH+pdpahVB0Bf/zWPybbKqfvyXJf3ERa0rsfcEHyYFP XawwbTJbIzC8TKJV1fT4E+x8P2h4r74pHjkXscKhZMDcdAc1/knzQ9GAOX6ktNflXVr/ KyKdSWxPPDLmlWCb4vG5zCuPGlj5x6sght7qmzYIddvu4MU4giE/sxaJI2GooimwfAOZ PR+SflYuNnvlX4GF3myEwTDVKsjcmttCoODyiG2yt8oku3XFYK5qtu3Aj/wrwgkeGdy8 VE0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EvmzBDZ3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m13si2561438edc.258.2021.03.24.14.56.40; Wed, 24 Mar 2021 14:57:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EvmzBDZ3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231990AbhCXCbc (ORCPT + 99 others); Tue, 23 Mar 2021 22:31:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232012AbhCXCbM (ORCPT ); Tue, 23 Mar 2021 22:31:12 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40E35C061763 for ; Tue, 23 Mar 2021 19:31:12 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id q11so7135751pld.11 for ; Tue, 23 Mar 2021 19:31:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=smeNo2nLOzLoAqQ0eDu45bUTA0pWmhws44H491W9z+0=; b=EvmzBDZ30bavlVo5llPGM4DVAa7h37P89ePfMEf5oMkGD9epTsE5m75nO/7X6hw4cN SkizuxTwxzNwMrDOJoCrMnbrim2PTBN2Y5aXzWvRh/4d5q/RPYgoE/mwZU5zQNdlgYm9 DdiJf5xPDxzLRVShek+nVRVOBfaWMIesglLag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=smeNo2nLOzLoAqQ0eDu45bUTA0pWmhws44H491W9z+0=; b=b4F/RESlRzQZudh0IX2GOWF7HN5VEOjIWLDE1/v1+x4QQ0ngyz19fvpPjjdsNFdNDD ordBxQ1yPXx/3E92ChNIwD+6ABob7SxzY2nEih/WbbWsffuc2g8gRK8iU1cz6LQiyhq0 BJGmfGQkbyrrSDCS5QxR0scaSuuOqObh6AOYTmdHNC3b0Pv7rTmn2CIlkJiEmItR0qQl 4H8ygYO7nqppxbO+CQQMUDEDX720jVCC0EYFcx2olZEoddQeaEOu2uaS2bbeZm6sI3Vo /2n7M0lez4FIZ26KkImzUGS0E9Rg8E2+PDeiXfJvGCajm3eJrGHAkom3bJwrZlqnMU+R 3g9g== X-Gm-Message-State: AOAM531H943pVSfjRqeXwrBuzVz7fmx0RoYKKXblaX8voCRa8rEzG9sn QeTis5RGhMSMdtLk7X0FakLaMA== X-Received: by 2002:a17:90a:4d07:: with SMTP id c7mr1058957pjg.104.1616553071745; Tue, 23 Mar 2021 19:31:11 -0700 (PDT) Received: from google.com ([2409:10:2e40:5100:bcf2:e05a:a993:9494]) by smtp.gmail.com with ESMTPSA id l19sm444720pjt.16.2021.03.23.19.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 19:31:11 -0700 (PDT) Date: Wed, 24 Mar 2021 11:31:06 +0900 From: Sergey Senozhatsky To: Tomasz Figa Cc: Sergey Senozhatsky , Ricardo Ribalda , Laurent Pinchart , Mauro Carvalho Chehab , Hans Verkuil , Linux Media Mailing List , Linux Kernel Mailing List Subject: Re: [PATCHv3 5/6] media: uvcvideo: add UVC 1.5 ROI control Message-ID: References: <20210319055342.127308-1-senozhatsky@chromium.org> <20210319055342.127308-6-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (21/03/24 11:14), Tomasz Figa wrote: > > > > +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. > > Adjusting the rectangle to something supported by the hardware is > mentioned explicitly in the V4L2 API documentation and is what drivers > have to implement. Returning an error on invalid value is not a > correct behavior here (and similarly for many other operations, e.g. > S_FMT). Well, in this particular case we are talking about user-space that wants to set ROI rectangle that is knowingly violates device's GET_MAX and overflows UVC ROI rectangle u16 value range. That's a clear bug in user-space. Do we want to pretend that user-space does the correct thing and fixup stuff behind the scenes? > > 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 > > Perhaps the frame size would be the correct bounds? I can check that.