6.10.13-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 414/634 nvme-multipath: system fails to create generic nvme device
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Reinecke <[email protected]>
[ Upstream commit 63bcf9014e95a7d279d10d8e2caa5d88db2b1855 ]
NVME_NSHEAD_DISK_LIVE is a flag for struct nvme_ns_head, not nvme_ns. The current code has a typo causing NVME_NSHEAD_DISK_LIVE never to be cleared once device_add_disk_fails, causing the system never to create the 'generic' character device. Even several rescan attempts will change the situation and the system has to be rebooted to fix the issue.
--- drivers/nvme/host/multipath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/multipath.c +1 -1
@@ -587,7 +587,7 @@ static void nvme_mpath_set_live(struct nvme_ns *ns) rc =device_add_disk (&head->subsys->dev, head->disk, nvme_ns_attr_groups);if (rc) { -clear_bit (NVME_NSHEAD_DISK_LIVE , &ns->flags); +clear_bit (NVME_NSHEAD_DISK_LIVE , &head->flags);return ; }nvme_add_ns_head_cdev (head);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 415/634 iio: adc: ad7606: fix oversampling gpio array
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Stols <[email protected]>
[ Upstream commit 8dc4594b54dbaaba40dc8884ad3d42083de39434 ]
gpiod_set_array_value was misused here: the implementation relied on the assumption that an unsigned long was required for each gpio, while the function expects a bit array stored in "as much unsigned long as needed for storing one bit per GPIO", i.e it is using a bit field.
This leaded to incorrect parameter passed to gpiod_set_array_value, that would set 1 value instead of 3.
It also prevents to select the software mode correctly for the AD7606B.
--- drivers/iio/adc/ad7606.c | 4 ++-- drivers/iio/adc/ad7606_spi.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/iio/adc/ad7606.c +2 -2
@@ -215,9 +215,9 @@ static int ad7606_write_os_hw(struct iio_dev *indio_dev, int val)struct ad7606_state *st =iio_priv (indio_dev);DECLARE_BITMAP (values,3 ); - values[0 ] = val; + values[0 ] = val &GENMASK (2 ,0 ); -gpiod_set_array_value (ARRAY_SIZE (values), st->gpio_os->desc, +gpiod_set_array_value (st->gpio_os->ndescs, st->gpio_os->desc, st->gpio_os->info, values);/* AD7616 requires a reset to update value */
drivers/iio/adc/ad7606_spi.c +3 -2
@@ -249,8 +249,9 @@ static int ad7616_sw_mode_config(struct iio_dev *indio_dev)static int ad7606B_sw_mode_config (struct iio_dev *indio_dev) {struct ad7606_state *st =iio_priv (indio_dev); -unsigned long os[3 ] = {1 }; +DECLARE_BITMAP (os,3 ); +bitmap_fill (os,3 );/* * Software mode is enabled when all three oversampling * pins are set to high. If oversampling gpios are defined
@@ -258,7 +259,7 @@ static int ad7606B_sw_mode_config(struct iio_dev *indio_dev)* otherwise, they must be hardwired to VDD */ if (st->gpio_os) { -gpiod_set_array_value (ARRAY_SIZE (os), +gpiod_set_array_value (st->gpio_os->ndescs, st->gpio_os->desc, st->gpio_os->info, os); }/* OS of 128 and 256 are available only in software mode */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 416/634 iio: adc: ad7606: fix standby gpio state to match the documentation
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Stols <[email protected]>
[ Upstream commit 059fe4f8bbdf5cad212e1aeeb3e8968c80b9ff3b ]
The binding's documentation specifies that "As the line is active low, it should be marked GPIO_ACTIVE_LOW". However, in the driver, it was handled the opposite way. This commit sets the driver's behaviour in sync with the documentation
--- drivers/iio/adc/ad7606.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/ad7606.c +2 -2
@@ -422,7 +422,7 @@ static int ad7606_request_gpios(struct ad7606_state *st)return PTR_ERR (st->gpio_range); st->gpio_standby =devm_gpiod_get_optional (dev,"standby" , -GPIOD_OUT_HIGH ); +GPIOD_OUT_LOW );if (IS_ERR (st->gpio_standby))return PTR_ERR (st->gpio_standby);
@@ -665,7 +665,7 @@ static int ad7606_suspend(struct device *dev)if (st->gpio_standby) {gpiod_set_value (st->gpio_range,1 ); -gpiod_set_value (st->gpio_standby,0 ); +gpiod_set_value (st->gpio_standby,1 ); }return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 417/634 driver core: Fix error handling in driver API device_rename()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit 6d8249ac29bc23260dfa9747eb398ce76012d73c ]
For class-device, device_rename() failure maybe cause unexpected link name within its class folder as explained below:
/sys/class/.../old_name -> /sys/devices/.../old_name device_rename(..., new_name) and failed /sys/class/.../new_name -> /sys/devices/.../old_name
Fixed by undoing renaming link if renaming kobject failed.
--- drivers/base/core.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/base/core.c +10 -5
@@ -4515,9 +4515,11 @@ EXPORT_SYMBOL_GPL(device_destroy);*/ int device_rename (struct device *dev,const char *new_name) { +struct subsys_private *sp =NULL ;struct kobject *kobj = &dev->kobj;char *old_device_name =NULL ;int error; +bool is_link_renamed = false; dev =get_device (dev);if (!dev)
@@ -4532,7 +4534,7 @@ int device_rename(struct device *dev, const char *new_name) }if (dev->class) { -struct subsys_private *sp =class_to_subsys (dev->class); + sp =class_to_subsys (dev->class);if (!sp) { error = -EINVAL ;
@@ -4541,16 +4543,19 @@ int device_rename(struct device *dev, const char *new_name) error =sysfs_rename_link_ns (&sp->subsys.kobj, kobj, old_device_name, new_name,kobject_namespace (kobj)); -subsys_put (sp);if (error) goto out; + + is_link_renamed = true; } error =kobject_rename (kobj, new_name); -if (error) - goto out; - out: +if (error && is_link_renamed) +sysfs_rename_link_ns (&sp->subsys.kobj, kobj, new_name, + old_device_name,kobject_namespace (kobj)); +subsys_put (sp); +put_device (dev);kfree (old_device_name);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 418/634 ABI: testing: fix admv8818 attr description
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
[ Upstream commit 7d34b4ad8cd2867b130b5b8d7d76d0d6092bd019 ]
Fix description of the filter_mode_available attribute by pointing to the correct name of the attribute that can be written with valid values.
--- Documentation/ABI/testing/sysfs-bus-iio-filter-admv8818 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-bus-iio-filter-admv8818 +1 -1
@@ -3,7 +3,7 @@ KernelVersion: Contact: [email protected] Description: Reading this returns the valid values that can be written to the - on_altvoltage0_mode attribute: + filter_mode attribute: - auto -> Adjust bandpass filter to track changes in input clock rate. - manual -> disable/unregister the clock rate notifier / input clock tracking.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 419/634 iio: chemical: bme680: Fix read/write ops to device by adding mutexes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasileios Amoiridis <[email protected]>
[ Upstream commit 77641e5a477d428335cd094b88ac54e09ccb70f4 ]
Add mutexes in the {read/write}_raw() functions of the device to guard the read/write of data from/to the device. This is necessary because for any operation other than temperature, multiple reads need to take place from the device. Even though regmap has a locking by itself, it won't protect us from multiple applications trying to read at the same time temperature and pressure since the pressure reading includes an internal temperature reading and there is nothing to ensure that this temperature+pressure reading will happen sequentially without any other operation interfering in the meantime.
--- drivers/iio/chemical/bme680_core.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/iio/chemical/bme680_core.c +7 -0
@@ -10,6 +10,7 @@*/ #include <linux/acpi.h> #include <linux/bitfield.h> +#include <linux/cleanup.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/module.h>
@@ -52,6 +53,7 @@ struct bme680_calib {struct bme680_data {struct regmap *regmap;struct bme680_calib bme680; +struct mutex lock;/* Protect multiple serial R/W ops to device. */ u8 oversampling_temp;u8 oversampling_press;u8 oversampling_humid;
@@ -827,6 +829,8 @@ static int bme680_read_raw(struct iio_dev *indio_dev, {struct bme680_data *data =iio_priv (indio_dev); +guard (mutex)(&data->lock); +switch (mask) {case IIO_CHAN_INFO_PROCESSED :switch (chan->type) {
@@ -871,6 +875,8 @@ static int bme680_write_raw(struct iio_dev *indio_dev, {struct bme680_data *data =iio_priv (indio_dev); +guard (mutex)(&data->lock); +if (val2 !=0 )return -EINVAL ;
@@ -967,6 +973,7 @@ int bme680_core_probe(struct device *dev, struct regmap *regmap, name =bme680_match_acpi_device (dev); data =iio_priv (indio_dev); +mutex_init (&data->lock);dev_set_drvdata (dev, indio_dev); data->regmap = regmap; indio_dev->name = name;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 420/634 iio: magnetometer: ak8975: drop incorrect AK09116 compatible
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit da6e3160df230692bbd48a6d52318035f19595e2 ]
All compatibles in this binding without prefixes were deprecated, so adding a new deprecated one after some time is not allowed, because it defies the core logic of deprecating things.
Drop the AK09916 vendorless compatible.
--- drivers/iio/magnetometer/ak8975.c | 1 - 1 file changed, 1 deletion(-)
drivers/iio/magnetometer/ak8975.c +0 -1
@@ -1081,7 +1081,6 @@ static const struct of_device_id ak8975_of_match[] = { { .compatible = "asahi-kasei,ak09912", .data = &ak_def_array[AK09912] }, { .compatible = "ak09912", .data = &ak_def_array[AK09912] }, { .compatible = "asahi-kasei,ak09916", .data = &ak_def_array[AK09916] }, - { .compatible = "ak09916", .data = &ak_def_array[AK09916] }, {} };MODULE_DEVICE_TABLE (of, ak8975_of_match);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 421/634 dt-bindings: iio: asahi-kasei,ak8975: drop incorrect AK09116 compatible
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit c7668ac67bc21aebdd8e2d7f839bfffba31b7713 ]
All compatibles in this binding without prefixes were deprecated, so adding a new deprecated one after some time is not allowed, because it defies the core logic of deprecating things.
Drop the AK09916 vendorless compatible.
--- .../devicetree/bindings/iio/magnetometer/asahi-kasei,ak8975.yaml | 1 - 1 file changed, 1 deletion(-)
Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8975.yaml +0 -1
@@ -23,7 +23,6 @@ properties: - ak8963 - ak09911 - ak09912 - - ak09916 deprecated: true reg:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 422/634 driver core: Fix a potential null-ptr-deref in module_add_driver()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
[ Upstream commit 18ec12c97b39ff6aa15beb8d2b25d15cd44b87d8 ]
Inject fault while probing of-fpga-region, if kasprintf() fails in module_add_driver(), the second sysfs_remove_link() in exit path will cause null-ptr-deref as below because kernfs_name_hash() will call strlen() with NULL driver_name.
Fix it by releasing resources based on the exit path sequence.
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] Mem abort info: ESR = 0x0000000096000005 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 FSC = 0x05: level 1 translation fault Data abort info: ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000 CM = 0, WnR = 0, TnD = 0, TagAccess = 0 GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [dfffffc000000000] address between user and kernel address ranges Internal error: Oops: 0000000096000005 [#1] PREEMPT SMP Dumping ftrace buffer: (ftrace buffer empty) Modules linked in: of_fpga_region(+) fpga_region fpga_bridge cfg80211 rfkill 8021q garp mrp stp llc ipv6 [last unloaded: of_fpga_region] CPU: 2 UID: 0 PID: 2036 Comm: modprobe Not tainted 6.11.0-rc2-g6a0e38264012 #295 Hardware name: linux,dummy-virt (DT) pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : strlen+0x24/0xb0 lr : kernfs_name_hash+0x1c/0xc4 sp : ffffffc081f97380 x29: ffffffc081f97380 x28: ffffffc081f97b90 x27: ffffff80c821c2a0 x26: ffffffedac0be418 x25: 0000000000000000 x24: ffffff80c09d2000 x23: 0000000000000000 x22: 0000000000000000 x21: 0000000000000000 x20: 0000000000000000 x19: 0000000000000000 x18: 0000000000001840 x17: 0000000000000000 x16: 0000000000000000 x15: 1ffffff8103f2e42 x14: 00000000f1f1f1f1 x13: 0000000000000004 x12: ffffffb01812d61d x11: 1ffffff01812d61c x10: ffffffb01812d61c x9 : dfffffc000000000 x8 : 0000004fe7ed29e4 x7 : ffffff80c096b0e7 x6 : 0000000000000001 x5 : ffffff80c096b0e0 x4 : 1ffffffdb990efa2 x3 : 0000000000000000 x2 : 0000000000000000 x1 : dfffffc000000000 x0 : 0000000000000000 Call trace: strlen+0x24/0xb0 kernfs_name_hash+0x1c/0xc4 kernfs_find_ns+0x118/0x2e8 kernfs_remove_by_name_ns+0x80/0x100 sysfs_remove_link+0x74/0xa8 module_add_driver+0x278/0x394 bus_add_driver+0x1f0/0x43c driver_register+0xf4/0x3c0 __platform_driver_register+0x60/0x88 of_fpga_region_init+0x20/0x1000 [of_fpga_region] do_one_initcall+0x110/0x788 do_init_module+0x1dc/0x5c8 load_module+0x3c38/0x4cac init_module_from_file+0xd4/0x128 idempotent_init_module+0x2cc/0x528 __arm64_sys_finit_module+0xac/0x100 invoke_syscall+0x6c/0x258 el0_svc_common.constprop.0+0x160/0x22c do_el0_svc+0x44/0x5c el0_svc+0x48/0xb8 el0t_64_sync_handler+0x13c/0x158 el0t_64_sync+0x190/0x194 Code: f2fbffe1 a90157f4 12000802 aa0003f5 (38e16861) ---[ end trace 0000000000000000 ]--- Kernel panic - not syncing: Oops: Fatal exception
--- drivers/base/module.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/base/module.c +9 -5
@@ -66,27 +66,31 @@ int module_add_driver(struct module *mod, struct device_driver *drv) driver_name =make_driver_name (drv);if (!driver_name) { ret = -ENOMEM ; - goto out; + goto out_remove_kobj; }module_create_drivers_dir (mk);if (!mk->drivers_dir) { ret = -EINVAL ; - goto out; + goto out_free_driver_name; } ret =sysfs_create_link (mk->drivers_dir, &drv->p->kobj, driver_name);if (ret) - goto out; + goto out_remove_drivers_dir;kfree (driver_name);return 0 ; -out: -sysfs_remove_link (&drv->p->kobj,"module" ); + +out_remove_drivers_dir:sysfs_remove_link (mk->drivers_dir, driver_name); + +out_free_driver_name:kfree (driver_name); +out_remove_kobj: +sysfs_remove_link (&drv->p->kobj,"module" );return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 423/634 serial: 8250: omap: Cleanup on error in request_irq
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Markus Schneider-Pargmann <[email protected]>
[ Upstream commit 35e648a16018b747897be2ccc3ce95ff23237bb5 ]
If devm_request_irq fails, the code does not cleanup many things that were setup before. Instead of directly returning ret we should jump to err.
--- drivers/tty/serial/8250/8250_omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_omap.c +1 -1
@@ -1581,7 +1581,7 @@ static int omap8250_probe(struct platform_device *pdev) ret =devm_request_irq (&pdev->dev, up.port.irq, omap8250_irq,0 ,dev_name (&pdev->dev), priv);if (ret <0 ) -return ret; + goto err; priv->wakeirq =irq_of_parse_and_map (np,1 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 424/634 Coresight: Set correct cs_mode for TPDM to fix disable issue
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jie Gan <[email protected]>
[ Upstream commit 14f5fa9b5fcbe2b3d5098893aba6ad62254d2ef6 ]
The coresight_disable_source_sysfs function should verify the mode of the coresight device before disabling the source.
However, the mode for the TPDM device is always set to CS_MODE_DISABLED, resulting in the check consistently failing. As a result, TPDM cannot be properly disabled.
Configure CS_MODE_SYSFS/CS_MODE_PERF during the enablement. Configure CS_MODE_DISABLED during the disablement.
--- drivers/hwtracing/coresight/coresight-tpdm.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/hwtracing/coresight/coresight-tpdm.c +6 -0
@@ -449,6 +449,11 @@ static int tpdm_enable(struct coresight_device *csdev, struct perf_event *event,return -EBUSY ; } +if (!coresight_take_mode (csdev, mode)) { +spin_unlock (&drvdata->spinlock); +return -EBUSY ; + } +__tpdm_enable (drvdata); drvdata->enable = true;spin_unlock (&drvdata->spinlock);
@@ -506,6 +511,7 @@ static void tpdm_disable(struct coresight_device *csdev, }__tpdm_disable (drvdata); +coresight_set_mode (csdev,CS_MODE_DISABLED ); drvdata->enable = false;spin_unlock (&drvdata->spinlock);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 425/634 Coresight: Set correct cs_mode for dummy source to fix disable issue
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jie Gan <[email protected]>
[ Upstream commit e6b64cda393efd84709ab3df2e42d36d36d7553e ]
The coresight_disable_source_sysfs function should verify the mode of the coresight device before disabling the source. However, the mode for the dummy source device is always set to CS_MODE_DISABLED, resulting in the check consistently failing. As a result, dummy source cannot be properly disabled.
Configure CS_MODE_SYSFS/CS_MODE_PERF during the enablement. Configure CS_MODE_DISABLED during the disablement.
--- drivers/hwtracing/coresight/coresight-dummy.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/hwtracing/coresight/coresight-dummy.c +4 -0
@@ -23,6 +23,9 @@ DEFINE_CORESIGHT_DEVLIST(sink_devs, "dummy_sink");static int dummy_source_enable (struct coresight_device *csdev,struct perf_event *event,enum cs_mode mode) { +if (!coresight_take_mode (csdev, mode)) +return -EBUSY ; +dev_dbg (csdev->dev.parent,"Dummy source enabled\n" );return 0 ;
@@ -31,6 +34,7 @@ static int dummy_source_enable(struct coresight_device *csdev,static void dummy_source_disable (struct coresight_device *csdev,struct perf_event *event) { +coresight_set_mode (csdev,CS_MODE_DISABLED );dev_dbg (csdev->dev.parent,"Dummy source disabled\n" ); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 426/634 coresight: tmc: sg: Do not leak sg_table
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suzuki K Poulose <[email protected]>
[ Upstream commit c58dc5a1f886f2fcc1133746d0cbaa1fe7fd44ff ]
Running perf with cs_etm on Juno triggers the following kmemleak warning !
:~# cat /sys/kernel/debug/kmemleak unreferenced object 0xffffff8806b6d720 (size 96): comm "perf", pid 562, jiffies 4297810960 hex dump (first 32 bytes): 38 d8 13 07 88 ff ff ff 00 d0 9e 85 c0 ff ff ff 8............... 00 10 00 88 c0 ff ff ff 00 f0 ff f7 ff 00 00 00 ................ backtrace (crc 1dbf6e00): [<ffffffc08107381c>] kmemleak_alloc+0xbc/0xd8 [<ffffffc0802f9798>] kmalloc_trace_noprof+0x220/0x2e8 [<ffffffc07bb71948>] tmc_alloc_sg_table+0x48/0x208 [coresight_tmc] [<ffffffc07bb71cbc>] tmc_etr_alloc_sg_buf+0xac/0x240 [coresight_tmc] [<ffffffc07bb72538>] tmc_alloc_etr_buf.constprop.0+0x1f0/0x260 [coresight_tmc] [<ffffffc07bb7280c>] alloc_etr_buf.constprop.0.isra.0+0x74/0xa8 [coresight_tmc] [<ffffffc07bb72950>] tmc_alloc_etr_buffer+0x110/0x260 [coresight_tmc] [<ffffffc07bb38afc>] etm_setup_aux+0x204/0x3b0 [coresight] [<ffffffc08025837c>] rb_alloc_aux+0x20c/0x318 [<ffffffc08024dd84>] perf_mmap+0x2e4/0x7a0 [<ffffffc0802cceb0>] mmap_region+0x3b0/0xa08 [<ffffffc0802cd8a8>] do_mmap+0x3a0/0x500 [<ffffffc080295328>] vm_mmap_pgoff+0x100/0x1d0 [<ffffffc0802cadf8>] ksys_mmap_pgoff+0xb8/0x110 [<ffffffc080020688>] __arm64_sys_mmap+0x38/0x58 [<ffffffc080028fc0>] invoke_syscall.constprop.0+0x58/0x100
This due to the fact that we do not free the "sg_table" itself while freeing up the SG table and data pages. Fix this by freeing the sg_table in tmc_free_sg_table().
--- drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-tmc-etr.c +1 -1
@@ -261,6 +261,7 @@ void tmc_free_sg_table(struct tmc_sg_table *sg_table) {tmc_free_table_pages (sg_table);tmc_free_data_pages (sg_table); +kfree (sg_table); }EXPORT_SYMBOL_GPL (tmc_free_sg_table);
@@ -342,7 +343,6 @@ struct tmc_sg_table *tmc_alloc_sg_table(struct device *dev, rc =tmc_alloc_table_pages (sg_table);if (rc) {tmc_free_sg_table (sg_table); -kfree (sg_table);return ERR_PTR (rc); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 427/634 interconnect: icc-clk: Add missed num_nodes initialization
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit c801ed86840ec38b2a9bcafeee3d7c9e14c743f3 ]
With the new __counted_by annotation, the "num_nodes" struct member must be set before accessing the "nodes" array. This initialization was done in other places where a new struct icc_onecell_data is allocated, but this case in icc_clk_register() was missed. Set "num_nodes" after allocation.
--- drivers/interconnect/icc-clk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/interconnect/icc-clk.c +1 -2
@@ -87,6 +87,7 @@ struct icc_provider *icc_clk_register(struct device *dev, onecell =devm_kzalloc (dev,struct_size (onecell, nodes,2 * num_clocks),GFP_KERNEL );if (!onecell)return ERR_PTR (-ENOMEM ); + onecell->num_nodes =2 * num_clocks; qp =devm_kzalloc (dev,struct_size (qp, clocks, num_clocks),GFP_KERNEL );if (!qp)
@@ -133,8 +134,6 @@ struct icc_provider *icc_clk_register(struct device *dev, onecell->nodes[j++] = node; } - onecell->num_nodes = j; - ret =icc_provider_register (provider);if (ret) goto err;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 428/634 interconnect: qcom: sm8250: Enable sync_state
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit d3681b30214eb5885092ce4586f07237dc3c522f ]
Enable the generic icc sync_state callback to ensure interconnect votes are actually taken into account, instead of being forced to the maximum value.
--- drivers/interconnect/qcom/sm8350.c | 1 + 1 file changed, 1 insertion(+)
drivers/interconnect/qcom/sm8350.c +1 -0
@@ -1965,6 +1965,7 @@ static struct platform_driver qnoc_driver = { .driver = { .name = "qnoc-sm8350", .of_match_table = qnoc_of_match, + .sync_state = icc_sync_state, }, };module_platform_driver (qnoc_driver);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 429/634 cxl/pci: Fix to record only non-zero ranges
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yanfei Xu <[email protected]>
[ Upstream commit 55e268694e8b07026c88191f9b6949b6887d9ce3 ]
The function cxl_dvsec_rr_decode() retrieves and records DVSEC ranges into info->dvsec_range[], regardless of whether it is non-zero range, and the variable info->ranges indicates the number of non-zero ranges. However, in cxl_hdm_decode_init(), the validation for info->dvsec_range[] occurs in a for loop that iterates based on info->ranges. It may result in zero range to be validated but non-zero range not be validated, in turn, the number of allowed ranges is to be
0. Address it by only record non-zero ranges.
This fix is not urgent as it requires a configuration that zeroes out the first dvsec range while populating the second. This has not been observed, but it is theoretically possible. If this gets picked up for -stable, no harm done, but there is no urgency to backport.
--- drivers/cxl/core/pci.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/cxl/core/pci.c +1 -7
@@ -390,10 +390,6 @@ int cxl_dvsec_rr_decode(struct device *dev, int d, size |= temp &CXL_DVSEC_MEM_SIZE_LOW_MASK ;if (!size) { - info->dvsec_range[i] = (struct range ) { - .start =0 , - .end =CXL_RESOURCE_NONE , - };continue ; }
@@ -411,12 +407,10 @@ int cxl_dvsec_rr_decode(struct device *dev, int d, base |= temp &CXL_DVSEC_MEM_BASE_LOW_MASK ; - info->dvsec_range[i] = (struct range ) { + info->dvsec_range[ranges++] = (struct range ) { .start = base, .end = base + size -1 }; - - ranges++; } info->ranges = ranges;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 430/634 vdpa/mlx5: Fix invalid mr resource destroy
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dragos Tatulea <[email protected]>
[ Upstream commit dc12502905b7a3de9097ea6b98870470c2921e09 ]
Certain error paths from mlx5_vdpa_dev_add() can end up releasing mr resources which never got initialized in the first place.
This patch adds the missing check in mlx5_vdpa_destroy_mr_resources() to block releasing non-initialized mr resources.
Reference trace:
mlx5_core 0000:08:00.2: mlx5_vdpa_dev_add:3274:(pid 2700) warning: No mac address provisioned?
BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 140216067 P4D 0 Oops: 0000 [#1] PREEMPT SMP NOPTI CPU: 8 PID: 2700 Comm: vdpa Kdump: loaded Not tainted 5.14.0-496.el9.x86_64 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 RIP: 0010:vhost_iotlb_del_range+0xf/0xe0 [vhost_iotlb] Code: [...] RSP: 0018:ff1c823ac23077f0 EFLAGS: 00010246 RAX: ffffffffc1a21a60 RBX: ffffffff899567a0 RCX: 0000000000000000 RDX: ffffffffffffffff RSI: 0000000000000000 RDI: 0000000000000000 RBP: ff1bda1f7c21e800 R08: 0000000000000000 R09: ff1c823ac2307670 R10: ff1c823ac2307668 R11: ffffffff8a9e7b68 R12: 0000000000000000 R13: 0000000000000000 R14: ff1bda1f43e341a0 R15: 00000000ffffffea FS: 00007f56eba7c740(0000) GS:ff1bda269f800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 0000000104d90001 CR4: 0000000000771ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: ? show_trace_log_lvl+0x1c4/0x2df ? show_trace_log_lvl+0x1c4/0x2df ? mlx5_vdpa_free+0x3d/0x150 [mlx5_vdpa] ? __die_body.cold+0x8/0xd ? page_fault_oops+0x134/0x170 ? __irq_work_queue_local+0x2b/0xc0 ? irq_work_queue+0x2c/0x50 ? exc_page_fault+0x62/0x150 ? asm_exc_page_fault+0x22/0x30 ? __pfx_mlx5_vdpa_free+0x10/0x10 [mlx5_vdpa] ? vhost_iotlb_del_range+0xf/0xe0 [vhost_iotlb] mlx5_vdpa_free+0x3d/0x150 [mlx5_vdpa] vdpa_release_dev+0x1e/0x50 [vdpa] device_release+0x31/0x90 kobject_cleanup+0x37/0x130 mlx5_vdpa_dev_add+0x2d2/0x7a0 [mlx5_vdpa] vdpa_nl_cmd_dev_add_set_doit+0x277/0x4c0 [vdpa] genl_family_rcv_msg_doit+0xd9/0x130 genl_family_rcv_msg+0x14d/0x220 ? __pfx_vdpa_nl_cmd_dev_add_set_doit+0x10/0x10 [vdpa] ? _copy_to_user+0x1a/0x30 ? move_addr_to_user+0x4b/0xe0 genl_rcv_msg+0x47/0xa0 ? __import_iovec+0x46/0x150 ? __pfx_genl_rcv_msg+0x10/0x10 netlink_rcv_skb+0x54/0x100 genl_rcv+0x24/0x40 netlink_unicast+0x245/0x370 netlink_sendmsg+0x206/0x440 __sys_sendto+0x1dc/0x1f0 ? do_read_fault+0x10c/0x1d0 ? do_pte_missing+0x10d/0x190 __x64_sys_sendto+0x20/0x30 do_syscall_64+0x5c/0xf0 ? __count_memcg_events+0x4f/0xb0 ? mm_account_fault+0x6c/0x100 ? handle_mm_fault+0x116/0x270 ? do_user_addr_fault+0x1d6/0x6a0 ? do_syscall_64+0x6b/0xf0 ? clear_bhb_loop+0x25/0x80 ? clear_bhb_loop+0x25/0x80 ? clear_bhb_loop+0x25/0x80 ? clear_bhb_loop+0x25/0x80 ? clear_bhb_loop+0x25/0x80 entry_SYSCALL_64_after_hwframe+0x78/0x80
Message-Id: <[email protected]>
--- drivers/vdpa/mlx5/core/mr.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/vdpa/mlx5/core/mr.c +3 -0
@@ -581,6 +581,9 @@ static void mlx5_vdpa_show_mr_leaks(struct mlx5_vdpa_dev *mvdev)void mlx5_vdpa_destroy_mr_resources (struct mlx5_vdpa_dev *mvdev) { +if (!mvdev->res.valid) +return ; +for (int i =0 ; i <MLX5_VDPA_NUM_AS ; i++)mlx5_vdpa_update_mr (mvdev,NULL , i);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 431/634 vhost_vdpa: assign irq bypass producer token correctly
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Wang <[email protected]>
[ Upstream commit 02e9e9366fefe461719da5d173385b6685f70319 ]
We used to call irq_bypass_unregister_producer() in vhost_vdpa_setup_vq_irq() which is problematic as we don't know if the token pointer is still valid or not.
Actually, we use the eventfd_ctx as the token so the life cycle of the token should be bound to the VHOST_SET_VRING_CALL instead of vhost_vdpa_setup_vq_irq() which could be called by set_status().
Fixing this by setting up irq bypass producer's token when handling VHOST_SET_VRING_CALL and un-registering the producer before calling vhost_vring_ioctl() to prevent a possible use after free as eventfd could have been released in vhost_vring_ioctl(). And such registering and unregistering will only be done if DRIVER_OK is set.
Message-Id: <[email protected]>
--- drivers/vhost/vdpa.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/vhost/vdpa.c +13 -3
@@ -209,11 +209,9 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)if (irq <0 )return ; -irq_bypass_unregister_producer (&vq->call_ctx.producer);if (!vq->call_ctx.ctx)return ; - vq->call_ctx.producer.token = vq->call_ctx.ctx; vq->call_ctx.producer.irq = irq; ret =irq_bypass_register_producer (&vq->call_ctx.producer);if (unlikely (ret))
@@ -709,6 +707,14 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, vq->last_avail_idx = vq_state.split.avail_index; }break ; +case VHOST_SET_VRING_CALL : +if (vq->call_ctx.ctx) { +if (ops->get_status (vdpa) & +VIRTIO_CONFIG_S_DRIVER_OK ) +vhost_vdpa_unsetup_vq_irq (v, idx); + vq->call_ctx.producer.token =NULL ; + } +break ; } r =vhost_vring_ioctl (&v->vdev, cmd, argp);
@@ -747,13 +753,16 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, cb.callback = vhost_vdpa_virtqueue_cb; cb.private = vq; cb.trigger = vq->call_ctx.ctx; + vq->call_ctx.producer.token = vq->call_ctx.ctx; +if (ops->get_status (vdpa) & +VIRTIO_CONFIG_S_DRIVER_OK ) +vhost_vdpa_setup_vq_irq (v, idx); }else { cb.callback =NULL ; cb.private =NULL ; cb.trigger =NULL ; } ops->set_vq_cb (vdpa, idx, &cb); -vhost_vdpa_setup_vq_irq (v, idx);break ;case VHOST_SET_VRING_NUM :
@@ -1421,6 +1430,7 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)for (i =0 ; i < nvqs; i++) { vqs[i] = &v->vqs[i]; vqs[i]->handle_kick = handle_vq_kick; + vqs[i]->call_ctx.ctx =NULL ; }vhost_dev_init (dev, vqs, nvqs,0 ,0 ,0 , false, vhost_vdpa_process_iotlb_msg);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 432/634 ep93xx: clock: Fix off by one in ep93xx_div_recalc_rate()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit c7f06284a6427475e3df742215535ec3f6cd9662 ]
The psc->div[] array has psc->num_div elements. These values come from when we call clk_hw_register_div(). It's adc_divisors and ARRAY_SIZE(adc_divisors)) and so on. So this condition needs to be >= instead of > to prevent an out of bounds read.
--- arch/arm/mach-ep93xx/clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-ep93xx/clock.c +1 -1
@@ -359,7 +359,7 @@ static unsigned long ep93xx_div_recalc_rate(struct clk_hw *hw,u32 val =__raw_readl (psc->reg);u8 index = (val & psc->mask) >> psc->shift; -if (index > psc->num_div) +if (index >= psc->num_div)return 0 ;return DIV_ROUND_UP_ULL (parent_rate, psc->div[index]);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 433/634 Revert "dm: requeue IO if mapping table not yet available"
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit c8691cd0fc11197515ed148de0780d927bfca38b ]
This reverts commit fa247089de9936a46e290d4724cb5f0b845600f5.
The following sequence of commands causes a livelock - there will be workqueue process looping and consuming 100% CPU:
dmsetup create --notable test
truncate -s 1MiB testdata
losetup /dev/loop0 testdata
dmsetup load test --table '0 2048 linear /dev/loop0 0' dd if=/dev/zero of=/dev/dm-0 bs=16k count=1 conv=fdatasync
The livelock is caused by the commit fa247089de99. The commit claims that it fixes a race condition, however, it is unknown what the actual race condition is and what program is involved in the race condition.
When the inactive table is loaded, the nodes /dev/dm-0 and /sys/block/dm-0 are created. /dev/dm-0 has zero size at this point. When the device is suspended and resumed, the nodes /dev/mapper/test and /dev/disk/* are created.
If some program opens a block device before it is created by dmsetup or lvm, the program is buggy, so dm could just report an error as it used to do before.
--- drivers/md/dm-rq.c | 4 +++- drivers/md/dm.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/md/dm-rq.c +3 -1
@@ -496,8 +496,10 @@ static blk_status_t dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx, map =dm_get_live_table (md, &srcu_idx);if (unlikely (!map)) { +DMERR_LIMIT ("%s: mapping table unavailable, erroring io" , +dm_device_name (md));dm_put_live_table (md, srcu_idx); -return BLK_STS_RESOURCE ; +return BLK_STS_IOERR ; } ti =dm_table_find_target (map,0 );dm_put_live_table (md, srcu_idx);
drivers/md/dm.c +8 -3
@@ -1880,10 +1880,15 @@ static void dm_submit_bio(struct bio *bio)struct dm_table *map; map =dm_get_live_table (md, &srcu_idx); +if (unlikely (!map)) { +DMERR_LIMIT ("%s: mapping table unavailable, erroring io" , +dm_device_name (md)); +bio_io_error (bio); + goto out; + } -/* If suspended, or map not yet available, queue this IO for later */ -if (unlikely (test_bit (DMF_BLOCK_IO_FOR_SUSPEND , &md->flags)) || -unlikely (!map)) { +/* If suspended, queue this IO for later */ +if (unlikely (test_bit (DMF_BLOCK_IO_FOR_SUSPEND , &md->flags))) {if (bio->bi_opf &REQ_NOWAIT )bio_wouldblock_error (bio);else if (bio->bi_opf &REQ_RAHEAD )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 434/634 net: xilinx: axienet: Schedule NAPI in two steps
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Anderson <[email protected]>
[ Upstream commit ba0da2dc934ec5ac32bbeecbd0670da16ba03565 ]
As advised by Documentation/networking/napi.rst, masking IRQs after calling napi_schedule can be racy. Avoid this by only masking/scheduling if napi_schedule_prep returns true.
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +8 -6
@@ -1222,9 +1222,10 @@ static irqreturn_t axienet_tx_irq(int irq, void *_ndev)u32 cr = lp->tx_dma_cr; cr &= ~(XAXIDMA_IRQ_IOC_MASK |XAXIDMA_IRQ_DELAY_MASK ); -axienet_dma_out32 (lp,XAXIDMA_TX_CR_OFFSET , cr); - -napi_schedule (&lp->napi_tx); +if (napi_schedule_prep (&lp->napi_tx)) { +axienet_dma_out32 (lp,XAXIDMA_TX_CR_OFFSET , cr); +__napi_schedule (&lp->napi_tx); + } }return IRQ_HANDLED ;
@@ -1266,9 +1267,10 @@ static irqreturn_t axienet_rx_irq(int irq, void *_ndev)u32 cr = lp->rx_dma_cr; cr &= ~(XAXIDMA_IRQ_IOC_MASK |XAXIDMA_IRQ_DELAY_MASK ); -axienet_dma_out32 (lp,XAXIDMA_RX_CR_OFFSET , cr); - -napi_schedule (&lp->napi_rx); +if (napi_schedule_prep (&lp->napi_rx)) { +axienet_dma_out32 (lp,XAXIDMA_RX_CR_OFFSET , cr); +__napi_schedule (&lp->napi_rx); + } }return IRQ_HANDLED ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 435/634 net: xilinx: axienet: Fix packet counting
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Anderson <[email protected]>
[ Upstream commit 5a6caa2cfabb559309b5ce29ee7c8e9ce1a9a9df ]
axienet_free_tx_chain returns the number of DMA descriptors it's handled. However, axienet_tx_poll treats the return as the number of packets. When scatter-gather SKBs are enabled, a single packet may use multiple DMA descriptors, which causes incorrect packet counts. Fix this by explicitly keepting track of the number of packets processed as separate from the DMA descriptors.
Budget does not affect the number of Tx completions we can process for NAPI, so we use the ring size as the limit instead of budget. As we no longer return the number of descriptors processed to axienet_tx_poll, we now update tx_bd_ci in axienet_free_tx_chain.
--- .../net/ethernet/xilinx/xilinx_axienet_main.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +14 -9
@@ -674,15 +674,15 @@ static int axienet_device_reset(struct net_device *ndev)* * Would either be called after a successful transmit operation, or after * there was an error when setting up the chain. -* Returns the number of descriptors handled. +* Returns the number of packets handled. */ static int axienet_free_tx_chain (struct axienet_local *lp,u32 first_bd,int nr_bds,bool force,u32 *sizep,int budget) {struct axidma_bd *cur_p;unsigned int status; +int i, packets =0 ;dma_addr_t phys; -int i;for (i =0 ; i < nr_bds; i++) { cur_p = &lp->tx_bd_v[(first_bd + i) % lp->tx_bd_num];
@@ -701,8 +701,10 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, (cur_p->cntrl &XAXIDMA_BD_CTRL_LENGTH_MASK ), DMA_TO_DEVICE); -if (cur_p->skb && (status &XAXIDMA_BD_STS_COMPLETE_MASK )) +if (cur_p->skb && (status &XAXIDMA_BD_STS_COMPLETE_MASK )) {napi_consume_skb (cur_p->skb, budget); + packets++; + } cur_p->app0 =0 ; cur_p->app1 =0 ;
@@ -718,7 +720,13 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, *sizep += status &XAXIDMA_BD_STS_ACTUAL_LEN_MASK ; } -return i; +if (!force) { + lp->tx_bd_ci += i; +if (lp->tx_bd_ci >= lp->tx_bd_num) + lp->tx_bd_ci %= lp->tx_bd_num; + } + +return packets; }/**
@@ -891,13 +899,10 @@ static int axienet_tx_poll(struct napi_struct *napi, int budget)u32 size =0 ;int packets; - packets =axienet_free_tx_chain (lp, lp->tx_bd_ci, budget, false, &size, budget); + packets =axienet_free_tx_chain (lp, lp->tx_bd_ci, lp->tx_bd_num, false, + &size, budget);if (packets) { - lp->tx_bd_ci += packets; -if (lp->tx_bd_ci >= lp->tx_bd_num) - lp->tx_bd_ci %= lp->tx_bd_num; -u64_stats_update_begin (&lp->tx_stat_sync);u64_stats_add (&lp->tx_packets, packets);u64_stats_add (&lp->tx_bytes, size);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 436/634 netfilter: nf_reject_ipv6: fix nf_reject_ip6_tcphdr_put()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9c778fe48d20ef362047e3376dee56d77f8500d4 ]
syzbot reported that nf_reject_ip6_tcphdr_put() was possibly sending garbage on the four reserved tcp bits (th->res1)
Use skb_put_zero() to clear the whole TCP header,
as done in nf_reject_ip_tcphdr_put()
BUG: KMSAN: uninit-value in nf_reject_ip6_tcphdr_put+0x688/0x6c0 net/ipv6/netfilter/nf_reject_ipv6.c:255 nf_reject_ip6_tcphdr_put+0x688/0x6c0 net/ipv6/netfilter/nf_reject_ipv6.c:255 nf_send_reset6+0xd84/0x15b0 net/ipv6/netfilter/nf_reject_ipv6.c:344 nft_reject_inet_eval+0x3c1/0x880 net/netfilter/nft_reject_inet.c:48 expr_call_ops_eval net/netfilter/nf_tables_core.c:240 [inline] nft_do_chain+0x438/0x22a0 net/netfilter/nf_tables_core.c:288 nft_do_chain_inet+0x41a/0x4f0 net/netfilter/nft_chain_filter.c:161 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook include/linux/netfilter.h:269 [inline] NF_HOOK include/linux/netfilter.h:312 [inline] ipv6_rcv+0x29b/0x390 net/ipv6/ip6_input.c:310 __netif_receive_skb_one_core net/core/dev.c:5661 [inline] __netif_receive_skb+0x1da/0xa00 net/core/dev.c:5775 process_backlog+0x4ad/0xa50 net/core/dev.c:6108 __napi_poll+0xe7/0x980 net/core/dev.c:6772 napi_poll net/core/dev.c:6841 [inline] net_rx_action+0xa5a/0x19b0 net/core/dev.c:6963 handle_softirqs+0x1ce/0x800 kernel/softirq.c:554 __do_softirq+0x14/0x1a kernel/softirq.c:588 do_softirq+0x9a/0x100 kernel/softirq.c:455 __local_bh_enable_ip+0x9f/0xb0 kernel/softirq.c:382 local_bh_enable include/linux/bottom_half.h:33 [inline] rcu_read_unlock_bh include/linux/rcupdate.h:908 [inline] __dev_queue_xmit+0x2692/0x5610 net/core/dev.c:4450 dev_queue_xmit include/linux/netdevice.h:3105 [inline] neigh_resolve_output+0x9ca/0xae0 net/core/neighbour.c:1565 neigh_output include/net/neighbour.h:542 [inline] ip6_finish_output2+0x2347/0x2ba0 net/ipv6/ip6_output.c:141 __ip6_finish_output net/ipv6/ip6_output.c:215 [inline] ip6_finish_output+0xbb8/0x14b0 net/ipv6/ip6_output.c:226 NF_HOOK_COND include/linux/netfilter.h:303 [inline] ip6_output+0x356/0x620 net/ipv6/ip6_output.c:247 dst_output include/net/dst.h:450 [inline] NF_HOOK include/linux/netfilter.h:314 [inline] ip6_xmit+0x1ba6/0x25d0 net/ipv6/ip6_output.c:366 inet6_csk_xmit+0x442/0x530 net/ipv6/inet6_connection_sock.c:135 __tcp_transmit_skb+0x3b07/0x4880 net/ipv4/tcp_output.c:1466 tcp_transmit_skb net/ipv4/tcp_output.c:1484 [inline] tcp_connect+0x35b6/0x7130 net/ipv4/tcp_output.c:4143 tcp_v6_connect+0x1bcc/0x1e40 net/ipv6/tcp_ipv6.c:333 __inet_stream_connect+0x2ef/0x1730 net/ipv4/af_inet.c:679 inet_stream_connect+0x6a/0xd0 net/ipv4/af_inet.c:750 __sys_connect_file net/socket.c:2061 [inline] __sys_connect+0x606/0x690 net/socket.c:2078 __do_sys_connect net/socket.c:2088 [inline] __se_sys_connect net/socket.c:2085 [inline] __x64_sys_connect+0x91/0xe0 net/socket.c:2085 x64_sys_call+0x27a5/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:43 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was stored to memory at:
nf_reject_ip6_tcphdr_put+0x60c/0x6c0 net/ipv6/netfilter/nf_reject_ipv6.c:249 nf_send_reset6+0xd84/0x15b0 net/ipv6/netfilter/nf_reject_ipv6.c:344 nft_reject_inet_eval+0x3c1/0x880 net/netfilter/nft_reject_inet.c:48 expr_call_ops_eval net/netfilter/nf_tables_core.c:240 [inline] nft_do_chain+0x438/0x22a0 net/netfilter/nf_tables_core.c:288 nft_do_chain_inet+0x41a/0x4f0 net/netfilter/nft_chain_filter.c:161 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook include/linux/netfilter.h:269 [inline] NF_HOOK include/linux/netfilter.h:312 [inline] ipv6_rcv+0x29b/0x390 net/ipv6/ip6_input.c:310 __netif_receive_skb_one_core net/core/dev.c:5661 [inline] __netif_receive_skb+0x1da/0xa00 net/core/dev.c:5775 process_backlog+0x4ad/0xa50 net/core/dev.c:6108 __napi_poll+0xe7/0x980 net/core/dev.c:6772 napi_poll net/core/dev.c:6841 [inline] net_rx_action+0xa5a/0x19b0 net/core/dev.c:6963 handle_softirqs+0x1ce/0x800 kernel/softirq.c:554 __do_softirq+0x14/0x1a kernel/softirq.c:588
Uninit was stored to memory at:
nf_reject_ip6_tcphdr_put+0x2ca/0x6c0 net/ipv6/netfilter/nf_reject_ipv6.c:231 nf_send_reset6+0xd84/0x15b0 net/ipv6/netfilter/nf_reject_ipv6.c:344 nft_reject_inet_eval+0x3c1/0x880 net/netfilter/nft_reject_inet.c:48 expr_call_ops_eval net/netfilter/nf_tables_core.c:240 [inline] nft_do_chain+0x438/0x22a0 net/netfilter/nf_tables_core.c:288 nft_do_chain_inet+0x41a/0x4f0 net/netfilter/nft_chain_filter.c:161 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook include/linux/netfilter.h:269 [inline] NF_HOOK include/linux/netfilter.h:312 [inline] ipv6_rcv+0x29b/0x390 net/ipv6/ip6_input.c:310 __netif_receive_skb_one_core net/core/dev.c:5661 [inline] __netif_receive_skb+0x1da/0xa00 net/core/dev.c:5775 process_backlog+0x4ad/0xa50 net/core/dev.c:6108 __napi_poll+0xe7/0x980 net/core/dev.c:6772 napi_poll net/core/dev.c:6841 [inline] net_rx_action+0xa5a/0x19b0 net/core/dev.c:6963 handle_softirqs+0x1ce/0x800 kernel/softirq.c:554 __do_softirq+0x14/0x1a kernel/softirq.c:588
Uninit was created at:
slab_post_alloc_hook mm/slub.c:3998 [inline] slab_alloc_node mm/slub.c:4041 [inline] kmem_cache_alloc_node_noprof+0x6bf/0xb80 mm/slub.c:4084 kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:583 __alloc_skb+0x363/0x7b0 net/core/skbuff.c:674 alloc_skb include/linux/skbuff.h:1320 [inline] nf_send_reset6+0x98d/0x15b0 net/ipv6/netfilter/nf_reject_ipv6.c:327 nft_reject_inet_eval+0x3c1/0x880 net/netfilter/nft_reject_inet.c:48 expr_call_ops_eval net/netfilter/nf_tables_core.c:240 [inline] nft_do_chain+0x438/0x22a0 net/netfilter/nf_tables_core.c:288 nft_do_chain_inet+0x41a/0x4f0 net/netfilter/nft_chain_filter.c:161 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook include/linux/netfilter.h:269 [inline] NF_HOOK include/linux/netfilter.h:312 [inline] ipv6_rcv+0x29b/0x390 net/ipv6/ip6_input.c:310 __netif_receive_skb_one_core net/core/dev.c:5661 [inline] __netif_receive_skb+0x1da/0xa00 net/core/dev.c:5775 process_backlog+0x4ad/0xa50 net/core/dev.c:6108 __napi_poll+0xe7/0x980 net/core/dev.c:6772 napi_poll net/core/dev.c:6841 [inline] net_rx_action+0xa5a/0x19b0 net/core/dev.c:6963 handle_softirqs+0x1ce/0x800 kernel/softirq.c:554 __do_softirq+0x14/0x1a kernel/softirq.c:588
--- net/ipv6/netfilter/nf_reject_ipv6.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
net/ipv6/netfilter/nf_reject_ipv6.c +2 -12
@@ -223,33 +223,23 @@ void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb, const struct tcphdr *oth, unsigned int otcplen) { struct tcphdr *tcph; -int needs_ack;skb_reset_transport_header (nskb); - tcph =skb_put (nskb,sizeof (struct tcphdr )); + tcph =skb_put_zero (nskb,sizeof (struct tcphdr ));/* Truncate to length (no data) */ tcph->doff =sizeof (struct tcphdr )/4 ; tcph->source = oth->dest; tcph->dest = oth->source;if (oth->ack) { - needs_ack =0 ; tcph->seq = oth->ack_seq; - tcph->ack_seq =0 ; }else { - needs_ack =1 ; tcph->ack_seq =htonl (ntohl (oth->seq) + oth->syn + oth->fin + otcplen - (oth->doff<<2 )); - tcph->seq =0 ; + tcph->ack =1 ; } -/* Reset flags */ - ((u_int8_t *)tcph)[13 ] =0 ; tcph->rst =1 ; - tcph->ack = needs_ack; - tcph->window =0 ; - tcph->urg_ptr =0 ; - tcph->check =0 ;/* Adjust TCP checksum */ tcph->check = csum_ipv6_magic(&ipv6_hdr(nskb)->saddr,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 437/634 net: seeq: Fix use after free vulnerability in ether3 Driver Due to Race Condition
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kaixin Wang <[email protected]>
[ Upstream commit b5109b60ee4fcb2f2bb24f589575e10cc5283ad4 ]
In the ether3_probe function, a timer is initialized with a callback function ether3_ledoff, bound to &prev(dev)->timer. Once the timer is started, there is a risk of a race condition if the module or device is removed, triggering the ether3_remove function to perform cleanup. The sequence of operations that may lead to a UAF bug is as follows:
CPU0 CPU1
| ether3_ledoff
ether3_remove |
free_netdev(dev); |
put_devic |
kfree(dev); |
| ether3_outw(priv(dev)->regs.config2 |= CFG2_CTRLO, REG_CONFIG2);
| // use devFix it by ensuring that the timer is canceled before proceeding with the cleanup in ether3_remove.
--- drivers/net/ethernet/seeq/ether3.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/seeq/ether3.c +2 -0
@@ -847,9 +847,11 @@ static void ether3_remove(struct expansion_card *ec) {struct net_device *dev =ecard_get_drvdata (ec); +ether3_outw (priv (dev)->regs.config2 |=CFG2_CTRLO ,REG_CONFIG2 );ecard_set_drvdata (ec,NULL );unregister_netdev (dev); +del_timer_sync (&priv (dev)->timer);free_netdev (dev);ecard_release_resources (ec); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 438/634 net: ipv6: select DST_CACHE from IPV6_RPL_LWTUNNEL
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 93c21077bb9ba08807c459982d440dbbee4c7af3 ]
The rpl sr tunnel code contains calls to dst_cache_*() which are only present when the dst cache is built.
Select DST_CACHE to build the dst cache, similar to other kconfig options in the same file.
Compiling the rpl sr tunnel without DST_CACHE will lead to linker errors.
--- net/ipv6/Kconfig | 1 + 1 file changed, 1 insertion(+)
net/ipv6/Kconfig +1 -0
@@ -323,6 +323,7 @@ config IPV6_RPL_LWTUNNEL bool "IPv6: RPL Source Routing Header support" depends on IPV6 select LWTUNNEL + select DST_CACHE help Support for RFC6554 RPL Source Routing Header using the lightweight tunnels mechanism.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 439/634 tcp: check skb is non-NULL in tcp_rto_delta_us()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Hunt <[email protected]>
[ Upstream commit c8770db2d54437a5f49417ae7b46f7de23d14db6 ]
We have some machines running stock Ubuntu 20.04.6 which is their 5.4.0-174-generic kernel that are running ceph and recently hit a null ptr dereference in tcp_rearm_rto(). Initially hitting it from the TLP path, but then later we also saw it getting hit from the RACK case as well. Here are examples of the oops messages we saw in each of those cases:
Jul 26 15:05:02 rx [11061395.780353] BUG: kernel NULL pointer dereference, address: 0000000000000020 Jul 26 15:05:02 rx [11061395.787572] #PF: supervisor read access in kernel mode Jul 26 15:05:02 rx [11061395.792971] #PF: error_code(0x0000) - not-present page Jul 26 15:05:02 rx [11061395.798362] PGD 0 P4D 0 Jul 26 15:05:02 rx [11061395.801164] Oops: 0000 [#1] SMP NOPTI Jul 26 15:05:02 rx [11061395.805091] CPU: 0 PID: 9180 Comm: msgr-worker-1 Tainted: G W 5.4.0-174-generic #193-Ubuntu Jul 26 15:05:02 rx [11061395.814996] Hardware name: Supermicro SMC 2x26 os-gen8 64C NVME-Y 256G/H12SSW-NTR, BIOS 2.5.V1.2U.NVMe.UEFI 05/09/2023 Jul 26 15:05:02 rx [11061395.825952] RIP: 0010:tcp_rearm_rto+0xe4/0x160 Jul 26 15:05:02 rx [11061395.830656] Code: 87 ca 04 00 00 00 5b 41 5c 41 5d 5d c3 c3 49 8b bc 24 40 06 00 00 eb 8d 48 bb cf f7 53 e3 a5 9b c4 20 4c 89 ef e8 0c fe 0e 00 <48> 8b 78 20 48 c1 ef 03 48 89 f8 41 8b bc 24 80 04 00 00 48 f7 e3 Jul 26 15:05:02 rx [11061395.849665] RSP: 0018:ffffb75d40003e08 EFLAGS: 00010246 Jul 26 15:05:02 rx [11061395.855149] RAX: 0000000000000000 RBX: 20c49ba5e353f7cf RCX: 0000000000000000 Jul 26 15:05:02 rx [11061395.862542] RDX: 0000000062177c30 RSI: 000000000000231c RDI: ffff9874ad283a60 Jul 26 15:05:02 rx [11061395.869933] RBP: ffffb75d40003e20 R08: 0000000000000000 R09: ffff987605e20aa8 Jul 26 15:05:02 rx [11061395.877318] R10: ffffb75d40003f00 R11: ffffb75d4460f740 R12: ffff9874ad283900 Jul 26 15:05:02 rx [11061395.884710] R13: ffff9874ad283a60 R14: ffff9874ad283980 R15: ffff9874ad283d30 Jul 26 15:05:02 rx [11061395.892095] FS: 00007f1ef4a2e700(0000) GS:ffff987605e00000(0000) knlGS:0000000000000000 Jul 26 15:05:02 rx [11061395.900438] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 Jul 26 15:05:02 rx [11061395.906435] CR2: 0000000000000020 CR3: 0000003e450ba003 CR4: 0000000000760ef0 Jul 26 15:05:02 rx [11061395.913822] PKRU: 55555554 Jul 26 15:05:02 rx [11061395.916786] Call Trace: Jul 26 15:05:02 rx [11061395.919488] Jul 26 15:05:02 rx [11061395.921765] ? show_regs.cold+0x1a/0x1f Jul 26 15:05:02 rx [11061395.925859] ? __die+0x90/0xd9 Jul 26 15:05:02 rx [11061395.929169] ? no_context+0x196/0x380 Jul 26 15:05:02 rx [11061395.933088] ? ip6_protocol_deliver_rcu+0x4e0/0x4e0 Jul 26 15:05:02 rx [11061395.938216] ? ip6_sublist_rcv_finish+0x3d/0x50 Jul 26 15:05:02 rx [11061395.943000] ? __bad_area_nosemaphore+0x50/0x1a0 Jul 26 15:05:02 rx [11061395.947873] ? bad_area_nosemaphore+0x16/0x20 Jul 26 15:05:02 rx [11061395.952486] ? do_user_addr_fault+0x267/0x450 Jul 26 15:05:02 rx [11061395.957104] ? ipv6_list_rcv+0x112/0x140 Jul 26 15:05:02 rx [11061395.961279] ? __do_page_fault+0x58/0x90 Jul 26 15:05:02 rx [11061395.965458] ? do_page_fault+0x2c/0xe0 Jul 26 15:05:02 rx [11061395.969465] ? page_fault+0x34/0x40 Jul 26 15:05:02 rx [11061395.973217] ? tcp_rearm_rto+0xe4/0x160 Jul 26 15:05:02 rx [11061395.977313] ? tcp_rearm_rto+0xe4/0x160 Jul 26 15:05:02 rx [11061395.981408] tcp_send_loss_probe+0x10b/0x220 Jul 26 15:05:02 rx [11061395.985937] tcp_write_timer_handler+0x1b4/0x240 Jul 26 15:05:02 rx [11061395.990809] tcp_write_timer+0x9e/0xe0 Jul 26 15:05:02 rx [11061395.994814] ? tcp_write_timer_handler+0x240/0x240 Jul 26 15:05:02 rx [11061395.999866] call_timer_fn+0x32/0x130 Jul 26 15:05:02 rx [11061396.003782] __run_timers.part.0+0x180/0x280 Jul 26 15:05:02 rx [11061396.008309] ? recalibrate_cpu_khz+0x10/0x10 Jul 26 15:05:02 rx [11061396.012841] ? native_x2apic_icr_write+0x30/0x30 Jul 26 15:05:02 rx [11061396.017718] ? lapic_next_event+0x21/0x30 Jul 26 15:05:02 rx [11061396.021984] ? clockevents_program_event+0x8f/0xe0 Jul 26 15:05:02 rx [11061396.027035] run_timer_softirq+0x2a/0x50 Jul 26 15:05:02 rx [11061396.031212] __do_softirq+0xd1/0x2c1 Jul 26 15:05:02 rx [11061396.035044] do_softirq_own_stack+0x2a/0x40 Jul 26 15:05:02 rx [11061396.039480] Jul 26 15:05:02 rx [11061396.041840] do_softirq.part.0+0x46/0x50 Jul 26 15:05:02 rx [11061396.046022] __local_bh_enable_ip+0x50/0x60 Jul 26 15:05:02 rx [11061396.050460] _raw_spin_unlock_bh+0x1e/0x20 Jul 26 15:05:02 rx [11061396.054817] nf_conntrack_tcp_packet+0x29e/0xbe0 [nf_conntrack] Jul 26 15:05:02 rx [11061396.060994] ? get_l4proto+0xe7/0x190 [nf_conntrack] Jul 26 15:05:02 rx [11061396.066220] nf_conntrack_in+0xe9/0x670 [nf_conntrack] Jul 26 15:05:02 rx [11061396.071618] ipv6_conntrack_local+0x14/0x20 [nf_conntrack] Jul 26 15:05:02 rx [11061396.077356] nf_hook_slow+0x45/0xb0 Jul 26 15:05:02 rx [11061396.081098] ip6_xmit+0x3f0/0x5d0 Jul 26 15:05:02 rx [11061396.084670] ? ipv6_anycast_cleanup+0x50/0x50 Jul 26 15:05:02 rx [11061396.089282] ? __sk_dst_check+0x38/0x70 Jul 26 15:05:02 rx [11061396.093381] ? inet6_csk_route_socket+0x13b/0x200 Jul 26 15:05:02 rx [11061396.098346] inet6_csk_xmit+0xa7/0xf0 Jul 26 15:05:02 rx [11061396.102263] __tcp_transmit_skb+0x550/0xb30 Jul 26 15:05:02 rx [11061396.106701] tcp_write_xmit+0x3c6/0xc20 Jul 26 15:05:02 rx [11061396.110792] ? __alloc_skb+0x98/0x1d0 Jul 26 15:05:02 rx [11061396.114708] __tcp_push_pending_frames+0x37/0x100 Jul 26 15:05:02 rx [11061396.119667] tcp_push+0xfd/0x100 Jul 26 15:05:02 rx [11061396.123150] tcp_sendmsg_locked+0xc70/0xdd0 Jul 26 15:05:02 rx [11061396.127588] tcp_sendmsg+0x2d/0x50 Jul 26 15:05:02 rx [11061396.131245] inet6_sendmsg+0x43/0x70 Jul 26 15:05:02 rx [11061396.135075] __sock_sendmsg+0x48/0x70 Jul 26 15:05:02 rx [11061396.138994] ____sys_sendmsg+0x212/0x280 Jul 26 15:05:02 rx [11061396.143172] ___sys_sendmsg+0x88/0xd0 Jul 26 15:05:02 rx [11061396.147098] ? __seccomp_filter+0x7e/0x6b0 Jul 26 15:05:02 rx [11061396.151446] ? __switch_to+0x39c/0x460 Jul 26 15:05:02 rx [11061396.155453] ? __switch_to_asm+0x42/0x80 Jul 26 15:05:02 rx [11061396.159636] ? __switch_to_asm+0x5a/0x80 Jul 26 15:05:02 rx [11061396.163816] __sys_sendmsg+0x5c/0xa0 Jul 26 15:05:02 rx [11061396.167647] __x64_sys_sendmsg+0x1f/0x30 Jul 26 15:05:02 rx [11061396.171832] do_syscall_64+0x57/0x190 Jul 26 15:05:02 rx [11061396.175748] entry_SYSCALL_64_after_hwframe+0x5c/0xc1 Jul 26 15:05:02 rx [11061396.181055] RIP: 0033:0x7f1ef692618d Jul 26 15:05:02 rx [11061396.184893] Code: 28 89 54 24 1c 48 89 74 24 10 89 7c 24 08 e8 ca ee ff ff 8b 54 24 1c 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 2f 44 89 c7 48 89 44 24 08 e8 fe ee ff ff 48 Jul 26 15:05:02 rx [11061396.203889] RSP: 002b:00007f1ef4a26aa0 EFLAGS: 00000293 ORIG_RAX: 000000000000002e Jul 26 15:05:02 rx [11061396.211708] RAX: ffffffffffffffda RBX: 000000000000084b RCX: 00007f1ef692618d Jul 26 15:05:02 rx [11061396.219091] RDX: 0000000000004000 RSI: 00007f1ef4a26b10 RDI: 0000000000000275 Jul 26 15:05:02 rx [11061396.226475] RBP: 0000000000004000 R08: 0000000000000000 R09: 0000000000000020 Jul 26 15:05:02 rx [11061396.233859] R10: 0000000000000000 R11: 0000000000000293 R12: 000000000000084b Jul 26 15:05:02 rx [11061396.241243] R13: 00007f1ef4a26b10 R14: 0000000000000275 R15: 000055592030f1e8 Jul 26 15:05:02 rx [11061396.248628] Modules linked in: vrf bridge stp llc vxlan ip6_udp_tunnel udp_tunnel nls_iso8859_1 amd64_edac_mod edac_mce_amd kvm_amd kvm crct10dif_pclmul ghash_clmulni_intel aesni_intel crypto_simd cryptd glue_helper wmi_bmof ipmi_ssif input_leds joydev rndis_host cdc_ether usbnet mii ast drm_vram_helper ttm drm_kms_helper i2c_algo_bit fb_sys_fops syscopyarea sysfillrect sysimgblt ccp mac_hid ipmi_si ipmi_devintf ipmi_msghandler nft_ct sch_fq_codel nf_tables_set nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nf_tables nfnetlink ramoops reed_solomon efi_pstore drm ip_tables x_tables autofs4 raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid0 multipath linear mlx5_ib ib_uverbs ib_core raid1 mlx5_core hid_generic pci_hyperv_intf crc32_pclmul tls usbhid ahci mlxfw bnxt_en libahci hid nvme i2c_piix4 nvme_core wmi Jul 26 15:05:02 rx [11061396.324334] CR2: 0000000000000020 Jul 26 15:05:02 rx [11061396.327944] ---[ end trace 68a2b679d1cfb4f1 ]--- Jul 26 15:05:02 rx [11061396.433435] RIP: 0010:tcp_rearm_rto+0xe4/0x160 Jul 26 15:05:02 rx [11061396.438137] Code: 87 ca 04 00 00 00 5b 41 5c 41 5d 5d c3 c3 49 8b bc 24 40 06 00 00 eb 8d 48 bb cf f7 53 e3 a5 9b c4 20 4c 89 ef e8 0c fe 0e 00 <48> 8b 78 20 48 c1 ef 03 48 89 f8 41 8b bc 24 80 04 00 00 48 f7 e3 Jul 26 15:05:02 rx [11061396.457144] RSP: 0018:ffffb75d40003e08 EFLAGS: 00010246 Jul 26 15:05:02 rx [11061396.462629] RAX: 0000000000000000 RBX: 20c49ba5e353f7cf RCX: 0000000000000000 Jul 26 15:05:02 rx [11061396.470012] RDX: 0000000062177c30 RSI: 000000000000231c RDI: ffff9874ad283a60 Jul 26 15:05:02 rx [11061396.477396] RBP: ffffb75d40003e20 R08: 0000000000000000 R09: ffff987605e20aa8 Jul 26 15:05:02 rx [11061396.484779] R10: ffffb75d40003f00 R11: ffffb75d4460f740 R12: ffff9874ad283900 Jul 26 15:05:02 rx [11061396.492164] R13: ffff9874ad283a60 R14: ffff9874ad283980 R15: ffff9874ad283d30 Jul 26 15:05:02 rx [11061396.499547] FS: 00007f1ef4a2e700(0000) GS:ffff987605e00000(0000) knlGS:0000000000000000 Jul 26 15:05:02 rx [11061396.507886] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 Jul 26 15:05:02 rx [11061396.513884] CR2: 0000000000000020 CR3: 0000003e450ba003 CR4: 0000000000760ef0 Jul 26 15:05:02 rx [11061396.521267] PKRU: 55555554 Jul 26 15:05:02 rx [11061396.524230] Kernel panic - not syncing: Fatal exception in interrupt Jul 26 15:05:02 rx [11061396.530885] Kernel Offset: 0x1b200000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff) Jul 26 15:05:03 rx [11061396.660181] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---
After we hit this we disabled TLP by setting tcp_early_retrans to 0 and then hit the crash in the RACK case:
Aug 7 07:26:16 rx [1006006.265582] BUG: kernel NULL pointer dereference, address: 0000000000000020
Aug 7 07:26:16 rx [1006006.272719] #PF: supervisor read access in kernel mode
Aug 7 07:26:16 rx [1006006.278030] #PF: error_code(0x0000) - not-present page
Aug 7 07:26:16 rx [1006006.283343] PGD 0 P4D 0
Aug 7 07:26:16 rx [1006006.286057] Oops: 0000 [#1] SMP NOPTI
Aug 7 07:26:16 rx [1006006.289896] CPU: 5 PID: 0 Comm: swapper/5 Tainted: G W 5.4.0-174-generic #193-Ubuntu
Aug 7 07:26:16 rx [1006006.299107] Hardware name: Supermicro SMC 2x26 os-gen8 64C NVME-Y 256G/H12SSW-NTR, BIOS 2.5.V1.2U.NVMe.UEFI 05/09/2023
Aug 7 07:26:16 rx [1006006.309970] RIP: 0010:tcp_rearm_rto+0xe4/0x160
Aug 7 07:26:16 rx [1006006.314584] Code: 87 ca 04 00 00 00 5b 41 5c 41 5d 5d c3 c3 49 8b bc 24 40 06 00 00 eb 8d 48 bb cf f7 53 e3 a5 9b c4 20 4c 89 ef e8 0c fe 0e 00 <48> 8b 78 20 48 c1 ef 03 48 89 f8 41 8b bc 24 80 04 00 00 48 f7 e3
Aug 7 07:26:16 rx [1006006.333499] RSP: 0018:ffffb42600a50960 EFLAGS: 00010246
Aug 7 07:26:16 rx [1006006.338895] RAX: 0000000000000000 RBX: 20c49ba5e353f7cf RCX: 0000000000000000
Aug 7 07:26:16 rx [1006006.346193] RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff92d687ed8160
Aug 7 07:26:16 rx [1006006.353489] RBP: ffffb42600a50978 R08: 0000000000000000 R09: 00000000cd896dcc
Aug 7 07:26:16 rx [1006006.360786] R10: ffff92dc3404f400 R11: 0000000000000001 R12: ffff92d687ed8000
Aug 7 07:26:16 rx [1006006.368084] R13: ffff92d687ed8160 R14: 00000000cd896dcc R15: 00000000cd8fca81
Aug 7 07:26:16 rx [1006006.375381] FS: 0000000000000000(0000) GS:ffff93158ad40000(0000) knlGS:0000000000000000
Aug 7 07:26:16 rx [1006006.383632] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Aug 7 07:26:16 rx [1006006.389544] CR2: 0000000000000020 CR3: 0000003e775ce006 CR4: 0000000000760ee0
Aug 7 07:26:16 rx [1006006.396839] PKRU: 55555554
Aug 7 07:26:16 rx [1006006.399717] Call Trace:
Aug 7 07:26:16 rx [1006006.402335]
Aug 7 07:26:16 rx [1006006.404525] ? show_regs.cold+0x1a/0x1f
Aug 7 07:26:16 rx [1006006.408532] ? __die+0x90/0xd9
Aug 7 07:26:16 rx [1006006.411760] ? no_context+0x196/0x380
Aug 7 07:26:16 rx [1006006.415599] ? __bad_area_nosemaphore+0x50/0x1a0
Aug 7 07:26:16 rx [1006006.420392] ? _raw_spin_lock+0x1e/0x30
Aug 7 07:26:16 rx [1006006.424401] ? bad_area_nosemaphore+0x16/0x20
Aug 7 07:26:16 rx [1006006.428927] ? do_user_addr_fault+0x267/0x450
Aug 7 07:26:16 rx [1006006.433450] ? __do_page_fault+0x58/0x90
Aug 7 07:26:16 rx [1006006.437542] ? do_page_fault+0x2c/0xe0
Aug 7 07:26:16 rx [1006006.441470] ? page_fault+0x34/0x40
Aug 7 07:26:16 rx [1006006.445134] ? tcp_rearm_rto+0xe4/0x160
Aug 7 07:26:16 rx [1006006.449145] tcp_ack+0xa32/0xb30
Aug 7 07:26:16 rx [1006006.452542] tcp_rcv_established+0x13c/0x670
Aug 7 07:26:16 rx [1006006.456981] ? sk_filter_trim_cap+0x48/0x220
Aug 7 07:26:16 rx [1006006.461419] tcp_v6_do_rcv+0xdb/0x450
Aug 7 07:26:16 rx [1006006.465257] tcp_v6_rcv+0xc2b/0xd10
Aug 7 07:26:16 rx [1006006.468918] ip6_protocol_deliver_rcu+0xd3/0x4e0
Aug 7 07:26:16 rx [1006006.473706] ip6_input_finish+0x15/0x20
Aug 7 07:26:16 rx [1006006.477710] ip6_input+0xa2/0xb0
Aug 7 07:26:16 rx [1006006.481109] ? ip6_protocol_deliver_rcu+0x4e0/0x4e0
Aug 7 07:26:16 rx [1006006.486151] ip6_sublist_rcv_finish+0x3d/0x50
Aug 7 07:26:16 rx [1006006.490679] ip6_sublist_rcv+0x1aa/0x250
Aug 7 07:26:16 rx [1006006.494779] ? ip6_rcv_finish_core.isra.0+0xa0/0xa0
Aug 7 07:26:16 rx [1006006.499828] ipv6_list_rcv+0x112/0x140
Aug 7 07:26:16 rx [1006006.503748] __netif_receive_skb_list_core+0x1a4/0x250
Aug 7 07:26:16 rx [1006006.509057] netif_receive_skb_list_internal+0x1a1/0x2b0
Aug 7 07:26:16 rx [1006006.514538] gro_normal_list.part.0+0x1e/0x40
Aug 7 07:26:16 rx [1006006.519068] napi_complete_done+0x91/0x130
Aug 7 07:26:16 rx [1006006.523352] mlx5e_napi_poll+0x18e/0x610 [mlx5_core]
Aug 7 07:26:16 rx [1006006.528481] net_rx_action+0x142/0x390
Aug 7 07:26:16 rx [1006006.532398] __do_softirq+0xd1/0x2c1
Aug 7 07:26:16 rx [1006006.536142] irq_exit+0xae/0xb0
Aug 7 07:26:16 rx [1006006.539452] do_IRQ+0x5a/0xf0
Aug 7 07:26:16 rx [1006006.542590] common_interrupt+0xf/0xf
Aug 7 07:26:16 rx [1006006.546421]
Aug 7 07:26:16 rx [1006006.548695] RIP: 0010:native_safe_halt+0xe/0x10
Aug 7 07:26:16 rx [1006006.553399] Code: 7b ff ff ff eb bd 90 90 90 90 90 90 e9 07 00 00 00 0f 00 2d 36 2c 50 00 f4 c3 66 90 e9 07 00 00 00 0f 00 2d 26 2c 50 00 fb f4 90 0f 1f 44 00 00 55 48 89 e5 41 55 41 54 53 e8 dd 5e 61 ff 65
Aug 7 07:26:16 rx [1006006.572309] RSP: 0018:ffffb42600177e70 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffc2
Aug 7 07:26:16 rx [1006006.580040] RAX: ffffffff8ed08b20 RBX: 0000000000000005 RCX: 0000000000000001
Aug 7 07:26:16 rx [1006006.587337] RDX: 00000000f48eeca2 RSI: 0000000000000082 RDI: 0000000000000082
Aug 7 07:26:16 rx [1006006.594635] RBP: ffffb42600177e90 R08: 0000000000000000 R09: 000000000000020f
Aug 7 07:26:16 rx [1006006.601931] R10: 0000000000100000 R11: 0000000000000000 R12: 0000000000000005
Aug 7 07:26:16 rx [1006006.609229] R13: ffff93157deb5f00 R14: 0000000000000000 R15: 0000000000000000
Aug 7 07:26:16 rx [1006006.616530] ? __cpuidle_text_start+0x8/0x8
Aug 7 07:26:16 rx [1006006.620886] ? default_idle+0x20/0x140
Aug 7 07:26:16 rx [1006006.624804] arch_cpu_idle+0x15/0x20
Aug 7 07:26:16 rx [1006006.628545] default_idle_call+0x23/0x30
Aug 7 07:26:16 rx [1006006.632640] do_idle+0x1fb/0x270
Aug 7 07:26:16 rx [1006006.636035] cpu_startup_entry+0x20/0x30
Aug 7 07:26:16 rx [1006006.640126] start_secondary+0x178/0x1d0
Aug 7 07:26:16 rx [1006006.644218] secondary_startup_64+0xa4/0xb0
Aug 7 07:26:17 rx [1006006.648568] Modules linked in: vrf bridge stp llc vxlan ip6_udp_tunnel udp_tunnel nls_iso8859_1 nft_ct amd64_edac_mod edac_mce_amd kvm_amd kvm crct10dif_pclmul ghash_clmulni_intel aesni_intel crypto_simd cryptd glue_helper wmi_bmof ipmi_ssif input_leds joydev rndis_host cdc_ether usbnet ast mii drm_vram_helper ttm drm_kms_helper i2c_algo_bit fb_sys_fops syscopyarea sysfillrect sysimgblt ccp mac_hid ipmi_si ipmi_devintf ipmi_msghandler sch_fq_codel nf_tables_set nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nf_tables nfnetlink ramoops reed_solomon efi_pstore drm ip_tables x_tables autofs4 raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid0 multipath linear mlx5_ib ib_uverbs ib_core raid1 hid_generic mlx5_core pci_hyperv_intf crc32_pclmul usbhid ahci tls mlxfw bnxt_en hid libahci nvme i2c_piix4 nvme_core wmi [last unloaded: cpuid] Aug 7 07:26:17 rx [1006006.726180] CR2: 0000000000000020
Aug 7 07:26:17 rx [1006006.729718] ---[ end trace e0e2e37e4e612984 ]---
Prior to seeing the first crash and on other machines we also see the warning in tcp_send_loss_probe() where packets_out is non-zero, but both transmit and retrans queues are empty so we know the box is seeing some accounting issue in this area:
Jul 26 09:15:27 kernel: ------------[ cut here ]------------ Jul 26 09:15:27 kernel: invalid inflight: 2 state 1 cwnd 68 mss 8988 Jul 26 09:15:27 kernel: WARNING: CPU: 16 PID: 0 at net/ipv4/tcp_output.c:2605 tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: Modules linked in: vrf bridge stp llc vxlan ip6_udp_tunnel udp_tunnel nls_iso8859_1 nft_ct amd64_edac_mod edac_mce_amd kvm_amd kvm crct10dif_pclmul ghash_clmulni_intel aesni_intel crypto_simd cryptd glue_helper wmi_bmof ipmi_ssif joydev input_leds rndis_host cdc_ether usbnet mii ast drm_vram_helper ttm drm_kms_he> Jul 26 09:15:27 kernel: CPU: 16 PID: 0 Comm: swapper/16 Not tainted 5.4.0-174-generic #193-Ubuntu Jul 26 09:15:27 kernel: Hardware name: Supermicro SMC 2x26 os-gen8 64C NVME-Y 256G/H12SSW-NTR, BIOS 2.5.V1.2U.NVMe.UEFI 05/09/2023 Jul 26 09:15:27 kernel: RIP: 0010:tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: Code: 08 26 01 00 75 e2 41 0f b6 54 24 12 41 8b 8c 24 c0 06 00 00 45 89 f0 48 c7 c7 e0 b4 20 a7 c6 05 8d 08 26 01 01 e8 4a c0 0f 00 <0f> 0b eb ba 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55 48 89 e5 41 Jul 26 09:15:27 kernel: RSP: 0018:ffffb7838088ce00 EFLAGS: 00010286 Jul 26 09:15:27 kernel: RAX: 0000000000000000 RBX: ffff9b84b5630430 RCX: 0000000000000006 Jul 26 09:15:27 kernel: RDX: 0000000000000007 RSI: 0000000000000096 RDI: ffff9b8e4621c8c0 Jul 26 09:15:27 kernel: RBP: ffffb7838088ce18 R08: 0000000000000927 R09: 0000000000000004 Jul 26 09:15:27 kernel: R10: 0000000000000000 R11: 0000000000000001 R12: ffff9b84b5630000 Jul 26 09:15:27 kernel: R13: 0000000000000000 R14: 000000000000231c R15: ffff9b84b5630430 Jul 26 09:15:27 kernel: FS: 0000000000000000(0000) GS:ffff9b8e46200000(0000) knlGS:0000000000000000 Jul 26 09:15:27 kernel: CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 Jul 26 09:15:27 kernel: CR2: 000056238cec2380 CR3: 0000003e49ede005 CR4: 0000000000760ee0 Jul 26 09:15:27 kernel: PKRU: 55555554 Jul 26 09:15:27 kernel: Call Trace: Jul 26 09:15:27 kernel: <IRQ> Jul 26 09:15:27 kernel: ? show_regs.cold+0x1a/0x1f Jul 26 09:15:27 kernel: ? __warn+0x98/0xe0 Jul 26 09:15:27 kernel: ? tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: ? report_bug+0xd1/0x100 Jul 26 09:15:27 kernel: ? do_error_trap+0x9b/0xc0 Jul 26 09:15:27 kernel: ? do_invalid_op+0x3c/0x50 Jul 26 09:15:27 kernel: ? tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: ? invalid_op+0x1e/0x30 Jul 26 09:15:27 kernel: ? tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: tcp_write_timer_handler+0x1b4/0x240 Jul 26 09:15:27 kernel: tcp_write_timer+0x9e/0xe0 Jul 26 09:15:27 kernel: ? tcp_write_timer_handler+0x240/0x240 Jul 26 09:15:27 kernel: call_timer_fn+0x32/0x130 Jul 26 09:15:27 kernel: __run_timers.part.0+0x180/0x280 Jul 26 09:15:27 kernel: ? timerqueue_add+0x9b/0xb0 Jul 26 09:15:27 kernel: ? enqueue_hrtimer+0x3d/0x90 Jul 26 09:15:27 kernel: ? do_error_trap+0x9b/0xc0 Jul 26 09:15:27 kernel: ? do_invalid_op+0x3c/0x50 Jul 26 09:15:27 kernel: ? tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: ? invalid_op+0x1e/0x30 Jul 26 09:15:27 kernel: ? tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: tcp_write_timer_handler+0x1b4/0x240 Jul 26 09:15:27 kernel: tcp_write_timer+0x9e/0xe0 Jul 26 09:15:27 kernel: ? tcp_write_timer_handler+0x240/0x240 Jul 26 09:15:27 kernel: call_timer_fn+0x32/0x130 Jul 26 09:15:27 kernel: __run_timers.part.0+0x180/0x280 Jul 26 09:15:27 kernel: ? timerqueue_add+0x9b/0xb0 Jul 26 09:15:27 kernel: ? enqueue_hrtimer+0x3d/0x90 Jul 26 09:15:27 kernel: ? recalibrate_cpu_khz+0x10/0x10 Jul 26 09:15:27 kernel: ? ktime_get+0x3e/0xa0 Jul 26 09:15:27 kernel: ? native_x2apic_icr_write+0x30/0x30 Jul 26 09:15:27 kernel: run_timer_softirq+0x2a/0x50 Jul 26 09:15:27 kernel: __do_softirq+0xd1/0x2c1 Jul 26 09:15:27 kernel: irq_exit+0xae/0xb0 Jul 26 09:15:27 kernel: smp_apic_timer_interrupt+0x7b/0x140 Jul 26 09:15:27 kernel: apic_timer_interrupt+0xf/0x20 Jul 26 09:15:27 kernel: </IRQ> Jul 26 09:15:27 kernel: RIP: 0010:native_safe_halt+0xe/0x10 Jul 26 09:15:27 kernel: Code: 7b ff ff ff eb bd 90 90 90 90 90 90 e9 07 00 00 00 0f 00 2d 36 2c 50 00 f4 c3 66 90 e9 07 00 00 00 0f 00 2d 26 2c 50 00 fb f4 <c3> 90 0f 1f 44 00 00 55 48 89 e5 41 55 41 54 53 e8 dd 5e 61 ff 65 Jul 26 09:15:27 kernel: RSP: 0018:ffffb783801cfe70 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13 Jul 26 09:15:27 kernel: RAX: ffffffffa6908b20 RBX: 0000000000000010 RCX: 0000000000000001 Jul 26 09:15:27 kernel: RDX: 000000006fc0c97e RSI: 0000000000000082 RDI: 0000000000000082 Jul 26 09:15:27 kernel: RBP: ffffb783801cfe90 R08: 0000000000000000 R09: 0000000000000225 Jul 26 09:15:27 kernel: R10: 0000000000100000 R11: 0000000000000000 R12: 0000000000000010 Jul 26 09:15:27 kernel: R13: ffff9b8e390b0000 R14: 0000000000000000 R15: 0000000000000000 Jul 26 09:15:27 kernel: ? __cpuidle_text_start+0x8/0x8 Jul 26 09:15:27 kernel: ? default_idle+0x20/0x140 Jul 26 09:15:27 kernel: arch_cpu_idle+0x15/0x20 Jul 26 09:15:27 kernel: default_idle_call+0x23/0x30 Jul 26 09:15:27 kernel: do_idle+0x1fb/0x270 Jul 26 09:15:27 kernel: cpu_startup_entry+0x20/0x30 Jul 26 09:15:27 kernel: start_secondary+0x178/0x1d0 Jul 26 09:15:27 kernel: secondary_startup_64+0xa4/0xb0 Jul 26 09:15:27 kernel: ---[ end trace e7ac822987e33be1 ]---
The NULL ptr deref is coming from tcp_rto_delta_us() attempting to pull an skb off the head of the retransmit queue and then dereferencing that skb to get the skb_mstamp_ns value via tcp_skb_timestamp_us(skb).
The crash is the same one that was reported a # of years ago here:
https://lore.kernel.org/netdev/[email protected]/T/#t
and the kernel we're running has the fix which was added to resolve this issue.
Unfortunately we've been unsuccessful so far in reproducing this problem in the lab and do not have the luxury of pushing out a new kernel to try and test if newer kernels resolve this issue at the moment. I realize this is a report against both an Ubuntu kernel and also an older 5.4 kernel. I have reported this issue to Ubuntu here: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2077657
however I feel like since this issue has possibly cropped up again it makes sense to build in some protection in this path (even on the latest kernel versions) since the code in question just blindly assumes there's a valid skb without testing if it's NULL b/f it looks at the timestamp.
Given we have seen crashes in this path before and now this case it seems like we should protect ourselves for when packets_out accounting is incorrect. While we should fix that root cause we should also just make sure the skb is not NULL before dereferencing it. Also add a warn once here to capture some information if/when the problem case is hit again.
--- include/net/tcp.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
include/net/tcp.h +19 -2
@@ -2437,9 +2437,26 @@ static inline s64 tcp_rto_delta_us(const struct sock *sk) {const struct sk_buff *skb =tcp_rtx_queue_head (sk);u32 rto =inet_csk (sk)->icsk_rto; -u64 rto_time_stamp_us =tcp_skb_timestamp_us (skb) +jiffies_to_usecs (rto); -return rto_time_stamp_us -tcp_sk (sk)->tcp_mstamp; +if (likely (skb)) { +u64 rto_time_stamp_us =tcp_skb_timestamp_us (skb) +jiffies_to_usecs (rto); + +return rto_time_stamp_us -tcp_sk (sk)->tcp_mstamp; + }else { +WARN_ONCE (1 , +"rtx queue emtpy: " +"out:%u sacked:%u lost:%u retrans:%u " +"tlp_high_seq:%u sk_state:%u ca_state:%u " +"advmss:%u mss_cache:%u pmtu:%u\n" , +tcp_sk (sk)->packets_out,tcp_sk (sk)->sacked_out, +tcp_sk (sk)->lost_out,tcp_sk (sk)->retrans_out, +tcp_sk (sk)->tlp_high_seq, sk->sk_state, +inet_csk (sk)->icsk_ca_state, +tcp_sk (sk)->advmss,tcp_sk (sk)->mss_cache, +inet_csk (sk)->icsk_pmtu_cookie); +return jiffies_to_usecs (rto); + } + }/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 440/634 net: qrtr: Update packets cloning when broadcasting
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Youssef Samir <[email protected]>
[ Upstream commit f011b313e8ebd5b7abd8521b5119aecef403de45 ]
When broadcasting data to multiple nodes via MHI, using skb_clone() causes all nodes to receive the same header data. This can result in packets being discarded by endpoints, leading to lost data.
This issue occurs when a socket is closed, and a QRTR_TYPE_DEL_CLIENT packet is broadcasted. All nodes receive the same destination node ID, causing the node connected to the client to discard the packet and remain unaware of the client's deletion.
Replace skb_clone() with pskb_copy(), to create a separate copy of the header for each sk_buff.
--- net/qrtr/af_qrtr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/qrtr/af_qrtr.c +1 -1
@@ -884,7 +884,7 @@ static int qrtr_bcast_enqueue(struct qrtr_node *node, struct sk_buff *skb,mutex_lock (&qrtr_node_lock);list_for_each_entry (node, &qrtr_all_nodes, item) { - skbn =skb_clone (skb,GFP_KERNEL ); + skbn =pskb_copy (skb,GFP_KERNEL );if (!skbn)break ;skb_set_owner_w (skbn, skb->sk);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 441/634 net: ravb: Fix R-Car RX frame size limit
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Barker <[email protected]>
[ Upstream commit ec8234717db8589078d08b17efa528a235c61f4f ]
The RX frame size limit should not be based on the current MTU setting. Instead it should be based on the hardware capabilities.
While we're here, improve the description of the receive frame length setting as suggested by Niklas.
--- drivers/net/ethernet/renesas/ravb_main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/ethernet/renesas/ravb_main.c +10 -2
@@ -530,8 +530,16 @@ static void ravb_emac_init_gbeth(struct net_device *ndev)static void ravb_emac_init_rcar (struct net_device *ndev) { -/* Receive frame limit set register */ -ravb_write (ndev, ndev->mtu +ETH_HLEN +VLAN_HLEN +ETH_FCS_LEN ,RFLR ); +struct ravb_private *priv =netdev_priv (ndev); + +/* Set receive frame length +* +* The length set here describes the frame from the destination address +* up to and including the CRC data. However only the frame data, +* excluding the CRC, are transferred to memory. To allow for the +* largest frames add the CRC length to the maximum Rx descriptor size. +*/ +ravb_write (ndev, priv->info->rx_max_frame_size +ETH_FCS_LEN ,RFLR );/* EMAC Mode: PAUSE prohibition; Duplex; RX Checksum; TX; RX */ ravb_write(ndev, ECMR_ZPF | ECMR_DM |
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 442/634 bonding: Fix unnecessary warnings and logs from bond_xdp_get_xmit_slave()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiwon Kim <[email protected]>
[ Upstream commit 0cbfd45fbcf0cb26d85c981b91c62fe73cdee01c ]
syzbot reported a WARNING in bond_xdp_get_xmit_slave. To reproduce this[1], one bond device (bond1) has xdpdrv, which increases bpf_master_redirect_enabled_key. Another bond device (bond0) which is unsupported by XDP but its slave (veth3) has xdpgeneric that returns XDP_TX. This triggers WARN_ON_ONCE() from the xdp_master_redirect(). To reduce unnecessary warnings and improve log management, we need to delete the WARN_ON_ONCE() and add ratelimit to the netdev_err().
[1] Steps to reproduce:
# Needs tx_xdp with return XDP_TX;
ip l add veth0 type veth peer veth1
ip l add veth3 type veth peer veth4
ip l add bond0 type bond mode 6 # BOND_MODE_ALB, unsupported by XDP ip l add bond1 type bond # BOND_MODE_ROUNDROBIN by default ip l set veth0 master bond1
ip l set bond1 up
# Increases bpf_master_redirect_enabled_key
ip l set dev bond1 xdpdrv object tx_xdp.o section xdp_tx ip l set veth3 master bond0
ip l set bond0 up
ip l set veth4 up
# Triggers WARN_ON_ONCE() from the xdp_master_redirect() ip l set veth3 xdpgeneric object tx_xdp.o section xdp_tx
--- drivers/net/bonding/bond_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/bonding/bond_main.c +3 -3
@@ -5536,9 +5536,9 @@ bond_xdp_get_xmit_slave(struct net_device *bond_dev, struct xdp_buff *xdp)break ;default : -/* Should never happen. Mode guarded by bond_xdp_check() */ -netdev_err (bond_dev,"Unknown bonding mode %d for xdp xmit\n" ,BOND_MODE (bond)); -WARN_ON_ONCE (1 ); +if (net_ratelimit ()) +netdev_err (bond_dev,"Unknown bonding mode %d for xdp xmit\n" , +BOND_MODE (bond));return NULL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 443/634 virtio_net: Fix mismatched buf address when unmapping for small packets
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenbo Li <[email protected]>
[ Upstream commit c11a49d58ad229a1be1ebe08a2b68fedf83db6c8 ]
Currently, the virtio-net driver will perform a pre-dma-mapping for small or mergeable RX buffer. But for small packets, a mismatched address without VIRTNET_RX_PAD and xdp_headroom is used for unmapping.
That will result in unsynchronized buffers when SWIOTLB is enabled, for example, when running as a TDX guest.
This patch unifies the address passed to the virtio core as the address of the virtnet header and fixes the mismatched buffer address.
Changes from v2: unify the buf that passed to the virtio core in small and merge mode.
Changes from v1: Use ctx to get xdp_headroom.
--- drivers/net/virtio_net.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/virtio_net.c +8 -2
@@ -1439,6 +1439,11 @@ static struct sk_buff *receive_small(struct net_device *dev,struct page *page =virt_to_head_page (buf);struct sk_buff *skb; +/* We passed the address of virtnet header to virtio-core, +* so truncate the padding. +*/ + buf -=VIRTNET_RX_PAD + xdp_headroom; + len -= vi->hdr_len;u64_stats_add (&stats->bytes, len);
@@ -2029,8 +2034,9 @@ static int add_recvbuf_small(struct virtnet_info *vi, struct receive_queue *rq,if (unlikely (!buf))return -ENOMEM ; -virtnet_rq_init_one_sg (rq, buf +VIRTNET_RX_PAD + xdp_headroom, - vi->hdr_len +GOOD_PACKET_LEN ); + buf +=VIRTNET_RX_PAD + xdp_headroom; + +virtnet_rq_init_one_sg (rq, buf, vi->hdr_len +GOOD_PACKET_LEN ); err =virtqueue_add_inbuf_ctx (rq->vq, rq->sg,1 , buf, ctx, gfp);if (err <0 ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 444/634 net: stmmac: set PP_FLAG_DMA_SYNC_DEV only if XDP is enabled
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Furong Xu <[email protected]>
[ Upstream commit b514c47ebf41a6536551ed28a05758036e6eca7c ]
Commit 5fabb01207a2 ("net: stmmac: Add initial XDP support") sets PP_FLAG_DMA_SYNC_DEV flag for page_pool unconditionally, page_pool_recycle_direct() will call page_pool_dma_sync_for_device() on every page even the page is not going to be reused by XDP program.
When XDP is not enabled, the page which holds the received buffer will be recycled once the buffer is copied into new SKB by skb_copy_to_linear_data(), then the MAC core will never reuse this page any longer. Always setting PP_FLAG_DMA_SYNC_DEV wastes CPU cycles on unnecessary calling of page_pool_dma_sync_for_device().
After this patch, up to 9% noticeable performance improvement was observed on certain platforms.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
@@ -2025,7 +2025,7 @@ static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv, rx_q->queue_index = queue; rx_q->priv_data = priv; - pp_params.flags =PP_FLAG_DMA_MAP |PP_FLAG_DMA_SYNC_DEV ; + pp_params.flags =PP_FLAG_DMA_MAP | (xdp_prog ?PP_FLAG_DMA_SYNC_DEV :0 ); pp_params.pool_size = dma_conf->dma_rx_size; num_pages =DIV_ROUND_UP (dma_conf->dma_buf_sz,PAGE_SIZE ); pp_params.order =ilog2 (num_pages);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 445/634 netfilter: nf_tables: Keep deleted flowtable hooks until after RCU
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Phil Sutter <[email protected]>
[ Upstream commit 642c89c475419b4d0c0d90e29d9c1a0e4351f379 ]
Documentation of list_del_rcu() warns callers to not immediately free the deleted list item. While it seems not necessary to use the RCU-variant of list_del() here in the first place, doing so seems to require calling kfree_rcu() on the deleted item as well.
--- net/netfilter/nf_tables_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +1 -1
@@ -9137,7 +9137,7 @@ static void nf_tables_flowtable_destroy(struct nft_flowtable *flowtable) flowtable->data.type->setup (&flowtable->data, hook->ops.dev,FLOW_BLOCK_UNBIND );list_del_rcu (&hook->list); -kfree (hook); +kfree_rcu (hook, rcu); }kfree (flowtable->name);module_put (flowtable->data.type->owner);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 446/634 netfilter: ctnetlink: compile ctnetlink_label_size with CONFIG_NF_CONNTRACK_EVENTS
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Horman <[email protected]>
[ Upstream commit e1f1ee0e9ad8cbe660f5c104e791c5f1a7cf4c31 ]
Only provide ctnetlink_label_size when it is used, which is when CONFIG_NF_CONNTRACK_EVENTS is configured.
Flagged by clang-18 W=1 builds as:
.../nf_conntrack_netlink.c:385:19: warning: unused function 'ctnetlink_label_size' [-Wunused-function]
385 | static inline int ctnetlink_label_size(const struct nf_conn *ct)
| ^~~~~~~~~~~~~~~~~~~~
The condition on CONFIG_NF_CONNTRACK_LABELS being removed by this patch guards compilation of non-trivial implementations of ctnetlink_dump_labels() and ctnetlink_label_size().
However, this is not necessary as each of these functions will always return 0 if CONFIG_NF_CONNTRACK_LABELS is not defined as each function starts with the equivalent of:
struct nf_conn_labels *labels = nf_ct_labels_find(ct); if (!labels) return 0;
And nf_ct_labels_find always returns NULL if CONFIG_NF_CONNTRACK_LABELS is not enabled. So I believe that the compiler optimises the code away in such cases anyway.
Found by inspection.
Compile tested only.
Originally splitted in two patches, Pablo Neira Ayuso collapsed them and added Fixes: tag.
--- net/netfilter/nf_conntrack_netlink.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
net/netfilter/nf_conntrack_netlink.c +2 -5
@@ -382,7 +382,7 @@ static int ctnetlink_dump_secctx(struct sk_buff *skb, const struct nf_conn *ct)#define ctnetlink_dump_secctx (a, b) (0)#endif -#ifdef CONFIG_NF_CONNTRACK_LABELS +#ifdef CONFIG_NF_CONNTRACK_EVENTS static inline int ctnetlink_label_size (const struct nf_conn *ct) {struct nf_conn_labels *labels =nf_ct_labels_find (ct);
@@ -391,6 +391,7 @@ static inline int ctnetlink_label_size(const struct nf_conn *ct)return 0 ; return nla_total_size(sizeof(labels->bits)); } +#endif static int ctnetlink_dump_labels (struct sk_buff *skb,const struct nf_conn *ct)
@@ -411,10 +412,6 @@ ctnetlink_dump_labels(struct sk_buff *skb, const struct nf_conn *ct)return 0 ; } -#else -#define ctnetlink_dump_labels (a, b) (0) -#define ctnetlink_label_size (a) (0) -#endif #define master_tuple (ct) &(ct->master->tuplehash[IP_CT_DIR_ORIGINAL].tuple)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 447/634 netfilter: nf_tables: use rcu chain hook list iterator from netlink dump path
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 4ffcf5ca81c3b83180473eb0d3c010a1a7c6c4de ]
Lockless iteration over hook list is possible from netlink dump path, use rcu variant to iterate over the hook list as is done with flowtable hooks.
--- net/netfilter/nf_tables_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +1 -1
@@ -1795,7 +1795,7 @@ static int nft_dump_basechain_hook(struct sk_buff *skb, int family,if (!hook_list) hook_list = &basechain->hook_list; -list_for_each_entry (hook, hook_list, list) { +list_for_each_entry_rcu (hook, hook_list, list) {if (!first) first = hook;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 448/634 netfilter: nf_tables: missing objects with no memcg accounting
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 69e687cea79fc99a17dfb0116c8644b9391b915e ]
Several ruleset objects are still not using GFP_KERNEL_ACCOUNT for memory accounting, update them. This includes:
- catchall elements
- compat match large info area
- log prefix
- meta secctx
- numgen counters
- pipapo set backend datastructure
- tunnel private objects
--- net/netfilter/nf_tables_api.c | 2 +- net/netfilter/nft_compat.c | 6 +++--- net/netfilter/nft_log.c | 2 +- net/netfilter/nft_meta.c | 2 +- net/netfilter/nft_numgen.c | 2 +- net/netfilter/nft_set_pipapo.c | 13 +++++++------ net/netfilter/nft_tunnel.c | 5 +++-- 7 files changed, 17 insertions(+), 15 deletions(-)
net/netfilter/nf_tables_api.c +1 -1
@@ -6631,7 +6631,7 @@ static int nft_setelem_catchall_insert(const struct net *net, } } - catchall =kmalloc (sizeof (*catchall),GFP_KERNEL ); + catchall =kmalloc (sizeof (*catchall),GFP_KERNEL_ACCOUNT );if (!catchall)return -ENOMEM ;
net/netfilter/nft_compat.c +3 -3
@@ -536,7 +536,7 @@ nft_match_large_init(const struct nft_ctx *ctx, const struct nft_expr *expr,struct xt_match *m = expr->ops->data;int ret; - priv->info =kmalloc (XT_ALIGN (m->matchsize),GFP_KERNEL ); + priv->info =kmalloc (XT_ALIGN (m->matchsize),GFP_KERNEL_ACCOUNT );if (!priv->info)return -ENOMEM ;
@@ -810,7 +810,7 @@ nft_match_select_ops(const struct nft_ctx *ctx, goto err; } - ops =kzalloc (sizeof (struct nft_expr_ops ),GFP_KERNEL ); + ops =kzalloc (sizeof (struct nft_expr_ops ),GFP_KERNEL_ACCOUNT );if (!ops) { err = -ENOMEM ; goto err;
@@ -900,7 +900,7 @@ nft_target_select_ops(const struct nft_ctx *ctx, goto err; } - ops =kzalloc (sizeof (struct nft_expr_ops ),GFP_KERNEL ); + ops =kzalloc (sizeof (struct nft_expr_ops ),GFP_KERNEL_ACCOUNT );if (!ops) { err = -ENOMEM ; goto err;
net/netfilter/nft_log.c +1 -1
@@ -163,7 +163,7 @@ static int nft_log_init(const struct nft_ctx *ctx, nla = tb[NFTA_LOG_PREFIX ];if (nla !=NULL ) { - priv->prefix =kmalloc (nla_len (nla) +1 ,GFP_KERNEL ); + priv->prefix =kmalloc (nla_len (nla) +1 ,GFP_KERNEL_ACCOUNT );if (priv->prefix ==NULL )return -ENOMEM ;nla_strscpy (priv->prefix, nla,nla_len (nla) +1 );
net/netfilter/nft_meta.c +1 -1
@@ -954,7 +954,7 @@ static int nft_secmark_obj_init(const struct nft_ctx *ctx,if (tb[NFTA_SECMARK_CTX ] ==NULL )return -EINVAL ; - priv->ctx =nla_strdup (tb[NFTA_SECMARK_CTX ],GFP_KERNEL ); + priv->ctx =nla_strdup (tb[NFTA_SECMARK_CTX ],GFP_KERNEL_ACCOUNT );if (!priv->ctx)return -ENOMEM ;
net/netfilter/nft_numgen.c +1 -1
@@ -66,7 +66,7 @@ static int nft_ng_inc_init(const struct nft_ctx *ctx,if (priv->offset + priv->modulus -1 < priv->offset)return -EOVERFLOW ; - priv->counter =kmalloc (sizeof (*priv->counter),GFP_KERNEL ); + priv->counter =kmalloc (sizeof (*priv->counter),GFP_KERNEL_ACCOUNT );if (!priv->counter)return -ENOMEM ;
net/netfilter/nft_set_pipapo.c +7 -6
@@ -663,7 +663,7 @@ static int pipapo_realloc_mt(struct nft_pipapo_field *f, check_add_overflow(rules, extra, &rules_alloc))return -EOVERFLOW ; - new_mt =kvmalloc_array (rules_alloc,sizeof (*new_mt),GFP_KERNEL ); + new_mt =kvmalloc_array (rules_alloc,sizeof (*new_mt),GFP_KERNEL_ACCOUNT );if (!new_mt)return -ENOMEM ;
@@ -936,7 +936,7 @@ static void pipapo_lt_bits_adjust(struct nft_pipapo_field *f)return ; } - new_lt =kvzalloc (lt_size +NFT_PIPAPO_ALIGN_HEADROOM ,GFP_KERNEL ); + new_lt =kvzalloc (lt_size +NFT_PIPAPO_ALIGN_HEADROOM ,GFP_KERNEL_ACCOUNT );if (!new_lt)return ;
@@ -1212,7 +1212,7 @@ static int pipapo_realloc_scratch(struct nft_pipapo_match *clone, scratch =kzalloc_node (struct_size (scratch, map, bsize_max *2 ) +NFT_PIPAPO_ALIGN_HEADROOM , -GFP_KERNEL ,cpu_to_node (i)); +GFP_KERNEL_ACCOUNT ,cpu_to_node (i));if (!scratch) {/* On failure, there's no need to undo previous * allocations: this means that some scratch maps have
@@ -1427,7 +1427,7 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)struct nft_pipapo_match *new;int i; - new =kmalloc (struct_size (new, f, old->field_count),GFP_KERNEL ); + new =kmalloc (struct_size (new, f, old->field_count),GFP_KERNEL_ACCOUNT );if (!new)return NULL ;
@@ -1457,7 +1457,7 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old) new_lt =kvzalloc (src->groups *NFT_PIPAPO_BUCKETS (src->bb) * src->bsize *sizeof (*dst->lt) +NFT_PIPAPO_ALIGN_HEADROOM , -GFP_KERNEL ); +GFP_KERNEL_ACCOUNT );if (!new_lt) goto out_lt;
@@ -1470,7 +1470,8 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)if (src->rules >0 ) { dst->mt =kvmalloc_array (src->rules_alloc, -sizeof (*src->mt),GFP_KERNEL ); +sizeof (*src->mt), +GFP_KERNEL_ACCOUNT );if (!dst->mt) goto out_mt;
net/netfilter/nft_tunnel.c +3 -2
@@ -509,13 +509,14 @@ static int nft_tunnel_obj_init(const struct nft_ctx *ctx,return err; } - md =metadata_dst_alloc (priv->opts.len,METADATA_IP_TUNNEL ,GFP_KERNEL ); + md =metadata_dst_alloc (priv->opts.len,METADATA_IP_TUNNEL , +GFP_KERNEL_ACCOUNT );if (!md)return -ENOMEM ;memcpy (&md->u.tun_info, &info,sizeof (info));#ifdef CONFIG_DST_CACHE - err =dst_cache_init (&md->u.tun_info.dst_cache,GFP_KERNEL ); + err =dst_cache_init (&md->u.tun_info.dst_cache,GFP_KERNEL_ACCOUNT );if (err <0 ) {metadata_dst_free (md);return err;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 449/634 selftests: netfilter: Avoid hanging ipvs.sh
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Phil Sutter <[email protected]>
[ Upstream commit fc786304ad9803e8bb86b8599bc64d1c1746c75f ]
If the client can't reach the server, the latter remains listening forever. Kill it after 5s of waiting.
--- tools/testing/selftests/net/netfilter/ipvs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/netfilter/ipvs.sh +1 -1
@@ -97,7 +97,7 @@ cleanup() { } server_listen() { - ip netns exec "$ns2" socat -u -4 TCP-LISTEN:8080,reuseaddr STDOUT > "${outfile}" & + ip netns exec "$ns2" timeout 5 socat -u -4 TCP-LISTEN:8080,reuseaddr STDOUT > "${outfile}" & server_pid=$! sleep 0.2 }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 450/634 io_uring/sqpoll: do not allow pinning outside of cpuset
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Moessbauer <[email protected]>
commit f011c9cf04c06f16b24f583d313d3c012e589e50 upstream.
The submit queue polling threads are userland threads that just never exit to the userland. When creating the thread with IORING_SETUP_SQ_AFF, the affinity of the poller thread is set to the cpu specified in sq_thread_cpu. However, this CPU can be outside of the cpuset defined by the cgroup cpuset controller. This violates the rules defined by the cpuset controller and is a potential issue for realtime applications.
In b7ed6d8ffd6 we fixed the default affinity of the poller thread, in case no explicit pinning is required by inheriting the one of the creating task. In case of explicit pinning, the check is more complicated, as also a cpu outside of the parent cpumask is allowed. We implemented this by using cpuset_cpus_allowed (that has support for cgroup cpusets) and testing if the requested cpu is in the set.
--- io_uring/sqpoll.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
io_uring/sqpoll.c +4 -1
@@ -10,6 +10,7 @@#include <linux/slab.h> #include <linux/audit.h> #include <linux/security.h> +#include <linux/cpuset.h> #include <linux/io_uring.h> #include <uapi/linux/io_uring.h>
@@ -460,10 +461,12 @@ __cold int io_sq_offload_create(struct ireturn 0 ;if (p->flags &IORING_SETUP_SQ_AFF ) { +struct cpumask allowed_mask;int cpu = p->sq_thread_cpu; ret = -EINVAL ; -if (cpu >= nr_cpu_ids || !cpu_online (cpu)) +cpuset_cpus_allowed (current, &allowed_mask); +if (!cpumask_test_cpu (cpu, &allowed_mask)) goto err_sqpoll; sqd->sq_cpu = cpu; }else {
Greg Kroah-Hartman
maintainerPATCH 451/634 io_uring/rw: treat -EOPNOTSUPP for IOCB_NOWAIT like -EAGAIN
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit c0a9d496e0fece67db777bd48550376cf2960c47 upstream.
Some file systems, ocfs2 in this case, will return -EOPNOTSUPP for an IOCB_NOWAIT read/write attempt. While this can be argued to be correct, the usual return value for something that requires blocking issue is -EAGAIN.
A refactoring io_uring commit dropped calling kiocb_done() for negative return values, which is otherwise where we already do that transformation. To ensure we catch it in both spots, check it in __io_read() itself as well.
--- io_uring/rw.c | 8 ++++++++ 1 file changed, 8 insertions(+)
io_uring/rw.c +8 -0
@@ -856,6 +856,14 @@ static int __io_read(struct io_kiocb *re ret =io_iter_do_read (rw, &io->iter); +/* +* Some file systems like to return -EOPNOTSUPP for an IOCB_NOWAIT +* issue, even though they should be returning -EAGAIN. To be safe, +* retry from blocking context for either. +*/ +if (ret == -EOPNOTSUPP && force_nonblock) + ret = -EAGAIN ; +if (ret == -EAGAIN || (req->flags &REQ_F_REISSUE )) { req->flags &= ~REQ_F_REISSUE ;/* If we can poll, just do that. */
Greg Kroah-Hartman
maintainerPATCH 452/634 io_uring: check for presence of task_work rather than TIF_NOTIFY_SIGNAL
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit 04beb6e0e08c30c6f845f50afb7d7953603d7a6f upstream.
If some part of the kernel adds task_work that needs executing, in terms of signaling it'll generally use TWA_SIGNAL or TWA_RESUME. Those two directly translate to TIF_NOTIFY_SIGNAL or TIF_NOTIFY_RESUME, and can be used for a variety of use case outside of task_work.
However, io_cqring_wait_schedule() only tests explicitly for TIF_NOTIFY_SIGNAL. This means it can miss if task_work got added for the task, but used a different kind of signaling mechanism (or none at all). Normally this doesn't matter as any task_work will be run once the task exits to userspace, except if:
1) The ring is setup with DEFER_TASKRUN
2) The local work item may generate normal task_work
For condition 2, this can happen when closing a file and it's the final put of that file, for example. This can cause stalls where a task is waiting to make progress inside io_cqring_wait(), but there's nothing else that will wake it up. Hence change the "should we schedule or loop around" check to check for the presence of task_work explicitly, rather than just TIF_NOTIFY_SIGNAL as the mechanism. While in there, also change the ordering of what type of task_work first in terms of ordering, to both make it consistent with other task_work runs in io_uring, but also to better handle the case of defer task_work generating normal task_work, like in the above example.
--- io_uring/io_uring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
io_uring/io_uring.c +2 -2
@@ -2401,7 +2401,7 @@ static inline int io_cqring_wait_schedulreturn 1 ;if (unlikely (!llist_empty (&ctx->work_llist)))return 1 ; -if (unlikely (test_thread_flag (TIF_NOTIFY_SIGNAL ))) +if (unlikely (task_work_pending (current)))return 1 ;if (unlikely (task_sigpending (current)))return -EINTR ;
@@ -2502,9 +2502,9 @@ static int io_cqring_wait(struct io_ring* If we got woken because of task_work being processed, run it * now rather than let the caller do another wait loop. */ -io_run_task_work ();if (!llist_empty (&ctx->work_llist))io_run_local_work (ctx, nr_wait); +io_run_task_work ();/* * Non-local task_work will be run on exit to userspace, but
Greg Kroah-Hartman
maintainerPATCH 453/634 fuse: use exclusive lock when FUSE_I_CACHE_IO_MODE is set
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: yangyun <[email protected]>
commit 2f3d8ff457982f4055fe8f7bf19d3821ba22c376 upstream.
This may be a typo. The comment has said shared locks are not allowed when this bit is set. If using shared lock, the wait in fuse_file_cached_io_open may be forever.
--- fs/fuse/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/file.c +1 -1
@@ -1345,7 +1345,7 @@ static bool fuse_dio_wr_exclusive_lock(struct kiocb *iocb, struct iov_iter *from/* shared locks are not allowed with parallel page cache IO */ if (test_bit (FUSE_I_CACHE_IO_MODE , &fi->state)) -return false; +return true;/* Parallel dio beyond EOF is not supported, at least for now. */ if (fuse_io_past_eof (iocb, from))
Signature · 1 line
2.46.2
Greg Kroah-Hartman
maintainerPATCH 454/634 mm: migrate: annotate data-race in migrate_folio_unmap()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
commit 8001070cfbec5cd4ea00b8b48ea51df91122f265 upstream.
I found a report from syzbot [1]
This report shows that the value can be changed, but in reality, the value of __folio_set_movable() cannot be changed because it holds the folio refcount.
Therefore, it is appropriate to add an annotate to make KCSAN ignore that data-race.
[1]
==================================================================
BUG: KCSAN: data-race in __filemap_remove_folio / migrate_pages_batch
write to 0xffffea0004b81dd8 of 8 bytes by task 6348 on cpu 0:
page_cache_delete mm/filemap.c:153 [inline] __filemap_remove_folio+0x1ac/0x2c0 mm/filemap.c:233 filemap_remove_folio+0x6b/0x1f0 mm/filemap.c:265 truncate_inode_folio+0x42/0x50 mm/truncate.c:178 shmem_undo_range+0x25b/0xa70 mm/shmem.c:1028 shmem_truncate_range mm/shmem.c:1144 [inline] shmem_evict_inode+0x14d/0x530 mm/shmem.c:1272 evict+0x2f0/0x580 fs/inode.c:731 iput_final fs/inode.c:1883 [inline] iput+0x42a/0x5b0 fs/inode.c:1909 dentry_unlink_inode+0x24f/0x260 fs/dcache.c:412 __dentry_kill+0x18b/0x4c0 fs/dcache.c:615 dput+0x5c/0xd0 fs/dcache.c:857 __fput+0x3fb/0x6d0 fs/file_table.c:439 ____fput+0x1c/0x30 fs/file_table.c:459 task_work_run+0x13a/0x1a0 kernel/task_work.c:228 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline] exit_to_user_mode_loop kernel/entry/common.c:114 [inline] exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline] __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline] syscall_exit_to_user_mode+0xbe/0x130 kernel/entry/common.c:218 do_syscall_64+0xd6/0x1c0 arch/x86/entry/common.c:89 entry_SYSCALL_64_after_hwframe+0x77/0x7f
read to 0xffffea0004b81dd8 of 8 bytes by task 6342 on cpu 1:
__folio_test_movable include/linux/page-flags.h:699 [inline] migrate_folio_unmap mm/migrate.c:1199 [inline] migrate_pages_batch+0x24c/0x1940 mm/migrate.c:1797 migrate_pages_sync mm/migrate.c:1963 [inline] migrate_pages+0xff1/0x1820 mm/migrate.c:2072 do_mbind mm/mempolicy.c:1390 [inline] kernel_mbind mm/mempolicy.c:1533 [inline] __do_sys_mbind mm/mempolicy.c:1607 [inline] __se_sys_mbind+0xf76/0x1160 mm/mempolicy.c:1603 __x64_sys_mbind+0x78/0x90 mm/mempolicy.c:1603 x64_sys_call+0x2b4d/0x2d60 arch/x86/include/generated/asm/syscalls_64.h:238 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xc9/0x1c0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
value changed: 0xffff888127601078 -> 0x0000000000000000
--- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/migrate.c +1 -1
@@ -1129,7 +1129,7 @@ static int migrate_folio_unmap(new_folioint rc = -EAGAIN ;int old_page_state =0 ;struct anon_vma *anon_vma =NULL ; -bool is_lru = !__folio_test_movable (src); +bool is_lru =data_race (!__folio_test_movable (src));bool locked = false;bool dst_locked = false;
Greg Kroah-Hartman
maintainerPATCH 455/634 mm: call the security_mmap_file() LSM hook in remap_file_pages()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shu Han <[email protected]>
commit ea7e2d5e49c05e5db1922387b09ca74aa40f46e2 upstream.
The remap_file_pages syscall handler calls do_mmap() directly, which doesn't contain the LSM security check. And if the process has called personality(READ_IMPLIES_EXEC) before and remap_file_pages() is called for RW pages, this will actually result in remapping the pages to RWX, bypassing a W^X policy enforced by SELinux.
So we should check prot by security_mmap_file LSM hook in the remap_file_pages syscall handler before do_mmap() is called. Otherwise, it potentially permits an attacker to bypass a W^X policy enforced by SELinux.
The bypass is similar to CVE-2016-10044, which bypass the same thing via AIO and can be found in [1].
The PoC:
$ cat > test.c
int main(void) {
size_t pagesz = sysconf(_SC_PAGE_SIZE);
int mfd = syscall(SYS_memfd_create, "test", 0);
const char *buf = mmap(NULL, 4 * pagesz, PROT_READ | PROT_WRITE,
MAP_SHARED, mfd, 0);
unsigned int old = syscall(SYS_personality, 0xffffffff);
syscall(SYS_personality, READ_IMPLIES_EXEC | old);
syscall(SYS_remap_file_pages, buf, pagesz, 0, 2, 0);
syscall(SYS_personality, old);
// show the RWX page exists even if W^X policy is enforced
int fd = open("/proc/self/maps", O_RDONLY);
unsigned char buf2[1024];
while (1) {
int ret = read(fd, buf2, 1024);
if (ret <= 0) break;
write(1, buf2, ret);
}
close(fd);
}$ gcc test.c -o test $ ./test | grep rwx 7f1836c34000-7f1836c35000 rwxs 00002000 00:01 2050 /memfd:test (deleted)
--- mm/mmap.c | 4 ++++ 1 file changed, 4 insertions(+)
mm/mmap.c +4 -0
@@ -3127,8 +3127,12 @@ SYSCALL_DEFINE5(remap_file_pages, unsign flags |=MAP_LOCKED ; file =get_file (vma->vm_file); + ret =security_mmap_file (vma->vm_file, prot, flags); +if (ret) + goto out_fput; ret =do_mmap (vma->vm_file, start, size, prot, flags,0 , pgoff, &populate,NULL ); +out_fput:fput (file); out:mmap_write_unlock (mm);
Greg Kroah-Hartman
maintainerPATCH 456/634 drm/amd/display: Fix Synaptics Cascaded Panamera DSC Determination
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fangzhi Zuo <[email protected]>
commit 4437936c6b696b98f3fe1d8679a2788c41b4df77 upstream.
Synaptics Cascaded Panamera topology needs to unconditionally acquire root aux for dsc decoding.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +1 -1
@@ -251,7 +251,7 @@ static bool validate_dsc_caps_on_connect aconnector->dsc_aux = &aconnector->mst_root->dm_dp_aux.aux;/* synaptics cascaded MST hub case */ -if (!aconnector->dsc_aux &&is_synaptics_cascaded_panamera (aconnector->dc_link, port)) +if (is_synaptics_cascaded_panamera (aconnector->dc_link, port)) aconnector->dsc_aux = port->mgr->aux;if (!aconnector->dsc_aux)
Greg Kroah-Hartman
maintainerPATCH 457/634 xen: move checks for e820 conflicts further up
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit c4498ae316da5b5786ccd448fc555f3339b8e4ca upstream.
Move the checks for e820 memory map conflicts using the xen_chk_is_e820_usable() helper further up in order to prepare resolving some of the possible conflicts by doing some e820 map modifications, which must happen before evaluating the RAM layout.
--- arch/x86/xen/setup.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
arch/x86/xen/setup.c +22 -22
@@ -855,6 +855,28 @@ char * __init xen_memory_setup(void)/* Make sure the Xen-supplied memory map is well-ordered. */ e820__update_table (&xen_e820_table); +/* +* Check whether the kernel itself conflicts with the target E820 map. +* Failing now is better than running into weird problems later due +* to relocating (and even reusing) pages with kernel text or data. +*/ +xen_chk_is_e820_usable (__pa_symbol (_text), +__pa_symbol (_end) -__pa_symbol (_text), +"kernel" ); + +/* +* Check for a conflict of the xen_start_info memory with the target +* E820 map. +*/ +xen_chk_is_e820_usable (__pa (xen_start_info),sizeof (*xen_start_info), +"xen_start_info" ); + +/* +* Check for a conflict of the hypervisor supplied page tables with +* the target E820 map. +*/ +xen_pt_check_e820 (); + max_pages =xen_get_max_pages ();/* How many extra pages do we need due to remapping? */
@@ -927,28 +949,6 @@ char * __init xen_memory_setup(void)e820__update_table (e820_table); -/* -* Check whether the kernel itself conflicts with the target E820 map. -* Failing now is better than running into weird problems later due -* to relocating (and even reusing) pages with kernel text or data. -*/ -xen_chk_is_e820_usable (__pa_symbol (_text), -__pa_symbol (_end) -__pa_symbol (_text), -"kernel" ); - -/* -* Check for a conflict of the xen_start_info memory with the target -* E820 map. -*/ -xen_chk_is_e820_usable (__pa (xen_start_info),sizeof (*xen_start_info), -"xen_start_info" ); - -/* -* Check for a conflict of the hypervisor supplied page tables with -* the target E820 map. -*/ -xen_pt_check_e820 (); -xen_reserve_xen_mfnlist ();/* Check for a conflict of the initrd with the target E820 map. */
Greg Kroah-Hartman
maintainerPATCH 458/634 xen: allow mapping ACPI data using a different physical address
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit 9221222c717dbddac1e3c49906525475d87a3a44 upstream.
When running as a Xen PV dom0 the system needs to map ACPI data of the host using host physical addresses, while those addresses can conflict with the guest physical addresses of the loaded linux kernel. The same problem might apply in case a PV guest is configured to use the host memory map.
This conflict can be solved by mapping the ACPI data to a different guest physical address, but mapping the data via acpi_os_ioremap() must still be possible using the host physical address, as this address might be generated by AML when referencing some of the ACPI data.
When configured to support running as a Xen PV domain, have an implementation of acpi_os_ioremap() being aware of the possibility to need above mentioned translation of a host physical address to the guest physical address.
This modification requires to #include linux/acpi.h in some sources which need to include asm/acpi.h directly.
--- arch/x86/include/asm/acpi.h | 8 ++++++++ arch/x86/kernel/acpi/boot.c | 11 +++++++++++ arch/x86/kernel/jailhouse.c | 1 + arch/x86/kernel/mmconf-fam10h_64.c | 1 + arch/x86/kernel/smpboot.c | 1 + arch/x86/kernel/x86_init.c | 1 + arch/x86/xen/p2m.c | 35 +++++++++++++++++++++++++++++++++++ arch/x86/xen/setup.c | 2 +- 8 files changed, 59 insertions(+), 1 deletion(-)
arch/x86/include/asm/acpi.h +8 -0
@@ -167,6 +167,14 @@ void acpi_generic_reduced_hw_init(void);void x86_default_set_root_pointer (u64 addr);u64 x86_default_get_root_pointer (void ); +#ifdef CONFIG_XEN_PV +/* A Xen PV domain needs a special acpi_os_ioremap() handling. */ +extern void __iomem * (*acpi_os_ioremap)(acpi_physical_address phys, +acpi_size size); +void __iomem *x86_acpi_os_ioremap (acpi_physical_address phys,acpi_size size); +#define acpi_os_ioremap acpi_os_ioremap +#endif +#else /* !CONFIG_ACPI */ #define acpi_lapic 0
arch/x86/kernel/acpi/boot.c +11 -0
@@ -1862,3 +1862,14 @@ u64 x86_default_get_root_pointer(void) {return boot_params.acpi_rsdp_addr; } + +#ifdef CONFIG_XEN_PV +void __iomem *x86_acpi_os_ioremap (acpi_physical_address phys,acpi_size size) +{ +return ioremap_cache (phys, size); +} + +void __iomem * (*acpi_os_ioremap)(acpi_physical_address phys,acpi_size size) = + x86_acpi_os_ioremap; +EXPORT_SYMBOL_GPL (acpi_os_ioremap); +#endif
arch/x86/kernel/jailhouse.c +1 -0
@@ -12,6 +12,7 @@#include <linux/kernel.h> #include <linux/reboot.h> #include <linux/serial_8250.h> +#include <linux/acpi.h> #include <asm/apic.h> #include <asm/io_apic.h> #include <asm/acpi.h>
arch/x86/kernel/mmconf-fam10h_64.c +1 -0
@@ -9,6 +9,7 @@#include <linux/pci.h> #include <linux/dmi.h> #include <linux/range.h> +#include <linux/acpi.h> #include <asm/pci-direct.h> #include <linux/sort.h>
arch/x86/kernel/smpboot.c +1 -0
@@ -60,6 +60,7 @@#include <linux/stackprotector.h> #include <linux/cpuhotplug.h> #include <linux/mc146818rtc.h> +#include <linux/acpi.h> #include <asm/acpi.h> #include <asm/cacheinfo.h>
arch/x86/kernel/x86_init.c +1 -0
@@ -8,6 +8,7 @@#include <linux/ioport.h> #include <linux/export.h> #include <linux/pci.h> +#include <linux/acpi.h> #include <asm/acpi.h> #include <asm/bios_ebda.h>
arch/x86/xen/p2m.c +35 -0
@@ -70,6 +70,7 @@#include <linux/memblock.h> #include <linux/slab.h> #include <linux/vmalloc.h> +#include <linux/acpi.h> #include <asm/cache.h> #include <asm/setup.h>
@@ -835,6 +836,34 @@ void __init xen_do_remap_nonram(void)pr_info ("Remapped %u non-RAM page(s)\n" , remapped); } +#ifdef CONFIG_ACPI +/* +* Xen variant of acpi_os_ioremap() taking potentially remapped non-RAM +* regions into account. +* Any attempt to map an area crossing a remap boundary will produce a +* WARN() splat. +* phys is related to remap->maddr on input and will be rebased to remap->paddr. +*/ +static void __iomem *xen_acpi_os_ioremap (acpi_physical_address phys, +acpi_size size) +{ +unsigned int i; +const struct nonram_remap *remap = xen_nonram_remap; + +for (i =0 ; i < nr_nonram_remap; i++) { +if (phys + size > remap->maddr && + phys < remap->maddr + remap->size) { +WARN_ON (phys < remap->maddr || + phys + size > remap->maddr + remap->size); + phys += remap->paddr - remap->maddr; +break ; + } + } + +return x86_acpi_os_ioremap (phys, size); +} +#endif /* CONFIG_ACPI */ +/* * Add a new non-RAM remap entry. * In case of no free entry found, just crash the system.
@@ -849,6 +878,12 @@ void __init xen_add_remap_nonram(phys_adBUG (); } +#ifdef CONFIG_ACPI +/* Switch to the Xen acpi_os_ioremap() variant. */ +if (nr_nonram_remap ==0 ) + acpi_os_ioremap = xen_acpi_os_ioremap; +#endif + xen_nonram_remap[nr_nonram_remap].maddr = maddr; xen_nonram_remap[nr_nonram_remap].paddr = paddr; xen_nonram_remap[nr_nonram_remap].size = size;
arch/x86/xen/setup.c +1 -1
@@ -15,12 +15,12 @@#include <linux/cpuidle.h> #include <linux/cpufreq.h> #include <linux/memory_hotplug.h> +#include <linux/acpi.h> #include <asm/elf.h> #include <asm/vdso.h> #include <asm/e820/api.h> #include <asm/setup.h> -#include <asm/acpi.h> #include <asm/numa.h> #include <asm/idtentry.h> #include <asm/xen/hypervisor.h>
Greg Kroah-Hartman
maintainerPATCH 459/634 io_uring/sqpoll: retain test for whether the CPU is valid
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit a09c17240bdf2e9fa6d0591afa9448b59785f7d4 upstream.
A recent commit ensured that SQPOLL cannot be setup with a CPU that isn't in the current tasks cpuset, but it also dropped testing whether the CPU is valid in the first place. Without that, if a task passes in a CPU value that is too high, the following KASAN splat can get triggered:
BUG: KASAN: stack-out-of-bounds in io_sq_offload_create+0x858/0xaa4 Read of size 8 at addr ffff800089bc7b90 by task wq-aff.t/1391 CPU: 4 UID: 1000 PID: 1391 Comm: wq-aff.t Not tainted 6.11.0-rc7-00227-g371c468f4db6 #7080 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace.part.0+0xcc/0xe0 show_stack+0x14/0x1c dump_stack_lvl+0x58/0x74 print_report+0x16c/0x4c8 kasan_report+0x9c/0xe4 __asan_report_load8_noabort+0x1c/0x24 io_sq_offload_create+0x858/0xaa4 io_uring_setup+0x1394/0x17c4 __arm64_sys_io_uring_setup+0x6c/0x180 invoke_syscall+0x6c/0x260 el0_svc_common.constprop.0+0x158/0x224 do_el0_svc+0x3c/0x5c el0_svc+0x34/0x70 el0t_64_sync_handler+0x118/0x124 el0t_64_sync+0x168/0x16c The buggy address belongs to stack of task wq-aff.t/1391 and is located at offset 48 in frame: io_sq_offload_create+0x0/0xaa4
This frame has 1 object:
[32, 40) 'allowed_mask'
The buggy address belongs to the virtual mapping at
[ffff800089bc0000, ffff800089bc9000) created by:
kernel_clone+0x124/0x7e0
The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff0000d740af80 pfn:0x11740a
memcg:ffff0000c2706f02
flags: 0xbffe00000000000(node=0|zone=2|lastcpupid=0x1fff)
raw: 0bffe00000000000 0000000000000000 dead000000000122 0000000000000000
raw: ffff0000d740af80 0000000000000000 00000001ffffffff ffff0000c2706f02
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff800089bc7a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff800089bc7b00: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
>ffff800089bc7b80: 00 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
^
ffff800089bc7c00: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
ffff800089bc7c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f3--- io_uring/sqpoll.c | 2 ++ 1 file changed, 2 insertions(+)
io_uring/sqpoll.c +2 -0
@@ -465,6 +465,8 @@ __cold int io_sq_offload_create(struct iint cpu = p->sq_thread_cpu; ret = -EINVAL ; +if (cpu >= nr_cpu_ids || !cpu_online (cpu)) + goto err_sqpoll;cpuset_cpus_allowed (current, &allowed_mask);if (!cpumask_test_cpu (cpu, &allowed_mask)) goto err_sqpoll;
Greg Kroah-Hartman
maintainerPATCH 460/634 io_uring/sqpoll: do not put cpumask on stack
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Moessbauer <[email protected]>
commit 7f44beadcc11adb98220556d2ddbe9c97aa6d42d upstream.
Putting the cpumask on the stack is deprecated for a long time (since 2d3854a37e8), as these can be big. Given that, change the on-stack allocation of allowed_mask to be dynamically allocated.
--- io_uring/sqpoll.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
io_uring/sqpoll.c +10 -3
@@ -461,15 +461,22 @@ __cold int io_sq_offload_create(struct ireturn 0 ;if (p->flags &IORING_SETUP_SQ_AFF ) { -struct cpumask allowed_mask; +cpumask_var_t allowed_mask;int cpu = p->sq_thread_cpu; ret = -EINVAL ;if (cpu >= nr_cpu_ids || !cpu_online (cpu)) goto err_sqpoll; -cpuset_cpus_allowed (current, &allowed_mask); -if (!cpumask_test_cpu (cpu, &allowed_mask)) + ret = -ENOMEM ; +if (!alloc_cpumask_var (&allowed_mask,GFP_KERNEL )) goto err_sqpoll; + ret = -EINVAL ; +cpuset_cpus_allowed (current, allowed_mask); +if (!cpumask_test_cpu (cpu, allowed_mask)) { +free_cpumask_var (allowed_mask); + goto err_sqpoll; + } +free_cpumask_var (allowed_mask); sqd->sq_cpu = cpu; }else { sqd->sq_cpu =-1 ;
Greg Kroah-Hartman
maintainerPATCH 461/634 selftests/bpf: correctly move log upon successful match
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduard Zingerman <[email protected]>
commit d0a29cdb6ef95d8a175e09ab2d1334271f047e60 upstream.
Suppose log="foo bar buz" and msg->substr="bar".
In such case current match processing logic would update 'log' as
follows: log += strlen(msg->substr); -> log += 3 -> log=" bar". However, the intent behind the 'log' update is to make it point after the successful match, e.g. to make log=" buz" in the example above.
--- tools/testing/selftests/bpf/test_loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/test_loader.c +1 -1
@@ -545,7 +545,7 @@ static void validate_msgs(char *log_buf,if (msg->substr) { match =strstr (log, msg->substr);if (match) - log +=strlen (msg->substr); + log = match +strlen (msg->substr); }else { err =regexec (&msg->regex, log,1 , reg_match,0 );if (err ==0 ) {
Greg Kroah-Hartman
maintainerPATCH 462/634 Remove *.orig pattern from .gitignore
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Pinchart <[email protected]>
commit 76be4f5a784533c71afbbb1b8f2963ef9e2ee258 upstream.
Commit 3f1b0e1f2875 (".gitignore update") added *.orig and *.rej patterns to .gitignore in v2.6.23. The commit message didn't give a rationale. Later on, commit 1f5d3a6b6532 ("Remove *.rej pattern from .gitignore") removed the *.rej pattern in v2.6.26, on the rationale that *.rej files indicated something went really wrong and should not be ignored.
The *.rej files are now shown by git status, which helps located conflicts when applying patches and lowers the probability that they will go unnoticed. It is however still easy to overlook the *.orig files which slowly polute the source tree. That's not as big of a deal as not noticing a conflict, but it's still not nice.
Drop the *.orig pattern from .gitignore to avoid this and help keep the source tree clean.
[[email protected]:
I do not have a strong opinion about this. Perhaps some people may have a different opinion.
If you are someone who wants to ignore *.orig, it is likely you would want to do so across all projects. Then, $XDG_CONFIG_HOME/git/ignore would be more suitable for your needs. gitignore(5) suggests, "Patterns which a user wants Git to ignore in all situations generally go into a file specified by core.excludesFile in the user's ~/.gitconfig".
Please note that you cannot do the opposite; if *.orig is ignored by the project's .gitignore, you cannot override the decision because $XDG_CONFIG_HOME/git/ignore has a lower priority.
If *.orig is sitting on the fence, I'd leave it to the users. ]
--- .gitignore | 1 - 1 file changed, 1 deletion(-)
.gitignore +0 -1
@@ -136,7 +136,6 @@ GTAGS # id-utils files ID -*.orig *~ \#*#
Greg Kroah-Hartman
maintainerPATCH 463/634 PCI: Revert to the original speed after PCIe failed link retraining
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit f68dea13405c94381d08f42dbf0416261622bdad upstream.
When `pcie_failed_link_retrain' has failed to retrain the link by hand it leaves the link speed restricted to 2.5GT/s, which will then affect any device that has been plugged in later on, which may not suffer from the problem that caused the speed restriction to have been attempted. Consequently such a downstream device will suffer from an unnecessary communication throughput limitation and therefore performance loss.
Remove the speed restriction then and revert the Link Control 2 register to its original state if link retraining with the speed restriction in place has failed. Retrain the link again afterwards so as to remove any residual state, waiting on LT rather than DLLLA to avoid an excessive delay and ignoring the result as this training is supposed to fail anyway.
--- drivers/pci/quirks.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/pci/quirks.c +10 -1
@@ -66,7 +66,7 @@* apply this erratum workaround to any downstream ports as long as they * support Link Active reporting and have the Link Control 2 register. * Restrict the speed to 2.5GT/s then with the Target Link Speed field, -* request a retrain and wait 200ms for the data link to go up. +* request a retrain and check the result. * * If this turns out successful and we know by the Vendor:Device ID it is * safe to do so, then lift the restriction, letting the devices negotiate
@@ -74,6 +74,10 @@* firmware may have already arranged and lift it with ports that already * report their data link being up. * +* Otherwise revert the speed to the original setting and request a retrain +* again to remove any residual state, ignoring the result as it's supposed +* to fail anyway. +* * Return TRUE if the link has been successfully retrained, otherwise FALSE. */ bool pcie_failed_link_retrain (struct pci_dev *dev)
@@ -92,6 +96,8 @@ bool pcie_failed_link_retrain(struct pcipcie_capability_read_word (dev,PCI_EXP_LNKSTA , &lnksta);if ((lnksta & (PCI_EXP_LNKSTA_LBMS |PCI_EXP_LNKSTA_DLLLA )) ==PCI_EXP_LNKSTA_LBMS ) { +u16 oldlnkctl2 = lnkctl2; +pci_info (dev,"broken device, retraining non-functional downstream link at 2.5GT/s\n" ); lnkctl2 &= ~PCI_EXP_LNKCTL2_TLS ;
@@ -100,6 +106,9 @@ bool pcie_failed_link_retrain(struct pciif (pcie_retrain_link (dev, false)) {pci_info (dev,"retraining failed\n" ); +pcie_capability_write_word (dev,PCI_EXP_LNKCTL2 , + oldlnkctl2); +pcie_retrain_link (dev, true);return false; }
Greg Kroah-Hartman
maintainerPATCH 464/634 PCI: Clear the LBMS bit after a link retrain
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 8037ac08c2bbb3186f83a5a924f52d1048dbaec5 upstream.
The LBMS bit, where implemented, is set by hardware either in response to the completion of retraining caused by writing 1 to the Retrain Link bit or whenever hardware has changed the link speed or width in attempt to correct unreliable link operation. It is never cleared by hardware other than by software writing 1 to the bit position in the Link Status register and we never do such a write.
We currently have two places, namely apply_bad_link_workaround() and pcie_failed_link_retrain() in drivers/pci/controller/dwc/pcie-tegra194.c and drivers/pci/quirks.c respectively where we check the state of the LBMS bit and neither is interested in the state of the bit resulting from the completion of retraining, both check for a link fault.
And in particular pcie_failed_link_retrain() causes issues consequently, by trying to retrain a link where there's no downstream device anymore and the state of 1 in the LBMS bit has been retained from when there was a device downstream that has since been removed.
Clear the LBMS bit then at the conclusion of pcie_retrain_link(), so that we have a single place that controls it and that our code can track link speed or width changes resulting from unreliable link operation.
--- drivers/pci/pci.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/pci/pci.c +9 -1
@@ -4647,7 +4647,15 @@ int pcie_retrain_link(struct pci_dev *pdpcie_capability_clear_word (pdev,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_RL ); } -return pcie_wait_for_link_status (pdev, use_lt, !use_lt); + rc =pcie_wait_for_link_status (pdev, use_lt, !use_lt); + +/* +* Clear LBMS after a manual retrain so that the bit can be used +* to track link speed or width changes made by hardware itself +* in attempt to correct unreliable link operation. +*/ +pcie_capability_write_word (pdev,PCI_EXP_LNKSTA ,PCI_EXP_LNKSTA_LBMS ); +return rc; }/**
Greg Kroah-Hartman
maintainerPATCH 465/634 PCI: dra7xx: Fix threaded IRQ request for "dra7xx-pcie-main" IRQ
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siddharth Vadapalli <[email protected]>
commit 03f84b3baba7836bdfc162c19288d5ce1aa92890 upstream.
Commit da87d35a6e51 ("PCI: dra7xx: Use threaded IRQ handler for "dra7xx-pcie-main" IRQ") switched from devm_request_irq() to devm_request_threaded_irq() for the "dra7xx-pcie-main" interrupt.
Since the primary handler was set to NULL, the "IRQF_ONESHOT" flag should have also been set. Fix this.
--- drivers/pci/controller/dwc/pci-dra7xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pci-dra7xx.c +2 -1
@@ -850,7 +850,8 @@ static int dra7xx_pcie_probe(struct plat dra7xx->mode = mode; ret =devm_request_threaded_irq (dev, irq,NULL , dra7xx_pcie_irq_handler, -IRQF_SHARED ,"dra7xx-pcie-main" , dra7xx); +IRQF_SHARED |IRQF_ONESHOT , +"dra7xx-pcie-main" , dra7xx);if (ret) {dev_err (dev,"failed to request irq\n" ); goto err_gpio;
Greg Kroah-Hartman
maintainerPATCH 466/634 PCI: imx6: Fix missing call to phy_power_off() in error handling
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit 5b04d44d5c74e4d8aab1678496b84700b4b343fe upstream.
Fix missing call to phy_power_off() in the error path of imx6_pcie_host_init(). Remove unnecessary check for imx6_pcie->phy as the PHY API already handles NULL pointers.
--- drivers/pci/controller/dwc/pci-imx6.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pci-imx6.c +4 -3
@@ -958,7 +958,7 @@ static int imx6_pcie_host_init(struct dw ret =phy_power_on (imx6_pcie->phy);if (ret) {dev_err (dev,"waiting for PHY ready timeout!\n" ); - goto err_phy_off; + goto err_phy_exit; } }
@@ -973,8 +973,9 @@ static int imx6_pcie_host_init(struct dwreturn 0 ; err_phy_off: -if (imx6_pcie->phy) -phy_exit (imx6_pcie->phy); +phy_power_off (imx6_pcie->phy); +err_phy_exit: +phy_exit (imx6_pcie->phy); err_clk_disable:imx6_pcie_clk_disable (imx6_pcie); err_reg_disable:
Greg Kroah-Hartman
maintainerPATCH 467/634 PCI: imx6: Fix establish link failure in EP mode for i.MX8MM and i.MX8MP
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Zhu <[email protected]>
commit 5214ff221a14cadab1e2ee29499750fd5e884feb upstream.
Add IMX6_PCIE_FLAG_HAS_APP_RESET flag to IMX8MM_EP and IMX8MP_EP drvdata.
This flag was overlooked during code restructuring. It is crucial to release the app-reset from the System Reset Controller before initiating LTSSM to rectify the issue.
--- drivers/pci/controller/dwc/pci-imx6.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pci-imx6.c +4 -2
@@ -1579,7 +1579,8 @@ static const struct imx6_pcie_drvdata dr }, [IMX8MM_EP] = { .variant = IMX8MM_EP, - .flags = IMX6_PCIE_FLAG_HAS_PHYDRV, + .flags =IMX6_PCIE_FLAG_HAS_APP_RESET | + IMX6_PCIE_FLAG_HAS_PHYDRV, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mm-iomuxc-gpr", .clk_names = imx8mm_clks,
@@ -1590,7 +1591,8 @@ static const struct imx6_pcie_drvdata dr }, [IMX8MP_EP] = { .variant = IMX8MP_EP, - .flags = IMX6_PCIE_FLAG_HAS_PHYDRV, + .flags =IMX6_PCIE_FLAG_HAS_APP_RESET | + IMX6_PCIE_FLAG_HAS_PHYDRV, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mp-iomuxc-gpr", .clk_names = imx8mm_clks,
Greg Kroah-Hartman
maintainerPATCH 468/634 PCI: imx6: Fix i.MX8MP PCIe EPs occasional failure to trigger MSI
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Zhu <[email protected]>
commit 5cb3aa92c7cf182940ae575c3f450d3708af087c upstream.
Correct occasional MSI triggering failures in i.MX8MP PCIe EP by applying the correct hardware outbound alignment requirement.
The i.MX platform has a restriction about outbound address translation. The pci-epc-mem uses page_size to manage it. Set the correct page_size for i.MX platform to meet the hardware requirement, which is the same as inbound address alignment.
Thus, align it with epc_features::align.
--- drivers/pci/controller/dwc/pci-imx6.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/controller/dwc/pci-imx6.c +2 -0
@@ -1119,6 +1119,8 @@ static int imx6_add_pcie_ep(struct imx6_if (imx6_check_flag (imx6_pcie,IMX6_PCIE_FLAG_SUPPORT_64BIT ))dma_set_mask_and_coherent (dev,DMA_BIT_MASK (64 )); + ep->page_size = imx6_pcie->drvdata->epc_features->align; + ret =dw_pcie_ep_init (ep);if (ret) {dev_err (dev,"failed to initialize endpoint\n" );
Greg Kroah-Hartman
maintainerPATCH 469/634 PCI: Correct error reporting with PCIe failed link retraining
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 712e49c967064a3a7a5738c6f65ac540a3f6a1df upstream.
Only return successful completion status from pcie_failed_link_retrain() if retraining has actually been done, preventing excessive delays from being triggered at call sites in a hope that communication will finally be established with the downstream device where in fact nothing has been done about the link in question that would justify such a hope.
--- drivers/pci/quirks.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/pci/quirks.c +8 -4
@@ -78,7 +78,8 @@* again to remove any residual state, ignoring the result as it's supposed * to fail anyway. * -* Return TRUE if the link has been successfully retrained, otherwise FALSE. +* Return TRUE if the link has been successfully retrained. Return FALSE +* if retraining was not needed or we attempted a retrain and it failed. */ bool pcie_failed_link_retrain (struct pci_dev *dev) {
@@ -87,6 +88,7 @@ bool pcie_failed_link_retrain(struct pci {} };u16 lnksta, lnkctl2; +bool ret = false;if (!pci_is_pcie (dev) || !pcie_downstream_port (dev) || !pcie_cap_has_lnkctl2 (dev) || !dev->link_active_reporting)
@@ -104,7 +106,8 @@ bool pcie_failed_link_retrain(struct pci lnkctl2 |=PCI_EXP_LNKCTL2_TLS_2_5GT ;pcie_capability_write_word (dev,PCI_EXP_LNKCTL2 , lnkctl2); -if (pcie_retrain_link (dev, false)) { + ret =pcie_retrain_link (dev, false) ==0 ; +if (!ret) {pci_info (dev,"retraining failed\n" );pcie_capability_write_word (dev,PCI_EXP_LNKCTL2 , oldlnkctl2);
@@ -126,13 +129,14 @@ bool pcie_failed_link_retrain(struct pci lnkctl2 |= lnkcap &PCI_EXP_LNKCAP_SLS ;pcie_capability_write_word (dev,PCI_EXP_LNKCTL2 , lnkctl2); -if (pcie_retrain_link (dev, false)) { + ret =pcie_retrain_link (dev, false) ==0 ; +if (!ret) {pci_info (dev,"retraining failed\n" );return false; } } -return true; +return ret; } static ktime_t fixup_debug_start(struct pci_dev *dev,
Greg Kroah-Hartman
maintainerPATCH 470/634 PCI: Use an error code with PCIe failed link retraining
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 59100eb248c0b15585affa546c7f6834b30eb5a4 upstream.
Given how the call place in pcie_wait_for_link_delay() got structured now, and that pcie_retrain_link() returns a potentially useful error code, convert pcie_failed_link_retrain() to return an error code rather than a boolean status, fixing handling at the call site mentioned. Update the other call site accordingly.
--- drivers/pci/pci.c | 2 +- drivers/pci/pci.h | 6 +++--- drivers/pci/quirks.c | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-)
drivers/pci/pci.c +1 -1
@@ -1295,7 +1295,7 @@ static int pci_dev_wait(struct pci_dev *if (delay >PCI_RESET_WAIT ) {if (retrain) { retrain = false; -if (pcie_failed_link_retrain (bridge)) { +if (pcie_failed_link_retrain (bridge) ==0 ) { delay =1 ;continue ; }
drivers/pci/pci.h +3 -3
@@ -541,7 +541,7 @@ void pci_acs_init(struct pci_dev *dev);int pci_dev_specific_acs_enabled (struct pci_dev *dev,u16 acs_flags);int pci_dev_specific_enable_acs (struct pci_dev *dev);int pci_dev_specific_disable_acs_redir (struct pci_dev *dev); -bool pcie_failed_link_retrain (struct pci_dev *dev); +int pcie_failed_link_retrain (struct pci_dev *dev);#else static inline int pci_dev_specific_acs_enabled (struct pci_dev *dev,u16 acs_flags)
@@ -556,9 +556,9 @@ static inline int pci_dev_specific_disab {return -ENOTTY ; } -static inline bool pcie_failed_link_retrain (struct pci_dev *dev) +static inline int pcie_failed_link_retrain (struct pci_dev *dev) { -return false; +return -ENOTTY ; }#endif
drivers/pci/quirks.c +10 -10
@@ -78,21 +78,21 @@* again to remove any residual state, ignoring the result as it's supposed * to fail anyway. * -* Return TRUE if the link has been successfully retrained. Return FALSE +* Return 0 if the link has been successfully retrained. Return an error * if retraining was not needed or we attempted a retrain and it failed. */ -bool pcie_failed_link_retrain (struct pci_dev *dev) +int pcie_failed_link_retrain (struct pci_dev *dev) {static const struct pci_device_id ids[] = { {PCI_VDEVICE (ASMEDIA ,0x2824 ) },/* ASMedia ASM2824 */ {} };u16 lnksta, lnkctl2; -bool ret = false; +int ret = -ENOTTY ;if (!pci_is_pcie (dev) || !pcie_downstream_port (dev) || !pcie_cap_has_lnkctl2 (dev) || !dev->link_active_reporting) -return false; +return ret;pcie_capability_read_word (dev,PCI_EXP_LNKCTL2 , &lnkctl2);pcie_capability_read_word (dev,PCI_EXP_LNKSTA , &lnksta);
@@ -106,13 +106,13 @@ bool pcie_failed_link_retrain(struct pci lnkctl2 |=PCI_EXP_LNKCTL2_TLS_2_5GT ;pcie_capability_write_word (dev,PCI_EXP_LNKCTL2 , lnkctl2); - ret =pcie_retrain_link (dev, false) ==0 ; -if (!ret) { + ret =pcie_retrain_link (dev, false); +if (ret) {pci_info (dev,"retraining failed\n" );pcie_capability_write_word (dev,PCI_EXP_LNKCTL2 , oldlnkctl2);pcie_retrain_link (dev, true); -return false; +return ret; }pcie_capability_read_word (dev,PCI_EXP_LNKSTA , &lnksta);
@@ -129,10 +129,10 @@ bool pcie_failed_link_retrain(struct pci lnkctl2 |= lnkcap &PCI_EXP_LNKCAP_SLS ;pcie_capability_write_word (dev,PCI_EXP_LNKCTL2 , lnkctl2); - ret =pcie_retrain_link (dev, false) ==0 ; -if (!ret) { + ret =pcie_retrain_link (dev, false); +if (ret) {pci_info (dev,"retraining failed\n" ); -return false; +return ret; } }
Greg Kroah-Hartman
maintainerPATCH 471/634 PCI: xilinx-nwl: Fix off-by-one in INTx IRQ handler
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Anderson <[email protected]>
commit 0199d2f2bd8cd97b310f7ed82a067247d7456029 upstream.
MSGF_LEG_MASK is laid out with INTA in bit 0, INTB in bit 1, INTC in bit 2, and INTD in bit 3. Hardware IRQ numbers start at 0, and we register PCI_NUM_INTX IRQs. So to enable INTA (aka hwirq 0) we should set bit 0. Remove the subtraction of one.
This bug would cause INTx interrupts not to be delivered, as enabling INTB would actually enable INTA, and enabling INTA wouldn't enable anything at all. It is likely that this got overlooked for so long since most PCIe hardware uses MSIs. This fixes the following UBSAN error:
UBSAN: shift-out-of-bounds in ../drivers/pci/controller/pcie-xilinx-nwl.c:389:11 shift exponent 18446744073709551615 is too large for 32-bit type 'int' CPU: 1 PID: 61 Comm: kworker/u10:1 Not tainted 6.6.20+ #268 Hardware name: xlnx,zynqmp (DT) Workqueue: events_unbound deferred_probe_work_func Call trace: dump_backtrace (arch/arm64/kernel/stacktrace.c:235) show_stack (arch/arm64/kernel/stacktrace.c:242) dump_stack_lvl (lib/dump_stack.c:107) dump_stack (lib/dump_stack.c:114) __ubsan_handle_shift_out_of_bounds (lib/ubsan.c:218 lib/ubsan.c:387) nwl_unmask_leg_irq (drivers/pci/controller/pcie-xilinx-nwl.c:389 (discriminator 1)) irq_enable (kernel/irq/internals.h:234 kernel/irq/chip.c:170 kernel/irq/chip.c:439 kernel/irq/chip.c:432 kernel/irq/chip.c:345) __irq_startup (kernel/irq/internals.h:239 kernel/irq/chip.c:180 kernel/irq/chip.c:250) irq_startup (kernel/irq/chip.c:270) __setup_irq (kernel/irq/manage.c:1800) request_threaded_irq (kernel/irq/manage.c:2206) pcie_pme_probe (include/linux/interrupt.h:168 drivers/pci/pcie/pme.c:348)
--- drivers/pci/controller/pcie-xilinx-nwl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-xilinx-nwl.c +2 -2
@@ -371,7 +371,7 @@ static void nwl_mask_intx_irq(struct irqu32 mask;u32 val; - mask =1 << (data->hwirq -1 ); + mask =1 << data->hwirq;raw_spin_lock_irqsave (&pcie->leg_mask_lock, flags); val =nwl_bridge_readl (pcie,MSGF_LEG_MASK );nwl_bridge_writel (pcie, (val & (~mask)),MSGF_LEG_MASK );
@@ -385,7 +385,7 @@ static void nwl_unmask_intx_irq(struct iu32 mask;u32 val; - mask =1 << (data->hwirq -1 ); + mask =1 << data->hwirq;raw_spin_lock_irqsave (&pcie->leg_mask_lock, flags); val =nwl_bridge_readl (pcie,MSGF_LEG_MASK );nwl_bridge_writel (pcie, (val | mask),MSGF_LEG_MASK );
Greg Kroah-Hartman
maintainerPATCH 472/634 PCI: dra7xx: Fix error handling when IRQ request fails in probe
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siddharth Vadapalli <[email protected]>
commit 4d60f6d4b8fa4d7bad4aeb2b3ee5c10425bc60a4 upstream.
Commit d4c7d1a089d6 ("PCI: dwc: dra7xx: Push request_irq() call to the bottom of probe") moved the IRQ request for "dra7xx-pcie-main" towards the end of dra7xx_pcie_probe().
However, the error handling does not take into account the initialization performed by either dra7xx_add_pcie_port() or dra7xx_add_pcie_ep(), depending on the mode of operation.
Fix the error handling to address this.
--- drivers/pci/controller/dwc/pci-dra7xx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pci-dra7xx.c +7 -1
@@ -854,11 +854,17 @@ static int dra7xx_pcie_probe(struct plat "dra7xx-pcie-main", dra7xx);if (ret) {dev_err (dev,"failed to request irq\n" ); - goto err_gpio; + goto err_deinit; }return 0 ; +err_deinit: +if (dra7xx->mode ==DW_PCIE_RC_TYPE ) +dw_pcie_host_deinit (&dra7xx->pci->pp); +else +dw_pcie_ep_deinit (&dra7xx->pci->ep); + err_gpio: err_get_sync:pm_runtime_put (dev);
Greg Kroah-Hartman
maintainerPATCH 473/634 Revert "soc: qcom: smd-rpm: Match rpmsg channel instead of compatible"
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
commit b17155133391d7f6dd18d3fb94a7d492fdec18fa upstream.
The rpm_requests device nodes have the compatible node. As such the rpmsg core uses OF modalias instead of a native rpmsg modalias. Thus if smd-rpm is built as a module, it doesn't get autoloaded for the device.
Revert the commit bcabe1e09135 ("soc: qcom: smd-rpm: Match rpmsg channel instead of compatible")
--- drivers/soc/qcom/smd-rpm.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)
drivers/soc/qcom/smd-rpm.c +26 -9
@@ -196,9 +196,6 @@ static int qcom_smd_rpm_probe(struct rpm {struct qcom_smd_rpm *rpm; -if (!rpdev->dev.of_node) -return -EINVAL ; - rpm =devm_kzalloc (&rpdev->dev,sizeof (*rpm),GFP_KERNEL );if (!rpm)return -ENOMEM ;
@@ -218,18 +215,38 @@ static void qcom_smd_rpm_remove(struct rof_platform_depopulate (&rpdev->dev); } -static const struct rpmsg_device_id qcom_smd_rpm_id_table[] = { - { .name ="rpm_requests" , }, - {/* sentinel */ } +static const struct of_device_id qcom_smd_rpm_of_match[] = { + { .compatible ="qcom,rpm-apq8084" }, + { .compatible ="qcom,rpm-ipq6018" }, + { .compatible ="qcom,rpm-ipq9574" }, + { .compatible ="qcom,rpm-msm8226" }, + { .compatible ="qcom,rpm-msm8909" }, + { .compatible ="qcom,rpm-msm8916" }, + { .compatible ="qcom,rpm-msm8936" }, + { .compatible ="qcom,rpm-msm8953" }, + { .compatible ="qcom,rpm-msm8974" }, + { .compatible ="qcom,rpm-msm8976" }, + { .compatible ="qcom,rpm-msm8994" }, + { .compatible ="qcom,rpm-msm8996" }, + { .compatible ="qcom,rpm-msm8998" }, + { .compatible ="qcom,rpm-sdm660" }, + { .compatible ="qcom,rpm-sm6115" }, + { .compatible ="qcom,rpm-sm6125" }, + { .compatible ="qcom,rpm-sm6375" }, + { .compatible ="qcom,rpm-qcm2290" }, + { .compatible ="qcom,rpm-qcs404" }, + {} }; -MODULE_DEVICE_TABLE (rpmsg, qcom_smd_rpm_id_table); +MODULE_DEVICE_TABLE (of, qcom_smd_rpm_of_match);static struct rpmsg_driver qcom_smd_rpm_driver = { .probe = qcom_smd_rpm_probe, .remove = qcom_smd_rpm_remove, .callback = qcom_smd_rpm_callback, - .id_table = qcom_smd_rpm_id_table, - .drv.name ="qcom_smd_rpm" , + .drv = { + .name ="qcom_smd_rpm" , + .of_match_table = qcom_smd_rpm_of_match, + }, };static int __init qcom_smd_rpm_init (void )
Greg Kroah-Hartman
maintainerPATCH 474/634 ASoC: rt5682: Return devm_of_clk_add_hw_provider to transfer the error
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit fcca6d05ef49d5650514ea1dcfd12e4ae3ff2be6 upstream.
Return devm_of_clk_add_hw_provider() in order to transfer the error, if it fails due to resource allocation failure or device tree clock provider registration failure.
--- sound/soc/codecs/rt5682.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5682.c +3 -1
@@ -2903,8 +2903,10 @@ int rt5682_register_dai_clks(struct rt56 }if (dev->of_node) { -devm_of_clk_add_hw_provider (dev, of_clk_hw_simple_get, + ret =devm_of_clk_add_hw_provider (dev, of_clk_hw_simple_get, dai_clk_hw); +if (ret) +return ret; }else { ret = devm_clk_hw_register_clkdev(dev, dai_clk_hw, init.name,
Greg Kroah-Hartman
maintainerPATCH 475/634 soc: fsl: cpm1: qmc: Update TRNSYNC only in transparent mode
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herve Codina <[email protected]>
commit c3cc3e69b33fee3d276895e0e2d1a8fb37ea5d0e upstream.
The TRNSYNC feature is available (and enabled) only in transparent mode.
Since commit 7cc9bda9c163 ("soc: fsl: cpm1: qmc: Handle timeslot entries at channel start() and stop()") TRNSYNC register is updated in transparent and hdlc mode. In hdlc mode, the address of the TRNSYNC register is used by the QMC for other internal purpose. Even if no weird results were observed in hdlc mode, touching this register in this mode is wrong.
Update TRNSYNC only in transparent mode.
--- drivers/soc/fsl/qe/qmc.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/soc/fsl/qe/qmc.c +14 -10
@@ -940,11 +940,13 @@ static int qmc_chan_start_rx(struct qmc_chan *chan) goto end; } - ret =qmc_setup_chan_trnsync (chan->qmc, chan); -if (ret) { -dev_err (chan->qmc->dev,"chan %u: setup TRNSYNC failed (%d)\n" , - chan->id, ret); - goto end; +if (chan->mode ==QMC_TRANSPARENT ) { + ret =qmc_setup_chan_trnsync (chan->qmc, chan); +if (ret) { +dev_err (chan->qmc->dev,"chan %u: setup TRNSYNC failed (%d)\n" , + chan->id, ret); + goto end; + } }/* Restart the receiver */
@@ -982,11 +984,13 @@ static int qmc_chan_start_tx(struct qmc_chan *chan) goto end; } - ret =qmc_setup_chan_trnsync (chan->qmc, chan); -if (ret) { -dev_err (chan->qmc->dev,"chan %u: setup TRNSYNC failed (%d)\n" , - chan->id, ret); - goto end; +if (chan->mode ==QMC_TRANSPARENT ) { + ret =qmc_setup_chan_trnsync (chan->qmc, chan); +if (ret) { +dev_err (chan->qmc->dev,"chan %u: setup TRNSYNC failed (%d)\n" , + chan->id, ret); + goto end; + } }/*
Signature · 1 line
2.46.2
Greg Kroah-Hartman
maintainerPATCH 476/634 soc: fsl: cpm1: tsa: Fix tsa_write8()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herve Codina <[email protected]>
commit 47a347bae9a491b467ab3543e4725a3e4fbe30f5 upstream.
The tsa_write8() parameter is an u32 value. This is not consistent with the function itself. Indeed, tsa_write8() writes an 8bits value.
Be consistent and use an u8 parameter value.
--- drivers/soc/fsl/qe/tsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/fsl/qe/tsa.c +1 -1
@@ -140,7 +140,7 @@ static inline void tsa_write32(void __ioiowrite32be (val, addr); } -static inline void tsa_write8 (void __iomem *addr,u32 val) +static inline void tsa_write8 (void __iomem *addr,u8 val) {iowrite8 (val, addr); }
Greg Kroah-Hartman
maintainerPATCH 477/634 soc: versatile: integrator: fix OF node leak in probe() error path
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 874c5b601856adbfda10846b9770a6c66c41e229 upstream.
Driver is leaking OF node reference obtained fromof_find_matching_node().
--- drivers/soc/versatile/soc-integrator.c | 1 + 1 file changed, 1 insertion(+)
drivers/soc/versatile/soc-integrator.c +1 -0
@@ -113,6 +113,7 @@ static int __init integrator_soc_init(voreturn -ENODEV ; syscon_regmap =syscon_node_to_regmap (np); +of_node_put (np);if (IS_ERR (syscon_regmap))return PTR_ERR (syscon_regmap);
Greg Kroah-Hartman
maintainerPATCH 478/634 Revert "media: tuners: fix error return code of hybrid_tuner_request_state()"
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roman Smirnov <[email protected]>
commit e25cc4be4616fcf5689622b3226d648aab253cdb upstream.
This reverts commit b9302fa7ed979e84b454e4ca92192cf485a4ed41.
As Fedor Pchelkin pointed out, this commit violates the convention of using the macro return value, which causes errors. For example, in functions tda18271_attach(), xc5000_attach(), simple_tuner_attach().
--- drivers/media/tuners/tuner-i2c.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/tuners/tuner-i2c.h +1 -3
@@ -133,10 +133,8 @@ static inline int tuner_i2c_xfer_send_re } \if (0 == __ret) { \ state =kzalloc (sizeof (type),GFP_KERNEL ); \ -if (!state) { \ - __ret = -ENOMEM ; \ +if (NULL == state) \ goto __fail; \ - } \ state->i2c_props.addr = i2caddr; \ state->i2c_props.adap = i2cadap; \ state->i2c_props.name = devname; \
Greg Kroah-Hartman
maintainerPATCH 479/634 iommu/amd: Fix argument order in amd_iommu_dev_flush_pasid_all()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eliav Bar-ilan <[email protected]>
commit 8386207f37e98453e1de3f51e50eeeea089103f9 upstream.
An incorrect argument order calling amd_iommu_dev_flush_pasid_pages() causes improper flushing of the IOMMU, leaving the old value of GCR3 from a previous process attached to the same PASID.
The function has the signature:
void amd_iommu_dev_flush_pasid_pages(struct iommu_dev_data *dev_data,
ioasid_t pasid, u64 address, size_t size)
Correct the argument order.
--- drivers/iommu/amd/iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/amd/iommu.c +2 -2
@@ -1550,8 +1550,8 @@ void amd_iommu_dev_flush_pasid_pages(strvoid amd_iommu_dev_flush_pasid_all (struct iommu_dev_data *dev_data,ioasid_t pasid) { -amd_iommu_dev_flush_pasid_pages (dev_data,0 , -CMD_INV_IOMMU_ALL_PAGES_ADDRESS , pasid); +amd_iommu_dev_flush_pasid_pages (dev_data, pasid,0 , +CMD_INV_IOMMU_ALL_PAGES_ADDRESS ); }void amd_iommu_domain_flush_complete (struct protection_domain *domain)
Greg Kroah-Hartman
maintainerPATCH 480/634 iommufd: Protect against overflow of ALIGN() during iova allocation
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit 8f6887349b2f829a4121c518aeb064fc922714e4 upstream.
Userspace can supply an iova and uptr such that the target iova alignment becomes really big and ALIGN() overflows which corrupts the selected area range during allocation. CONFIG_IOMMUFD_TEST can detect this:
WARNING: CPU: 1 PID: 5092 at drivers/iommu/iommufd/io_pagetable.c:268 iopt_alloc_area_pages drivers/iommu/iommufd/io_pagetable.c:268 [inline]
WARNING: CPU: 1 PID: 5092 at drivers/iommu/iommufd/io_pagetable.c:268 iopt_map_pages+0xf95/0x1050 drivers/iommu/iommufd/io_pagetable.c:352
Modules linked in:
CPU: 1 PID: 5092 Comm: syz-executor294 Not tainted 6.10.0-rc5-syzkaller-00294-g3ffea9a7a6f7 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
RIP: 0010:iopt_alloc_area_pages drivers/iommu/iommufd/io_pagetable.c:268 [inline]
RIP: 0010:iopt_map_pages+0xf95/0x1050 drivers/iommu/iommufd/io_pagetable.c:352
Code: fc e9 a4 f3 ff ff e8 1a 8b 4c fc 41 be e4 ff ff ff e9 8a f3 ff ff e8 0a 8b 4c fc 90 0f 0b 90 e9 37 f5 ff ff e8 fc 8a 4c fc 90 <0f> 0b 90 e9 68 f3 ff ff 48 c7 c1 ec 82 ad 8f 80 e1 07 80 c1 03 38
RSP: 0018:ffffc90003ebf9e0 EFLAGS: 00010293
RAX: ffffffff85499fa4 RBX: 00000000ffffffef RCX: ffff888079b49e00
RDX: 0000000000000000 RSI: 00000000ffffffef RDI: 0000000000000000
RBP: ffffc90003ebfc50 R08: ffffffff85499b30 R09: ffffffff85499942
R10: 0000000000000002 R11: ffff888079b49e00 R12: ffff8880228e0010
R13: 0000000000000000 R14: 1ffff920007d7f68 R15: ffffc90003ebfd00
FS: 000055557d760380(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000005fdeb8 CR3: 000000007404a000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
iommufd_ioas_copy+0x610/0x7b0 drivers/iommu/iommufd/ioas.c:274
iommufd_fops_ioctl+0x4d9/0x5a0 drivers/iommu/iommufd/main.c:421
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:907 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7fCap the automatic alignment to the huge page size, which is probably a better idea overall. Huge automatic alignments can fragment and chew up the available IOVA space without any reason.
--- drivers/iommu/iommufd/io_pagetable.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/iommu/iommufd/io_pagetable.c +8 -0
@@ -112,6 +112,7 @@ static int iopt_alloc_iova(struct io_pagunsigned long page_offset = uptr %PAGE_SIZE ;struct interval_tree_double_span_iter used_span;struct interval_tree_span_iter allowed_span; +unsigned long max_alignment =PAGE_SIZE ;unsigned long iova_alignment;lockdep_assert_held (&iopt->iova_rwsem);
@@ -131,6 +132,13 @@ static int iopt_alloc_iova(struct io_pagroundup_pow_of_two (length), 1UL << __ffs64(uptr)); +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + max_alignment =HPAGE_SIZE ; +#endif +/* Protect against ALIGN() overflow */ +if (iova_alignment >= max_alignment) + iova_alignment = max_alignment; +if (iova_alignment < iopt->iova_alignment)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 481/634 Input: adp5588-keys - fix check on return code
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuno Sa <[email protected]>
commit eb017f4ea13b1a5ad7f4332279f2e4c67b44bdea upstream.
During adp5588_setup(), we read all the events to clear the event FIFO. However, adp5588_read() just calls i2c_smbus_read_byte_data() which returns the byte read in case everything goes well. Hence, we need to explicitly check for a negative error code instead of checking for something different than 0.
--- drivers/input/keyboard/adp5588-keys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/keyboard/adp5588-keys.c +1 -1
@@ -627,7 +627,7 @@ static int adp5588_setup(struct adp5588_for (i =0 ; i <KEYP_MAX_EVENT ; i++) { ret =adp5588_read (client,KEY_EVENTA ); -if (ret) +if (ret <0 )return ret; }
Greg Kroah-Hartman
maintainerPATCH 482/634 Input: i8042 - add TUXEDO Stellaris 16 Gen5 AMD to i8042 quirk table
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Werner Sembach <[email protected]>
commit e06edf96dea065dd1d9df695bf8b92784992333e upstream.
Some TongFang barebones have touchpad and/or keyboard issues after suspend, fixable with nomux + reset + noloop + nopnp. Luckily, none of them have an external PS/2 port so this can safely be set for all of them.
I'm not entirely sure if every device listed really needs all four quirks, but after testing and production use, no negative effects could be observed when setting all four.
--- drivers/input/serio/i8042-acpipnpio.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/input/serio/i8042-acpipnpio.h +23 -0
@@ -1121,6 +1121,29 @@ static const struct dmi_system_id i8042_ .driver_data = (void *)(SERIO_QUIRK_NOLOOP) },/* +* Some TongFang barebones have touchpad and/or keyboard issues after +* suspend fixable with nomux + reset + noloop + nopnp. Luckily, none of +* them have an external PS/2 port so this can safely be set for all of +* them. +* TongFang barebones come with board_vendor and/or system_vendor set to +* a different value for each individual reseller. The only somewhat +* universal way to identify them is by board_name. +*/ + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "GM6XGxX"), + }, + .driver_data = (void *)(SERIO_QUIRK_NOMUX |SERIO_QUIRK_RESET_ALWAYS | +SERIO_QUIRK_NOLOOP |SERIO_QUIRK_NOPNP ) + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "GMxXGxX"), + }, + .driver_data = (void *)(SERIO_QUIRK_NOMUX |SERIO_QUIRK_RESET_ALWAYS | +SERIO_QUIRK_NOLOOP |SERIO_QUIRK_NOPNP ) + }, +/* * A lot of modern Clevo barebones have touchpad and/or keyboard issues * after suspend fixable with nomux + reset + noloop + nopnp. Luckily, * none of them have an external PS/2 port so this can safely be set for
Greg Kroah-Hartman
maintainerPATCH 483/634 Input: i8042 - add TUXEDO Stellaris 15 Slim Gen6 AMD to i8042 quirk table
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Werner Sembach <[email protected]>
commit 3870e2850b56306d1d1e435c5a1ccbccd7c59291 upstream.
The Gen6 devices have the same problem and the same Solution as the Gen5 ones.
Some TongFang barebones have touchpad and/or keyboard issues after suspend, fixable with nomux + reset + noloop + nopnp. Luckily, none of them have an external PS/2 port so this can safely be set for all of them.
I'm not entirely sure if every device listed really needs all four quirks, but after testing and production use, no negative effects could be observed when setting all four.
--- drivers/input/serio/i8042-acpipnpio.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/serio/i8042-acpipnpio.h +7 -0
@@ -1143,6 +1143,13 @@ static const struct dmi_system_id i8042_ .driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS | SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP) }, + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "GMxHGxx"), + }, + .driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS | + SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP) + }, /* * A lot of modern Clevo barebones have touchpad and/or keyboard issues * after suspend fixable with nomux + reset + noloop + nopnp. Luckily,
Greg Kroah-Hartman
maintainerPATCH 484/634 Input: i8042 - add another board name for TUXEDO Stellaris Gen5 AMD line
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Werner Sembach <[email protected]>
commit 01eed86d50af9fab27d876fd677b86259ebe9de3 upstream.
There might be devices out in the wild where the board name is GMxXGxx instead of GMxXGxX.
Adding both to be on the safe side.
--- drivers/input/serio/i8042-acpipnpio.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/serio/i8042-acpipnpio.h +7 -0
@@ -1138,6 +1138,13 @@ static const struct dmi_system_id i8042_ }, { .matches = { + DMI_MATCH(DMI_BOARD_NAME, "GMxXGxx"), + }, + .driver_data = (void *)(SERIO_QUIRK_NOMUX |SERIO_QUIRK_RESET_ALWAYS | +SERIO_QUIRK_NOLOOP |SERIO_QUIRK_NOPNP ) + }, + { + .matches = { DMI_MATCH(DMI_BOARD_NAME, "GMxXGxX"), }, .driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS |
Greg Kroah-Hartman
maintainerPATCH 485/634 KVM: arm64: Add memory length checks and remove inline in do_ffa_mem_xfer
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Snehal Koukuntla <[email protected]>
commit f26a525b77e040d584e967369af1e018d2d59112 upstream.
When we share memory through FF-A and the description of the buffers exceeds the size of the mapped buffer, the fragmentation API is used. The fragmentation API allows specifying chunks of descriptors in subsequent FF-A fragment calls and no upper limit has been established for this. The entire memory region transferred is identified by a handle which can be used to reclaim the transferred memory.
To be able to reclaim the memory, the description of the buffers has to fit in the ffa_desc_buf.
Add a bounds check on the FF-A sharing path to prevent the memory reclaim from failing.
Also do_ffa_mem_xfer() does not need __always_inline, except for the BUILD_BUG_ON() aspect, which gets moved to a macro.
[maz: fixed the BUILD_BUG_ON() breakage with LLVM, thanks to Wei-Lin Chang
for the timely report]
--- arch/arm64/kvm/hyp/nvhe/ffa.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +15 -6
@@ -423,9 +423,9 @@ out:return ; } -static __always_inline void do_ffa_mem_xfer(const u64 func_id, -struct arm_smccc_res *res, -struct kvm_cpu_context *ctxt) +static void __do_ffa_mem_xfer (const u64 func_id, +struct arm_smccc_res *res, +struct kvm_cpu_context *ctxt) {DECLARE_REG (u32, len, ctxt,1 );DECLARE_REG (u32, fraglen, ctxt,2 );
@@ -437,9 +437,6 @@ static __always_inline void do_ffa_mem_xu32 offset, nr_ranges;int ret =0 ; -BUILD_BUG_ON (func_id !=FFA_FN64_MEM_SHARE && - func_id !=FFA_FN64_MEM_LEND ); -if (addr_mbz || npages_mbz || fraglen > len || fraglen >KVM_FFA_MBOX_NR_PAGES *PAGE_SIZE ) { ret =FFA_RET_INVALID_PARAMETERS ;
@@ -458,6 +455,11 @@ static __always_inline void do_ffa_mem_x goto out_unlock; } +if (len > ffa_desc_buf.len) { + ret =FFA_RET_NO_MEMORY ; + goto out_unlock; + } + buf = hyp_buffers.tx;memcpy (buf, host_buffers.tx, fraglen);
@@ -509,6 +511,13 @@ err_unshare: goto out_unlock; } +#define do_ffa_mem_xfer (fid, res, ctxt) \ + do { \ + BUILD_BUG_ON((fid) != FFA_FN64_MEM_SHARE && \ + (fid) != FFA_FN64_MEM_LEND); \ + __do_ffa_mem_xfer((fid), (res), (ctxt)); \ + } while (0); +static void do_ffa_mem_reclaim (struct arm_smccc_res *res,struct kvm_cpu_context *ctxt) {
Greg Kroah-Hartman
maintainerPATCH 486/634 KVM: x86: Enforce x2APICs must-be-zero reserved ICR bits
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 71bf395a276f0578d19e0ae137a7d1d816d08e0e upstream.
Inject a #GP on a WRMSR(ICR) that attempts to set any reserved bits that are must-be-zero on both Intel and AMD, i.e. any reserved bits other than the BUSY bit, which Intel ignores and basically says is undefined.
KVM's xapic_state_test selftest has been fudging the bug since commit 4b88b1a518b3 ("KVM: selftests: Enhance handling WRMSR ICR register in x2APIC mode"), which essentially removed the testcase instead of fixing the bug.
WARN if the nodecode path triggers a #GP, as the CPU is supposed to check reserved bits for ICR when it's partially virtualized.
--- arch/x86/kvm/lapic.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
arch/x86/kvm/lapic.c +14 -1
@@ -2470,7 +2470,7 @@ void kvm_apic_write_nodecode(struct kvm_* maybe-unecessary write, and both are in the noise anyways. */ if (apic_x2apic_mode (apic) && offset ==APIC_ICR ) -kvm_x2apic_icr_write (apic,kvm_lapic_get_reg64 (apic,APIC_ICR )); +WARN_ON_ONCE (kvm_x2apic_icr_write (apic,kvm_lapic_get_reg64 (apic,APIC_ICR )));else kvm_lapic_reg_write (apic, offset,kvm_lapic_get_reg (apic, offset)); }
@@ -3183,8 +3183,21 @@ int kvm_lapic_set_vapic_addr(struct kvm_return 0 ; } +#define X2APIC_ICR_RESERVED_BITS (GENMASK_ULL(31, 20) | GENMASK_ULL(17, 16) | BIT(13)) +int kvm_x2apic_icr_write (struct kvm_lapic *apic,u64 data) { +if (data &X2APIC_ICR_RESERVED_BITS ) +return 1 ; + +/* +* The BUSY bit is reserved on both Intel and AMD in x2APIC mode, but +* only AMD requires it to be zero, Intel essentially just ignores the +* bit. And if IPI virtualization (Intel) or x2AVIC (AMD) is enabled, +* the CPU performs the reserved bits checks, i.e. the underlying CPU +* behavior will "win". Arbitrarily clear the BUSY bit, as there is no +* sane way to provide consistent behavior with respect to hardware. +*/ data &= ~APIC_ICR_BUSY ;kvm_apic_send_ipi (apic, (u32 )data, (u32)(data >>32 ));
Greg Kroah-Hartman
maintainerPATCH 487/634 KVM: x86: Move x2APIC ICR helper above kvm_apic_write_nodecode()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit d33234342f8b468e719e05649fd26549fb37ef8a upstream.
Hoist kvm_x2apic_icr_write() above kvm_apic_write_nodecode() so that a local helper to _read_ the x2APIC ICR can be added and used in the nodecode path without needing a forward declaration.
No functional change intended.
--- arch/x86/kvm/lapic.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-)
arch/x86/kvm/lapic.c +23 -23
@@ -2453,6 +2453,29 @@ void kvm_lapic_set_eoi(struct kvm_vcpu * }EXPORT_SYMBOL_GPL (kvm_lapic_set_eoi); +#define X2APIC_ICR_RESERVED_BITS (GENMASK_ULL(31, 20) | GENMASK_ULL(17, 16) | BIT(13)) + +int kvm_x2apic_icr_write (struct kvm_lapic *apic,u64 data) +{ +if (data &X2APIC_ICR_RESERVED_BITS ) +return 1 ; + +/* +* The BUSY bit is reserved on both Intel and AMD in x2APIC mode, but +* only AMD requires it to be zero, Intel essentially just ignores the +* bit. And if IPI virtualization (Intel) or x2AVIC (AMD) is enabled, +* the CPU performs the reserved bits checks, i.e. the underlying CPU +* behavior will "win". Arbitrarily clear the BUSY bit, as there is no +* sane way to provide consistent behavior with respect to hardware. +*/ + data &= ~APIC_ICR_BUSY ; + +kvm_apic_send_ipi (apic, (u32 )data, (u32)(data >>32 )); +kvm_lapic_set_reg64 (apic,APIC_ICR , data); +trace_kvm_apic_write (APIC_ICR , data); +return 0 ; +} +/* emulate APIC access in a trap manner */ void kvm_apic_write_nodecode (struct kvm_vcpu *vcpu,u32 offset) {
@@ -3183,29 +3206,6 @@ int kvm_lapic_set_vapic_addr(struct kvm_return 0 ; } -#define X2APIC_ICR_RESERVED_BITS (GENMASK_ULL(31, 20) | GENMASK_ULL(17, 16) | BIT(13)) - -int kvm_x2apic_icr_write (struct kvm_lapic *apic,u64 data) -{ -if (data &X2APIC_ICR_RESERVED_BITS ) -return 1 ; - -/* -* The BUSY bit is reserved on both Intel and AMD in x2APIC mode, but -* only AMD requires it to be zero, Intel essentially just ignores the -* bit. And if IPI virtualization (Intel) or x2AVIC (AMD) is enabled, -* the CPU performs the reserved bits checks, i.e. the underlying CPU -* behavior will "win". Arbitrarily clear the BUSY bit, as there is no -* sane way to provide consistent behavior with respect to hardware. -*/ - data &= ~APIC_ICR_BUSY ; - -kvm_apic_send_ipi (apic, (u32 )data, (u32)(data >>32 )); -kvm_lapic_set_reg64 (apic,APIC_ICR , data); -trace_kvm_apic_write (APIC_ICR , data); -return 0 ; -} -static int kvm_lapic_msr_read (struct kvm_lapic *apic,u32 reg,u64 *data) {u32 low;
Greg Kroah-Hartman
maintainerPATCH 488/634 KVM: Use dedicated mutex to protect kvm_usage_count to avoid deadlock
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 44d17459626052a2390457e550a12cb973506b2f upstream.
Use a dedicated mutex to guard kvm_usage_count to fix a potential deadlock on x86 due to a chain of locks and SRCU synchronizations. Translating the below lockdep splat, CPU1 #6 will wait on CPU0 #1, CPU0 #8 will wait on CPU2 #3, and CPU2 #7 will wait on CPU1 #4 (if there's a writer, due to the fairness of r/w semaphores).
CPU0 CPU1 CPU2
1 lock(&kvm->slots_lock);
2 lock(&vcpu->mutex);
3 lock(&kvm->srcu);
4 lock(cpu_hotplug_lock); 5 lock(kvm_lock); 6 lock(&kvm->slots_lock);
7 lock(cpu_hotplug_lock);
8 sync(&kvm->srcu);
Note, there are likely more potential deadlocks in KVM x86, e.g. the same pattern of taking cpu_hotplug_lock outside of kvm_lock likely exists with __kvmclock_cpufreq_notifier():
cpuhp_cpufreq_online()
|
-> cpufreq_online()
|
-> cpufreq_gov_performance_limits()
|
-> __cpufreq_driver_target()
|
-> __target_index()
|
-> cpufreq_freq_transition_begin()
|
-> cpufreq_notify_transition()
|
-> ... __kvmclock_cpufreq_notifier()But, actually triggering such deadlocks is beyond rare due to the combination of dependencies and timings involved. E.g. the cpufreq notifier is only used on older CPUs without a constant TSC, mucking with the NX hugepage mitigation while VMs are running is very uncommon, and doing so while also onlining/offlining a CPU (necessary to generate contention on cpu_hotplug_lock) would be even more unusual.
The most robust solution to the general cpu_hotplug_lock issue is likely to switch vm_list to be an RCU-protected list, e.g. so that x86's cpufreq notifier doesn't to take kvm_lock. For now, settle for fixing the most blatant deadlock, as switching to an RCU-protected list is a much more involved change, but add a comment in locking.rst to call out that care needs to be taken when walking holding kvm_lock and walking vm_list.
======================================================
WARNING: possible circular locking dependency detected
6.10.0-smp--c257535a0c9d-pip #330 Tainted: G S O
------------------------------------------------------
tee/35048 is trying to acquire lock:
ff6a80eced71e0a8 (&kvm->slots_lock){+.+.}-{3:3}, at: set_nx_huge_pages+0x179/0x1e0 [kvm]
but task is already holding lock:
ffffffffc07abb08 (kvm_lock){+.+.}-{3:3}, at: set_nx_huge_pages+0x14a/0x1e0 [kvm]
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #3 (kvm_lock){+.+.}-{3:3}:
__mutex_lock+0x6a/0xb40
mutex_lock_nested+0x1f/0x30
kvm_dev_ioctl+0x4fb/0xe50 [kvm]
__se_sys_ioctl+0x7b/0xd0
__x64_sys_ioctl+0x21/0x30
x64_sys_call+0x15d0/0x2e60
do_syscall_64+0x83/0x160
entry_SYSCALL_64_after_hwframe+0x76/0x7e-> #2 (cpu_hotplug_lock){++++}-{0:0}:
cpus_read_lock+0x2e/0xb0
static_key_slow_inc+0x16/0x30
kvm_lapic_set_base+0x6a/0x1c0 [kvm]
kvm_set_apic_base+0x8f/0xe0 [kvm]
kvm_set_msr_common+0x9ae/0xf80 [kvm]
vmx_set_msr+0xa54/0xbe0 [kvm_intel]
__kvm_set_msr+0xb6/0x1a0 [kvm]
kvm_arch_vcpu_ioctl+0xeca/0x10c0 [kvm]
kvm_vcpu_ioctl+0x485/0x5b0 [kvm]
__se_sys_ioctl+0x7b/0xd0
__x64_sys_ioctl+0x21/0x30
x64_sys_call+0x15d0/0x2e60
do_syscall_64+0x83/0x160
entry_SYSCALL_64_after_hwframe+0x76/0x7e-> #1 (&kvm->srcu){.+.+}-{0:0}:
__synchronize_srcu+0x44/0x1a0
synchronize_srcu_expedited+0x21/0x30
kvm_swap_active_memslots+0x110/0x1c0 [kvm]
kvm_set_memslot+0x360/0x620 [kvm]
__kvm_set_memory_region+0x27b/0x300 [kvm]
kvm_vm_ioctl_set_memory_region+0x43/0x60 [kvm]
kvm_vm_ioctl+0x295/0x650 [kvm]
__se_sys_ioctl+0x7b/0xd0
__x64_sys_ioctl+0x21/0x30
x64_sys_call+0x15d0/0x2e60
do_syscall_64+0x83/0x160
entry_SYSCALL_64_after_hwframe+0x76/0x7e-> #0 (&kvm->slots_lock){+.+.}-{3:3}:
__lock_acquire+0x15ef/0x2e30
lock_acquire+0xe0/0x260
__mutex_lock+0x6a/0xb40
mutex_lock_nested+0x1f/0x30
set_nx_huge_pages+0x179/0x1e0 [kvm]
param_attr_store+0x93/0x100
module_attr_store+0x22/0x40
sysfs_kf_write+0x81/0xb0
kernfs_fop_write_iter+0x133/0x1d0
vfs_write+0x28d/0x380
ksys_write+0x70/0xe0
__x64_sys_write+0x1f/0x30
x64_sys_call+0x281b/0x2e60
do_syscall_64+0x83/0x160
entry_SYSCALL_64_after_hwframe+0x76/0x7eMessage-ID: <[email protected]>
--- Documentation/virt/kvm/locking.rst | 32 +++++++++++++++++++++++--------- virt/kvm/kvm_main.c | 31 ++++++++++++++++--------------- 2 files changed, 39 insertions(+), 24 deletions(-)
Documentation/virt/kvm/locking.rst +23 -9
@@ -9,7 +9,7 @@ KVM Lock Overview The acquisition orders for mutexes are as follows: -- cpus_read_lock() is taken outside kvm_lock +- cpus_read_lock() is taken outside kvm_lock and kvm_usage_lock - kvm->lock is taken outside vcpu->mutex
@@ -24,6 +24,12 @@ The acquisition orders for mutexes are a are taken on the waiting side when modifying memslots, so MMU notifiers must not take either kvm->slots_lock or kvm->slots_arch_lock. +cpus_read_lock() vs kvm_lock: +- Taking cpus_read_lock() outside of kvm_lock is problematic, despite that + being the official ordering, as it is quite easy to unknowingly trigger + cpus_read_lock() while holding kvm_lock. Use caution when walking vm_list, + e.g. avoid complex operations when possible. + For SRCU: - ``synchronize_srcu(&kvm->srcu)`` is called inside critical sections
@@ -227,10 +233,17 @@ time it will be set using the Dirty trac :Type: mutex :Arch: any :Protects: - vm_list - - kvm_usage_count + +``kvm_usage_lock`` +^^^^^^^^^^^^^^^^^^ + +:Type: mutex +:Arch: any +:Protects: - kvm_usage_count - hardware virtualization enable/disable -:Comment: KVM also disables CPU hotplug via cpus_read_lock() during - enable/disable. +:Comment: Exists because using kvm_lock leads to deadlock (see earlier comment + on cpus_read_lock() vs kvm_lock). Note, KVM also disables CPU hotplug via + cpus_read_lock() when enabling/disabling virtualization. ``kvm->mn_invalidate_lock`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -290,11 +303,12 @@ time it will be set using the Dirty trac wakeup. ``vendor_module_lock`` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^ :Type: mutex :Arch: x86 :Protects: loading a vendor module (kvm_amd or kvm_intel) -:Comment: Exists because using kvm_lock leads to deadlock. cpu_hotplug_lock is - taken outside of kvm_lock, e.g. in KVM's CPU online/offline callbacks, and - many operations need to take cpu_hotplug_lock when loading a vendor module, - e.g. updating static calls. +:Comment: Exists because using kvm_lock leads to deadlock. kvm_lock is taken + in notifiers, e.g. __kvmclock_cpufreq_notifier(), that may be invoked while + cpu_hotplug_lock is held, e.g. from cpufreq_boost_trigger_state(), and many + operations need to take cpu_hotplug_lock when loading a vendor module, e.g. + updating static calls.
virt/kvm/kvm_main.c +16 -15
@@ -5500,6 +5500,7 @@ __visible bool kvm_rebooting;EXPORT_SYMBOL_GPL (kvm_rebooting); static DEFINE_PER_CPU(bool, hardware_enabled); +static DEFINE_MUTEX (kvm_usage_lock);static int kvm_usage_count;static int __hardware_enable_nolock (void )
@@ -5532,10 +5533,10 @@ static int kvm_online_cpu(unsigned int c* be enabled. Otherwise running VMs would encounter unrecoverable * errors when scheduled to this CPU. */ -mutex_lock (&kvm_lock); +mutex_lock (&kvm_usage_lock);if (kvm_usage_count) ret =__hardware_enable_nolock (); -mutex_unlock (&kvm_lock); +mutex_unlock (&kvm_usage_lock);return ret; }
@@ -5555,10 +5556,10 @@ static void hardware_disable_nolock(voidstatic int kvm_offline_cpu (unsigned int cpu) { -mutex_lock (&kvm_lock); +mutex_lock (&kvm_usage_lock);if (kvm_usage_count)hardware_disable_nolock (NULL ); -mutex_unlock (&kvm_lock); +mutex_unlock (&kvm_usage_lock);return 0 ; }
@@ -5574,9 +5575,9 @@ static void hardware_disable_all_nolock(static void hardware_disable_all (void ) {cpus_read_lock (); -mutex_lock (&kvm_lock); +mutex_lock (&kvm_usage_lock);hardware_disable_all_nolock (); -mutex_unlock (&kvm_lock); +mutex_unlock (&kvm_usage_lock);cpus_read_unlock (); }
@@ -5607,7 +5608,7 @@ static int hardware_enable_all(void)* enable hardware multiple times. */ cpus_read_lock (); -mutex_lock (&kvm_lock); +mutex_lock (&kvm_usage_lock); r =0 ;
@@ -5621,7 +5622,7 @@ static int hardware_enable_all(void) } } -mutex_unlock (&kvm_lock); +mutex_unlock (&kvm_usage_lock);cpus_read_unlock ();return r;
@@ -5649,13 +5650,13 @@ static int kvm_suspend(void) {/* * Secondary CPUs and CPU hotplug are disabled across the suspend/resume -* callbacks, i.e. no need to acquire kvm_lock to ensure the usage count -* is stable. Assert that kvm_lock is not held to ensure the system -* isn't suspended while KVM is enabling hardware. Hardware enabling -* can be preempted, but the task cannot be frozen until it has dropped -* all locks (userspace tasks are frozen via a fake signal). +* callbacks, i.e. no need to acquire kvm_usage_lock to ensure the usage +* count is stable. Assert that kvm_usage_lock is not held to ensure +* the system isn't suspended while KVM is enabling hardware. Hardware +* enabling can be preempted, but the task cannot be frozen until it has +* dropped all locks (userspace tasks are frozen via a fake signal). */ -lockdep_assert_not_held (&kvm_lock); +lockdep_assert_not_held (&kvm_usage_lock);lockdep_assert_irqs_disabled ();if (kvm_usage_count)
@@ -5665,7 +5666,7 @@ static int kvm_suspend(void)static void kvm_resume (void ) { -lockdep_assert_not_held (&kvm_lock); +lockdep_assert_not_held (&kvm_usage_lock);lockdep_assert_irqs_disabled ();if (kvm_usage_count)
Greg Kroah-Hartman
maintainerPATCH 489/634 drm/amd/display: Skip Recompute DSC Params if no Stream on Link
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fangzhi Zuo <[email protected]>
commit 8151a6c13111b465dbabe07c19f572f7cbd16fef upstream.
[why]
Encounter NULL pointer dereference uner mst + dsc setup.
BUG: kernel NULL pointer dereference, address: 0000000000000008
PGD 0 P4D 0
Oops: 0000 [#1] PREEMPT SMP NOPTI
CPU: 4 PID: 917 Comm: sway Not tainted 6.3.9-arch1-1 #1 124dc55df4f5272ccb409f39ef4872fc2b3376a2
Hardware name: LENOVO 20NKS01Y00/20NKS01Y00, BIOS R12ET61W(1.31 ) 07/28/2022
RIP: 0010:drm_dp_atomic_find_time_slots+0x5e/0x260 [drm_display_helper]
Code: 01 00 00 48 8b 85 60 05 00 00 48 63 80 88 00 00 00 3b 43 28 0f 8d 2e 01 00 00 48 8b 53 30 48 8d 04 80 48 8d 04 c2 48 8b 40 18 <48> 8>
RSP: 0018:ffff960cc2df77d8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: ffff8afb87e81280 RCX: 0000000000000224
RDX: ffff8afb9ee37c00 RSI: ffff8afb8da1a578 RDI: ffff8afb87e81280
RBP: ffff8afb83d67000 R08: 0000000000000001 R09: ffff8afb9652f850
R10: ffff960cc2df7908 R11: 0000000000000002 R12: 0000000000000000
R13: ffff8afb8d7688a0 R14: ffff8afb8da1a578 R15: 0000000000000224
FS: 00007f4dac35ce00(0000) GS:ffff8afe30b00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000008 CR3: 000000010ddc6000 CR4: 00000000003506e0
Call Trace:
<TASK>
? __die+0x23/0x70
? page_fault_oops+0x171/0x4e0
? plist_add+0xbe/0x100
? exc_page_fault+0x7c/0x180
? asm_exc_page_fault+0x26/0x30
? drm_dp_atomic_find_time_slots+0x5e/0x260 [drm_display_helper 0e67723696438d8e02b741593dd50d80b44c2026]
? drm_dp_atomic_find_time_slots+0x28/0x260 [drm_display_helper 0e67723696438d8e02b741593dd50d80b44c2026]
compute_mst_dsc_configs_for_link+0x2ff/0xa40 [amdgpu 62e600d2a75e9158e1cd0a243bdc8e6da040c054]
? fill_plane_buffer_attributes+0x419/0x510 [amdgpu 62e600d2a75e9158e1cd0a243bdc8e6da040c054]
compute_mst_dsc_configs_for_state+0x1e1/0x250 [amdgpu 62e600d2a75e9158e1cd0a243bdc8e6da040c054]
amdgpu_dm_atomic_check+0xecd/0x1190 [amdgpu 62e600d2a75e9158e1cd0a243bdc8e6da040c054]
drm_atomic_check_only+0x5c5/0xa40
drm_mode_atomic_ioctl+0x76e/0xbc0[how]
dsc recompute should be skipped if no mode change detected on the new request. If detected, keep checking whether the stream is already on current state or not.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +3 -0
@@ -1267,6 +1267,9 @@ static bool is_dsc_need_re_compute(if (new_stream_on_link_num ==0 )return false; +if (new_stream_on_link_num ==0 ) +return false; +/* check current_state if there stream on link but it is not in * new request state */
Greg Kroah-Hartman
maintainerPATCH 490/634 drm/amdgpu/mes11: reduce timeout
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 856265caa94a3c78feaa23ec1acd799fe1989201 upstream.
The firmware timeout is 2s. Reduce the driver timeout to 2.1 seconds to avoid back pressure on queue submissions.
--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1 -1
@@ -155,7 +155,7 @@ static int mes_v11_0_submit_pkt_and_poll int api_status_off) {union MESAPI__QUERY_MES_STATUS mes_status_pkt; -signed long timeout =3000000 ;/* 3000 ms */ +signed long timeout =2100000 ;/* 2100 ms */ struct amdgpu_device *adev = mes->adev;struct amdgpu_ring *ring = &mes->ring;struct MES_API_STATUS *api_status;
Greg Kroah-Hartman
maintainerPATCH 491/634 drm/amdgpu/vcn: enable AV1 on both instances
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saleemkhan Jamadar <[email protected]>
commit 8048e5ade8224969023902b0b3f64470f9c250a7 upstream.
v1 - remove cs parse code (Christian)
On VCN v4_0_6 AV1 is supported on both the instances. Remove cs IB parse code since explict handling of AV1 schedule is not required.
--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 165 -------------------------------- 1 file changed, 165 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c +0 -165
@@ -1353,170 +1353,6 @@ static void vcn_v4_0_5_unified_ring_set_ } } -static int vcn_v4_0_5_limit_sched (struct amdgpu_cs_parser *p, -struct amdgpu_job *job) -{ -struct drm_gpu_scheduler **scheds; - -/* The create msg must be in the first IB submitted */ -if (atomic_read (&job->base.entity->fence_seq)) -return -EINVAL ; - -/* if VCN0 is harvested, we can't support AV1 */ -if (p->adev->vcn.harvest_config &AMDGPU_VCN_HARVEST_VCN0 ) -return -EINVAL ; - - scheds = p->adev->gpu_sched[AMDGPU_HW_IP_VCN_ENC ] - [AMDGPU_RING_PRIO_0 ].sched; -drm_sched_entity_modify_sched (job->base.entity, scheds,1 ); -return 0 ; -} - -static int vcn_v4_0_5_dec_msg (struct amdgpu_cs_parser *p,struct amdgpu_job *job, -uint64_t addr) -{ -struct ttm_operation_ctx ctx = { false, false }; -struct amdgpu_bo_va_mapping *map; -uint32_t *msg, num_buffers; -struct amdgpu_bo *bo; -uint64_t start, end; -unsigned int i; -void *ptr; -int r; - - addr &=AMDGPU_GMC_HOLE_MASK ; - r =amdgpu_cs_find_mapping (p, addr, &bo, &map); -if (r) { -DRM_ERROR ("Can't find BO for addr 0x%08llx\n" , addr); -return r; - } - - start = map->start *AMDGPU_GPU_PAGE_SIZE ; - end = (map->last +1 ) *AMDGPU_GPU_PAGE_SIZE ; -if (addr &0x7 ) { -DRM_ERROR ("VCN messages must be 8 byte aligned!\n" ); -return -EINVAL ; - } - - bo->flags |=AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ; -amdgpu_bo_placement_from_domain (bo, bo->allowed_domains); - r =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx); -if (r) { -DRM_ERROR ("Failed validating the VCN message BO (%d)!\n" , r); -return r; - } - - r =amdgpu_bo_kmap (bo, &ptr); -if (r) { -DRM_ERROR ("Failed mapping the VCN message (%d)!\n" , r); -return r; - } - - msg = ptr + addr - start; - -/* Check length */ -if (msg[1 ] > end - addr) { - r = -EINVAL ; - goto out; - } - -if (msg[3 ] !=RDECODE_MSG_CREATE ) - goto out; - - num_buffers = msg[2 ]; -for (i =0 , msg = &msg[6 ]; i < num_buffers; ++i, msg +=4 ) { -uint32_t offset, size, *create; - -if (msg[0 ] !=RDECODE_MESSAGE_CREATE ) -continue ; - - offset = msg[1 ]; - size = msg[2 ]; - -if (offset + size > end) { - r = -EINVAL ; - goto out; - } - - create = ptr + addr + offset - start; - -/* H264, HEVC and VP9 can run on any instance */ -if (create[0 ] ==0x7 || create[0 ] ==0x10 || create[0 ] ==0x11 ) -continue ; - - r =vcn_v4_0_5_limit_sched (p, job); -if (r) - goto out; - } - -out: -amdgpu_bo_kunmap (bo); -return r; -} - -#define RADEON_VCN_ENGINE_TYPE_ENCODE (0x00000002) -#define RADEON_VCN_ENGINE_TYPE_DECODE (0x00000003) - -#define RADEON_VCN_ENGINE_INFO (0x30000001) -#define RADEON_VCN_ENGINE_INFO_MAX_OFFSET 16 - -#define RENCODE_ENCODE_STANDARD_AV1 2 -#define RENCODE_IB_PARAM_SESSION_INIT 0x00000003 -#define RENCODE_IB_PARAM_SESSION_INIT_MAX_OFFSET 64 - -/* return the offset in ib if id is found, -1 otherwise -* to speed up the searching we only search upto max_offset -*/ -static int vcn_v4_0_5_enc_find_ib_param (struct amdgpu_ib *ib,uint32_t id,int max_offset) -{ -int i; - -for (i =0 ; i < ib->length_dw && i < max_offset && ib->ptr[i] >=8 ; i += ib->ptr[i]/4 ) { -if (ib->ptr[i +1 ] == id) -return i; - } -return -1 ; -} - -static int vcn_v4_0_5_ring_patch_cs_in_place (struct amdgpu_cs_parser *p, -struct amdgpu_job *job, -struct amdgpu_ib *ib) -{ -struct amdgpu_ring *ring =amdgpu_job_ring (job); -struct amdgpu_vcn_decode_buffer *decode_buffer; -uint64_t addr; -uint32_t val; -int idx; - -/* The first instance can decode anything */ -if (!ring->me) -return 0 ; - -/* RADEON_VCN_ENGINE_INFO is at the top of ib block */ - idx =vcn_v4_0_5_enc_find_ib_param (ib,RADEON_VCN_ENGINE_INFO , -RADEON_VCN_ENGINE_INFO_MAX_OFFSET ); -if (idx <0 )/* engine info is missing */ -return 0 ; - - val =amdgpu_ib_get_value (ib, idx +2 );/* RADEON_VCN_ENGINE_TYPE */ -if (val ==RADEON_VCN_ENGINE_TYPE_DECODE ) { - decode_buffer = (struct amdgpu_vcn_decode_buffer *)&ib->ptr[idx +6 ]; - -if (!(decode_buffer->valid_buf_flag &0x1 )) -return 0 ; - - addr = ((u64 )decode_buffer->msg_buffer_address_hi) <<32 | - decode_buffer->msg_buffer_address_lo; -return vcn_v4_0_5_dec_msg (p, job, addr); - }else if (val ==RADEON_VCN_ENGINE_TYPE_ENCODE ) { - idx =vcn_v4_0_5_enc_find_ib_param (ib,RENCODE_IB_PARAM_SESSION_INIT , -RENCODE_IB_PARAM_SESSION_INIT_MAX_OFFSET ); -if (idx >=0 && ib->ptr[idx +2 ] ==RENCODE_ENCODE_STANDARD_AV1 ) -return vcn_v4_0_5_limit_sched (p, job); - } -return 0 ; -} -static const struct amdgpu_ring_funcs vcn_v4_0_5_unified_ring_vm_funcs = { .type =AMDGPU_RING_TYPE_VCN_ENC , .align_mask =0x3f ,
@@ -1524,7 +1360,6 @@ static const struct amdgpu_ring_funcs vc .get_rptr = vcn_v4_0_5_unified_ring_get_rptr, .get_wptr = vcn_v4_0_5_unified_ring_get_wptr, .set_wptr = vcn_v4_0_5_unified_ring_set_wptr, - .patch_cs_in_place = vcn_v4_0_5_ring_patch_cs_in_place, .emit_frame_size =SOC15_FLUSH_GPU_TLB_NUM_WREG *3 + SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 4 +
Greg Kroah-Hartman
maintainerPATCH 492/634 drm/amd/display: Add HDMI DSC native YCbCr422 support
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Ma <[email protected]>
commit 07bfa9cdbf3cd2daadfaaba0601f126f45951ffa upstream.
[WHY && HOW]
For some HDMI OVT timing, YCbCr422 encoding fails at the DSC bandwidth check. The root cause is our DSC policy for timing doesn't account for HDMI YCbCr422 native support.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 4 ++-- drivers/gpu/drm/amd/display/dc/dc_dsc.h | 3 ++- drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +2 -2
@@ -1111,7 +1111,7 @@ static int compute_mst_dsc_configs_for_l params[count].num_slices_v = aconnector->dsc_settings.dsc_num_slices_v; params[count].bpp_overwrite = aconnector->dsc_settings.dsc_bits_per_pixel; params[count].compression_possible = stream->sink->dsc_caps.dsc_dec_caps.is_dsc_supported; -dc_dsc_get_policy_for_timing (params[count].timing,0 , &dsc_policy); +dc_dsc_get_policy_for_timing (params[count].timing,0 , &dsc_policy,dc_link_get_highest_encoding_format (stream->link)); if (!dc_dsc_compute_bandwidth_range( stream->sink->ctx->dc->res_pool->dscs[0], stream->sink->ctx->dc->debug.dsc_min_slice_height_override,
@@ -1586,7 +1586,7 @@ static bool is_dsc_common_config_possibl {struct dc_dsc_policy dsc_policy = {0 }; -dc_dsc_get_policy_for_timing (&stream->timing,0 , &dsc_policy); +dc_dsc_get_policy_for_timing (&stream->timing,0 , &dsc_policy,dc_link_get_highest_encoding_format (stream->link)); dc_dsc_compute_bandwidth_range(stream->sink->ctx->dc->res_pool->dscs[0], stream->sink->ctx->dc->debug.dsc_min_slice_height_override, dsc_policy.min_target_bpp * 16,
drivers/gpu/drm/amd/display/dc/dc_dsc.h +2 -1
@@ -100,7 +100,8 @@ uint32_t dc_dsc_stream_bandwidth_overhea*/ void dc_dsc_get_policy_for_timing (const struct dc_crtc_timing *timing,uint32_t max_target_bpp_limit_override_x16, -struct dc_dsc_policy *policy); +struct dc_dsc_policy *policy, +const enum dc_link_encoding_format link_encoding);void dc_dsc_policy_set_max_target_bpp_limit (uint32_t limit);
drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c +3 -2
@@ -883,7 +883,7 @@ static bool setup_dsc_config(memset (dsc_cfg,0 ,sizeof (struct dc_dsc_config )); -dc_dsc_get_policy_for_timing (timing, options->max_target_bpp_limit_override_x16, &policy); +dc_dsc_get_policy_for_timing (timing, options->max_target_bpp_limit_override_x16, &policy, link_encoding); pic_width = timing->h_addressable + timing->h_border_left + timing->h_border_right; pic_height = timing->v_addressable + timing->v_border_top + timing->v_border_bottom;
@@ -1156,7 +1156,8 @@ uint32_t dc_dsc_stream_bandwidth_overheavoid dc_dsc_get_policy_for_timing (const struct dc_crtc_timing *timing,uint32_t max_target_bpp_limit_override_x16, -struct dc_dsc_policy *policy) +struct dc_dsc_policy *policy, +const enum dc_link_encoding_format link_encoding) {uint32_t bpc =0 ;
Greg Kroah-Hartman
maintainerPATCH 493/634 drm/amd/display: Round calculated vtotal
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robin Chen <[email protected]>
commit c03fca619fc687338a3b6511fdbed94096abdf79 upstream.
[WHY]
The calculated vtotal may has 1 line deviation. To get precisely vtotal number, round the vtotal result.
--- drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/modules/freesync/freesync.c +1 -1
@@ -134,7 +134,7 @@ unsigned int mod_freesync_calc_v_total_f v_total =div64_u64 (div64_u64 (((unsigned long long )( frame_duration_in_ns) * (stream->timing.pix_clk_100hz /10 )), - stream->timing.h_total),1000000 ); + stream->timing.h_total) +500000 ,1000000 );/* v_total cannot be less than nominal */ if (v_total < stream->timing.v_total) {
Greg Kroah-Hartman
maintainerPATCH 494/634 drm/amd/display: Clean up dsc blocks in accelerated mode
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Tsai <[email protected]>
commit 3766a840e093d30e1a2522f650d8a6ac892a8719 upstream.
[WHY]
DSC on eDP could be enabled during VBIOS post. The enabled DSC may not be disabled when enter to OS, once the system was in second screen only mode before entering to S4. In this case, OS will not send setTimings to reset eDP path again.
The enabled DSC HW will make a new stream without DSC cannot output normally if it reused this pipe with enabled DSC.
[HOW]
In accelerated mode, to clean up DSC blocks if eDP is on link but not active when we are not in fast boot and seamless boot.
--- drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c | 50 ++++++++++++++ 1 file changed, 50 insertions(+)
drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c +50 -0
@@ -57,6 +57,7 @@#include "panel_cntl.h" #include "dc_state_priv.h" #include "dpcd_defs.h" +#include "dsc.h" /* include DCE11 register header files */ #include "dce/dce_11_0_d.h" #include "dce/dce_11_0_sh_mask.h"
@@ -1768,6 +1769,48 @@ static void get_edp_links_with_sink( } } +static void clean_up_dsc_blocks (struct dc *dc) +{ +struct display_stream_compressor *dsc =NULL ; +struct timing_generator *tg =NULL ; +struct stream_encoder *se =NULL ; +struct dccg *dccg = dc->res_pool->dccg; +struct pg_cntl *pg_cntl = dc->res_pool->pg_cntl; +int i; + +if (dc->ctx->dce_version !=DCN_VERSION_3_5 && + dc->ctx->dce_version !=DCN_VERSION_3_51 ) +return ; + +for (i =0 ; i < dc->res_pool->res_cap->num_dsc; i++) { +struct dcn_dsc_state s = {0 }; + + dsc = dc->res_pool->dscs[i]; + dsc->funcs->dsc_read_state (dsc, &s); +if (s.dsc_fw_en) { +/* disable DSC in OPTC */ +if (i < dc->res_pool->timing_generator_count) { + tg = dc->res_pool->timing_generators[i]; + tg->funcs->set_dsc_config (tg,OPTC_DSC_DISABLED ,0 ,0 ); + } +/* disable DSC in stream encoder */ +if (i < dc->res_pool->stream_enc_count) { + se = dc->res_pool->stream_enc[i]; + se->funcs->dp_set_dsc_config (se,OPTC_DSC_DISABLED ,0 ,0 ); + se->funcs->dp_set_dsc_pps_info_packet (se, false,NULL , true); + } +/* disable DSC block */ +if (dccg->funcs->set_ref_dscclk) + dccg->funcs->set_ref_dscclk (dccg, dsc->inst); + dsc->funcs->dsc_disable (dsc); + +/* power down DSC */ +if (pg_cntl !=NULL ) + pg_cntl->funcs->dsc_pg_control (pg_cntl, dsc->inst, false); + } + } +} +/* * When ASIC goes from VBIOS/VGA mode to driver/accelerated mode we need: * 1. Power down all DC HW blocks
@@ -1852,6 +1895,13 @@ void dce110_enable_accelerated_mode(struclk_mgr_exit_optimized_pwr_state (dc, dc->clk_mgr);power_down_all_hw_blocks (dc); + +/* DSC could be enabled on eDP during VBIOS post. +* To clean up dsc blocks if eDP is in link but not active. +*/ +if (edp_link_with_sink && (edp_stream_num ==0 )) +clean_up_dsc_blocks (dc); +disable_vga_and_power_gate_all_controllers (dc);if (edp_link_with_sink && !keep_edp_vdd_on) dc->hwss.edp_power_control (edp_link_with_sink, false);
Greg Kroah-Hartman
maintainerPATCH 495/634 drm/amd/display: Validate backlight caps are sane
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit 327e62f47eb57ae5ff63de82b0815557104e439a upstream.
Currently amdgpu takes backlight caps provided by the ACPI tables on systems as is. If the firmware sets maximums that are too low this means that users don't get a good experience.
To avoid having to maintain a quirk list of such systems, do a sanity check on the values. Check that the spread is at least half of the values that amdgpu would use if no ACPI table was found and if not use the amdgpu defaults.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +16 -0
@@ -4149,6 +4149,7 @@ static int amdgpu_dm_mode_config_init(st#define AMDGPU_DM_DEFAULT_MIN_BACKLIGHT 12#define AMDGPU_DM_DEFAULT_MAX_BACKLIGHT 255 +#define AMDGPU_DM_MIN_SPREAD ((AMDGPU_DM_DEFAULT_MAX_BACKLIGHT - AMDGPU_DM_DEFAULT_MIN_BACKLIGHT) / 2)#define AUX_BL_DEFAULT_TRANSITION_TIME_MS 50 static void amdgpu_dm_update_backlight_caps(struct amdgpu_display_manager *dm,
@@ -4163,6 +4164,21 @@ static void amdgpu_dm_update_backlight_creturn ;amdgpu_acpi_get_backlight_caps (&caps); + +/* validate the firmware value is sane */ +if (caps.caps_valid) { +int spread = caps.max_input_signal - caps.min_input_signal; + +if (caps.max_input_signal >AMDGPU_DM_DEFAULT_MAX_BACKLIGHT || + caps.min_input_signal <AMDGPU_DM_DEFAULT_MIN_BACKLIGHT || + spread >AMDGPU_DM_DEFAULT_MAX_BACKLIGHT || + spread <AMDGPU_DM_MIN_SPREAD ) { +DRM_DEBUG_KMS ("DM: Invalid backlight caps: min=%d, max=%d\n" , + caps.min_input_signal, caps.max_input_signal); + caps.caps_valid = false; + } + } +if (caps.caps_valid) { dm->backlight_caps[bl_idx].caps_valid = true;if (caps.aux_support)
Greg Kroah-Hartman
maintainerPATCH 496/634 drm/amd/display: Disable SYMCLK32_LE root clock gating
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Joon Kim <[email protected]>
commit ae5100805f98641ea4112241e350485c97936bbe upstream.
[WHY & HOW]
On display on sequence, enabling SYMCLK32_LE root clock gating causes issue in link training so disabling it is needed.
--- drivers/gpu/drm/amd/display/dc/resource/dcn351/dcn351_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/resource/dcn351/dcn351_resource.c +1 -1
@@ -736,7 +736,7 @@ static const struct dc_debug_options deb .hdmichar = true, .dpstream = true, .symclk32_se = true, - .symclk32_le = true, + .symclk32_le = false, .symclk_fe = true, .physymclk = true, .dpiasymclk = true,
Greg Kroah-Hartman
maintainerPATCH 497/634 drm/amd/display: Block dynamic IPS2 on DCN35 for incompatible FW versions
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Kazlauskas <[email protected]>
commit 401c90c4d64f2227fc2f4c02d2ad23296bf5ca6f upstream.
[WHY]
Hangs with Z8 can occur if running an older unfixed PMFW version.
[HOW]
Fallback to RCG only for dynamic IPS2 states if it's not newer than 93.12. Limit to DCN35.
--- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn35/dcn35_clk_mgr.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn35/dcn35_clk_mgr.c +6 -0
@@ -1149,6 +1149,12 @@ void dcn35_clk_mgr_construct( ctx->dc->debug.disable_dpp_power_gate = false; ctx->dc->debug.disable_hubp_power_gate = false; ctx->dc->debug.disable_dsc_power_gate = false; + +/* Disable dynamic IPS2 in older PMFW (93.12) for Z8 interop. */ +if (ctx->dc->config.disable_ips ==DMUB_IPS_ENABLE && + ctx->dce_version ==DCN_VERSION_3_5 && + ((clk_mgr->base.smu_ver &0x00FFFFFF ) <=0x005d0c00 )) + ctx->dc->config.disable_ips =DMUB_IPS_RCG_IN_ACTIVE_IPS2_IN_OFF ; }else {/*let's reset the config control flag*/ ctx->dc->config.disable_ips =DMUB_IPS_DISABLE_ALL ;/*pmfw not support it, disable it all*/
Greg Kroah-Hartman
maintainerPATCH 498/634 drm/amd/display: Enable DML2 override_det_buffer_size_kbytes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yihan Zhu <[email protected]>
commit f57b77d667dc6bd2b114d08d04b03869539209f6 upstream.
[WHY]
Corrupted screen will be observed when 4k144 DP/HDMI display and 4k144 eDP are connected, changing eDP refresh rate from 60Hz to 144Hz.
[HOW]override_det_buffer_size_kbytes should be true for DCN35/DCN351.
--- drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c | 1 + drivers/gpu/drm/amd/display/dc/resource/dcn351/dcn351_resource.c | 1 + 2 files changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c +1 -0
@@ -2150,6 +2150,7 @@ static bool dcn35_resource_construct( dc->dml2_options.max_segments_per_hubp =24 ; dc->dml2_options.det_segment_size =DCN3_2_DET_SEG_SIZE ;/*todo*/ + dc->dml2_options.override_det_buffer_size_kbytes = true;if (dc->config.sdpif_request_limit_words_per_umc ==0 ) dc->config.sdpif_request_limit_words_per_umc =16 ;/*todo*/
drivers/gpu/drm/amd/display/dc/resource/dcn351/dcn351_resource.c +1 -0
@@ -2132,6 +2132,7 @@ static bool dcn351_resource_construct( dc->dml2_options.max_segments_per_hubp =24 ; dc->dml2_options.det_segment_size =DCN3_2_DET_SEG_SIZE ;/*todo*/ + dc->dml2_options.override_det_buffer_size_kbytes = true;if (dc->config.sdpif_request_limit_words_per_umc ==0 ) dc->config.sdpif_request_limit_words_per_umc =16 ;/*todo*/
Greg Kroah-Hartman
maintainerPATCH 499/634 drm/amd/display: Skip to enable dsc if it has been off
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhikai Zhai <[email protected]>
commit 4bdc5b504af7de1f649004cfdd37445d36db6703 upstream.
[WHY]
It makes DSC enable when we commit the stream which need keep power off, and then it will skip to disable DSC if pipe reset at this situation as power has been off. It may cause the DSC unexpected enable on the pipe with the next new stream which doesn't support DSC.
[HOW]
Check the DSC used on current pipe status when update stream. Skip to enable if it has been off. The operation enable DSC should happen when set power on.
--- drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c | 14 ++++++++++++++ drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c | 13 +++++++++++++ 2 files changed, 27 insertions(+)
drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c +14 -0
@@ -991,6 +991,20 @@ static void update_dsc_on_stream(structstruct dsc_config dsc_cfg;struct dsc_optc_config dsc_optc_cfg = {0 };enum optc_dsc_mode optc_dsc_mode; +struct dcn_dsc_state dsc_state = {0 }; + +if (!dsc) { +DC_LOG_DSC ("DSC is NULL for tg instance %d:" , pipe_ctx->stream_res.tg->inst); +return ; + } + +if (dsc->funcs->dsc_read_state) { + dsc->funcs->dsc_read_state (dsc, &dsc_state); +if (!dsc_state.dsc_fw_en) { +DC_LOG_DSC ("DSC has been disabled for tg instance %d:" , pipe_ctx->stream_res.tg->inst); +return ; + } + }/* Enable DSC hw block */ dsc_cfg.pic_width = (stream->timing.h_addressable + stream->timing.h_border_left + stream->timing.h_border_right) / opp_cnt;
drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c +13 -0
@@ -375,7 +375,20 @@ static void update_dsc_on_stream(structstruct dsc_config dsc_cfg;struct dsc_optc_config dsc_optc_cfg = {0 };enum optc_dsc_mode optc_dsc_mode; +struct dcn_dsc_state dsc_state = {0 }; +if (!dsc) { +DC_LOG_DSC ("DSC is NULL for tg instance %d:" , pipe_ctx->stream_res.tg->inst); +return ; + } + +if (dsc->funcs->dsc_read_state) { + dsc->funcs->dsc_read_state (dsc, &dsc_state); +if (!dsc_state.dsc_fw_en) { +DC_LOG_DSC ("DSC has been disabled for tg instance %d:" , pipe_ctx->stream_res.tg->inst); +return ; + } + }/* Enable DSC hw block */ dsc_cfg.pic_width = (stream->timing.h_addressable + stream->timing.h_border_left + stream->timing.h_border_right) / opp_cnt; dsc_cfg.pic_height = stream->timing.v_addressable + stream->timing.v_border_top + stream->timing.v_border_bottom;
Greg Kroah-Hartman
maintainerPATCH 500/634 Revert "LoongArch: KVM: Invalidate guest steal time address on vCPU reset"
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
This reverts commit 05969a6944713f159e8f28be2388500174521818 which is commit 4956e07f05e239b274d042618a250c9fa3e92629 upstream.
LoongArch's PV steal time support is add after 6.10, so 6.10.y doesn't need this fix.
--- arch/loongarch/include/asm/kvm_vcpu.h | 1 + arch/loongarch/kvm/timer.c | 7 +++++++ arch/loongarch/kvm/vcpu.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-)
arch/loongarch/include/asm/kvm_vcpu.h +1 -0
@@ -76,6 +76,7 @@ static inline void kvm_restore_lasx(stru#endif void kvm_init_timer (struct kvm_vcpu *vcpu,unsigned long hz); +void kvm_reset_timer (struct kvm_vcpu *vcpu);void kvm_save_timer (struct kvm_vcpu *vcpu);void kvm_restore_timer (struct kvm_vcpu *vcpu);
arch/loongarch/kvm/timer.c +7 -0
@@ -188,3 +188,10 @@ void kvm_save_timer(struct kvm_vcpu *vcpkvm_save_hw_gcsr (csr,LOONGARCH_CSR_ESTAT );preempt_enable (); } + +void kvm_reset_timer (struct kvm_vcpu *vcpu) +{ +write_gcsr_timercfg (0 ); +kvm_write_sw_gcsr (vcpu->arch.csr,LOONGARCH_CSR_TCFG ,0 ); +hrtimer_cancel (&vcpu->arch.swtimer); +}
arch/loongarch/kvm/vcpu.c +1 -1
@@ -572,7 +572,7 @@ static int kvm_set_one_reg(struct kvm_vc vcpu->kvm->arch.time_offset = (signed long )(v -drdtime ());break ;case KVM_REG_LOONGARCH_VCPU_RESET : - vcpu->arch.st.guest_addr =0 ; +kvm_reset_timer (vcpu);memset (&vcpu->arch.irq_pending,0 ,sizeof (vcpu->arch.irq_pending));memset (&vcpu->arch.irq_clear,0 ,sizeof (vcpu->arch.irq_clear));break ;
Greg Kroah-Hartman
maintainerPATCH 501/634 objtool: Handle frame pointer related instructions
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiezhu Yang <[email protected]>
commit da5b2ad1c2f18834cb1ce429e2e5a5cf5cbdf21b upstream.
After commit a0f7085f6a63 ("LoongArch: Add RANDOMIZE_KSTACK_OFFSET support"), there are three new instructions "addi.d $fp, $sp, 32", "sub.d $sp, $sp, $t0" and "addi.d $sp, $fp, -32" for the secondary stack in do_syscall(), then there is a objtool warning "return with modified stack frame" and no handle_syscall() which is the previous frame of do_syscall() in the call trace when executing the command "echo l > /proc/sysrq-trigger".
objdump shows something like this:
0000000000000000 <do_syscall>:
0: 02ff8063 addi.d $sp, $sp, -32 4: 29c04076 st.d $fp, $sp, 16 8: 29c02077 st.d $s0, $sp, 8 c: 29c06061 st.d $ra, $sp, 24 10: 02c08076 addi.d $fp, $sp, 32 ... 74: 0011b063 sub.d $sp, $sp, $t0 ... a8: 4c000181 jirl $ra, $t0, 0 ... dc: 02ff82c3 addi.d $sp, $fp, -32 e0: 28c06061 ld.d $ra, $sp, 24 e4: 28c04076 ld.d $fp, $sp, 16 e8: 28c02077 ld.d $s0, $sp, 8 ec: 02c08063 addi.d $sp, $sp, 32 f0: 4c000020 jirl $zero, $ra, 0
The instruction "sub.d $sp, $sp, $t0" changes the stack bottom and the new stack size is a random value, in order to find the return address of do_syscall() which is stored in the original stack frame after executing "jirl $ra, $t0, 0", it should use fp which points to the original stack top.
At the beginning, the thought is tended to decode the secondary stack instruction "sub.d $sp, $sp, $t0" and set it as a label, then check this label for the two frame pointer instructions to change the cfa base and cfa offset during the period of secondary stack in update_cfi_state(). This is valid for GCC but invalid for Clang due to there are different secondary stack instructions for ClangBuiltLinux on LoongArch, something like this:
0000000000000000 <do_syscall>:
...
88: 00119064 sub.d $a0, $sp, $a0 8c: 00150083 or $sp, $a0, $zero
...
Actually, it equals to a single instruction "sub.d $sp, $sp, $a0", but there is no proper condition to check it as a label like GCC, and so the beginning thought is not a good way.
Essentially, there are two special frame pointer instructions which are "addi.d $fp, $sp, imm" and "addi.d $sp, $fp, imm", the first one points fp to the original stack top and the second one restores the original stack bottom from fp.
Based on the above analysis, in order to avoid adding an arch-specific update_cfi_state(), we just add a member "frame_pointer" in the "struct symbol" as a label to avoid affecting the current normal case, then set it as true only if there is "addi.d $sp, $fp, imm". The last is to check this label for the two frame pointer instructions to change the cfa base and cfa offset in update_cfi_state().
Tested with the following two configs:
(1) CONFIG_RANDOMIZE_KSTACK_OFFSET=y &&
CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=n
(2) CONFIG_RANDOMIZE_KSTACK_OFFSET=y &&
CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y
By the way, there is no effect for x86 with this patch, tested on the x86 machine with Fedora 40 system.
--- tools/objtool/arch/loongarch/decode.c | 11 ++++++++++- tools/objtool/check.c | 23 ++++++++++++++++++++--- tools/objtool/include/objtool/elf.h | 1 + 3 files changed, 31 insertions(+), 4 deletions(-)
tools/objtool/arch/loongarch/decode.c +10 -1
@@ -122,7 +122,7 @@ static bool decode_insn_reg2i12_fomat(unswitch (inst.reg2i12_format.opcode) {case addid_op:if ((inst.reg2i12_format.rd ==CFI_SP ) || (inst.reg2i12_format.rj ==CFI_SP )) { -/* addi.d sp,sp,si12 or addi.d fp,sp,si12 */ +/* addi.d sp,sp,si12 or addi.d fp,sp,si12 or addi.d sp,fp,si12 */ insn->immediate =sign_extend64 (inst.reg2i12_format.immediate,11 );ADD_OP (op) { op->src.type =OP_SRC_ADD ;
@@ -132,6 +132,15 @@ static bool decode_insn_reg2i12_fomat(un op->dest.reg = inst.reg2i12_format.rd; } } +if ((inst.reg2i12_format.rd ==CFI_SP ) && (inst.reg2i12_format.rj ==CFI_FP )) { +/* addi.d sp,fp,si12 */ +struct symbol *func =find_func_containing (insn->sec, insn->offset); + +if (!func) +return false; + + func->frame_pointer = true; + }break ;case ldd_op:if (inst.reg2i12_format.rj ==CFI_SP ) {
tools/objtool/check.c +20 -3
@@ -2991,10 +2991,27 @@ static int update_cfi_state(struct instrbreak ; } -if (op->dest.reg ==CFI_SP && op->src.reg ==CFI_BP ) { +if (op->dest.reg ==CFI_BP && op->src.reg ==CFI_SP && + insn->sym->frame_pointer) { +/* addi.d fp,sp,imm on LoongArch */ +if (cfa->base ==CFI_SP && cfa->offset == op->src.offset) { + cfa->base =CFI_BP ; + cfa->offset =0 ; + } +break ; + } -/* lea disp(%rbp), %rsp */ - cfi->stack_size = -(op->src.offset + regs[CFI_BP ].offset); +if (op->dest.reg ==CFI_SP && op->src.reg ==CFI_BP ) { +/* addi.d sp,fp,imm on LoongArch */ +if (cfa->base ==CFI_BP && cfa->offset ==0 ) { +if (insn->sym->frame_pointer) { + cfa->base =CFI_SP ; + cfa->offset = -op->src.offset; + } + }else { +/* lea disp(%rbp), %rsp */ + cfi->stack_size = -(op->src.offset + regs[CFI_BP ].offset); + }break ; }
tools/objtool/include/objtool/elf.h +1 -0
@@ -68,6 +68,7 @@ struct symbol { u8 warned : 1; u8 embedded_insn : 1; u8 local_label : 1; + u8 frame_pointer : 1;struct list_head pv_target;struct reloc *relocs; };
Greg Kroah-Hartman
maintainerPATCH 502/634 KEYS: prevent NULL pointer dereference in find_asymmetric_key()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roman Smirnov <[email protected]>
commit 70fd1966c93bf3bfe3fe6d753eb3d83a76597eef upstream.
In find_asymmetric_key(), if all NULLs are passed in the id_{0,1,2} arguments, the kernel will first emit WARN but then have an oops because id_2 gets dereferenced anyway.
Add the missing id_2 check and move WARN_ON() to the final else branch to avoid duplicate NULL checks.
Found by Linux Verification Center (linuxtesting.org) with Svace static analysis tool.
--- crypto/asymmetric_keys/asymmetric_type.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
crypto/asymmetric_keys/asymmetric_type.c +4 -3
@@ -60,17 +60,18 @@ struct key *find_asymmetric_key(struct kchar *req, *p;int len; -WARN_ON (!id_0 && !id_1 && !id_2); -if (id_0) { lookup = id_0->data; len = id_0->len; }else if (id_1) { lookup = id_1->data; len = id_1->len; - }else { + }else if (id_2) { lookup = id_2->data; len = id_2->len; + }else { +WARN_ON (1 ); +return ERR_PTR (-EINVAL ); }/* Construct an identifier "id:<keyid>". */
Greg Kroah-Hartman
maintainerPATCH 503/634 powerpc/atomic: Use YZ constraints for DS-form instructions
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
commit 39190ac7cff1fd15135fa8e658030d9646fdb5f2 upstream.
The 'ld' and 'std' instructions require a 4-byte aligned displacement because they are DS-form instructions. But the "m" asm constraint doesn't enforce that.
That can lead to build errors if the compiler chooses a non-aligned displacement, as seen with GCC 14:
/tmp/ccuSzwiR.s: Assembler messages:
/tmp/ccuSzwiR.s:2579: Error: operand out of domain (39 is not a multiple of 4) make[5]: *** [scripts/Makefile.build:229: net/core/page_pool.o] Error 1
Dumping the generated assembler shows:
ld 8,39(8) # MEM[(const struct atomic64_t *)_29].counter, t
Use the YZ constraints to tell the compiler either to generate a DS-form displacement, or use an X-form instruction, either of which prevents the build error.
See commit 2d43cc701b96 ("powerpc/uaccess: Fix build errors seen with GCC 13/14") for more details on the constraint letters.
--- arch/powerpc/include/asm/asm-compat.h | 6 ++++++ arch/powerpc/include/asm/atomic.h | 5 +++-- arch/powerpc/include/asm/uaccess.h | 7 +------ 3 files changed, 10 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/asm-compat.h +6 -0
@@ -39,6 +39,12 @@#define STDX_BE stringify_in_c(stdbrx)#endif +#ifdef CONFIG_CC_IS_CLANG +#define DS_FORM_CONSTRAINT "Z<>" +#else +#define DS_FORM_CONSTRAINT "YZ<>" +#endif +#else /* 32-bit */ /* operations for longs and pointers */
arch/powerpc/include/asm/atomic.h +3 -2
@@ -11,6 +11,7 @@#include <asm/cmpxchg.h> #include <asm/barrier.h> #include <asm/asm-const.h> +#include <asm/asm-compat.h> /* * Since *_return_relaxed and {cmp}xchg_relaxed are implemented with
@@ -197,7 +198,7 @@ static __inline__ s64 arch_atomic64_readif (IS_ENABLED (CONFIG_PPC_KERNEL_PREFIXED )) __asm__ __volatile__("ld %0,0(%1)" :"=r" (t) :"b" (&v->counter));else - __asm__ __volatile__("ld%U1%X1 %0,%1" :"=r" (t) :"m<>" (v->counter)); + __asm__ __volatile__("ld%U1%X1 %0,%1" : "=r"(t) : DS_FORM_CONSTRAINT (v->counter));return t; }
@@ -208,7 +209,7 @@ static __inline__ void arch_atomic64_setif (IS_ENABLED (CONFIG_PPC_KERNEL_PREFIXED )) __asm__ __volatile__("std %1,0(%2)" :"=m" (v->counter) :"r" (i),"b" (&v->counter));else - __asm__ __volatile__("std%U0%X0 %1,%0" :"=m<>" (v->counter) :"r" (i)); + __asm__ __volatile__("std%U0%X0 %1,%0" : "=" DS_FORM_CONSTRAINT (v->counter) : "r"(i)); }#define ATOMIC64_OP (op, asm_op) \
arch/powerpc/include/asm/uaccess.h +1 -6
@@ -6,6 +6,7 @@#include <asm/page.h> #include <asm/extable.h> #include <asm/kup.h> +#include <asm/asm-compat.h> #ifdef __powerpc64__/* We use TASK_SIZE_USER64 as TASK_SIZE is not constant */
@@ -92,12 +93,6 @@ __pu_failed: \ : label)#endif -#ifdef CONFIG_CC_IS_CLANG -#define DS_FORM_CONSTRAINT "Z<>" -#else -#define DS_FORM_CONSTRAINT "YZ<>" -#endif -#ifdef __powerpc64__#ifdef CONFIG_PPC_KERNEL_PREFIXED #define __put_user_asm2_goto (x, ptr, label) \
Greg Kroah-Hartman
maintainerPATCH 504/634 ksmbd: make __dir_empty() compatible with POSIX
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hobin Woo <[email protected]>
commit ca4974ca954561e79f8871d220bb08f14f64f57c upstream.
Some file systems may not provide dot (.) and dot-dot (..) as they are optional in POSIX. ksmbd can misjudge emptiness of a directory in those file systems, since it assumes there are always at least two entries:
dot and dot-dot.
Just don't count dot and dot-dot.
--- fs/smb/server/vfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/smb/server/vfs.c +4 -3
@@ -1115,9 +1115,10 @@ static bool __dir_empty(struct dir_contestruct ksmbd_readdir_data *buf; buf = container_of(ctx, struct ksmbd_readdir_data, ctx); - buf->dirent_count++; +if (!is_dot_dotdot (name, namlen)) + buf->dirent_count++; -return buf->dirent_count <=2 ; +return !buf->dirent_count; }/**
@@ -1137,7 +1138,7 @@ int ksmbd_vfs_empty_dir(struct ksmbd_fil readdir_data.dirent_count =0 ; err =iterate_dir (fp->filp, &readdir_data.ctx); -if (readdir_data.dirent_count >2 ) +if (readdir_data.dirent_count) err = -ENOTEMPTY ;else err =0 ;
Greg Kroah-Hartman
maintainerPATCH 505/634 ksmbd: allow write with FILE_APPEND_DATA
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit 2fb9b5dc80cabcee636a6ccd020740dd925b4580 upstream.
Windows client write with FILE_APPEND_DATA when using git. ksmbd should allow write it with this flags.
Z:\test>git commit -m "test"
fatal: cannot update the ref 'HEAD': unable to append to
'.git/logs/HEAD': Bad file descriptor
--- fs/smb/server/vfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/server/vfs.c +1 -1
@@ -496,7 +496,7 @@ int ksmbd_vfs_write(struct ksmbd_work *wint err =0 ;if (work->conn->connection_type) { -if (!(fp->daccess &FILE_WRITE_DATA_LE )) { +if (!(fp->daccess & (FILE_WRITE_DATA_LE |FILE_APPEND_DATA_LE ))) {pr_err ("no right to write(%pD)\n" , fp->filp); err = -EACCES ; goto out;
Greg Kroah-Hartman
maintainerPATCH 506/634 ksmbd: handle caseless file creation
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit c5a709f08d40b1a082e44ffcde1aea4d2822ddd5 upstream.
Ray Zhang reported ksmbd can not create file if parent filename is caseless.
Y:\>mkdir A
Y:\>echo 123 >a\b.txt
The system cannot find the path specified. Y:\>echo 123 >A\b.txt
This patch convert name obtained by caseless lookup to parent name.
--- fs/smb/server/vfs.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
fs/smb/server/vfs.c +3 -7
@@ -1167,7 +1167,7 @@ static bool __caseless_lookup(struct dirif (cmp <0 ) cmp =strncasecmp ((char *)buf->private, name, namlen);if (!cmp) { -memcpy ((char *)buf->private, name, namlen); +memcpy ((char *)buf->private, name, buf->used); buf->dirent_count =1 ;return false; }
@@ -1235,10 +1235,7 @@ int ksmbd_vfs_kern_path_locked(struct kschar *filepath;size_t path_len, remain_len; - filepath =kstrdup (name,GFP_KERNEL ); -if (!filepath) -return -ENOMEM ; - + filepath = name; path_len =strlen (filepath); remain_len = path_len;
@@ -1281,10 +1278,9 @@ int ksmbd_vfs_kern_path_locked(struct ks err = -EINVAL ; out2:path_put (parent_path); -out1: -kfree (filepath); } +out1:if (!err) { err =mnt_want_write (parent_path->mnt);if (err) {
Greg Kroah-Hartman
maintainerPATCH 507/634 ata: libata-scsi: Fix ata_msense_control() CDL page reporting
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 0e9a2990a93f27daa643b6fa73cfa47b128947a7 upstream.
When the user requests the ALL_SUB_MPAGES mode sense page, ata_msense_control() adds the CDL_T2A_SUB_MPAGE twice instead of adding the CDL_T2A_SUB_MPAGE and CDL_T2B_SUB_MPAGE pages information. Correct the second call to ata_msense_control_spgt2() to report the CDL_T2B_SUB_MPAGE page.
--- drivers/ata/libata-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libata-scsi.c +1 -1
@@ -2358,7 +2358,7 @@ static unsigned int ata_msense_control(scase ALL_SUB_MPAGES : n =ata_msense_control_spg0 (dev, buf, changeable); n +=ata_msense_control_spgt2 (dev, buf + n,CDL_T2A_SUB_MPAGE ); - n +=ata_msense_control_spgt2 (dev, buf + n,CDL_T2A_SUB_MPAGE ); + n +=ata_msense_control_spgt2 (dev, buf + n,CDL_T2B_SUB_MPAGE ); n +=ata_msense_control_ata_feature (dev, buf + n);return n;default :
Greg Kroah-Hartman
maintainerPATCH 508/634 scsi: sd: Fix off-by-one error in sd_read_block_characteristics()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Wilck <[email protected]>
commit f81eaf08385ddd474a2f41595a7757502870c0eb upstream.
Ff the device returns page 0xb1 with length 8 (happens with qemu v2.x, for example), sd_read_block_characteristics() may attempt an out-of-bounds memory access when accessing the zoned field at offset 8.
--- drivers/scsi/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sd.c +1 -1
@@ -3283,7 +3283,7 @@ static void sd_read_block_characteristicrcu_read_lock (); vpd =rcu_dereference (sdkp->device->vpd_pgb1); -if (!vpd || vpd->len <8 ) { +if (!vpd || vpd->len <=8 ) {rcu_read_unlock ();return ; }
Greg Kroah-Hartman
maintainerPATCH 509/634 scsi: ufs: qcom: Update MODE_MAX cfg_bw value
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manish Pandey <[email protected]>
commit 0c40f079f1c808e7e480c795a79009f200366eb1 upstream.
Commit 8db8f6ce556a ("scsi: ufs: qcom: Add missing interconnect bandwidth values for Gear 5") updated the ufs_qcom_bw_table for Gear 5. However, it missed updating the cfg_bw value for the max mode.
Hence update the cfg_bw value for the max mode for UFS 4.x devices.
--- drivers/ufs/host/ufs-qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ufs/host/ufs-qcom.c +1 -1
@@ -93,7 +93,7 @@ static const struct __ufs_qcom_bw_table [MODE_HS_RB][UFS_HS_G3][UFS_LANE_2] = { 1492582, 204800 }, [MODE_HS_RB][UFS_HS_G4][UFS_LANE_2] = { 2915200, 409600 }, [MODE_HS_RB][UFS_HS_G5][UFS_LANE_2] = { 5836800, 819200 }, - [MODE_MAX][0][0] = { 7643136, 307200 }, + [MODE_MAX][0][0] = { 7643136, 819200 }, };static void ufs_qcom_get_default_testbus_cfg (struct ufs_qcom_host *host);
Greg Kroah-Hartman
maintainerPATCH 510/634 scsi: lpfc: Restrict support for 32 byte CDBs to specific HBAs
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Tee <[email protected]>
commit 05ab4e7846f1103377133c00295a9a910cc6dfc2 upstream.
An older generation of HBAs are failing FCP discovery due to usage of an outdated field in FCP command WQEs.
Fix by checking the SLI Interface Type register for applicable support of 32 Byte CDB commands, and restore a setting for a WQE path using normal 16 byte CDBs.
--- drivers/scsi/lpfc/lpfc_hw4.h | 3 +++ drivers/scsi/lpfc/lpfc_init.c | 21 ++++++++++++++++++--- drivers/scsi/lpfc/lpfc_scsi.c | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-)
drivers/scsi/lpfc/lpfc_hw4.h +3 -0
@@ -4847,6 +4847,7 @@ struct fcp_iwrite64_wqe {#define cmd_buff_len_SHIFT 16#define cmd_buff_len_MASK 0x00000ffff#define cmd_buff_len_WORD word3 +/* Note: payload_offset_len field depends on ASIC support */ #define payload_offset_len_SHIFT 0#define payload_offset_len_MASK 0x0000ffff#define payload_offset_len_WORD word3
@@ -4863,6 +4864,7 @@ struct fcp_iread64_wqe {#define cmd_buff_len_SHIFT 16#define cmd_buff_len_MASK 0x00000ffff#define cmd_buff_len_WORD word3 +/* Note: payload_offset_len field depends on ASIC support */ #define payload_offset_len_SHIFT 0#define payload_offset_len_MASK 0x0000ffff#define payload_offset_len_WORD word3
@@ -4879,6 +4881,7 @@ struct fcp_icmnd64_wqe {#define cmd_buff_len_SHIFT 16#define cmd_buff_len_MASK 0x00000ffff#define cmd_buff_len_WORD word3 +/* Note: payload_offset_len field depends on ASIC support */ #define payload_offset_len_SHIFT 0#define payload_offset_len_MASK 0x0000ffff#define payload_offset_len_WORD word3
drivers/scsi/lpfc/lpfc_init.c +18 -3
@@ -4699,6 +4699,7 @@ lpfc_create_port(struct lpfc_hba *phba,uint64_t wwn;bool use_no_reset_hba = false;int rc; +u8 if_type;if (lpfc_no_hba_reset_cnt) { if (phba->sli_rev < LPFC_SLI_REV4 &&
@@ -4773,10 +4774,24 @@ lpfc_create_port(struct lpfc_hba *phba, shost->max_id =LPFC_MAX_TARGET ; shost->max_lun = vport->cfg_max_luns; shost->this_id =-1 ; -if (phba->sli_rev ==LPFC_SLI_REV4 ) - shost->max_cmd_len =LPFC_FCP_CDB_LEN_32 ; -else + +/* Set max_cmd_len applicable to ASIC support */ +if (phba->sli_rev ==LPFC_SLI_REV4 ) { + if_type =bf_get (lpfc_sli_intf_if_type, + &phba->sli4_hba.sli_intf); +switch (if_type) { +case LPFC_SLI_INTF_IF_TYPE_2 : + fallthrough; +case LPFC_SLI_INTF_IF_TYPE_6 : + shost->max_cmd_len =LPFC_FCP_CDB_LEN_32 ; +break ; +default : + shost->max_cmd_len =LPFC_FCP_CDB_LEN ; +break ; + } + }else { shost->max_cmd_len =LPFC_FCP_CDB_LEN ; + }if (phba->sli_rev ==LPFC_SLI_REV4 ) { if (!phba->cfg_fcp_mq_threshold ||
drivers/scsi/lpfc/lpfc_scsi.c +1 -1
@@ -4760,7 +4760,7 @@ static int lpfc_scsi_prep_cmnd_buf_s4(st/* Word 3 */ bf_set (payload_offset_len, &wqe->fcp_icmd, -sizeof (struct fcp_cmnd32 ) +sizeof (struct fcp_rsp )); +sizeof (struct fcp_cmnd ) +sizeof (struct fcp_rsp ));/* Word 6 */ bf_set(wqe_ctxt_tag, &wqe->generic.wqe_com,
Greg Kroah-Hartman
maintainerPATCH 511/634 scsi: mac_scsi: Revise printk(KERN_DEBUG ...) messages
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Finn Thain <[email protected]>
commit 5ec4f820cb9766e4583df947150a6febce8da794 upstream.
After a bus fault, capture and log the chip registers immediately, if the NDEBUG_PSEUDO_DMA macro is defined. Remove some printk(KERN_DEBUG ...) messages that aren't needed any more. Don't skip the debug message when bytes == 0. Show all of the byte counters in the debug messages.
--- drivers/scsi/mac_scsi.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-)
drivers/scsi/mac_scsi.c +22 -20
@@ -286,13 +286,14 @@ static inline int macscsi_pread(struct Nwhile (!NCR5380_poll_politely (hostdata,BUS_AND_STATUS_REG ,BASR_DRQ |BASR_PHASE_MATCH ,BASR_DRQ |BASR_PHASE_MATCH ,0 )) { -int bytes; +int bytes, chunk_bytes;if (macintosh_config->ident ==MAC_MODEL_IIFX )write_ctrl_reg (hostdata,CTRL_HANDSHAKE_MODE |CTRL_INTERRUPTS_ENABLE ); - bytes =mac_pdma_recv (s, d,min (hostdata->pdma_residual,512 )); + chunk_bytes =min (hostdata->pdma_residual,512 ); + bytes =mac_pdma_recv (s, d, chunk_bytes);if (bytes >0 ) { d += bytes;
@@ -302,23 +303,23 @@ static inline int macscsi_pread(struct Nif (hostdata->pdma_residual ==0 ) goto out; -if (NCR5380_poll_politely2 (hostdata,STATUS_REG ,SR_REQ ,SR_REQ , -BUS_AND_STATUS_REG ,BASR_ACK , -BASR_ACK ,0 ) <0 ) -scmd_printk (KERN_DEBUG , hostdata->connected, -"%s: !REQ and !ACK\n" , __func__);if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH )) goto out;if (bytes ==0 )udelay (MAC_PDMA_DELAY ); -if (bytes >=0 ) +if (bytes >0 )continue ; -dsprintk (NDEBUG_PSEUDO_DMA , hostdata->host, -"%s: bus error (%d/%d)\n" , __func__, d - dst, len);NCR5380_dprint (NDEBUG_PSEUDO_DMA , hostdata->host); +dsprintk (NDEBUG_PSEUDO_DMA , hostdata->host, +"%s: bus error [%d/%d] (%d/%d)\n" , + __func__, d - dst, len, bytes, chunk_bytes); + +if (bytes ==0 ) +continue ; + result =-1 ; goto out; }
@@ -345,13 +346,14 @@ static inline int macscsi_pwrite(structwhile (!NCR5380_poll_politely (hostdata,BUS_AND_STATUS_REG ,BASR_DRQ |BASR_PHASE_MATCH ,BASR_DRQ |BASR_PHASE_MATCH ,0 )) { -int bytes; +int bytes, chunk_bytes;if (macintosh_config->ident ==MAC_MODEL_IIFX )write_ctrl_reg (hostdata,CTRL_HANDSHAKE_MODE |CTRL_INTERRUPTS_ENABLE ); - bytes =mac_pdma_send (s, d,min (hostdata->pdma_residual,512 )); + chunk_bytes =min (hostdata->pdma_residual,512 ); + bytes =mac_pdma_send (s, d, chunk_bytes);if (bytes >0 ) { s += bytes;
@@ -370,23 +372,23 @@ static inline int macscsi_pwrite(struct goto out; } -if (NCR5380_poll_politely2 (hostdata,STATUS_REG ,SR_REQ ,SR_REQ , -BUS_AND_STATUS_REG ,BASR_ACK , -BASR_ACK ,0 ) <0 ) -scmd_printk (KERN_DEBUG , hostdata->connected, -"%s: !REQ and !ACK\n" , __func__);if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH )) goto out;if (bytes ==0 )udelay (MAC_PDMA_DELAY ); -if (bytes >=0 ) +if (bytes >0 )continue ; -dsprintk (NDEBUG_PSEUDO_DMA , hostdata->host, -"%s: bus error (%d/%d)\n" , __func__, s - src, len);NCR5380_dprint (NDEBUG_PSEUDO_DMA , hostdata->host); +dsprintk (NDEBUG_PSEUDO_DMA , hostdata->host, +"%s: bus error [%d/%d] (%d/%d)\n" , + __func__, s - src, len, bytes, chunk_bytes); + +if (bytes ==0 ) +continue ; + result =-1 ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 512/634 scsi: mac_scsi: Refactor polling loop
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Finn Thain <[email protected]>
commit 5545c3165cbc98615fe65a44f41167cbb557e410 upstream.
Before the error handling can be revised, some preparation is needed. Refactor the polling loop with a new function, macscsi_wait_for_drq(). This function will gain more call sites in the next patch.
--- drivers/scsi/mac_scsi.c | 80 +++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 38 deletions(-)
drivers/scsi/mac_scsi.c +42 -38
@@ -208,8 +208,6 @@ __setup("mac5380=", mac_scsi_setup);".previous \n" \ : "+a" (addr), "+r" (n), "+r" (result) : "a" (io)) -#define MAC_PDMA_DELAY 32 - static inline int mac_pdma_recv(void __iomem *io, unsigned char *start, int n) {unsigned char *addr = start;
@@ -274,6 +272,36 @@ static inline void write_ctrl_reg(structout_be32 (hostdata->io + (CTRL_REG <<4 ), value); } +static inline int macscsi_wait_for_drq (struct NCR5380_hostdata *hostdata) +{ +unsigned int n =1 ;/* effectively multiplies NCR5380_REG_POLL_TIME */ +unsigned char basr; + +again: + basr =NCR5380_read (BUS_AND_STATUS_REG ); + +if (!(basr &BASR_PHASE_MATCH )) +return 1 ; + +if (basr &BASR_IRQ ) +return -1 ; + +if (basr &BASR_DRQ ) +return 0 ; + +if (n-- ==0 ) { +NCR5380_dprint (NDEBUG_PSEUDO_DMA , hostdata->host); +dsprintk (NDEBUG_PSEUDO_DMA , hostdata->host, +"%s: DRQ timeout\n" , __func__); +return -1 ; + } + +NCR5380_poll_politely2 (hostdata, +BUS_AND_STATUS_REG ,BASR_DRQ ,BASR_DRQ , +BUS_AND_STATUS_REG ,BASR_PHASE_MATCH ,0 ,0 ); + goto again; +} +static inline int macscsi_pread (struct NCR5380_hostdata *hostdata,unsigned char *dst,int len) {
@@ -283,9 +311,7 @@ static inline int macscsi_pread(struct N hostdata->pdma_residual = len; -while (!NCR5380_poll_politely (hostdata,BUS_AND_STATUS_REG , -BASR_DRQ |BASR_PHASE_MATCH , -BASR_DRQ |BASR_PHASE_MATCH ,0 )) { +while (macscsi_wait_for_drq (hostdata) ==0 ) {int bytes, chunk_bytes;if (macintosh_config->ident ==MAC_MODEL_IIFX )
@@ -295,19 +321,16 @@ static inline int macscsi_pread(struct N chunk_bytes =min (hostdata->pdma_residual,512 ); bytes =mac_pdma_recv (s, d, chunk_bytes); +if (macintosh_config->ident ==MAC_MODEL_IIFX ) +write_ctrl_reg (hostdata,CTRL_INTERRUPTS_ENABLE ); +if (bytes >0 ) { d += bytes; hostdata->pdma_residual -= bytes; }if (hostdata->pdma_residual ==0 ) - goto out; - -if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH )) - goto out; - -if (bytes ==0 ) -udelay (MAC_PDMA_DELAY ); +break ;if (bytes >0 )continue ;
@@ -321,16 +344,9 @@ static inline int macscsi_pread(struct Ncontinue ; result =-1 ; - goto out; +break ; } -scmd_printk (KERN_ERR , hostdata->connected, -"%s: phase mismatch or !DRQ\n" , __func__); -NCR5380_dprint (NDEBUG_PSEUDO_DMA , hostdata->host); - result =-1 ; -out: -if (macintosh_config->ident ==MAC_MODEL_IIFX ) -write_ctrl_reg (hostdata,CTRL_INTERRUPTS_ENABLE );return result; }
@@ -343,9 +359,7 @@ static inline int macscsi_pwrite(struct hostdata->pdma_residual = len; -while (!NCR5380_poll_politely (hostdata,BUS_AND_STATUS_REG , -BASR_DRQ |BASR_PHASE_MATCH , -BASR_DRQ |BASR_PHASE_MATCH ,0 )) { +while (macscsi_wait_for_drq (hostdata) ==0 ) {int bytes, chunk_bytes;if (macintosh_config->ident ==MAC_MODEL_IIFX )
@@ -355,6 +369,9 @@ static inline int macscsi_pwrite(struct chunk_bytes =min (hostdata->pdma_residual,512 ); bytes =mac_pdma_send (s, d, chunk_bytes); +if (macintosh_config->ident ==MAC_MODEL_IIFX ) +write_ctrl_reg (hostdata,CTRL_INTERRUPTS_ENABLE ); +if (bytes >0 ) { s += bytes; hostdata->pdma_residual -= bytes;
@@ -369,15 +386,9 @@ static inline int macscsi_pwrite(struct "%s: Last Byte Sent timeout\n", __func__); result =-1 ; } - goto out; +break ; } -if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH )) - goto out; - -if (bytes ==0 ) -udelay (MAC_PDMA_DELAY ); -if (bytes >0 )continue ;
@@ -390,16 +401,9 @@ static inline int macscsi_pwrite(structcontinue ; result =-1 ; - goto out; +break ; } -scmd_printk (KERN_ERR , hostdata->connected, -"%s: phase mismatch or !DRQ\n" , __func__); -NCR5380_dprint (NDEBUG_PSEUDO_DMA , hostdata->host); - result =-1 ; -out: -if (macintosh_config->ident ==MAC_MODEL_IIFX ) -write_ctrl_reg (hostdata,CTRL_INTERRUPTS_ENABLE );return result; }
Greg Kroah-Hartman
maintainerPATCH 513/634 scsi: mac_scsi: Disallow bus errors during PDMA send
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Finn Thain <[email protected]>
commit 5551bc30e4a69ad86d0d008e2f56cd59b6583476 upstream.
SD cards can produce write latency spikes on the order of a hundred milliseconds. If the target firmware does not hide that latency during DATA IN and OUT phases it can cause the PDMA circuitry to raise a processor bus fault which in turn leads to an unreliable byte count and a DMA overrun.
The Last Byte Sent flag is used to detect the overrun but this mechanism is unreliable on some systems. Instead, set a DID_ERROR result whenever there is a bus fault during a PDMA send, unless the cause was a phase mismatch.
--- drivers/scsi/mac_scsi.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-)
drivers/scsi/mac_scsi.c +19 -25
@@ -102,11 +102,15 @@ __setup("mac5380=", mac_scsi_setup);* Linux SCSI drivers lack knowledge of the timing behaviour of SCSI targets * so bus errors are unavoidable. * -* If a MOVE.B instruction faults, we assume that zero bytes were transferred -* and simply retry. That assumption probably depends on target behaviour but -* seems to hold up okay. The NOP provides synchronization: without it the -* fault can sometimes occur after the program counter has moved past the -* offending instruction. Post-increment addressing can't be used. +* If a MOVE.B instruction faults during a receive operation, we assume the +* target sent nothing and try again. That assumption probably depends on +* target firmware but it seems to hold up okay. If a fault happens during a +* send operation, the target may or may not have seen /ACK and got the byte. +* It's uncertain so the whole SCSI command gets retried. +* +* The NOP is needed for synchronization because the fault address in the +* exception stack frame may or may not be the instruction that actually +* caused the bus error. Post-increment addressing can't be used. */ #define MOVE_BYTE (operands) \
@@ -243,22 +247,21 @@ static inline int mac_pdma_send(unsignedif (n >=1 ) {MOVE_BYTE ("%0@,%3@" );if (result) - goto out; +return -1 ; }if (n >=1 && ((unsigned long )addr &1 )) {MOVE_BYTE ("%0@,%3@" );if (result) - goto out; +return -2 ; }while (n >=32 )MOVE_16_WORDS ("%0@+,%3@" );while (n >=2 )MOVE_WORD ("%0@+,%3@" );if (result) -return start - addr;/* Negated to indicate uncertain length */ +return start - addr -1 ;/* Negated to indicate uncertain length */ if (n ==1 )MOVE_BYTE ("%0@,%3@" ); -out:return addr - start; }
@@ -307,7 +310,6 @@ static inline int macscsi_pread(struct N {u8 __iomem *s = hostdata->pdma_io + (INPUT_DATA_REG <<4 );unsigned char *d = dst; -int result =0 ; hostdata->pdma_residual = len;
@@ -343,11 +345,12 @@ static inline int macscsi_pread(struct Nif (bytes ==0 )continue ; - result =-1 ; +if (macscsi_wait_for_drq (hostdata) <=0 ) +set_host_byte (hostdata->connected,DID_ERROR );break ; } -return result; +return 0 ; } static inline int macscsi_pwrite(struct NCR5380_hostdata *hostdata,
@@ -355,7 +358,6 @@ static inline int macscsi_pwrite(struct {unsigned char *s = src;u8 __iomem *d = hostdata->pdma_io + (OUTPUT_DATA_REG <<4 ); -int result =0 ; hostdata->pdma_residual = len;
@@ -377,17 +379,8 @@ static inline int macscsi_pwrite(struct hostdata->pdma_residual -= bytes; } -if (hostdata->pdma_residual ==0 ) { -if (NCR5380_poll_politely (hostdata,TARGET_COMMAND_REG , -TCR_LAST_BYTE_SENT , -TCR_LAST_BYTE_SENT , -0 ) <0 ) { -scmd_printk (KERN_ERR , hostdata->connected, -"%s: Last Byte Sent timeout\n" , __func__); - result =-1 ; - } +if (hostdata->pdma_residual ==0 )break ; - }if (bytes >0 )continue ;
@@ -400,11 +393,12 @@ static inline int macscsi_pwrite(structif (bytes ==0 )continue ; - result =-1 ; +if (macscsi_wait_for_drq (hostdata) <=0 ) +set_host_byte (hostdata->connected,DID_ERROR );break ; } -return result; +return 0 ; } static int macscsi_dma_xfer_len(struct NCR5380_hostdata *hostdata,
Greg Kroah-Hartman
maintainerPATCH 514/634 can: esd_usb: Remove CAN_CTRLMODE_3_SAMPLES for CAN-USB/3-FD
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Mätje <[email protected]>
commit 75b3189540578f96b4996e4849b6649998f49455 upstream.
Remove the CAN_CTRLMODE_3_SAMPLES announcement for CAN-USB/3-FD devices because these devices don't support it.
The hardware has a Microchip SAM E70 microcontroller that uses a Bosch MCAN IP core as CAN FD controller. But this MCAN core doesn't support triple sampling.
--- drivers/net/can/usb/esd_usb.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/can/usb/esd_usb.c +1 -5
@@ -3,7 +3,7 @@* CAN driver for esd electronics gmbh CAN-USB/2, CAN-USB/3 and CAN-USB/Micro * * Copyright (C) 2010-2012 esd electronic system design gmbh, Matthias Fuchs <[email protected]> -* Copyright (C) 2022-2023 esd electronics gmbh, Frank Jungclaus <[email protected]> +* Copyright (C) 2022-2024 esd electronics gmbh, Frank Jungclaus <[email protected]> */ #include <linux/can.h>
@@ -1116,9 +1116,6 @@ static int esd_usb_3_set_bittiming(strucif (priv->can.ctrlmode &CAN_CTRLMODE_LISTENONLY ) flags |=ESD_USB_3_BAUDRATE_FLAG_LOM ; -if (priv->can.ctrlmode &CAN_CTRLMODE_3_SAMPLES ) - flags |=ESD_USB_3_BAUDRATE_FLAG_TRS ; - baud_x->nom.brp =cpu_to_le16 (nom_bt->brp & (nom_btc->brp_max -1 )); baud_x->nom.sjw =cpu_to_le16 (nom_bt->sjw & (nom_btc->sjw_max -1 )); baud_x->nom.tseg1 = cpu_to_le16((nom_bt->prop_seg + nom_bt->phase_seg1)
@@ -1219,7 +1216,6 @@ static int esd_usb_probe_one_net(structswitch (le16_to_cpu (dev->udev->descriptor.idProduct)) {case ESD_USB_CANUSB3_PRODUCT_ID : priv->can.clock.freq =ESD_USB_3_CAN_CLOCK ; - priv->can.ctrlmode_supported |=CAN_CTRLMODE_3_SAMPLES ; priv->can.ctrlmode_supported |=CAN_CTRLMODE_FD ; priv->can.bittiming_const = &esd_usb_3_nom_bittiming_const; priv->can.data_bittiming_const = &esd_usb_3_data_bittiming_const;
Greg Kroah-Hartman
maintainerPATCH 515/634 wifi: rtw88: Fix USB/SDIO devices not transmitting beacons
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bitterblue Smith <[email protected]>
commit faa2e484b393c56bc1243dca6676a70bc485f775 upstream.
All USB devices supported by rtw88 have the same problem: they don't transmit beacons in AP mode. (Some?) SDIO devices are also affected. The cause appears to be clearing BIT_EN_BCNQ_DL of REG_FWHW_TXQ_CTRL before uploading the beacon reserved page, so don't clear the bit for USB and SDIO devices.
Tested with RTL8811CU and RTL8723DU.
--- drivers/net/wireless/realtek/rtw88/fw.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/wireless/realtek/rtw88/fw.c +8 -5
@@ -1468,10 +1468,12 @@ int rtw_fw_write_data_rsvd_page(struct r val |=BIT_ENSWBCN >>8 ;rtw_write8 (rtwdev,REG_CR +1 , val); - val =rtw_read8 (rtwdev,REG_FWHW_TXQ_CTRL +2 ); - bckp[1 ] = val; - val &= ~(BIT_EN_BCNQ_DL >>16 ); -rtw_write8 (rtwdev,REG_FWHW_TXQ_CTRL +2 , val); +if (rtw_hci_type (rtwdev) ==RTW_HCI_TYPE_PCIE ) { + val =rtw_read8 (rtwdev,REG_FWHW_TXQ_CTRL +2 ); + bckp[1 ] = val; + val &= ~(BIT_EN_BCNQ_DL >>16 ); +rtw_write8 (rtwdev,REG_FWHW_TXQ_CTRL +2 , val); + } ret =rtw_hci_write_data_rsvd_page (rtwdev, buf, size);if (ret) {
@@ -1496,7 +1498,8 @@ restore: rsvd_pg_head = rtwdev->fifo.rsvd_boundary;rtw_write16 (rtwdev,REG_FIFOPAGE_CTRL_2 , rsvd_pg_head |BIT_BCN_VALID_V1 ); -rtw_write8 (rtwdev,REG_FWHW_TXQ_CTRL +2 , bckp[1 ]); +if (rtw_hci_type (rtwdev) ==RTW_HCI_TYPE_PCIE ) +rtw_write8 (rtwdev,REG_FWHW_TXQ_CTRL +2 , bckp[1 ]);rtw_write8 (rtwdev,REG_CR +1 , bckp[0 ]);return ret;
Greg Kroah-Hartman
maintainerPATCH 516/634 usbnet: fix cyclical race on disconnect with work queue
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 04e906839a053f092ef53f4fb2d610983412b904 upstream.
The work can submit URBs and the URBs can schedule the work. This cycle needs to be broken, when a device is to be stopped. Use a flag to do so.
This is a design issue as old as the driver.
--- drivers/net/usb/usbnet.c | 37 ++++++++++++++++++++++++++++--------- include/linux/usb/usbnet.h | 15 +++++++++++++++ 2 files changed, 43 insertions(+), 9 deletions(-)
drivers/net/usb/usbnet.c +28 -9
@@ -464,10 +464,15 @@ static enum skb_state defer_bh(struct usvoid usbnet_defer_kevent (struct usbnet *dev,int work) {set_bit (work, &dev->flags); -if (!schedule_work (&dev->kevent)) -netdev_dbg (dev->net,"kevent %s may have been dropped\n" , usbnet_event_names[work]); -else -netdev_dbg (dev->net,"kevent %s scheduled\n" , usbnet_event_names[work]); +if (!usbnet_going_away (dev)) { +if (!schedule_work (&dev->kevent)) +netdev_dbg (dev->net, +"kevent %s may have been dropped\n" , + usbnet_event_names[work]); +else +netdev_dbg (dev->net, +"kevent %s scheduled\n" , usbnet_event_names[work]); + } }EXPORT_SYMBOL_GPL (usbnet_defer_kevent);
@@ -535,7 +540,8 @@ static int rx_submit (struct usbnet *devtasklet_schedule (&dev->bh);break ;case 0 : -__usbnet_queue_skb (&dev->rxq, skb, rx_start); +if (!usbnet_going_away (dev)) +__usbnet_queue_skb (&dev->rxq, skb, rx_start); } }else {netif_dbg (dev, ifdown, dev->net,"rx: stopped\n" );
@@ -843,9 +849,18 @@ int usbnet_stop (struct net_device *net)/* deferred work (timer, softirq, task) must also stop */ dev->flags =0 ; -del_timer_sync (&dev->delay); -tasklet_kill (&dev->bh); +del_timer_sync (&dev->delay); +tasklet_kill (&dev->bh);cancel_work_sync (&dev->kevent); + +/* We have cyclic dependencies. Those calls are needed +* to break a cycle. We cannot fall into the gaps because +* we have a flag +*/ +tasklet_kill (&dev->bh); +del_timer_sync (&dev->delay); +cancel_work_sync (&dev->kevent); +if (!pm)usb_autopm_put_interface (dev->intf);
@@ -1171,7 +1186,8 @@ fail_halt: status); }else {clear_bit (EVENT_RX_HALT , &dev->flags); -tasklet_schedule (&dev->bh); +if (!usbnet_going_away (dev)) +tasklet_schedule (&dev->bh); } }
@@ -1196,7 +1212,8 @@ fail_halt:usb_autopm_put_interface (dev->intf); fail_lowmem:if (resched) -tasklet_schedule (&dev->bh); +if (!usbnet_going_away (dev)) +tasklet_schedule (&dev->bh); } }
@@ -1559,6 +1576,7 @@ static void usbnet_bh (struct timer_list }else if (netif_running (dev->net) &&netif_device_present (dev->net) &&netif_carrier_ok (dev->net) && + !usbnet_going_away (dev) && !timer_pending (&dev->delay) && !test_bit (EVENT_RX_PAUSED , &dev->flags) && !test_bit (EVENT_RX_HALT , &dev->flags)) {
@@ -1606,6 +1624,7 @@ void usbnet_disconnect (struct usb_interusb_set_intfdata (intf,NULL );if (!dev)return ; +usbnet_mark_going_away (dev); xdev =interface_to_usbdev (intf);
include/linux/usb/usbnet.h +15 -0
@@ -76,8 +76,23 @@ struct usbnet {# define EVENT_LINK_CHANGE 11# define EVENT_SET_RX_MODE 12# define EVENT_NO_IP_ALIGN 13 +/* This one is special, as it indicates that the device is going away +* there are cyclic dependencies between tasklet, timer and bh +* that must be broken +*/ +# define EVENT_UNPLUG 31 }; +static inline bool usbnet_going_away (struct usbnet *ubn) +{ +return test_bit (EVENT_UNPLUG , &ubn->flags); +} + +static inline void usbnet_mark_going_away (struct usbnet *ubn) +{ +set_bit (EVENT_UNPLUG , &ubn->flags); +} +static inline struct usb_driver *driver_of (struct usb_interface *intf) {return to_usb_driver (intf->dev.driver);
Greg Kroah-Hartman
maintainerPATCH 517/634 arm64: dts: mediatek: mt8195-cherry: Mark USB 3.0 on xhci1 as disabled
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
commit 09d385679487c58f0859c1ad4f404ba3df2f8830 upstream.
USB 3.0 on xhci1 is not used, as the controller shares the same PHY as pcie1. The latter is enabled to support the M.2 PCIe WLAN card on this design.
Mark USB 3.0 as disabled on this controller using the "mediatek,u3p-dis-msk" property.
--- arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi +1 -0
@@ -1359,6 +1359,7 @@ rx-fifo-depth = <3072>; vusb33-supply = <&mt6359_vusb_ldo_reg>; vbus-supply = <&usb_vbus>; + mediatek,u3p-dis-msk = <1>; }; &xhci2 {
Greg Kroah-Hartman
maintainerPATCH 518/634 arm64: dts: mediatek: mt8395-nio-12l: Mark USB 3.0 on xhci1 as disabled
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
commit be985531a5dd9ca50fc9f3f85b8adeb2a4a75a58 upstream.
USB 3.0 on xhci1 is not used, as the controller shares the same PHY as pcie1. The latter is enabled to support the M.2 PCIe WLAN card on this design.
Mark USB 3.0 as disabled on this controller using the "mediatek,u3p-dis-msk" property.
--- arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts +1 -0
@@ -816,6 +816,7 @@ usb2-lpm-disable; vusb33-supply = <&mt6359_vusb_ldo_reg>; vbus-supply = <&vsys>; + mediatek,u3p-dis-msk = <1>; status = "okay"; };
Greg Kroah-Hartman
maintainerPATCH 519/634 USB: appledisplay: close race between probe and completion handler
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 8265d06b7794493d82c5c21a12d7ba43eccc30cb upstream.
There is a small window during probing when IO is running but the backlight is not registered. Processing events during that time will crash. The completion handler needs to check for a backlight before scheduling work.
The bug is as old as the driver.
--- drivers/usb/misc/appledisplay.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/usb/misc/appledisplay.c +11 -4
@@ -107,7 +107,12 @@ static void appledisplay_complete(structcase ACD_BTN_BRIGHT_UP :case ACD_BTN_BRIGHT_DOWN : pdata->button_pressed =1 ; -schedule_delayed_work (&pdata->work,0 ); +/* +* there is a window during which no device +* is registered +*/ +if (pdata->bd ) +schedule_delayed_work (&pdata->work,0 );break ;case ACD_BTN_NONE :default :
@@ -202,6 +207,7 @@ static int appledisplay_probe(struct usb const struct usb_device_id *id) {struct backlight_properties props; +struct backlight_device *backlight;struct appledisplay *pdata;struct usb_device *udev =interface_to_usbdev (iface);struct usb_endpoint_descriptor *endpoint;
@@ -272,13 +278,14 @@ static int appledisplay_probe(struct usbmemset (&props,0 ,sizeof (struct backlight_properties )); props.type =BACKLIGHT_RAW ; props.max_brightness =0xff ; - pdata->bd =backlight_device_register (bl_name,NULL , pdata, + backlight =backlight_device_register (bl_name,NULL , pdata, &appledisplay_bl_data, &props); -if (IS_ERR (pdata->bd)) { +if (IS_ERR (backlight)) {dev_err (&iface->dev,"Backlight registration failed\n" ); - retval =PTR_ERR (pdata->bd); + retval =PTR_ERR (backlight); goto error; } + pdata->bd = backlight;/* Try to get brightness */ brightness =appledisplay_bl_get_brightness (pdata->bd);
Greg Kroah-Hartman
maintainerPATCH 520/634 USB: misc: cypress_cy7c63: check for short transfer
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 49cd2f4d747eeb3050b76245a7f72aa99dbd3310 upstream.
As we process the second byte of a control transfer, transfers of less than 2 bytes must be discarded.
This bug is as old as the driver.
--- drivers/usb/misc/cypress_cy7c63.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/misc/cypress_cy7c63.c +4 -0
@@ -88,6 +88,9 @@ static int vendor_command(struct cypressUSB_DIR_IN |USB_TYPE_VENDOR |USB_RECIP_OTHER , address, data, iobuf,CYPRESS_MAX_REQSIZE , USB_CTRL_GET_TIMEOUT); +/* we must not process garbage */ +if (retval <2 ) + goto err_buf;/* store returned data (more READs to be added) */ switch (request) {
@@ -107,6 +110,7 @@ static int vendor_command(struct cypressbreak ; } +err_buf:kfree (iobuf); error:return retval;
Greg Kroah-Hartman
maintainerPATCH 521/634 USB: class: CDC-ACM: fix race between get_serial and set_serial
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit b41c1fa155ba56d125885b0191aabaf3c508d0a3 upstream.
TIOCGSERIAL is an ioctl. Thus it must be atomic. It returns two values. Racing with set_serial it can return an inconsistent result. The mutex must be taken.
In terms of logic the bug is as old as the driver. In terms of code it goes back to the conversion to the get_serial and set_serial methods.
--- drivers/usb/class/cdc-acm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/class/cdc-acm.c +2 -0
@@ -962,10 +962,12 @@ static int get_serial_info(struct tty_ststruct acm *acm = tty->driver_data; ss->line = acm->minor; +mutex_lock (&acm->port.mutex); ss->close_delay =jiffies_to_msecs (acm->port.close_delay) /10 ; ss->closing_wait = acm->port.closing_wait ==ASYNC_CLOSING_WAIT_NONE ?ASYNC_CLOSING_WAIT_NONE :jiffies_to_msecs (acm->port.closing_wait) /10 ; +mutex_unlock (&acm->port.mutex);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 522/634 USB: misc: yurex: fix race between read and write
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 93907620b308609c72ba4b95b09a6aa2658bb553 upstream.
The write code path touches the bbu member in a non atomic manner without taking the spinlock. Fix it.
The bug is as old as the driver.
--- drivers/usb/misc/yurex.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/usb/misc/yurex.c +6 -4
@@ -404,7 +404,6 @@ static ssize_t yurex_read(struct file *fstruct usb_yurex *dev;int len =0 ;char in_buffer[MAX_S64_STRLEN ]; -unsigned long flags; dev = file->private_data;
@@ -419,9 +418,9 @@ static ssize_t yurex_read(struct file *freturn -EIO ; } -spin_lock_irqsave (&dev->lock, flags); +spin_lock_irq (&dev->lock);scnprintf (in_buffer,MAX_S64_STRLEN ,"%lld\n" , dev->bbu); -spin_unlock_irqrestore (&dev->lock, flags); +spin_unlock_irq (&dev->lock);mutex_unlock (&dev->io_mutex);return simple_read_from_buffer (buffer, count, ppos, in_buffer, len);
@@ -511,8 +510,11 @@ static ssize_t yurex_write(struct file * __func__, retval); goto error; } -if (set && timeout) +if (set && timeout) { +spin_lock_irq (&dev->lock); dev->bbu = c2; +spin_unlock_irq (&dev->lock); + }return timeout ? count : -EIO ; error:
Greg Kroah-Hartman
maintainerPATCH 523/634 usb: cdnsp: Fix incorrect usb_request status
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pawel Laszczak <[email protected]>
commit 1702bec4477cc7d31adb4a760d14d33fac928b7a upstream.
Fix changes incorrect usb_request->status returned during disabling endpoints. Before fix the status returned during dequeuing requests while disabling endpoint was ECONNRESET.
Patch change it to ESHUTDOWN.
Patch fixes issue detected during testing UVC gadget.
During stopping streaming the class starts dequeuing usb requests and controller driver returns the -ECONNRESET status. After completion requests the class or application "uvc-gadget" try to queue this request again. Changing this status to ESHUTDOWN cause that UVC assumes that endpoint is disabled, or device is disconnected and stops re-queuing usb requests.
--- drivers/usb/cdns3/cdnsp-ring.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/cdns3/cdnsp-ring.c +4 -2
@@ -718,7 +718,8 @@ int cdnsp_remove_request(struct cdnsp_de seg =cdnsp_trb_in_td (pdev, cur_td->start_seg, cur_td->first_trb, cur_td->last_trb, hw_deq); -if (seg && (pep->ep_state &EP_ENABLED )) +if (seg && (pep->ep_state &EP_ENABLED ) && + !(pep->ep_state &EP_DIS_IN_RROGRESS ))cdnsp_find_new_dequeue_state (pdev, pep, preq->request.stream_id, cur_td, &deq_state);else
@@ -736,7 +737,8 @@ int cdnsp_remove_request(struct cdnsp_de* During disconnecting all endpoint will be disabled so we don't * have to worry about updating dequeue pointer. */ -if (pdev->cdnsp_state &CDNSP_STATE_DISCONNECT_PENDING ) { +if (pdev->cdnsp_state &CDNSP_STATE_DISCONNECT_PENDING || + pep->ep_state &EP_DIS_IN_RROGRESS ) { status = -ESHUTDOWN ; ret =cdnsp_cmd_set_deq (pdev, pep, &deq_state); }
Greg Kroah-Hartman
maintainerPATCH 524/634 usb: xHCI: add XHCI_RESET_ON_RESUME quirk for Phytium xHCI host
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit 118ecef16cc221a23f96617016f7a205b070109f upstream.
The resume operation of Phytium Px210 xHCI host would failed to restore state. Use the XHCI_RESET_ON_RESUME quirk to skip it and reset the controller after resume.
--- drivers/usb/host/xhci-pci.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/host/xhci-pci.c +7 -0
@@ -55,6 +55,9 @@#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI 0x51ed#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_PCH_XHCI 0x54ed +#define PCI_VENDOR_ID_PHYTIUM 0x1db7 +#define PCI_DEVICE_ID_PHYTIUM_XHCI 0xdc27 +/* Thunderbolt */ #define PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI 0x1138#define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_XHCI 0x15b5
@@ -416,6 +419,10 @@ static void xhci_pci_quirks(struct devicif (pdev->vendor ==PCI_VENDOR_ID_VIA ) xhci->quirks |=XHCI_RESET_ON_RESUME ; +if (pdev->vendor ==PCI_VENDOR_ID_PHYTIUM && + pdev->device ==PCI_DEVICE_ID_PHYTIUM_XHCI ) + xhci->quirks |=XHCI_RESET_ON_RESUME ; +/* See https://bugzilla.kernel.org/show_bug.cgi?id=79511 */ if (pdev->vendor ==PCI_VENDOR_ID_VIA && pdev->device ==0x3432 )
Greg Kroah-Hartman
maintainerPATCH 525/634 usb: gadget: dummy_hcd: execute hrtimer callback in softirq context
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Konovalov <[email protected]>
commit 9313d139aa25e572d860f6f673b73a20f32d7f93 upstream.
Commit a7f3813e589f ("usb: gadget: dummy_hcd: Switch to hrtimer transfer scheduler") switched dummy_hcd to use hrtimer and made the timer's callback be executed in the hardirq context.
With that change, __usb_hcd_giveback_urb now gets executed in the hardirq context, which causes problems for KCOV and KMSAN.
One problem is that KCOV now is unable to collect coverage from the USB code that gets executed from the dummy_hcd's timer callback, as KCOV cannot collect coverage in the hardirq context.
Another problem is that the dummy_hcd hrtimer might get triggered in the middle of a softirq with KCOV remote coverage collection enabled, and that causes a WARNING in KCOV, as reported by syzbot. (I sent a separate patch to shut down this WARNING, but that doesn't fix the other two issues.)
Finally, KMSAN appears to ignore tracking memory copying operations that happen in the hardirq context, which causes false positive kernel-infoleaks, as reported by syzbot.
Change the hrtimer in dummy_hcd to execute the callback in the softirq context.
--- drivers/usb/gadget/udc/dummy_hcd.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/usb/gadget/udc/dummy_hcd.c +8 -6
@@ -1304,7 +1304,8 @@ static int dummy_urb_enqueue(/* kick the scheduler, it'll do the rest */ if (!hrtimer_active (&dum_hcd->timer)) -hrtimer_start (&dum_hcd->timer,ns_to_ktime (DUMMY_TIMER_INT_NSECS ),HRTIMER_MODE_REL ); +hrtimer_start (&dum_hcd->timer,ns_to_ktime (DUMMY_TIMER_INT_NSECS ), +HRTIMER_MODE_REL_SOFT ); done:spin_unlock_irqrestore (&dum_hcd->dum->lock, flags);
@@ -1325,7 +1326,7 @@ static int dummy_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) rc =usb_hcd_check_unlink_urb (hcd, urb, status);if (!rc && dum_hcd->rh_state !=DUMMY_RH_RUNNING && !list_empty (&dum_hcd->urbp_list)) -hrtimer_start (&dum_hcd->timer,ns_to_ktime (0 ),HRTIMER_MODE_REL ); +hrtimer_start (&dum_hcd->timer,ns_to_ktime (0 ),HRTIMER_MODE_REL_SOFT );spin_unlock_irqrestore (&dum_hcd->dum->lock, flags);return rc;
@@ -1995,7 +1996,8 @@ static enum hrtimer_restart dummy_timer(struct hrtimer *t) dum_hcd->udev =NULL ; }else if (dum_hcd->rh_state ==DUMMY_RH_RUNNING ) {/* want a 1 msec delay here */ -hrtimer_start (&dum_hcd->timer,ns_to_ktime (DUMMY_TIMER_INT_NSECS ),HRTIMER_MODE_REL ); +hrtimer_start (&dum_hcd->timer,ns_to_ktime (DUMMY_TIMER_INT_NSECS ), +HRTIMER_MODE_REL_SOFT ); }spin_unlock_irqrestore (&dum->lock, flags);
@@ -2389,7 +2391,7 @@ static int dummy_bus_resume(struct usb_hcd *hcd) dum_hcd->rh_state =DUMMY_RH_RUNNING ;set_link_state (dum_hcd);if (!list_empty (&dum_hcd->urbp_list)) -hrtimer_start (&dum_hcd->timer,ns_to_ktime (0 ),HRTIMER_MODE_REL ); +hrtimer_start (&dum_hcd->timer,ns_to_ktime (0 ),HRTIMER_MODE_REL_SOFT ); hcd->state =HC_STATE_RUNNING ; }spin_unlock_irq (&dum_hcd->dum->lock);
@@ -2467,7 +2469,7 @@ static DEVICE_ATTR_RO(urbs);static int dummy_start_ss (struct dummy_hcd *dum_hcd) { -hrtimer_init (&dum_hcd->timer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); +hrtimer_init (&dum_hcd->timer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL_SOFT ); dum_hcd->timer.function = dummy_timer; dum_hcd->rh_state =DUMMY_RH_RUNNING ; dum_hcd->stream_en_ep =0 ;
@@ -2497,7 +2499,7 @@ static int dummy_start(struct usb_hcd *hcd)return dummy_start_ss (dum_hcd);spin_lock_init (&dum_hcd->dum->lock); -hrtimer_init (&dum_hcd->timer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); +hrtimer_init (&dum_hcd->timer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL_SOFT ); dum_hcd->timer.function = dummy_timer; dum_hcd->rh_state =DUMMY_RH_RUNNING ;
Signature · 1 line
2.46.2
Greg Kroah-Hartman
maintainerPATCH 526/634 usb: dwc2: drd: fix clock gating on USB role switch
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomas Marek <[email protected]>
commit 2c6b6afa59e78bebcb65bbc8a76b3459f139547c upstream.
The dwc2_handle_usb_suspend_intr() function disables gadget clocks in USB peripheral mode when no other power-down mode is available (introduced by commit 0112b7ce68ea ("usb: dwc2: Update dwc2_handle_usb_suspend_intr function.")). However, the dwc2_drd_role_sw_set() USB role update handler attempts to read DWC2 registers if the USB role has changed while the USB is in suspend mode (when the clocks are gated). This causes the system to hang.
Release the gadget clocks before handling the USB role update.
--- drivers/usb/dwc2/drd.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/dwc2/drd.c +9 -0
@@ -127,6 +127,15 @@ static int dwc2_drd_role_sw_set(struct u role =USB_ROLE_DEVICE ; } +if ((IS_ENABLED (CONFIG_USB_DWC2_PERIPHERAL ) || +IS_ENABLED (CONFIG_USB_DWC2_DUAL_ROLE )) && +dwc2_is_device_mode (hsotg) && + hsotg->lx_state ==DWC2_L2 && + hsotg->params.power_down ==DWC2_POWER_DOWN_PARAM_NONE && + hsotg->bus_suspended && + !hsotg->params.no_clock_gating) +dwc2_gadget_exit_clock_gating (hsotg,0 ); +if (role ==USB_ROLE_HOST ) { already =dwc2_ovr_avalid (hsotg, true); }else if (role ==USB_ROLE_DEVICE ) {
Greg Kroah-Hartman
maintainerPATCH 527/634 bus: integrator-lm: fix OF node leak in probe()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 15a62b81175885b5adfcaf49870466e3603f06c7 upstream.
Driver code is leaking OF node reference from of_find_matching_node() in probe().
--- drivers/bus/arm-integrator-lm.c | 1 + 1 file changed, 1 insertion(+)
drivers/bus/arm-integrator-lm.c +1 -0
@@ -85,6 +85,7 @@ static int integrator_ap_lm_probe(structreturn -ENODEV ; } map =syscon_node_to_regmap (syscon); +of_node_put (syscon);if (IS_ERR (map)) {dev_err (dev,"could not find Integrator/AP system controller\n" );
Greg Kroah-Hartman
maintainerPATCH 528/634 bus: mhi: host: pci_generic: Fix the name for the Telit FE990A
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Porcedda <[email protected]>
commit bfc5ca0fd1ea7aceae0b682fa4bd8079c52f96c8 upstream.
Add a mhi_pci_dev_info struct specific for the Telit FE990A modem in order to use the correct product name.
--- drivers/bus/mhi/host/pci_generic.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/bus/mhi/host/pci_generic.c +11 -2
@@ -606,6 +606,15 @@ static const struct mhi_pci_dev_info mhi .mru_default = 32768, }; +static const struct mhi_pci_dev_info mhi_telit_fe990a_info = { + .name ="telit-fe990a" , + .config = &modem_telit_fn990_config, + .bar_num =MHI_PCI_DEFAULT_BAR_NUM , + .dma_data_width =32 , + .sideband_wake = false, + .mru_default =32768 , +}; +/* Keep the list sorted based on the PID. New VID should be added as the last entry */ static const struct pci_device_id mhi_pci_id_table[] = { {PCI_DEVICE (PCI_VENDOR_ID_QCOM ,0x0304 ),
@@ -623,9 +632,9 @@ static const struct pci_device_id mhi_pc/* Telit FN990 */ { PCI_DEVICE_SUB(PCI_VENDOR_ID_QCOM, 0x0308, 0x1c5d, 0x2010), .driver_data = (kernel_ulong_t) &mhi_telit_fn990_info }, -/* Telit FE990 */ +/* Telit FE990A */ { PCI_DEVICE_SUB(PCI_VENDOR_ID_QCOM, 0x0308, 0x1c5d, 0x2015), - .driver_data = (kernel_ulong_t) &mhi_telit_fn990_info }, + .driver_data = (kernel_ulong_t) &mhi_telit_fe990a_info }, { PCI_DEVICE(PCI_VENDOR_ID_QCOM, 0x0308), .driver_data = (kernel_ulong_t) &mhi_qcom_sdx65_info }, { PCI_DEVICE(PCI_VENDOR_ID_QCOM, 0x0309),
Greg Kroah-Hartman
maintainerPATCH 529/634 firmware_loader: Block path traversal
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit f0e5311aa8022107d63c54e2f03684ec097d1394 upstream.
Most firmware names are hardcoded strings, or are constructed from fairly constrained format strings where the dynamic parts are just some hex numbers or such.
However, there are a couple codepaths in the kernel where firmware file names contain string components that are passed through from a device or semi-privileged userspace; the ones I could find (not counting interfaces that require root privileges) are:
- lpfc_sli4_request_firmware_update() seems to construct the firmware filename from "ModelName", a string that was previously parsed out of some descriptor ("Vital Product Data") in lpfc_fill_vpd()
- nfp_net_fw_find() seems to construct a firmware filename from a model name coming from nfp_hwinfo_lookup(pf->hwinfo, "nffw.partno"), which I think parses some descriptor that was read from the device. (But this case likely isn't exploitable because the format string looks like "netronome/nic_%s", and there shouldn't be any *folders* starting with "netronome/nic_". The previous case was different because there, the "%s" is *at the start* of the format string.)
- module_flash_fw_schedule() is reachable from the ETHTOOL_MSG_MODULE_FW_FLASH_ACT netlink command, which is marked as GENL_UNS_ADMIN_PERM (meaning CAP_NET_ADMIN inside a user namespace is enough to pass the privilege check), and takes a userspace-provided firmware name.
(But I think to reach this case, you need to have CAP_NET_ADMIN over a network namespace that a special kind of ethernet device is mapped into, so I think this is not a viable attack path in practice.)
Fix it by rejecting any firmware names containing ".." path components.
For what it's worth, I went looking and haven't found any USB device drivers that use the firmware loader dangerously.
--- drivers/base/firmware_loader/main.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/base/firmware_loader/main.c +30 -0
@@ -849,6 +849,26 @@ static void fw_log_firmware_info(const s {}#endif +/* +* Reject firmware file names with ".." path components. +* There are drivers that construct firmware file names from device-supplied +* strings, and we don't want some device to be able to tell us "I would like to +* be sent my firmware from ../../../etc/shadow, please". +* +* Search for ".." surrounded by either '/' or start/end of string. +* +* This intentionally only looks at the firmware name, not at the firmware base +* directory or at symlink contents. +*/ +static bool name_contains_dotdot (const char *name) +{ +size_t name_len =strlen (name); + +return strcmp (name,".." ) ==0 ||strncmp (name,"../" ,3 ) ==0 || +strstr (name,"/../" ) !=NULL || + (name_len >=3 &&strcmp (name+name_len-3 ,"/.." ) ==0 ); +} +/* called from request_firmware() and request_firmware_work_func() */ static int _request_firmware(const struct firmware **firmware_p, const char *name,
@@ -869,6 +889,14 @@ _request_firmware(const struct firmware goto out; } +if (name_contains_dotdot (name)) { +dev_warn (device, +"Firmware load for '%s' refused, path contains '..' component\n" , + name); + ret = -EINVAL ; + goto out; + } + ret =_request_firmware_prepare (&fw, name, device, buf, size, offset, opt_flags);if (ret <=0 )/* error or already assigned */
@@ -946,6 +974,8 @@ out:* @name will be used as $FIRMWARE in the uevent environment and * should be distinctive enough not to be confused with any other * firmware image for this or any other device. +* It must not contain any ".." path components - "foo/bar..bin" is +* allowed, but "foo/../bar.bin" is not. * * Caller must hold the reference count of @device. *
Greg Kroah-Hartman
maintainerPATCH 530/634 tty: rp2: Fix reset with non forgiving PCIe host bridges
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
commit f16dd10ba342c429b1e36ada545fb36d4d1f0e63 upstream.
The write to RP2_GLOBAL_CMD followed by an immediate read of RP2_GLOBAL_CMD in rp2_reset_asic() is intented to flush out the write, however by then the device is already in reset and cannot respond to a memory cycle access.
On platforms such as the Raspberry Pi 4 and others using the pcie-brcmstb.c driver, any memory access to a device that cannot respond is met with a fatal system error, rather than being substituted with all 1s as is usually the case on PC platforms.
Swapping the delay and the read ensures that the device has finished resetting before we attempt to read from it.
--- drivers/tty/serial/rp2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/rp2.c +1 -1
@@ -577,8 +577,8 @@ static void rp2_reset_asic(struct rp2_cau32 clk_cfg;writew (1 , base +RP2_GLOBAL_CMD ); -readw (base +RP2_GLOBAL_CMD );msleep (100 ); +readw (base +RP2_GLOBAL_CMD );writel (0 , base +RP2_CLK_PRESCALER );/* TDM clock configuration */
Greg Kroah-Hartman
maintainerPATCH 531/634 pps: add an error check in parport_attach
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit 62c5a01a5711c8e4be8ae7b6f0db663094615d48 upstream.
In parport_attach, the return value of ida_alloc is unchecked, witch leads to the use of an invalid index value.
To address this issue, index should be checked. When the index value is abnormal, the device should be freed.
Found by code review, compile tested only.
--- drivers/pps/clients/pps_parport.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/pps/clients/pps_parport.c +6 -2
@@ -149,6 +149,9 @@ static void parport_attach(struct parpor } index =ida_alloc (&pps_client_index,GFP_KERNEL ); +if (index <0 ) + goto err_free_device; +memset (&pps_client_cb,0 ,sizeof (pps_client_cb)); pps_client_cb.private = device; pps_client_cb.irq_func = parport_irq;
@@ -159,7 +162,7 @@ static void parport_attach(struct parpor index);if (!device->pardev) {pr_err ("couldn't register with %s\n" , port->name); - goto err_free; + goto err_free_ida; }if (parport_claim_or_block (device->pardev) <0 ) {
@@ -187,8 +190,9 @@ err_release_dev:parport_release (device->pardev); err_unregister_dev:parport_unregister_device (device->pardev); -err_free: +err_free_ida:ida_free (&pps_client_index, index); +err_free_device:kfree (device); }
Greg Kroah-Hartman
maintainerPATCH 532/634 serial: dont use uninitialized value in uart_poll_init()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby (SUSE) <[email protected]>
commit d0009a32c9e4e083358092f3c97e3c6e803a8930 upstream.
Coverity reports (as CID 1536978) that uart_poll_init() passes uninitialized pm_state to uart_change_pm(). It is in case the first 'if' takes the true branch (does "goto out;").
Fix this and simplify the function by simple guard(mutex). The code needs no labels after this at all. And it is pretty clear that the code has not fiddled with pm_state at that point.
--- drivers/tty/serial/serial_core.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/tty/serial/serial_core.c +6 -7
@@ -2696,14 +2696,13 @@ static int uart_poll_init(struct tty_driint ret =0 ; tport = &state->port; -mutex_lock (&tport->mutex); + +guard (mutex)(&tport->mutex); port =uart_port_check (state);if (!port || port->type ==PORT_UNKNOWN || - !(port->ops->poll_get_char && port->ops->poll_put_char)) { - ret =-1 ; - goto out; - } + !(port->ops->poll_get_char && port->ops->poll_put_char)) +return -1 ; pm_state = state->pm_state;uart_change_pm (state,UART_PM_STATE_ON );
@@ -2723,10 +2722,10 @@ static int uart_poll_init(struct tty_dri ret =uart_set_options (port,NULL , baud, parity, bits, flow);console_list_unlock (); } -out: +if (ret)uart_change_pm (state, pm_state); -mutex_unlock (&tport->mutex); +return ret; }
Greg Kroah-Hartman
maintainerPATCH 533/634 xhci: Set quirky xHC PCI hosts to D3 _after_ stopping and freeing them.
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit f81dfa3b57c624c56f2bff171c431bc7f5b558f2 upstream.
PCI xHC host should be stopped and xhci driver memory freed before putting host to PCI D3 state during PCI remove callback.
Hosts with XHCI_SPURIOUS_WAKEUP quirk did this the wrong way around and set the host to D3 before calling usb_hcd_pci_remove(dev), which will access the host to stop it, and then free xhci.
--- drivers/usb/host/xhci-pci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/usb/host/xhci-pci.c +5 -3
@@ -662,8 +662,10 @@ put_runtime_pm:static void xhci_pci_remove (struct pci_dev *dev) {struct xhci_hcd *xhci; +bool set_power_d3; xhci =hcd_to_xhci (pci_get_drvdata (dev)); + set_power_d3 = xhci->quirks &XHCI_SPURIOUS_WAKEUP ; xhci->xhc_state |=XHCI_STATE_REMOVING ;
@@ -676,11 +678,11 @@ static void xhci_pci_remove(struct pci_d xhci->shared_hcd =NULL ; } +usb_hcd_pci_remove (dev); +/* Workaround for spurious wakeups at shutdown with HSW */ -if (xhci->quirks &XHCI_SPURIOUS_WAKEUP ) +if (set_power_d3)pci_set_power_state (dev, PCI_D3hot); - -usb_hcd_pci_remove (dev); }/*
Greg Kroah-Hartman
maintainerPATCH 534/634 serial: qcom-geni: fix fifo polling timeout
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit c80ee36ac8f9e9c27d8e097a2eaaf198e7534c83 upstream.
The qcom_geni_serial_poll_bit() can be used to wait for events like command completion and is supposed to wait for the time it takes to clear a full fifo before timing out.
As noted by Doug, the current implementation does not account for start, stop and parity bits when determining the timeout. The helper also does not currently account for the shift register and the two-word intermediate transfer register.
A too short timeout can specifically lead to lost characters when waiting for a transfer to complete as the transfer is cancelled on timeout.
Instead of determining the poll timeout on every call, store the fifo timeout when updating it in set_termios() and make sure to take the shift and intermediate registers into account. Note that serial core has already added a 20 ms margin to the fifo timeout.
Also note that the current uart_fifo_timeout() interface does unnecessary calculations on every call and did not exist in earlier kernels so only store its result once. This facilitates backports too as earlier kernels can derive the timeout from uport->timeout, which has since been removed.
--- drivers/tty/serial/qcom_geni_serial.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +17 -14
@@ -124,7 +124,7 @@ struct qcom_geni_serial_port {dma_addr_t tx_dma_addr;dma_addr_t rx_dma_addr;bool setup; -unsigned int baud; +unsigned long poll_timeout_us;unsigned long clk_rate;void *rx_buf;u32 loopback;
@@ -270,22 +270,13 @@ static bool qcom_geni_serial_poll_bit(st {u32 reg;struct qcom_geni_serial_port *port; -unsigned int baud; -unsigned int fifo_bits;unsigned long timeout_us =20000 ;struct qcom_geni_private_data *private_data = uport->private_data;if (private_data->drv) { port =to_dev_port (uport); - baud = port->baud; -if (!baud) - baud =115200 ; - fifo_bits = port->tx_fifo_depth * port->tx_fifo_width; -/* -* Total polling iterations based on FIFO worth of bytes to be -* sent at current baud. Add a little fluff to the wait. -*/ - timeout_us = ((fifo_bits *USEC_PER_SEC ) / baud) +500 ; +if (port->poll_timeout_us) + timeout_us = port->poll_timeout_us; }/*
@@ -1244,11 +1235,11 @@ static void qcom_geni_serial_set_termiosunsigned long clk_rate;u32 ver, sampling_rate;unsigned int avg_bw_core; +unsigned long timeout;qcom_geni_serial_stop_rx (uport);/* baud rate */ baud =uart_get_baud_rate (uport, termios, old,300 ,4000000 ); - port->baud = baud; sampling_rate =UART_OVERSAMPLING ;/* Sampling rate is halved for IP versions >= 2.5 */
@@ -1326,9 +1317,21 @@ static void qcom_geni_serial_set_termioselse tx_trans_cfg |=UART_CTS_MASK ; -if (baud) +if (baud) {uart_update_timeout (uport, termios->c_cflag, baud); +/* +* Make sure that qcom_geni_serial_poll_bitfield() waits for +* the FIFO, two-word intermediate transfer register and shift +* register to clear. +* +* Note that uart_fifo_timeout() also adds a 20 ms margin. +*/ + timeout =jiffies_to_usecs (uart_fifo_timeout (uport)); + timeout +=3 * timeout / port->tx_fifo_depth; +WRITE_ONCE (port->poll_timeout_us, timeout); + } +if (!uart_console (uport))writel (port->loopback, uport->membase +SE_UART_LOOPBACK_CFG );
Greg Kroah-Hartman
maintainerPATCH 535/634 serial: qcom-geni: fix false console tx restart
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit f97cdbbf187fefcf1fe19689cd9fdca11fe9c3eb upstream.
Commit 663abb1a7a7f ("tty: serial: qcom_geni_serial: Fix UART hang") addressed an issue with stalled tx after the console code interrupted the last bytes of a tx command by reenabling the watermark interrupt if there is data in write buffer. This can however break software flow control by re-enabling tx after the user has stopped it.
Address the original issue by not clearing the CMD_DONE flag after polling for command completion. This allows the interrupt handler to start another transfer when the CMD_DONE interrupt has not been disabled due to flow control.
--- drivers/tty/serial/qcom_geni_serial.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +3 -10
@@ -306,18 +306,16 @@ static void qcom_geni_serial_setup_tx(ststatic void qcom_geni_serial_poll_tx_done (struct uart_port *uport) {int done; -u32 irq_clear =M_CMD_DONE_EN ; done =qcom_geni_serial_poll_bit (uport,SE_GENI_M_IRQ_STATUS ,M_CMD_DONE_EN , true);if (!done) {writel (M_GENI_CMD_ABORT , uport->membase +SE_GENI_M_CMD_CTRL_REG ); - irq_clear |=M_CMD_ABORT_EN ;qcom_geni_serial_poll_bit (uport,SE_GENI_M_IRQ_STATUS ,M_CMD_ABORT_EN , true); +writel (M_CMD_ABORT_EN , uport->membase +SE_GENI_M_IRQ_CLEAR ); } -writel (irq_clear, uport->membase +SE_GENI_M_IRQ_CLEAR ); }static void qcom_geni_serial_abort_rx (struct uart_port *uport)
@@ -378,6 +376,7 @@ static void qcom_geni_serial_poll_put_ch unsigned char c) {writel (DEF_TX_WM , uport->membase +SE_GENI_TX_WATERMARK_REG ); +writel (M_CMD_DONE_EN , uport->membase +SE_GENI_M_IRQ_CLEAR );qcom_geni_serial_setup_tx (uport,1 );WARN_ON (!qcom_geni_serial_poll_bit (uport,SE_GENI_M_IRQ_STATUS ,M_TX_FIFO_WATERMARK_EN , true));
@@ -422,6 +421,7 @@ __qcom_geni_serial_console_write(struct }writel (DEF_TX_WM , uport->membase +SE_GENI_TX_WATERMARK_REG ); +writel (M_CMD_DONE_EN , uport->membase +SE_GENI_M_IRQ_CLEAR );qcom_geni_serial_setup_tx (uport, bytes_to_send);for (i =0 ; i < count; ) {size_t chars_to_write =0 ;
@@ -463,7 +463,6 @@ static void qcom_geni_serial_console_wribool locked = true;unsigned long flags;u32 geni_status; -u32 irq_en;WARN_ON (co->index <0 || co->index >=GENI_UART_CONS_PORTS );
@@ -495,12 +494,6 @@ static void qcom_geni_serial_console_wri* has been sent, in which case we need to look for done first. */ qcom_geni_serial_poll_tx_done (uport); - -if (!kfifo_is_empty (&uport->state->port.xmit_fifo)) { - irq_en =readl (uport->membase +SE_GENI_M_IRQ_EN ); -writel (irq_en |M_TX_FIFO_WATERMARK_EN , - uport->membase +SE_GENI_M_IRQ_EN ); - } }__qcom_geni_serial_console_write (uport, s, count);
Greg Kroah-Hartman
maintainerPATCH 536/634 crypto: qcom-rng - fix support for ACPI-based systems
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Masney <[email protected]>
commit 3e87031a6ce68f13722155497cd511a00b56a2ae upstream.
The qcom-rng driver supports both ACPI and device tree-based systems. ACPI support was broken when the hw_random interface support was added. Let's go ahead and fix this by adding the appropriate driver data to the ACPI match table, and change the of_device_get_match_data() call to device_get_match_data() so that it will also work on ACPI-based systems.
This fix was boot tested on a Qualcomm Amberwing server (ACPI based) and on a Qualcomm SA8775p Automotive Development Board (DT based). I also verified that qcom-rng shows up in /proc/crypto on both systems.
--- drivers/crypto/qcom-rng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/qcom-rng.c +2 -2
@@ -196,7 +196,7 @@ static int qcom_rng_probe(struct platform_device *pdev)if (IS_ERR (rng->clk))return PTR_ERR (rng->clk); - rng->of_data = (struct qcom_rng_of_data *)of_device_get_match_data (&pdev->dev); + rng->of_data = (struct qcom_rng_of_data *)device_get_match_data (&pdev->dev); qcom_rng_dev = rng; ret =crypto_register_rng (&qcom_rng_alg);
@@ -247,7 +247,7 @@ static struct qcom_rng_of_data qcom_trng_of_data = { };static const struct acpi_device_id __maybe_unused qcom_rng_acpi_match[] = { - { .id ="QCOM8160" , .driver_data =1 }, + { .id ="QCOM8160" , .driver_data = (kernel_ulong_t)&qcom_prng_ee_of_data }, {} };MODULE_DEVICE_TABLE (acpi, qcom_rng_acpi_match);
Signature · 1 line
2.46.2
Greg Kroah-Hartman
maintainerPATCH 537/634 crypto: ccp - Properly unregister /dev/sev on sev PLATFORM_STATUS failure
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavan Kumar Paluri <[email protected]>
commit ce3d2d6b150ba8528f3218ebf0cee2c2c572662d upstream.
In case of sev PLATFORM_STATUS failure, sev_get_api_version() fails resulting in sev_data field of psp_master nulled out. This later becomes a problem when unloading the ccp module because the device has not been unregistered (via misc_deregister()) before clearing the sev_data field of psp_master. As a result, on reloading the ccp module, a duplicate device issue is encountered as can be seen from the dmesg log below.
on reloading ccp module via modprobe ccp
Call Trace: <TASK> dump_stack_lvl+0xd7/0xf0 dump_stack+0x10/0x20 sysfs_warn_dup+0x5c/0x70 sysfs_create_dir_ns+0xbc/0xd kobject_add_internal+0xb1/0x2f0 kobject_add+0x7a/0xe0 ? srso_alias_return_thunk+0x5/0xfbef5 ? get_device_parent+0xd4/0x1e0 ? __pfx_klist_children_get+0x10/0x10 device_add+0x121/0x870 ? srso_alias_return_thunk+0x5/0xfbef5 device_create_groups_vargs+0xdc/0x100 device_create_with_groups+0x3f/0x60 misc_register+0x13b/0x1c0 sev_dev_init+0x1d4/0x290 [ccp] psp_dev_init+0x136/0x300 [ccp] sp_init+0x6f/0x80 [ccp] sp_pci_probe+0x2a6/0x310 [ccp] ? srso_alias_return_thunk+0x5/0xfbef5 local_pci_probe+0x4b/0xb0 work_for_cpu_fn+0x1a/0x30 process_one_work+0x203/0x600 worker_thread+0x19e/0x350 ? __pfx_worker_thread+0x10/0x10 kthread+0xeb/0x120 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x3c/0x60 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> kobject: kobject_add_internal failed for sev with -EEXIST, don't try to register things with the same name in the same directory. ccp 0000:22:00.1: sev initialization failed ccp 0000:22:00.1: psp initialization failed ccp 0000:a2:00.1: no command queues available ccp 0000:a2:00.1: psp enabled
Address this issue by unregistering the /dev/sev before clearing out sev_data in case of PLATFORM_STATUS failure.
--- drivers/crypto/ccp/sev-dev.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/crypto/ccp/sev-dev.c +2 -0
@@ -2385,6 +2385,8 @@ void sev_pci_init(void)return ; err: +sev_dev_destroy (psp_master); + psp_master->sev_data =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 538/634 drbd: Fix atomicity violation in drbd_uuid_set_bm()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiu-ji Chen <[email protected]>
commit 2f02b5af3a4482b216e6a466edecf6ba8450fa45 upstream.
The violation of atomicity occurs when the drbd_uuid_set_bm function is executed simultaneously with modifying the value of device->ldev->md.uuid[UI_BITMAP]. Consider a scenario where, while device->ldev->md.uuid[UI_BITMAP] passes the validity check when its value is not zero, the value of device->ldev->md.uuid[UI_BITMAP] is written to zero. In this case, the check in drbd_uuid_set_bm might refer to the old value of device->ldev->md.uuid[UI_BITMAP] (before locking), which allows an invalid value to pass the validity check, resulting in inconsistency.
To address this issue, it is recommended to include the data validity check within the locked section of the function. This modification ensures that the value of device->ldev->md.uuid[UI_BITMAP] does not change during the validation process, thereby maintaining its integrity.
This possible bug is found by an experimental static analysis tool developed by our team. This tool analyzes the locking APIs to extract function pairs that can be concurrently executed, and then analyzes the instructions in the paired functions to identify possible concurrency bugs including data races and atomicity violations.
--- drivers/block/drbd/drbd_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/block/drbd/drbd_main.c +4 -2
@@ -3399,10 +3399,12 @@ void drbd_uuid_new_current(struct drbd_dvoid drbd_uuid_set_bm (struct drbd_device *device,u64 val)__must_hold (local) {unsigned long flags; -if (device->ldev->md.uuid[UI_BITMAP ] ==0 && val ==0 ) +spin_lock_irqsave (&device->ldev->md.uuid_lock, flags); +if (device->ldev->md.uuid[UI_BITMAP ] ==0 && val ==0 ) { +spin_unlock_irqrestore (&device->ldev->md.uuid_lock, flags);return ; + } -spin_lock_irqsave (&device->ldev->md.uuid_lock, flags);if (val ==0 ) {drbd_uuid_move_history (device); device->ldev->md.uuid[UI_HISTORY_START ] = device->ldev->md.uuid[UI_BITMAP ];
Greg Kroah-Hartman
maintainerPATCH 539/634 drbd: Add NULL check for net_conf to prevent dereference in state validation
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Lobanov <[email protected]>
commit a5e61b50c9f44c5edb6e134ede6fee8806ffafa9 upstream.
If the net_conf pointer is NULL and the code attempts to access its fields without a check, it will lead to a null pointer dereference. Add a NULL check before dereferencing the pointer.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/block/drbd/drbd_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/drbd/drbd_state.c +1 -1
@@ -876,7 +876,7 @@ is_valid_state(struct drbd_device *devic ns.disk == D_OUTDATED) rv =SS_CONNECTED_OUTDATES ; - else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) && + else if (nc && (ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) && (nc->verify_alg[0] == 0)) rv =SS_NO_VERIFY_ALG ;
Greg Kroah-Hartman
maintainerPATCH 540/634 ACPI: sysfs: validate return type of _STR method
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
commit 4bb1e7d027413835b086aed35bc3f0713bc0f72b upstream.
Only buffer objects are valid return values of _STR.
If something else is returned description_show() will access invalid memory.
--- drivers/acpi/device_sysfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/acpi/device_sysfs.c +3 -2
@@ -540,8 +540,9 @@ int acpi_device_setup_files(struct acpi_* If device has _STR, 'description' file is created */ if (acpi_has_method (dev->handle,"_STR" )) { - status =acpi_evaluate_object (dev->handle,"_STR" , -NULL , &buffer); + status =acpi_evaluate_object_typed (dev->handle,"_STR" , +NULL , &buffer, +ACPI_TYPE_BUFFER );if (ACPI_FAILURE (status)) buffer.pointer =NULL ; dev->pnp.str_obj = buffer.pointer;
Greg Kroah-Hartman
maintainerPATCH 541/634 ACPI: resource: Do IRQ override on MECHREV GM7XG0M
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Chen <[email protected]>
commit b53f09ecd602d7b8b7da83b0890cbac500b6a9b9 upstream.
Listed device need the override for the keyboard to work.
--- drivers/acpi/resource.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/acpi/resource.c +6 -0
@@ -555,6 +555,12 @@ static const struct dmi_system_id irq1_l*/ static const struct dmi_system_id irq1_edge_low_force_override[] = { { +/* MECHREV Jiaolong17KS Series GM7XG0M */ + .matches = { +DMI_MATCH (DMI_BOARD_NAME ,"GM7XG0M" ), + }, + }, + {/* XMG APEX 17 (M23) */ .matches = {DMI_MATCH (DMI_BOARD_NAME ,"GMxBGxx" ),
Greg Kroah-Hartman
maintainerPATCH 542/634 ACPI: resource: Add another DMI match for the TongFang GMxXGxx
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Werner Sembach <[email protected]>
commit a98cfe6ff15b62f94a44d565607a16771c847bc6 upstream.
Internal documentation suggest that the TUXEDO Polaris 15 Gen5 AMD might have GMxXGxX as the board name instead of GMxXGxx.
Adding both to be on the safe side.
--- drivers/acpi/resource.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/acpi/resource.c +6 -0
@@ -579,6 +579,12 @@ static const struct dmi_system_id irq1_e }, }, { +/* TongFang GMxXGxX/TUXEDO Polaris 15 Gen5 AMD */ + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "GMxXGxX"), + }, + }, + {/* TongFang GMxXGxx sold as Eluktronics Inc. RP-15 */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Eluktronics Inc."),
Greg Kroah-Hartman
maintainerPATCH 543/634 efistub/tpm: Use ACPI reclaim memory for event log to avoid corruption
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 77d48d39e99170b528e4f2e9fc5d1d64cdedd386 upstream.
The TPM event log table is a Linux specific construct, where the data produced by the GetEventLog() boot service is cached in memory, and passed on to the OS using an EFI configuration table.
The use of EFI_LOADER_DATA here results in the region being left unreserved in the E820 memory map constructed by the EFI stub, and this is the memory description that is passed on to the incoming kernel by kexec, which is therefore unaware that the region should be reserved.
Even though the utility of the TPM2 event log after a kexec is questionable, any corruption might send the parsing code off into the weeds and crash the kernel. So let's use EFI_ACPI_RECLAIM_MEMORY instead, which is always treated as reserved by the E820 conversion logic.
--- drivers/firmware/efi/libstub/tpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/libstub/tpm.c +1 -1
@@ -96,7 +96,7 @@ static void efi_retrieve_tcg2_eventlog(i }/* Allocate space for the logs and copy them. */ - status =efi_bs_call (allocate_pool,EFI_LOADER_DATA , + status =efi_bs_call (allocate_pool,EFI_ACPI_RECLAIM_MEMORY ,sizeof (*log_tbl) + log_size, (void **)&log_tbl);if (status !=EFI_SUCCESS ) {
Greg Kroah-Hartman
maintainerPATCH 544/634 x86/entry: Remove unwanted instrumentation in common_interrupt()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Vyukov <[email protected]>
commit 477d81a1c47a1b79b9c08fc92b5dea3c5143800b upstream.
common_interrupt() and related variants call kvm_set_cpu_l1tf_flush_l1d(), which is neither marked noinstr nor __always_inline.
So compiler puts it out of line and adds instrumentation to it. Since the call is inside of instrumentation_begin/end(), objtool does not warn about it.
The manifestation is that KCOV produces spurious coverage in kvm_set_cpu_l1tf_flush_l1d() in random places because the call happens when preempt count is not yet updated to say that the kernel is in an interrupt.
Mark kvm_set_cpu_l1tf_flush_l1d() as __always_inline and move it out of the instrumentation_begin/end() section. It only calls __this_cpu_write() which is already safe to call in noinstr contexts.
--- arch/x86/include/asm/hardirq.h | 8 ++++++-- arch/x86/include/asm/idtentry.h | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-)
arch/x86/include/asm/hardirq.h +6 -2
@@ -69,7 +69,11 @@ extern u64 arch_irq_stat(void);#define local_softirq_pending_ref pcpu_hot.softirq_pending#if IS_ENABLED (CONFIG_KVM_INTEL ) -static inline void kvm_set_cpu_l1tf_flush_l1d (void ) +/* +* This function is called from noinstr interrupt contexts +* and must be inlined to not get instrumentation. +*/ +static __always_inline void kvm_set_cpu_l1tf_flush_l1d(void) {__this_cpu_write (irq_stat.kvm_cpu_l1tf_flush_l1d,1 ); }
@@ -84,7 +88,7 @@ static __always_inline bool kvm_get_cpu_return __this_cpu_read (irq_stat.kvm_cpu_l1tf_flush_l1d); }#else /* !IS_ENABLED(CONFIG_KVM_INTEL) */ -static inline void kvm_set_cpu_l1tf_flush_l1d (void ) { } +static __always_inline void kvm_set_cpu_l1tf_flush_l1d(void) { }#endif /* IS_ENABLED(CONFIG_KVM_INTEL) */ #endif /* _ASM_X86_HARDIRQ_H */
arch/x86/include/asm/idtentry.h +3 -3
@@ -212,8 +212,8 @@ __visible noinstr void func(struct pt_reirqentry_state_t state =irqentry_enter (regs); \u32 vector = (u32 )(u8 )error_code; \ \ +kvm_set_cpu_l1tf_flush_l1d (); \instrumentation_begin (); \ -kvm_set_cpu_l1tf_flush_l1d (); \ run_irq_on_irqstack_cond(__##func, regs, vector); \ instrumentation_end(); \ irqentry_exit(regs, state); \
@@ -250,7 +250,6 @@ static void __##func(struct pt_regs *reg \ static __always_inline void instr_##func(struct pt_regs *regs) \ { \ - kvm_set_cpu_l1tf_flush_l1d(); \ run_sysvec_on_irqstack_cond(__##func, regs); \ } \ \
@@ -258,6 +257,7 @@ __visible noinstr void func(struct pt_re { \irqentry_state_t state =irqentry_enter (regs); \ \ +kvm_set_cpu_l1tf_flush_l1d (); \instrumentation_begin (); \ instr_##func (regs); \instrumentation_end (); \
@@ -288,7 +288,6 @@ static __always_inline void __##func(str static __always_inline void instr_##func(struct pt_regs *regs) \ { \ __irq_enter_raw(); \ - kvm_set_cpu_l1tf_flush_l1d(); \ __##func (regs); \ __irq_exit_raw(); \ } \
@@ -297,6 +296,7 @@ __visible noinstr void func(struct pt_re { \irqentry_state_t state =irqentry_enter (regs); \ \ +kvm_set_cpu_l1tf_flush_l1d (); \instrumentation_begin (); \ instr_##func (regs); \instrumentation_end (); \
Greg Kroah-Hartman
maintainerPATCH 545/634 perf/x86/intel: Allow to setup LBR for counting event for BPF
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
commit ef493f4b122d6b14a6de111d1acac1eab1d673b0 upstream.
The BPF subsystem may capture LBR data on a counting event. However, the current implementation assumes that LBR can/should only be used with sampling events.
For instance, retsnoop tool ([0]) makes an extensive use of this functionality and sets up perf event as follows:
struct perf_event_attr attr; memset(&attr, 0, sizeof(attr)); attr.size = sizeof(attr); attr.type = PERF_TYPE_HARDWARE; attr.config = PERF_COUNT_HW_CPU_CYCLES; attr.sample_type = PERF_SAMPLE_BRANCH_STACK; attr.branch_sample_type = PERF_SAMPLE_BRANCH_KERNEL;
To limit the LBR for a sampling event is to avoid unnecessary branch stack setup for a counting event in the sample read. Because LBR is only read in the sampling event's overflow.
Although in most cases LBR is used in sampling, there is no HW limit to bind LBR to the sampling mode. Allow an LBR setup for a counting event unless in the sample read mode.
--- arch/x86/events/intel/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/x86/events/intel/core.c +6 -2
@@ -3912,8 +3912,12 @@ static int intel_pmu_hw_config(struct pe x86_pmu.pebs_aliases (event); } -if (needs_branch_stack (event) &&is_sampling_event (event)) - event->hw.flags |=PERF_X86_EVENT_NEEDS_BRANCH_STACK ; +if (needs_branch_stack (event)) { +/* Avoid branch stack setup for counting events in SAMPLE READ */ +if (is_sampling_event (event) || + !(event->attr.sample_type &PERF_SAMPLE_READ )) + event->hw.flags |=PERF_X86_EVENT_NEEDS_BRANCH_STACK ; + }if (branch_sample_counters (event)) {struct perf_event *leader, *sibling;
Greg Kroah-Hartman
maintainerPATCH 546/634 perf/x86/intel/pt: Fix sampling synchronization
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit d92792a4b26e50b96ab734cbe203d8a4c932a7a9 upstream.
pt_event_snapshot_aux() uses pt->handle_nmi to determine if tracing needs to be stopped, however tracing can still be going because pt->handle_nmi is set to zero before tracing is stopped in pt_event_stop, whereas pt_event_snapshot_aux() requires that tracing must be stopped in order to copy a sample of trace from the buffer.
Instead call pt_config_stop() always, which anyway checks config for RTIT_CTL_TRACEEN and does nothing if it is already clear.
Note pt_event_snapshot_aux() can continue to use pt->handle_nmi to determine if the trace needs to be restarted afterwards.
--- arch/x86/events/intel/pt.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
arch/x86/events/intel/pt.c +7 -8
@@ -1606,6 +1606,7 @@ static void pt_event_stop(struct perf_ev* see comment in intel_pt_interrupt(). */ WRITE_ONCE (pt->handle_nmi,0 ); +barrier ();pt_config_stop (event);
@@ -1657,11 +1658,10 @@ static long pt_event_snapshot_aux(structreturn 0 ;/* -* Here, handle_nmi tells us if the tracing is on +* There is no PT interrupt in this mode, so stop the trace and it will +* remain stopped while the buffer is copied. */ -if (READ_ONCE (pt->handle_nmi)) -pt_config_stop (event); - +pt_config_stop (event);pt_read_offset (buf);pt_update_head (pt);
@@ -1673,11 +1673,10 @@ static long pt_event_snapshot_aux(struct ret =perf_output_copy_aux (&pt->handle, handle, from, to);/* -* If the tracing was on when we turned up, restart it. -* Compiler barrier not needed as we couldn't have been -* preempted by anything that touches pt->handle_nmi. +* Here, handle_nmi tells us if the tracing was on. +* If the tracing was on, restart it. */ -if (pt->handle_nmi) +if (READ_ONCE (pt->handle_nmi))pt_config_start (event);return ret;
Greg Kroah-Hartman
maintainerPATCH 547/634 btrfs: subpage: fix the bitmap dump which can cause bitmap corruption
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit 77b0b98bb743f5d04d8f995ba1936e1143689d4a upstream.
In commit 75258f20fb70 ("btrfs: subpage: dump extra subpage bitmaps for debug") an internal macro GET_SUBPAGE_BITMAP() is introduced to grab the bitmap of each attribute.
But that commit is using bitmap_cut() which will do the left shift of the larger bitmap, causing incorrect values.
Thankfully this bitmap_cut() is only called for debug usage, and so far it's not yet causing problem.
Fix it to use bitmap_read() to only grab the desired sub-bitmap.
--- fs/btrfs/subpage.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/btrfs/subpage.c +8 -2
@@ -766,8 +766,14 @@ void btrfs_folio_unlock_writer(struct bt }#define GET_SUBPAGE_BITMAP (subpage, subpage_info, name, dst) \ - bitmap_cut(dst, subpage->bitmaps, 0, \ - subpage_info->name##_offset, subpage_info->bitmap_nr_bits) +{ \ + const int bitmap_nr_bits = subpage_info->bitmap_nr_bits; \ + \ + ASSERT(bitmap_nr_bits < BITS_PER_LONG); \ + *dst = bitmap_read(subpage->bitmaps, \ + subpage_info->name##_offset, \ + bitmap_nr_bits); \ +}void __cold btrfs_subpage_dump_bitmap (const struct btrfs_fs_info *fs_info,struct folio *folio,u64 start,u32 len)
Greg Kroah-Hartman
maintainerPATCH 548/634 wifi: mt76: mt7921: Check devm_kasprintf() returned value
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit 1ccc9e476ce76e8577ba4fdbd1f63cb3e3499d38 upstream.
devm_kasprintf() can return a NULL pointer on failure but this returned value is not checked. Fix this lack and check the returned value.
Found by code review.
--- drivers/net/wireless/mediatek/mt76/mt7921/init.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/init.c +2 -0
@@ -52,6 +52,8 @@ static int mt7921_thermal_init(struct mt name =devm_kasprintf (&wiphy->dev,GFP_KERNEL ,"mt7921_%s" ,wiphy_name (wiphy)); +if (!name) +return -ENOMEM ; hwmon =devm_hwmon_device_register_with_groups (&wiphy->dev, name, phy, mt7921_hwmon_groups);
Greg Kroah-Hartman
maintainerPATCH 549/634 wifi: mt76: mt7915: check devm_kasprintf() returned value
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit 267efeda8c55f30e0e7c5b7fd03dea4efec6916c upstream.
devm_kasprintf() can return a NULL pointer on failure but this returned value is not checked. Fix this lack and check the returned value.
Found by code review.
--- drivers/net/wireless/mediatek/mt76/mt7915/init.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/init.c +2 -0
@@ -194,6 +194,8 @@ static int mt7915_thermal_init(struct mt name =devm_kasprintf (&wiphy->dev,GFP_KERNEL ,"mt7915_%s" ,wiphy_name (wiphy)); +if (!name) +return -ENOMEM ; cdev =thermal_cooling_device_register (name, phy, &mt7915_thermal_ops);if (!IS_ERR (cdev)) {
Greg Kroah-Hartman
maintainerPATCH 550/634 wifi: mt76: mt7996: fix NULL pointer dereference in mt7996_mcu_sta_bfer_he
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit f503ae90c7355e8506e68498fe84c1357894cd5b upstream.
Fix the NULL pointer dereference in mt7996_mcu_sta_bfer_he routine adding an sta interface to the mt7996 driver.
Found by code review.
--- drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +3 -0
@@ -1544,6 +1544,9 @@ mt7996_mcu_sta_bfer_he(struct ieee80211_u8 nss_mcs =mt7996_mcu_get_sta_nss (mcs_map);u8 snd_dim, sts; +if (!vc) +return ; + bf->tx_mode =MT_PHY_TYPE_HE_SU ;mt7996_mcu_sta_sounding_rate (bf);
Greg Kroah-Hartman
maintainerPATCH 551/634 wifi: mt76: mt7925: fix a potential array-index-out-of-bounds issue for clc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Yen Hsieh <[email protected]>
commit 9679ca7326e52282cc923c4d71d81c999cb6cd55 upstream.
Due to the lack of checks on the clc array, if the firmware supports more clc configuration, it will cause illegal memory access.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +3 -0
@@ -613,6 +613,9 @@ static int mt7925_load_clc(struct mt792xfor (offset =0 ; offset < len; offset +=le32_to_cpu (clc->len)) { clc = (const struct mt7925_clc *)(clc_base + offset); +if (clc->idx >ARRAY_SIZE (phy->clc)) +break ; +/* do not init buf again if chip reset triggered */ if (phy->clc[clc->idx])continue ;
Greg Kroah-Hartman
maintainerPATCH 552/634 wifi: rtw88: 8821cu: Remove VID/PID 0bda:c82c
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nick Morrow <[email protected]>
commit 0af8cd2822f31ed8363223329e5cff2a7ed01961 upstream.
Remove VID/PID 0bda:c82c as it was inadvertently added to the device list in driver rtw8821cu. This VID/PID is for the rtw8822cu device and it is already in the appropriate place for that device.
--- drivers/net/wireless/realtek/rtw88/rtw8821cu.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/wireless/realtek/rtw88/rtw8821cu.c +0 -2
@@ -31,8 +31,6 @@ static const struct usb_device_id rtw_88 .driver_info = (kernel_ulong_t)&(rtw8821c_hw_spec) }, { USB_DEVICE_AND_INTERFACE_INFO(RTW_USB_VENDOR_ID_REALTEK, 0xc82b, 0xff, 0xff, 0xff), .driver_info = (kernel_ulong_t)&(rtw8821c_hw_spec) }, - { USB_DEVICE_AND_INTERFACE_INFO(RTW_USB_VENDOR_ID_REALTEK, 0xc82c, 0xff, 0xff, 0xff), - .driver_info = (kernel_ulong_t)&(rtw8821c_hw_spec) }, { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x331d, 0xff, 0xff, 0xff), .driver_info = (kernel_ulong_t)&(rtw8821c_hw_spec) }, /* D-Link */ { USB_DEVICE_AND_INTERFACE_INFO(0x7392, 0xc811, 0xff, 0xff, 0xff),
Greg Kroah-Hartman
maintainerPATCH 553/634 wifi: rtw88: 8822c: Fix reported RX band width
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bitterblue Smith <[email protected]>
commit a71ed5898dfae68262f79277915d1dfe34586bc6 upstream.
"iw dev wlp2s0 station dump" shows incorrect rx bitrate:
tx bitrate: 866.7 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 2 rx bitrate: 86.7 MBit/s VHT-MCS 9 VHT-NSS 1
This is because the RX band width is calculated incorrectly. Fix the calculation according to the phydm_rxsc_2_bw() function from the official drivers.
After:
tx bitrate: 866.7 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 2 rx bitrate: 390.0 MBit/s VHT-MCS 9 80MHz VHT-NSS 1
It also works correctly with the AP configured for 20 MHz and 40 MHz.
Tested with RTL8822CE.
--- drivers/net/wireless/realtek/rtw88/rtw8822c.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/realtek/rtw88/rtw8822c.c +6 -4
@@ -2611,12 +2611,14 @@ static void query_phy_status_page1(strucelse rxsc =GET_PHY_STAT_P1_HT_RXSC (phy_status); -if (rxsc >=9 && rxsc <=12 ) +if (rxsc ==0 ) + bw = rtwdev->hal.current_band_width; +else if (rxsc >=1 && rxsc <=8 ) + bw =RTW_CHANNEL_WIDTH_20 ; +else if (rxsc >=9 && rxsc <=12 ) bw =RTW_CHANNEL_WIDTH_40 ; -else if (rxsc >=13 ) - bw =RTW_CHANNEL_WIDTH_80 ;else - bw =RTW_CHANNEL_WIDTH_20 ; + bw =RTW_CHANNEL_WIDTH_80 ; channel =GET_PHY_STAT_P1_CHANNEL (phy_status);rtw_set_rx_freq_band (pkt_stat, channel);
Greg Kroah-Hartman
maintainerPATCH 554/634 wifi: rtw88: 8703b: Fix reported RX band width
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bitterblue Smith <[email protected]>
commit 0129e5ff2842450f1426e312b5e580c0814e0de3 upstream.
The definition of GET_RX_DESC_BW is incorrect. Fix it according to the GET_RX_STATUS_DESC_BW_8703B macro from the official driver.
Tested only with RTL8812AU, which uses the same bits.
--- drivers/net/wireless/realtek/rtw88/rx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/rx.h +1 -1
@@ -41,7 +41,7 @@ enum rtw_rx_desc_enc {#define GET_RX_DESC_TSFL (rxdesc) \ le32_get_bits(*((__le32 *)(rxdesc) + 0x05), GENMASK(31, 0))#define GET_RX_DESC_BW (rxdesc) \ - (le32_get_bits(*((__le32 *)(rxdesc) + 0x04), GENMASK(31, 24))) + (le32_get_bits(*((__le32 *)(rxdesc) + 0x04), GENMASK(5, 4)))void rtw_rx_stats (struct rtw_dev *rtwdev,struct ieee80211_vif *vif,struct sk_buff *skb);
Signature · 1 line
2.46.2
Greg Kroah-Hartman
maintainerPATCH 555/634 wifi: mt76: mt7615: check devm_kasprintf() returned value
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit 5acdc432f832d810e0d638164c393b877291d9b4 upstream.
devm_kasprintf() can return a NULL pointer on failure but this returned value is not checked. Fix this lack and check the returned value.
Found by code review.
--- drivers/net/wireless/mediatek/mt76/mt7615/init.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7615/init.c +3 -0
@@ -56,6 +56,9 @@ int mt7615_thermal_init(struct mt7615_de name =devm_kasprintf (&wiphy->dev,GFP_KERNEL ,"mt7615_%s" ,wiphy_name (wiphy)); +if (!name) +return -ENOMEM ; + hwmon =devm_hwmon_device_register_with_groups (&wiphy->dev, name, dev, mt7615_hwmon_groups);return PTR_ERR_OR_ZERO (hwmon);
Greg Kroah-Hartman
maintainerPATCH 556/634 debugobjects: Fix conditions in fill_pool()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhen Lei <[email protected]>
commit 684d28feb8546d1e9597aa363c3bfcf52fe250b7 upstream.
fill_pool() uses 'obj_pool_min_free' to decide whether objects should be handed back to the kmem cache. But 'obj_pool_min_free' records the lowest historical value of the number of objects in the object pool and not the minimum number of objects which should be kept in the pool.
Use 'debug_objects_pool_min_level' instead, which holds the minimum number which was scaled to the number of CPUs at boot time.
[ tglx: Massage change log ]
--- lib/debugobjects.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/debugobjects.c +3 -2
@@ -142,13 +142,14 @@ static void fill_pool(void)* READ_ONCE()s pair with the WRITE_ONCE()s in pool_lock critical * sections. */ -while (READ_ONCE (obj_nr_tofree) && (READ_ONCE (obj_pool_free) < obj_pool_min_free)) { +while (READ_ONCE (obj_nr_tofree) && +READ_ONCE (obj_pool_free) < debug_objects_pool_min_level) {raw_spin_lock_irqsave (&pool_lock, flags);/* * Recheck with the lock held as the worker thread might have * won the race and freed the global free list already. */ -while (obj_nr_tofree && (obj_pool_free < obj_pool_min_free)) { +while (obj_nr_tofree && (obj_pool_free < debug_objects_pool_min_level)) { obj =hlist_entry (obj_to_free.first,typeof (*obj), node);hlist_del (&obj->node);WRITE_ONCE (obj_nr_tofree, obj_nr_tofree -1 );
Greg Kroah-Hartman
maintainerPATCH 557/634 btrfs: fix race setting file private on concurrent lseek using same fd
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 7ee85f5515e86a4e2a2f51969795920733912bad upstream.
When doing concurrent lseek(2) system calls against the same file descriptor, using multiple threads belonging to the same process, we have a short time window where a race happens and can result in a memory leak.
The race happens like this:
1) A program opens a file descriptor for a file and then spawns two threads (with the pthreads library for example), lets call them task A and task B;
2) Task A calls lseek with SEEK_DATA or SEEK_HOLE and ends up at file.c:find_desired_extent() while holding a read lock on the inode;
3) At the start of find_desired_extent(), it extracts the file's private_data pointer into a local variable named 'private', which has a value of NULL;
4) Task B also calls lseek with SEEK_DATA or SEEK_HOLE, locks the inode in shared mode and enters file.c:find_desired_extent(), where it also extracts file->private_data into its local variable 'private', which has a NULL value;
5) Because it saw a NULL file private, task A allocates a private structure and assigns to the file structure;
6) Task B also saw a NULL file private so it also allocates its own file private and then assigns it to the same file structure, since both tasks are using the same file descriptor.
At this point we leak the private structure allocated by task A.
Besides the memory leak, there's also the detail that both tasks end up using the same cached state record in the private structure (struct btrfs_file_private::llseek_cached_state), which can result in a use-after-free problem since one task can free it while the other is still using it (only one task took a reference count on it). Also, sharing the cached state is not a good idea since it could result in incorrect results in the future - right now it should not be a problem because it end ups being used only in extent-io-tree.c:count_range_bits() where we do range validation before using the cached state.
Fix this by protecting the private assignment and check of a file while holding the inode's spinlock and keep track of the task that allocated the private, so that it's used only by that task in order to prevent user-after-free issues with the cached state record as well as potentially using it incorrectly in the future.
--- fs/btrfs/btrfs_inode.h | 1 + fs/btrfs/ctree.h | 2 ++ fs/btrfs/file.c | 34 +++++++++++++++++++++++++++++++--- 3 files changed, 34 insertions(+), 3 deletions(-)
fs/btrfs/btrfs_inode.h +1 -0
@@ -126,6 +126,7 @@ struct btrfs_inode {* logged_trans), to access/update delalloc_bytes, new_delalloc_bytes, * defrag_bytes, disk_i_size, outstanding_extents, csum_bytes and to * update the VFS' inode number of bytes used. +* Also protects setting struct file::private_data. */ spinlock_t lock;
fs/btrfs/ctree.h +2 -0
@@ -457,6 +457,8 @@ struct btrfs_file_private {void *filldir_buf;u64 last_index;struct extent_state *llseek_cached_state; +/* Task that allocated this structure. */ +struct task_struct *owner_task; };static inline u32 BTRFS_LEAF_DATA_SIZE (const struct btrfs_fs_info *info)
fs/btrfs/file.c +31 -3
@@ -3689,7 +3689,7 @@ static bool find_desired_extent_in_hole(static loff_t find_desired_extent (struct file *file,loff_t offset,int whence) {struct btrfs_inode *inode =BTRFS_I (file->f_mapping->host); -struct btrfs_file_private *private = file->private_data; +struct btrfs_file_private *private;struct btrfs_fs_info *fs_info = inode->root->fs_info;struct extent_state *cached_state =NULL ;struct extent_state **delalloc_cached_state;
@@ -3717,7 +3717,19 @@ static loff_t find_desired_extent(struct inode_get_bytes(&inode->vfs_inode) == i_size)return i_size; -if (!private) { +spin_lock (&inode->lock); + private = file->private_data; +spin_unlock (&inode->lock); + +if (private && private->owner_task != current) { +/* +* Not allocated by us, don't use it as its cached state is used +* by the task that allocated it and we don't want neither to +* mess with it nor get incorrect results because it reflects an +* invalid state for the current task. +*/ + private =NULL ; + }else if (!private) { private =kzalloc (sizeof (*private),GFP_KERNEL );/* * No worries if memory allocation failed.
@@ -3725,7 +3737,23 @@ static loff_t find_desired_extent(struct* lseek SEEK_HOLE/DATA calls to a file when there's delalloc, * so everything will still be correct. */ - file->private_data = private; +if (private) { +bool free = false; + + private->owner_task = current; + +spin_lock (&inode->lock); +if (file->private_data) + free = true; +else + file->private_data = private; +spin_unlock (&inode->lock); + +if (free) { +kfree (private); + private =NULL ; + } + } }if (private)
Greg Kroah-Hartman
maintainerPATCH 558/634 btrfs: tree-checker: fix the wrong output of data backref objectid
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit b0b595e61d97de61c15b379b754b2caa90e83e5c upstream.
[BUG]
There are some reports about invalid data backref objectids, the report looks like this:
BTRFS critical (device sda): corrupt leaf: block=333654787489792 slot=110 extent bytenr=333413935558656 len=65536 invalid data ref objectid value 2543
The data ref objectid is the inode number inside the subvolume.
But in above case, the value is completely sane, not really showing the problem.
[CAUSE]
The root cause of the problem is the deprecated feature, inode cache.
This feature results a special inode number, -12ULL, and it's no longer recognized by tree-checker, triggering the error.
The direct problem here is the output of data ref objectid. The value shown is in fact the dref_root (subvolume id), not the dref_objectid (inode number).
[FIX]
Fix the output to use dref_objectid instead.
--- fs/btrfs/tree-checker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tree-checker.c +1 -1
@@ -1499,7 +1499,7 @@ static int check_extent_item(struct exte dref_objectid > BTRFS_LAST_FREE_OBJECTID)) {extent_err (leaf, slot,"invalid data ref objectid value %llu" , - dref_root); + dref_objectid);return -EUCLEAN ; } if (unlikely(!IS_ALIGNED(dref_offset,
Greg Kroah-Hartman
maintainerPATCH 559/634 btrfs: always update fstrim_range on failure in FITRIM ioctl
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Stefani <[email protected]>
commit 3368597206dc3c6c3c2247ee146beada14c67380 upstream.
Even in case of failure we could've discarded some data and userspace should be made aware of it, so copy fstrim_range to userspace regardless.
Also make sure to update the trimmed bytes amount even if btrfs_trim_free_extents fails.
--- fs/btrfs/extent-tree.c | 4 ++-- fs/btrfs/ioctl.c | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-)
fs/btrfs/extent-tree.c +2 -2
@@ -6426,13 +6426,13 @@ int btrfs_trim_fs(struct btrfs_fs_info *continue ; ret =btrfs_trim_free_extents (device, &group_trimmed); + + trimmed += group_trimmed;if (ret) { dev_failed++; dev_ret = ret;break ; } - - trimmed += group_trimmed; }mutex_unlock (&fs_devices->device_list_mutex);
fs/btrfs/ioctl.c +1 -3
@@ -543,13 +543,11 @@ static noinline int btrfs_ioctl_fitrim(s range.minlen =max (range.minlen, minlen); ret =btrfs_trim_fs (fs_info, &range); -if (ret <0 ) -return ret;if (copy_to_user (arg, &range,sizeof (range)))return -EFAULT ; -return 0 ; +return ret; }int __pure btrfs_is_empty_uuid (u8 *uuid)
Greg Kroah-Hartman
maintainerPATCH 560/634 f2fs: fix several potential integer overflows in file offsets
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikita Zhandarovich <[email protected]>
commit 1cade98cf6415897bf9342ee451cc5b40b58c638 upstream.
When dealing with large extents and calculating file offsets by summing up according extent offsets and lengths of unsigned int type, one may encounter possible integer overflow if the values are big enough.
Prevent this from happening by expanding one of the addends to (pgoff_t) type.
Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE.
--- fs/f2fs/extent_cache.c | 4 ++-- fs/f2fs/file.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
fs/f2fs/extent_cache.c +2 -2
@@ -366,7 +366,7 @@ static unsigned int __free_extent_tree(sstatic void __drop_largest_extent (struct extent_tree *et,pgoff_t fofs,unsigned int len) { -if (fofs < et->largest.fofs + et->largest.len && +if (fofs < (pgoff_t )et->largest.fofs + et->largest.len && fofs + len > et->largest.fofs) { et->largest.len =0 ; et->largest_updated = true;
@@ -456,7 +456,7 @@ static bool __lookup_extent_tree(structif (type ==EX_READ && et->largest.fofs <= pgofs && - et->largest.fofs + et->largest.len > pgofs) { + (pgoff_t )et->largest.fofs + et->largest.len > pgofs) { *ei = et->largest; ret = true;stat_inc_largest_node_hit (sbi);
fs/f2fs/file.c +1 -1
@@ -2719,7 +2719,7 @@ static int f2fs_defragment_range(struct* block addresses are continuous. */ if (f2fs_lookup_read_extent_cache (inode, pg_start, &ei)) { -if (ei.fofs + ei.len >= pg_end) +if ((pgoff_t )ei.fofs + ei.len >= pg_end) goto out; }
Greg Kroah-Hartman
maintainerPATCH 561/634 f2fs: prevent possible int overflow in dir_block_index()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikita Zhandarovich <[email protected]>
commit 47f268f33dff4a5e31541a990dc09f116f80e61c upstream.
The result of multiplication between values derived from functions dir_buckets() and bucket_blocks() *could* technically reach 2^30 * 2^2 = 2^32.
While unlikely to happen, it is prudent to ensure that it will not lead to integer overflow. Thus, use mul_u32_u32() as it's more appropriate to mitigate the issue.
Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE.
--- fs/f2fs/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/dir.c +2 -1
@@ -157,7 +157,8 @@ static unsigned long dir_block_index(unsunsigned long bidx =0 ;for (i =0 ; i < level; i++) - bidx +=dir_buckets (i, dir_level) *bucket_blocks (i); + bidx +=mul_u32_u32 (dir_buckets (i, dir_level), +bucket_blocks (i)); bidx += idx *bucket_blocks (level);return bidx; }
Greg Kroah-Hartman
maintainerPATCH 562/634 f2fs: avoid potential int overflow in sanity_check_area_boundary()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikita Zhandarovich <[email protected]>
commit 50438dbc483ca6a133d2bce9d5d6747bcee38371 upstream.
While calculating the end addresses of main area and segment 0, u32 may be not enough to hold the result without the danger of int overflow.
Just in case, play it safe and cast one of the operands to a wider type (u64).
Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE.
--- fs/f2fs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/super.c +2 -2
@@ -3366,9 +3366,9 @@ static inline bool sanity_check_area_bouu32 segment_count =le32_to_cpu (raw_super->segment_count);u32 log_blocks_per_seg =le32_to_cpu (raw_super->log_blocks_per_seg);u64 main_end_blkaddr = main_blkaddr + - (segment_count_main << log_blocks_per_seg); + ((u64 )segment_count_main << log_blocks_per_seg);u64 seg_end_blkaddr = segment0_blkaddr + - (segment_count << log_blocks_per_seg); + ((u64 )segment_count << log_blocks_per_seg);if (segment0_blkaddr != cp_blkaddr) { f2fs_info(sbi, "Mismatch start address, segment0(%u) cp_blkaddr(%u)",
Greg Kroah-Hartman
maintainerPATCH 563/634 f2fs: Require FMODE_WRITE for atomic write ioctls
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit 4f5a100f87f32cb65d4bb1ad282a08c92f6f591e upstream.
The F2FS ioctls for starting and committing atomic writes check for inode_owner_or_capable(), but this does not give LSMs like SELinux or Landlock an opportunity to deny the write access - if the caller's FSUID matches the inode's UID, inode_owner_or_capable() immediately returns true.
There are scenarios where LSMs want to deny a process the ability to write particular files, even files that the FSUID of the process owns; but this can currently partially be bypassed using atomic write ioctls in two ways:
- F2FS_IOC_START_ATOMIC_REPLACE + F2FS_IOC_COMMIT_ATOMIC_WRITE can truncate an inode to size 0
- F2FS_IOC_START_ATOMIC_WRITE + F2FS_IOC_ABORT_ATOMIC_WRITE can revert changes another process concurrently made to a file
Fix it by requiring FMODE_WRITE for these operations, just like for F2FS_IOC_MOVE_RANGE. Since any legitimate caller should only be using these ioctls when intending to write into the file, that seems unlikely to break anything.
--- fs/f2fs/file.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/f2fs/file.c +9 -0
@@ -2123,6 +2123,9 @@ static int f2fs_ioc_start_atomic_write(sloff_t isize;int ret; +if (!(filp->f_mode &FMODE_WRITE )) +return -EBADF ; +if (!inode_owner_or_capable (idmap, inode))return -EACCES ;
@@ -2230,6 +2233,9 @@ static int f2fs_ioc_commit_atomic_write(struct mnt_idmap *idmap =file_mnt_idmap (filp);int ret; +if (!(filp->f_mode &FMODE_WRITE )) +return -EBADF ; +if (!inode_owner_or_capable (idmap, inode))return -EACCES ;
@@ -2262,6 +2268,9 @@ static int f2fs_ioc_abort_atomic_write(sstruct mnt_idmap *idmap =file_mnt_idmap (filp);int ret; +if (!(filp->f_mode &FMODE_WRITE )) +return -EBADF ; +if (!inode_owner_or_capable (idmap, inode))return -EACCES ;