From: Greg Kroah-Hartman Date: Tue, 23 Jan 2024 17:26:08 +0000 (-0800) Subject: drop some USB patches X-Git-Tag: v4.19.306~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=84adb6229d9c0e57cd44c6f5c33473e7ec8de670;p=thirdparty%2Fkernel%2Fstable-queue.git drop some USB patches --- diff --git a/queue-5.15/r8152-choose-our-usb-config-with-choose_configuratio.patch b/queue-5.15/r8152-choose-our-usb-config-with-choose_configuratio.patch deleted file mode 100644 index 2f37aa2f9ab..00000000000 --- a/queue-5.15/r8152-choose-our-usb-config-with-choose_configuratio.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 7cb0bcacfbbda3487ecaa7bdd6b625f08ee63528 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Fri, 1 Dec 2023 10:29:52 -0800 -Subject: r8152: Choose our USB config with choose_configuration() rather than - probe() - -From: Douglas Anderson - -[ 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 -Signed-off-by: Douglas Anderson -Reviewed-by: Grant Grundler -Link: https://lore.kernel.org/r/20231201102946.v2.3.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid -Signed-off-by: Greg Kroah-Hartman -Signed-off-by: Sasha Levin ---- - 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 - diff --git a/queue-5.15/series b/queue-5.15/series index cc66b3e95b7..bb26edc4fc0 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -302,8 +302,6 @@ power-supply-cw2015-correct-time_to_empty-units-in-s.patch 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 @@ -318,7 +316,6 @@ tty-early-return-from-send_break-on-tty_driver_hardw.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 diff --git a/queue-5.15/usb-core-allow-subclassed-usb-drivers-to-override-us.patch b/queue-5.15/usb-core-allow-subclassed-usb-drivers-to-override-us.patch deleted file mode 100644 index 4268b5fc1e7..00000000000 --- a/queue-5.15/usb-core-allow-subclassed-usb-drivers-to-override-us.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 692bc9dc9b8cd469bb61a68003639f223d6bc15c Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Fri, 1 Dec 2023 10:29:51 -0800 -Subject: usb: core: Allow subclassed USB drivers to override - usb_choose_configuration() - -From: Douglas Anderson - -[ 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 -Signed-off-by: Douglas Anderson -Reviewed-by: Alan Stern -Link: https://lore.kernel.org/r/20231201102946.v2.2.Iade5fa31997f1a0ca3e1dec0591633b02471df12@changeid -Signed-off-by: Greg Kroah-Hartman -Stable-dep-of: aa4f2b3e418e ("r8152: Choose our USB config with choose_configuration() rather than probe()") -Signed-off-by: Sasha Levin ---- - 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 - diff --git a/queue-5.15/usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch b/queue-5.15/usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch deleted file mode 100644 index f005bc1a5b8..00000000000 --- a/queue-5.15/usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 75ea98ad215b45d2ceb7a803dc6b6463c19b9564 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Mon, 11 Dec 2023 07:32:41 -0800 -Subject: usb: core: Fix crash w/ usb_choose_configuration() if no driver - -From: Douglas Anderson - -[ 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 -Signed-off-by: Douglas Anderson -Link: https://lore.kernel.org/r/20231211073237.v3.1.If27eb3bf7812f91ab83810f232292f032f4203e0@changeid -Signed-off-by: Greg Kroah-Hartman -Signed-off-by: Sasha Levin ---- - 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 - diff --git a/queue-6.1/r8152-choose-our-usb-config-with-choose_configuratio.patch b/queue-6.1/r8152-choose-our-usb-config-with-choose_configuratio.patch deleted file mode 100644 index b11598c0c77..00000000000 --- a/queue-6.1/r8152-choose-our-usb-config-with-choose_configuratio.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 2bdc1c1d7ca3e1c1222705acfcaa506cee203efb Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Fri, 1 Dec 2023 10:29:52 -0800 -Subject: r8152: Choose our USB config with choose_configuration() rather than - probe() - -From: Douglas Anderson - -[ 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 -Signed-off-by: Douglas Anderson -Reviewed-by: Grant Grundler -Link: https://lore.kernel.org/r/20231201102946.v2.3.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid -Signed-off-by: Greg Kroah-Hartman -Signed-off-by: Sasha Levin ---- - 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 - diff --git a/queue-6.1/series b/queue-6.1/series index a0e6d40c48a..b040127ac8d 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -337,8 +337,6 @@ power-supply-cw2015-correct-time_to_empty-units-in-s.patch 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 @@ -358,7 +356,6 @@ tty-early-return-from-send_break-on-tty_driver_hardw.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 diff --git a/queue-6.1/usb-core-allow-subclassed-usb-drivers-to-override-us.patch b/queue-6.1/usb-core-allow-subclassed-usb-drivers-to-override-us.patch deleted file mode 100644 index 00c35da9360..00000000000 --- a/queue-6.1/usb-core-allow-subclassed-usb-drivers-to-override-us.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 89f477bd047273d8654f338159d387f37267ae9e Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Fri, 1 Dec 2023 10:29:51 -0800 -Subject: usb: core: Allow subclassed USB drivers to override - usb_choose_configuration() - -From: Douglas Anderson - -[ 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 -Signed-off-by: Douglas Anderson -Reviewed-by: Alan Stern -Link: https://lore.kernel.org/r/20231201102946.v2.2.Iade5fa31997f1a0ca3e1dec0591633b02471df12@changeid -Signed-off-by: Greg Kroah-Hartman -Stable-dep-of: aa4f2b3e418e ("r8152: Choose our USB config with choose_configuration() rather than probe()") -Signed-off-by: Sasha Levin ---- - 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 - diff --git a/queue-6.1/usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch b/queue-6.1/usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch deleted file mode 100644 index 5d419a13f99..00000000000 --- a/queue-6.1/usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 05694d9fc201f5042fecab532a59b317aadb5f53 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Mon, 11 Dec 2023 07:32:41 -0800 -Subject: usb: core: Fix crash w/ usb_choose_configuration() if no driver - -From: Douglas Anderson - -[ 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 -Signed-off-by: Douglas Anderson -Link: https://lore.kernel.org/r/20231211073237.v3.1.If27eb3bf7812f91ab83810f232292f032f4203e0@changeid -Signed-off-by: Greg Kroah-Hartman -Signed-off-by: Sasha Levin ---- - 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 - diff --git a/queue-6.6/r8152-choose-our-usb-config-with-choose_configuratio.patch b/queue-6.6/r8152-choose-our-usb-config-with-choose_configuratio.patch deleted file mode 100644 index c24a95a3da8..00000000000 --- a/queue-6.6/r8152-choose-our-usb-config-with-choose_configuratio.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 0b0dd4e71eeae2e0e3ef2f70ef98708f586769c4 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Fri, 1 Dec 2023 10:29:52 -0800 -Subject: r8152: Choose our USB config with choose_configuration() rather than - probe() - -From: Douglas Anderson - -[ 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 -Signed-off-by: Douglas Anderson -Reviewed-by: Grant Grundler -Link: https://lore.kernel.org/r/20231201102946.v2.3.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid -Signed-off-by: Greg Kroah-Hartman -Signed-off-by: Sasha Levin ---- - 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 - diff --git a/queue-6.6/series b/queue-6.6/series index e6643f38eb4..5fdcb50f131 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -461,8 +461,6 @@ iommu-map-reserved-memory-as-cacheable-if-device-is-.patch 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 @@ -493,7 +491,6 @@ tty-early-return-from-send_break-on-tty_driver_hardw.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 diff --git a/queue-6.6/usb-core-allow-subclassed-usb-drivers-to-override-us.patch b/queue-6.6/usb-core-allow-subclassed-usb-drivers-to-override-us.patch deleted file mode 100644 index 62ddbaccb21..00000000000 --- a/queue-6.6/usb-core-allow-subclassed-usb-drivers-to-override-us.patch +++ /dev/null @@ -1,89 +0,0 @@ -From e298d511909d50f1da9e63a5b5949f41a77dc2a3 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Fri, 1 Dec 2023 10:29:51 -0800 -Subject: usb: core: Allow subclassed USB drivers to override - usb_choose_configuration() - -From: Douglas Anderson - -[ 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 -Signed-off-by: Douglas Anderson -Reviewed-by: Alan Stern -Link: https://lore.kernel.org/r/20231201102946.v2.2.Iade5fa31997f1a0ca3e1dec0591633b02471df12@changeid -Signed-off-by: Greg Kroah-Hartman -Stable-dep-of: aa4f2b3e418e ("r8152: Choose our USB config with choose_configuration() rather than probe()") -Signed-off-by: Sasha Levin ---- - 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 - diff --git a/queue-6.6/usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch b/queue-6.6/usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch deleted file mode 100644 index cf34e163039..00000000000 --- a/queue-6.6/usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch +++ /dev/null @@ -1,64 +0,0 @@ -From f40a7d1b7ffa8ee851a2a3bcd4237c10c564445d Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Mon, 11 Dec 2023 07:32:41 -0800 -Subject: usb: core: Fix crash w/ usb_choose_configuration() if no driver - -From: Douglas Anderson - -[ 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 -Signed-off-by: Douglas Anderson -Link: https://lore.kernel.org/r/20231211073237.v3.1.If27eb3bf7812f91ab83810f232292f032f4203e0@changeid -Signed-off-by: Greg Kroah-Hartman -Signed-off-by: Sasha Levin ---- - 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 - diff --git a/queue-6.7/r8152-choose-our-usb-config-with-choose_configuratio.patch b/queue-6.7/r8152-choose-our-usb-config-with-choose_configuratio.patch deleted file mode 100644 index b97967cf69f..00000000000 --- a/queue-6.7/r8152-choose-our-usb-config-with-choose_configuratio.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 789207c691d113fac0bd79371537148758310385 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Fri, 1 Dec 2023 10:29:52 -0800 -Subject: r8152: Choose our USB config with choose_configuration() rather than - probe() - -From: Douglas Anderson - -[ 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 -Signed-off-by: Douglas Anderson -Reviewed-by: Grant Grundler -Link: https://lore.kernel.org/r/20231201102946.v2.3.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid -Signed-off-by: Greg Kroah-Hartman -Signed-off-by: Sasha Levin ---- - 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 - diff --git a/queue-6.7/series b/queue-6.7/series index 6540842943a..0c1b89901fb 100644 --- a/queue-6.7/series +++ b/queue-6.7/series @@ -509,8 +509,6 @@ perf-header-fix-segfault-on-build_mem_topology-error.patch 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 @@ -540,7 +538,6 @@ bus-mhi-ep-pass-mhi_ep_buf_info-struct-to-read-write.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 diff --git a/queue-6.7/usb-core-allow-subclassed-usb-drivers-to-override-us.patch b/queue-6.7/usb-core-allow-subclassed-usb-drivers-to-override-us.patch deleted file mode 100644 index b415ca29724..00000000000 --- a/queue-6.7/usb-core-allow-subclassed-usb-drivers-to-override-us.patch +++ /dev/null @@ -1,89 +0,0 @@ -From df41b669ad09e572e61c730aa600fc24c9127a45 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Fri, 1 Dec 2023 10:29:51 -0800 -Subject: usb: core: Allow subclassed USB drivers to override - usb_choose_configuration() - -From: Douglas Anderson - -[ 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 -Signed-off-by: Douglas Anderson -Reviewed-by: Alan Stern -Link: https://lore.kernel.org/r/20231201102946.v2.2.Iade5fa31997f1a0ca3e1dec0591633b02471df12@changeid -Signed-off-by: Greg Kroah-Hartman -Stable-dep-of: aa4f2b3e418e ("r8152: Choose our USB config with choose_configuration() rather than probe()") -Signed-off-by: Sasha Levin ---- - 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 - diff --git a/queue-6.7/usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch b/queue-6.7/usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch deleted file mode 100644 index d748b117063..00000000000 --- a/queue-6.7/usb-core-fix-crash-w-usb_choose_configuration-if-no-.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 995b37662d62f8340cc8d22fc287e5ee83103a0c Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Mon, 11 Dec 2023 07:32:41 -0800 -Subject: usb: core: Fix crash w/ usb_choose_configuration() if no driver - -From: Douglas Anderson - -[ 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 -Signed-off-by: Douglas Anderson -Link: https://lore.kernel.org/r/20231211073237.v3.1.If27eb3bf7812f91ab83810f232292f032f4203e0@changeid -Signed-off-by: Greg Kroah-Hartman -Signed-off-by: Sasha Levin ---- - 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 -