From nobody Mon Apr 6 09:11:44 2026 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 247AA377014 for ; Fri, 20 Mar 2026 08:55:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773996923; cv=none; b=gfTVD++nxhgP0b+BTUT17QFLQPuLc1F9RZ5SCNe++aeTTX6b7qlnGnskAvxPOpfJLhvDAsXhyrA4SyLYFEkC7yslEFBLJx8qjBKN+yjtGquiyiboqPTMtKHLYvqjC7qz3PJMiPJnfr5Ubbc5AlVXpfdiC8cnvdmL5d4dZiokDqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773996923; c=relaxed/simple; bh=6Wkr6y8zvwVGvQGPNYUT30NoBb4TcsrkrqZeBgojKgk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ssw324KBwPYQ8L3KsL6pQuztS5Lw/g3nuE2m4zeg15R0z/ZYn6VK7ppgMIsVjiRG7ldbHl3x6Vvws9vIicEMGPuPokkoQ/yXTJHF9uVwSSYrB+C0xCu3L+Seqsu4qJB5YQ9uRET2cvgJuHpDkIFiKpJ9nl4qTeX+c68FET1nOnc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--khtsai.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=uUdz5pjF; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--khtsai.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uUdz5pjF" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c70ea91bfe1so1534026a12.1 for ; Fri, 20 Mar 2026 01:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773996921; x=1774601721; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=hZ7vsqBU2jtHuNF1VCOsuin7WLACvQQEK8+9Bbcoxqo=; b=uUdz5pjFTS+WCCMmWUWscbOP1MTYn/8UbNXYHATlZNrliZ/h2THIjq3bayR+sV0wgO bYkkE9KpGJLPjD/KIHzqV1ybWiGFEKkRMUzgsZb0cgGImtDRCtsI54QWNRkxZ5pL0EUE TrTZ/1HhIb0gOfWaC668vlLMTjTRJb+HHoZXcS1RqLVGw32+qRKhAd2y3nxHYPg+xpnQ mFvLm+6msxjjq2JDN5f04Dl/J84ub2jiim65HL6pvJDkquEHVmewDvlSLKK5nWaKQuNX 2yV/w6BQ+h0MOOdjyuvXyDTWO+toL2bRlauG2M9o9rm1JrVd3tXkF387x6U3ga9x8GY7 mwZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773996921; x=1774601721; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hZ7vsqBU2jtHuNF1VCOsuin7WLACvQQEK8+9Bbcoxqo=; b=O943lC4O5USZhe4VnmT+qZ/Eb9BLuGdaV5gqInE2aSaoRvYN90JL5Xi8OzhyUK9SPJ Lt02CkJ1ece9B16gX8nroUXf7JE18TvzKqcyvmvnBrbkrZHXF5JDC/liEAXc1TvJUKrB shCaK4uwJQuqQDED6RIR9ygEswf4TwkGD7dsvtWhdYx2O74fMfyC/e0G09nEr+JRi+Mw Tr4mSBuOonEtHRcb5aSjaEus0LgVgQVMbw0VexLiovozPM9N8RHK2FM4OtNCJYSCsXMh pDn/hPeavlIMsM8YeuLnJi6hJQZivTEcp+OoQyLBbG9Tz94mSXiTT17yV/oTqGiEtiis KdVw== X-Forwarded-Encrypted: i=1; AJvYcCVK98jVMZ/VHbA5tupP9SqohvlqzJoBHR+pdNgTVGhzxEQpW9ciFQqRo+JHbIfTxN5RLdC02A21SlIQpxc=@vger.kernel.org X-Gm-Message-State: AOJu0YzvxfJNfiFkvPf95z/DLQfLFF0TEt/6MGt2hnpu2TZP9a/hiHf1 jw1uptAGcQDXXCowiT6hzFwvYeVcQlJElTfbL/Wc3cgEDLnMlg+Xm8v2Vv+WJZ6Rk5X9hfbNwRs Mk+6H5Q== X-Received: from pfbbt10.prod.google.com ([2002:a05:6a00:438a:b0:82a:6e03:a17f]) (user=khtsai job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3d10:b0:82a:77f9:c563 with SMTP id d2e1a72fcca58-82a8c22deabmr1820957b3a.12.1773996921141; Fri, 20 Mar 2026 01:55:21 -0700 (PDT) Date: Fri, 20 Mar 2026 16:54:45 +0800 In-Reply-To: <20260320-usb-net-lifecycle-v1-0-4886b578161b@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260320-usb-net-lifecycle-v1-0-4886b578161b@google.com> X-Developer-Key: i=khtsai@google.com; a=ed25519; pk=abA4Pw6dY2ZufSbSXW9mtp7xiv1AVPtgRhCFWJSEqLE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1773996915; l=1561; i=khtsai@google.com; s=20250916; h=from:subject:message-id; bh=6Wkr6y8zvwVGvQGPNYUT30NoBb4TcsrkrqZeBgojKgk=; b=v8vZYl0ZMCKyFw75/3cvh+rKLQGT0mxQMyM9i1ZigduUl/TMQ6/WSN2wbvDbTi7ITMVr9tAy2 OgCsgnfoDZ6AJKz/G4uH9hFs6gmLjtZtgdn5E3QO8DoyM/0L6RyzjAX X-Mailer: b4 0.14.3 Message-ID: <20260320-usb-net-lifecycle-v1-2-4886b578161b@google.com> Subject: [PATCH 2/7] usb: gadget: f_rndis: Protect RNDIS options with mutex From: Kuen-Han Tsai To: Greg Kroah-Hartman , Kyungmin Park , Felipe Balbi , David Lechner Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kuen-Han Tsai , stable@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The class/subclass/protocol options are suspectible to race conditions as they can be accessed concurrently through configfs. Use existing mutex to protect these options. This issue was identified during code inspection. Fixes: 73517cf49bd4 ("usb: gadget: add RNDIS configfs options for class/sub= class/protocol") Cc: stable@vger.kernel.org Signed-off-by: Kuen-Han Tsai --- drivers/usb/gadget/function/f_rndis.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/fun= ction/f_rndis.c index 8b11d8d6d89c..521b4619d6be 100644 --- a/drivers/usb/gadget/function/f_rndis.c +++ b/drivers/usb/gadget/function/f_rndis.c @@ -11,6 +11,7 @@ =20 /* #define VERBOSE_DEBUG */ =20 +#include #include #include #include @@ -678,9 +679,11 @@ rndis_bind(struct usb_configuration *c, struct usb_fun= ction *f) return -ENOMEM; } =20 - rndis_iad_descriptor.bFunctionClass =3D rndis_opts->class; - rndis_iad_descriptor.bFunctionSubClass =3D rndis_opts->subclass; - rndis_iad_descriptor.bFunctionProtocol =3D rndis_opts->protocol; + scoped_guard(mutex, &rndis_opts->lock) { + rndis_iad_descriptor.bFunctionClass =3D rndis_opts->class; + rndis_iad_descriptor.bFunctionSubClass =3D rndis_opts->subclass; + rndis_iad_descriptor.bFunctionProtocol =3D rndis_opts->protocol; + } =20 /* * in drivers/usb/gadget/configfs.c:configfs_composite_bind() --=20 2.53.0.959.g497ff81fa9-goog