All of lore.kernel.org
 help / color / mirror / Atom feed
* Legacy configuration for NCM/RNDIS does not work for Win >= 10
@ 2023-03-10  9:44 Joakim Tjernlund
  2023-03-10  9:55 ` gregkh
  0 siblings, 1 reply; 6+ messages in thread
From: Joakim Tjernlund @ 2023-03-10  9:44 UTC (permalink / raw)
  To: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org

The old RNDIS/NCM configs does not work against modern Windows. I wonder if there
should/could be updated to working state ?

I tried to mimic configs like so:
-------------------- drivers/usb/gadget/function/f_ncm.c ---------------------
index dc8f078f918c..f75f4bfdc971 100644
@@ -17,6 +17,7 @@
 #include <linux/device.h>
 #include <linux/etherdevice.h>
 #include <linux/crc32.h>
+#include <linux/nls.h>
 
 #include <linux/usb/cdc.h>
 
@@ -148,9 +149,9 @@ static struct usb_interface_assoc_descriptor ncm_iad_desc = {
 
 	/* .bFirstInterface =	DYNAMIC, */
 	.bInterfaceCount =	2,	/* control + data */
-	.bFunctionClass =	USB_CLASS_COMM,
-	.bFunctionSubClass =	USB_CDC_SUBCLASS_NCM,
-	.bFunctionProtocol =	USB_CDC_PROTO_NONE,
+	.bFunctionClass =	0xef, //USB_CLASS_COMM,
+	.bFunctionSubClass =	0x02, //USB_CDC_SUBCLASS_NCM,
+	.bFunctionProtocol =	0x01, //USB_CDC_PROTO_NONE,
 	/* .iFunction =		DYNAMIC */
 };
 
@@ -162,9 +163,9 @@ static struct usb_interface_descriptor ncm_control_intf = {
 
 	/* .bInterfaceNumber = DYNAMIC */
 	.bNumEndpoints =	1,
-	.bInterfaceClass =	USB_CLASS_COMM,
-	.bInterfaceSubClass =	USB_CDC_SUBCLASS_NCM,
-	.bInterfaceProtocol =	USB_CDC_PROTO_NONE,
+	.bInterfaceClass =	0xef, //USB_CLASS_COMM,
+	.bInterfaceSubClass =	0x02, //USB_CDC_SUBCLASS_NCM,
+	.bInterfaceProtocol =	0x01, //USB_CDC_PROTO_NONE,
 	/* .iInterface = DYNAMIC */
 };
 
@@ -1423,7 +1424,10 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f)
 		return -EINVAL;
 
 	ncm_opts = container_of(f->fi, struct f_ncm_opts, func_inst);
-
+	cdev->use_os_string = true;
+	cdev->b_vendor_code = 0xbc; /* Microsoft */
+	utf8s_to_utf16s("MSFT100", 7, UTF16_LITTLE_ENDIAN,
+			(wchar_t *)cdev->qw_sign, OS_STRING_QW_SIGN_LEN); /* Microsft */
 	if (cdev->use_os_string) {
 		f->os_desc_table = kzalloc(sizeof(*f->os_desc_table),
 					   GFP_KERNEL);
@@ -1625,6 +1629,8 @@ static struct usb_function_instance *ncm_alloc_inst(void)
 	opts = kzalloc(sizeof(*opts), GFP_KERNEL);
 	if (!opts)
 		return ERR_PTR(-ENOMEM);
+	strcpy(opts->ncm_ext_compat_id, "WINNCM"); /* compatible_id */
+
 	opts->ncm_os_desc.ext_compat_id = opts->ncm_ext_compat_id;
 
 	mutex_init(&opts->lock);


and:
------------------- drivers/usb/gadget/function/f_rndis.c --------------------
index ee95e8f5f9d4..e7c0a60c1107 100644
@@ -17,6 +17,7 @@
 #include <linux/device.h>
 #include <linux/etherdevice.h>
 
+#include <linux/nls.h>
 #include <linux/atomic.h>
 
 #include "u_ether.h"
@@ -176,9 +177,9 @@ rndis_iad_descriptor = {
 
 	.bFirstInterface =	0, /* XXX, hardcoded */
 	.bInterfaceCount = 	2,	// control + data
-	.bFunctionClass =	USB_CLASS_COMM,
-	.bFunctionSubClass =	USB_CDC_SUBCLASS_ETHERNET,
-	.bFunctionProtocol =	USB_CDC_PROTO_NONE,
+	.bFunctionClass =	0xef, //USB_CLASS_COMM,
+	.bFunctionSubClass =	0x02, //USB_CDC_SUBCLASS_ETHERNET,
+	.bFunctionProtocol =	0x01, //USB_CDC_PROTO_NONE,
 	/* .iFunction = DYNAMIC */
 };
 
@@ -681,6 +682,7 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
 
 	rndis_opts = container_of(f->fi, struct f_rndis_opts, func_inst);
 
+	cdev->use_os_string = true;
 	if (cdev->use_os_string) {
 		f->os_desc_table = kzalloc(sizeof(*f->os_desc_table),
 					   GFP_KERNEL);
@@ -688,6 +690,10 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
 			return -ENOMEM;
 		f->os_desc_n = 1;
 		f->os_desc_table[0].os_desc = &rndis_opts->rndis_os_desc;
+		//cdev->b_vendor_code = 0xcd; /* Microsoft */
+		cdev->b_vendor_code = 0xbc; /* Microsoft */
+		utf8s_to_utf16s("MSFT100", 7, UTF16_LITTLE_ENDIAN,
+				(wchar_t *)cdev->qw_sign, OS_STRING_QW_SIGN_LEN); /* Microsoft */
 	}
 
 	rndis_iad_descriptor.bFunctionClass = rndis_opts->class;
@@ -921,6 +927,8 @@ static struct usb_function_instance *rndis_alloc_inst(void)
 	opts = kzalloc(sizeof(*opts), GFP_KERNEL);
 	if (!opts)
 		return ERR_PTR(-ENOMEM);
+	strcpy(opts->rndis_ext_compat_id, "RNDIS"); /* RNDIS 6.0, compatible_id */
+	strcpy(opts->rndis_ext_compat_id + 8, "5162001"); /* RNDIS 6.0, sub_compatible_id */
 	opts->rndis_os_desc.ext_compat_id = opts->rndis_ext_compat_id;
 
 	mutex_init(&opts->lock);


But this didn't work

 Jocke


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

* Re: Legacy configuration for NCM/RNDIS does not work for Win >= 10
  2023-03-10  9:44 Legacy configuration for NCM/RNDIS does not work for Win >= 10 Joakim Tjernlund
@ 2023-03-10  9:55 ` gregkh
  2023-03-10 12:27   ` Joakim Tjernlund
  0 siblings, 1 reply; 6+ messages in thread
From: gregkh @ 2023-03-10  9:55 UTC (permalink / raw)
  To: Joakim Tjernlund; +Cc: linux-usb@vger.kernel.org

On Fri, Mar 10, 2023 at 09:44:26AM +0000, Joakim Tjernlund wrote:
> The old RNDIS/NCM configs does not work against modern Windows. I wonder if there
> should/could be updated to working state ?

Please never use RNDIS on modern systems unless you fully trust the
"other side" of the connection as it is not a secure protocol by any
means.

NCM should "just work" instead.  What exactly is failing, and what
specifically do you mean by "modern Windows"?

thanks,

greg k-h

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

* Re: Legacy configuration for NCM/RNDIS does not work for Win >= 10
  2023-03-10  9:55 ` gregkh
