From patchwork Sat Sep 30 18:48:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avichal Rakesh X-Patchwork-Id: 14767 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp651382vqb; Sat, 30 Sep 2023 18:27:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4ZQtlATW9SuA+6Lch/R+8hdkLhJd42Kdu/pJMDkEgjKeoV837CXR3GkrUdnykflWrl5Db X-Received: by 2002:a05:6a20:12d1:b0:15e:7323:5bf3 with SMTP id v17-20020a056a2012d100b0015e73235bf3mr13011462pzg.26.1696123648043; Sat, 30 Sep 2023 18:27:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696123648; cv=none; d=google.com; s=arc-20160816; b=z15wrLdl8mbq8zKJASJ0G/5xwFqKQr7dUDvRXuuzwrtaow1Ga2tfXbxaRzcG02PWCZ QY11tYSstVqo8EAibJ4Y6yL3n6yOkSou/sn6MIPV6YFj8l7hRrqSM/TN0BY2DE4FOfOL hYn5tiTmVgWZErAI2NAWJWMFCeHjSH1j/lPRmsjn4N0b8WUgNX5kUce+iTdKkUDY+Gj0 YA0dsRzdD+5sVHyQU6agyenX35akzXyY1Jn2OMgA0hp48ZKmGCNRzJTIBbDjVgH03t+J cpG5pcvsJYIp+sxkki1U/pic8j659NZmLleNSVBgG9XfECH2Dux7hReyQ1GOXpluOxDQ J3Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=gKqACIemJ7xq8miKveFE694eSHgsnRyVWu3g5h4Gxp4=; fh=X0UZ/0JiC2tQYTlQJjUvn7XaESk5c4hOSEK+aRyeDXE=; b=w/eFDJzIy7aijKDAIdJTcBj5dNKZo2p47m61YO+hcBTfQAiwbruJwmWQk5Pfexi1ZT gSy1OVHq2AIAVQrXG9/i2vdlMxHnoYFk3VPITnDYkfuefrALGPQIFvLb7YD9a6snJ0QY Y329RyFvBgogZK8kau1ZG7QoXhcPEjJtV/kuVFG1l1w2IJ8nWp127JG35xvxUBIeXtv0 axqA9tBPpPS792nUfkaWfuz3ZS8vvoJr15cSlMn+YdjZAKN/3V0s4YSt40GX63Ov0uO+ 8qzcU8JuTxUKw1eJQx+324uFfN49ivuTmd+3l1kfB00dpYSckFYpW7JqnpFxd4LD/lVK S48A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3a4VBHeW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id u62-20020a638541000000b00588e13f4cc8si2452981pgd.519.2023.09.30.18.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 18:27:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3a4VBHeW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C712A802733B; Sat, 30 Sep 2023 11:48:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234695AbjI3Ssa (ORCPT + 20 others); Sat, 30 Sep 2023 14:48:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231603AbjI3Ss3 (ORCPT ); Sat, 30 Sep 2023 14:48:29 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C943BDD for ; Sat, 30 Sep 2023 11:48:26 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-57cf261194aso16739971a12.3 for ; Sat, 30 Sep 2023 11:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696099706; x=1696704506; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=gKqACIemJ7xq8miKveFE694eSHgsnRyVWu3g5h4Gxp4=; b=3a4VBHeWdu0/zbAmE7je7DBZv+0KEc/xQMVeV+qdGK6Nr8LfehtgWbocwiY+dYlgLZ PAACuN7qj+NQTZTYVetASsQx8DYWkZfPrQMLvDAZhsCJnh2VqkpzBm5QJuOZI5l0TYbd ytUK3acBBgwxaufYyEunNxjsEqTnl8fX7f8RDIcUSmXu8umNAb0qqQtEm9vKHj/FgyjO hi+VVa00WP7deOyQ62HrgxmuBcGB1zwinhIq+/Tq4mACwE5ZRdEMCwF8O9vfacgT6s/J R7sDA70ZawaazXg6ttCdXpBFjiNL5rllXcIKbG9ejb5YX/gPVBCKk1sR2/bVwa8CqfmJ p3Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696099706; x=1696704506; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=gKqACIemJ7xq8miKveFE694eSHgsnRyVWu3g5h4Gxp4=; b=MjEl1b6Nh9nCe/p8qii79feniFOLcb3ZRzStbdYrvV31gPPN1L/bhtLMmZp10U+1uL HdBsh/i41/aLX+X8Re+Jqr3mrkBqWaNTeGk19i5ZuWO4W68e+ha8xbuPwOMO/1tjtW6d pGOJdq/kM9ZyzGjV/kPNU8xWrtHDMYxX5GX4B2Hx++T9KodZNXwT4caiJ0s4S1gHC9me tPHg0RZAn6Smpgqb7wp6lLzSdIxs4ughYmpBSve7fMaAyZAOucZF2l4o9gJQNYd+e8Y8 4vvarJcJD+d8/Rh13oIUSKcrmVFo2XYcZ8esuSa5bM1hcxuPkYa/I4+zVSXOWYVyGgyl gYPQ== X-Gm-Message-State: AOJu0YwQJ9PdHHk1MvJgrWZeE9toKuUEtOkaVUZOX1VHd6MOfiw4+H93 MsAdUNlZbviF6BI598OYm59eZ9EXnUJk X-Received: from hi-h2o-specialist.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:3cef]) (user=arakesh job=sendgmr) by 2002:a63:6d48:0:b0:563:dddb:2016 with SMTP id i69-20020a636d48000000b00563dddb2016mr116191pgc.5.1696099706255; Sat, 30 Sep 2023 11:48:26 -0700 (PDT) Date: Sat, 30 Sep 2023 11:48:18 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.582.g8ccd20d70d-goog Message-ID: <20230930184821.310143-1-arakesh@google.com> Subject: [PATCH v1 0/3] usb: gadget: uvc: stability fixes on STREAMOFF. From: Avichal Rakesh To: Laurent Pinchart , Daniel Scally , Greg Kroah-Hartman , Michael Grzeschik Cc: jchowdhary@google.com, etalvala@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Avichal Rakesh X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 30 Sep 2023 11:48:40 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778514550514119417 X-GMAIL-MSGID: 1778514550514119417 We have been seeing two main stability issues that uvc gadget driver runs into when stopping streams: 1. Attempting to queue usb_requests to a disabled usb_ep 2. use-after-free issue for inflight usb_requests The three patches below fix the two issues above. Patch 1/3 fixes the first issue, and Patch 2/3 and 3/3 fix the second issue. Avichal Rakesh (3): usb: gadget: uvc: prevent use of disabled endpoint usb: gadget: uvc: Allocate uvc_requests one at a time usb: gadget: uvc: Fix use-after-free for inflight usb_requests drivers/usb/gadget/function/f_uvc.c | 11 +- drivers/usb/gadget/function/f_uvc.h | 2 +- drivers/usb/gadget/function/uvc.h | 6 +- drivers/usb/gadget/function/uvc_v4l2.c | 21 ++- drivers/usb/gadget/function/uvc_video.c | 189 +++++++++++++++++------- 5 files changed, 164 insertions(+), 65 deletions(-) --- 2.42.0.582.g8ccd20d70d-goog