mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: legacy: ether: fix RNDIS for Windows hosts
@ 2026-10-30  9:17 amine-ayaou
  2026-10-30 11:13 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: amine-ayaou @ 2026-10-30  9:17 UTC (permalink / raw)
  To: nkapron; +Cc: gregkh, linux-usb, linux-kernel, Amine Ayaou

From: Amine Ayaou <amine-ayaou@hotmail.com>

Fix RNDIS for Windows hosts by adding Microsoft OS 1.0
descriptor that allows Windows to identify the RNDIS function.

g_ether currently advertises its RNDIS configuration using
the legacy NetChip VID/PID and the RNDIS control interface
class, subclass and protocol values provided by f_rndis
(02/02/FF).

While the Linux rndis_host driver still recognizes the legacy
02/02/FF RNDIS interface descriptors, modern Windows hosts
do not bind the RNDIS driver to g_ether.

Use the existing USB composite framework support for
Microsoft OS 1.0 descriptors to advertise RNDIS when the
RNDIS function is enabled in g_ether.

Use of OS descriptor does not change the existing device IDs
or RNDIS control interface descriptors, keeping compatibility
with older hosts.
(It only adds a string descriptor at index 0xEE and handles
the associated vendor request)

Signed-off-by: Amine Ayaou <amine-ayaou@hotmail.com>
---

Notes:
    g_ether's RNDIS is useful when a network interface via USB
    is needed early during boot, before a filesystem is available
    (e.g., nfsroot).
    
    Alternatives for having a network interface via USB during
    boot are configfs and g_ncm.
    Configuring the gadget through configfs requires userspace,
    which is unavailable before mounting the NFS root when
    no initramfs is used.
    NCM (g_ncm) is not an option on hosts that only provide
    RNDIS support.
    
    Tested on BeagleBone Black with a Windows 11 host
    (Version 10.0.26200, Build 26200)
    RNDIS automatically bound with the patch.

 drivers/usb/gadget/legacy/ether.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/legacy/ether.c b/drivers/usb/gadget/legacy/ether.c
index 99c7fc0d1d597..70de686fa56b7 100644
--- a/drivers/usb/gadget/legacy/ether.c
+++ b/drivers/usb/gadget/legacy/ether.c
@@ -11,6 +11,7 @@
 
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
+#include <linux/nls.h>
 
 #if defined USB_ETH_RNDIS
 #  undef USB_ETH_RNDIS
@@ -92,8 +93,8 @@ static inline bool has_rndis(void)
 
 #include "u_ecm.h"
 #include "u_gether.h"
-#ifdef	USB_ETH_RNDIS
 #include "u_rndis.h"
+#ifdef	USB_ETH_RNDIS
 #include "rndis.h"
 #else
 #define rndis_borrow_net(...) do {} while (0)