@ 2023-03-10 12:27   ` Joakim Tjernlund
  2023-03-14 13:19     ` Joakim Tjernlund
  0 siblings, 1 reply; 6+ messages in thread
From: Joakim Tjernlund @ 2023-03-10 12:27 UTC (permalink / raw)
  To: gregkh@linuxfoundation.org; +Cc: linux-usb@vger.kernel.org

On Fri, 2023-03-10 at 10:55 +0100, gregkh@linuxfoundation.org wrote:
> On Fri, Mar 10, 2023 at 09:44:26AM +0000, Joakim Tjernlund wrote:
> > The old RNDIS/NCM configs does not work against modern Windows. I wonder if there
> > should/could be updated to working state ?
> 
> Please never use RNDIS on modern systems unless you fully trust the
> "other side" of the connection as it is not a secure protocol by any
> means.

Yes, we will move to NCM (new in >= Windows 10)

> 
> NCM should "just work" instead.  What exactly is failing, and what
> specifically do you mean by "modern Windows"?

NCM does not just work on Windows >= 10 it needs configfs settings:

NCM snipped:
	echo 1       > os_desc/use
	echo 0xbc    > os_desc/b_vendor_code
	echo MSFT100 > os_desc/qw_sign

	mkdir functions/ncm.usb0
	mkdir -p functions/ncm.usb0/os_desc/interface.ncm
    #Set compatible id so that Windows 10 can match this function to
    # NCM driver more easily.
	echo WINNCM   > functions/ncm.usb0/os_desc/interface.ncm/compatible_id

	mkdir -p configs/c.1
	mkdir -p configs/c.1/strings/0x409
	echo "conf1" > configs/c.1/strings/0x409/configuration
	ln -s functions/ncm.usb0 configs/c.1
	if [ ! -L os_desc/c.1 ]
	then
		 ln -s configs/c.1 os_desc
	fi

