+++ /dev/null
-From 7cb0bcacfbbda3487ecaa7bdd6b625f08ee63528 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 1 Dec 2023 10:29:52 -0800
-Subject: r8152: Choose our USB config with choose_configuration() rather than
- probe()
-
-From: Douglas Anderson <dianders@chromium.org>
-
-[ Upstream commit aa4f2b3e418e8673e55145de8b8016a7a9920306 ]
-
-If you deauthorize the r8152 device (by writing 0 to the "authorized"
-field in sysfs) and then reauthorize it (by writing a 1) then it no
-longer works. This is because when you do the above we lose the
-special configuration that we set in rtl8152_cfgselector_probe().
-Deauthorizing causes the config to be set to -1 and then reauthorizing
-runs the default logic for choosing the best config.
-
-I made an attempt to fix it so that the config is kept across
-deauthorizing / reauthorizing [1] but it was a bit ugly.
-
-Let's instead use the new USB core feature to override
-choose_configuration().
-
-This patch relies upon the patches ("usb: core: Don't force USB
-generic_subclass drivers to define probe()") and ("usb: core: Allow
-subclassed USB drivers to override usb_choose_configuration()")
-
-[1] https://lore.kernel.org/r/20231130154337.1.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid
-
-Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
-Suggested-by: Alan Stern <stern@rowland.harvard.edu>
-Signed-off-by: Douglas Anderson <dianders@chromium.org>
-Reviewed-by: Grant Grundler <grundler@chromium.org>
-Link: https://lore.kernel.org/r/20231201102946.v2.3.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/net/usb/r8152.c | 16 +++++-----------
- 1 file changed, 5 insertions(+), 11 deletions(-)
-
-diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
-index e8fd743a1509..85b98fd06ba2 100644
---- a/drivers/net/usb/r8152.c
-+++ b/drivers/net/usb/r8152.c
-@@ -9872,7 +9872,7 @@ static struct usb_driver rtl8152_driver = {
- .disable_hub_initiated_lpm = 1,
- };
-
--static int rtl8152_cfgselector_probe(struct usb_device *udev)
-+static int rtl8152_cfgselector_choose_configuration(struct usb_device *udev)
- {
- struct usb_host_config *c;
- int i, num_configs;
-@@ -9899,19 +9899,13 @@ static int rtl8152_cfgselector_probe(struct usb_device *udev)
- if (i == num_configs)
- return -ENODEV;
-
-- if (usb_set_configuration(udev, c->desc.bConfigurationValue)) {
-- dev_err(&udev->dev, "Failed to set configuration %d\n",
-- c->desc.bConfigurationValue);
-- return -ENODEV;
-- }
--
-- return 0;
-+ return c->desc.bConfigurationValue;
- }
-
- static struct usb_device_driver rtl8152_cfgselector_driver = {
-- .name = MODULENAME "-cfgselector",
-- .probe = rtl8152_cfgselector_probe,
-- .id_table = rtl8152_table,
-+ .name = MODULENAME "-cfgselector",
-+ .choose_configuration = rtl8152_cfgselector_choose_configuration,
-+ .id_table = rtl8152_table,
- .generic_subclass = 1,
- .supports_autosuspend = 1,
- };
---
-2.43.0
-
power-supply-bq256xx-fix-some-problem-in-bq256xx_hw_.patch
serial-8250-omap-don-t-skip-resource-freeing-if-pm_r.patch
libapi-add-missing-linux-types.h-header-to-get-the-_.patch
-usb-core-allow-subclassed-usb-drivers-to-override-us.patch
-r8152-choose-our-usb-config-with-choose_configuratio.patch
software-node-let-args-be-null-in-software_node_get_.patch
serial-imx-fix-tx-statemachine-deadlock.patch
selftests-sgx-fix-uninitialized-pointer-dereference-.patch
tty-don-t-check-for-signal_pending-in-send_break.patch
tty-use-if-in-send_break-instead-of-goto.patch
usb-cdc-acm-return-correct-error-code-on-unsupported.patch
-usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch
nvmet-tcp-fix-a-kernel-panic-when-host-sends-an-inva.patch
nvmet-tcp-fix-a-crash-in-nvmet_req_complete.patch
perf-env-avoid-recursively-taking-env-bpf_progs.lock.patch
+++ /dev/null
-From 692bc9dc9b8cd469bb61a68003639f223d6bc15c Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 1 Dec 2023 10:29:51 -0800
-Subject: usb: core: Allow subclassed USB drivers to override
- usb_choose_configuration()
-
-From: Douglas Anderson <dianders@chromium.org>
-
-[ Upstream commit a87b8e3be926af0fc3b9b1af42b1127bd1ff077c ]
-
-For some USB devices we might want to do something different for
-usb_choose_configuration(). One example here is the r8152 driver where
-we want to end up using the vendor driver with the preferred
-interface.
-
-The r8152 driver tried to make things work by implementing a USB
-generic_subclass driver and then overriding the normal config
-selection after it happened. This is less than ideal and also caused
-breakage if someone deauthorized and re-authorized the USB device
-because the USB core ended up going back to it's default logic for
-choosing the best config. I made an attempt to fix this [1] but it was
-a bit ugly.
-
-Let's do this better and allow USB generic_subclass drivers to
-override usb_choose_configuration().
-
-[1] https://lore.kernel.org/r/20231130154337.1.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid
-
-Suggested-by: Alan Stern <stern@rowland.harvard.edu>
-Signed-off-by: Douglas Anderson <dianders@chromium.org>
-Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
-Link: https://lore.kernel.org/r/20231201102946.v2.2.Iade5fa31997f1a0ca3e1dec0591633b02471df12@changeid
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Stable-dep-of: aa4f2b3e418e ("r8152: Choose our USB config with choose_configuration() rather than probe()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/usb/core/generic.c | 7 +++++++
- include/linux/usb.h | 6 ++++++
- 2 files changed, 13 insertions(+)
-
-diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
-index 26f9fb9f67ca..57f6cab36ef6 100644
---- a/drivers/usb/core/generic.c
-+++ b/drivers/usb/core/generic.c
-@@ -59,10 +59,17 @@ int usb_choose_configuration(struct usb_device *udev)
- int num_configs;
- int insufficient_power = 0;
- struct usb_host_config *c, *best;
-+ struct usb_device_driver *udriver = to_usb_device_driver(udev->dev.driver);
-
- if (usb_device_is_owned(udev))
- return 0;
-
-+ if (udriver->choose_configuration) {
-+ i = udriver->choose_configuration(udev);
-+ if (i >= 0)
-+ return i;
-+ }
-+
- best = NULL;
- c = udev->config;
- num_configs = udev->descriptor.bNumConfigurations;
-diff --git a/include/linux/usb.h b/include/linux/usb.h
-index 987550fd46fa..d879fc573f43 100644
---- a/include/linux/usb.h
-+++ b/include/linux/usb.h
-@@ -1241,6 +1241,9 @@ struct usb_driver {
- * module is being unloaded.
- * @suspend: Called when the device is going to be suspended by the system.
- * @resume: Called when the device is being resumed by the system.
-+ * @choose_configuration: If non-NULL, called instead of the default
-+ * usb_choose_configuration(). If this returns an error then we'll go
-+ * on to call the normal usb_choose_configuration().
- * @dev_groups: Attributes attached to the device that will be created once it
- * is bound to the driver.
- * @drvwrap: Driver-model core structure wrapper.
-@@ -1264,6 +1267,9 @@ struct usb_device_driver {
-
- int (*suspend) (struct usb_device *udev, pm_message_t message);
- int (*resume) (struct usb_device *udev, pm_message_t message);
-+
-+ int (*choose_configuration) (struct usb_device *udev);
-+
- const struct attribute_group **dev_groups;
- struct usbdrv_wrap drvwrap;
- const struct usb_device_id *id_table;
---
-2.43.0
-
+++ /dev/null
-From 75ea98ad215b45d2ceb7a803dc6b6463c19b9564 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 11 Dec 2023 07:32:41 -0800
-Subject: usb: core: Fix crash w/ usb_choose_configuration() if no driver
-
-From: Douglas Anderson <dianders@chromium.org>
-
-[ Upstream commit 44995e6f07028f798efd0c3c11a1efc78330f600 ]
-
-It's possible that usb_choose_configuration() can get called when a
-USB device has no driver. In this case the recent commit a87b8e3be926
-("usb: core: Allow subclassed USB drivers to override
-usb_choose_configuration()") can cause a crash since it dereferenced
-the driver structure without checking for NULL. Let's add a check.
-
-A USB device with no driver is an anomaly, so make
-usb_choose_configuration() return immediately if there is no driver.
-
-This was seen in the real world when usbguard got ahold of a r8152
-device at the wrong time. It can also be simulated via this on a
-computer with one r8152-based USB Ethernet adapter:
- cd /sys/bus/usb/drivers/r8152-cfgselector
- to_unbind="$(ls -d *-*)"
- real_dir="$(readlink -f "${to_unbind}")"
- echo "${to_unbind}" > unbind
- cd "${real_dir}"
- echo 0 > authorized
- echo 1 > authorized
-
-Fixes: a87b8e3be926 ("usb: core: Allow subclassed USB drivers to override usb_choose_configuration()")
-Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
-Signed-off-by: Douglas Anderson <dianders@chromium.org>
-Link: https://lore.kernel.org/r/20231211073237.v3.1.If27eb3bf7812f91ab83810f232292f032f4203e0@changeid
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/usb/core/generic.c | 11 ++++++++++-
- 1 file changed, 10 insertions(+), 1 deletion(-)
-
-diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
-index 57f6cab36ef6..77aefe0f4fc5 100644
---- a/drivers/usb/core/generic.c
-+++ b/drivers/usb/core/generic.c
-@@ -59,7 +59,16 @@ int usb_choose_configuration(struct usb_device *udev)
- int num_configs;
- int insufficient_power = 0;
- struct usb_host_config *c, *best;
-- struct usb_device_driver *udriver = to_usb_device_driver(udev->dev.driver);
-+ struct usb_device_driver *udriver;
-+
-+ /*
-+ * If a USB device (not an interface) doesn't have a driver then the
-+ * kernel has no business trying to select or install a configuration
-+ * for it.
-+ */
-+ if (!udev->dev.driver)
-+ return -1;
-+ udriver = to_usb_device_driver(udev->dev.driver);
-
- if (usb_device_is_owned(udev))
- return 0;
---
-2.43.0
-
+++ /dev/null
-From 2bdc1c1d7ca3e1c1222705acfcaa506cee203efb Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 1 Dec 2023 10:29:52 -0800
-Subject: r8152: Choose our USB config with choose_configuration() rather than
- probe()
-
-From: Douglas Anderson <dianders@chromium.org>
-
-[ Upstream commit aa4f2b3e418e8673e55145de8b8016a7a9920306 ]
-
-If you deauthorize the r8152 device (by writing 0 to the "authorized"
-field in sysfs) and then reauthorize it (by writing a 1) then it no
-longer works. This is because when you do the above we lose the
-special configuration that we set in rtl8152_cfgselector_probe().
-Deauthorizing causes the config to be set to -1 and then reauthorizing
-runs the default logic for choosing the best config.
-
-I made an attempt to fix it so that the config is kept across
-deauthorizing / reauthorizing [1] but it was a bit ugly.
-
-Let's instead use the new USB core feature to override
-choose_configuration().
-
-This patch relies upon the patches ("usb: core: Don't force USB
-generic_subclass drivers to define probe()") and ("usb: core: Allow
-subclassed USB drivers to override usb_choose_configuration()")
-
-[1] https://lore.kernel.org/r/20231130154337.1.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid
-
-Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
-Suggested-by: Alan Stern <stern@rowland.harvard.edu>
-Signed-off-by: Douglas Anderson <dianders@chromium.org>
-Reviewed-by: Grant Grundler <grundler@chromium.org>
-Link: https://lore.kernel.org/r/20231201102946.v2.3.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/net/usb/r8152.c | 16 +++++-----------
- 1 file changed, 5 insertions(+), 11 deletions(-)
-
-diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
-index 958a02b19554..0893e51f807b 100644
---- a/drivers/net/usb/r8152.c
-+++ b/drivers/net/usb/r8152.c
-@@ -9899,7 +9899,7 @@ static struct usb_driver rtl8152_driver = {
- .disable_hub_initiated_lpm = 1,
- };
-
--static int rtl8152_cfgselector_probe(struct usb_device *udev)
-+static int rtl8152_cfgselector_choose_configuration(struct usb_device *udev)
- {
- struct usb_host_config *c;
- int i, num_configs;
-@@ -9926,19 +9926,13 @@ static int rtl8152_cfgselector_probe(struct usb_device *udev)
- if (i == num_configs)
- return -ENODEV;
-
-- if (usb_set_configuration(udev, c->desc.bConfigurationValue)) {
-- dev_err(&udev->dev, "Failed to set configuration %d\n",
-- c->desc.bConfigurationValue);
-- return -ENODEV;
-- }
--
-- return 0;
-+ return c->desc.bConfigurationValue;
- }
-
- static struct usb_device_driver rtl8152_cfgselector_driver = {
-- .name = MODULENAME "-cfgselector",
-- .probe = rtl8152_cfgselector_probe,
-- .id_table = rtl8152_table,
-+ .name = MODULENAME "-cfgselector",
-+ .choose_configuration = rtl8152_cfgselector_choose_configuration,
-+ .id_table = rtl8152_table,
- .generic_subclass = 1,
- .supports_autosuspend = 1,
- };
---
-2.43.0
-
power-supply-bq256xx-fix-some-problem-in-bq256xx_hw_.patch
serial-8250-omap-don-t-skip-resource-freeing-if-pm_r.patch
libapi-add-missing-linux-types.h-header-to-get-the-_.patch
-usb-core-allow-subclassed-usb-drivers-to-override-us.patch
-r8152-choose-our-usb-config-with-choose_configuratio.patch
base-node.c-initialize-the-accessor-list-before-regi.patch
acpi-property-let-args-be-null-in-__acpi_node_get_pr.patch
software-node-let-args-be-null-in-software_node_get_.patch
tty-don-t-check-for-signal_pending-in-send_break.patch
tty-use-if-in-send_break-instead-of-goto.patch
usb-cdc-acm-return-correct-error-code-on-unsupported.patch
-usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch
spmi-mtk-pmif-serialize-pmif-status-check-and-comman.patch
vdpa-fix-an-error-handling-path-in-eni_vdpa_probe.patch
nvmet-tcp-fix-a-kernel-panic-when-host-sends-an-inva.patch
+++ /dev/null
-From 89f477bd047273d8654f338159d387f37267ae9e Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 1 Dec 2023 10:29:51 -0800
-Subject: usb: core: Allow subclassed USB drivers to override
- usb_choose_configuration()
-
-From: Douglas Anderson <dianders@chromium.org>
-
-[ Upstream commit a87b8e3be926af0fc3b9b1af42b1127bd1ff077c ]
-
-For some USB devices we might want to do something different for
-usb_choose_configuration(). One example here is the r8152 driver where
-we want to end up using the vendor driver with the preferred
-interface.
-
-The r8152 driver tried to make things work by implementing a USB
-generic_subclass driver and then overriding the normal config
-selection after it happened. This is less than ideal and also caused
-breakage if someone deauthorized and re-authorized the USB device
-because the USB core ended up going back to it's default logic for
-choosing the best config. I made an attempt to fix this [1] but it was
-a bit ugly.
-
-Let's do this better and allow USB generic_subclass drivers to
-override usb_choose_configuration().
-
-[1] https://lore.kernel.org/r/20231130154337.1.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid
-
-Suggested-by: Alan Stern <stern@rowland.harvard.edu>
-Signed-off-by: Douglas Anderson <dianders@chromium.org>
-Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
-Link: https://lore.kernel.org/r/20231201102946.v2.2.Iade5fa31997f1a0ca3e1dec0591633b02471df12@changeid
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Stable-dep-of: aa4f2b3e418e ("r8152: Choose our USB config with choose_configuration() rather than probe()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/usb/core/generic.c | 7 +++++++
- include/linux/usb.h | 6 ++++++
- 2 files changed, 13 insertions(+)
-
-diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
-index 740342a2812a..dcb897158228 100644
---- a/drivers/usb/core/generic.c
-+++ b/drivers/usb/core/generic.c
-@@ -59,10 +59,17 @@ int usb_choose_configuration(struct usb_device *udev)
- int num_configs;
- int insufficient_power = 0;
- struct usb_host_config *c, *best;
-+ struct usb_device_driver *udriver = to_usb_device_driver(udev->dev.driver);
-
- if (usb_device_is_owned(udev))
- return 0;
-
-+ if (udriver->choose_configuration) {
-+ i = udriver->choose_configuration(udev);
-+ if (i >= 0)
-+ return i;
-+ }
-+
- best = NULL;
- c = udev->config;
- num_configs = udev->descriptor.bNumConfigurations;
-diff --git a/include/linux/usb.h b/include/linux/usb.h
-index 3ce7b052a19f..08b1d6fbcd3c 100644
---- a/include/linux/usb.h
-+++ b/include/linux/usb.h
-@@ -1234,6 +1234,9 @@ struct usb_driver {
- * module is being unloaded.
- * @suspend: Called when the device is going to be suspended by the system.
- * @resume: Called when the device is being resumed by the system.
-+ * @choose_configuration: If non-NULL, called instead of the default
-+ * usb_choose_configuration(). If this returns an error then we'll go
-+ * on to call the normal usb_choose_configuration().
- * @dev_groups: Attributes attached to the device that will be created once it
- * is bound to the driver.
- * @drvwrap: Driver-model core structure wrapper.
-@@ -1257,6 +1260,9 @@ struct usb_device_driver {
-
- int (*suspend) (struct usb_device *udev, pm_message_t message);
- int (*resume) (struct usb_device *udev, pm_message_t message);
-+
-+ int (*choose_configuration) (struct usb_device *udev);
-+
- const struct attribute_group **dev_groups;
- struct usbdrv_wrap drvwrap;
- const struct usb_device_id *id_table;
---
-2.43.0
-
+++ /dev/null
-From 05694d9fc201f5042fecab532a59b317aadb5f53 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 11 Dec 2023 07:32:41 -0800
-Subject: usb: core: Fix crash w/ usb_choose_configuration() if no driver
-
-From: Douglas Anderson <dianders@chromium.org>
-
-[ Upstream commit 44995e6f07028f798efd0c3c11a1efc78330f600 ]
-
-It's possible that usb_choose_configuration() can get called when a
-USB device has no driver. In this case the recent commit a87b8e3be926
-("usb: core: Allow subclassed USB drivers to override
-usb_choose_configuration()") can cause a crash since it dereferenced
-the driver structure without checking for NULL. Let's add a check.
-
-A USB device with no driver is an anomaly, so make
-usb_choose_configuration() return immediately if there is no driver.
-
-This was seen in the real world when usbguard got ahold of a r8152
-device at the wrong time. It can also be simulated via this on a
-computer with one r8152-based USB Ethernet adapter:
- cd /sys/bus/usb/drivers/r8152-cfgselector
- to_unbind="$(ls -d *-*)"
- real_dir="$(readlink -f "${to_unbind}")"
- echo "${to_unbind}" > unbind
- cd "${real_dir}"
- echo 0 > authorized
- echo 1 > authorized
-
-Fixes: a87b8e3be926 ("usb: core: Allow subclassed USB drivers to override usb_choose_configuration()")
-Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
-Signed-off-by: Douglas Anderson <dianders@chromium.org>
-Link: https://lore.kernel.org/r/20231211073237.v3.1.If27eb3bf7812f91ab83810f232292f032f4203e0@changeid
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/usb/core/generic.c | 11 ++++++++++-
- 1 file changed, 10 insertions(+), 1 deletion(-)
-
-diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
-index dcb897158228..b134bff5c3fe 100644
---- a/drivers/usb/core/generic.c
-+++ b/drivers/usb/core/generic.c
-@@ -59,7 +59,16 @@ int usb_choose_configuration(struct usb_device *udev)
- int num_configs;
- int insufficient_power = 0;
- struct usb_host_config *c, *best;
-- struct usb_device_driver *udriver = to_usb_device_driver(udev->dev.driver);
-+ struct usb_device_driver *udriver;
-+
-+ /*
-+ * If a USB device (not an interface) doesn't have a driver then the
-+ * kernel has no business trying to select or install a configuration
-+ * for it.
-+ */
-+ if (!udev->dev.driver)
-+ return -1;
-+ udriver = to_usb_device_driver(udev->dev.driver);
-
- if (usb_device_is_owned(udev))
- return 0;
---
-2.43.0
-
+++ /dev/null
-From 0b0dd4e71eeae2e0e3ef2f70ef98708f586769c4 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 1 Dec 2023 10:29:52 -0800
-Subject: r8152: Choose our USB config with choose_configuration() rather than
- probe()
-
-From: Douglas Anderson <dianders@chromium.org>
-
-[ Upstream commit aa4f2b3e418e8673e55145de8b8016a7a9920306 ]
-
-If you deauthorize the r8152 device (by writing 0 to the "authorized"
-field in sysfs) and then reauthorize it (by writing a 1) then it no
-longer works. This is because when you do the above we lose the
-special configuration that we set in rtl8152_cfgselector_probe().
-Deauthorizing causes the config to be set to -1 and then reauthorizing
-runs the default logic for choosing the best config.
-
-I made an attempt to fix it so that the config is kept across
-deauthorizing / reauthorizing [1] but it was a bit ugly.
-
-Let's instead use the new USB core feature to override
-choose_configuration().
-
-This patch relies upon the patches ("usb: core: Don't force USB
-generic_subclass drivers to define probe()") and ("usb: core: Allow
-subclassed USB drivers to override usb_choose_configuration()")
-
-[1] https://lore.kernel.org/r/20231130154337.1.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid
-
-Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
-Suggested-by: Alan Stern <stern@rowland.harvard.edu>
-Signed-off-by: Douglas Anderson <dianders@chromium.org>
-Reviewed-by: Grant Grundler <grundler@chromium.org>
-Link: https://lore.kernel.org/r/20231201102946.v2.3.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/net/usb/r8152.c | 16 +++++-----------
- 1 file changed, 5 insertions(+), 11 deletions(-)
-
-diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
-index 127b34dcc5b3..cca5b81c8b18 100644
---- a/drivers/net/usb/r8152.c
-+++ b/drivers/net/usb/r8152.c
-@@ -10036,7 +10036,7 @@ static struct usb_driver rtl8152_driver = {
- .disable_hub_initiated_lpm = 1,
- };
-
--static int rtl8152_cfgselector_probe(struct usb_device *udev)
-+static int rtl8152_cfgselector_choose_configuration(struct usb_device *udev)
- {
- struct usb_host_config *c;
- int i, num_configs;
-@@ -10063,19 +10063,13 @@ static int rtl8152_cfgselector_probe(struct usb_device *udev)
- if (i == num_configs)
- return -ENODEV;
-
-- if (usb_set_configuration(udev, c->desc.bConfigurationValue)) {
-- dev_err(&udev->dev, "Failed to set configuration %d\n",
-- c->desc.bConfigurationValue);
-- return -ENODEV;
-- }
--
-- return 0;
-+ return c->desc.bConfigurationValue;
- }
-
- static struct usb_device_driver rtl8152_cfgselector_driver = {
-- .name = MODULENAME "-cfgselector",
-- .probe = rtl8152_cfgselector_probe,
-- .id_table = rtl8152_table,
-+ .name = MODULENAME "-cfgselector",
-+ .choose_configuration = rtl8152_cfgselector_choose_configuration,
-+ .id_table = rtl8152_table,
- .generic_subclass = 1,
- .supports_autosuspend = 1,
- };
---
-2.43.0
-
perf-test-remove-atomics-from-test_loop-to-avoid-tes.patch
perf-header-fix-segfault-on-build_mem_topology-error.patch
libapi-add-missing-linux-types.h-header-to-get-the-_.patch
-usb-core-allow-subclassed-usb-drivers-to-override-us.patch
-r8152-choose-our-usb-config-with-choose_configuratio.patch
perf-test-record-user-regs-fix-mask-for-vg-register.patch
vfio-pds-fix-calculations-in-pds_vfio_dirty_sync.patch
perf-vendor-events-arm64-ampereone-rename-bpu_flush_.patch
tty-don-t-check-for-signal_pending-in-send_break.patch
tty-use-if-in-send_break-instead-of-goto.patch
usb-cdc-acm-return-correct-error-code-on-unsupported.patch
-usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch
spmi-mtk-pmif-serialize-pmif-status-check-and-comman.patch
usb-gadget-webcam-make-g_webcam-loadable-again.patch
iommu-don-t-reserve-0-length-iova-region.patch
+++ /dev/null
-From e298d511909d50f1da9e63a5b5949f41a77dc2a3 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 1 Dec 2023 10:29:51 -0800
-Subject: usb: core: Allow subclassed USB drivers to override
- usb_choose_configuration()
-
-From: Douglas Anderson <dianders@chromium.org>
-
-[ Upstream commit a87b8e3be926af0fc3b9b1af42b1127bd1ff077c ]
-
-For some USB devices we might want to do something different for
-usb_choose_configuration(). One example here is the r8152 driver where
-we want to end up using the vendor driver with the preferred
-interface.
-
-The r8152 driver tried to make things work by implementing a USB
-generic_subclass driver and then overriding the normal config
-selection after it happened. This is less than ideal and also caused
-breakage if someone deauthorized and re-authorized the USB device
-because the USB core ended up going back to it's default logic for
-choosing the best config. I made an attempt to fix this [1] but it was
-a bit ugly.
-
-Let's do this better and allow USB generic_subclass drivers to
-override usb_choose_configuration().
-
-[1] https://lore.kernel.org/r/20231130154337.1.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid
-
-Suggested-by: Alan Stern <stern@rowland.harvard.edu>
-Signed-off-by: Douglas Anderson <dianders@chromium.org>
-Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
-Link: https://lore.kernel.org/r/20231201102946.v2.2.Iade5fa31997f1a0ca3e1dec0591633b02471df12@changeid
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Stable-dep-of: aa4f2b3e418e ("r8152: Choose our USB config with choose_configuration() rather than probe()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/usb/core/generic.c | 7 +++++++
- include/linux/usb.h | 6 ++++++
- 2 files changed, 13 insertions(+)
-
-diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
-index 740342a2812a..dcb897158228 100644
---- a/drivers/usb/core/generic.c
-+++ b/drivers/usb/core/generic.c
-@@ -59,10 +59,17 @@ int usb_choose_configuration(struct usb_device *udev)
- int num_configs;
- int insufficient_power = 0;
- struct usb_host_config *c, *best;
-+ struct usb_device_driver *udriver = to_usb_device_driver(udev->dev.driver);
-
- if (usb_device_is_owned(udev))
- return 0;
-
-+ if (udriver->choose_configuration) {
-+ i = udriver->choose_configuration(udev);
-+ if (i >= 0)
-+ return i;
-+ }
-+
- best = NULL;
- c = udev->config;
- num_configs = udev->descriptor.bNumConfigurations;
-diff --git a/include/linux/usb.h b/include/linux/usb.h
-index a21074861f91..bfd77ece0643 100644
---- a/include/linux/usb.h
-+++ b/include/linux/usb.h
-@@ -1264,6 +1264,9 @@ struct usb_driver {
- * module is being unloaded.
- * @suspend: Called when the device is going to be suspended by the system.
- * @resume: Called when the device is being resumed by the system.
-+ * @choose_configuration: If non-NULL, called instead of the default
-+ * usb_choose_configuration(). If this returns an error then we'll go
-+ * on to call the normal usb_choose_configuration().
- * @dev_groups: Attributes attached to the device that will be created once it
- * is bound to the driver.
- * @drvwrap: Driver-model core structure wrapper.
-@@ -1287,6 +1290,9 @@ struct usb_device_driver {
-
- int (*suspend) (struct usb_device *udev, pm_message_t message);
- int (*resume) (struct usb_device *udev, pm_message_t message);
-+
-+ int (*choose_configuration) (struct usb_device *udev);
-+
- const struct attribute_group **dev_groups;
- struct usbdrv_wrap drvwrap;
- const struct usb_device_id *id_table;
---
-2.43.0
-
+++ /dev/null
-From f40a7d1b7ffa8ee851a2a3bcd4237c10c564445d Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 11 Dec 2023 07:32:41 -0800
-Subject: usb: core: Fix crash w/ usb_choose_configuration() if no driver
-
-From: Douglas Anderson <dianders@chromium.org>
-
-[ Upstream commit 44995e6f07028f798efd0c3c11a1efc78330f600 ]
-
-It's possible that usb_choose_configuration() can get called when a
-USB device has no driver. In this case the recent commit a87b8e3be926
-("usb: core: Allow subclassed USB drivers to override
-usb_choose_configuration()") can cause a crash since it dereferenced
-the driver structure without checking for NULL. Let's add a check.
-
-A USB device with no driver is an anomaly, so make
-usb_choose_configuration() return immediately if there is no driver.
-
-This was seen in the real world when usbguard got ahold of a r8152
-device at the wrong time. It can also be simulated via this on a
-computer with one r8152-based USB Ethernet adapter:
- cd /sys/bus/usb/drivers/r8152-cfgselector
- to_unbind="$(ls -d *-*)"
- real_dir="$(readlink -f "${to_unbind}")"
- echo "${to_unbind}" > unbind
- cd "${real_dir}"
- echo 0 > authorized
- echo 1 > authorized
-
-Fixes: a87b8e3be926 ("usb: core: Allow subclassed USB drivers to override usb_choose_configuration()")
-Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
-Signed-off-by: Douglas Anderson <dianders@chromium.org>
-Link: https://lore.kernel.org/r/20231211073237.v3.1.If27eb3bf7812f91ab83810f232292f032f4203e0@changeid
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/usb/core/generic.c | 11 ++++++++++-
- 1 file changed, 10 insertions(+), 1 deletion(-)
-
-diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
-index dcb897158228..b134bff5c3fe 100644
---- a/drivers/usb/core/generic.c
-+++ b/drivers/usb/core/generic.c
-@@ -59,7 +59,16 @@ int usb_choose_configuration(struct usb_device *udev)
- int num_configs;
- int insufficient_power = 0;
- struct usb_host_config *c, *best;
-- struct usb_device_driver *udriver = to_usb_device_driver(udev->dev.driver);
-+ struct usb_device_driver *udriver;
-+
-+ /*
-+ * If a USB device (not an interface) doesn't have a driver then the
-+ * kernel has no business trying to select or install a configuration
-+ * for it.
-+ */
-+ if (!udev->dev.driver)
-+ return -1;
-+ udriver = to_usb_device_driver(udev->dev.driver);
-
- if (usb_device_is_owned(udev))
- return 0;
---
-2.43.0
-
+++ /dev/null
-From 789207c691d113fac0bd79371537148758310385 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 1 Dec 2023 10:29:52 -0800
-Subject: r8152: Choose our USB config with choose_configuration() rather than
- probe()
-
-From: Douglas Anderson <dianders@chromium.org>
-
-[ Upstream commit aa4f2b3e418e8673e55145de8b8016a7a9920306 ]
-
-If you deauthorize the r8152 device (by writing 0 to the "authorized"
-field in sysfs) and then reauthorize it (by writing a 1) then it no
-longer works. This is because when you do the above we lose the
-special configuration that we set in rtl8152_cfgselector_probe().
-Deauthorizing causes the config to be set to -1 and then reauthorizing
-runs the default logic for choosing the best config.
-
-I made an attempt to fix it so that the config is kept across
-deauthorizing / reauthorizing [1] but it was a bit ugly.
-
-Let's instead use the new USB core feature to override
-choose_configuration().
-
-This patch relies upon the patches ("usb: core: Don't force USB
-generic_subclass drivers to define probe()") and ("usb: core: Allow
-subclassed USB drivers to override usb_choose_configuration()")
-
-[1] https://lore.kernel.org/r/20231130154337.1.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid
-
-Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
-Suggested-by: Alan Stern <stern@rowland.harvard.edu>
-Signed-off-by: Douglas Anderson <dianders@chromium.org>
-Reviewed-by: Grant Grundler <grundler@chromium.org>
-Link: https://lore.kernel.org/r/20231201102946.v2.3.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/net/usb/r8152.c | 16 +++++-----------
- 1 file changed, 5 insertions(+), 11 deletions(-)
-
-diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
-index 9bf2140fd0a1..0d0672d2a654 100644
---- a/drivers/net/usb/r8152.c
-+++ b/drivers/net/usb/r8152.c
-@@ -10069,7 +10069,7 @@ static struct usb_driver rtl8152_driver = {
- .disable_hub_initiated_lpm = 1,
- };
-
--static int rtl8152_cfgselector_probe(struct usb_device *udev)
-+static int rtl8152_cfgselector_choose_configuration(struct usb_device *udev)
- {
- struct usb_host_config *c;
- int i, num_configs;
-@@ -10096,19 +10096,13 @@ static int rtl8152_cfgselector_probe(struct usb_device *udev)
- if (i == num_configs)
- return -ENODEV;
-
-- if (usb_set_configuration(udev, c->desc.bConfigurationValue)) {
-- dev_err(&udev->dev, "Failed to set configuration %d\n",
-- c->desc.bConfigurationValue);
-- return -ENODEV;
-- }
--
-- return 0;
-+ return c->desc.bConfigurationValue;
- }
-
- static struct usb_device_driver rtl8152_cfgselector_driver = {
-- .name = MODULENAME "-cfgselector",
-- .probe = rtl8152_cfgselector_probe,
-- .id_table = rtl8152_table,
-+ .name = MODULENAME "-cfgselector",
-+ .choose_configuration = rtl8152_cfgselector_choose_configuration,
-+ .id_table = rtl8152_table,
- .generic_subclass = 1,
- .supports_autosuspend = 1,
- };
---
-2.43.0
-
libapi-add-missing-linux-types.h-header-to-get-the-_.patch
staging-vc04_services-vchiq_core-log-through-struct-.patch
staging-vc04_services-do-not-pass-null-to-vchiq_log_.patch
-usb-core-allow-subclassed-usb-drivers-to-override-us.patch
-r8152-choose-our-usb-config-with-choose_configuratio.patch
perf-test-record-user-regs-fix-mask-for-vg-register.patch
vfio-pds-fix-calculations-in-pds_vfio_dirty_sync.patch
perf-vendor-events-arm64-ampereone-rename-bpu_flush_.patch
pci-epf-mhi-fix-the-dma-data-direction-of-dma_unmap_.patch
usb-cdc-acm-return-correct-error-code-on-unsupported.patch
arm64-dts-qcom-qrb5165-rb5-use-u16-for-dp-altmode-sv.patch
-usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch
cdx-explicitly-include-correct-dt-includes-again.patch
spmi-mtk-pmif-serialize-pmif-status-check-and-comman.patch
usb-gadget-webcam-make-g_webcam-loadable-again.patch
+++ /dev/null
-From df41b669ad09e572e61c730aa600fc24c9127a45 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 1 Dec 2023 10:29:51 -0800
-Subject: usb: core: Allow subclassed USB drivers to override
- usb_choose_configuration()
-
-From: Douglas Anderson <dianders@chromium.org>
-
-[ Upstream commit a87b8e3be926af0fc3b9b1af42b1127bd1ff077c ]
-
-For some USB devices we might want to do something different for
-usb_choose_configuration(). One example here is the r8152 driver where
-we want to end up using the vendor driver with the preferred
-interface.
-
-The r8152 driver tried to make things work by implementing a USB
-generic_subclass driver and then overriding the normal config
-selection after it happened. This is less than ideal and also caused
-breakage if someone deauthorized and re-authorized the USB device
-because the USB core ended up going back to it's default logic for
-choosing the best config. I made an attempt to fix this [1] but it was
-a bit ugly.
-
-Let's do this better and allow USB generic_subclass drivers to
-override usb_choose_configuration().
-
-[1] https://lore.kernel.org/r/20231130154337.1.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid
-
-Suggested-by: Alan Stern <stern@rowland.harvard.edu>
-Signed-off-by: Douglas Anderson <dianders@chromium.org>
-Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
-Link: https://lore.kernel.org/r/20231201102946.v2.2.Iade5fa31997f1a0ca3e1dec0591633b02471df12@changeid
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Stable-dep-of: aa4f2b3e418e ("r8152: Choose our USB config with choose_configuration() rather than probe()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/usb/core/generic.c | 7 +++++++
- include/linux/usb.h | 6 ++++++
- 2 files changed, 13 insertions(+)
-
-diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
-index 740342a2812a..dcb897158228 100644
---- a/drivers/usb/core/generic.c
-+++ b/drivers/usb/core/generic.c
-@@ -59,10 +59,17 @@ int usb_choose_configuration(struct usb_device *udev)
- int num_configs;
- int insufficient_power = 0;
- struct usb_host_config *c, *best;
-+ struct usb_device_driver *udriver = to_usb_device_driver(udev->dev.driver);
-
- if (usb_device_is_owned(udev))
- return 0;
-
-+ if (udriver->choose_configuration) {
-+ i = udriver->choose_configuration(udev);
-+ if (i >= 0)
-+ return i;
-+ }
-+
- best = NULL;
- c = udev->config;
- num_configs = udev->descriptor.bNumConfigurations;
-diff --git a/include/linux/usb.h b/include/linux/usb.h
-index 8c61643acd49..618e5a0b1a22 100644
---- a/include/linux/usb.h
-+++ b/include/linux/usb.h
-@@ -1264,6 +1264,9 @@ struct usb_driver {
- * module is being unloaded.
- * @suspend: Called when the device is going to be suspended by the system.
- * @resume: Called when the device is being resumed by the system.
-+ * @choose_configuration: If non-NULL, called instead of the default
-+ * usb_choose_configuration(). If this returns an error then we'll go
-+ * on to call the normal usb_choose_configuration().
- * @dev_groups: Attributes attached to the device that will be created once it
- * is bound to the driver.
- * @drvwrap: Driver-model core structure wrapper.
-@@ -1287,6 +1290,9 @@ struct usb_device_driver {
-
- int (*suspend) (struct usb_device *udev, pm_message_t message);
- int (*resume) (struct usb_device *udev, pm_message_t message);
-+
-+ int (*choose_configuration) (struct usb_device *udev);
-+
- const struct attribute_group **dev_groups;
- struct usbdrv_wrap drvwrap;
- const struct usb_device_id *id_table;
---
-2.43.0
-
+++ /dev/null
-From 995b37662d62f8340cc8d22fc287e5ee83103a0c Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 11 Dec 2023 07:32:41 -0800
-Subject: usb: core: Fix crash w/ usb_choose_configuration() if no driver
-
-From: Douglas Anderson <dianders@chromium.org>
-
-[ Upstream commit 44995e6f07028f798efd0c3c11a1efc78330f600 ]
-
-It's possible that usb_choose_configuration() can get called when a
-USB device has no driver. In this case the recent commit a87b8e3be926
-("usb: core: Allow subclassed USB drivers to override
-usb_choose_configuration()") can cause a crash since it dereferenced
-the driver structure without checking for NULL. Let's add a check.
-
-A USB device with no driver is an anomaly, so make
-usb_choose_configuration() return immediately if there is no driver.
-
-This was seen in the real world when usbguard got ahold of a r8152
-device at the wrong time. It can also be simulated via this on a
-computer with one r8152-based USB Ethernet adapter:
- cd /sys/bus/usb/drivers/r8152-cfgselector
- to_unbind="$(ls -d *-*)"
- real_dir="$(readlink -f "${to_unbind}")"
- echo "${to_unbind}" > unbind
- cd "${real_dir}"
- echo 0 > authorized
- echo 1 > authorized
-
-Fixes: a87b8e3be926 ("usb: core: Allow subclassed USB drivers to override usb_choose_configuration()")
-Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
-Signed-off-by: Douglas Anderson <dianders@chromium.org>
-Link: https://lore.kernel.org/r/20231211073237.v3.1.If27eb3bf7812f91ab83810f232292f032f4203e0@changeid
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/usb/core/generic.c | 11 ++++++++++-
- 1 file changed, 10 insertions(+), 1 deletion(-)
-
-diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
-index dcb897158228..b134bff5c3fe 100644
---- a/drivers/usb/core/generic.c
-+++ b/drivers/usb/core/generic.c
-@@ -59,7 +59,16 @@ int usb_choose_configuration(struct usb_device *udev)
- int num_configs;
- int insufficient_power = 0;
- struct usb_host_config *c, *best;
-- struct usb_device_driver *udriver = to_usb_device_driver(udev->dev.driver);
-+ struct usb_device_driver *udriver;
-+
-+ /*
-+ * If a USB device (not an interface) doesn't have a driver then the
-+ * kernel has no business trying to select or install a configuration
-+ * for it.
-+ */
-+ if (!udev->dev.driver)
-+ return -1;
-+ udriver = to_usb_device_driver(udev->dev.driver);
-
- if (usb_device_is_owned(udev))
- return 0;
---
-2.43.0
-