Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp767591rwb; Wed, 26 Jul 2023 02:31:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlFW+wAv8BF8ydHAAu6x4RQznE1FzUqsQftv13N4kW4ptl2s6Bn9dzyLEuqr5yyraQya0W2J X-Received: by 2002:a05:6a20:5482:b0:130:7803:5843 with SMTP id i2-20020a056a20548200b0013078035843mr1508716pzk.4.1690363868112; Wed, 26 Jul 2023 02:31:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690363868; cv=none; d=google.com; s=arc-20160816; b=lgccTrzT29wntapO4Jo5pCmEnVnbAe4tSEvZM2GuXx8pidrCpWVuxiVUWU1AMSkvWi IkmUp5k3NNtFT+/D2QCP7ky+cC4aZj5E3LJghRtTTgw49EzkaUeLrM+METBBplKsgXDZ NEICKNR/umW1MfGjrzj0+ajD3DpN5QQKowon9fS5h5X2ZSEKoyfzwxRTy3oBZ+xF1r5K Qldfn0vY61Y0JrJ84HGki9GiAW7h8pjZRBTE1aq+C+UhaoibJxX/5z72Wgg4Jqj8QkrD FHjXe/mlR5m+6CWzv30CQLPSGmIZ7cOCPFR/wkNelnpzvf3lZxu67jd7XxD6ndeBp+A3 +m2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=74wyanum3tMY6hDx3TZatyjXXaq/omZ9n0t0OUBylr4=; fh=eZaVC4RseuG0AWevISt236d2srPpLG+oi+yMuskqwrI=; b=No522NFRAX/ChPMpDz08+PLv04ksqUzQBypc7mNRjfvElQgZiC1e+OSpm5m91q0rUM NcaGUDBc44pcFG7opBo2hKlHMpBfQhMr29YBpMa0kK0Q6jyUSXgCzWUGjrS31U89goW6 MKVe4ZloH30uL++uEH/ngzyopHzHn7ZgWEGDHK/d3jFlCdIp4qTW/5E61vyjPIiRXLRM 4D1aboWkBjWmiWlxD7mbTwBG7SU/a8EDU5OsKYwItZpzMKnM5kuMqa6tkiGUdj4Z0YAV NegoiVOhrRoOU++2gg1mImCAkH42qkam1V+n/pIvTqPaOSnuJEBBX1wMvUA8c0wj/4Z8 ldDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hvkW0yU+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h23-20020a656397000000b0055c1fb5a4a9si12505415pgv.661.2023.07.26.02.30.56; Wed, 26 Jul 2023 02:31:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hvkW0yU+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233225AbjGZIqS (ORCPT + 99 others); Wed, 26 Jul 2023 04:46:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232239AbjGZIpt (ORCPT ); Wed, 26 Jul 2023 04:45:49 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F4B82D5B for ; Wed, 26 Jul 2023 01:38:19 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-7656652da3cso495177385a.1 for ; Wed, 26 Jul 2023 01:38:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690360698; x=1690965498; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=74wyanum3tMY6hDx3TZatyjXXaq/omZ9n0t0OUBylr4=; b=hvkW0yU+SBX4+XFY9QdEEWD6uWusk3QtD2FOsR9/3ALp8IJw7ZEB5o6Ds8zD9mX1H0 cEo/IxD9gxFFiU6nf75883gHJ4hXt8Bzr/1hFZnXTuqN7n0eXr/TijDA//AaugReIftU jHS2W6eE1Qo5CIVIBDy8yCnK/iNo0/W9kVIJY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690360698; x=1690965498; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=74wyanum3tMY6hDx3TZatyjXXaq/omZ9n0t0OUBylr4=; b=czTGV3VzXhqiPBW+kKq8Ze2bfPWK8CGUZqCtFjXz/3mfSWBzGQvIkPH/l7GxIdPA8A DwbAJtpGFkDUt1bSJqC0cUE/wKTnnFDPcajxqnl1oWo2PRoN9eHR15HNQ1vah/cjyFqL A1LFP9GZqnOslAg2x/pPp26KFZFq+FMmP+TvUhnnNxY/i6pclni3v9m5x1ZAwWSSy6p2 I3c9gPQyiZ9o+ZYHYhwBgPL39I7yvDlnY/j5e7kUnk6ps/krmlleo1p8JQibMpu/2ON6 mNJ1KLhqvlJlHUTsv2w5+9p7ZwSfB2Y7WlpYI+oxK2odbLa9Hrz5IDcVeyFfT9Y/x3k1 Bkkw== X-Gm-Message-State: ABy/qLbs9BP5IWim9A5SZOK/V2ha7WFClBeh+7pcAfrJkMYOF4eLQrpO /ioluoVJcfkkyuKlc0F6XV/2IegTe/WWIXX3C1TLUw== X-Received: by 2002:a05:620a:2586:b0:765:83e8:d990 with SMTP id x6-20020a05620a258600b0076583e8d990mr1534196qko.75.1690360698311; Wed, 26 Jul 2023 01:38:18 -0700 (PDT) Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com. [209.85.219.45]) by smtp.gmail.com with ESMTPSA id v9-20020a05620a122900b00765aa3ffa07sm4214283qkj.98.2023.07.26.01.37.30 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Jul 2023 01:37:45 -0700 (PDT) Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-63ce8bea776so24592976d6.0 for ; Wed, 26 Jul 2023 01:37:30 -0700 (PDT) X-Received: by 2002:a0c:c684:0:b0:63c:da03:1c12 with SMTP id d4-20020a0cc684000000b0063cda031c12mr975386qvj.60.1690360649449; Wed, 26 Jul 2023 01:37:29 -0700 (PDT) MIME-Version: 1.0 References: <20230717-uvc-oob-v2-1-c7745a8d5847@chromium.org> <20230725213451.GU31069@pendragon.ideasonboard.com> <20230726080753.GX31069@pendragon.ideasonboard.com> In-Reply-To: <20230726080753.GX31069@pendragon.ideasonboard.com> From: Ricardo Ribalda Date: Wed, 26 Jul 2023 10:37:17 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] media: uvcvideo: Fix OOB read To: Laurent Pinchart Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky , stable@kernel.org, Zubin Mithra , =?UTF-8?Q?Kai_Wasserb=C3=A4ch?= , Thorsten Leemhuis Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Laurent On Wed, 26 Jul 2023 at 10:07, Laurent Pinchart wrote: > > Hi Ricardo, > > (CC'ing Kai and Thorsten who have added the check to checkpatch) > > On Wed, Jul 26, 2023 at 08:24:50AM +0200, Ricardo Ribalda wrote: > > On Tue, 25 Jul 2023 at 23:34, Laurent Pinchart wrote: > > > On Thu, Jul 20, 2023 at 05:46:54PM +0000, Ricardo Ribalda wrote: > > > > If the index provided by the user is bigger than the mask size, we might do an > > > > out of bound read. > > > > > > > > CC: stable@kernel.org > > > > Fixes: 40140eda661e ("media: uvcvideo: Implement mask for V4L2_CTRL_TYPE_MENU") > > > > Reported-by: Zubin Mithra > > > > > > checkpatch now requests a Reported-by tag to be immediately followed by > > > a Closes tag that contains the URL to the report. Could you please > > > provide that ? > > > > I saw that, but the URL is kind of private: > > > > Closes: http://issuetracker.google.com/issues/289975230 > > Ah :-S I wonder if we should drop the Reported-by tag then ? > > > > > Signed-off-by: Ricardo Ribalda > > > > --- > > > > Avoid reading index >= 31 > > > > --- > > > > Changes in v2: > > > > - Use BITS_PER_TYPE instead of 32 (thanks Sergey). > > > > - Add Reported-by tag. > > > > - Link to v1: https://lore.kernel.org/r/20230717-uvc-oob-v1-1-f5b9b4aba3b4@chromium.org > > > > --- > > > > drivers/media/usb/uvc/uvc_ctrl.c | 3 +++ > > > > 1 file changed, 3 insertions(+) > > > > > > > > diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c > > > > index 5e9d3da862dd..e59a463c2761 100644 > > > > --- a/drivers/media/usb/uvc/uvc_ctrl.c > > > > +++ b/drivers/media/usb/uvc/uvc_ctrl.c > > > > @@ -1402,6 +1402,9 @@ int uvc_query_v4l2_menu(struct uvc_video_chain *chain, > > > > query_menu->id = id; > > > > query_menu->index = index; > > > > > > > > + if (index >= BITS_PER_TYPE(mapping->menu_mask)) > > > > + return -EINVAL; > > > > + > > > > > > I'd move this a few lines up, before setting query_menu. > > > > SGTM, I just wanted to clear all the fields to mimic the other error > > paths of the function. > > I'm fine with that too if you prefer. Your call. I prefer my version, but I am of course biased :P > > > > With those minor changes, > > > > > > Reviewed-by: Laurent Pinchart > > > > > > There's no need for a v3, I can handle the changes locally, but I need > > > the URL for the Closes tag. > > > > > > > ret = mutex_lock_interruptible(&chain->ctrl_mutex); > > > > if (ret < 0) > > > > return -ERESTARTSYS; > > > > > > > > --- > > > > base-commit: fdf0eaf11452d72945af31804e2a1048ee1b574c > > > > change-id: 20230717-uvc-oob-4b0148a00417 > > -- > Regards, > > Laurent Pinchart -- Ricardo Ribalda