From: "Konrad Gräfe" <k.graefe@gateware.de>
To: Quentin Schulz <quentin.schulz@theobroma-systems.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Petr Mladek <pmladek@suse.com>,
Steven Rostedt <rostedt@goodmis.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Kyungmin Park <kyungmin.park@samsung.com>,
Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Cc: "Konrad Gräfe" <k.graefe@gateware.de>, stable@vger.kernel.org
Subject: [PATCH v5] usb: gadget: u_ether: Fix host MAC address case
Date: Fri, 5 May 2023 16:36:40 +0200 [thread overview]
Message-ID: <20230505143640.443014-1-k.graefe@gateware.de> (raw)
In-Reply-To: <20230427115120.241954-2-k.graefe@gateware.de>
The CDC-ECM specification [1] requires to send the host MAC address as
an uppercase hexadecimal string in chapter "5.4 Ethernet Networking
Functional Descriptor":
The Unicode character is chosen from the set of values 30h through
39h and 41h through 46h (0-9 and A-F).
However, snprintf(.., "%pm", ..) generates a lowercase MAC address
string. While most host drivers are tolerant to this, UsbNcm.sys on
Windows 10 is not. Instead it uses a different MAC address with all
bytes set to zero including and after the first byte containing a
lowercase letter. On Windows 11 Microsoft fixed it, but apparently they
did not backport the fix.
This change fixes the issue by upper-casing the MAC to comply with the
specification.
[1]: https://www.usb.org/document-library/class-definitions-communication-devices-12, file ECM120.pdf
Fixes: bcd4a1c40bee ("usb: gadget: u_ether: construct with default values and add setters/getters")
Cc: stable@vger.kernel.org
Signed-off-by: Konrad Gräfe <k.graefe@gateware.de>
---
Changes since v4:
* Use string_upper() instead of a special format string
Changes since v3: None
Changes since v2:
* Add uppercase MAC address format string and use that instead of
manually uppercasing the resulting MAC address string.
Changes since v1:
* Fixed checkpatch.pl warnings
drivers/usb/gadget/function/u_ether.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index 6956ad8ba8dd..a366abb45623 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -17,6 +17,7 @@
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/if_vlan.h>
+#include <linux/string_helpers.h>
#include <linux/usb/composite.h>
#include "u_ether.h"
@@ -965,6 +966,8 @@ int gether_get_host_addr_cdc(struct net_device *net, char *host_addr, int len)
dev = netdev_priv(net);
snprintf(host_addr, len, "%pm", dev->host_mac);
+ string_upper(host_addr, host_addr);
+
return strlen(host_addr);
}
EXPORT_SYMBOL_GPL(gether_get_host_addr_cdc);
--
2.34.1
next prev parent reply other threads:[~2023-05-05 14:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2023042625-rendition-distort-fe06@gregkh>
2023-04-27 11:51 ` [PATCH v3 1/2] vsprintf: Add %p[mM]U for uppercase MAC address Konrad Gräfe
2023-04-27 11:51 ` [PATCH v3 2/2] usb: gadget: u_ether: Fix host MAC address case Konrad Gräfe
2023-04-28 6:49 ` [PATCH v4 1/2] vsprintf: Add %p[mM]U for uppercase MAC address Konrad Gräfe
2023-04-28 6:49 ` [PATCH v4 2/2] usb: gadget: u_ether: Fix host MAC address case Konrad Gräfe
2023-05-02 20:03 ` [PATCH v4 1/2] vsprintf: Add %p[mM]U for uppercase MAC address Andy Shevchenko
2023-05-05 14:36 ` Konrad Gräfe [this message]
2023-04-27 12:26 ` [PATCH v3 " Greg Kroah-Hartman
2023-04-27 12:35 ` Rasmus Villemoes
2023-04-27 14:26 ` Konrad Gräfe
2023-04-27 21:30 ` Peter Seiderer
2023-04-28 6:56 ` Rasmus Villemoes
2023-04-28 7:19 ` Greg Kroah-Hartman
2023-04-28 7:46 ` David Laight
2023-05-02 20:01 ` Andy Shevchenko
2023-05-02 12:23 ` Petr Mladek
2023-05-04 13:25 ` Konrad Gräfe
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=20230505143640.443014-1-k.graefe@gateware.de \
--to=k.graefe@gateware.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andrzej.p@collabora.com \
--cc=gregkh@linuxfoundation.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=pmladek@suse.com \
--cc=quentin.schulz@theobroma-systems.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.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