From patchwork Wed Jul 19 12:05:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 122584 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2396428vqt; Wed, 19 Jul 2023 05:20:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlHsjpsdjWqWzIjwPZtJypAVNmuzkM7wb5sNxmMi0zKqSpLZeIXSaCWVKiUoZuNsxhVJuR8n X-Received: by 2002:a17:906:73cf:b0:993:dd1d:824d with SMTP id n15-20020a17090673cf00b00993dd1d824dmr2504048ejl.19.1689769233024; Wed, 19 Jul 2023 05:20:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689769233; cv=none; d=google.com; s=arc-20160816; b=antrk5L5Gb4WstakGGwWpBazwH+0aIU/qiPkjemmobYwBXpQNM7J6Fi0i3KCS4mMDJ tBciHB9D54Za9qnZFdp2dO7GyqNCj4LEmoCSO8vJWk4vJrQqH1W5wT+OeWwyX76Vyyd6 1pABixYrySoklv/PW2bB/Vat/D0y7SQ4kW8wD/XwnePy5qgrMq239o0csb6Uw+QDkZO2 p+ECTPLxVG1kXDGAln74hzdZYstYRSz4rmCAafpNWL6HNSSwSpYaH7vRIckCDEPOtH2a kQLD655EuqH5NLr6U8S0x3ZP0HRL3ywjI+c6cxKTQwluX8ACgxDPxBvwWb7JEU06FGC+ vXPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=pLowqAWOc4M3SC2uHAXkI5IQ+uhVoM7LHPPZMdxwUUI=; fh=cDzc3CAYYqJGZh/UVtiN1GKa6zjSedkJ54zZ9+wWO+I=; b=1B5wtQtVvkwGQKeUCoD64gjzCgpVmvFC8B1ibWgmazI6iSMqMC5rNUX+a+zd7ZhbAa /OWZtJ2arLrko7+HYCRH8cLSM1Ukf4f78jun74tcJWpOd058pXrYDZFzvYaQ4kbpZwTo Eyatzr6bs+AVLC+6bHscK2e+N/w3X12zLTvfYAJVTt/8GGb9/emXs0sHhd7lcRYnnKKQ 71Lb3oczcUGE4rCiGlzfDawUaBGqskoRknfTxOnHfX4q2i9zryO2ijlRrovnecK49/9S SNfX/U2K8oK/dCqmQqzsWsod9EoLL7h30YTmVBtyNRfp/JiGmENyu2Ubq69o4mz4JM3U 0V4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PXxx2pbS; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a1709060ac900b0098730845081si2590698ejf.599.2023.07.19.05.20.08; Wed, 19 Jul 2023 05:20:33 -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=PXxx2pbS; 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 S230144AbjGSMFf (ORCPT + 99 others); Wed, 19 Jul 2023 08:05:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbjGSMFc (ORCPT ); Wed, 19 Jul 2023 08:05:32 -0400 Received: from mail-yw1-x1133.google.com (mail-yw1-x1133.google.com [IPv6:2607:f8b0:4864:20::1133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B57F2E0 for ; Wed, 19 Jul 2023 05:05:31 -0700 (PDT) Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-579d5d89b41so69996387b3.2 for ; Wed, 19 Jul 2023 05:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689768331; x=1692360331; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=pLowqAWOc4M3SC2uHAXkI5IQ+uhVoM7LHPPZMdxwUUI=; b=PXxx2pbSriUm3e3DE8gaZBuxsjDEaS9cNZVOUYnyPAfBJxQrxxfTjVx0oYzXIkle8p 3h0cu+5hkbVFSEMnwxoB8bwlIAvcGQAHmUcopd3kUevwruiIpasepjFitt/u0UqLtRtP H3DyyFPDMqjgwp2EY90oRs42NDTjWfzb/Wy9o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689768331; x=1692360331; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pLowqAWOc4M3SC2uHAXkI5IQ+uhVoM7LHPPZMdxwUUI=; b=RHsG5VYP8VFKx3YyAHDWIprMIAbtBR47SnUftY8+/MjWpct75NqFBvNcIFzNu+7h9d HeRMm1V6QQoZWErQwyjTDlnzcEPWTguDh+pWzHq8k8N1SDmJqP79jUbOScHbg6bsWwsZ WgQ5KS7mNs1FpSOZ0xdsIUdy2cuy8jWyEQZo3wVpkH6QwmJKEx8zhG2tkiz1br6vloZB pJN8rf+hDY46dqcYBMQ23SKN8gHW36y/8x8QXWYJ/+77VPqCbcngOKM4zuGC6BgRHsu2 OwZLOjOiXjwzQ4QvfvWKS3AXtNqe1VroDaXlvmZl86lLyXQkOPjrDdbvUTCwA9jyyPgh O+Fw== X-Gm-Message-State: ABy/qLZEp1FbFzqo1s7Kq4w1BQIyfW9Jzr9ERnwV2fkl6/uh2kVNRIXa FcQNIl6z9aUrCKsnPB4eZWbuaA== X-Received: by 2002:a0d:ebc3:0:b0:568:d586:77c4 with SMTP id u186-20020a0debc3000000b00568d58677c4mr17111470ywe.4.1689768330891; Wed, 19 Jul 2023 05:05:30 -0700 (PDT) Received: from denia.c.googlers.com (122.213.145.34.bc.googleusercontent.com. [34.145.213.122]) by smtp.gmail.com with ESMTPSA id h23-20020ac87457000000b003f9b9d7f319sm1274205qtr.70.2023.07.19.05.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 05:05:30 -0700 (PDT) From: Ricardo Ribalda Date: Wed, 19 Jul 2023 12:05:29 +0000 Subject: [PATCH] media: uvcvideo: Fix OOB read MIME-Version: 1.0 Message-Id: <20230717-uvc-oob-v1-1-f5b9b4aba3b4@chromium.org> X-B4-Tracking: v=1; b=H4sIAIjRt2QC/x3NQQqDMBCF4avIrDsw0UBKr1JcTOK0ziYpE5SCe HcTlz/vg3dAFVOp8BoOMNm1askt3GOAtHL+CurSGkYaJwou4LYnLCWij+T8k4m8C9B05CoYjXN au+/EhJc+/Uw++r9P3vN5XkwfF9l0AAAA To: Laurent Pinchart , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.2 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_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771851463277528101 X-GMAIL-MSGID: 1771851463277528101 If the index provided by the user is bigger than 32, we might do an out of bound read. CC: stable@kernel.org Fixes: 40140eda661e ("media: uvcvideo: Implement mask for V4L2_CTRL_TYPE_MENU") Signed-off-by: Ricardo Ribalda --- Avoid reading index >= 31 --- drivers/media/usb/uvc/uvc_ctrl.c | 3 +++ drivers/media/usb/uvc/uvcvideo.h | 1 + 2 files changed, 4 insertions(+) --- base-commit: fdf0eaf11452d72945af31804e2a1048ee1b574c change-id: 20230717-uvc-oob-4b0148a00417 Best regards, diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 5e9d3da862dd..5e3af66a2223 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 >= UVC_MAX_MENU) + return -EINVAL; + ret = mutex_lock_interruptible(&chain->ctrl_mutex); if (ret < 0) return -ERESTARTSYS; diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 6fb0a78b1b00..139608f83499 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -101,6 +101,7 @@ struct uvc_control_info { u32 flags; }; +#define UVC_MAX_MENU 32 struct uvc_control_mapping { struct list_head list; struct list_head ev_subs;