@@ -364,6 +365,8 @@ static int eth_bind(struct usb_composite_dev *cdev)
 
 	if (has_rndis()) {
 		/* RNDIS plus ECM-or-Subset */
+		struct f_rndis_opts *rndis_opts = NULL;
+
 		gether_set_gadget(net, cdev->gadget);
 		status = gether_register_netdev(net);
 		if (status)
@@ -387,6 +390,18 @@ static int eth_bind(struct usb_composite_dev *cdev)
 		device_desc.idVendor = cpu_to_le16(RNDIS_VENDOR_NUM);
 		device_desc.idProduct = cpu_to_le16(RNDIS_PRODUCT_NUM);
 		device_desc.bNumConfigurations = 2;
+
+		/* Configure Microsoft OS 1.0 descriptors for RNDIS. */
+		cdev->os_desc_config = &rndis_config_driver;
+		cdev->use_os_string = true;
+		cdev->b_vendor_code = 0xcd; /* arbitrary */
+		utf8s_to_utf16s("MSFT100", 7,
+			UTF16_LITTLE_ENDIAN, (wchar_t *)cdev->qw_sign,
+			OS_STRING_QW_SIGN_LEN / 2);
+		rndis_opts = container_of(fi_rndis, struct f_rndis_opts,
+					  func_inst);
+		memcpy(rndis_opts->rndis_ext_compat_id,
+			"RNDIS\0\0\0" "5162001", 16);
 	}
 
 	/* Allocate string descriptor numbers ... note that string
-- 
2.53.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: gadget: legacy: ether: fix RNDIS for Windows hosts
  2026-10-30  9:17 [PATCH] usb: gadget: legacy: ether: fix RNDIS for Windows hosts amine-ayaou
@ 2026-10-30 11:13 ` Greg KH
  2026-11-04 21:08   ` Amine AYAOU
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2026-10-30 11:13 UTC (permalink / raw)
  To: amine-ayaou; +Cc: nkapron, linux-usb, linux-kernel

On Fri, Oct 30, 2026 at 10:17:06AM +0100, amine-ayaou@hotmail.com wrote:
> From: Amine Ayaou <amine-ayaou@hotmail.com>
> 
> Fix RNDIS for Windows hosts by adding Microsoft OS 1.0
> descriptor that allows Windows to identify the RNDIS function.

No, please no.

RNDIS should NEVER be used, it's not required by any shipping OS that I
know of these days, do you?

Why do you want this?  And are you really still using the "legacy" USB
gadget drivers?  If so, why?  What is preventing you from using the
"new" ones?

I ask as we are about to delete these legacy drivers and I don't want to
have anyone add new features to them.

> g_ether currently advertises its RNDIS configuration using
> the legacy NetChip VID/PID and the RNDIS control interface
> class, subclass and protocol values provided by f_rndis
> (02/02/FF).
> 
> While the Linux rndis_host driver still recognizes the legacy
> 02/02/FF RNDIS interface descriptors, modern Windows hosts
> do not bind the RNDIS driver to g_ether.

modern Windows hosts know that rndis is a lame protocol and should never
be used :)

Seriously, it's a broken one, there is no security for it and it's only
good for very very old desktop systems that never were updated to a
modern operating system.  And even then I would argue it shouldn't be
used.

> Notes:
>     g_ether's RNDIS is useful when a network interface via USB
>     is needed early during boot, before a filesystem is available
>     (e.g., nfsroot).

useful for which side?  What can you do with this "during boot"?  And
you are connecting to a nfs windows server with it?

>     Alternatives for having a network interface via USB during
>     boot are configfs and g_ncm.

YEs.

>     Configuring the gadget through configfs requires userspace,
>     which is unavailable before mounting the NFS root when
>     no initramfs is used.

Then use an initramfs :)

>     NCM (g_ncm) is not an option on hosts that only provide
>     RNDIS support.

What hosts exactly are that?  And why would you connect to them?

>     Tested on BeagleBone Black with a Windows 11 host
>     (Version 10.0.26200, Build 26200)
>     RNDIS automatically bound with the patch.

And did your nfs server on that host work properly?

Sorry for the rant, but I really want to delete this stuff as it should
never be used anymore...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: gadget: legacy: ether: fix RNDIS for Windows hosts
  2026-10-30 11:13 ` Greg KH
@ 2026-11-04 21:08   ` Amine AYAOU
  0 siblings, 0 replies; 3+ messages in thread
From: Amine AYAOU @ 2026-11-04 21:08 UTC (permalink / raw)
  To: Greg KH; +Cc: nkapron, linux-usb, linux-kernel

Thank you for the feedback and for taking the time to review the patch.

It is clear for me now that additions to legacy drivers and RNDIS are
to be avoided.
I have no further arguments for this patch and I don't intend to push
for it further.

For my specific use case, using initramfs is possible (boot time is
unimportant).
Using g_ncm is also an option.

I have answered your questions below for context.

On 10/30/2026 12:13 PM, Greg KH wrote:
> RNDIS should NEVER be used, it's not required by any shipping OS that I
> know of these days, do you?
Windows 10. Specifically, any version prior to Windows 10 1903, where
NCM support was first bundled.

> Why do you want this?  And are you really still using the "legacy" USB
> gadget drivers?  If so, why?  What is preventing you from using the
> "new" ones?
When building a minimalist embedded Linux system, I reached for the most
straightforward option to boot with nfsroot, which happened to be the
legacy drivers.

> useful for which side?  What can you do with this "during boot"?  And
> you are connecting to a nfs windows server with it?
My setup is:
BeagleBone Black (BBB) / Linux <=USB=> Windows <=> WSL (nfs server)
The BBB boots using an nfsroot hosted on the WSL side.
Network traffic goes through Windows.

> What hosts exactly are that?  And why would you connect to them?
As mentioned, versions prior to Windows 10 1903. For instance, Windows
10 Enterprise LTSC 2019.
In a previous strict corporate IT environment, the embedded linux team
were handed Windows 10 machines. They had to connect to Linux (WSL)
through their Windows machines.

>>      Tested on BeagleBone Black with a Windows 11 host
>>      (Version 10.0.26200, Build 26200)
>>      RNDIS automatically bound with the patch.
> 
> And did your nfs server on that host work properly?
Yes.
(As mentioned, the nfs server is running on Linux)

Amine Ayaou

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-04 21:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-30  9:17 [PATCH] usb: gadget: legacy: ether: fix RNDIS for Windows hosts amine-ayaou
2026-10-30 11:13 ` Greg KH
2026-11-04 21:08   ` Amine AYAOU

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®