From: Kuen-Han Tsai <khtsai@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Kyungmin Park <kyungmin.park@samsung.com>,
Felipe Balbi <balbi@kernel.org>,
David Lechner <david@lechnology.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Kuen-Han Tsai <khtsai@google.com>,
stable@vger.kernel.org
Subject: [PATCH 2/7] usb: gadget: f_rndis: Protect RNDIS options with mutex
Date: Fri, 20 Mar 2026 16:54:45 +0800 [thread overview]
Message-ID: <20260320-usb-net-lifecycle-v1-2-4886b578161b@google.com> (raw)
In-Reply-To: <20260320-usb-net-lifecycle-v1-0-4886b578161b@google.com>
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/subclass/protocol")
Cc: stable@vger.kernel.org
Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
---
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/function/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 @@
/* #define VERBOSE_DEBUG */
+#include <linux/cleanup.h>
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/module.h>
@@ -678,9 +679,11 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
return -ENOMEM;
}
- rndis_iad_descriptor.bFunctionClass = rndis_opts->class;
- rndis_iad_descriptor.bFunctionSubClass = rndis_opts->subclass;
- rndis_iad_descriptor.bFunctionProtocol = rndis_opts->protocol;
+ scoped_guard(mutex, &rndis_opts->lock) {
+ rndis_iad_descriptor.bFunctionClass = rndis_opts->class;
+ rndis_iad_descriptor.bFunctionSubClass = rndis_opts->subclass;
+ rndis_iad_descriptor.bFunctionProtocol = rndis_opts->protocol;
+ }
/*
* in drivers/usb/gadget/configfs.c:configfs_composite_bind()
--
2.53.0.959.g497ff81fa9-goog
next prev parent reply other threads:[~2026-03-20 8:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 8:54 [PATCH 0/7] usb: gadget: Fix net_device lifecycles and configfs races Kuen-Han Tsai
2026-03-20 8:54 ` [PATCH 1/7] usb: gadget: f_subset: Fix unbalanced refcnt in geth_free Kuen-Han Tsai
2026-03-20 8:54 ` Kuen-Han Tsai [this message]
2026-03-20 8:54 ` [PATCH 3/7] usb: gadget: u_ncm: Add kernel-doc comments for struct f_ncm_opts Kuen-Han Tsai
2026-03-20 8:54 ` [PATCH 4/7] usb: gadget: f_ecm: Fix net_device lifecycle with device_move Kuen-Han Tsai
2026-03-20 8:54 ` [PATCH 5/7] usb: gadget: f_eem: " Kuen-Han Tsai
2026-03-20 8:54 ` [PATCH 6/7] usb: gadget: f_subset: " Kuen-Han Tsai
2026-03-20 8:54 ` [PATCH 7/7] usb: gadget: f_rndis: " Kuen-Han Tsai
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=20260320-usb-net-lifecycle-v1-2-4886b578161b@google.com \
--to=khtsai@google.com \
--cc=balbi@kernel.org \
--cc=david@lechnology.com \
--cc=gregkh@linuxfoundation.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®