mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
usb: gadget: f_rndis: Protect RNDIS options with mutex
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: 73517cf49b ("usb: gadget: add RNDIS configfs options for class/subclass/protocol")
Cc: stable@vger.kernel.org
Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
Link: https://patch.msgid.link/20260320-usb-net-lifecycle-v1-2-4886b578161b@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
caa27923aa
commit
8d8c68b1fc
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user