From: Sasha Levin Date: Sat, 2 Mar 2024 13:51:33 +0000 (-0500) Subject: Fixes for 5.10 X-Git-Tag: v6.6.20~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b3a1a62c83a4b1e45be5db69aba57898e385150;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.10 Signed-off-by: Sasha Levin --- diff --git a/queue-5.10/crypto-virtio-akcipher-fix-stack-overflow-on-memcpy.patch b/queue-5.10/crypto-virtio-akcipher-fix-stack-overflow-on-memcpy.patch new file mode 100644 index 00000000000..9056d6ed229 --- /dev/null +++ b/queue-5.10/crypto-virtio-akcipher-fix-stack-overflow-on-memcpy.patch @@ -0,0 +1,57 @@ +From 3e7d63543f4d4b81189066f16755305d0492cd10 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 30 Jan 2024 19:27:40 +0800 +Subject: crypto: virtio/akcipher - Fix stack overflow on memcpy + +From: zhenwei pi + +[ Upstream commit c0ec2a712daf133d9996a8a1b7ee2d4996080363 ] + +sizeof(struct virtio_crypto_akcipher_session_para) is less than +sizeof(struct virtio_crypto_op_ctrl_req::u), copying more bytes from +stack variable leads stack overflow. Clang reports this issue by +commands: +make -j CC=clang-14 mrproper >/dev/null 2>&1 +make -j O=/tmp/crypto-build CC=clang-14 allmodconfig >/dev/null 2>&1 +make -j O=/tmp/crypto-build W=1 CC=clang-14 drivers/crypto/virtio/ + virtio_crypto_akcipher_algs.o + +Fixes: 59ca6c93387d ("virtio-crypto: implement RSA algorithm") +Link: https://lore.kernel.org/all/0a194a79-e3a3-45e7-be98-83abd3e1cb7e@roeck-us.net/ +Cc: +Signed-off-by: zhenwei pi +Tested-by: Nathan Chancellor # build +Acked-by: Michael S. Tsirkin +Acked-by: Jason Wang +Signed-off-by: Herbert Xu +Signed-off-by: Sasha Levin +--- + drivers/crypto/virtio/virtio_crypto_akcipher_algs.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c +index 2cfc36d141c07..c58fac5748359 100644 +--- a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c ++++ b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c +@@ -101,7 +101,8 @@ static void virtio_crypto_dataq_akcipher_callback(struct virtio_crypto_request * + } + + static int virtio_crypto_alg_akcipher_init_session(struct virtio_crypto_akcipher_ctx *ctx, +- struct virtio_crypto_ctrl_header *header, void *para, ++ struct virtio_crypto_ctrl_header *header, ++ struct virtio_crypto_akcipher_session_para *para, + const uint8_t *key, unsigned int keylen) + { + struct scatterlist outhdr_sg, key_sg, inhdr_sg, *sgs[3]; +@@ -125,7 +126,7 @@ static int virtio_crypto_alg_akcipher_init_session(struct virtio_crypto_akcipher + + ctrl = &vc_ctrl_req->ctrl; + memcpy(&ctrl->header, header, sizeof(ctrl->header)); +- memcpy(&ctrl->u, para, sizeof(ctrl->u)); ++ memcpy(&ctrl->u.akcipher_create_session.para, para, sizeof(*para)); + input = &vc_ctrl_req->input; + input->status = cpu_to_le32(VIRTIO_CRYPTO_ERR); + +-- +2.43.0 + diff --git a/queue-5.10/platform-x86-touchscreen_dmi-allow-partial-prefix-ma.patch b/queue-5.10/platform-x86-touchscreen_dmi-allow-partial-prefix-ma.patch new file mode 100644 index 00000000000..aa28f01ebf2 --- /dev/null +++ b/queue-5.10/platform-x86-touchscreen_dmi-allow-partial-prefix-ma.patch @@ -0,0 +1,64 @@ +From 6652e92a0f68735e1adc2d4acb3de57241ae0d74 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 12 Feb 2024 13:06:07 +0100 +Subject: platform/x86: touchscreen_dmi: Allow partial (prefix) matches for + ACPI names + +From: Hans de Goede + +[ Upstream commit dbcbfd662a725641d118fb3ae5ffb7be4e3d0fb0 ] + +On some devices the ACPI name of the touchscreen is e.g. either +MSSL1680:00 or MSSL1680:01 depending on the BIOS version. + +This happens for example on the "Chuwi Hi8 Air" tablet where the initial +commit's ts_data uses "MSSL1680:00" but the tablets from the github issue +and linux-hardware.org probe linked below both use "MSSL1680:01". + +Replace the strcmp() match on ts_data->acpi_name with a strstarts() +check to allow using a partial match on just the ACPI HID of "MSSL1680" +and change the ts_data->acpi_name for the "Chuwi Hi8 Air" accordingly +to fix the touchscreen not working on models where it is "MSSL1680:01". + +Note this drops the length check for I2C_NAME_SIZE. This never was +necessary since the ACPI names used are never more then 11 chars and +I2C_NAME_SIZE is 20 so the replaced strncmp() would always stop long +before reaching I2C_NAME_SIZE. + +Link: https://linux-hardware.org/?computer=AC4301C0542A +Fixes: bbb97d728f77 ("platform/x86: touchscreen_dmi: Add info for the Chuwi Hi8 Air tablet") +Closes: https://github.com/onitake/gsl-firmware/issues/91 +Cc: stable@vger.kernel.org +Reviewed-by: Kuppuswamy Sathyanarayanan +Signed-off-by: Hans de Goede +Link: https://lore.kernel.org/r/20240212120608.30469-1-hdegoede@redhat.com +Signed-off-by: Sasha Levin +--- + drivers/platform/x86/touchscreen_dmi.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/platform/x86/touchscreen_dmi.c b/drivers/platform/x86/touchscreen_dmi.c +index fd22f6778664b..fb5c84872d322 100644 +--- a/drivers/platform/x86/touchscreen_dmi.c ++++ b/drivers/platform/x86/touchscreen_dmi.c +@@ -50,7 +50,7 @@ static const struct property_entry chuwi_hi8_air_props[] = { + }; + + static const struct ts_dmi_data chuwi_hi8_air_data = { +- .acpi_name = "MSSL1680:00", ++ .acpi_name = "MSSL1680", + .properties = chuwi_hi8_air_props, + }; + +@@ -1648,7 +1648,7 @@ static void ts_dmi_add_props(struct i2c_client *client) + int error; + + if (has_acpi_companion(dev) && +- !strncmp(ts_data->acpi_name, client->name, I2C_NAME_SIZE)) { ++ strstarts(client->name, ts_data->acpi_name)) { + error = device_create_managed_software_node(dev, ts_data->properties, NULL); + if (error) + dev_err(dev, "failed to add properties: %d\n", error); +-- +2.43.0 + diff --git a/queue-5.10/platform-x86-touchscreen_dmi-handle-device-propertie.patch b/queue-5.10/platform-x86-touchscreen_dmi-handle-device-propertie.patch new file mode 100644 index 00000000000..ece4e611963 --- /dev/null +++ b/queue-5.10/platform-x86-touchscreen_dmi-handle-device-propertie.patch @@ -0,0 +1,39 @@ +From 348424bfd17a248c97fef308f20e7c853834c9bc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 4 Mar 2021 11:20:23 +0300 +Subject: platform/x86: touchscreen_dmi: Handle device properties with software + node API + +From: Heikki Krogerus + +[ Upstream commit 87eaede45385e384faf5b15d9c718a951667bdd0 ] + +The old device property API (device_add_properties()) is +going to be removed. Replacing the it with the software node +API equivalent, device_create_managed_software_node(). + +Signed-off-by: Heikki Krogerus +Link: https://lore.kernel.org/r/20210304082023.17689-1-heikki.krogerus@linux.intel.com +Signed-off-by: Hans de Goede +Stable-dep-of: dbcbfd662a72 ("platform/x86: touchscreen_dmi: Allow partial (prefix) matches for ACPI names") +Signed-off-by: Sasha Levin +--- + drivers/platform/x86/touchscreen_dmi.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/platform/x86/touchscreen_dmi.c b/drivers/platform/x86/touchscreen_dmi.c +index eedff2ae28511..fd22f6778664b 100644 +--- a/drivers/platform/x86/touchscreen_dmi.c ++++ b/drivers/platform/x86/touchscreen_dmi.c +@@ -1649,7 +1649,7 @@ static void ts_dmi_add_props(struct i2c_client *client) + + if (has_acpi_companion(dev) && + !strncmp(ts_data->acpi_name, client->name, I2C_NAME_SIZE)) { +- error = device_add_properties(dev, ts_data->properties); ++ error = device_create_managed_software_node(dev, ts_data->properties, NULL); + if (error) + dev_err(dev, "failed to add properties: %d\n", error); + } +-- +2.43.0 + diff --git a/queue-5.10/series b/queue-5.10/series new file mode 100644 index 00000000000..bc7c8787fe4 --- /dev/null +++ b/queue-5.10/series @@ -0,0 +1,5 @@ +software-node-introduce-device_add_software_node.patch +software-node-provide-replacement-for-device_add_pro.patch +platform-x86-touchscreen_dmi-handle-device-propertie.patch +platform-x86-touchscreen_dmi-allow-partial-prefix-ma.patch +crypto-virtio-akcipher-fix-stack-overflow-on-memcpy.patch diff --git a/queue-5.10/software-node-introduce-device_add_software_node.patch b/queue-5.10/software-node-introduce-device_add_software_node.patch new file mode 100644 index 00000000000..9f8b1024af8 --- /dev/null +++ b/queue-5.10/software-node-introduce-device_add_software_node.patch @@ -0,0 +1,135 @@ +From fdcd9f91d60f029d904322dbf5cf129901f39ec2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 15 Jan 2021 12:49:11 +0300 +Subject: software node: Introduce device_add_software_node() + +From: Heikki Krogerus + +[ Upstream commit e68d0119e3284334de5650a1ac42ef4e179f895e ] + +This helper will register a software node and then assign +it to device at the same time. The function will also make +sure that the device can't have more than one software node. + +Acked-by: Felipe Balbi +Signed-off-by: Heikki Krogerus +Link: https://lore.kernel.org/r/20210115094914.88401-2-heikki.krogerus@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: dbcbfd662a72 ("platform/x86: touchscreen_dmi: Allow partial (prefix) matches for ACPI names") +Signed-off-by: Sasha Levin +--- + drivers/base/swnode.c | 71 +++++++++++++++++++++++++++++++++++----- + include/linux/property.h | 3 ++ + 2 files changed, 65 insertions(+), 9 deletions(-) + +diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c +index b664c36388e24..ad66d7c545f92 100644 +--- a/drivers/base/swnode.c ++++ b/drivers/base/swnode.c +@@ -48,6 +48,19 @@ EXPORT_SYMBOL_GPL(is_software_node); + struct swnode, fwnode) : NULL; \ + }) + ++static inline struct swnode *dev_to_swnode(struct device *dev) ++{ ++ struct fwnode_handle *fwnode = dev_fwnode(dev); ++ ++ if (!fwnode) ++ return NULL; ++ ++ if (!is_software_node(fwnode)) ++ fwnode = fwnode->secondary; ++ ++ return to_swnode(fwnode); ++} ++ + static struct swnode * + software_node_to_swnode(const struct software_node *node) + { +@@ -853,22 +866,62 @@ void fwnode_remove_software_node(struct fwnode_handle *fwnode) + } + EXPORT_SYMBOL_GPL(fwnode_remove_software_node); + ++/** ++ * device_add_software_node - Assign software node to a device ++ * @dev: The device the software node is meant for. ++ * @swnode: The software node. ++ * ++ * This function will register @swnode and make it the secondary firmware node ++ * pointer of @dev. If @dev has no primary node, then @swnode will become the primary ++ * node. ++ */ ++int device_add_software_node(struct device *dev, const struct software_node *swnode) ++{ ++ int ret; ++ ++ /* Only one software node per device. */ ++ if (dev_to_swnode(dev)) ++ return -EBUSY; ++ ++ ret = software_node_register(swnode); ++ if (ret) ++ return ret; ++ ++ set_secondary_fwnode(dev, software_node_fwnode(swnode)); ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(device_add_software_node); ++ ++/** ++ * device_remove_software_node - Remove device's software node ++ * @dev: The device with the software node. ++ * ++ * This function will unregister the software node of @dev. ++ */ ++void device_remove_software_node(struct device *dev) ++{ ++ struct swnode *swnode; ++ ++ swnode = dev_to_swnode(dev); ++ if (!swnode) ++ return; ++ ++ software_node_notify(dev, KOBJ_REMOVE); ++ set_secondary_fwnode(dev, NULL); ++ kobject_put(&swnode->kobj); ++} ++EXPORT_SYMBOL_GPL(device_remove_software_node); ++ + int software_node_notify(struct device *dev, unsigned long action) + { +- struct fwnode_handle *fwnode = dev_fwnode(dev); + struct swnode *swnode; + int ret; + +- if (!fwnode) +- return 0; +- +- if (!is_software_node(fwnode)) +- fwnode = fwnode->secondary; +- if (!is_software_node(fwnode)) ++ swnode = dev_to_swnode(dev); ++ if (!swnode) + return 0; + +- swnode = to_swnode(fwnode); +- + switch (action) { + case KOBJ_ADD: + ret = sysfs_create_link(&dev->kobj, &swnode->kobj, +diff --git a/include/linux/property.h b/include/linux/property.h +index 2d4542629d80b..3b6093f6bd04c 100644 +--- a/include/linux/property.h ++++ b/include/linux/property.h +@@ -485,4 +485,7 @@ fwnode_create_software_node(const struct property_entry *properties, + const struct fwnode_handle *parent); + void fwnode_remove_software_node(struct fwnode_handle *fwnode); + ++int device_add_software_node(struct device *dev, const struct software_node *swnode); ++void device_remove_software_node(struct device *dev); ++ + #endif /* _LINUX_PROPERTY_H_ */ +-- +2.43.0 + diff --git a/queue-5.10/software-node-provide-replacement-for-device_add_pro.patch b/queue-5.10/software-node-provide-replacement-for-device_add_pro.patch new file mode 100644 index 00000000000..a445dc3d750 --- /dev/null +++ b/queue-5.10/software-node-provide-replacement-for-device_add_pro.patch @@ -0,0 +1,135 @@ +From 3995588dbe6584f277a9a6d92164ade46144c9dc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 4 Feb 2021 17:17:06 +0300 +Subject: software node: Provide replacement for device_add_properties() + +From: Heikki Krogerus + +[ Upstream commit 151f6ff78cdf1d6de76e90556cfc43f1e48abe18 ] + +At the moment the function device_del() is calling +device_remove_properties() unconditionally. That will result into the +reference count of the software node attached to the device being +decremented, and in most cases it will hit 0 at that point. So in +practice device_del() will unregister the software node attached to +the device, even if that was not the intention of the caller. Right +now software nodes can not be reused or shared because of that. + +So device_del() can not unregister the software nodes unconditionally +like that. Unfortunately some of the users of device_add_properties() +are now relying on this behaviour. Because of that, and also in +general, we do need a function that can offer similar behaviour where +the lifetime of the software node is bound to the lifetime of the +device. But it just has to be a separate function so the behaviour is +optional. We can not remove the device_remove_properties() call from +device_del() before we have that new function, and before we have +replaced device_add_properties() calls with it in all the places that +require that behaviour. + +This adds function device_create_managed_software_node() that can be +used for exactly that purpose. Software nodes created with it are +declared "managed", and separate handling for those nodes is added to +the software node code. The reference count of the "managed" nodes is +decremented when the device they are attached to is removed. This will +not affect the other nodes that are not declared "managed". + +The function device_create_managed_software_node() has also one +additional feature that device_add_properties() does not have. It +allows the software nodes created with it to be part of a node +hierarchy by taking also an optional parent node as parameter. + +Reviewed-by: Rafael J. Wysocki +Signed-off-by: Heikki Krogerus +Link: https://lore.kernel.org/r/20210204141711.53775-2-heikki.krogerus@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: dbcbfd662a72 ("platform/x86: touchscreen_dmi: Allow partial (prefix) matches for ACPI names") +Signed-off-by: Sasha Levin +--- + drivers/base/swnode.c | 43 ++++++++++++++++++++++++++++++++++++++++ + include/linux/property.h | 4 ++++ + 2 files changed, 47 insertions(+) + +diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c +index ad66d7c545f92..f9069180f2428 100644 +--- a/drivers/base/swnode.c ++++ b/drivers/base/swnode.c +@@ -24,6 +24,7 @@ struct swnode { + struct swnode *parent; + + unsigned int allocated:1; ++ unsigned int managed:1; + }; + + static DEFINE_IDA(swnode_root_ids); +@@ -913,6 +914,43 @@ void device_remove_software_node(struct device *dev) + } + EXPORT_SYMBOL_GPL(device_remove_software_node); + ++/** ++ * device_create_managed_software_node - Create a software node for a device ++ * @dev: The device the software node is assigned to. ++ * @properties: Device properties for the software node. ++ * @parent: Parent of the software node. ++ * ++ * Creates a software node as a managed resource for @dev, which means the ++ * lifetime of the newly created software node is tied to the lifetime of @dev. ++ * Software nodes created with this function should not be reused or shared ++ * because of that. The function takes a deep copy of @properties for the ++ * software node. ++ * ++ * Since the new software node is assigned directly to @dev, and since it should ++ * not be shared, it is not returned to the caller. The function returns 0 on ++ * success, and errno in case of an error. ++ */ ++int device_create_managed_software_node(struct device *dev, ++ const struct property_entry *properties, ++ const struct software_node *parent) ++{ ++ struct fwnode_handle *p = software_node_fwnode(parent); ++ struct fwnode_handle *fwnode; ++ ++ if (parent && !p) ++ return -EINVAL; ++ ++ fwnode = fwnode_create_software_node(properties, p); ++ if (IS_ERR(fwnode)) ++ return PTR_ERR(fwnode); ++ ++ to_swnode(fwnode)->managed = true; ++ set_secondary_fwnode(dev, fwnode); ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(device_create_managed_software_node); ++ + int software_node_notify(struct device *dev, unsigned long action) + { + struct swnode *swnode; +@@ -941,6 +979,11 @@ int software_node_notify(struct device *dev, unsigned long action) + sysfs_remove_link(&swnode->kobj, dev_name(dev)); + sysfs_remove_link(&dev->kobj, "software_node"); + kobject_put(&swnode->kobj); ++ ++ if (swnode->managed) { ++ set_secondary_fwnode(dev, NULL); ++ kobject_put(&swnode->kobj); ++ } + break; + default: + break; +diff --git a/include/linux/property.h b/include/linux/property.h +index 3b6093f6bd04c..d339b835c7766 100644 +--- a/include/linux/property.h ++++ b/include/linux/property.h +@@ -488,4 +488,8 @@ void fwnode_remove_software_node(struct fwnode_handle *fwnode); + int device_add_software_node(struct device *dev, const struct software_node *swnode); + void device_remove_software_node(struct device *dev); + ++int device_create_managed_software_node(struct device *dev, ++ const struct property_entry *properties, ++ const struct software_node *parent); ++ + #endif /* _LINUX_PROPERTY_H_ */ +-- +2.43.0 +