New RNDIS in Windows >= 10
	echo 1       > os_desc/use
	echo 0xbc    > os_desc/b_vendor_code
	echo MSFT100 > os_desc/qw_sign

	mkdir functions/rndis.usb0
	mkdir -p functions/rndis.usb0/os_desc/interface.rndis

	#Set compatible / sub-compatible id's so that Windows can match this
    # function to RNDIS6 driver more easily.
	echo RNDIS   > functions/rndis.usb0/os_desc/interface.rndis/compatible_id
	echo 5162001 > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id

	mkdir -p configs/c.1
	mkdir -p configs/c.1/strings/0x409
	echo "conf1" > configs/c.1/strings/0x409/configuration
	ln -s functions/rndis.usb0 configs/c.1
	if [ ! -L os_desc/c.1 ]
	then
	 	ln -s configs/c.1 os_desc

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

* Re: Legacy configuration for NCM/RNDIS does not work for Win >= 10
  2023-03-10 12:27   ` Joakim Tjernlund
@ 2023-03-14 13:19     ` Joakim Tjernlund
  2023-03-16 10:56       ` gregkh
  0 siblings, 1 reply; 6+ messages in thread
From: Joakim Tjernlund @ 2023-03-14 13:19 UTC (permalink / raw)
  To: gregkh@linuxfoundation.org; +Cc: linux-usb@vger.kernel.org

On Fri, 2023-03-10 at 13:27 +0100, Joakim Tjernlund wrote:
> On Fri, 2023-03-10 at 10:55 +0100, gregkh@linuxfoundation.org wrote:
> > On Fri, Mar 10, 2023 at 09:44:26AM +0000, Joakim Tjernlund wrote:
> > > The old RNDIS/NCM configs does not work against modern Windows. I wonder if there
> > > should/could be updated to working state ?
> > 
> > Please never use RNDIS on modern systems unless you fully trust the
> > "other side" of the connection as it is not a secure protocol by any
> > means.
> 
> Yes, we will move to NCM (new in >= Windows 10)
> 
> > 
> > NCM should "just work" instead.  What exactly is failing, and what
> > specifically do you mean by "modern Windows"?
> 
> NCM does not just work on Windows >= 10 it needs configfs settings:
> 
> NCM snipped:
> 	echo 1       > os_desc/use
> 	echo 0xbc    > os_desc/b_vendor_code
> 	echo MSFT100 > os_desc/qw_sign
> 
> 	mkdir functions/ncm.usb0
> 	mkdir -p functions/ncm.usb0/os_desc/interface.ncm
>     #Set compatible id so that Windows 10 can match this function to
>     # NCM driver more easily.
> 	echo WINNCM   > functions/ncm.usb0/os_desc/interface.ncm/compatible_id
> 
> 	mkdir -p configs/c.1
> 	mkdir -p configs/c.1/strings/0x409
> 	echo "conf1" > configs/c.1/strings/0x409/configuration
> 	ln -s functions/ncm.usb0 configs/c.1
> 	if [ ! -L os_desc/c.1 ]
> 	then
> 		 ln -s configs/c.1 os_desc
> 	fi
> 
> New RNDIS in Windows >= 10
> 	echo 1       > os_desc/use
> 	echo 0xbc    > os_desc/b_vendor_code
> 	echo MSFT100 > os_desc/qw_sign
> 
> 	mkdir functions/rndis.usb0
> 	mkdir -p functions/rndis.usb0/os_desc/interface.rndis
> 
> 	#Set compatible / sub-compatible id's so that Windows can match this
>     # function to RNDIS6 driver more easily.
> 	echo RNDIS   > functions/rndis.usb0/os_desc/interface.rndis/compatible_id
> 	echo 5162001 > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
> 
> 	mkdir -p configs/c.1
> 	mkdir -p configs/c.1/strings/0x409
> 	echo "conf1" > configs/c.1/strings/0x409/configuration
> 	ln -s functions/rndis.usb0 configs/c.1
> 	if [ ! -L os_desc/c.1 ]
> 	then
> 	 	ln -s configs/c.1 os_desc


Did this make any sense to you ? The old legacy/builtin configs does not do any of this.

 Jocke

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

* Re: Legacy configuration for NCM/RNDIS does not work for Win >= 10
  2023-03-14 13:19     ` Joakim Tjernlund
