public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Scally <dan.scally@ideasonboard.com>
To: Michael Grzeschik <mgr@pengutronix.de>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-usb@vger.kernel.org, linux-media@vger.kernel.org,
	gregkh@linuxfoundation.org, balbi@kernel.org,
	kernel@pengutronix.de
Subject: Re: [PATCH v7] usb: gadget: uvc: add validate and fix function for uvc response
Date: Tue, 29 Nov 2022 11:15:08 +0000	[thread overview]
Message-ID: <2e28fbab-2367-5d00-6e46-37879fd046e5@ideasonboard.com> (raw)
In-Reply-To: <20221129102308.GO18924@pengutronix.de>


On 29/11/2022 10:23, Michael Grzeschik wrote:
> On Tue, Nov 29, 2022 at 05:10:24AM +0200, Laurent Pinchart wrote:
>> Hi Michael,
>>
>> (CC'ing Dan)
>>
>> Thank you for the patch.
>>
>> On Mon, Nov 28, 2022 at 11:31:25AM +0100, Michael Grzeschik wrote:
>>> When the userspace gets the setup requests for UVC_GET_CUR UVC_GET_MIN,
>>> UVC_GET_MAX, UVC_GET_DEF it will fill out the ctrl response. This data
>>> needs to be validated. Since the kernel also knows the limits for valid
>>> cases, it can fixup the values in case the userspace is setting invalid
>>> data.
>>
>> Why is this a good idea ?
>
> Why is it not? We don't want the userspace to communicate other things
> to the host than what is configured in the configfs. If you only object
> the explanation, then I will improve the commit message and send an
> fixed v8. If you have more objections please share your doubts, thanks.


I'm also not really sure of the benefit; wouldn't this result in 
userspace streaming data that's configured differently to what the host 
is expecting?

>>>  static int
>>>  uvc_send_response(struct uvc_device *uvc, struct uvc_request_data 
>>> *data)
>>>  {
>>> @@ -192,6 +253,21 @@ uvc_send_response(struct uvc_device *uvc, 
>>> struct uvc_request_data *data)
>>>
>>>      memcpy(req->buf, data->data, req->length);
>>>
>>> +    /* validate the ctrl content and fixup */
>>> +    if (!uvc->event_setup_out) {
>>> +        struct uvc_streaming_control *ctrl = req->buf;
>>> +
>>> +        switch (uvc->streaming_request) {
>>> +        case UVC_GET_CUR:
>>> +        case UVC_GET_MIN:
>>> +        case UVC_GET_MAX:
>>> +        case UVC_GET_DEF:
>>> +            uvc_validate_streaming_ctrl(uvc, ctrl);
>>> +        default:
>>> +            break;
>>> +        }
>>> +    }
>>> +


What about read requests for controls that aren't for the streaming 
interface?

>>>      return usb_ep_queue(cdev->gadget->ep0, req, GFP_KERNEL);
>>>  }
>>>
>>
>> -- 
>> Regards,
>>
>> Laurent Pinchart
>>
>

  reply	other threads:[~2022-11-29 11:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28 10:31 [PATCH v7] usb: gadget: uvc: add validate and fix function for uvc response Michael Grzeschik
2022-11-29  3:10 ` Laurent Pinchart
2022-11-29 10:23   ` Michael Grzeschik
2022-11-29 11:15     ` Dan Scally [this message]
2022-11-29 12:02     ` Laurent Pinchart
2022-11-29 15:22       ` Michael Grzeschik
2022-11-29 21:56         ` Michael Grzeschik
2022-12-03 21:29         ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2e28fbab-2367-5d00-6e46-37879fd046e5@ideasonboard.com \
    --to=dan.scally@ideasonboard.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mgr@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox