Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 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>
Link: https://patch.msgid.link/20260320-usb-net-lifecycle-v1-2-4886b578161b@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Kuen-Han Tsai and committed by
Greg Kroah-Hartman
8d8c68b1 caa27923

+6 -3
+6 -3
drivers/usb/gadget/function/f_rndis.c
··· 11 11 12 12 /* #define VERBOSE_DEBUG */ 13 13 14 + #include <linux/cleanup.h> 14 15 #include <linux/slab.h> 15 16 #include <linux/kernel.h> 16 17 #include <linux/module.h> ··· 679 678 return -ENOMEM; 680 679 } 681 680 682 - rndis_iad_descriptor.bFunctionClass = rndis_opts->class; 683 - rndis_iad_descriptor.bFunctionSubClass = rndis_opts->subclass; 684 - rndis_iad_descriptor.bFunctionProtocol = rndis_opts->protocol; 681 + scoped_guard(mutex, &rndis_opts->lock) { 682 + rndis_iad_descriptor.bFunctionClass = rndis_opts->class; 683 + rndis_iad_descriptor.bFunctionSubClass = rndis_opts->subclass; 684 + rndis_iad_descriptor.bFunctionProtocol = rndis_opts->protocol; 685 + } 685 686 686 687 /* 687 688 * in drivers/usb/gadget/configfs.c:configfs_composite_bind()