@ 2023-03-16 10:56       ` gregkh
  2023-03-16 11:19         ` Joakim Tjernlund
  0 siblings, 1 reply; 6+ messages in thread
From: gregkh @ 2023-03-16 10:56 UTC (permalink / raw)
  To: Joakim Tjernlund; +Cc: linux-usb@vger.kernel.org

On Tue, Mar 14, 2023 at 01:19:25PM +0000, Joakim Tjernlund wrote:
> On Fri, 2023-03-10 at 13:27 +0100, Joakim Tjernlund wrote:
> > On Fri, 2023-03-10 at 10:55 +0100, gregkh@linuxfoundation.org wrote:
> > > On Fri, Mar 10, 2023 at 09:44:26AM +0000, Joakim Tjernlund wrote:
> > > > The old RNDIS/NCM configs does not work against modern Windows. I wonder if there
> > > > should/could be updated to working state ?
> > > 
> > > Please never use RNDIS on modern systems unless you fully trust the
> > > "other side" of the connection as it is not a secure protocol by any
> > > means.
> > 
> > Yes, we will move to NCM (new in >= Windows 10)
> > 
> > > 
> > > NCM should "just work" instead.  What exactly is failing, and what
> > > specifically do you mean by "modern Windows"?
> > 
> > NCM does not just work on Windows >= 10 it needs configfs settings:
> > 
> > NCM snipped:
> > 	echo 1       > os_desc/use
> > 	echo 0xbc    > os_desc/b_vendor_code
> > 	echo MSFT100 > os_desc/qw_sign
> > 
> > 	mkdir functions/ncm.usb0
> > 	mkdir -p functions/ncm.usb0/os_desc/interface.ncm
> >     #Set compatible id so that Windows 10 can match this function to
> >     # NCM driver more easily.
> > 	echo WINNCM   > functions/ncm.usb0/os_desc/interface.ncm/compatible_id
> > 
> > 	mkdir -p configs/c.1
> > 	mkdir -p configs/c.1/strings/0x409
> > 	echo "conf1" > configs/c.1/strings/0x409/configuration
> > 	ln -s functions/ncm.usb0 configs/c.1
> > 	if [ ! -L os_desc/c.1 ]
> > 	then
> > 		 ln -s configs/c.1 os_desc
> > 	fi
> > 
> > New RNDIS in Windows >= 10
> > 	echo 1       > os_desc/use
> > 	echo 0xbc    > os_desc/b_vendor_code
> > 	echo MSFT100 > os_desc/qw_sign
> > 
> > 	mkdir functions/rndis.usb0
> > 	mkdir -p functions/rndis.usb0/os_desc/interface.rndis
> > 
> > 	#Set compatible / sub-compatible id's so that Windows can match this
> >     # function to RNDIS6 driver more easily.
> > 	echo RNDIS   > functions/rndis.usb0/os_desc/interface.rndis/compatible_id
> > 	echo 5162001 > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
> > 
> > 	mkdir -p configs/c.1
> > 	mkdir -p configs/c.1/strings/0x409
> > 	echo "conf1" > configs/c.1/strings/0x409/configuration
> > 	ln -s functions/rndis.usb0 configs/c.1
> > 	if [ ! -L os_desc/c.1 ]
> > 	then
> > 	 	ln -s configs/c.1 os_desc
> 
> 
> Did this make any sense to you ? The old legacy/builtin configs does not do any of this.

Sorry, I do not have any Windows machines to test with so I really do
not know.  If you think the defaults are currently wrong, please submit
a patch to fix them up.

thanks,

greg k-h

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

* Re: Legacy configuration for NCM/RNDIS does not work for Win >= 10
  2023-03-16 10:56       ` gregkh
@ 2023-03-16 11:19         ` Joakim Tjernlund
  0 siblings, 0 replies; 6+ messages in thread
From: Joakim Tjernlund @ 2023-03-16 11:19 UTC (permalink / raw)
  To: gregkh@linuxfoundation.org; +Cc: linux-usb@vger.kernel.org

On Thu, 2023-03-16 at 11:56 +0100, gregkh@linuxfoundation.org wrote:
> On Tue, Mar 14, 2023 at 01:19:25PM +0000, Joakim Tjernlund wrote:
> > On Fri, 2023-03-10 at 13:27 +0100, Joakim Tjernlund wrote:
> > > On Fri, 2023-03-10 at 10:55 +0100, gregkh@linuxfoundation.org wrote:
> > > > On Fri, Mar 10, 2023 at 09:44:26AM +0000, Joakim Tjernlund wrote:
> > > > > The old RNDIS/NCM configs does not work against modern Windows. I wonder if there
> > > > > should/could be updated to working state ?
> > > > 
> > > > Please never use RNDIS on modern systems unless you fully trust the
> > > > "other side" of the connection as it is not a secure protocol by any
> > > > means.
> > > 
> > > Yes, we will move to NCM (new in >= Windows 10)
> > > 
> > > > 
> > > > NCM should "just work" instead.  What exactly is failing, and what
> > > > specifically do you mean by "modern Windows"?
> > > 
> > > NCM does not just work on Windows >= 10 it needs configfs settings:
> > > 
> > > NCM snipped:
> > > 	echo 1       > os_desc/use
> > > 	echo 0xbc    > os_desc/b_vendor_code
> > > 	echo MSFT100 > os_desc/qw_sign
> > > 
> > > 	mkdir functions/ncm.usb0
> > > 	mkdir -p functions/ncm.usb0/os_desc/interface.ncm
> > >     #Set compatible id so that Windows 10 can match this function to
> > >     # NCM driver more easily.
> > > 	echo WINNCM   > functions/ncm.usb0/os_desc/interface.ncm/compatible_id
> > > 
> > > 	mkdir -p configs/c.1
> > > 	mkdir -p configs/c.1/strings/0x409
> > > 	echo "conf1" > configs/c.1/strings/0x409/configuration
> > > 	ln -s functions/ncm.usb0 configs/c.1
> > > 	if [ ! -L os_desc/c.1 ]
> > > 	then
> > > 		 ln -s configs/c.1 os_desc
> > > 	fi
> > > 
> > > New RNDIS in Windows >= 10
> > > 	echo 1       > os_desc/use
> > > 	echo 0xbc    > os_desc/b_vendor_code
> > > 	echo MSFT100 > os_desc/qw_sign
> > > 
> > > 	mkdir functions/rndis.usb0
> > > 	mkdir -p functions/rndis.usb0/os_desc/interface.rndis
> > > 
> > > 	#Set compatible / sub-compatible id's so that Windows can match this
> > >     # function to RNDIS6 driver more easily.
> > > 	echo RNDIS   > functions/rndis.usb0/os_desc/interface.rndis/compatible_id
> > > 	echo 5162001 > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
> > > 
> > > 	mkdir -p configs/c.1
> > > 	mkdir -p configs/c.1/strings/0x409
> > > 	echo "conf1" > configs/c.1/strings/0x409/configuration
> > > 	ln -s functions/rndis.usb0 configs/c.1
> > > 	if [ ! -L os_desc/c.1 ]
> > > 	then
> > > 	 	ln -s configs/c.1 os_desc
> > 
> > 
> > Did this make any sense to you ? The old legacy/builtin configs does not do any of this.
> 
> Sorry, I do not have any Windows machines to test with so I really do
> not know.  If you think the defaults are currently wrong, please submit
> a patch to fix them up.

They are wrong for Win >= 10, that much is sure.

In the 1:st mail in this series I showed what I had done to change the
defaults by mimicking the setup from configs(that works) into code in legacy area
but I cannot make it work. This needs someone who knows how configfs works
and can codify it into legacy C code(not me obviously)

 Jocke

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

end of thread, other threads:[~2023-03-16 11:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-10  9:44 Legacy configuration for NCM/RNDIS does not work for Win >= 10 Joakim Tjernlund
2023-03-10  9:55 ` gregkh
2023-03-10 12:27   ` Joakim Tjernlund
2023-03-14 13:19     ` Joakim Tjernlund
2023-03-16 10:56       ` gregkh
2023-03-16 11:19         ` Joakim Tjernlund

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.