6.1.142-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 149/508 nfs: ignore SB_RDONLY when remounting nfs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Lingfeng <[email protected]>
[ Upstream commit 80c4de6ab44c14e910117a02f2f8241ffc6ec54a ]
In some scenarios, when mounting NFS, more than one superblock may be created. The final superblock used is the last one created, but only the first superblock carries the ro flag passed from user space. If a ro flag is added to the superblock via remount, it will trigger the issue described in Link[1].
Link[2] attempted to address this by marking the superblock as ro during the initial mount. However, this introduced a new problem in scenarios where multiple mount points share the same superblock:
[root@a ~]# mount /dev/sdb /mnt/sdb
[root@a ~]# echo "/mnt/sdb *(rw,no_root_squash)" > /etc/exports [root@a ~]# echo "/mnt/sdb/test_dir2 *(ro,no_root_squash)" >> /etc/exports [root@a ~]# systemctl restart nfs-server
[root@a ~]# mount -t nfs -o rw 127.0.0.1:/mnt/sdb/test_dir1 /mnt/test_mp1 [root@a ~]# mount | grep nfs4
127.0.0.1:/mnt/sdb/test_dir1 on /mnt/test_mp1 type nfs4 (rw,relatime,... [root@a ~]# mount -t nfs -o ro 127.0.0.1:/mnt/sdb/test_dir2 /mnt/test_mp2 [root@a ~]# mount | grep nfs4
127.0.0.1:/mnt/sdb/test_dir1 on /mnt/test_mp1 type nfs4 (ro,relatime,... 127.0.0.1:/mnt/sdb/test_dir2 on /mnt/test_mp2 type nfs4 (ro,relatime,... [root@a ~]#
When mounting the second NFS, the shared superblock is marked as ro, causing the previous NFS mount to become read-only.
To resolve both issues, the ro flag is no longer applied to the superblock during remount. Instead, the ro flag on the mount is used to control whether the mount point is read-only.
Link[1]: https://lore.kernel.org/all/[email protected]/
Link[2]: https://lore.kernel.org/all/[email protected]/
--- fs/nfs/super.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/nfs/super.c +10 -0
@@ -1017,6 +1017,16 @@ int nfs_reconfigure(struct fs_context *fc)sync_filesystem (sb); +/* +* The SB_RDONLY flag has been removed from the superblock during +* mounts to prevent interference between different filesystems. +* Similarly, it is also necessary to ignore the SB_RDONLY flag +* during reconfiguration; otherwise, it may also result in the +* creation of redundant superblocks when mounting a directory with +* different rw and ro flags multiple times. +*/ + fc->sb_flags_mask &= ~SB_RDONLY ; +/* * Userspace mount programs that send binary options generally send * them populated with default values. We have no way to know which
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 150/508 rtc: sh: assign correct interrupts with DT
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit 8f2efdbc303fe7baa83843d3290dd6ea5ba3276c ]
The DT bindings for this driver define the interrupts in the order as they are numbered in the interrupt controller. The old platform_data, however, listed them in a different order. So, for DT based platforms, they are mixed up. Assign them specifically for DT, so we can keep the bindings stable. After the fix, 'rtctest' passes again on the Renesas Genmai board (RZ-A1 / R7S72100).
--- drivers/rtc/rtc-sh.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/rtc/rtc-sh.c +9 -3
@@ -485,9 +485,15 @@ static int __init sh_rtc_probe(struct platform_device *pdev)return -ENOENT ; } - rtc->periodic_irq = ret; - rtc->carry_irq =platform_get_irq (pdev,1 ); - rtc->alarm_irq =platform_get_irq (pdev,2 ); +if (!pdev->dev.of_node) { + rtc->periodic_irq = ret; + rtc->carry_irq =platform_get_irq (pdev,1 ); + rtc->alarm_irq =platform_get_irq (pdev,2 ); + }else { + rtc->alarm_irq = ret; + rtc->periodic_irq =platform_get_irq (pdev,1 ); + rtc->carry_irq =platform_get_irq (pdev,2 ); + } res =platform_get_resource (pdev,IORESOURCE_IO ,0 );if (!res)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 151/508 PCI: cadence: Fix runtime atomic count underflow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Zhang <[email protected]>
[ Upstream commit 8805f32a96d3b97cef07999fa6f52112678f7e65 ]
If the call to pci_host_probe() in cdns_pcie_host_setup() fails, PM runtime count is decremented in the error path using pm_runtime_put_sync(). But the runtime count is not incremented by this driver, but only by the callers (cdns_plat_pcie_probe/j721e_pcie_probe). And the callers also decrement the runtime PM count in their error path. So this leads to the below warning from the PM core:
"runtime PM usage count underflow!"
So fix it by getting rid of pm_runtime_put_sync() in the error path and directly return the errno.
--- drivers/pci/controller/cadence/pcie-cadence-host.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-host.c +1 -10
@@ -558,14 +558,5 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)if (!bridge->ops) bridge->ops = &cdns_pcie_host_ops; - ret =pci_host_probe (bridge); -if (ret <0 ) - goto err_init; - -return 0 ; - - err_init: -pm_runtime_put_sync (dev); - -return ret; +return pci_host_probe (bridge); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 152/508 PCI: apple: Use gpiod_set_value_cansleep in probe flow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hector Martin <[email protected]>
[ Upstream commit 7334364f9de79a9a236dd0243ba574b8d2876e89 ]
We're allowed to sleep here, so tell the GPIO core by using gpiod_set_value_cansleep instead of gpiod_set_value.
--- drivers/pci/controller/pcie-apple.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-apple.c +2 -2
@@ -541,7 +541,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,rmw_set (PORT_APPCLK_EN , port->base +PORT_APPCLK );/* Assert PERST# before setting up the clock */ -gpiod_set_value (reset,1 ); +gpiod_set_value_cansleep (reset,1 ); ret =apple_pcie_setup_refclk (pcie, port);if (ret <0 )
@@ -552,7 +552,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,/* Deassert PERST# */ rmw_set (PORT_PERST_OFF , port->base +PORT_PERST ); -gpiod_set_value (reset,0 ); +gpiod_set_value_cansleep (reset,0 );/* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */ msleep (100 );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 153/508 phy: qcom-qmp-usb: Fix an NULL vs IS_ERR() bug
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chenyuan Yang <[email protected]>
[ Upstream commit d14402a38c2d868cacb1facaf9be908ca6558e59 ]
The qmp_usb_iomap() helper function currently returns the raw result of devm_ioremap() for non-exclusive mappings. Since devm_ioremap() may return a NULL pointer and the caller only checks error pointers with IS_ERR(), NULL could bypass the check and lead to an invalid dereference.
Fix the issue by checking if devm_ioremap() returns NULL. When it does, qmp_usb_iomap() now returns an error pointer via IOMEM_ERR_PTR(-ENOMEM), ensuring safe and consistent error handling.
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +5 -1
@@ -2428,12 +2428,16 @@ static void __iomem *qmp_usb_iomap(struct device *dev, struct device_node *np, int index, bool exclusive) {struct resource res; +void __iomem *mem;if (!exclusive) {if (of_address_to_resource (np, index, &res))return IOMEM_ERR_PTR (-EINVAL ); -return devm_ioremap (dev, res.start,resource_size (&res)); + mem =devm_ioremap (dev, res.start,resource_size (&res)); +if (!mem) +return IOMEM_ERR_PTR (-ENOMEM ); +return mem; }return devm_of_iomap (dev, np, index,NULL );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 154/508 dmaengine: ti: Add NULL check in udma_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit fd447415e74bccd7362f760d4ea727f8e1ebfe91 ]
devm_kasprintf() returns NULL when memory allocation fails. Currently, udma_probe() does not check for this case, which results in a NULL pointer dereference.
Add NULL check after devm_kasprintf() to prevent this issue.
--- drivers/dma/ti/k3-udma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/dma/ti/k3-udma.c +2 -1
@@ -5490,7 +5490,8 @@ static int udma_probe(struct platform_device *pdev) uc->config.dir =DMA_MEM_TO_MEM ; uc->name =devm_kasprintf (dev,GFP_KERNEL ,"%s chan%d" ,dev_name (dev), i); - +if (!uc->name) +return -ENOMEM ;vchan_init (&uc->vc, &ud->ddev);/* Use custom vchan completion handling */ tasklet_setup (&uc->vc.task, udma_vchan_complete);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 155/508 PCI/DPC: Initialize aer_err_info before using it
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Helgaas <[email protected]>
[ Upstream commit a424b598e6a6c1e69a2bb801d6fd16e805ab2c38 ]
Previously the struct aer_err_info "info" was allocated on the stack without being initialized, so it contained junk except for the fields we explicitly set later.
Initialize "info" at declaration so it starts as all zeros.
--- drivers/pci/pcie/dpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pcie/dpc.c +1 -1
@@ -263,7 +263,7 @@ static int dpc_get_aer_uncorrect_severity(struct pci_dev *dev,void dpc_process_error (struct pci_dev *pdev) {u16 cap = pdev->dpc_cap, status, source, reason, ext_reason; -struct aer_err_info info; +struct aer_err_info info = {};pci_read_config_word (pdev, cap +PCI_EXP_DPC_STATUS , &status);pci_read_config_word (pdev, cap +PCI_EXP_DPC_SOURCE_ID , &source);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 156/508 usb: renesas_usbhs: Reorder clock handling and power management in probe
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lad Prabhakar <[email protected]>
[ Upstream commit ffb34a60ce86656ba12d46e91f1ccc71dd221251 ]
Reorder the initialization sequence in usbhs_probe() to enable runtime PM before accessing registers, preventing potential crashes due to uninitialized clocks.
Currently, in the probe path, registers are accessed before enabling the clocks, leading to a synchronous external abort on the RZ/V2H SoC. The problematic call flow is as follows:
usbhs_probe()
usbhs_sys_clock_ctrl()
usbhs_bset()
usbhs_write()
iowrite16() <-- Register access before enabling clocks
Since iowrite16() is performed without ensuring the required clocks are enabled, this can lead to access errors. To fix this, enable PM runtime early in the probe function and ensure clocks are acquired before register access, preventing crashes like the following on RZ/V2H:
[13.272640] Internal error: synchronous external abort: 0000000096000010 [#1] PREEMPT SMP [13.280814] Modules linked in: cec renesas_usbhs(+) drm_kms_helper fuse drm backlight ipv6 [13.289088] CPU: 1 UID: 0 PID: 195 Comm: (udev-worker) Not tainted 6.14.0-rc7+ #98 [13.296640] Hardware name: Renesas RZ/V2H EVK Board based on r9a09g057h44 (DT) [13.303834] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [13.310770] pc : usbhs_bset+0x14/0x4c [renesas_usbhs] [13.315831] lr : usbhs_probe+0x2e4/0x5ac [renesas_usbhs] [13.321138] sp : ffff8000827e3850 [13.324438] x29: ffff8000827e3860 x28: 0000000000000000 x27: ffff8000827e3ca0 [13.331554] x26: ffff8000827e3ba0 x25: ffff800081729668 x24: 0000000000000025 [13.338670] x23: ffff0000c0f08000 x22: 0000000000000000 x21: ffff0000c0f08010 [13.345783] x20: 0000000000000000 x19: ffff0000c3b52080 x18: 00000000ffffffff [13.352895] x17: 0000000000000000 x16: 0000000000000000 x15: ffff8000827e36ce [13.360009] x14: 00000000000003d7 x13: 00000000000003d7 x12: 0000000000000000 [13.367122] x11: 0000000000000000 x10: 0000000000000aa0 x9 : ffff8000827e3750 [13.374235] x8 : ffff0000c1850b00 x7 : 0000000003826060 x6 : 000000000000001c [13.381347] x5 : 000000030d5fcc00 x4 : ffff8000825c0000 x3 : 0000000000000000 [13.388459] x2 : 0000000000000400 x1 : 0000000000000000 x0 : ffff0000c3b52080 [13.395574] Call trace: [13.398013] usbhs_bset+0x14/0x4c [renesas_usbhs] (P) [13.403076] platform_probe+0x68/0xdc [13.406738] really_probe+0xbc/0x2c0 [13.410306] __driver_probe_device+0x78/0x120 [13.414653] driver_probe_device+0x3c/0x154 [13.418825] __driver_attach+0x90/0x1a0 [13.422647] bus_for_each_dev+0x7c/0xe0 [13.426470] driver_attach+0x24/0x30 [13.430032] bus_add_driver+0xe4/0x208 [13.433766] driver_register+0x68/0x130 [13.437587] __platform_driver_register+0x24/0x30 [13.442273] renesas_usbhs_driver_init+0x20/0x1000 [renesas_usbhs] [13.448450] do_one_initcall+0x60/0x1d4 [13.452276] do_init_module+0x54/0x1f8 [13.456014] load_module+0x1754/0x1c98 [13.459750] init_module_from_file+0x88/0xcc [13.464004] __arm64_sys_finit_module+0x1c4/0x328 [13.468689] invoke_syscall+0x48/0x104 [13.472426] el0_svc_common.constprop.0+0xc0/0xe0 [13.477113] do_el0_svc+0x1c/0x28 [13.480415] el0_svc+0x30/0xcc [13.483460] el0t_64_sync_handler+0x10c/0x138 [13.487800] el0t_64_sync+0x198/0x19c [13.491453] Code: 2a0103e1 12003c42 12003c63 8b010084 (79400084) [13.497522] ---[ end trace 0000000000000000 ]---
--- drivers/usb/renesas_usbhs/common.c | 50 +++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 12 deletions(-)
drivers/usb/renesas_usbhs/common.c +38 -12
@@ -674,10 +674,29 @@ static int usbhs_probe(struct platform_device *pdev)INIT_DELAYED_WORK (&priv->notify_hotplug_work, usbhsc_notify_hotplug);spin_lock_init (usbhs_priv_to_lock (priv)); +/* +* Acquire clocks and enable power management (PM) early in the +* probe process, as the driver accesses registers during +* initialization. Ensure the device is active before proceeding. +*/ +pm_runtime_enable (dev); + + ret =usbhsc_clk_get (dev, priv); +if (ret) + goto probe_pm_disable; + + ret =pm_runtime_resume_and_get (dev); +if (ret) + goto probe_clk_put; + + ret =usbhsc_clk_prepare_enable (priv); +if (ret) + goto probe_pm_put; +/* call pipe and module init */ ret =usbhs_pipe_probe (priv);if (ret <0 ) -return ret; + goto probe_clk_dis_unprepare; ret =usbhs_fifo_probe (priv);if (ret <0 )
@@ -694,10 +713,6 @@ static int usbhs_probe(struct platform_device *pdev)if (ret) goto probe_fail_rst; - ret =usbhsc_clk_get (dev, priv); -if (ret) - goto probe_fail_clks; -/* * deviece reset here because * USB device might be used in boot loader.
@@ -710,7 +725,7 @@ static int usbhs_probe(struct platform_device *pdev)if (ret) {dev_warn (dev,"USB function not selected (GPIO)\n" ); ret = -ENOTSUPP ; - goto probe_end_mod_exit; + goto probe_assert_rest; } }
@@ -724,14 +739,19 @@ static int usbhs_probe(struct platform_device *pdev) ret =usbhs_platform_call (priv, hardware_init, pdev);if (ret <0 ) {dev_err (dev,"platform init failed.\n" ); - goto probe_end_mod_exit; + goto probe_assert_rest; }/* reset phy for connection */ usbhs_platform_call (priv, phy_reset, pdev); -/* power control */ -pm_runtime_enable (dev); +/* +* Disable the clocks that were enabled earlier in the probe path, +* and let the driver handle the clocks beyond this point. +*/ +usbhsc_clk_disable_unprepare (priv); +pm_runtime_put (dev); +if (!usbhs_get_dparam (priv, runtime_pwctrl)) {usbhsc_power_ctrl (priv,1 );usbhs_mod_autonomy_mode (priv);
@@ -748,9 +768,7 @@ static int usbhs_probe(struct platform_device *pdev)return ret; -probe_end_mod_exit: -usbhsc_clk_put (priv); -probe_fail_clks: +probe_assert_rest:reset_control_assert (priv->rsts); probe_fail_rst:usbhs_mod_remove (priv);
@@ -758,6 +776,14 @@ static int usbhs_probe(struct platform_device *pdev)usbhs_fifo_remove (priv); probe_end_pipe_exit:usbhs_pipe_remove (priv); +probe_clk_dis_unprepare: +usbhsc_clk_disable_unprepare (priv); +probe_pm_put: +pm_runtime_put (dev); +probe_clk_put: +usbhsc_clk_put (priv); +probe_pm_disable: +pm_runtime_disable (dev);dev_info (dev,"probe failed (%d)\n" , ret);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 157/508 serial: Fix potential null-ptr-deref in mlb_usio_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit 86bcae88c9209e334b2f8c252f4cc66beb261886 ]
devm_ioremap() can return NULL on error. Currently, mlb_usio_probe() does not check for this case, which could result in a NULL pointer dereference.
Add NULL check after devm_ioremap() to prevent this issue.
--- drivers/tty/serial/milbeaut_usio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/tty/serial/milbeaut_usio.c +4 -1
@@ -524,7 +524,10 @@ static int mlb_usio_probe(struct platform_device *pdev) } port->membase =devm_ioremap (&pdev->dev, res->start,resource_size (res)); - +if (!port->membase) { + ret = -ENOMEM ; + goto failed; + } ret =platform_get_irq_byname (pdev,"rx" ); mlb_usio_irq[index][RX ] = ret;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 158/508 iio: filter: admv8818: fix band 4, state 15
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sam Winchenbach <[email protected]>
[ Upstream commit ef0ce24f590ac075d5eda11f2d6434b303333ed6 ]
Corrects the upper range of LPF Band 4 from 18.5 GHz to 18.85 GHz per the ADMV8818 datasheet
--- drivers/iio/filter/admv8818.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/filter/admv8818.c +1 -1
@@ -102,7 +102,7 @@ static const unsigned long long freq_range_lpf[4][2] = { {2050000000ULL, 3850000000ULL}, {3350000000ULL, 7250000000ULL}, {7000000000, 13000000000}, - {12550000000, 18500000000} + {12550000000, 18850000000} };static const struct regmap_config admv8818_regmap_config = {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 159/508 iio: filter: admv8818: fix integer overflow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sam Winchenbach <[email protected]>
[ Upstream commit fb6009a28d77edec4eb548b5875dae8c79b88467 ]
HZ_PER_MHZ is only unsigned long. This math overflows, leading to incorrect results.
--- drivers/iio/filter/admv8818.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/filter/admv8818.c +1 -1
@@ -152,7 +152,7 @@ static int __admv8818_hpf_select(struct admv8818_state *st, u64 freq) }/* Close HPF frequency gap between 12 and 12.5 GHz */ -if (freq >=12000 *HZ_PER_MHZ && freq <=12500 *HZ_PER_MHZ ) { +if (freq >=12000ULL *HZ_PER_MHZ && freq <12500ULL *HZ_PER_MHZ ) { hpf_band =3 ; hpf_step =15 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 160/508 iio: filter: admv8818: fix range calculation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sam Winchenbach <[email protected]>
[ Upstream commit d542db7095d322bfcdc8e306db6f8c48358c9619 ]
Search for the minimum error while ensuring that the LPF corner frequency is greater than the target, and the HPF corner frequency is lower than the target
This fixes issues where the range calculations were suboptimal.
Add two new DTS properties to set the margin between the input frequency and the calculated corner frequency
Below is a generated table of the differences between the old algorithm and the new. This is a sweep from 0 to 20 GHz in 10 MHz steps. === HPF ===
freq = 1750 MHz, 3db: bypass => 1750 MHz
freq = 3400 MHz, 3db: 3310 => 3400 MHz
freq = 3410 MHz, 3db: 3310 => 3400 MHz
freq = 3420 MHz, 3db: 3310 => 3400 MHz
freq = 3660 MHz, 3db: 3550 => 3656 MHz
freq = 6600 MHz, 3db: 6479 => 6600 MHz
freq = 6610 MHz, 3db: 6479 => 6600 MHz
freq = 6620 MHz, 3db: 6479 => 6600 MHz
freq = 6630 MHz, 3db: 6479 => 6600 MHz
freq = 6640 MHz, 3db: 6479 => 6600 MHz
freq = 6650 MHz, 3db: 6479 => 6600 MHz
freq = 6660 MHz, 3db: 6479 => 6600 MHz
freq = 6670 MHz, 3db: 6479 => 6600 MHz
freq = 6680 MHz, 3db: 6479 => 6600 MHz
freq = 6690 MHz, 3db: 6479 => 6600 MHz
freq = 6700 MHz, 3db: 6479 => 6600 MHz
freq = 6710 MHz, 3db: 6479 => 6600 MHz
freq = 6720 MHz, 3db: 6479 => 6600 MHz
freq = 6730 MHz, 3db: 6479 => 6600 MHz
freq = 6960 MHz, 3db: 6736 => 6960 MHz
freq = 6970 MHz, 3db: 6736 => 6960 MHz
freq = 6980 MHz, 3db: 6736 => 6960 MHz
freq = 6990 MHz, 3db: 6736 => 6960 MHz
freq = 7320 MHz, 3db: 7249 => 7320 MHz
freq = 7330 MHz, 3db: 7249 => 7320 MHz
freq = 7340 MHz, 3db: 7249 => 7320 MHz
freq = 7350 MHz, 3db: 7249 => 7320 MHz
freq = 7360 MHz, 3db: 7249 => 7320 MHz
freq = 7370 MHz, 3db: 7249 => 7320 MHz
freq = 7380 MHz, 3db: 7249 => 7320 MHz
freq = 7390 MHz, 3db: 7249 => 7320 MHz
freq = 7400 MHz, 3db: 7249 => 7320 MHz
freq = 7410 MHz, 3db: 7249 => 7320 MHz
freq = 7420 MHz, 3db: 7249 => 7320 MHz
freq = 7430 MHz, 3db: 7249 => 7320 MHz
freq = 7440 MHz, 3db: 7249 => 7320 MHz
freq = 7450 MHz, 3db: 7249 => 7320 MHz
freq = 7460 MHz, 3db: 7249 => 7320 MHz
freq = 7470 MHz, 3db: 7249 => 7320 MHz
freq = 7480 MHz, 3db: 7249 => 7320 MHz
freq = 7490 MHz, 3db: 7249 => 7320 MHz
freq = 7500 MHz, 3db: 7249 => 7320 MHz
freq = 12500 MHz, 3db: 12000 => 12500 MHz
=== LPF ===
freq = 2050 MHz, 3db: bypass => 2050 MHz freq = 2170 MHz, 3db: 2290 => 2170 MHz freq = 2290 MHz, 3db: 2410 => 2290 MHz freq = 2410 MHz, 3db: 2530 => 2410 MHz freq = 2530 MHz, 3db: 2650 => 2530 MHz freq = 2650 MHz, 3db: 2770 => 2650 MHz freq = 2770 MHz, 3db: 2890 => 2770 MHz freq = 2890 MHz, 3db: 3010 => 2890 MHz freq = 3010 MHz, 3db: 3130 => 3010 MHz freq = 3130 MHz, 3db: 3250 => 3130 MHz freq = 3250 MHz, 3db: 3370 => 3250 MHz freq = 3260 MHz, 3db: 3370 => 3350 MHz freq = 3270 MHz, 3db: 3370 => 3350 MHz freq = 3280 MHz, 3db: 3370 => 3350 MHz freq = 3290 MHz, 3db: 3370 => 3350 MHz freq = 3300 MHz, 3db: 3370 => 3350 MHz freq = 3310 MHz, 3db: 3370 => 3350 MHz freq = 3320 MHz, 3db: 3370 => 3350 MHz freq = 3330 MHz, 3db: 3370 => 3350 MHz freq = 3340 MHz, 3db: 3370 => 3350 MHz freq = 3350 MHz, 3db: 3370 => 3350 MHz freq = 3370 MHz, 3db: 3490 => 3370 MHz freq = 3490 MHz, 3db: 3610 => 3490 MHz freq = 3610 MHz, 3db: 3730 => 3610 MHz freq = 3730 MHz, 3db: 3850 => 3730 MHz freq = 3850 MHz, 3db: 3870 => 3850 MHz freq = 3870 MHz, 3db: 4130 => 3870 MHz freq = 4130 MHz, 3db: 4390 => 4130 MHz freq = 4390 MHz, 3db: 4650 => 4390 MHz freq = 4650 MHz, 3db: 4910 => 4650 MHz freq = 4910 MHz, 3db: 5170 => 4910 MHz freq = 5170 MHz, 3db: 5430 => 5170 MHz freq = 5430 MHz, 3db: 5690 => 5430 MHz freq = 5690 MHz, 3db: 5950 => 5690 MHz freq = 5950 MHz, 3db: 6210 => 5950 MHz freq = 6210 MHz, 3db: 6470 => 6210 MHz freq = 6470 MHz, 3db: 6730 => 6470 MHz freq = 6730 MHz, 3db: 6990 => 6730 MHz freq = 6990 MHz, 3db: 7250 => 6990 MHz freq = 7000 MHz, 3db: 7250 => 7000 MHz freq = 7250 MHz, 3db: 7400 => 7250 MHz freq = 7400 MHz, 3db: 7800 => 7400 MHz freq = 7800 MHz, 3db: 8200 => 7800 MHz freq = 8200 MHz, 3db: 8600 => 8200 MHz freq = 8600 MHz, 3db: 9000 => 8600 MHz freq = 9000 MHz, 3db: 9400 => 9000 MHz freq = 9400 MHz, 3db: 9800 => 9400 MHz freq = 9800 MHz, 3db: 10200 => 9800 MHz freq = 10200 MHz, 3db: 10600 => 10200 MHz freq = 10600 MHz, 3db: 11000 => 10600 MHz freq = 11000 MHz, 3db: 11400 => 11000 MHz freq = 11400 MHz, 3db: 11800 => 11400 MHz freq = 11800 MHz, 3db: 12200 => 11800 MHz freq = 12200 MHz, 3db: 12600 => 12200 MHz freq = 12210 MHz, 3db: 12600 => 12550 MHz freq = 12220 MHz, 3db: 12600 => 12550 MHz freq = 12230 MHz, 3db: 12600 => 12550 MHz freq = 12240 MHz, 3db: 12600 => 12550 MHz freq = 12250 MHz, 3db: 12600 => 12550 MHz freq = 12260 MHz, 3db: 12600 => 12550 MHz freq = 12270 MHz, 3db: 12600 => 12550 MHz freq = 12280 MHz, 3db: 12600 => 12550 MHz freq = 12290 MHz, 3db: 12600 => 12550 MHz freq = 12300 MHz, 3db: 12600 => 12550 MHz freq = 12310 MHz, 3db: 12600 => 12550 MHz freq = 12320 MHz, 3db: 12600 => 12550 MHz freq = 12330 MHz, 3db: 12600 => 12550 MHz freq = 12340 MHz, 3db: 12600 => 12550 MHz freq = 12350 MHz, 3db: 12600 => 12550 MHz freq = 12360 MHz, 3db: 12600 => 12550 MHz freq = 12370 MHz, 3db: 12600 => 12550 MHz freq = 12380 MHz, 3db: 12600 => 12550 MHz freq = 12390 MHz, 3db: 12600 => 12550 MHz freq = 12400 MHz, 3db: 12600 => 12550 MHz freq = 12410 MHz, 3db: 12600 => 12550 MHz freq = 12420 MHz, 3db: 12600 => 12550 MHz freq = 12430 MHz, 3db: 12600 => 12550 MHz freq = 12440 MHz, 3db: 12600 => 12550 MHz freq = 12450 MHz, 3db: 12600 => 12550 MHz freq = 12460 MHz, 3db: 12600 => 12550 MHz freq = 12470 MHz, 3db: 12600 => 12550 MHz freq = 12480 MHz, 3db: 12600 => 12550 MHz freq = 12490 MHz, 3db: 12600 => 12550 MHz freq = 12500 MHz, 3db: 12600 => 12550 MHz freq = 12510 MHz, 3db: 12600 => 12550 MHz freq = 12520 MHz, 3db: 12600 => 12550 MHz freq = 12530 MHz, 3db: 12600 => 12550 MHz freq = 12540 MHz, 3db: 12600 => 12550 MHz freq = 12550 MHz, 3db: 12600 => 12550 MHz freq = 12600 MHz, 3db: 13000 => 12600 MHz freq = 12610 MHz, 3db: 13000 => 12970 MHz freq = 12620 MHz, 3db: 13000 => 12970 MHz freq = 12630 MHz, 3db: 13000 => 12970 MHz freq = 12640 MHz, 3db: 13000 => 12970 MHz freq = 12650 MHz, 3db: 13000 => 12970 MHz freq = 12660 MHz, 3db: 13000 => 12970 MHz freq = 12670 MHz, 3db: 13000 => 12970 MHz freq = 12680 MHz, 3db: 13000 => 12970 MHz freq = 12690 MHz, 3db: 13000 => 12970 MHz freq = 12700 MHz, 3db: 13000 => 12970 MHz freq = 12710 MHz, 3db: 13000 => 12970 MHz freq = 12720 MHz, 3db: 13000 => 12970 MHz freq = 12730 MHz, 3db: 13000 => 12970 MHz freq = 12740 MHz, 3db: 13000 => 12970 MHz freq = 12750 MHz, 3db: 13000 => 12970 MHz freq = 12760 MHz, 3db: 13000 => 12970 MHz freq = 12770 MHz, 3db: 13000 => 12970 MHz freq = 12780 MHz, 3db: 13000 => 12970 MHz freq = 12790 MHz, 3db: 13000 => 12970 MHz freq = 12800 MHz, 3db: 13000 => 12970 MHz freq = 12810 MHz, 3db: 13000 => 12970 MHz freq = 12820 MHz, 3db: 13000 => 12970 MHz freq = 12830 MHz, 3db: 13000 => 12970 MHz freq = 12840 MHz, 3db: 13000 => 12970 MHz freq = 12850 MHz, 3db: 13000 => 12970 MHz freq = 12860 MHz, 3db: 13000 => 12970 MHz freq = 12870 MHz, 3db: 13000 => 12970 MHz freq = 12880 MHz, 3db: 13000 => 12970 MHz freq = 12890 MHz, 3db: 13000 => 12970 MHz freq = 12900 MHz, 3db: 13000 => 12970 MHz freq = 12910 MHz, 3db: 13000 => 12970 MHz freq = 12920 MHz, 3db: 13000 => 12970 MHz freq = 12930 MHz, 3db: 13000 => 12970 MHz freq = 12940 MHz, 3db: 13000 => 12970 MHz freq = 12950 MHz, 3db: 13000 => 12970 MHz freq = 12960 MHz, 3db: 13000 => 12970 MHz freq = 12970 MHz, 3db: 13000 => 12970 MHz freq = 13000 MHz, 3db: 13390 => 13000 MHz freq = 13390 MHz, 3db: 13810 => 13390 MHz freq = 13810 MHz, 3db: 14230 => 13810 MHz freq = 14230 MHz, 3db: 14650 => 14230 MHz freq = 14650 MHz, 3db: 15070 => 14650 MHz freq = 15070 MHz, 3db: 15490 => 15070 MHz freq = 15490 MHz, 3db: 15910 => 15490 MHz freq = 15910 MHz, 3db: 16330 => 15910 MHz freq = 16330 MHz, 3db: 16750 => 16330 MHz freq = 16750 MHz, 3db: 17170 => 16750 MHz freq = 17170 MHz, 3db: 17590 => 17170 MHz freq = 17590 MHz, 3db: 18010 => 17590 MHz freq = 18010 MHz, 3db: 18430 => 18010 MHz freq = 18430 MHz, 3db: 18850 => 18430 MHz freq = 18850 MHz, 3db: bypass => 18850 MHz
--- drivers/iio/filter/admv8818.c | 205 +++++++++++++++++++++++++--------- 1 file changed, 152 insertions(+), 53 deletions(-)
drivers/iio/filter/admv8818.c +152 -53
@@ -14,6 +14,7 @@#include <linux/mod_devicetable.h> #include <linux/mutex.h> #include <linux/notifier.h> +#include <linux/property.h> #include <linux/regmap.h> #include <linux/spi/spi.h> #include <linux/units.h>
@@ -70,6 +71,16 @@#define ADMV8818_HPF_WR0_MSK GENMASK(7, 4)#define ADMV8818_LPF_WR0_MSK GENMASK(3, 0) +#define ADMV8818_BAND_BYPASS 0 +#define ADMV8818_BAND_MIN 1 +#define ADMV8818_BAND_MAX 4 +#define ADMV8818_BAND_CORNER_LOW 0 +#define ADMV8818_BAND_CORNER_HIGH 1 + +#define ADMV8818_STATE_MIN 0 +#define ADMV8818_STATE_MAX 15 +#define ADMV8818_NUM_STATES 16 +enum {ADMV8818_BW_FREQ ,ADMV8818_CENTER_FREQ
@@ -89,16 +100,20 @@ struct admv8818_state {struct mutex lock;unsigned int filter_mode;u64 cf_hz; +u64 lpf_margin_hz; +u64 hpf_margin_hz; }; -static const unsigned long long freq_range_hpf[4 ][2 ] = { +static const unsigned long long freq_range_hpf[5 ][2 ] = { + {0ULL ,0ULL },/* bypass */ {1750000000ULL ,3550000000ULL }, {3400000000ULL ,7250000000ULL }, {6600000000 ,12000000000 }, {12500000000 ,19900000000 } }; -static const unsigned long long freq_range_lpf[4 ][2 ] = { +static const unsigned long long freq_range_lpf[5 ][2 ] = { + {U64_MAX ,U64_MAX },/* bypass */ {2050000000ULL ,3850000000ULL }, {3350000000ULL ,7250000000ULL }, {7000000000 ,13000000000 },
@@ -119,44 +134,59 @@ static const char * const admv8818_modes[] = {static int __admv8818_hpf_select (struct admv8818_state *st,u64 freq) { -unsigned int hpf_step =0 , hpf_band =0 , i, j; -u64 freq_step; -int ret; +int band, state, ret; +unsigned int hpf_state =ADMV8818_STATE_MIN , hpf_band =ADMV8818_BAND_BYPASS ; +u64 freq_error, min_freq_error, freq_corner, freq_step; -if (freq < freq_range_hpf[0 ][0 ]) +if (freq < freq_range_hpf[ADMV8818_BAND_MIN ][ADMV8818_BAND_CORNER_LOW ]) goto hpf_write; -if (freq > freq_range_hpf[3 ][1 ]) { - hpf_step =15 ; - hpf_band =4 ; - +if (freq >= freq_range_hpf[ADMV8818_BAND_MAX ][ADMV8818_BAND_CORNER_HIGH ]) { + hpf_state =ADMV8818_STATE_MAX ; + hpf_band =ADMV8818_BAND_MAX ; goto hpf_write; } -for (i =0 ; i <4 ; i++) { - freq_step =div_u64 ((freq_range_hpf[i][1 ] - - freq_range_hpf[i][0 ]),15 ); +/* Close HPF frequency gap between 12 and 12.5 GHz */ +if (freq >=12000ULL *HZ_PER_MHZ && freq <12500ULL *HZ_PER_MHZ ) { + hpf_state =ADMV8818_STATE_MAX ; + hpf_band =3 ; + goto hpf_write; + } -if (freq > freq_range_hpf[i][0 ] && - (freq < freq_range_hpf[i][1 ] + freq_step)) { - hpf_band = i +1 ; + min_freq_error =U64_MAX ; +for (band =ADMV8818_BAND_MIN ; band <=ADMV8818_BAND_MAX ; band++) { +/* +* This (and therefore all other ranges) have a corner +* frequency higher than the target frequency. +*/ +if (freq_range_hpf[band][ADMV8818_BAND_CORNER_LOW ] > freq) +break ; -for (j =1 ; j <=16 ; j++) { -if (freq < (freq_range_hpf[i][0 ] + (freq_step * j))) { - hpf_step = j -1 ; -break ; - } + freq_step = freq_range_hpf[band][ADMV8818_BAND_CORNER_HIGH ] - + freq_range_hpf[band][ADMV8818_BAND_CORNER_LOW ]; + freq_step =div_u64 (freq_step,ADMV8818_NUM_STATES -1 ); + +for (state =ADMV8818_STATE_MIN ; state <=ADMV8818_STATE_MAX ; state++) { + freq_corner = freq_range_hpf[band][ADMV8818_BAND_CORNER_LOW ] + + freq_step * state; + +/* +* This (and therefore all other states) have a corner +* frequency higher than the target frequency. +*/ +if (freq_corner > freq) +break ; + + freq_error = freq - freq_corner; +if (freq_error < min_freq_error) { + min_freq_error = freq_error; + hpf_state = state; + hpf_band = band; } -break ; } } -/* Close HPF frequency gap between 12 and 12.5 GHz */ -if (freq >=12000ULL *HZ_PER_MHZ && freq <12500ULL *HZ_PER_MHZ ) { - hpf_band =3 ; - hpf_step =15 ; - } - hpf_write: ret = regmap_update_bits(st->regmap, ADMV8818_REG_WR0_SW, ADMV8818_SW_IN_SET_WR0_MSK |
@@ -168,7 +198,7 @@ static int __admv8818_hpf_select(struct admv8818_state *st, u64 freq)return regmap_update_bits (st->regmap,ADMV8818_REG_WR0_FILTER ,ADMV8818_HPF_WR0_MSK , -FIELD_PREP (ADMV8818_HPF_WR0_MSK , hpf_step)); +FIELD_PREP (ADMV8818_HPF_WR0_MSK , hpf_state)); }static int admv8818_hpf_select (struct admv8818_state *st,u64 freq)
@@ -184,31 +214,52 @@ static int admv8818_hpf_select(struct admv8818_state *st, u64 freq)static int __admv8818_lpf_select (struct admv8818_state *st,u64 freq) { -unsigned int lpf_step =0 , lpf_band =0 , i, j; -u64 freq_step; -int ret; +int band, state, ret; +unsigned int lpf_state =ADMV8818_STATE_MIN , lpf_band =ADMV8818_BAND_BYPASS ; +u64 freq_error, min_freq_error, freq_corner, freq_step; -if (freq > freq_range_lpf[3 ][1 ]) +if (freq > freq_range_lpf[ADMV8818_BAND_MAX ][ADMV8818_BAND_CORNER_HIGH ]) goto lpf_write; -if (freq < freq_range_lpf[0 ][0 ]) { - lpf_band =1 ; - +if (freq < freq_range_lpf[ADMV8818_BAND_MIN ][ADMV8818_BAND_CORNER_LOW ]) { + lpf_state =ADMV8818_STATE_MIN ; + lpf_band =ADMV8818_BAND_MIN ; goto lpf_write; } -for (i =0 ; i <4 ; i++) { -if (freq > freq_range_lpf[i][0 ] && freq < freq_range_lpf[i][1 ]) { - lpf_band = i +1 ; - freq_step =div_u64 ((freq_range_lpf[i][1 ] - freq_range_lpf[i][0 ]),15 ); + min_freq_error =U64_MAX ; +for (band =ADMV8818_BAND_MAX ; band >=ADMV8818_BAND_MIN ; --band) { +/* +* At this point the highest corner frequency of +* all remaining ranges is below the target. +* LPF corner should be >= the target. +*/ +if (freq > freq_range_lpf[band][ADMV8818_BAND_CORNER_HIGH ]) +break ; + + freq_step = freq_range_lpf[band][ADMV8818_BAND_CORNER_HIGH ] - + freq_range_lpf[band][ADMV8818_BAND_CORNER_LOW ]; + freq_step =div_u64 (freq_step,ADMV8818_NUM_STATES -1 ); + +for (state =ADMV8818_STATE_MAX ; state >=ADMV8818_STATE_MIN ; --state) { -for (j =0 ; j <=15 ; j++) { -if (freq < (freq_range_lpf[i][0 ] + (freq_step * j))) { - lpf_step = j; -break ; - } + freq_corner = freq_range_lpf[band][ADMV8818_BAND_CORNER_LOW ] + + state * freq_step; + +/* +* At this point all other states in range will +* place the corner frequency below the target +* LPF corner should >= the target. +*/ +if (freq > freq_corner) +break ; + + freq_error = freq_corner - freq; +if (freq_error < min_freq_error) { + min_freq_error = freq_error; + lpf_state = state; + lpf_band = band; } -break ; } }
@@ -223,7 +274,7 @@ static int __admv8818_lpf_select(struct admv8818_state *st, u64 freq)return regmap_update_bits (st->regmap,ADMV8818_REG_WR0_FILTER ,ADMV8818_LPF_WR0_MSK , -FIELD_PREP (ADMV8818_LPF_WR0_MSK , lpf_step)); +FIELD_PREP (ADMV8818_LPF_WR0_MSK , lpf_state)); }static int admv8818_lpf_select (struct admv8818_state *st,u64 freq)
@@ -240,16 +291,28 @@ static int admv8818_lpf_select(struct admv8818_state *st, u64 freq)static int admv8818_rfin_band_select (struct admv8818_state *st) {int ret; +u64 hpf_corner_target, lpf_corner_target; st->cf_hz =clk_get_rate (st->clkin); +/* Check for underflow */ +if (st->cf_hz > st->hpf_margin_hz) + hpf_corner_target = st->cf_hz - st->hpf_margin_hz; +else + hpf_corner_target =0 ; + +/* Check for overflow */ + lpf_corner_target = st->cf_hz + st->lpf_margin_hz; +if (lpf_corner_target < st->cf_hz) + lpf_corner_target =U64_MAX ; +mutex_lock (&st->lock); - ret =__admv8818_hpf_select (st, st->cf_hz); + ret =__admv8818_hpf_select (st, hpf_corner_target);if (ret) goto exit; - ret =__admv8818_lpf_select (st, st->cf_hz); + ret =__admv8818_lpf_select (st, lpf_corner_target); exit:mutex_unlock (&st->lock);return ret;
@@ -276,8 +339,11 @@ static int __admv8818_read_hpf_freq(struct admv8818_state *st, u64 *hpf_freq) hpf_state =FIELD_GET (ADMV8818_HPF_WR0_MSK , data); - *hpf_freq =div_u64 (freq_range_hpf[hpf_band -1 ][1 ] - freq_range_hpf[hpf_band -1 ][0 ],15 ); - *hpf_freq = freq_range_hpf[hpf_band -1 ][0 ] + (*hpf_freq * hpf_state); + *hpf_freq = freq_range_hpf[hpf_band][ADMV8818_BAND_CORNER_HIGH ] - + freq_range_hpf[hpf_band][ADMV8818_BAND_CORNER_LOW ]; + *hpf_freq =div_u64 (*hpf_freq,ADMV8818_NUM_STATES -1 ); + *hpf_freq = freq_range_hpf[hpf_band][ADMV8818_BAND_CORNER_LOW ] + + (*hpf_freq * hpf_state);return ret; }
@@ -314,8 +380,11 @@ static int __admv8818_read_lpf_freq(struct admv8818_state *st, u64 *lpf_freq) lpf_state =FIELD_GET (ADMV8818_LPF_WR0_MSK , data); - *lpf_freq =div_u64 (freq_range_lpf[lpf_band -1 ][1 ] - freq_range_lpf[lpf_band -1 ][0 ],15 ); - *lpf_freq = freq_range_lpf[lpf_band -1 ][0 ] + (*lpf_freq * lpf_state); + *lpf_freq = freq_range_lpf[lpf_band][ADMV8818_BAND_CORNER_HIGH ] - + freq_range_lpf[lpf_band][ADMV8818_BAND_CORNER_LOW ]; + *lpf_freq =div_u64 (*lpf_freq,ADMV8818_NUM_STATES -1 ); + *lpf_freq = freq_range_lpf[lpf_band][ADMV8818_BAND_CORNER_LOW ] + + (*lpf_freq * lpf_state);return ret; }
@@ -594,6 +663,32 @@ static int admv8818_clk_setup(struct admv8818_state *st)return devm_add_action_or_reset (&spi->dev, admv8818_clk_notifier_unreg, st); } +static int admv8818_read_properties (struct admv8818_state *st) +{ +struct spi_device *spi = st->spi; +u32 mhz; +int ret; + + ret =device_property_read_u32 (&spi->dev,"adi,lpf-margin-mhz" , &mhz); +if (ret ==0 ) + st->lpf_margin_hz = (u64 )mhz *HZ_PER_MHZ ; +else if (ret == -EINVAL ) + st->lpf_margin_hz =0 ; +else +return ret; + + + ret =device_property_read_u32 (&spi->dev,"adi,hpf-margin-mhz" , &mhz); +if (ret ==0 ) + st->hpf_margin_hz = (u64 )mhz *HZ_PER_MHZ ; +else if (ret == -EINVAL ) + st->hpf_margin_hz =0 ; +else if (ret <0 ) +return ret; + +return 0 ; +} +static int admv8818_probe (struct spi_device *spi) {struct iio_dev *indio_dev;
@@ -625,6 +720,10 @@ static int admv8818_probe(struct spi_device *spi)mutex_init (&st->lock); + ret =admv8818_read_properties (st); +if (ret) +return ret; + ret =admv8818_init (st);if (ret)return ret;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 161/508 iio: filter: admv8818: Support frequencies >= 2^32
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Pellegrino <[email protected]>
[ Upstream commit 9016776f1301627de78a633bda7c898425a56572 ]
This patch allows writing u64 values to the ADMV8818's high and low-pass filter frequencies. It includes the following changes:
- Rejects negative frequencies in admv8818_write_raw.
- Adds a write_raw_get_fmt function to admv8818's iio_info, returning IIO_VAL_INT_64 for the high and low-pass filter 3dB frequency channels.
--- drivers/iio/filter/admv8818.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/iio/filter/admv8818.c +17 -0
@@ -400,6 +400,19 @@ static int admv8818_read_lpf_freq(struct admv8818_state *st, u64 *lpf_freq)return ret; } +static int admv8818_write_raw_get_fmt (struct iio_dev *indio_dev, +struct iio_chan_spec const *chan, +long mask) +{ +switch (mask) { +case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY : +case IIO_CHAN_INFO_HIGH_PASS_FILTER_3DB_FREQUENCY : +return IIO_VAL_INT_64 ; +default : +return -EINVAL ; + } +} +static int admv8818_write_raw (struct iio_dev *indio_dev,struct iio_chan_spec const *chan,int val,int val2,long info)
@@ -408,6 +421,9 @@ static int admv8818_write_raw(struct iio_dev *indio_dev,u64 freq = ((u64 )val2 <<32 | (u32 )val); +if ((s64 )freq <0 ) +return -EINVAL ; +switch (info) {case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY :return admv8818_lpf_select (st, freq);
@@ -524,6 +540,7 @@ static int admv8818_set_mode(struct iio_dev *indio_dev,static const struct iio_info admv8818_info = { .write_raw = admv8818_write_raw, + .write_raw_get_fmt = admv8818_write_raw_get_fmt, .read_raw = admv8818_read_raw, .debugfs_reg_access = &admv8818_reg_access, };
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 162/508 iio: adc: ad7124: Fix 3dB filter frequency reading
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 8712e4986e7ce42a14c762c4c350f290989986a5 ]
The sinc4 filter has a factor 0.23 between Output Data Rate and f_{3dB} and for sinc3 the factor is 0.272 according to the data sheets for ad7124-4 (Rev. E.) and ad7124-8 (Rev. F).
--- drivers/iio/adc/ad7124.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/ad7124.c +2 -2
@@ -299,9 +299,9 @@ static int ad7124_get_3db_filter_freq(struct ad7124_state *st,switch (st->channels[channel].cfg.filter_type) {case AD7124_SINC3_FILTER : -return DIV_ROUND_CLOSEST (fadc *230 ,1000 ); +return DIV_ROUND_CLOSEST (fadc *272 ,1000 );case AD7124_SINC4_FILTER : -return DIV_ROUND_CLOSEST (fadc *262 ,1000 ); +return DIV_ROUND_CLOSEST (fadc *230 ,1000 );default :return -EINVAL ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 163/508 MIPS: Loongson64: Add missing #interrupt-cells for loongson64c_ls7a
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
[ Upstream commit 6d223b8ffcd1593d032b71875def2daa71c53111 ]
Similar to commit 98a9e2ac3755 ("MIPS: Loongson64: DTS: Fix msi node for ls7a").
Fix follow warnings:
arch/mips/boot/dts/loongson/loongson64c_4core_ls7a.dts:28.31-36.4: Warning (interrupt_provider): /bus@10000000/msi-controller@2ff00000: Missing '#interrupt-cells' in interrupt provider arch/mips/boot/dts/loongson/loongson64c_4core_ls7a.dtb: Warning (interrupt_map): Failed prerequisite 'interrupt_provider'
--- arch/mips/boot/dts/loongson/loongson64c_4core_ls7a.dts | 1 + 1 file changed, 1 insertion(+)
arch/mips/boot/dts/loongson/loongson64c_4core_ls7a.dts +1 -0
@@ -29,6 +29,7 @@ compatible = "loongson,pch-msi-1.0"; reg = <0 0x2ff00000 0 0x8>; interrupt-controller; + #interrupt-cells = <1>; msi-controller; loongson,msi-base-vec = <64>; loongson,msi-num-vecs = <64>;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 164/508 counter: interrupt-cnt: Protect enable/disable OPs with mutex
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Sverdlin <[email protected]>
[ Upstream commit 7351312632e831e51383f48957d47712fae791ef ]
Enable/disable seems to be racy on SMP, consider the following scenario:
CPU0 CPU1
interrupt_cnt_enable_write(true)
{
if (priv->enabled == enable)
return 0;
if (enable) {
priv->enabled = true;
interrupt_cnt_enable_write(false)
{
if (priv->enabled == enable)
return 0;
if (enable) {
priv->enabled = true;
enable_irq(priv->irq);
} else {
disable_irq(priv->irq)
priv->enabled = false;
}
enable_irq(priv->irq);
} else {
disable_irq(priv->irq);
priv->enabled = false;
}The above would result in priv->enabled == false, but IRQ left enabled. Protect both write (above race) and read (to propagate the value on SMP) callbacks with a mutex.
--- drivers/counter/interrupt-cnt.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/counter/interrupt-cnt.c +9 -0
@@ -3,12 +3,14 @@* Copyright (c) 2021 Pengutronix, Oleksij Rempel <[email protected]> */ +#include <linux/cleanup.h> #include <linux/counter.h> #include <linux/gpio/consumer.h> #include <linux/interrupt.h> #include <linux/irq.h> #include <linux/mod_devicetable.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/platform_device.h> #include <linux/types.h>
@@ -19,6 +21,7 @@ struct interrupt_cnt_priv {struct gpio_desc *gpio;int irq;bool enabled; +struct mutex lock;struct counter_signal signals;struct counter_synapse synapses;struct counter_count cnts;
@@ -41,6 +44,8 @@ static int interrupt_cnt_enable_read(struct counter_device *counter, {struct interrupt_cnt_priv *priv =counter_priv (counter); +guard (mutex)(&priv->lock); + *enable = priv->enabled;return 0 ;
@@ -51,6 +56,8 @@ static int interrupt_cnt_enable_write(struct counter_device *counter, {struct interrupt_cnt_priv *priv =counter_priv (counter); +guard (mutex)(&priv->lock); +if (priv->enabled == enable)return 0 ;
@@ -227,6 +234,8 @@ static int interrupt_cnt_probe(struct platform_device *pdev)if (ret)return ret; +mutex_init (&priv->lock); + ret =devm_counter_add (dev, counter);if (ret <0 )return dev_err_probe (dev, ret,"Failed to add counter\n" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 165/508 coresight: prevent deactivate active config while enabling the config
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yeoreum Yun <[email protected]>
[ Upstream commit 408c97c4a5e0b634dcd15bf8b8808b382e888164 ]
While enable active config via cscfg_csdev_enable_active_config(), active config could be deactivated via configfs' sysfs interface. This could make UAF issue in below scenario:
CPU0 CPU1
(sysfs enable) load module
cscfg_load_config_sets() activate config. // sysfs (sys_active_cnt == 1)
...cscfg_csdev_enable_active_config() lock(csdev->cscfg_csdev_lock)
// here load config activate by CPU1 unlock(csdev->cscfg_csdev_lock)
deactivate config // sysfs (sys_activec_cnt == 0) cscfg_unload_config_sets() unload module
// access to config_desc which freed
// while unloading module.cscfg_csdev_enable_config
To address this, use cscfg_config_desc's active_cnt as a reference count
which will be holded when
- activate the config.
- enable the activated config.
and put the module reference when config_active_cnt == 0.
--- .../hwtracing/coresight/coresight-config.h | 2 +- .../hwtracing/coresight/coresight-syscfg.c | 49 +++++++++++++------ 2 files changed, 35 insertions(+), 16 deletions(-)
drivers/hwtracing/coresight/coresight-config.h +1 -1
@@ -228,7 +228,7 @@ struct cscfg_feature_csdev {* @feats_csdev:references to the device features to enable. */ struct cscfg_config_csdev { -const struct cscfg_config_desc *config_desc; +struct cscfg_config_desc *config_desc;struct coresight_device *csdev;bool enabled;struct list_head node;
drivers/hwtracing/coresight/coresight-syscfg.c +34 -15
101 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 166/508 vt: remove VT_RESIZE and VT_RESIZEX from vt_compat_ioctl()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Pitre <[email protected]>
[ Upstream commit c4c7ead7b86c1e7f11c64915b7e5bb6d2e242691 ]
They are listed amon those cmd values that "treat 'arg' as an integer" which is wrong. They should instead fall into the default case. Probably nobody ever relied on that code since 2009 but still.
--- drivers/tty/vt/vt_ioctl.c | 2 -- 1 file changed, 2 deletions(-)
drivers/tty/vt/vt_ioctl.c +0 -2
@@ -1105,8 +1105,6 @@ long vt_compat_ioctl(struct tty_struct *tty,case VT_WAITACTIVE :case VT_RELDISP :case VT_DISALLOCATE : -case VT_RESIZE : -case VT_RESIZEX :return vt_ioctl (tty, cmd, arg);/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 167/508 net: stmmac: platform: guarantee uniqueness of bus_id
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quentin Schulz <[email protected]>
[ Upstream commit eb7fd7aa35bfcc1e1fda4ecc42ccfcb526cdc780 ]
bus_id is currently derived from the ethernetX alias. If one is missing for the device, 0 is used. If ethernet0 points to another stmmac device or if there are 2+ stmmac devices without an ethernet alias, then bus_id will be 0 for all of those.
This is an issue because the bus_id is used to generate the mdio bus id (new_bus->id in drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c stmmac_mdio_register) and this needs to be unique.
This allows to avoid needing to define ethernet aliases for devices with multiple stmmac controllers (such as the Rockchip RK3588) for multiple stmmac devices to probe properly.
Obviously, the bus_id isn't guaranteed to be stable across reboots if no alias is set for the device but that is easily fixed by simply adding an alias if this is desired.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +9 -2
@@ -417,6 +417,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)struct device_node *np = pdev->dev.of_node;struct plat_stmmacenet_data *plat;struct stmmac_dma_cfg *dma_cfg; +static int bus_id = -ENODEV ;int phy_mode;void *ret;int rc;
@@ -453,8 +454,14 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)of_property_read_u32 (np,"max-speed" , &plat->max_speed); plat->bus_id =of_alias_get_id (np,"ethernet" ); -if (plat->bus_id <0 ) - plat->bus_id =0 ; +if (plat->bus_id <0 ) { +if (bus_id <0 ) + bus_id =of_alias_get_highest_id ("ethernet" ); +/* No ethernet alias found, init at -1 so first bus_id is 0 */ +if (bus_id <0 ) + bus_id =-1 ; + plat->bus_id = ++bus_id; + }/* Default to phy auto-detection */ plat->phy_addr =-1 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 168/508 gve: Fix RX_BUFFERS_POSTED stat to report per-queue fill_cnt
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit f41a94aade120dc60322865f363cee7865f2df01 ]
Previously, the RX_BUFFERS_POSTED stat incorrectly reported the fill_cnt from RX queue 0 for all queues, resulting in inaccurate per-queue statistics.
Fix this by correctly indexing priv->rx[idx].fill_cnt for each RX queue.
--- drivers/net/ethernet/google/gve/gve_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/google/gve/gve_main.c +1 -1
@@ -1312,7 +1312,7 @@ void gve_handle_report_stats(struct gve_priv *priv) }; stats[stats_idx++] = (struct stats ) { .stat_name =cpu_to_be32 (RX_BUFFERS_POSTED ), - .value =cpu_to_be64 (priv->rx[0 ].fill_cnt), + .value =cpu_to_be64 (priv->rx[idx].fill_cnt), .queue_id =cpu_to_be32 (idx), }; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 169/508 net: tipc: fix refcount warning in tipc_aead_encrypt
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charalampos Mitrodimas <[email protected]>
[ Upstream commit f29ccaa07cf3d35990f4d25028cc55470d29372b ]
syzbot reported a refcount warning [1] caused by calling get_net() on a network namespace that is being destroyed (refcount=0). This happens when a TIPC discovery timer fires during network namespace cleanup.
The recently added get_net() call in commit e279024617134 ("net/tipc:
fix slab-use-after-free Read in tipc_aead_encrypt_done") attempts to hold a reference to the network namespace. However, if the namespace is already being destroyed, its refcount might be zero, leading to the use-after-free warning.
Replace get_net() with maybe_get_net(), which safely checks if the refcount is non-zero before incrementing it. If the namespace is being destroyed, return -ENODEV early, after releasing the bearer reference.
[1]: https://lore.kernel.org/all/[email protected]/T/#m12019cf9ae77e1954f666914640efa36d52704a2
--- net/tipc/crypto.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/tipc/crypto.c +5 -1
@@ -818,7 +818,11 @@ static int tipc_aead_encrypt(struct tipc_aead *aead, struct sk_buff *skb, }/* Get net to avoid freed tipc_crypto when delete namespace */ -get_net (aead->crypto->net); +if (!maybe_get_net (aead->crypto->net)) { +tipc_bearer_put (b); + rc = -ENODEV ; + goto exit; + }/* Now, do encrypt */ rc =crypto_aead_encrypt (req);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 170/508 driver: net: ethernet: mtk_star_emac: fix suspend/resume issue
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yanqing Wang <[email protected]>
[ Upstream commit ba99c627aac85bc746fb4a6e2d79edb3ad100326 ]
Identify the cause of the suspend/resume hang: netif_carrier_off() is called during link state changes and becomes stuck while executing linkwatch_work().
To resolve this issue, call netif_device_detach() during the Ethernet suspend process to temporarily detach the network device from the kernel and prevent the suspend/resume hang.
--- drivers/net/ethernet/mediatek/mtk_star_emac.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/mediatek/mtk_star_emac.c +4 -0
@@ -1475,6 +1475,8 @@ static __maybe_unused int mtk_star_suspend(struct device *dev)if (netif_running (ndev))mtk_star_disable (ndev); +netif_device_detach (ndev); +clk_bulk_disable_unprepare (MTK_STAR_NCLKS , priv->clks);return 0 ;
@@ -1499,6 +1501,8 @@ static __maybe_unused int mtk_star_resume(struct device *dev)clk_bulk_disable_unprepare (MTK_STAR_NCLKS , priv->clks); } +netif_device_attach (ndev); +return ret; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 171/508 net/mlx4_en: Prevent potential integer overflow calculating Hz
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 54d34165b4f786d7fea8412a18fb4a54c1eab623 ]
The "freq" variable is in terms of MHz and "max_val_cycles" is in terms of Hz. The fact that "max_val_cycles" is a u64 suggests that support for high frequency is intended but the "freq_khz * 1000" would overflow the u32 type if we went above 4GHz. Use unsigned long long type for the mutliplication to prevent that.
--- drivers/net/ethernet/mellanox/mlx4/en_clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx4/en_clock.c +1 -1
@@ -251,7 +251,7 @@ static const struct ptp_clock_info mlx4_en_ptp_clock_info = {static u32 freq_to_shift (u16 freq) {u32 freq_khz = freq *1000 ; -u64 max_val_cycles = freq_khz *1000 *MLX4_EN_WRAP_AROUND_SEC ; +u64 max_val_cycles = freq_khz *1000ULL *MLX4_EN_WRAP_AROUND_SEC ;u64 max_val_cycles_rounded =1ULL <<fls64 (max_val_cycles -1 );/* calculate max possible multiplier in order to fit in 64bit */ u64 max_mul =div64_u64 (ULLONG_MAX , max_val_cycles_rounded);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 172/508 net: lan966x: Make sure to insert the vlan tags also in host mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Horatiu Vultur <[email protected]>
[ Upstream commit 27eab4c644236a9324084a70fe79e511cbd07393 ]
When running these commands on DUT (and similar at the other end) ip link set dev eth0 up
ip link add link eth0 name eth0.10 type vlan id 10
ip addr add 10.0.0.1/24 dev eth0.10
ip link set dev eth0.10 up
ping 10.0.0.2
The ping will fail.
The reason why is failing is because, the network interfaces for lan966x have a flag saying that the HW can insert the vlan tags into the frames(NETIF_F_HW_VLAN_CTAG_TX). Meaning that the frames that are transmitted don't have the vlan tag inside the skb data, but they have it inside the skb. We already get that vlan tag and put it in the IFH but the problem is that we don't configure the HW to rewrite the frame when the interface is in host mode.
The fix consists in actually configuring the HW to insert the vlan tag if it is different than 0.
--- .../ethernet/microchip/lan966x/lan966x_main.c | 1 + .../ethernet/microchip/lan966x/lan966x_main.h | 1 + .../microchip/lan966x/lan966x_switchdev.c | 1 + .../ethernet/microchip/lan966x/lan966x_vlan.c | 21 +++++++++++++++++++ 4 files changed, 24 insertions(+)
drivers/net/ethernet/microchip/lan966x/lan966x_main.c +1 -0
@@ -811,6 +811,7 @@ static int lan966x_probe_port(struct lan966x *lan966x, u32 p,lan966x_vlan_port_set_vlan_aware (port,0 );lan966x_vlan_port_set_vid (port,HOST_PVID , false, false);lan966x_vlan_port_apply (port); +lan966x_vlan_port_rew_host (port);return 0 ; }
drivers/net/ethernet/microchip/lan966x/lan966x_main.h +1 -0
@@ -388,6 +388,7 @@ void lan966x_vlan_port_apply(struct lan966x_port *port);bool lan966x_vlan_cpu_member_cpu_vlan_mask (struct lan966x *lan966x,u16 vid);void lan966x_vlan_port_set_vlan_aware (struct lan966x_port *port,bool vlan_aware); +void lan966x_vlan_port_rew_host (struct lan966x_port *port); int lan966x_vlan_port_set_vid(struct lan966x_port *port, u16 vid, bool pvid,
drivers/net/ethernet/microchip/lan966x/lan966x_switchdev.c +1 -0
@@ -297,6 +297,7 @@ static void lan966x_port_bridge_leave(struct lan966x_port *port,lan966x_vlan_port_set_vlan_aware (port, false);lan966x_vlan_port_set_vid (port,HOST_PVID , false, false);lan966x_vlan_port_apply (port); +lan966x_vlan_port_rew_host (port); } int lan966x_port_changeupper(struct net_device *dev,
drivers/net/ethernet/microchip/lan966x/lan966x_vlan.c +21 -0
@@ -149,6 +149,27 @@ void lan966x_vlan_port_set_vlan_aware(struct lan966x_port *port, port->vlan_aware = vlan_aware; } +/* When the interface is in host mode, the interface should not be vlan aware +* but it should insert all the tags that it gets from the network stack. +* The tags are not in the data of the frame but actually in the skb and the ifh +* is configured already to get this tag. So what we need to do is to update the +* rewriter to insert the vlan tag for all frames which have a vlan tag +* different than 0. +*/ +void lan966x_vlan_port_rew_host (struct lan966x_port *port) +{ +struct lan966x *lan966x = port->lan966x; +u32 val; + +/* Tag all frames except when VID=0*/ + val =REW_TAG_CFG_TAG_CFG_SET (2 ); + +/* Update only some bits in the register */ +lan_rmw (val, +REW_TAG_CFG_TAG_CFG , + lan966x,REW_TAG_CFG (port->chip_port)); +} +void lan966x_vlan_port_apply (struct lan966x_port *port) {struct lan966x *lan966x = port->lan966x;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 173/508 spi: bcm63xx-spi: fix shared reset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Álvaro Fernández Rojas <[email protected]>
[ Upstream commit 5ad20e3d8cfe3b2e42bbddc7e0ebaa74479bb589 ]
Some bmips SoCs (bcm6362, bcm63268) share the same SPI reset for both SPI and HSSPI controllers, so reset shouldn't be exclusive.
--- drivers/spi/spi-bcm63xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-bcm63xx.c +1 -1
@@ -533,7 +533,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)return PTR_ERR (clk); } - reset =devm_reset_control_get_optional_exclusive (dev,NULL ); + reset =devm_reset_control_get_optional_shared (dev,NULL );if (IS_ERR (reset))return PTR_ERR (reset);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 174/508 spi: bcm63xx-hsspi: fix shared reset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Álvaro Fernández Rojas <[email protected]>
[ Upstream commit 3d6d84c8f2f66d3fd6a43a1e2ce8e6b54c573960 ]
Some bmips SoCs (bcm6362, bcm63268) share the same SPI reset for both SPI and HSSPI controllers, so reset shouldn't be exclusive.
--- drivers/spi/spi-bcm63xx-hsspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-bcm63xx-hsspi.c +1 -1
@@ -357,7 +357,7 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)if (IS_ERR (clk))return PTR_ERR (clk); - reset =devm_reset_control_get_optional_exclusive (dev,NULL ); + reset =devm_reset_control_get_optional_shared (dev,NULL );if (IS_ERR (reset))return PTR_ERR (reset);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 175/508 Bluetooth: L2CAP: Fix not responding with L2CAP_CR_LE_ENCRYPTION
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 03dba9cea72f977e873e4e60e220fa596959dd8f ]
Depending on the security set the response to L2CAP_LE_CONN_REQ shall be just L2CAP_CR_LE_ENCRYPTION if only encryption when BT_SECURITY_MEDIUM is selected since that means security mode 2 which doesn't require authentication which is something that is covered in the qualification test L2CAP/LE/CFC/BV-25-C.
--- net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +2 -1
@@ -5883,7 +5883,8 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,if (!smp_sufficient_security (conn->hcon, pchan->sec_level,SMP_ALLOW_STK )) { - result =L2CAP_CR_LE_AUTHENTICATION ; + result = pchan->sec_level ==BT_SECURITY_MEDIUM ? +L2CAP_CR_LE_ENCRYPTION :L2CAP_CR_LE_AUTHENTICATION ; chan =NULL ; goto response_unlock; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 176/508 ice: create new Tx scheduler nodes for new queues only
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Kubiak <[email protected]>
[ Upstream commit 6fa2942578472c9cab13a8fc1dae0d830193e0a1 ]
The current implementation of the Tx scheduler tree attempts to create nodes for all Tx queues, ignoring the fact that some queues may already exist in the tree. For example, if the VSI already has 128 Tx queues and the user requests for 16 new queues, the Tx scheduler will compute the tree for 272 queues (128 existing queues + 144 new queues), instead of 144 queues (128 existing queues and 16 new queues).
Fix that by modifying the node count calculation algorithm to skip the queues that already exist in the tree.
--- drivers/net/ethernet/intel/ice/ice_sched.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_sched.c +6 -5
@@ -1591,16 +1591,16 @@ ice_sched_get_agg_node(struct ice_port_info *pi, struct ice_sched_node *tc_node,/** * ice_sched_calc_vsi_child_nodes - calculate number of VSI child nodes * @hw: pointer to the HW struct -* @num_qs: number of queues +* @num_new_qs: number of new queues that will be added to the tree * @num_nodes: num nodes array * * This function calculates the number of VSI child nodes based on the * number of queues. */ static void -ice_sched_calc_vsi_child_nodes (struct ice_hw *hw,u16 num_qs,u16 *num_nodes) +ice_sched_calc_vsi_child_nodes (struct ice_hw *hw,u16 num_new_qs,u16 *num_nodes) { -u16 num = num_qs; +u16 num = num_new_qs;u8 i, qgl, vsil; qgl =ice_sched_get_qgrp_layer (hw);
@@ -1848,8 +1848,9 @@ ice_sched_update_vsi_child_nodes(struct ice_port_info *pi, u16 vsi_handle,return status; } -if (new_numqs) -ice_sched_calc_vsi_child_nodes (hw, new_numqs, new_num_nodes); +ice_sched_calc_vsi_child_nodes (hw, new_numqs - prev_numqs, + new_num_nodes); +/* Keep the max number of queue configuration all the time. Update the * tree only if number of queues > previous number of queues. This may * leave some extra nodes in the tree if number of queues < previous
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 177/508 ice: fix rebuilding the Tx scheduler tree for large queue counts
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Kubiak <[email protected]>
[ Upstream commit 73145e6d81070d34a21431c9e0d7aaf2f29ca048 ]
The current implementation of the Tx scheduler allows the tree to be rebuilt as the user adds more Tx queues to the VSI. In such a case, additional child nodes are added to the tree to support the new number of queues.
Unfortunately, this algorithm does not take into account that the limit of the VSI support node may be exceeded, so an additional node in the VSI layer may be required to handle all the requested queues.
Such a scenario occurs when adding XDP Tx queues on machines with many CPUs. Although the driver still respects the queue limit returned by the FW, the Tx scheduler was unable to add those queues to its tree and returned one of the errors below.
Such a scenario occurs when adding XDP Tx queues on machines with many CPUs (e.g. at least 321 CPUs, if there is already 128 Tx/Rx queue pairs). Although the driver still respects the queue limit returned by the FW, the Tx scheduler was unable to add those queues to its tree and returned the following errors:
Failed VSI LAN queue config for XDP, error: -5
or:
Failed to set LAN Tx queue context, error: -22
Fix this problem by extending the tree rebuild algorithm to check if the current VSI node can support the requested number of queues. If it cannot, create as many additional VSI support nodes as necessary to handle all the required Tx queues. Symmetrically, adjust the VSI node removal algorithm to remove all nodes associated with the given VSI. Also, make the search for the next free VSI node more restrictive. That is, add queue group nodes only to the VSI support nodes that have a matching VSI handle.
Finally, fix the comment describing the tree update algorithm to better reflect the current scenario.
--- drivers/net/ethernet/intel/ice/ice_sched.c | 170 +++++++++++++++++---- 1 file changed, 142 insertions(+), 28 deletions(-)
drivers/net/ethernet/intel/ice/ice_sched.c +142 -28
@@ -84,6 +84,27 @@ ice_sched_find_node_by_teid(struct ice_sched_node *start_node, u32 teid)return NULL ; } +/** +* ice_sched_find_next_vsi_node - find the next node for a given VSI +* @vsi_node: VSI support node to start search with +* +* Return: Next VSI support node, or NULL. +* +* The function returns a pointer to the next node from the VSI layer +* assigned to the given VSI, or NULL if there is no such a node. +*/ +static struct ice_sched_node * +ice_sched_find_next_vsi_node (struct ice_sched_node *vsi_node) +{ +unsigned int vsi_handle = vsi_node->vsi_handle; + +while ((vsi_node = vsi_node->sibling) !=NULL ) +if (vsi_node->vsi_handle == vsi_handle) +break ; + +return vsi_node; +} +/** * ice_aqc_send_sched_elem_cmd - send scheduling elements cmd * @hw: pointer to the HW struct
@@ -1073,8 +1094,10 @@ ice_sched_add_nodes_to_layer(struct ice_port_info *pi,if (parent->num_children < max_child_nodes) { new_num_nodes = max_child_nodes - parent->num_children; }else { -/* This parent is full, try the next sibling */ - parent = parent->sibling; +/* This parent is full, +* try the next available sibling. +*/ + parent =ice_sched_find_next_vsi_node (parent);/* Don't modify the first node TEID memory if the * first node was added already in the above call. * Instead send some temp memory for all other
@@ -1515,12 +1538,23 @@ ice_sched_get_free_qparent(struct ice_port_info *pi, u16 vsi_handle, u8 tc,/* get the first queue group node from VSI sub-tree */ qgrp_node =ice_sched_get_first_node (pi, vsi_node, qgrp_layer);while (qgrp_node) { +struct ice_sched_node *next_vsi_node; +/* make sure the qgroup node is part of the VSI subtree */ if (ice_sched_find_node_in_subtree (pi->hw, vsi_node, qgrp_node))if (qgrp_node->num_children < max_children && qgrp_node->owner == owner)break ; qgrp_node = qgrp_node->sibling; +if (qgrp_node) +continue ; + + next_vsi_node =ice_sched_find_next_vsi_node (vsi_node); +if (!next_vsi_node) +break ; + + vsi_node = next_vsi_node; + qgrp_node =ice_sched_get_first_node (pi, vsi_node, qgrp_layer); }/* Select the best queue group */
@@ -1764,7 +1798,11 @@ ice_sched_add_vsi_support_nodes(struct ice_port_info *pi, u16 vsi_handle,if (!parent)return -EIO ; -if (i == vsil) +/* Do not modify the VSI handle for already existing VSI nodes, +* (if no new VSI node was added to the tree). +* Assign the VSI handle only to newly added VSI nodes. +*/ +if (i == vsil && num_added) parent->vsi_handle = vsi_handle; }
@@ -1797,6 +1835,41 @@ ice_sched_add_vsi_to_topo(struct ice_port_info *pi, u16 vsi_handle, u8 tc) num_nodes); } +/** +* ice_sched_recalc_vsi_support_nodes - recalculate VSI support nodes count +* @hw: pointer to the HW struct +* @vsi_node: pointer to the leftmost VSI node that needs to be extended +* @new_numqs: new number of queues that has to be handled by the VSI +* @new_num_nodes: pointer to nodes count table to modify the VSI layer entry +* +* This function recalculates the number of supported nodes that need to +* be added after adding more Tx queues for a given VSI. +* The number of new VSI support nodes that shall be added will be saved +* to the @new_num_nodes table for the VSI layer. +*/ +static void +ice_sched_recalc_vsi_support_nodes (struct ice_hw *hw, +struct ice_sched_node *vsi_node, +unsigned int new_numqs,u16 *new_num_nodes) +{ +u32 vsi_nodes_cnt =1 ; +u32 max_queue_cnt =1 ; +u32 qgl, vsil; + + qgl =ice_sched_get_qgrp_layer (hw); + vsil =ice_sched_get_vsi_layer (hw); + +for (u32 i = vsil; i <= qgl; i++) + max_queue_cnt *= hw->max_children[i]; + +while ((vsi_node =ice_sched_find_next_vsi_node (vsi_node)) !=NULL ) + vsi_nodes_cnt++; + +if (new_numqs > (max_queue_cnt * vsi_nodes_cnt)) + new_num_nodes[vsil] =DIV_ROUND_UP (new_numqs, max_queue_cnt) - + vsi_nodes_cnt; +} +/** * ice_sched_update_vsi_child_nodes - update VSI child nodes * @pi: port information structure
@@ -1848,16 +1921,25 @@ ice_sched_update_vsi_child_nodes(struct ice_port_info *pi, u16 vsi_handle,return status; } +ice_sched_recalc_vsi_support_nodes (hw, vsi_node, + new_numqs, new_num_nodes);ice_sched_calc_vsi_child_nodes (hw, new_numqs - prev_numqs, new_num_nodes); -/* Keep the max number of queue configuration all the time. Update the -* tree only if number of queues > previous number of queues. This may +/* Never decrease the number of queues in the tree. Update the tree +* only if number of queues > previous number of queues. This may * leave some extra nodes in the tree if number of queues < previous * number but that wouldn't harm anything. Removing those extra nodes * may complicate the code if those nodes are part of SRL or * individually rate limited. +* Also, add the required VSI support nodes if the existing ones cannot +* handle the requested new number of queues. */ + status =ice_sched_add_vsi_support_nodes (pi, vsi_handle, tc_node, + new_num_nodes); +if (status) +return status; + status =ice_sched_add_vsi_child_nodes (pi, vsi_handle, tc_node, new_num_nodes, owner);if (status)
@@ -1998,6 +2080,58 @@ static bool ice_sched_is_leaf_node_present(struct ice_sched_node *node)return (node->info.data.elem_type ==ICE_AQC_ELEM_TYPE_LEAF ); } +/** +* ice_sched_rm_vsi_subtree - remove all nodes assigned to a given VSI +* @pi: port information structure +* @vsi_node: pointer to the leftmost node of the VSI to be removed +* @owner: LAN or RDMA +* @tc: TC number +* +* Return: Zero in case of success, or -EBUSY if the VSI has leaf nodes in TC. +* +* This function removes all the VSI support nodes associated with a given VSI +* and its LAN or RDMA children nodes from the scheduler tree. +*/ +static int +ice_sched_rm_vsi_subtree (struct ice_port_info *pi, +struct ice_sched_node *vsi_node,u8 owner,u8 tc) +{ +u16 vsi_handle = vsi_node->vsi_handle; +bool all_vsi_nodes_removed = true; +int j =0 ; + +while (vsi_node) { +struct ice_sched_node *next_vsi_node; + +if (ice_sched_is_leaf_node_present (vsi_node)) { +ice_debug (pi->hw,ICE_DBG_SCHED ,"VSI has leaf nodes in TC %d\n" , tc); +return -EBUSY ; + } +while (j < vsi_node->num_children) { +if (vsi_node->children[j]->owner == owner) +ice_free_sched_node (pi, vsi_node->children[j]); +else + j++; + } + + next_vsi_node =ice_sched_find_next_vsi_node (vsi_node); + +/* remove the VSI if it has no children */ +if (!vsi_node->num_children) +ice_free_sched_node (pi, vsi_node); +else + all_vsi_nodes_removed = false; + + vsi_node = next_vsi_node; + } + +/* clean up aggregator related VSI info if any */ +if (all_vsi_nodes_removed) +ice_sched_rm_agg_vsi_info (pi, vsi_handle); + +return 0 ; +} +/** * ice_sched_rm_vsi_cfg - remove the VSI and its children nodes * @pi: port information structure
@@ -2024,7 +2158,6 @@ ice_sched_rm_vsi_cfg(struct ice_port_info *pi, u16 vsi_handle, u8 owner)ice_for_each_traffic_class (i) {struct ice_sched_node *vsi_node, *tc_node; -u8 j =0 ; tc_node =ice_sched_get_tc_node (pi, i);if (!tc_node)
@@ -2034,31 +2167,12 @@ ice_sched_rm_vsi_cfg(struct ice_port_info *pi, u16 vsi_handle, u8 owner)if (!vsi_node)continue ; -if (ice_sched_is_leaf_node_present (vsi_node)) { -ice_debug (pi->hw,ICE_DBG_SCHED ,"VSI has leaf nodes in TC %d\n" , i); - status = -EBUSY ; + status =ice_sched_rm_vsi_subtree (pi, vsi_node, owner, i); +if (status) goto exit_sched_rm_vsi_cfg; - } -while (j < vsi_node->num_children) { -if (vsi_node->children[j]->owner == owner) { -ice_free_sched_node (pi, vsi_node->children[j]); -/* reset the counter again since the num -* children will be updated after node removal -*/ - j =0 ; - }else { - j++; - } - } -/* remove the VSI if it has no children */ -if (!vsi_node->num_children) { -ice_free_sched_node (pi, vsi_node); - vsi_ctx->sched.vsi_node[i] =NULL ; + vsi_ctx->sched.vsi_node[i] =NULL ; -/* clean up aggregator related VSI info if any */ -ice_sched_rm_agg_vsi_info (pi, vsi_handle); - }if (owner ==ICE_SCHED_NODE_OWNER_LAN ) vsi_ctx->sched.max_lanq[i] =0 ;else
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 178/508 net: dsa: tag_brcm: legacy: fix pskb_may_pull length
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Álvaro Fernández Rojas <[email protected]>
[ Upstream commit efdddc4484859082da6c7877ed144c8121c8ea55 ]
BRCM_LEG_PORT_ID was incorrectly used for pskb_may_pull length. The correct check is BRCM_LEG_TAG_LEN + VLAN_HLEN, or 10 bytes.
--- net/dsa/tag_brcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/dsa/tag_brcm.c +1 -1
@@ -253,7 +253,7 @@ static struct sk_buff *brcm_leg_tag_rcv(struct sk_buff *skb,int source_port;u8 *brcm_tag; -if (unlikely (!pskb_may_pull (skb,BRCM_LEG_PORT_ID ))) +if (unlikely (!pskb_may_pull (skb,BRCM_LEG_TAG_LEN +VLAN_HLEN )))return NULL ; brcm_tag =dsa_etype_header_pos_rx (skb);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 179/508 net: stmmac: make sure that ptp_rate is not 0 before configuring timestamping
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexis Lothoré <[email protected]>
[ Upstream commit 030ce919e114a111e83b7976ecb3597cefd33f26 ]
The stmmac platform drivers that do not open-code the clk_ptp_rate value after having retrieved the default one from the device-tree can end up with 0 in clk_ptp_rate (as clk_get_rate can return 0). It will eventually propagate up to PTP initialization when bringing up the interface, leading to a divide by 0:
Division by zero in kernel.
CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.12.30-00001-g48313bd5768a #22 Hardware name: STM32 (Device Tree Support) Call trace: unwind_backtrace from show_stack+0x18/0x1c show_stack from dump_stack_lvl+0x6c/0x8c dump_stack_lvl from Ldiv0_64+0x8/0x18 Ldiv0_64 from stmmac_init_tstamp_counter+0x190/0x1a4 stmmac_init_tstamp_counter from stmmac_hw_setup+0xc1c/0x111c stmmac_hw_setup from __stmmac_open+0x18c/0x434 __stmmac_open from stmmac_open+0x3c/0xbc stmmac_open from __dev_open+0xf4/0x1ac __dev_open from __dev_change_flags+0x1cc/0x224 __dev_change_flags from dev_change_flags+0x24/0x60 dev_change_flags from ip_auto_config+0x2e8/0x11a0 ip_auto_config from do_one_initcall+0x84/0x33c do_one_initcall from kernel_init_freeable+0x1b8/0x214 kernel_init_freeable from kernel_init+0x24/0x140 kernel_init from ret_from_fork+0x14/0x28 Exception stack(0xe0815fb0 to 0xe0815ff8)
Prevent this division by 0 by adding an explicit check and error log about the actual issue. While at it, remove the same check from stmmac_ptp_register, which then becomes duplicate
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++++ drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5 -0
@@ -841,6 +841,11 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags)if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp))return -EOPNOTSUPP ; +if (!priv->plat->clk_ptp_rate) { +netdev_err (priv->dev,"Invalid PTP clock rate" ); +return -EINVAL ; + } +stmmac_config_hw_tstamping (priv, priv->ptpaddr, systime_flags); priv->systime_flags = systime_flags;
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +1 -1
@@ -301,7 +301,7 @@ void stmmac_ptp_register(struct stmmac_priv *priv)/* Calculate the clock domain crossing (CDC) error if necessary */ priv->plat->cdc_error_adj =0 ; -if (priv->plat->has_gmac4 && priv->plat->clk_ptp_rate) +if (priv->plat->has_gmac4) priv->plat->cdc_error_adj = (2 *NSEC_PER_SEC ) / priv->plat->clk_ptp_rate; stmmac_ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 180/508 net: fix udp gso skb_segment after pull from frag_list
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shiming Cheng <[email protected]>
[ Upstream commit 3382a1ed7f778db841063f5d7e317ac55f9e7f72 ]
Commit a1e40ac5b5e9 ("net: gso: fix udp gso fraglist segmentation after pull from frag_list") detected invalid geometry in frag_list skbs and redirects them from skb_segment_list to more robust skb_segment. But some packets with modified geometry can also hit bugs in that code. We don't know how many such cases exist. Addressing each one by one also requires touching the complex skb_segment code, which risks introducing bugs for other types of skbs. Instead, linearize all these packets that fail the basic invariants on gso fraglist skbs. That is more robust.
If only part of the fraglist payload is pulled into head_skb, it will always cause exception when splitting skbs by skb_segment. For detailed call stack information, see below.
Valid SKB_GSO_FRAGLIST skbs
- consist of two or more segments
- the head_skb holds the protocol headers plus first gso_size
- one or more frag_list skbs hold exactly one segment
- all but the last must be gso_size
Optional datapath hooks such as NAT and BPF (bpf_skb_pull_data) can modify fraglist skbs, breaking these invariants.
In extreme cases they pull one part of data into skb linear. For UDP, this causes three payloads with lengths of (11,11,10) bytes were pulled tail to become (12,10,10) bytes.
The skbs no longer meets the above SKB_GSO_FRAGLIST conditions because payload was pulled into head_skb, it needs to be linearized before pass to regular skb_segment.
skb_segment+0xcd0/0xd14
__udp_gso_segment+0x334/0x5f4
udp4_ufo_fragment+0x118/0x15c
inet_gso_segment+0x164/0x338
skb_mac_gso_segment+0xc4/0x13c
__skb_gso_segment+0xc4/0x124
validate_xmit_skb+0x9c/0x2c0
validate_xmit_skb_list+0x4c/0x80
sch_direct_xmit+0x70/0x404
__dev_queue_xmit+0x64c/0xe5c
neigh_resolve_output+0x178/0x1c4
ip_finish_output2+0x37c/0x47c
__ip_finish_output+0x194/0x240
ip_finish_output+0x20/0xf4
ip_output+0x100/0x1a0
NF_HOOK+0xc4/0x16c
ip_forward+0x314/0x32c
ip_rcv+0x90/0x118
__netif_receive_skb+0x74/0x124
process_backlog+0xe8/0x1a4
__napi_poll+0x5c/0x1f8
net_rx_action+0x154/0x314
handle_softirqs+0x154/0x4b8 [118.376811] [C201134] rxq0_pus: [name:bug&]kernel BUG at net/core/skbuff.c:4278!
[118.376829] [C201134] rxq0_pus: [name:traps&]Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP
[118.470774] [C201134] rxq0_pus: [name:mrdump&]Kernel Offset: 0x178cc00000 from 0xffffffc008000000
[118.470810] [C201134] rxq0_pus: [name:mrdump&]PHYS_OFFSET: 0x40000000
[118.470827] [C201134] rxq0_pus: [name:mrdump&]pstate: 60400005 (nZCv daif +PAN -UAO)
[118.470848] [C201134] rxq0_pus: [name:mrdump&]pc : [0xffffffd79598aefc] skb_segment+0xcd0/0xd14
[118.470900] [C201134] rxq0_pus: [name:mrdump&]lr : [0xffffffd79598a5e8] skb_segment+0x3bc/0xd14
[118.470928] [C201134] rxq0_pus: [name:mrdump&]sp : ffffffc008013770--- net/ipv4/udp_offload.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ipv4/udp_offload.c +5 -0
@@ -331,6 +331,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,bool copy_dtor;__sum16 check;__be16 newlen; +int ret =0 ; mss =skb_shinfo (gso_skb)->gso_size;if (gso_skb->len <=sizeof (*uh) + mss)
@@ -353,6 +354,10 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,if (skb_pagelen (gso_skb) -sizeof (*uh) ==skb_shinfo (gso_skb)->gso_size)return __udp_gso_segment_list (gso_skb, features, is_ipv6); + ret =__skb_linearize (gso_skb); +if (ret) +return ERR_PTR (ret); +/* Setup csum, as fraglist skips this in udp4_gro_receive. */ gso_skb->csum_start =skb_transport_header (gso_skb) - gso_skb->head; gso_skb->csum_offset = offsetof(struct udphdr , check);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 181/508 vmxnet3: correctly report gso type for UDP tunnels
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ronak Doshi <[email protected]>
[ Upstream commit 982d30c30eaa2ec723df42e3bf526c014c1dbb88 ]
Commit 3d010c8031e3 ("udp: do not accept non-tunnel GSO skbs landing in a tunnel") added checks in linux stack to not accept non-tunnel GRO packets landing in a tunnel. This exposed an issue in vmxnet3 which was not correctly reporting GRO packets for tunnel packets.
This patch fixes this issue by setting correct GSO type for the tunnel packets.
Currently, vmxnet3 does not support reporting inner fields for LRO tunnel packets. The issue is not seen for egress drivers that do not use skb inner fields. The workaround is to enable tnl-segmentation offload on the egress interfaces if the driver supports it. This problem pre-exists this patch fix and can be addressed as a separate future patch.
--- drivers/net/vmxnet3/vmxnet3_drv.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/net/vmxnet3/vmxnet3_drv.c +26 -0
@@ -1407,6 +1407,30 @@ vmxnet3_get_hdr_len(struct vmxnet3_adapter *adapter, struct sk_buff *skb,return (hlen + (hdr.tcp->doff <<2 )); } +static void +vmxnet3_lro_tunnel (struct sk_buff *skb,__be16 ip_proto) +{ +struct udphdr *uh =NULL ; + +if (ip_proto ==htons (ETH_P_IP )) { +struct iphdr *iph = (struct iphdr *)skb->data; + +if (iph->protocol ==IPPROTO_UDP ) + uh = (struct udphdr *)(iph +1 ); + }else { +struct ipv6hdr *iph = (struct ipv6hdr *)skb->data; + +if (iph->nexthdr ==IPPROTO_UDP ) + uh = (struct udphdr *)(iph +1 ); + } +if (uh) { +if (uh->check) +skb_shinfo (skb)->gso_type |=SKB_GSO_UDP_TUNNEL_CSUM ; +else +skb_shinfo (skb)->gso_type |=SKB_GSO_UDP_TUNNEL ; + } +} +static int vmxnet3_rq_rx_complete (struct vmxnet3_rx_queue *rq,struct vmxnet3_adapter *adapter,int quota)
@@ -1663,6 +1687,8 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,if (segCnt !=0 && mss !=0 ) {skb_shinfo (skb)->gso_type = rcd->v4 ?SKB_GSO_TCPV4 :SKB_GSO_TCPV6 ; +if (encap_lro) +vmxnet3_lro_tunnel (skb, skb->protocol);skb_shinfo (skb)->gso_size = mss;skb_shinfo (skb)->gso_segs = segCnt; }else if ((segCnt !=0 || skb->len > mtu) && !encap_lro) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 182/508 PM: sleep: Fix power.is_suspended cleanup for direct-complete devices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit d46c4c839c20a599a0eb8d73708ce401f9c7d06d ]
Commit 03f1444016b7 ("PM: sleep: Fix handling devices with direct_complete set on errors") caused power.is_suspended to be set for devices with power.direct_complete set, but it forgot to ensure the clearing of that flag for them in device_resume(), so power.is_suspended is still set for them during the next system suspend-resume cycle.
If that cycle is aborted in dpm_suspend(), the subsequent invocation of dpm_resume() will trigger a device_resume() call for every device and because power.is_suspended is set for the devices in question, they will not be skipped by device_resume() as expected which causes scary error messages to be logged (as appropriate).
To address this issue, move the clearing of power.is_suspended in device_resume() immediately after the power.is_suspended check so it will be always cleared for all devices processed by that function.
--- drivers/base/power/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/power/main.c +2 -1
@@ -897,6 +897,8 @@ static void __device_resume(struct device *dev, pm_message_t state, bool async)if (!dev->power.is_suspended) goto Complete; + dev->power.is_suspended = false; +if (dev->power.direct_complete) {/* Match the pm_runtime_disable() in __device_suspend(). */ pm_runtime_enable (dev);
@@ -952,7 +954,6 @@ static void __device_resume(struct device *dev, pm_message_t state, bool async) End: error =dpm_run_callback (callback, dev, state, info); - dev->power.is_suspended = false;device_unlock (dev);dpm_watchdog_clear (&wd);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 183/508 gve: add missing NULL check for gve_alloc_pending_packet() in TX DQO
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit 12c331b29c7397ac3b03584e12902990693bc248 ]
gve_alloc_pending_packet() can return NULL, but gve_tx_add_skb_dqo() did not check for this case before dereferencing the returned pointer.
Add a missing NULL check to prevent a potential NULL pointer dereference when allocation fails.
This improves robustness in low-memory scenarios.
--- drivers/net/ethernet/google/gve/gve_tx_dqo.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/google/gve/gve_tx_dqo.c +3 -0
@@ -452,6 +452,9 @@ static int gve_tx_add_skb_no_copy_dqo(struct gve_tx_ring *tx,int i; pkt =gve_alloc_pending_packet (tx); +if (!pkt) +return -ENOMEM ; + pkt->skb = skb; pkt->num_bufs =0 ; completion_tag = pkt - tx->dqo.pending_packets;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 184/508 netfilter: nf_set_pipapo_avx2: fix initial map fill
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit ea77c397bff8b6d59f6d83dae1425b08f465e8b5 ]
If the first field doesn't cover the entire start map, then we must zero out the remainder, else we leak those bits into the next match round map.
The early fix was incomplete and did only fix up the generic C implementation.
A followup patch adds a test case to nft_concat_range.sh.
--- net/netfilter/nft_set_pipapo_avx2.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
net/netfilter/nft_set_pipapo_avx2.c +20 -1
@@ -1113,6 +1113,25 @@ bool nft_pipapo_avx2_estimate(const struct nft_set_desc *desc, u32 features,return true; } +/** +* pipapo_resmap_init_avx2() - Initialise result map before first use +* @m: Matching data, including mapping table +* @res_map: Result map +* +* Like pipapo_resmap_init() but do not set start map bits covered by the first field. +*/ +static inline void pipapo_resmap_init_avx2 (const struct nft_pipapo_match *m,unsigned long *res_map) +{ +const struct nft_pipapo_field *f = m->f; +int i; + +/* Starting map doesn't need to be set to all-ones for this implementation, +* but we do need to zero the remaining bits, if any. +*/ +for (i = f->bsize; i < m->bsize_max; i++) + res_map[i] =0ul ; +} +/** * nft_pipapo_avx2_lookup() - Lookup function for AVX2 implementation * @net: Network namespace
@@ -1171,7 +1190,7 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set, res = scratch->map + (map_index ? m->bsize_max :0 ); fill = scratch->map + (map_index ?0 : m->bsize_max); -/* Starting map doesn't need to be set for this implementation */ +pipapo_resmap_init_avx2 (m, res);nft_pipapo_avx2_prepare ();
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 185/508 wireguard: device: enable threaded NAPI
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mirco Barone <[email protected]>
[ Upstream commit db9ae3b6b43c79b1ba87eea849fd65efa05b4b2e ]
Enable threaded NAPI by default for WireGuard devices in response to low performance behavior that we observed when multiple tunnels (and thus multiple wg devices) are deployed on a single host. This affects any kind of multi-tunnel deployment, regardless of whether the tunnels share the same endpoints or not (i.e., a VPN concentrator type of gateway would also be affected).
The problem is caused by the fact that, in case of a traffic surge that involves multiple tunnels at the same time, the polling of the NAPI instance of all these wg devices tends to converge onto the same core, causing underutilization of the CPU and bottlenecking performance.
This happens because NAPI polling is hosted by default in softirq context, but the WireGuard driver only raises this softirq after the rx peer queue has been drained, which doesn't happen during high traffic. In this case, the softirq already active on a core is reused instead of raising a new one.
As a result, once two or more tunnel softirqs have been scheduled on the same core, they remain pinned there until the surge ends.
In our experiments, this almost always leads to all tunnel NAPIs being handled on a single core shortly after a surge begins, limiting scalability to less than 3× the performance of a single tunnel, despite plenty of unused CPU cores being available.
The proposed mitigation is to enable threaded NAPI for all WireGuard devices. This moves the NAPI polling context to a dedicated per-device kernel thread, allowing the scheduler to balance the load across all available cores.
On our 32-core gateways, enabling threaded NAPI yields a ~4× performance improvement with 16 tunnels, increasing throughput from ~13 Gbps to ~48 Gbps. Meanwhile, CPU usage on the receiver (which is the bottleneck) jumps from 20% to 100%.
We have found no performance regressions in any scenario we tested. Single-tunnel throughput remains unchanged.
More details are available in our Netdev paper.
--- drivers/net/wireguard/device.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireguard/device.c +1 -0
@@ -368,6 +368,7 @@ static int wg_newlink(struct net *src_net, struct net_device *dev,if (ret <0 ) goto err_free_handshake_queue; +dev_set_threaded (dev, true); ret =register_netdevice (dev);if (ret <0 ) goto err_uninit_ratelimiter;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 186/508 seg6: Fix validation of nexthop addresses
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 7632fedb266d93ed0ed9f487133e6c6314a9b2d1 ]
The kernel currently validates that the length of the provided nexthop address does not exceed the specified length. This can lead to the kernel reading uninitialized memory if user space provided a shorter length than the specified one.
Fix by validating that the provided length exactly matches the specified one.
--- net/ipv6/seg6_local.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/ipv6/seg6_local.c +2 -4
@@ -1250,10 +1250,8 @@ static const struct nla_policy seg6_local_policy[SEG6_LOCAL_MAX + 1] = { [SEG6_LOCAL_SRH] = { .type = NLA_BINARY }, [SEG6_LOCAL_TABLE] = { .type = NLA_U32 }, [SEG6_LOCAL_VRFTABLE] = { .type = NLA_U32 }, - [SEG6_LOCAL_NH4] = { .type = NLA_BINARY, - .len = sizeof(struct in_addr) }, - [SEG6_LOCAL_NH6] = { .type = NLA_BINARY, - .len = sizeof(struct in6_addr) }, + [SEG6_LOCAL_NH4] = NLA_POLICY_EXACT_LEN(sizeof(struct in_addr)), + [SEG6_LOCAL_NH6] = NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)), [SEG6_LOCAL_IIF] = { .type = NLA_U32 }, [SEG6_LOCAL_OIF] = { .type = NLA_U32 }, [SEG6_LOCAL_BPF] = { .type = NLA_NESTED },
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 187/508 ASoC: codecs: hda: Fix RPM usage count underflow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cezary Rojewski <[email protected]>
[ Upstream commit ff0045de4ee0288dec683690f66f2f369b7d3466 ]
RPM manipulation in hda_codec_probe_complete()'s error path is superfluous and leads to RPM usage count underflow if the build-controls operation fails.
hda_codec_probe_complete() is called in:
1) hda_codec_probe() for all non-HDMI codecs
2) in card->late_probe() for HDMI codecs
Error path for hda_codec_probe() takes care of bus' RPM already. For 2) if late_probe() fails, ASoC performs card cleanup what triggers hda_codec_remote() - same treatment is in 1).
--- sound/soc/codecs/hda.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/hda.c +2 -2
@@ -149,7 +149,7 @@ int hda_codec_probe_complete(struct hda_codec *codec) ret =snd_hda_codec_build_controls (codec);if (ret <0 ) {dev_err (&hdev->dev,"unable to create controls %d\n" , ret); - goto out; +return ret; }/* Bus suspended codecs as it does not manage their pm */
@@ -157,7 +157,7 @@ int hda_codec_probe_complete(struct hda_codec *codec)/* rpm was forbidden in snd_hda_codec_device_new() */ snd_hda_codec_set_power_save (codec,2000 );snd_hda_codec_register (codec); -out: +/* Complement pm_runtime_get_sync(bus) in probe */ pm_runtime_mark_last_busy (bus->dev);pm_runtime_put_autosuspend (bus->dev);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 188/508 ASoC: Intel: avs: Fix deadlock when the failing IPC is SET_D0IX
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cezary Rojewski <[email protected]>
[ Upstream commit 9ad1f3cd0d60444c69948854c7e50d2a61b63755 ]
The procedure handling IPC timeouts and EXCEPTION_CAUGHT notification shall cancel any D0IX work before proceeding with DSP recovery. If SET_D0IX called from delayed_work is the failing IPC the procedure will deadlock. Conditionally skip cancelling the work to fix that.
--- sound/soc/intel/avs/ipc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/avs/ipc.c +3 -1
@@ -169,7 +169,9 @@ static void avs_dsp_exception_caught(struct avs_dev *adev, union avs_notify_msgdev_crit (adev->dev,"communication severed, rebooting dsp..\n" ); -cancel_delayed_work_sync (&ipc->d0ix_work); +/* Avoid deadlock as the exception may be the response to SET_D0IX. */ +if (current_work () != &ipc->d0ix_work.work) +cancel_delayed_work_sync (&ipc->d0ix_work); ipc->in_d0ix = false;/* Re-enabled on recovery completion. */ pm_runtime_disable (adev->dev);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 189/508 fix propagation graph breakage by MOVE_MOUNT_SET_GROUP move_mount(2)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit d8cc0362f918d020ca1340d7694f07062dc30f36 ]
9ffb14ef61ba "move_mount: allow to add a mount into an existing group" breaks assertions on ->mnt_share/->mnt_slave. For once, the data structures in question are actually documented.
Documentation/filesystem/sharedsubtree.rst:
All vfsmounts in a peer group have the same ->mnt_master. If it is non-NULL, they form a contiguous (ordered) segment of slave list.
do_set_group() puts a mount into the same place in propagation graph as the old one. As the result, if old mount gets events from somewhere and is not a pure event sink, new one needs to be placed next to the old one in the slave list the old one's on. If it is a pure event sink, we only need to make sure the new one doesn't end up in the middle of some peer group.
"move_mount: allow to add a mount into an existing group" ends up putting the new one in the beginning of list; that's definitely not going to be in the middle of anything, so that's fine for case when old is not marked shared. In case when old one _is_ marked shared (i.e. is not a pure event sink), that breaks the assumptions of propagation graph iterators.
Put the new mount next to the old one on the list - that does the right thing in "old is marked shared" case and is just as correct as the current behaviour if old is not marked shared (kudos to Pavel for pointing that out - my original suggested fix changed behaviour in the "nor marked" case, which complicated things for no good reason).
--- fs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/namespace.c +1 -1
@@ -2809,7 +2809,7 @@ static int do_set_group(struct path *from_path, struct path *to_path)if (IS_MNT_SLAVE (from)) {struct mount *m = from->mnt_master; -list_add (&to->mnt_slave, &m->mnt_slave_list); +list_add (&to->mnt_slave, &from->mnt_slave); to->mnt_master = m; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 190/508 do_change_type(): refuse to operate on unmounted/not ours mounts
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit 12f147ddd6de7382dad54812e65f3f08d05809fc ]
Ensure that propagation settings can only be changed for mounts located in the caller's mount namespace. This change aligns permission checking with the rest of mount(2).
--- fs/namespace.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/namespace.c +4 -0
@@ -2371,6 +2371,10 @@ static int do_change_type(struct path *path, int ms_flags)return -EINVAL ;namespace_lock (); +if (!check_mnt (mnt)) { + err = -EINVAL ; + goto out_unlock; + }if (type ==MS_SHARED ) { err =invent_group_ids (mnt, recurse);if (err)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 191/508 xfs: fix interval filtering in multi-step fsmap queries
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 63ef7a35912dd743cabd65d5bb95891625c0dd46 ]
I noticed a bug in ranged GETFSMAP queries:
# xfs_io -c 'fsmap -vvvv' /opt EXT: DEV BLOCK-RANGE OWNER FILE-OFFSET AG AG-OFFSET TOTAL 0: 8:80 [0..7]: static fs metadata 0 (0..7) 8 <snip> 9: 8:80 [192..223]: 137 0..31 0 (192..223) 32 # xfs_io -c 'fsmap -vvvv -d 208 208' /opt #
That's not right -- we asked what block maps block 208, and we should've received a mapping for inode 137 offset 16. Instead, we get nothing.
The root cause of this problem is a mis-interaction between the fsmap code and how btree ranged queries work. xfs_btree_query_range returns any btree record that overlaps with the query interval, even if the record starts before or ends after the interval. Similarly, GETFSMAP is supposed to return a recordset containing all records that overlap the range queried.
However, it's possible that the recordset is larger than the buffer that the caller provided to convey mappings to userspace. In /that/ case, userspace is supposed to copy the last record returned to fmh_keys[0] and call GETFSMAP again. In this case, we do not want to return mappings that we have already supplied to the caller. The call to xfs_btree_query_range is the same, but now we ignore any records that start before fmh_keys[0].
Unfortunately, we didn't implement the filtering predicate correctly. The predicate should only be called when we're calling back for more records. Accomplish this by setting info->low.rm_blockcount to a nonzero value and ensuring that it is cleared as necessary. As a result, we no longer want to adjust dkeys[0] in the main setup function because that's confusing.
This patch doesn't touch the logdev/rtbitmap backends because they have bigger problems that will be addressed by subsequent patches.
Found via xfs/556 with parent pointers enabled.
--- fs/xfs/xfs_fsmap.c | 67 +++++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 19 deletions(-)
fs/xfs/xfs_fsmap.c +48 -19
@@ -162,7 +162,14 @@ struct xfs_getfsmap_info {xfs_daddr_t next_daddr;/* next daddr we expect */ u64 missing_owner;/* owner of holes */ u32 dev;/* device id */ -struct xfs_rmap_irec low;/* low rmap key */ +/* +* Low rmap key for the query. If low.rm_blockcount is nonzero, this +* is the second (or later) call to retrieve the recordset in pieces. +* xfs_getfsmap_rec_before_start will compare all records retrieved +* by the rmapbt query to filter out any records that start before +* the last record. +*/ +struct xfs_rmap_irec low;struct xfs_rmap_irec high;/* high rmap key */ bool last;/* last extent? */ };
@@ -237,6 +244,17 @@ xfs_getfsmap_format(xfs_fsmap_from_internal (rec, xfm); } +static inline bool +xfs_getfsmap_rec_before_start ( +struct xfs_getfsmap_info *info, +const struct xfs_rmap_irec *rec, +xfs_daddr_t rec_daddr) +{ +if (info->low.rm_blockcount) +return xfs_rmap_compare (rec, &info->low) <0 ; +return false; +} +/* * Format a reverse mapping for getfsmap, having translated rm_startblock * into the appropriate daddr units.
@@ -260,7 +278,7 @@ xfs_getfsmap_helper(* Filter out records that start before our startpoint, if the * caller requested that. */ -if (xfs_rmap_compare (rec, &info->low) <0 ) { +if (xfs_getfsmap_rec_before_start (info, rec, rec_daddr)) { rec_daddr +=XFS_FSB_TO_BB (mp, rec->rm_blockcount);if (info->next_daddr < rec_daddr) info->next_daddr = rec_daddr;
@@ -606,9 +624,27 @@ __xfs_getfsmap_datadev( error =xfs_fsmap_owner_to_rmap (&info->low, &keys[0 ]);if (error)return error; - info->low.rm_blockcount =0 ; + info->low.rm_blockcount =XFS_BB_TO_FSBT (mp, keys[0 ].fmr_length);xfs_getfsmap_set_irec_flags (&info->low, &keys[0 ]); +/* Adjust the low key if we are continuing from where we left off. */ +if (info->low.rm_blockcount ==0 ) { +/* empty */ + }else if (XFS_RMAP_NON_INODE_OWNER (info->low.rm_owner) || + (info->low.rm_flags & (XFS_RMAP_ATTR_FORK | +XFS_RMAP_BMBT_BLOCK | +XFS_RMAP_UNWRITTEN ))) { + info->low.rm_startblock += info->low.rm_blockcount; + info->low.rm_owner =0 ; + info->low.rm_offset =0 ; + + start_fsb += info->low.rm_blockcount; +if (XFS_FSB_TO_DADDR (mp, start_fsb) >= eofs) +return 0 ; + }else { + info->low.rm_offset += info->low.rm_blockcount; + } + info->high.rm_startblock =-1U ; info->high.rm_owner =ULLONG_MAX ; info->high.rm_offset =ULLONG_MAX ;
@@ -659,12 +695,8 @@ __xfs_getfsmap_datadev(* Set the AG low key to the start of the AG prior to * moving on to the next AG. */ -if (pag->pag_agno == start_ag) { - info->low.rm_startblock =0 ; - info->low.rm_owner =0 ; - info->low.rm_offset =0 ; - info->low.rm_flags =0 ; - } +if (pag->pag_agno == start_ag) +memset (&info->low,0 ,sizeof (info->low));/* * If this is the last AG, report any gap at the end of it
@@ -901,21 +933,17 @@ xfs_getfsmap(* blocks could be mapped to several other files/offsets. * According to rmapbt record ordering, the minimal next * possible record for the block range is the next starting -* offset in the same inode. Therefore, bump the file offset to -* continue the search appropriately. For all other low key -* mapping types (attr blocks, metadata), bump the physical -* offset as there can be no other mapping for the same physical -* block range. +* offset in the same inode. Therefore, each fsmap backend bumps +* the file offset to continue the search appropriately. For +* all other low key mapping types (attr blocks, metadata), each +* fsmap backend bumps the physical offset as there can be no +* other mapping for the same physical block range. */ dkeys[0 ] = head->fmh_keys[0 ];if (dkeys[0 ].fmr_flags & (FMR_OF_SPECIAL_OWNER |FMR_OF_EXTENT_MAP )) { - dkeys[0 ].fmr_physical += dkeys[0 ].fmr_length; - dkeys[0 ].fmr_owner =0 ;if (dkeys[0 ].fmr_offset)return -EINVAL ; - }else - dkeys[0 ].fmr_offset += dkeys[0 ].fmr_length; - dkeys[0 ].fmr_length =0 ; + }memset (&dkeys[1 ],0xFF ,sizeof (struct xfs_fsmap ));if (!xfs_getfsmap_check_keys (dkeys, &head->fmh_keys[1 ]))
@@ -960,6 +988,7 @@ xfs_getfsmap( info.dev = handlers[i].dev; info.last = false; info.pag =NULL ; + info.low.rm_blockcount =0 ; error = handlers[i].fn (tp, dkeys, &info);if (error)break ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 192/508 xfs: fix integer overflows in the fsmap rtbitmap and logdev backends
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 7975aba19cba4eba7ff60410f9294c90edc96dcf ]
It's not correct to use the rmap irec structure to hold query key information to query the rtbitmap because the realtime volume can be longer than 2^32 fsblocks in length. Because the rt volume doesn't have allocation groups, introduce a daddr-based record filtering algorithm and compute the rtextent values using 64-bit variables. The same problem exists in the external log device fsmap implementation, so use the same solution to fix it too.
After this patch, all the code that touches info->low and info->high under xfs_getfsmap_logdev and __xfs_getfsmap_rtdev are unnecessary. Cleaning this up will be done in subsequent patches.
--- fs/xfs/xfs_fsmap.c | 90 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 26 deletions(-)
fs/xfs/xfs_fsmap.c +64 -26
@@ -160,6 +160,8 @@ struct xfs_getfsmap_info {struct xfs_buf *agf_bp;/* AGF, for refcount queries */ struct xfs_perag *pag;/* AG info, if applicable */ xfs_daddr_t next_daddr;/* next daddr we expect */ +/* daddr of low fsmap key when we're using the rtbitmap */ +xfs_daddr_t low_daddr;u64 missing_owner;/* owner of holes */ u32 dev;/* device id */ /*
@@ -250,6 +252,8 @@ xfs_getfsmap_rec_before_start( const struct xfs_rmap_irec *rec, xfs_daddr_t rec_daddr) { + if (info->low_daddr != -1ULL) + return rec_daddr < info->low_daddr;if (info->low.rm_blockcount)return xfs_rmap_compare (rec, &info->low) <0 ;return false;
@@ -257,14 +261,16 @@ xfs_getfsmap_rec_before_start(/* * Format a reverse mapping for getfsmap, having translated rm_startblock -* into the appropriate daddr units. +* into the appropriate daddr units. Pass in a nonzero @len_daddr if the +* length could be larger than rm_blockcount in struct xfs_rmap_irec. */ STATIC intxfs_getfsmap_helper (struct xfs_trans *tp,struct xfs_getfsmap_info *info,const struct xfs_rmap_irec *rec, -xfs_daddr_t rec_daddr) +xfs_daddr_t rec_daddr, +xfs_daddr_t len_daddr) {struct xfs_fsmap fmr;struct xfs_mount *mp = tp->t_mountp;
@@ -274,12 +280,15 @@ xfs_getfsmap_helper(if (fatal_signal_pending (current))return -EINTR ; +if (len_daddr ==0 ) + len_daddr =XFS_FSB_TO_BB (mp, rec->rm_blockcount); +/* * Filter out records that start before our startpoint, if the * caller requested that. */ if (xfs_getfsmap_rec_before_start (info, rec, rec_daddr)) { - rec_daddr +=XFS_FSB_TO_BB (mp, rec->rm_blockcount); + rec_daddr += len_daddr;if (info->next_daddr < rec_daddr) info->next_daddr = rec_daddr;return 0 ;
@@ -298,7 +307,7 @@ xfs_getfsmap_helper( info->head->fmh_entries++; - rec_daddr +=XFS_FSB_TO_BB (mp, rec->rm_blockcount); + rec_daddr += len_daddr;if (info->next_daddr < rec_daddr) info->next_daddr = rec_daddr;return 0 ;
@@ -338,7 +347,7 @@ xfs_getfsmap_helper(if (error)return error; fmr.fmr_offset =XFS_FSB_TO_BB (mp, rec->rm_offset); - fmr.fmr_length =XFS_FSB_TO_BB (mp, rec->rm_blockcount); + fmr.fmr_length = len_daddr;if (rec->rm_flags &XFS_RMAP_UNWRITTEN ) fmr.fmr_flags |=FMR_OF_PREALLOC ;if (rec->rm_flags &XFS_RMAP_ATTR_FORK )
@@ -355,7 +364,7 @@ xfs_getfsmap_helper(xfs_getfsmap_format (mp, &fmr, info); out: - rec_daddr +=XFS_FSB_TO_BB (mp, rec->rm_blockcount); + rec_daddr += len_daddr;if (info->next_daddr < rec_daddr) info->next_daddr = rec_daddr;return 0 ;
@@ -376,7 +385,7 @@ xfs_getfsmap_datadev_helper( fsb =XFS_AGB_TO_FSB (mp, cur->bc_ag.pag->pag_agno, rec->rm_startblock); rec_daddr =XFS_FSB_TO_DADDR (mp, fsb); -return xfs_getfsmap_helper (cur->bc_tp, info, rec, rec_daddr); +return xfs_getfsmap_helper (cur->bc_tp, info, rec, rec_daddr,0 ); }/* Transform a bnobt irec into a fsmap */
@@ -400,7 +409,7 @@ xfs_getfsmap_datadev_bnobt_helper( irec.rm_offset =0 ; irec.rm_flags =0 ; -return xfs_getfsmap_helper (cur->bc_tp, info, &irec, rec_daddr); +return xfs_getfsmap_helper (cur->bc_tp, info, &irec, rec_daddr,0 ); }/* Set rmap flags based on the getfsmap flags */
@@ -427,9 +436,13 @@ xfs_getfsmap_logdev( {struct xfs_mount *mp = tp->t_mountp;struct xfs_rmap_irec rmap; +xfs_daddr_t rec_daddr, len_daddr; +xfs_fsblock_t start_fsb;int error;/* Set up search keys */ + start_fsb =XFS_BB_TO_FSBT (mp, + keys[0 ].fmr_physical + keys[0 ].fmr_length); info->low.rm_startblock =XFS_BB_TO_FSBT (mp, keys[0 ].fmr_physical); info->low.rm_offset =XFS_BB_TO_FSBT (mp, keys[0 ].fmr_offset); error =xfs_fsmap_owner_to_rmap (&info->low, keys);
@@ -438,6 +451,10 @@ xfs_getfsmap_logdev( info->low.rm_blockcount =0 ;xfs_getfsmap_set_irec_flags (&info->low, &keys[0 ]); +/* Adjust the low key if we are continuing from where we left off. */ +if (keys[0 ].fmr_length >0 ) + info->low_daddr =XFS_FSB_TO_BB (mp, start_fsb); + error =xfs_fsmap_owner_to_rmap (&info->high, keys +1 );if (error)return error;
@@ -451,7 +468,7 @@ xfs_getfsmap_logdev(trace_xfs_fsmap_low_key (mp, info->dev,NULLAGNUMBER , &info->low);trace_xfs_fsmap_high_key (mp, info->dev,NULLAGNUMBER , &info->high); -if (keys[0 ].fmr_physical >0 ) +if (start_fsb >0 )return 0 ;/* Fabricate an rmap entry for the external log device. */
@@ -461,7 +478,9 @@ xfs_getfsmap_logdev( rmap.rm_offset =0 ; rmap.rm_flags =0 ; -return xfs_getfsmap_helper (tp, info, &rmap,0 ); + rec_daddr =XFS_FSB_TO_BB (mp, rmap.rm_startblock); + len_daddr =XFS_FSB_TO_BB (mp, rmap.rm_blockcount); +return xfs_getfsmap_helper (tp, info, &rmap, rec_daddr, len_daddr); }#ifdef CONFIG_XFS_RT
@@ -475,16 +494,22 @@ xfs_getfsmap_rtdev_rtbitmap_helper( {struct xfs_getfsmap_info *info = priv;struct xfs_rmap_irec irec; -xfs_daddr_t rec_daddr; +xfs_rtblock_t rtbno; +xfs_daddr_t rec_daddr, len_daddr; + + rtbno = rec->ar_startext * mp->m_sb.sb_rextsize; + rec_daddr =XFS_FSB_TO_BB (mp, rtbno); + irec.rm_startblock = rtbno; + + rtbno = rec->ar_extcount * mp->m_sb.sb_rextsize; + len_daddr =XFS_FSB_TO_BB (mp, rtbno); + irec.rm_blockcount = rtbno; - irec.rm_startblock = rec->ar_startext * mp->m_sb.sb_rextsize; - rec_daddr =XFS_FSB_TO_BB (mp, irec.rm_startblock); - irec.rm_blockcount = rec->ar_extcount * mp->m_sb.sb_rextsize; irec.rm_owner =XFS_RMAP_OWN_NULL ;/* "free" */ irec.rm_offset =0 ; irec.rm_flags =0 ; -return xfs_getfsmap_helper (tp, info, &irec, rec_daddr); +return xfs_getfsmap_helper (tp, info, &irec, rec_daddr, len_daddr); }/* Execute a getfsmap query against the realtime device. */
@@ -493,23 +518,26 @@ __xfs_getfsmap_rtdev(struct xfs_trans *tp, const struct xfs_fsmap *keys, int (*query_fn)(struct xfs_trans *, -struct xfs_getfsmap_info *), +struct xfs_getfsmap_info *, +xfs_rtblock_t start_rtb, +xfs_rtblock_t end_rtb), struct xfs_getfsmap_info *info) { struct xfs_mount *mp = tp->t_mountp; -xfs_fsblock_t start_fsb; -xfs_fsblock_t end_fsb; +xfs_rtblock_t start_rtb; +xfs_rtblock_t end_rtb;uint64_t eofs;int error =0 ; eofs =XFS_FSB_TO_BB (mp, mp->m_sb.sb_rblocks);if (keys[0 ].fmr_physical >= eofs)return 0 ; - start_fsb =XFS_BB_TO_FSBT (mp, keys[0 ].fmr_physical); - end_fsb =XFS_BB_TO_FSB (mp,min (eofs -1 , keys[1 ].fmr_physical)); + start_rtb =XFS_BB_TO_FSBT (mp, + keys[0 ].fmr_physical + keys[0 ].fmr_length); + end_rtb =XFS_BB_TO_FSB (mp,min (eofs -1 , keys[1 ].fmr_physical));/* Set up search keys */ - info->low.rm_startblock = start_fsb; + info->low.rm_startblock = start_rtb; error =xfs_fsmap_owner_to_rmap (&info->low, &keys[0 ]);if (error)return error;
@@ -517,7 +545,14 @@ __xfs_getfsmap_rtdev( info->low.rm_blockcount =0 ;xfs_getfsmap_set_irec_flags (&info->low, &keys[0 ]); - info->high.rm_startblock = end_fsb; +/* Adjust the low key if we are continuing from where we left off. */ +if (keys[0 ].fmr_length >0 ) { + info->low_daddr =XFS_FSB_TO_BB (mp, start_rtb); +if (info->low_daddr >= eofs) +return 0 ; + } + + info->high.rm_startblock = end_rtb; error =xfs_fsmap_owner_to_rmap (&info->high, &keys[1 ]);if (error)return error;
@@ -528,14 +563,16 @@ __xfs_getfsmap_rtdev(trace_xfs_fsmap_low_key (mp, info->dev,NULLAGNUMBER , &info->low);trace_xfs_fsmap_high_key (mp, info->dev,NULLAGNUMBER , &info->high); -return query_fn (tp, info); +return query_fn (tp, info, start_rtb, end_rtb); }/* Actually query the realtime bitmap. */ STATIC intxfs_getfsmap_rtdev_rtbitmap_query (struct xfs_trans *tp, -struct xfs_getfsmap_info *info) +struct xfs_getfsmap_info *info, +xfs_rtblock_t start_rtb, +xfs_rtblock_t end_rtb) {struct xfs_rtalloc_rec alow = {0 };struct xfs_rtalloc_rec ahigh = {0 };
@@ -548,8 +585,8 @@ xfs_getfsmap_rtdev_rtbitmap_query(* Set up query parameters to return free rtextents covering the range * we want. */ - alow.ar_startext = info->low.rm_startblock; - ahigh.ar_startext = info->high.rm_startblock; + alow.ar_startext = start_rtb; + ahigh.ar_startext = end_rtb;do_div (alow.ar_startext, mp->m_sb.sb_rextsize);if (do_div (ahigh.ar_startext, mp->m_sb.sb_rextsize)) ahigh.ar_startext++;
@@ -988,6 +1025,7 @@ xfs_getfsmap( info.dev = handlers[i].dev; info.last = false; info.pag =NULL ; + info.low_daddr =-1ULL ; info.low.rm_blockcount =0 ; error = handlers[i].fn (tp, dkeys, &info);if (error)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 193/508 xfs: fix getfsmap reporting past the last rt extent
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit d898137d789cac9ebe5eed9957e4cf25122ca524 ]
The realtime section ends at the last rt extent. If the user configures the rt geometry with an extent size that is not an integer factor of the number of rt blocks, it's possible for there to be rt blocks past the end of the last rt extent. These tail blocks cannot ever be allocated and will cause corruption reports if the last extent coincides with the end of an rt bitmap block, so do not report consider them for the GETFSMAP output.
--- fs/xfs/xfs_fsmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_fsmap.c +1 -1
@@ -529,7 +529,7 @@ __xfs_getfsmap_rtdev(uint64_t eofs;int error =0 ; - eofs =XFS_FSB_TO_BB (mp, mp->m_sb.sb_rblocks); + eofs =XFS_FSB_TO_BB (mp, mp->m_sb.sb_rextents * mp->m_sb.sb_rextsize);if (keys[0 ].fmr_physical >= eofs)return 0 ; start_rtb = XFS_BB_TO_FSBT(mp,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 194/508 xfs: clean up the rtbitmap fsmap backend
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit f045dd00328d78f25d64913285f4547f772d13e2 ]
The rtbitmap fsmap backend doesn't query the rmapbt, so it's wasteful to spend time initializing the rmap_irec objects. Worse yet, the logic to query the rtbitmap is spread across three separate functions, which is unnecessarily difficult to follow.
Compute the start rtextent that we want from keys[0] directly and combine the functions to avoid passing parameters around everywhere, and consolidate all the logic into a single function. At one point many years ago I intended to use __xfs_getfsmap_rtdev as the launching point for realtime rmapbt queries, but this hasn't been the case for a long time.
--- fs/xfs/xfs_fsmap.c | 62 +++++++--------------------------------------- fs/xfs/xfs_trace.h | 25 +++++++++++++++++++ 2 files changed, 34 insertions(+), 53 deletions(-)
fs/xfs/xfs_fsmap.c +9 -53
@@ -512,22 +512,21 @@ xfs_getfsmap_rtdev_rtbitmap_helper(return xfs_getfsmap_helper (tp, info, &irec, rec_daddr, len_daddr); } -/* Execute a getfsmap query against the realtime device. */ +/* Execute a getfsmap query against the realtime device rtbitmap. */ STATIC int -__xfs_getfsmap_rtdev ( +xfs_getfsmap_rtdev_rtbitmap (struct xfs_trans *tp,const struct xfs_fsmap *keys, -int (*query_fn)(struct xfs_trans *, -struct xfs_getfsmap_info *, -xfs_rtblock_t start_rtb, -xfs_rtblock_t end_rtb),struct xfs_getfsmap_info *info) { + +struct xfs_rtalloc_rec alow = {0 }; +struct xfs_rtalloc_rec ahigh = {0 };struct xfs_mount *mp = tp->t_mountp;xfs_rtblock_t start_rtb;xfs_rtblock_t end_rtb;uint64_t eofs; -int error =0 ; +int error; eofs =XFS_FSB_TO_BB (mp, mp->m_sb.sb_rextents * mp->m_sb.sb_rextsize);if (keys[0 ].fmr_physical >= eofs)
@@ -536,14 +535,7 @@ __xfs_getfsmap_rtdev( keys[0].fmr_physical + keys[0].fmr_length); end_rtb =XFS_BB_TO_FSB (mp,min (eofs -1 , keys[1 ].fmr_physical)); -/* Set up search keys */ - info->low.rm_startblock = start_rtb; - error =xfs_fsmap_owner_to_rmap (&info->low, &keys[0 ]); -if (error) -return error; - info->low.rm_offset =XFS_BB_TO_FSBT (mp, keys[0 ].fmr_offset); - info->low.rm_blockcount =0 ; -xfs_getfsmap_set_irec_flags (&info->low, &keys[0 ]); + info->missing_owner =XFS_FMR_OWN_UNKNOWN ;/* Adjust the low key if we are continuing from where we left off. */ if (keys[0 ].fmr_length >0 ) {
@@ -552,32 +544,8 @@ __xfs_getfsmap_rtdev(return 0 ; } - info->high.rm_startblock = end_rtb; - error =xfs_fsmap_owner_to_rmap (&info->high, &keys[1 ]); -if (error) -return error; - info->high.rm_offset =XFS_BB_TO_FSBT (mp, keys[1 ].fmr_offset); - info->high.rm_blockcount =0 ; -xfs_getfsmap_set_irec_flags (&info->high, &keys[1 ]); - -trace_xfs_fsmap_low_key (mp, info->dev,NULLAGNUMBER , &info->low); -trace_xfs_fsmap_high_key (mp, info->dev,NULLAGNUMBER , &info->high); - -return query_fn (tp, info, start_rtb, end_rtb); -} - -/* Actually query the realtime bitmap. */ -STATIC int -xfs_getfsmap_rtdev_rtbitmap_query ( -struct xfs_trans *tp, -struct xfs_getfsmap_info *info, -xfs_rtblock_t start_rtb, -xfs_rtblock_t end_rtb) -{ -struct xfs_rtalloc_rec alow = {0 }; -struct xfs_rtalloc_rec ahigh = {0 }; -struct xfs_mount *mp = tp->t_mountp; -int error; +trace_xfs_fsmap_low_key_linear (mp, info->dev, start_rtb); +trace_xfs_fsmap_high_key_linear (mp, info->dev, end_rtb);xfs_ilock (mp->m_rbmip,XFS_ILOCK_SHARED );
@@ -609,18 +577,6 @@ xfs_getfsmap_rtdev_rtbitmap_query(xfs_iunlock (mp->m_rbmip,XFS_ILOCK_SHARED ); return error; } - -/* Execute a getfsmap query against the realtime device rtbitmap. */ -STATIC int -xfs_getfsmap_rtdev_rtbitmap ( -struct xfs_trans *tp, -const struct xfs_fsmap *keys, -struct xfs_getfsmap_info *info) -{ - info->missing_owner =XFS_FMR_OWN_UNKNOWN ; -return __xfs_getfsmap_rtdev (tp, keys, xfs_getfsmap_rtdev_rtbitmap_query, - info); -}#endif /* CONFIG_XFS_RT */ /* Execute a getfsmap query against the regular data device. */
fs/xfs/xfs_trace.h +25 -0
@@ -3491,6 +3491,31 @@ DEFINE_FSMAP_EVENT(xfs_fsmap_low_key);DEFINE_FSMAP_EVENT (xfs_fsmap_high_key);DEFINE_FSMAP_EVENT (xfs_fsmap_mapping); +DECLARE_EVENT_CLASS (xfs_fsmap_linear_class, + TP_PROTO(struct xfs_mount *mp, u32 keydev, uint64_t bno), +TP_ARGS (mp, keydev, bno), +TP_STRUCT__entry ( + __field(dev_t, dev) + __field(dev_t, keydev) +__field (xfs_fsblock_t, bno) + ), +TP_fast_assign ( + __entry->dev = mp->m_super->s_dev; + __entry->keydev = new_decode_dev(keydev); + __entry->bno = bno; + ), +TP_printk ("dev %d:%d keydev %d:%d bno 0x%llx" , +MAJOR (__entry->dev),MINOR (__entry->dev), +MAJOR (__entry->keydev),MINOR (__entry->keydev), + __entry->bno) +) +#define DEFINE_FSMAP_LINEAR_EVENT (name) \ +DEFINE_EVENT(xfs_fsmap_linear_class, name, \ + TP_PROTO(struct xfs_mount *mp, u32 keydev, uint64_t bno), \ + TP_ARGS(mp, keydev, bno)) +DEFINE_FSMAP_LINEAR_EVENT (xfs_fsmap_low_key_linear); +DEFINE_FSMAP_LINEAR_EVENT (xfs_fsmap_high_key_linear); + DECLARE_EVENT_CLASS(xfs_getfsmap_class, TP_PROTO(struct xfs_mount *mp, struct xfs_fsmap *fsmap), TP_ARGS(mp, fsmap),
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 195/508 xfs: fix logdev fsmap query result filtering
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit a949a1c2a198e048630a8b0741a99b85a5d88136 ]
The external log device fsmap backend doesn't have an rmapbt to query, so it's wasteful to spend time initializing the rmap_irec objects. Worse yet, the log could (someday) be longer than 2^32 fsblocks, so using the rmap irec structure will result in integer overflows.
Fix this mess by computing the start address that we want from keys[0] directly, and use the daddr-based record filtering algorithm that we also use for rtbitmap queries.
--- fs/xfs/xfs_fsmap.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-)
fs/xfs/xfs_fsmap.c +8 -22
@@ -437,36 +437,22 @@ xfs_getfsmap_logdev(struct xfs_mount *mp = tp->t_mountp;struct xfs_rmap_irec rmap;xfs_daddr_t rec_daddr, len_daddr; -xfs_fsblock_t start_fsb; -int error; +xfs_fsblock_t start_fsb, end_fsb; +uint64_t eofs; -/* Set up search keys */ + eofs =XFS_FSB_TO_BB (mp, mp->m_sb.sb_logblocks); +if (keys[0 ].fmr_physical >= eofs) +return 0 ; start_fsb =XFS_BB_TO_FSBT (mp, keys[0 ].fmr_physical + keys[0 ].fmr_length); - info->low.rm_startblock =XFS_BB_TO_FSBT (mp, keys[0 ].fmr_physical); - info->low.rm_offset =XFS_BB_TO_FSBT (mp, keys[0 ].fmr_offset); - error =xfs_fsmap_owner_to_rmap (&info->low, keys); -if (error) -return error; - info->low.rm_blockcount =0 ; -xfs_getfsmap_set_irec_flags (&info->low, &keys[0 ]); + end_fsb =XFS_BB_TO_FSB (mp,min (eofs -1 , keys[1 ].fmr_physical));/* Adjust the low key if we are continuing from where we left off. */ if (keys[0 ].fmr_length >0 ) info->low_daddr =XFS_FSB_TO_BB (mp, start_fsb); - error =xfs_fsmap_owner_to_rmap (&info->high, keys +1 ); -if (error) -return error; - info->high.rm_startblock =-1U ; - info->high.rm_owner =ULLONG_MAX ; - info->high.rm_offset =ULLONG_MAX ; - info->high.rm_blockcount =0 ; - info->high.rm_flags =XFS_RMAP_KEY_FLAGS |XFS_RMAP_REC_FLAGS ; - info->missing_owner =XFS_FMR_OWN_FREE ; - -trace_xfs_fsmap_low_key (mp, info->dev,NULLAGNUMBER , &info->low); -trace_xfs_fsmap_high_key (mp, info->dev,NULLAGNUMBER , &info->high); +trace_xfs_fsmap_low_key_linear (mp, info->dev, start_fsb); +trace_xfs_fsmap_high_key_linear (mp, info->dev, end_fsb);if (start_fsb >0 )return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 196/508 xfs: validate fsmap offsets specified in the query keys
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 3ee9351e74907fe3acb0721c315af25b05dc87da ]
Improve the validation of the fsmap offset fields in the query keys and move the validation to the top of the function now that we have pushed the low key adjustment code downwards.
Also fix some indenting issues that aren't worth a separate patch.
--- fs/xfs/xfs_fsmap.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
fs/xfs/xfs_fsmap.c +19 -11
@@ -802,6 +802,19 @@ xfs_getfsmap_check_keys( struct xfs_fsmap *low_key, struct xfs_fsmap *high_key) { +if (low_key->fmr_flags & (FMR_OF_SPECIAL_OWNER |FMR_OF_EXTENT_MAP )) { +if (low_key->fmr_offset) +return false; + } +if (high_key->fmr_flags !=-1U && + (high_key->fmr_flags & (FMR_OF_SPECIAL_OWNER | +FMR_OF_EXTENT_MAP ))) { +if (high_key->fmr_offset && high_key->fmr_offset !=-1ULL ) +return false; + } +if (high_key->fmr_length && high_key->fmr_length !=-1ULL ) +return false; +if (low_key->fmr_device > high_key->fmr_device)return false;if (low_key->fmr_device < high_key->fmr_device)
@@ -845,15 +858,15 @@ xfs_getfsmap_check_keys(* ---------------- * There are multiple levels of keys and counters at work here: * xfs_fsmap_head.fmh_keys -- low and high fsmap keys passed in; -* these reflect fs-wide sector addrs. +* these reflect fs-wide sector addrs. * dkeys -- fmh_keys used to query each device; -* these are fmh_keys but w/ the low key -* bumped up by fmr_length. +* these are fmh_keys but w/ the low key +* bumped up by fmr_length. * xfs_getfsmap_info.next_daddr -- next disk addr we expect to see; this * is how we detect gaps in the fsmap records and report them. * xfs_getfsmap_info.low/high -- per-AG low/high keys computed from -* dkeys; used to query the metadata. +* dkeys; used to query the metadata. */ int xfs_getfsmap(
@@ -874,6 +887,8 @@ xfs_getfsmap(if (!xfs_getfsmap_is_valid_device (mp, &head->fmh_keys[0 ]) || !xfs_getfsmap_is_valid_device (mp, &head->fmh_keys[1 ]))return -EINVAL ; +if (!xfs_getfsmap_check_keys (&head->fmh_keys[0 ], &head->fmh_keys[1 ])) +return -EINVAL ; use_rmap =xfs_has_rmapbt (mp) &&has_capability_noaudit (current,CAP_SYS_ADMIN );
@@ -919,15 +934,8 @@ xfs_getfsmap(* other mapping for the same physical block range. */ dkeys[0 ] = head->fmh_keys[0 ]; -if (dkeys[0 ].fmr_flags & (FMR_OF_SPECIAL_OWNER |FMR_OF_EXTENT_MAP )) { -if (dkeys[0 ].fmr_offset) -return -EINVAL ; - }memset (&dkeys[1 ],0xFF ,sizeof (struct xfs_fsmap )); -if (!xfs_getfsmap_check_keys (dkeys, &head->fmh_keys[1 ])) -return -EINVAL ; - info.next_daddr = head->fmh_keys[0 ].fmr_physical + head->fmh_keys[0 ].fmr_length; info.fsmap_recs = fsmap_recs;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 197/508 xfs: fix xfs_btree_query_range callers to initialize btree rec fully
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 75dc0345312221971903b2e28279b7e24b7dbb1b ]
Use struct initializers to ensure that the xfs_btree_irecs passed into the query_range function are completely initialized. No functional changes, just closing some sloppy hygiene.
--- fs/xfs/libxfs/xfs_alloc.c | 10 +++------- fs/xfs/libxfs/xfs_refcount.c | 13 +++++++------ fs/xfs/libxfs/xfs_rmap.c | 10 +++------- 3 files changed, 13 insertions(+), 20 deletions(-)
fs/xfs/libxfs/xfs_alloc.c +3 -7
@@ -3545,15 +3545,11 @@ xfs_alloc_query_range(xfs_alloc_query_range_fn fn, void *priv) { - union xfs_btree_irec low_brec; -union xfs_btree_irec high_brec; -struct xfs_alloc_query_range_info query; + union xfs_btree_irec low_brec = { .a = *low_rec }; +union xfs_btree_irec high_brec = { .a = *high_rec }; +struct xfs_alloc_query_range_info query = { .priv = priv, .fn = fn };ASSERT (cur->bc_btnum ==XFS_BTNUM_BNO ); - low_brec.a = *low_rec; - high_brec.a = *high_rec; - query.priv = priv; - query.fn = fn;return xfs_btree_query_range (cur, &low_brec, &high_brec, xfs_alloc_query_range_helper, &query); }
fs/xfs/libxfs/xfs_refcount.c +7 -6
@@ -1903,8 +1903,13 @@ xfs_refcount_recover_cow_leftovers(struct xfs_buf *agbp;struct xfs_refcount_recovery *rr, *n;struct list_head debris; -union xfs_btree_irec low; -union xfs_btree_irec high; +union xfs_btree_irec low = { + .rc.rc_domain =XFS_REFC_DOMAIN_COW , + }; +union xfs_btree_irec high = { + .rc.rc_domain =XFS_REFC_DOMAIN_COW , + .rc.rc_startblock =-1U , + };xfs_fsblock_t fsb;int error;
@@ -1935,10 +1940,6 @@ xfs_refcount_recover_cow_leftovers( cur =xfs_refcountbt_init_cursor (mp, tp, agbp, pag);/* Find all the leftover CoW staging extents. */ -memset (&low,0 ,sizeof (low)); -memset (&high,0 ,sizeof (high)); - low.rc.rc_domain = high.rc.rc_domain =XFS_REFC_DOMAIN_COW ; - high.rc.rc_startblock =-1U ; error =xfs_btree_query_range (cur, &low, &high, xfs_refcount_recover_extent, &debris);xfs_btree_del_cursor (cur, error);
fs/xfs/libxfs/xfs_rmap.c +3 -7
@@ -2337,14 +2337,10 @@ xfs_rmap_query_range(xfs_rmap_query_range_fn fn, void *priv) { - union xfs_btree_irec low_brec; -union xfs_btree_irec high_brec; -struct xfs_rmap_query_range_info query; + union xfs_btree_irec low_brec = { .r = *low_rec }; +union xfs_btree_irec high_brec = { .r = *high_rec }; +struct xfs_rmap_query_range_info query = { .priv = priv, .fn = fn }; - low_brec.r = *low_rec; - high_brec.r = *high_rec; - query.priv = priv; - query.fn = fn;return xfs_btree_query_range (cur, &low_brec, &high_brec, xfs_rmap_query_range_helper, &query); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 198/508 xfs: fix an agbno overflow in __xfs_getfsmap_datadev
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit cfa2df68b7ceb49ac9eb2d295ab0c5974dbf17e7 ]
Dave Chinner reported that xfs/273 fails if the AG size happens to be an exact power of two. I traced this to an agbno integer overflow when the current GETFSMAP call is a continuation of a previous GETFSMAP call, and the last record returned was non-shareable space at the end of an AG.
__xfs_getfsmap_datadev sets up a data device query by converting the incoming fmr_physical into an xfs_fsblock_t and cracking it into an agno and agbno pair. In the (failing) case of where fmr_blockcount of the low key is nonzero and the record was for a non-shareable extent, it will add fmr_blockcount to start_fsb and info->low.rm_startblock.
If the low key was actually the last record for that AG, then this addition causes info->low.rm_startblock to point beyond EOAG. When the rmapbt range query starts, it'll return an empty set, and fsmap moves on to the next AG.
Or so I thought. Remember how we added to start_fsb?
If agsize < 1<<agblklog, start_fsb points to the same AG as the original fmr_physical from the low key. We run the rmapbt query, which returns nothing, so getfsmap zeroes info->low and moves on to the next AG.
If agsize == 1<<agblklog, start_fsb now points to the next AG. We run the rmapbt query on the next AG with the excessively large rm_startblock. If this next AG is actually the last AG, we'll set info->high to EOFS (which is now has a lower rm_startblock than info->low), and the ranged btree query code will return -EINVAL. If it's not the last AG, we ignore all records for the intermediate AGs.
Oops.
Fix this by decoding start_fsb into agno and agbno only after making adjustments to start_fsb. This means that info->low.rm_startblock will always be set to a valid agbno, and we always start the rmapbt iteration in the correct AG.
While we're at it, fix the predicate for determining if an fsmap record represents non-shareable space to include file data on pre-reflink filesystems.
--- fs/xfs/xfs_fsmap.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
fs/xfs/xfs_fsmap.c +18 -7
@@ -565,6 +565,19 @@ xfs_getfsmap_rtdev_rtbitmap( }#endif /* CONFIG_XFS_RT */ +static inline bool +rmap_not_shareable (struct xfs_mount *mp,const struct xfs_rmap_irec *r) +{ +if (!xfs_has_reflink (mp)) +return true; +if (XFS_RMAP_NON_INODE_OWNER (r->rm_owner)) +return true; +if (r->rm_flags & (XFS_RMAP_ATTR_FORK |XFS_RMAP_BMBT_BLOCK | +XFS_RMAP_UNWRITTEN )) +return true; +return false; +} +/* Execute a getfsmap query against the regular data device. */ STATIC int __xfs_getfsmap_datadev(
@@ -598,7 +611,6 @@ __xfs_getfsmap_datadev(* low to the fsmap low key and max out the high key to the end * of the AG. */ - info->low.rm_startblock =XFS_FSB_TO_AGBNO (mp, start_fsb); info->low.rm_offset =XFS_BB_TO_FSBT (mp, keys[0 ].fmr_offset); error =xfs_fsmap_owner_to_rmap (&info->low, &keys[0 ]);if (error)
@@ -608,12 +620,9 @@ __xfs_getfsmap_datadev(/* Adjust the low key if we are continuing from where we left off. */ if (info->low.rm_blockcount ==0 ) { -/* empty */ - }else if (XFS_RMAP_NON_INODE_OWNER (info->low.rm_owner) || - (info->low.rm_flags & (XFS_RMAP_ATTR_FORK | -XFS_RMAP_BMBT_BLOCK | -XFS_RMAP_UNWRITTEN ))) { - info->low.rm_startblock += info->low.rm_blockcount; +/* No previous record from which to continue */ + }else if (rmap_not_shareable (mp, &info->low)) { +/* Last record seen was an unshareable extent */ info->low.rm_owner =0 ; info->low.rm_offset =0 ;
@@ -621,8 +630,10 @@ __xfs_getfsmap_datadev(if (XFS_FSB_TO_DADDR (mp, start_fsb) >= eofs)return 0 ; }else { +/* Last record seen was a shareable file data extent */ info->low.rm_offset += info->low.rm_blockcount; } + info->low.rm_startblock =XFS_FSB_TO_AGBNO (mp, start_fsb); info->high.rm_startblock =-1U ; info->high.rm_owner =ULLONG_MAX ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 199/508 xfs: fix the contact address for the sysfs ABI documentation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
[ Upstream commit 9ff4490e2ab364ec433f15668ef3f5edfb53feca ]
oss.sgi.com is long dead, refer to the current linux-xfs list instead.
--- Documentation/ABI/testing/sysfs-fs-xfs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/ABI/testing/sysfs-fs-xfs +4 -4
@@ -1,7 +1,7 @@ What: /sys/fs/xfs/<disk>/log/log_head_lsn Date: July 2014 KernelVersion: 3.17 -Contact: [email protected] +Contact: [email protected] Description: The log sequence number (LSN) of the current head of the log. The LSN is exported in "cycle:basic block" format.
@@ -10,7 +10,7 @@ Users: xfstests What: /sys/fs/xfs/<disk>/log/log_tail_lsn Date: July 2014 KernelVersion: 3.17 -Contact: [email protected] +Contact: [email protected] Description: The log sequence number (LSN) of the current tail of the log. The LSN is exported in "cycle:basic block" format.
@@ -18,7 +18,7 @@ Description: What: /sys/fs/xfs/<disk>/log/reserve_grant_head Date: July 2014 KernelVersion: 3.17 -Contact: [email protected] +Contact: [email protected] Description: The current state of the log reserve grant head. It represents the total log reservation of all currently
@@ -29,7 +29,7 @@ Users: xfstests What: /sys/fs/xfs/<disk>/log/write_grant_head Date: July 2014 KernelVersion: 3.17 -Contact: [email protected] +Contact: [email protected] Description: The current state of the log write grant head. It represents the total log reservation of all currently
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 200/508 xfs: verify buffer, inode, and dquot items every tx commit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 150bb10a28b9c8709ae227fc898d9cf6136faa1e ]
generic/388 has an annoying tendency to fail like this during log recovery:
XFS (sda4): Unmounting Filesystem 435fe39b-82b6-46ef-be56-819499585130 XFS (sda4): Mounting V5 Filesystem 435fe39b-82b6-46ef-be56-819499585130 XFS (sda4): Starting recovery (logdev: internal)
00000000: 49 4e 81 b6 03 02 00 00 00 00 00 07 00 00 00 07 IN.............. 00000010: 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 10 ................ 00000020: 35 9a 8b c1 3e 6e 81 00 35 9a 8b c1 3f dc b7 00 5...>n..5...?... 00000030: 35 9a 8b c1 3f dc b7 00 00 00 00 00 00 3c 86 4f 5...?........<.O 00000040: 00 00 00 00 00 00 02 f3 00 00 00 00 00 00 00 00 ................ 00000050: 00 00 1f 01 00 00 00 00 00 00 00 02 b2 74 c9 0b .............t.. 00000060: ff ff ff ff d7 45 73 10 00 00 00 00 00 00 00 2d .....Es........- 00000070: 00 00 07 92 00 01 fe 30 00 00 00 00 00 00 00 1a .......0........ 00000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00000090: 35 9a 8b c1 3b 55 0c 00 00 00 00 00 04 27 b2 d1 5...;U.......'.. 000000a0: 43 5f e3 9b 82 b6 46 ef be 56 81 94 99 58 51 30 C_....F..V...XQ0 XFS (sda4): Internal error Bad dinode after recovery at line 539 of file fs/xfs/xfs_inode_item_recover.c. Caller xlog_recover_items_pass2+0x4e/0xc0 [xfs] CPU: 0 PID: 2189311 Comm: mount Not tainted 6.9.0-rc4-djwx #rc4 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20171121_152543-x86-ol7-builder-01.us.oracle.com-4.el7.1 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x4f/0x60 xfs_corruption_error+0x90/0xa0 xlog_recover_inode_commit_pass2+0x5f1/0xb00 xlog_recover_items_pass2+0x4e/0xc0 xlog_recover_commit_trans+0x2db/0x350 xlog_recovery_process_trans+0xab/0xe0 xlog_recover_process_data+0xa7/0x130 xlog_do_recovery_pass+0x398/0x840 xlog_do_log_recovery+0x62/0xc0 xlog_do_recover+0x34/0x1d0 xlog_recover+0xe9/0x1a0 xfs_log_mount+0xff/0x260 xfs_mountfs+0x5d9/0xb60 xfs_fs_fill_super+0x76b/0xa30 get_tree_bdev+0x124/0x1d0 vfs_get_tree+0x17/0xa0 path_mount+0x72b/0xa90 __x64_sys_mount+0x112/0x150 do_syscall_64+0x49/0x100 entry_SYSCALL_64_after_hwframe+0x4b/0x53 </TASK>
XFS (sda4): Corruption detected. Unmount and run xfs_repair
XFS (sda4): Metadata corruption detected at xfs_dinode_verify.part.0+0x739/0x920 [xfs], inode 0x427b2d1 XFS (sda4): Filesystem has been shut down due to log error (0x2).
XFS (sda4): Please unmount the filesystem and rectify the problem(s).
XFS (sda4): log mount/recovery failed: error -117
XFS (sda4): log mount failed
This inode log item recovery failing the dinode verifier after replaying the contents of the inode log item into the ondisk inode. Looking back into what the kernel was doing at the time of the fs shutdown, a thread was in the middle of running a series of transactions, each of which committed changes to the inode.
At some point in the middle of that chain, an invalid (at least according to the verifier) change was committed. Had the filesystem not shut down in the middle of the chain, a subsequent transaction would have corrected the invalid state and nobody would have noticed. But that's not what happened here. Instead, the invalid inode state was committed to the ondisk log, so log recovery tripped over it.
The actual defect here was an overzealous inode verifier, which was fixed in a separate patch. This patch adds some transaction precommit functions for CONFIG_XFS_DEBUG=y mode so that we can detect these kinds of transient errors at transaction commit time, where it's much easier to find the root cause.
--- fs/xfs/Kconfig | 12 ++++++++++++ fs/xfs/xfs.h | 4 ++++ fs/xfs/xfs_buf_item.c | 32 ++++++++++++++++++++++++++++++++ fs/xfs/xfs_dquot_item.c | 31 +++++++++++++++++++++++++++++++ fs/xfs/xfs_inode_item.c | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+)
fs/xfs/Kconfig +12 -0
@@ -154,6 +154,18 @@ config XFS_DEBUG Say N unless you are an XFS developer, or you play one on TV. +config XFS_DEBUG_EXPENSIVE + bool "XFS expensive debugging checks" + depends on XFS_FS && XFS_DEBUG + help + Say Y here to get an XFS build with expensive debugging checks + enabled. These checks may affect performance significantly. + + Note that the resulting code will be HUGER and SLOWER, and probably + not useful unless you are debugging a particular problem. + + Say N unless you are an XFS developer, or you play one on TV. + config XFS_ASSERT_FATAL bool "XFS fatal asserts" default y
fs/xfs/xfs.h +4 -0
@@ -10,6 +10,10 @@#define DEBUG 1#endif +#ifdef CONFIG_XFS_DEBUG_EXPENSIVE +#define DEBUG_EXPENSIVE 1 +#endif +#ifdef CONFIG_XFS_ASSERT_FATAL #define XFS_ASSERT_FATAL 1#endif
fs/xfs/xfs_buf_item.c +32 -0
@@ -22,6 +22,7 @@#include "xfs_trace.h" #include "xfs_log.h" #include "xfs_log_priv.h" +#include "xfs_error.h" struct kmem_cache *xfs_buf_item_cache;
@@ -781,8 +782,39 @@ xfs_buf_item_committed(return lsn; } +#ifdef DEBUG_EXPENSIVE +static int +xfs_buf_item_precommit ( +struct xfs_trans *tp, +struct xfs_log_item *lip) +{ +struct xfs_buf_log_item *bip =BUF_ITEM (lip); +struct xfs_buf *bp = bip->bli_buf; +struct xfs_mount *mp = bp->b_mount; +xfs_failaddr_t fa; + +if (!bp->b_ops || !bp->b_ops->verify_struct) +return 0 ; +if (bip->bli_flags &XFS_BLI_STALE ) +return 0 ; + + fa = bp->b_ops->verify_struct (bp); +if (fa) { +xfs_buf_verifier_error (bp, -EFSCORRUPTED , bp->b_ops->name, + bp->b_addr,BBTOB (bp->b_length), fa); +xfs_force_shutdown (mp,SHUTDOWN_CORRUPT_INCORE ); +ASSERT (fa ==NULL ); + } + +return 0 ; +} +#else +# define xfs_buf_item_precommit NULL +#endif +static const struct xfs_item_ops xfs_buf_item_ops = { .iop_size = xfs_buf_item_size, + .iop_precommit = xfs_buf_item_precommit, .iop_format = xfs_buf_item_format, .iop_pin = xfs_buf_item_pin, .iop_unpin = xfs_buf_item_unpin,
fs/xfs/xfs_dquot_item.c +31 -0
@@ -17,6 +17,7 @@#include "xfs_trans_priv.h" #include "xfs_qm.h" #include "xfs_log.h" +#include "xfs_error.h" static inline struct xfs_dq_logitem *DQUOT_ITEM (struct xfs_log_item *lip) {
@@ -193,8 +194,38 @@ xfs_qm_dquot_logitem_committing(return xfs_qm_dquot_logitem_release (lip); } +#ifdef DEBUG_EXPENSIVE +static int +xfs_qm_dquot_logitem_precommit ( +struct xfs_trans *tp, +struct xfs_log_item *lip) +{ +struct xfs_dquot *dqp =DQUOT_ITEM (lip)->qli_dquot; +struct xfs_mount *mp = dqp->q_mount; +struct xfs_disk_dquot ddq = { }; +xfs_failaddr_t fa; + +xfs_dquot_to_disk (&ddq, dqp); + fa =xfs_dquot_verify (mp, &ddq, dqp->q_id); +if (fa) { +XFS_CORRUPTION_ERROR ("Bad dquot during logging" , +XFS_ERRLEVEL_LOW , mp, &ddq,sizeof (ddq)); +xfs_alert (mp, +"Metadata corruption detected at %pS, dquot 0x%x" , + fa, dqp->q_id); +xfs_force_shutdown (mp,SHUTDOWN_CORRUPT_INCORE ); +ASSERT (fa ==NULL ); + } + +return 0 ; +} +#else +# define xfs_qm_dquot_logitem_precommit NULL +#endif +static const struct xfs_item_ops xfs_dquot_item_ops = { .iop_size = xfs_qm_dquot_logitem_size, + .iop_precommit = xfs_qm_dquot_logitem_precommit, .iop_format = xfs_qm_dquot_logitem_format, .iop_pin = xfs_qm_dquot_logitem_pin, .iop_unpin = xfs_qm_dquot_logitem_unpin,
fs/xfs/xfs_inode_item.c +32 -0
@@ -36,6 +36,36 @@ xfs_inode_item_sort(return INODE_ITEM (lip)->ili_inode->i_ino; } +#ifdef DEBUG_EXPENSIVE +static void +xfs_inode_item_precommit_check ( +struct xfs_inode *ip) +{ +struct xfs_mount *mp = ip->i_mount; +struct xfs_dinode *dip; +xfs_failaddr_t fa; + + dip =kzalloc (mp->m_sb.sb_inodesize,GFP_KERNEL |GFP_NOFS ); +if (!dip) { +ASSERT (dip !=NULL ); +return ; + } + +xfs_inode_to_disk (ip, dip,0 ); +xfs_dinode_calc_crc (mp, dip); + fa =xfs_dinode_verify (mp, ip->i_ino, dip); +if (fa) { +xfs_inode_verifier_error (ip, -EFSCORRUPTED , __func__, dip, +sizeof (*dip), fa); +xfs_force_shutdown (mp,SHUTDOWN_CORRUPT_INCORE ); +ASSERT (fa ==NULL ); + } +kfree (dip); +} +#else +# define xfs_inode_item_precommit_check (ip) ((void)0) +#endif +/* * Prior to finally logging the inode, we have to ensure that all the * per-modification inode state changes are applied. This includes VFS inode
@@ -168,6 +198,8 @@ xfs_inode_item_precommit( iip->ili_fields |= (flags | iip->ili_last_fields);spin_unlock (&iip->ili_lock); +xfs_inode_item_precommit_check (ip); +/* * We are done with the log item transaction dirty state, so clear it so * that it doesn't pollute future transactions.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 201/508 xfs: use consistent uid/gid when grabbing dquots for inodes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 24a4e1cb322e2bf0f3a1afd1978b610a23aa8f36 ]
[ 6.1: resolved conflicts in xfs_inode.c and xfs_symlink.c due to 6.1 not having switched to idmap yet ]
I noticed that callers of xfs_qm_vop_dqalloc use the following code to compute the anticipated uid of the new file:
mapped_fsuid(idmap, &init_user_ns);
whereas the VFS uses a slightly different computation for actually assigning i_uid:
mapped_fsuid(idmap, i_user_ns(inode));
Technically, these are not the same things. According to Christian Brauner, the only time that inode->i_sb->s_user_ns != &init_user_ns is when the filesystem was mounted in a new mount namespace by an unpriviledged user. XFS does not allow this, which is why we've never seen bug reports about quotas being incorrect or the uid checks in xfs_qm_vop_create_dqattach tripping debug assertions.
However, this /is/ a logic bomb, so let's make the code consistent.
--- fs/xfs/xfs_inode.c | 16 ++++++++++------ fs/xfs/xfs_symlink.c | 8 +++++--- 2 files changed, 15 insertions(+), 9 deletions(-)
fs/xfs/xfs_inode.c +10 -6
@@ -983,10 +983,12 @@ xfs_create( prid =xfs_get_initial_prid (dp);/* -* Make sure that we have allocated dquot(s) on disk. +* Make sure that we have allocated dquot(s) on disk. The uid/gid +* computation code must match what the VFS uses to assign i_[ug]id. +* INHERIT adjusts the gid computation for setgid/grpid systems. */ - error =xfs_qm_vop_dqalloc (dp,mapped_fsuid (mnt_userns, &init_user_ns), -mapped_fsgid (mnt_userns, &init_user_ns), prid, + error =xfs_qm_vop_dqalloc (dp,mapped_fsuid (mnt_userns,i_user_ns (VFS_I (dp))), +mapped_fsgid (mnt_userns,i_user_ns (VFS_I (dp))), prid,XFS_QMOPT_QUOTALL |XFS_QMOPT_INHERIT , &udqp, &gdqp, &pdqp);if (error)
@@ -1132,10 +1134,12 @@ xfs_create_tmpfile( prid =xfs_get_initial_prid (dp);/* -* Make sure that we have allocated dquot(s) on disk. +* Make sure that we have allocated dquot(s) on disk. The uid/gid +* computation code must match what the VFS uses to assign i_[ug]id. +* INHERIT adjusts the gid computation for setgid/grpid systems. */ - error =xfs_qm_vop_dqalloc (dp,mapped_fsuid (mnt_userns, &init_user_ns), -mapped_fsgid (mnt_userns, &init_user_ns), prid, + error =xfs_qm_vop_dqalloc (dp,mapped_fsuid (mnt_userns,i_user_ns (VFS_I (dp))), +mapped_fsgid (mnt_userns,i_user_ns (VFS_I (dp))), prid,XFS_QMOPT_QUOTALL |XFS_QMOPT_INHERIT , &udqp, &gdqp, &pdqp);if (error)
fs/xfs/xfs_symlink.c +5 -3
@@ -191,10 +191,12 @@ xfs_symlink( prid =xfs_get_initial_prid (dp);/* -* Make sure that we have allocated dquot(s) on disk. +* Make sure that we have allocated dquot(s) on disk. The uid/gid +* computation code must match what the VFS uses to assign i_[ug]id. +* INHERIT adjusts the gid computation for setgid/grpid systems. */ - error =xfs_qm_vop_dqalloc (dp,mapped_fsuid (mnt_userns, &init_user_ns), -mapped_fsgid (mnt_userns, &init_user_ns), prid, + error =xfs_qm_vop_dqalloc (dp,mapped_fsuid (mnt_userns,i_user_ns (VFS_I (dp))), +mapped_fsgid (mnt_userns,i_user_ns (VFS_I (dp))), prid,XFS_QMOPT_QUOTALL |XFS_QMOPT_INHERIT , &udqp, &gdqp, &pdqp);if (error)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 202/508 xfs: declare xfs_file.c symbols in xfs_file.h
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 00acb28d96746f78389f23a7b5309a917b45c12f ]
Move the two public symbols in xfs_file.c to xfs_file.h. We're about to add more public symbols in that source file, so let's finally create the header file.
--- fs/xfs/xfs_file.c | 1 + fs/xfs/xfs_file.h | 12 ++++++++++++ fs/xfs/xfs_ioctl.c | 1 + fs/xfs/xfs_iops.c | 1 + fs/xfs/xfs_iops.h | 3 --- 5 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 fs/xfs/xfs_file.h
fs/xfs/xfs_file.c +1 -0
@@ -24,6 +24,7 @@#include "xfs_pnfs.h" #include "xfs_iomap.h" #include "xfs_reflink.h" +#include "xfs_file.h" #include <linux/dax.h> #include <linux/falloc.h>
fs/xfs/xfs_file.h new file +12 -0
@@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2000-2005 Silicon Graphics, Inc. +* All Rights Reserved. +*/ +#ifndef __XFS_FILE_H__ +#define __XFS_FILE_H__ + +extern const struct file_operations xfs_file_operations; +extern const struct file_operations xfs_dir_file_operations; + +#endif /* __XFS_FILE_H__ */
fs/xfs/xfs_ioctl.c +1 -0
@@ -38,6 +38,7 @@#include "xfs_reflink.h" #include "xfs_ioctl.h" #include "xfs_xattr.h" +#include "xfs_file.h" #include <linux/mount.h> #include <linux/namei.h>
fs/xfs/xfs_iops.c +1 -0
@@ -25,6 +25,7 @@#include "xfs_error.h" #include "xfs_ioctl.h" #include "xfs_xattr.h" +#include "xfs_file.h" #include <linux/posix_acl.h> #include <linux/security.h>
fs/xfs/xfs_iops.h +0 -3
@@ -8,9 +8,6 @@struct xfs_inode ; -extern const struct file_operations xfs_file_operations; -extern const struct file_operations xfs_dir_file_operations; -extern ssize_t xfs_vn_listxattr (struct dentry *,char *data,size_t size); int xfs_vn_setattr_size(struct user_namespace *mnt_userns,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 203/508 xfs: create a new helper to return a files allocation unit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit ee20808d848c87a51e176706d81b95a21747d6cf ]
Create a new helper function to calculate the fundamental allocation unit (i.e. the smallest unit of space we can allocate) of a file. Things are going to get hairy with range-exchange on the realtime device, so prepare for this now.
Remove the static attribute from xfs_is_falloc_aligned since the next patch will need it.
--- fs/xfs/xfs_file.c | 32 ++++++++++++-------------------- fs/xfs/xfs_file.h | 3 +++ fs/xfs/xfs_inode.c | 13 +++++++++++++ fs/xfs/xfs_inode.h | 2 ++ 4 files changed, 30 insertions(+), 20 deletions(-)
fs/xfs/xfs_file.c +12 -20
@@ -39,33 +39,25 @@ static const struct vm_operations_struct xfs_file_vm_ops;* Decide if the given file range is aligned to the size of the fundamental * allocation unit for the file. */ -static bool +bool xfs_is_falloc_aligned (struct xfs_inode *ip,loff_t pos,long long int len) { -struct xfs_mount *mp = ip->i_mount; -uint64_t mask; - -if (XFS_IS_REALTIME_INODE (ip)) { -if (!is_power_of_2 (mp->m_sb.sb_rextsize)) { -u64 rextbytes; -u32 mod; - - rextbytes =XFS_FSB_TO_B (mp, mp->m_sb.sb_rextsize); -div_u64_rem (pos, rextbytes, &mod); -if (mod) -return false; -div_u64_rem (len, rextbytes, &mod); -return mod ==0 ; - } - mask =XFS_FSB_TO_B (mp, mp->m_sb.sb_rextsize) -1 ; - }else { - mask = mp->m_sb.sb_blocksize -1 ; +unsigned int alloc_unit =xfs_inode_alloc_unitsize (ip); + +if (!is_power_of_2 (alloc_unit)) { +u32 mod; + +div_u64_rem (pos, alloc_unit, &mod); +if (mod) +return false; +div_u64_rem (len, alloc_unit, &mod); +return mod ==0 ; } -return !((pos | len) & mask); +return !((pos | len) & (alloc_unit -1 )); }/*
fs/xfs/xfs_file.h +3 -0
@@ -9,4 +9,7 @@extern const struct file_operations xfs_file_operations;extern const struct file_operations xfs_dir_file_operations; +bool xfs_is_falloc_aligned (struct xfs_inode *ip,loff_t pos, +long long int len); +#endif /* __XFS_FILE_H__ */
fs/xfs/xfs_inode.c +13 -0
@@ -3775,3 +3775,16 @@ xfs_inode_reload_unlinked(return error; } + +/* Returns the size of fundamental allocation unit for a file, in bytes. */ +unsigned int +xfs_inode_alloc_unitsize ( +struct xfs_inode *ip) +{ +unsigned int blocks =1 ; + +if (XFS_IS_REALTIME_INODE (ip)) + blocks = ip->i_mount->m_sb.sb_rextsize; + +return XFS_FSB_TO_B (ip->i_mount, blocks); +}
fs/xfs/xfs_inode.h +2 -0
@@ -622,4 +622,6 @@ xfs_inode_unlinked_incomplete(int xfs_inode_reload_unlinked_bucket (struct xfs_trans *tp,struct xfs_inode *ip);int xfs_inode_reload_unlinked (struct xfs_inode *ip); +unsigned int xfs_inode_alloc_unitsize (struct xfs_inode *ip); +#endif /* __XFS_INODE_H__ */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 204/508 xfs: Fix xfs_flush_unmap_range() range for RT
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Garry <[email protected]>
[ Upstream commit d3b689d7c711a9f36d3e48db9eaa75784a892f4c ]
Currently xfs_flush_unmap_range() does unmap for a full RT extent range, which we also want to ensure is clean and idle.
This code change is originally from Dave Chinner.
--- fs/xfs/xfs_bmap_util.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/xfs/xfs_bmap_util.c +8 -4
@@ -963,14 +963,18 @@ xfs_flush_unmap_range( xfs_off_t offset, xfs_off_t len) { -struct xfs_mount *mp = ip->i_mount;struct inode *inode =VFS_I (ip);xfs_off_t rounding, start, end;int error; - rounding =max_t (xfs_off_t, mp->m_sb.sb_blocksize,PAGE_SIZE ); - start =round_down (offset, rounding); - end =round_up (offset + len, rounding) -1 ; +/* +* Make sure we extend the flush out to extent alignment +* boundaries so any extent range overlapping the start/end +* of the modification we are about to do is clean and idle. +*/ + rounding =max_t (xfs_off_t,xfs_inode_alloc_unitsize (ip),PAGE_SIZE ); + start =rounddown_64 (offset, rounding); + end =roundup_64 (offset + len, rounding) -1 ; error =filemap_write_and_wait_range (inode->i_mapping, start, end);if (error)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 205/508 xfs: Fix xfs_prepare_shift() range for RT
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Garry <[email protected]>
[ Upstream commit f23660f059470ec7043748da7641e84183c23bc8 ]
The RT extent range must be considered in the xfs_flush_unmap_range() call to stabilize the boundary.
This code change is originally from Dave Chinner.
--- fs/xfs/xfs_bmap_util.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/xfs/xfs_bmap_util.c +6 -4
@@ -1059,7 +1059,7 @@ xfs_prepare_shift( struct xfs_inode *ip, loff_t offset) { -struct xfs_mount *mp = ip->i_mount; +unsigned int rounding;int error;/*
@@ -1077,11 +1077,13 @@ xfs_prepare_shift(* with the full range of the operation. If we don't, a COW writeback * completion could race with an insert, front merge with the start * extent (after split) during the shift and corrupt the file. Start -* with the block just prior to the start to stabilize the boundary. +* with the allocation unit just prior to the start to stabilize the +* boundary. */ - offset =round_down (offset, mp->m_sb.sb_blocksize); + rounding =xfs_inode_alloc_unitsize (ip); + offset =rounddown_64 (offset, rounding);if (offset) - offset -= mp->m_sb.sb_blocksize; + offset -= rounding;/* * Writeback and invalidate cache for the remainder of the file as we're
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 206/508 xfs: dont walk off the end of a directory data block
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: lei lu <[email protected]>
[ Upstream commit 0c7fcdb6d06cdf8b19b57c17605215b06afa864a ]
This adds sanity checks for xfs_dir2_data_unused and xfs_dir2_data_entry to make sure don't stray beyond valid memory region. Before patching, the loop simply checks that the start offset of the dup and dep is within the range. So in a crafted image, if last entry is xfs_dir2_data_unused, we can change dup->length to dup->length-1 and leave 1 byte of space. In the next traversal, this space will be considered as dup or dep. We may encounter an out of bound read when accessing the fixed members.
In the patch, we make sure that the remaining bytes large enough to hold an unused entry before accessing xfs_dir2_data_unused and xfs_dir2_data_unused is XFS_DIR2_DATA_ALIGN byte aligned. We also make sure that the remaining bytes large enough to hold a dirent with a single-byte name before accessing xfs_dir2_data_entry.
--- fs/xfs/libxfs/xfs_dir2_data.c | 31 ++++++++++++++++++++++++++----- fs/xfs/libxfs/xfs_dir2_priv.h | 7 +++++++ 2 files changed, 33 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_dir2_data.c +26 -5
@@ -177,6 +177,14 @@ __xfs_dir3_data_check(while (offset < end) {struct xfs_dir2_data_unused *dup = bp->b_addr + offset;struct xfs_dir2_data_entry *dep = bp->b_addr + offset; +unsigned int reclen; + +/* +* Are the remaining bytes large enough to hold an +* unused entry? +*/ +if (offset > end -xfs_dir2_data_unusedsize (1 )) +return __this_address;/* * If it's unused, look for the space in the bestfree table.
@@ -186,9 +194,13 @@ __xfs_dir3_data_check(if (be16_to_cpu (dup->freetag) ==XFS_DIR2_DATA_FREE_TAG ) {xfs_failaddr_t fa; + reclen =xfs_dir2_data_unusedsize ( +be16_to_cpu (dup->length));if (lastfree !=0 )return __this_address; -if (offset +be16_to_cpu (dup->length) > end) +if (be16_to_cpu (dup->length) != reclen) +return __this_address; +if (offset + reclen > end)return __this_address;if (be16_to_cpu (*xfs_dir2_data_unused_tag_p (dup)) != offset)
@@ -206,10 +218,18 @@ __xfs_dir3_data_check( be16_to_cpu(bf[2].length))return __this_address; } - offset +=be16_to_cpu (dup->length); + offset += reclen; lastfree =1 ;continue ; } + +/* +* This is not an unused entry. Are the remaining bytes +* large enough for a dirent with a single-byte name? +*/ +if (offset > end -xfs_dir2_data_entsize (mp,1 )) +return __this_address; +/* * It's a real entry. Validate the fields. * If this is a block directory then make sure it's
@@ -218,9 +238,10 @@ __xfs_dir3_data_check(*/ if (dep->namelen ==0 )return __this_address; -if (!xfs_verify_dir_ino (mp,be64_to_cpu (dep->inumber))) + reclen =xfs_dir2_data_entsize (mp, dep->namelen); +if (offset + reclen > end)return __this_address; -if (offset +xfs_dir2_data_entsize (mp, dep->namelen) > end) +if (!xfs_verify_dir_ino (mp,be64_to_cpu (dep->inumber)))return __this_address;if (be16_to_cpu (*xfs_dir2_data_entry_tag_p (mp, dep)) != offset)return __this_address;
@@ -244,7 +265,7 @@ __xfs_dir3_data_check(if (i >=be32_to_cpu (btp->count))return __this_address; } - offset +=xfs_dir2_data_entsize (mp, dep->namelen); + offset += reclen; }/* * Need to have seen all the entries and all the bestfree slots.
fs/xfs/libxfs/xfs_dir2_priv.h +7 -0
@@ -187,6 +187,13 @@ void xfs_dir2_sf_put_ftype(struct xfs_mount *mp,extern int xfs_readdir (struct xfs_trans *tp,struct xfs_inode *dp,struct dir_context *ctx,size_t bufsize); +static inline unsigned int +xfs_dir2_data_unusedsize ( +unsigned int len) +{ +return round_up (len,XFS_DIR2_DATA_ALIGN ); +} + static inline unsigned int xfs_dir2_data_entsize( struct xfs_mount *mp,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 207/508 xfs: remove unused parameter in macro XFS_DQUOT_LOGRES
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Sun <[email protected]>
[ Upstream commit af5d92f2fad818663da2ce073b6fe15b9d56ffdc ]
In the macro definition of XFS_DQUOT_LOGRES, a parameter is accepted, but it is not used. Hence, it should be removed.
This patch has only passed compilation test, but it should be fine.
--- fs/xfs/libxfs/xfs_quota_defs.h | 2 +- fs/xfs/libxfs/xfs_trans_resv.c | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-)
fs/xfs/libxfs/xfs_quota_defs.h +1 -1
@@ -56,7 +56,7 @@ typedef uint8_t xfs_dqtype_t;* And, of course, we also need to take into account the dquot log format item * used to describe each dquot. */ -#define XFS_DQUOT_LOGRES (mp) \ +#define XFS_DQUOT_LOGRES \ ((sizeof(struct xfs_dq_logformat) + sizeof(struct xfs_disk_dquot)) * 6)#define XFS_IS_QUOTA_ON (mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)
fs/xfs/libxfs/xfs_trans_resv.c +14 -14
@@ -334,11 +334,11 @@ xfs_calc_write_reservation( blksz); t1 += adj; t3 += adj; -return XFS_DQUOT_LOGRES (mp) +max3 (t1, t2, t3); +return XFS_DQUOT_LOGRES +max3 (t1, t2, t3); } t4 =xfs_calc_refcountbt_reservation (mp,1 ); -return XFS_DQUOT_LOGRES (mp) +max (t4,max3 (t1, t2, t3)); +return XFS_DQUOT_LOGRES +max (t4,max3 (t1, t2, t3)); }unsigned int
@@ -406,11 +406,11 @@ xfs_calc_itruncate_reservation(xfs_refcountbt_block_count (mp,4 ), blksz); -return XFS_DQUOT_LOGRES (mp) +max3 (t1, t2, t3); +return XFS_DQUOT_LOGRES +max3 (t1, t2, t3); } t4 =xfs_calc_refcountbt_reservation (mp,2 ); -return XFS_DQUOT_LOGRES (mp) +max (t4,max3 (t1, t2, t3)); +return XFS_DQUOT_LOGRES +max (t4,max3 (t1, t2, t3)); }unsigned int
@@ -436,7 +436,7 @@ STATIC uintxfs_calc_rename_reservation ( struct xfs_mount *mp) { -return XFS_DQUOT_LOGRES (mp) + +return XFS_DQUOT_LOGRES + max((xfs_calc_inode_res(mp, 5) + xfs_calc_buf_res(2 * XFS_DIROP_LOG_COUNT(mp), XFS_FSB_TO_B(mp, 1))),
@@ -475,7 +475,7 @@ STATIC uintxfs_calc_link_reservation ( struct xfs_mount *mp) { - return XFS_DQUOT_LOGRES(mp) + + return XFS_DQUOT_LOGRES + xfs_calc_iunlink_remove_reservation(mp) + max((xfs_calc_inode_res(mp, 2) + xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
@@ -513,7 +513,7 @@ STATIC uintxfs_calc_remove_reservation ( struct xfs_mount *mp) { - return XFS_DQUOT_LOGRES(mp) + + return XFS_DQUOT_LOGRES + xfs_calc_iunlink_add_reservation(mp) + max((xfs_calc_inode_res(mp, 2) + xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
@@ -572,7 +572,7 @@ xfs_calc_icreate_resv_alloc( STATIC uintxfs_calc_icreate_reservation (xfs_mount_t *mp) { -return XFS_DQUOT_LOGRES (mp) + +return XFS_DQUOT_LOGRES +max (xfs_calc_icreate_resv_alloc (mp),xfs_calc_create_resv_modify (mp)); }
@@ -581,7 +581,7 @@ STATIC uintxfs_calc_create_tmpfile_reservation ( struct xfs_mount *mp) { -uint res =XFS_DQUOT_LOGRES (mp); +uint res =XFS_DQUOT_LOGRES ; res +=xfs_calc_icreate_resv_alloc (mp);return res +xfs_calc_iunlink_add_reservation (mp);
@@ -630,7 +630,7 @@ STATIC uintxfs_calc_ifree_reservation ( struct xfs_mount *mp) { -return XFS_DQUOT_LOGRES (mp) + +return XFS_DQUOT_LOGRES +xfs_calc_inode_res (mp,1 ) +xfs_calc_buf_res (3 , mp->m_sb.sb_sectsize) + xfs_calc_iunlink_remove_reservation(mp) +
@@ -647,7 +647,7 @@ STATIC uintxfs_calc_ichange_reservation ( struct xfs_mount *mp) { -return XFS_DQUOT_LOGRES (mp) + +return XFS_DQUOT_LOGRES +xfs_calc_inode_res (mp,1 ) +xfs_calc_buf_res (1 , mp->m_sb.sb_sectsize);
@@ -756,7 +756,7 @@ STATIC uintxfs_calc_addafork_reservation ( struct xfs_mount *mp) { -return XFS_DQUOT_LOGRES (mp) + +return XFS_DQUOT_LOGRES +xfs_calc_inode_res (mp,1 ) +xfs_calc_buf_res (2 , mp->m_sb.sb_sectsize) + xfs_calc_buf_res(1, mp->m_dir_geo->blksize) +
@@ -804,7 +804,7 @@ STATIC uintxfs_calc_attrsetm_reservation ( struct xfs_mount *mp) { -return XFS_DQUOT_LOGRES (mp) + +return XFS_DQUOT_LOGRES +xfs_calc_inode_res (mp,1 ) +xfs_calc_buf_res (1 , mp->m_sb.sb_sectsize) +xfs_calc_buf_res (XFS_DA_NODE_MAXDEPTH ,XFS_FSB_TO_B (mp,1 ));
@@ -844,7 +844,7 @@ STATIC uintxfs_calc_attrrm_reservation ( struct xfs_mount *mp) { -return XFS_DQUOT_LOGRES (mp) + +return XFS_DQUOT_LOGRES + max((xfs_calc_inode_res(mp, 1) + xfs_calc_buf_res(XFS_DA_NODE_MAXDEPTH, XFS_FSB_TO_B(mp, 1)) +
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 208/508 xfs: attr forks require attr, not attr2
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 73c34b0b85d46bf9c2c0b367aeaffa1e2481b136 ]
It turns out that I misunderstood the difference between the attr and attr2 feature bits. "attr" means that at some point an attr fork was created somewhere in the filesystem. "attr2" means that inodes have variable-sized forks, but says nothing about whether or not there actually /are/ attr forks in the system.
If we have an attr fork, we only need to check that attr is set.
--- fs/xfs/scrub/bmap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/xfs/scrub/bmap.c +7 -1
@@ -647,7 +647,13 @@ xchk_bmap( }break ;case XFS_ATTR_FORK : -if (!xfs_has_attr (mp) && !xfs_has_attr2 (mp)) +/* +* "attr" means that an attr fork was created at some point in +* the life of this filesystem. "attr2" means that inodes have +* variable-sized data/attr fork areas. Hence we only check +* attr here. +*/ +if (!xfs_has_attr (mp))xchk_ino_set_corrupt (sc, sc->ip->i_ino);break ;default :
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 209/508 xfs: conditionally allow FS_XFLAG_REALTIME changes if S_DAX is set
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 8d16762047c627073955b7ed171a36addaf7b1ff ]
If a file has the S_DAX flag (aka fsdax access mode) set, we cannot allow users to change the realtime flag unless the datadev and rtdev both support fsdax access modes. Even if there are no extents allocated to the file, the setattr thread could be racing with another thread that has already started down the write code paths.
--- fs/xfs/xfs_ioctl.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/xfs/xfs_ioctl.c +11 -0
@@ -1128,6 +1128,17 @@ xfs_ioctl_setattr_xflags(/* Can't change realtime flag if any extents are allocated. */ if (ip->i_df.if_nextents || ip->i_delayed_blks)return -EINVAL ; + +/* +* If S_DAX is enabled on this file, we can only switch the +* device if both support fsdax. We can't update S_DAX because +* there might be other threads walking down the access paths. +*/ +if (IS_DAX (VFS_I (ip)) && + (mp->m_ddev_targp->bt_daxdev ==NULL || + (mp->m_rtdev_targp && + mp->m_rtdev_targp->bt_daxdev ==NULL ))) +return -EINVAL ; }if (rtflag) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 210/508 xfs: Fix the owner setting issue for rmap query in xfs fsmap
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zizhi Wo <[email protected]>
[ Upstream commit 68415b349f3f16904f006275757f4fcb34b8ee43 ]
I notice a rmap query bug in xfs_io fsmap:
[root@fedora ~]# xfs_io -c 'fsmap -vvvv' /mnt
EXT: DEV BLOCK-RANGE OWNER FILE-OFFSET AG AG-OFFSET TOTAL 0: 253:16 [0..7]: static fs metadata 0 (0..7) 8 1: 253:16 [8..23]: per-AG metadata 0 (8..23) 16 2: 253:16 [24..39]: inode btree 0 (24..39) 16 3: 253:16 [40..47]: per-AG metadata 0 (40..47) 8 4: 253:16 [48..55]: refcount btree 0 (48..55) 8 5: 253:16 [56..103]: per-AG metadata 0 (56..103) 48 6: 253:16 [104..127]: free space 0 (104..127) 24
......
Bug:
[root@fedora ~]# xfs_io -c 'fsmap -vvvv -d 0 3' /mnt [root@fedora ~]#
Normally, we should be able to get one record, but we got nothing.
The root cause of this problem lies in the incorrect setting of rm_owner in the rmap query. In the case of the initial query where the owner is not set, __xfs_getfsmap_datadev() first sets info->high.rm_owner to ULLONG_MAX. This is done to prevent any omissions when comparing rmap items. However, if the current ag is detected to be the last one, the function sets info's high_irec based on the provided key. If high->rm_owner is not specified, it should continue to be set to ULLONG_MAX; otherwise, there will be issues with interval omissions. For example, consider "start" and "end" within the same block. If high->rm_owner == 0, it will be smaller than the founded record in rmapbt, resulting in a query with no records. The main call stack is as follows:
xfs_ioc_getfsmap
xfs_getfsmap
xfs_getfsmap_datadev_rmapbt
__xfs_getfsmap_datadev
info->high.rm_owner = ULLONG_MAX
if (pag->pag_agno == end_ag)
xfs_fsmap_owner_to_rmap
// set info->high.rm_owner = 0 because fmr_owner == -1ULL
dest->rm_owner = 0
// get nothing
xfs_getfsmap_datadev_rmapbt_queryThe problem can be resolved by simply modify the xfs_fsmap_owner_to_rmap function internal logic to achieve.
After applying this patch, the above problem have been solved:
[root@fedora ~]# xfs_io -c 'fsmap -vvvv -d 0 3' /mnt
EXT: DEV BLOCK-RANGE OWNER FILE-OFFSET AG AG-OFFSET TOTAL 0: 253:16 [0..7]: static fs metadata 0 (0..7) 8
--- fs/xfs/xfs_fsmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_fsmap.c +1 -1
@@ -71,7 +71,7 @@ xfs_fsmap_owner_to_rmap(switch (src->fmr_owner) {case 0 :/* "lowest owner id possible" */ case -1ULL :/* "highest owner id possible" */ - dest->rm_owner =0 ; + dest->rm_owner = src->fmr_owner;break ;case XFS_FMR_OWN_FREE : dest->rm_owner =XFS_RMAP_OWN_NULL ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 211/508 xfs: use XFS_BUF_DADDR_NULL for daddrs in getfsmap code
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 6b35cc8d9239569700cc7cc737c8ed40b8b9cfdb ]
Use XFS_BUF_DADDR_NULL (instead of a magic sentinel value) to mean "this field is null" like the rest of xfs.
--- fs/xfs/xfs_fsmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/xfs_fsmap.c +2 -2
@@ -252,7 +252,7 @@ xfs_getfsmap_rec_before_start( const struct xfs_rmap_irec *rec, xfs_daddr_t rec_daddr) { - if (info->low_daddr != -1ULL) + if (info->low_daddr != XFS_BUF_DADDR_NULL) return rec_daddr < info->low_daddr;if (info->low.rm_blockcount)return xfs_rmap_compare (rec, &info->low) <0 ;
@@ -986,7 +986,7 @@ xfs_getfsmap( info.dev = handlers[i].dev; info.last = false; info.pag =NULL ; - info.low_daddr =-1ULL ; + info.low_daddr =XFS_BUF_DADDR_NULL ; info.low.rm_blockcount =0 ; error = handlers[i].fn (tp, dkeys, &info);if (error)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 212/508 xfs: take m_growlock when running growfsrt
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 16e1fbdce9c8d084863fd63cdaff8fb2a54e2f88 ]
Take the grow lock when we're expanding the realtime volume, like we do for the other growfs calls.
--- fs/xfs/xfs_rtalloc.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-)
fs/xfs/xfs_rtalloc.c +25 -13
@@ -953,34 +953,39 @@ xfs_growfs_rt(/* Needs to have been mounted with an rt device. */ if (!XFS_IS_REALTIME_MOUNT (mp))return -EINVAL ; + +if (!mutex_trylock (&mp->m_growlock)) +return -EWOULDBLOCK ;/* * Mount should fail if the rt bitmap/summary files don't load, but * we'll check anyway. */ + error = -EINVAL ;if (!mp->m_rbmip || !mp->m_rsumip) -return -EINVAL ; + goto out_unlock;/* Shrink not supported. */ if (in->newblocks <= sbp->sb_rblocks) -return -EINVAL ; + goto out_unlock;/* Can only change rt extent size when adding rt volume. */ if (sbp->sb_rblocks >0 && in->extsize != sbp->sb_rextsize) -return -EINVAL ; + goto out_unlock;/* Range check the extent size. */ if (XFS_FSB_TO_B (mp, in->extsize) >XFS_MAX_RTEXTSIZE ||XFS_FSB_TO_B (mp, in->extsize) <XFS_MIN_RTEXTSIZE ) -return -EINVAL ; + goto out_unlock;/* Unsupported realtime features. */ + error = -EOPNOTSUPP ;if (xfs_has_rmapbt (mp) ||xfs_has_reflink (mp) ||xfs_has_quota (mp)) -return -EOPNOTSUPP ; + goto out_unlock; nrblocks = in->newblocks; error =xfs_sb_validate_fsb_count (sbp, nrblocks);if (error) -return error; + goto out_unlock;/* * Read in the last block of the device, make sure it exists. */
@@ -988,7 +993,7 @@ xfs_growfs_rt(XFS_FSB_TO_BB (mp, nrblocks -1 ), XFS_FSB_TO_BB(mp, 1), 0, &bp, NULL);if (error) -return error; + goto out_unlock;xfs_buf_relse (bp);/*
@@ -996,8 +1001,10 @@ xfs_growfs_rt(*/ nrextents = nrblocks;do_div (nrextents, in->extsize); -if (!xfs_validate_rtextents (nrextents)) -return -EINVAL ; +if (!xfs_validate_rtextents (nrextents)) { + error = -EINVAL ; + goto out_unlock; + } nrbmblocks =howmany_64 (nrextents,NBBY * sbp->sb_blocksize); nrextslog =xfs_compute_rextslog (nrextents); nrsumlevels = nrextslog +1 ;
@@ -1009,8 +1016,11 @@ xfs_growfs_rt(* the log. This prevents us from getting a log overflow, * since we'll log basically the whole summary file at once. */ -if (nrsumblocks > (mp->m_sb.sb_logblocks >>1 )) -return -EINVAL ; +if (nrsumblocks > (mp->m_sb.sb_logblocks >>1 )) { + error = -EINVAL ; + goto out_unlock; + } +/* * Get the old block counts for bitmap and summary inodes. * These can't change since other growfs callers are locked out.
@@ -1022,10 +1032,10 @@ xfs_growfs_rt(*/ error =xfs_growfs_rt_alloc (mp, rbmblocks, nrbmblocks, mp->m_rbmip);if (error) -return error; + goto out_unlock; error =xfs_growfs_rt_alloc (mp, rsumblocks, nrsumblocks, mp->m_rsumip);if (error) -return error; + goto out_unlock; rsum_cache = mp->m_rsum_cache;if (nrbmblocks != sbp->sb_rbmblocks)
@@ -1190,6 +1200,8 @@ xfs_growfs_rt( } } +out_unlock: +mutex_unlock (&mp->m_growlock);return error; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 213/508 xfs: reset rootdir extent size hint after growfsrt
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit a24cae8fc1f13f6f6929351309f248fd2e9351ce ]
If growfsrt is run on a filesystem that doesn't have a rt volume, it's possible to change the rt extent size. If the root directory was previously set up with an inherited extent size hint and rtinherit, it's possible that the hint is no longer a multiple of the rt extent size. Although the verifiers don't complain about this, xfs_repair will, so if we detect this situation, log the root directory to clean it up. This is still racy, but it's better than nothing.
--- fs/xfs/xfs_rtalloc.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
fs/xfs/xfs_rtalloc.c +40 -0
@@ -915,6 +915,39 @@ xfs_alloc_rsum_cache(xfs_warn (mp,"could not allocate realtime summary cache" ); } +/* +* If we changed the rt extent size (meaning there was no rt volume previously) +* and the root directory had EXTSZINHERIT and RTINHERIT set, it's possible +* that the extent size hint on the root directory is no longer congruent with +* the new rt extent size. Log the rootdir inode to fix this. +*/ +static int +xfs_growfs_rt_fixup_extsize ( +struct xfs_mount *mp) +{ +struct xfs_inode *ip = mp->m_rootip; +struct xfs_trans *tp; +int error =0 ; + +xfs_ilock (ip,XFS_IOLOCK_EXCL ); +if (!(ip->i_diflags &XFS_DIFLAG_RTINHERIT ) || + !(ip->i_diflags &XFS_DIFLAG_EXTSZINHERIT )) + goto out_iolock; + + error =xfs_trans_alloc_inode (ip, &M_RES (mp)->tr_ichange,0 ,0 , false, + &tp); +if (error) + goto out_iolock; + +xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); + error =xfs_trans_commit (tp); +xfs_iunlock (ip,XFS_ILOCK_EXCL ); + +out_iolock: +xfs_iunlock (ip,XFS_IOLOCK_EXCL ); +return error; +} +/* * Visible (exported) functions. */
@@ -944,6 +977,7 @@ xfs_growfs_rt(xfs_sb_t *sbp;/* old superblock */ xfs_fsblock_t sumbno;/* summary block number */ uint8_t *rsum_cache;/* old summary cache */ +xfs_agblock_t old_rextsize = mp->m_sb.sb_rextsize; sbp = &mp->m_sb;
@@ -1177,6 +1211,12 @@ xfs_growfs_rt(if (error) goto out_free; +if (old_rextsize != in->extsize) { + error =xfs_growfs_rt_fixup_extsize (mp); +if (error) + goto out_free; + } +/* Update secondary superblocks now the physical grow has completed */ error =xfs_update_secondary_sbs (mp);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 214/508 pmdomain: core: Fix error checking in genpd_dev_pm_attach_by_id()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 0f5757667ec0aaf2456c3b76fcf0c6c3ea3591fe ]
The error checking for of_count_phandle_with_args() does not handle negative error codes correctly. The problem is that "index" is a u32 so in the condition "if (index >= num_domains)" negative error codes stored in "num_domains" are type promoted to very high positive values and "index" is always going to be valid.
Test for negative error codes first and then test if "index" is valid.
--- drivers/base/power/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/power/domain.c +1 -1
@@ -2840,7 +2840,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev,/* Verify that the index is within a valid range. */ num_domains =of_count_phandle_with_args (dev->of_node,"power-domains" ,"#power-domain-cells" ); -if (index >= num_domains) +if (num_domains <0 || index >= num_domains)return NULL ;/* Allocate and register device on the genpd bus. */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 215/508 arm64: dts: marvell: uDPU: define pinctrl state for alarm LEDs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabor Juhos <[email protected]>
[ Upstream commit b04f0d89e880bc2cca6a5c73cf287082c91878da ]
The two alarm LEDs of on the uDPU board are stopped working since commit 78efa53e715e ("leds: Init leds class earlier").
The LEDs are driven by the GPIO{15,16} pins of the North Bridge GPIO controller. These pins are part of the 'spi_quad' pin group for which the 'spi' function is selected via the default pinctrl state of the 'spi' node. This is wrong however, since in order to allow controlling the LEDs, the pins should use the 'gpio' function.
Before the commit mentined above, the 'spi' function is selected first by the pinctrl core before probing the spi driver, but then it gets overridden to 'gpio' implicitly via the devm_gpiod_get_index_optional() call from the 'leds-gpio' driver.
After the commit, the LED subsystem gets initialized before the SPI subsystem, so the function of the pin group remains 'spi' which in turn prevents controlling of the LEDs.
Despite the change of the initialization order, the root cause is that the pinctrl state definition is wrong since its initial commit 0d45062cfc89 ("arm64: dts: marvell: Add device tree for uDPU board"),
To fix the problem, override the function in the 'spi_quad_pins' node to 'gpio' and move the pinctrl state definition from the 'spi' node into the 'leds' node.
--- arch/arm64/boot/dts/marvell/armada-3720-uDPU.dtsi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/marvell/armada-3720-uDPU.dtsi +6 -2
@@ -26,6 +26,8 @@ memory@0 { leds { compatible = "gpio-leds"; + pinctrl-names = "default"; + pinctrl-0 = <&spi_quad_pins>; led-power1 { label = "udpu:green:power";
@@ -82,8 +84,6 @@ &sdhci0 { &spi0 { status = "okay"; - pinctrl-names = "default"; - pinctrl-0 = <&spi_quad_pins>; flash@0 { compatible = "jedec,spi-nor";
@@ -108,6 +108,10 @@ partition@180000 { }; }; +&spi_quad_pins { + function = "gpio"; +}; + &pinctrl_nb { i2c2_recovery_pins: i2c2-recovery-pins { groups = "i2c2";
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 216/508 Input: synaptics-rmi - fix crash with unsupported versions of F34
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
[ Upstream commit ca39500f6af9cfe6823dc5aa8fbaed788d6e35b2 ]
Sysfs interface for updating firmware for RMI devices is available even when F34 probe fails. The code checks for presence of F34 "container" pointer and then tries to use the function data attached to the sub-device. F34 assigns the function data early, before it knows if probe will succeed, leaving behind a stale pointer.
Fix this by expanding checks to not only test for presence of F34 "container" but also check if there is driver data assigned to the sub-device, and call dev_set_drvdata() only after we are certain that probe is successful.
This is not a complete fix, since F34 will be freed during firmware update, so there is still a race when fetching and accessing this pointer. This race will be addressed in follow-up changes.
--- drivers/input/rmi4/rmi_f34.c | 135 ++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 59 deletions(-)
drivers/input/rmi4/rmi_f34.c +76 -59
@@ -4,6 +4,7 @@* Copyright (C) 2016 Zodiac Inflight Innovations */ +#include "linux/device.h" #include <linux/kernel.h> #include <linux/rmi.h> #include <linux/firmware.h>
@@ -298,39 +299,30 @@ static int rmi_f34_update_firmware(struct f34_data *f34,return ret; } -static int rmi_f34_status (struct rmi_function *fn) -{ -struct f34_data *f34 =dev_get_drvdata (&fn->dev); - -/* -* The status is the percentage complete, or once complete, -* zero for success or a negative return code. -*/ -return f34->update_status; -} -static ssize_t rmi_driver_bootloader_id_show (struct device *dev,struct device_attribute *dattr,char *buf) {struct rmi_driver_data *data =dev_get_drvdata (dev); -struct rmi_function *fn = data->f34_container; +struct rmi_function *fn;struct f34_data *f34; -if (fn) { - f34 =dev_get_drvdata (&fn->dev); - -if (f34->bl_version ==5 ) -return sysfs_emit (buf,"%c%c\n" , - f34->bootloader_id[0 ], - f34->bootloader_id[1 ]); -else -return sysfs_emit (buf,"V%d.%d\n" , - f34->bootloader_id[1 ], - f34->bootloader_id[0 ]); - } + fn = data->f34_container; +if (!fn) +return -ENODEV ; -return 0 ; + f34 =dev_get_drvdata (&fn->dev); +if (!f34) +return -ENODEV ; + +if (f34->bl_version ==5 ) +return sysfs_emit (buf,"%c%c\n" , + f34->bootloader_id[0 ], + f34->bootloader_id[1 ]); +else +return sysfs_emit (buf,"V%d.%d\n" , + f34->bootloader_id[1 ], + f34->bootloader_id[0 ]); } static DEVICE_ATTR(bootloader_id, 0444, rmi_driver_bootloader_id_show, NULL);
@@ -343,13 +335,16 @@ static ssize_t rmi_driver_configuration_id_show(struct device *dev,struct rmi_function *fn = data->f34_container;struct f34_data *f34; -if (fn) { - f34 =dev_get_drvdata (&fn->dev); + fn = data->f34_container; +if (!fn) +return -ENODEV ; -return sysfs_emit (buf,"%s\n" , f34->configuration_id); - } + f34 =dev_get_drvdata (&fn->dev); +if (!f34) +return -ENODEV ; -return 0 ; + +return sysfs_emit (buf,"%s\n" , f34->configuration_id); } static DEVICE_ATTR(configuration_id, 0444,
@@ -365,10 +360,14 @@ static int rmi_firmware_update(struct rmi_driver_data *data,if (!data->f34_container) {dev_warn (dev,"%s: No F34 present!\n" , __func__); -return -EINVAL ; +return -ENODEV ; } f34 =dev_get_drvdata (&data->f34_container->dev); +if (!f34) { +dev_warn (dev,"%s: No valid F34 present!\n" , __func__); +return -ENODEV ; + }if (f34->bl_version >=7 ) {if (data->pdt_props &HAS_BSR ) {
@@ -494,10 +493,18 @@ static ssize_t rmi_driver_update_fw_status_show(struct device *dev, char *buf) {struct rmi_driver_data *data =dev_get_drvdata (dev); -int update_status =0 ; +struct f34_data *f34; +int update_status = -ENODEV ; -if (data->f34_container) - update_status =rmi_f34_status (data->f34_container); +/* +* The status is the percentage complete, or once complete, +* zero for success or a negative return code. +*/ +if (data->f34_container) { + f34 =dev_get_drvdata (&data->f34_container->dev); +if (f34) + update_status = f34->update_status; + }return sysfs_emit (buf,"%d\n" , update_status); }
@@ -517,33 +524,21 @@ static const struct attribute_group rmi_firmware_attr_group = { .attrs = rmi_firmware_attrs, }; -static int rmi_f34_probe (struct rmi_function *fn) +static int rmi_f34v5_probe (struct f34_data *f34) { -struct f34_data *f34; -unsigned char f34_queries[9 ]; +struct rmi_function *fn = f34->fn; +u8 f34_queries[9 ];bool has_config_id; -u8 version = fn->fd.function_version; -int ret; - - f34 =devm_kzalloc (&fn->dev,sizeof (struct f34_data ),GFP_KERNEL ); -if (!f34) -return -ENOMEM ; - - f34->fn = fn; -dev_set_drvdata (&fn->dev, f34); - -/* v5 code only supported version 0, try V7 probe */ -if (version >0 ) -return rmi_f34v7_probe (f34); +int error; f34->bl_version =5 ; - ret =rmi_read_block (fn->rmi_dev, fn->fd.query_base_addr, - f34_queries,sizeof (f34_queries)); -if (ret) { + error =rmi_read_block (fn->rmi_dev, fn->fd.query_base_addr, + f34_queries,sizeof (f34_queries)); +if (error) {dev_err (&fn->dev,"%s: Failed to query properties\n" , __func__); -return ret; +return error; } snprintf(f34->bootloader_id, sizeof(f34->bootloader_id),
@@ -569,11 +564,11 @@ static int rmi_f34_probe(struct rmi_function *fn) f34->v5.config_blocks);if (has_config_id) { - ret =rmi_read_block (fn->rmi_dev, fn->fd.control_base_addr, - f34_queries,sizeof (f34_queries)); -if (ret) { + error =rmi_read_block (fn->rmi_dev, fn->fd.control_base_addr, + f34_queries,sizeof (f34_queries)); +if (error) {dev_err (&fn->dev,"Failed to read F34 config ID\n" ); -return ret; +return error; } snprintf(f34->configuration_id, sizeof(f34->configuration_id),
@@ -582,12 +577,34 @@ static int rmi_f34_probe(struct rmi_function *fn) f34_queries[2], f34_queries[3]);rmi_dbg (RMI_DEBUG_FN , &fn->dev,"Configuration ID: %s\n" , - f34->configuration_id); + f34->configuration_id); }return 0 ; } +static int rmi_f34_probe (struct rmi_function *fn) +{ +struct f34_data *f34; +u8 version = fn->fd.function_version; +int error; + + f34 =devm_kzalloc (&fn->dev,sizeof (struct f34_data ),GFP_KERNEL ); +if (!f34) +return -ENOMEM ; + + f34->fn = fn; + +/* v5 code only supported version 0 */ + error = version ==0 ?rmi_f34v5_probe (f34) :rmi_f34v7_probe (f34); +if (error) +return error; + +dev_set_drvdata (&fn->dev, f34); + +return 0 ; +} +int rmi_f34_create_sysfs (struct rmi_device *rmi_dev) {return sysfs_create_group (&rmi_dev->dev.kobj, &rmi_firmware_attr_group);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 217/508 arm64: dts: ti: k3-am65-main: Drop deprecated ti,otap-del-sel property
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nishanth Menon <[email protected]>
[ Upstream commit 2b9bb988742d1794e78d4297a99658f38477eedd ]
ti,otap-del-sel has been deprecated in favor of ti,otap-del-sel-legacy.
Drop the duplicate and misleading ti,otap-del-sel property.
Stable-dep-of: f55c9f087cc2 ("arm64: dts: ti: k3-am65-main: Add missing taps to sdhci0")
--- arch/arm64/boot/dts/ti/k3-am65-main.dtsi | 1 - 1 file changed, 1 deletion(-)
arch/arm64/boot/dts/ti/k3-am65-main.dtsi +0 -1
@@ -295,7 +295,6 @@ sdhci1: mmc@4fa0000 { ti,otap-del-sel-ddr52 = <0x4>; ti,otap-del-sel-hs200 = <0x7>; ti,clkbuf-sel = <0x7>; - ti,otap-del-sel = <0x2>; ti,trm-icp = <0x8>; dma-coherent; };
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 218/508 arm64: dts: ti: k3-am65-main: Fix sdhci node properties
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
[ Upstream commit 8ffe9cb889f2b831a9d5bbb1f7ad42d30e31170f ]
Update otap-del-sel properties as per datasheet [0].
Add missing clkbuf-sel and itap-del-sel values also as per datasheet [0].
Move clkbuf-sel and ti,trm-icp above the otap-del-sel properties so the sdhci nodes could be more uniform across platforms.
[0] https://www.ti.com/lit/ds/symlink/am6548.pdf
Stable-dep-of: f55c9f087cc2 ("arm64: dts: ti: k3-am65-main: Add missing taps to sdhci0")
--- arch/arm64/boot/dts/ti/k3-am65-main.dtsi | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/ti/k3-am65-main.dtsi +11 -6
@@ -262,6 +262,8 @@ sdhci0: mmc@4f80000 { interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>; mmc-ddr-1_8v; mmc-hs200-1_8v; + ti,clkbuf-sel = <0x7>; + ti,trm-icp = <0x8>; ti,otap-del-sel-legacy = <0x0>; ti,otap-del-sel-mmc-hs = <0x0>; ti,otap-del-sel-sd-hs = <0x0>;
@@ -272,8 +274,7 @@ sdhci0: mmc@4f80000 { ti,otap-del-sel-ddr50 = <0x5>; ti,otap-del-sel-ddr52 = <0x5>; ti,otap-del-sel-hs200 = <0x5>; - ti,otap-del-sel-hs400 = <0x0>; - ti,trm-icp = <0x8>; + ti,itap-del-sel-ddr52 = <0x0>; dma-coherent; };
@@ -284,18 +285,22 @@ sdhci1: mmc@4fa0000 { clocks = <&k3_clks 48 0>, <&k3_clks 48 1>; clock-names = "clk_ahb", "clk_xin"; interrupts = <GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>; + ti,clkbuf-sel = <0x7>; + ti,trm-icp = <0x8>; ti,otap-del-sel-legacy = <0x0>; ti,otap-del-sel-mmc-hs = <0x0>; ti,otap-del-sel-sd-hs = <0x0>; - ti,otap-del-sel-sdr12 = <0x0>; - ti,otap-del-sel-sdr25 = <0x0>; + ti,otap-del-sel-sdr12 = <0xf>; + ti,otap-del-sel-sdr25 = <0xf>; ti,otap-del-sel-sdr50 = <0x8>; ti,otap-del-sel-sdr104 = <0x7>; ti,otap-del-sel-ddr50 = <0x4>; ti,otap-del-sel-ddr52 = <0x4>; ti,otap-del-sel-hs200 = <0x7>; - ti,clkbuf-sel = <0x7>; - ti,trm-icp = <0x8>; + ti,itap-del-sel-legacy = <0xa>; + ti,itap-del-sel-sd-hs = <0x1>; + ti,itap-del-sel-sdr12 = <0xa>; + ti,itap-del-sel-sdr25 = <0x1>; dma-coherent; };
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 219/508 arm64: dts: ti: k3-am65-main: Add missing taps to sdhci0
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
[ Upstream commit f55c9f087cc2e2252d44ffd9d58def2066fc176e ]
For am65x, add missing ITAPDLYSEL values for Default Speed and High Speed SDR modes to sdhci0 node according to the device datasheet [0].
[0] https://www.ti.com/lit/gpn/am6548
--- arch/arm64/boot/dts/ti/k3-am65-main.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/ti/k3-am65-main.dtsi +2 -0
@@ -274,6 +274,8 @@ sdhci0: mmc@4f80000 { ti,otap-del-sel-ddr50 = <0x5>; ti,otap-del-sel-ddr52 = <0x5>; ti,otap-del-sel-hs200 = <0x5>; + ti,itap-del-sel-legacy = <0xa>; + ti,itap-del-sel-mmc-hs = <0x1>; ti,itap-del-sel-ddr52 = <0x0>; dma-coherent; };
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 220/508 serial: sh-sci: Check if TX data was written to device in .tx_empty()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
commit 7cc0e0a43a91052477c2921f924a37d9c3891f0c upstream.
On the Renesas RZ/G3S, when doing suspend to RAM, the uart_suspend_port() is called. The uart_suspend_port() calls 3 times the
struct uart_port::ops::tx_empty() before shutting down the port.
According to the documentation, the struct uart_port::ops::tx_empty() API tests whether the transmitter FIFO and shifter for the port is empty.
The Renesas RZ/G3S SCIFA IP reports the number of data units stored in the transmit FIFO through the FDR (FIFO Data Count Register). The data units in the FIFOs are written in the shift register and transmitted from there. The TEND bit in the Serial Status Register reports if the data was transmitted from the shift register.
In the previous code, in the tx_empty() API implemented by the sh-sci driver, it is considered that the TX is empty if the hardware reports the TEND bit set and the number of data units in the FIFO is zero.
According to the HW manual, the TEND bit has the following meaning:
0: Transmission is in the waiting state or in progress. 1: Transmission is completed.
It has been noticed that when opening the serial device w/o using it and then switch to a power saving mode, the tx_empty() call in the uart_port_suspend() function fails, leading to the "Unable to drain transmitter" message being printed on the console. This is because the TEND=0 if nothing has been transmitted and the FIFOs are empty. As the TEND=0 has double meaning (waiting state, in progress) we can't determined the scenario described above.
Add a software workaround for this. This sets a variable if any data has been sent on the serial console (when using PIO) or if the DMA callback has been called (meaning something has been transmitted). In the tx_empty() API the status of the DMA transaction is also checked and if it is completed or in progress the code falls back in checking the hardware registers instead of relying on the software variable.
[claudiu.beznea: fixed conflict by:
- keeping serial_port_out() instead of sci_port_out() in sci_transmit_chars()
- keeping !uart_circ_empty(xmit) condition in sci_dma_tx_complete(), after s->tx_occurred = true; assignement]
--- drivers/tty/serial/sh-sci.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/tty/serial/sh-sci.c +29 -0
@@ -175,6 +175,7 @@ struct sci_port {bool has_rtscts;bool autorts; +bool tx_occurred; };#define SCI_NPORTS CONFIG_SERIAL_SH_SCI_NR_UARTS
@@ -825,6 +826,7 @@ static void sci_transmit_chars(struct uart_port *port) {struct circ_buf *xmit = &port->state->xmit;unsigned int stopped =uart_tx_stopped (port); +struct sci_port *s =to_sci_port (port);unsigned short status;unsigned short ctrl;int count;
@@ -856,6 +858,7 @@ static void sci_transmit_chars(struct uart_port *port) }serial_port_out (port, SCxTDR, c); + s->tx_occurred = true; port->icount.tx++; }while (--count >0 );
@@ -1208,6 +1211,8 @@ static void sci_dma_tx_complete(void *arg)if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS )uart_write_wakeup (port); + s->tx_occurred = true; +if (!uart_circ_empty (xmit)) { s->cookie_tx =0 ;schedule_work (&s->work_tx);
@@ -1688,6 +1693,19 @@ static void sci_flush_buffer(struct uart_port *port) s->cookie_tx = -EINVAL; } } + +static void sci_dma_check_tx_occurred (struct sci_port *s) +{ +struct dma_tx_state state; +enum dma_status status; + +if (!s->chan_tx) +return ; + + status =dmaengine_tx_status (s->chan_tx, s->cookie_tx, &state); +if (status ==DMA_COMPLETE || status ==DMA_IN_PROGRESS ) + s->tx_occurred = true; +}#else /* !CONFIG_SERIAL_SH_SCI_DMA */ static inline void sci_request_dma (struct uart_port *port) {
@@ -1697,6 +1715,10 @@ static inline void sci_free_dma(struct uart_port *port) { } +static void sci_dma_check_tx_occurred (struct sci_port *s) +{ +} +#define sci_flush_buffer NULL#endif /* !CONFIG_SERIAL_SH_SCI_DMA */
@@ -2009,6 +2031,12 @@ static unsigned int sci_tx_empty(struct uart_port *port) {unsigned short status =serial_port_in (port, SCxSR);unsigned short in_tx_fifo =sci_txfill (port); +struct sci_port *s =to_sci_port (port); + +sci_dma_check_tx_occurred (s); + +if (!s->tx_occurred) +return TIOCSER_TEMT ;return (status &SCxSR_TEND (port)) && !in_tx_fifo ?TIOCSER_TEMT :0 ; }
@@ -2179,6 +2207,7 @@ static int sci_startup(struct uart_port *port)dev_dbg (port->dev,"%s(%d)\n" , __func__, port->line); + s->tx_occurred = false;sci_request_dma (port); ret =sci_request_irq (s);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 221/508 serial: sh-sci: Move runtime PM enable to sci_probe_single()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
commit 239f11209e5f282e16f5241b99256e25dd0614b6 upstream.
Relocate the runtime PM enable operation to sci_probe_single(). This change prepares the codebase for upcoming fixes.
While at it, replace the existing logic with a direct call to devm_pm_runtime_enable() and remove sci_cleanup_single(). The devm_pm_runtime_enable() function automatically handles disabling runtime PM during driver removal.
--- drivers/tty/serial/sh-sci.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)
drivers/tty/serial/sh-sci.c +6 -18
@@ -2982,10 +2982,6 @@ static int sci_init_single(struct platform_device *dev, ret =sci_init_clocks (sci_port, &dev->dev);if (ret <0 )return ret; - - port->dev = &dev->dev; - -pm_runtime_enable (&dev->dev); } port->type = p->type;
@@ -3015,11 +3011,6 @@ static int sci_init_single(struct platform_device *dev,return 0 ; } -static void sci_cleanup_single (struct sci_port *port) -{ -pm_runtime_disable (port->port.dev); -} -#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE ) || \ defined(CONFIG_SERIAL_SH_SCI_EARLYCON )static void serial_console_putchar (struct uart_port *port,unsigned char ch)
@@ -3177,8 +3168,6 @@ static int sci_remove(struct platform_device *dev) sci_ports_in_use &= ~BIT (port->port.line);uart_remove_one_port (&sci_uart_driver, &port->port); -sci_cleanup_single (port); -if (port->port.fifosize >1 )device_remove_file (&dev->dev, &dev_attr_rx_fifo_trigger);if (type ==PORT_SCIFA || type ==PORT_SCIFB || type ==PORT_HSCIF )
@@ -3341,6 +3330,11 @@ static int sci_probe_single(struct platform_device *dev,if (ret)return ret; + sciport->port.dev = &dev->dev; + ret =devm_pm_runtime_enable (&dev->dev); +if (ret) +return ret; + sciport->gpios =mctrl_gpio_init (&sciport->port,0 );if (IS_ERR (sciport->gpios))return PTR_ERR (sciport->gpios);
@@ -3354,13 +3348,7 @@ static int sci_probe_single(struct platform_device *dev, sciport->port.flags |=UPF_HARD_FLOW ; } - ret =uart_add_one_port (&sci_uart_driver, &sciport->port); -if (ret) { -sci_cleanup_single (sciport); -return ret; - } - -return 0 ; +return uart_add_one_port (&sci_uart_driver, &sciport->port); }static int sci_probe (struct platform_device *dev)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 222/508 serial: sh-sci: Clean sci_ports[0] after at earlycon exit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
commit 5f1017069933489add0c08659673443c9905659e upstream.
The early_console_setup() function initializes sci_ports[0].port with an object of type struct uart_port obtained from the struct earlycon_device passed as an argument to early_console_setup().
Later, during serial port probing, the serial port used as earlycon (e.g., port A) might be remapped to a different position in the sci_ports[] array, and a different serial port (e.g., port B) might be assigned to slot
0. For example:
sci_ports[0] = port B
sci_ports[X] = port A
In this scenario, the new port mapped at index zero (port B) retains the data associated with the earlycon configuration. Consequently, after the Linux boot process, any access to the serial port now mapped to sci_ports[0] (port B) will block the original earlycon port (port A).
To address this, introduce an early_console_exit() function to clean up sci_ports[0] when earlycon is exited.
To prevent the cleanup of sci_ports[0] while the serial device is still being used by earlycon, introduce the struct sci_port::probing flag and account for it in early_console_exit().
--- drivers/tty/serial/sh-sci.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-)
drivers/tty/serial/sh-sci.c +30 -2
@@ -184,6 +184,7 @@ static struct sci_port sci_ports[SCI_NPORTS];static unsigned long sci_ports_in_use;static struct uart_driver sci_uart_driver;static bool sci_uart_earlycon; +static bool sci_uart_earlycon_dev_probing;static inline struct sci_port *to_sci_port (struct uart_port *uart)
@@ -3301,7 +3302,8 @@ static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev,static int sci_probe_single (struct platform_device *dev,unsigned int index,struct plat_sci_port *p, -struct sci_port *sciport) +struct sci_port *sciport, +struct resource *sci_res) {int ret;
@@ -3348,6 +3350,14 @@ static int sci_probe_single(struct platform_device *dev, sciport->port.flags |=UPF_HARD_FLOW ; } +if (sci_uart_earlycon && sci_ports[0 ].port.mapbase == sci_res->start) { +/* +* Skip cleanup the sci_port[0] in early_console_exit(), this +* port is the same as the earlycon one. +*/ + sci_uart_earlycon_dev_probing = true; + } +return uart_add_one_port (&sci_uart_driver, &sciport->port); }
@@ -3406,7 +3416,7 @@ static int sci_probe(struct platform_device *dev)platform_set_drvdata (dev, sp); - ret =sci_probe_single (dev, dev_id, p, sp); + ret =sci_probe_single (dev, dev_id, p, sp, res);if (ret)return ret;
@@ -3563,6 +3573,22 @@ sh_early_platform_init_buffer("earlyprintk", &sci_driver,#ifdef CONFIG_SERIAL_SH_SCI_EARLYCON static struct plat_sci_port port_cfg; +static int early_console_exit (struct console *co) +{ +struct sci_port *sci_port = &sci_ports[0 ]; + +/* +* Clean the slot used by earlycon. A new SCI device might +* map to this slot. +*/ +if (!sci_uart_earlycon_dev_probing) { +memset (sci_port,0 ,sizeof (*sci_port)); + sci_uart_earlycon = false; + } + +return 0 ; +} +static int __init early_console_setup (struct earlycon_device *device,int type) {
@@ -3582,6 +3608,8 @@ static int __init early_console_setup(struct earlycon_device *device, SCSCR_RE | SCSCR_TE | port_cfg.scscr); device->con->write = serial_console_write; + device->con->exit = early_console_exit; +return 0 ; } static int __init sci_early_console_setup(struct earlycon_device *device,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 223/508 scsi: core: ufs: Fix a hang in the error handler
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanjeev Yadav <[email protected]>
[ Upstream commit 8a3514d348de87a9d5e2ac00fbac4faae0b97996 ]
ufshcd_err_handling_prepare() calls ufshcd_rpm_get_sync(). The latter function can only succeed if UFSHCD_EH_IN_PROGRESS is not set because resuming involves submitting a SCSI command and ufshcd_queuecommand() returns SCSI_MLQUEUE_HOST_BUSY if UFSHCD_EH_IN_PROGRESS is set. Fix this hang by setting UFSHCD_EH_IN_PROGRESS after ufshcd_rpm_get_sync() has been called instead of before.
Backtrace: __switch_to+0x174/0x338 __schedule+0x600/0x9e4 schedule+0x7c/0xe8 schedule_timeout+0xa4/0x1c8 io_schedule_timeout+0x48/0x70 wait_for_common_io+0xa8/0x160 //waiting on START_STOP wait_for_completion_io_timeout+0x10/0x20 blk_execute_rq+0xe4/0x1e4 scsi_execute_cmd+0x108/0x244 ufshcd_set_dev_pwr_mode+0xe8/0x250 __ufshcd_wl_resume+0x94/0x354 ufshcd_wl_runtime_resume+0x3c/0x174 scsi_runtime_resume+0x64/0xa4 rpm_resume+0x15c/0xa1c __pm_runtime_resume+0x4c/0x90 // Runtime resume ongoing ufshcd_err_handler+0x1a0/0xd08 process_one_work+0x174/0x808 worker_thread+0x15c/0x490 kthread+0xf4/0x1ec ret_from_fork+0x10/0x20
--- drivers/ufs/core/ufshcd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/ufs/core/ufshcd.c +6 -1
@@ -6285,9 +6285,14 @@ static void ufshcd_err_handler(struct work_struct *work)up (&hba->host_sem);return ; } -ufshcd_set_eh_in_progress (hba);spin_unlock_irqrestore (hba->host->host_lock, flags); +ufshcd_err_handling_prepare (hba); + +spin_lock_irqsave (hba->host->host_lock, flags); +ufshcd_set_eh_in_progress (hba); +spin_unlock_irqrestore (hba->host->host_lock, flags); +/* Complete requests that have door-bell cleared by h/w */ ufshcd_complete_requests (hba);spin_lock_irqsave (hba->host->host_lock, flags);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 224/508 Bluetooth: hci_core: fix list_for_each_entry_rcu usage
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 308a3a8ce8ea41b26c46169f3263e50f5997c28e ]
Releasing + re-acquiring RCU lock inside list_for_each_entry_rcu() loop body is not correct.
Fix by taking the update-side hdev->lock instead.
--- net/bluetooth/hci_core.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
net/bluetooth/hci_core.c +3 -8
@@ -3402,23 +3402,18 @@ static void hci_link_tx_to(struct hci_dev *hdev, __u8 type)bt_dev_err (hdev,"link tx timeout" ); -rcu_read_lock (); +hci_dev_lock (hdev);/* Kill stalled connections */ -list_for_each_entry_rcu (c, &h->list, list) { +list_for_each_entry (c, &h->list, list) {if (c->type == type && c->sent) {bt_dev_err (hdev,"killing stalled connection %pMR" , &c->dst); -/* hci_disconnect might sleep, so, we have to release -* the RCU read lock before calling it. -*/ -rcu_read_unlock ();hci_disconnect (c,HCI_ERROR_REMOTE_USER_TERM ); -rcu_read_lock (); } } -rcu_read_unlock (); +hci_dev_unlock (hdev); } static struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 225/508 Bluetooth: MGMT: Fix UAF on mgmt_remove_adv_monitor_complete
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit e6ed54e86aae9e4f7286ce8d5c73780f91b48d1c ]
This reworks MGMT_OP_REMOVE_ADV_MONITOR to not use mgmt_pending_add to avoid crashes like bellow:
==================================================================
BUG: KASAN: slab-use-after-free in mgmt_remove_adv_monitor_complete+0xe5/0x540 net/bluetooth/mgmt.c:5406 Read of size 8 at addr ffff88801c53f318 by task kworker/u5:5/5341 CPU: 0 UID: 0 PID: 5341 Comm: kworker/u5:5 Not tainted 6.15.0-syzkaller-10402-g4cb6c8af8591 #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Workqueue: hci0 hci_cmd_sync_work Call Trace: <TASK> dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:408 [inline] print_report+0xd2/0x2b0 mm/kasan/report.c:521 kasan_report+0x118/0x150 mm/kasan/report.c:634 mgmt_remove_adv_monitor_complete+0xe5/0x540 net/bluetooth/mgmt.c:5406 hci_cmd_sync_work+0x261/0x3a0 net/bluetooth/hci_sync.c:334 process_one_work kernel/workqueue.c:3238 [inline] process_scheduled_works+0xade/0x17b0 kernel/workqueue.c:3321 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3402 kthread+0x711/0x8a0 kernel/kthread.c:464 ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK> Allocated by task 5987: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:377 [inline] __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:394 kasan_kmalloc include/linux/kasan.h:260 [inline] __kmalloc_cache_noprof+0x230/0x3d0 mm/slub.c:4358 kmalloc_noprof include/linux/slab.h:905 [inline] kzalloc_noprof include/linux/slab.h:1039 [inline] mgmt_pending_new+0x65/0x240 net/bluetooth/mgmt_util.c:252 mgmt_pending_add+0x34/0x120 net/bluetooth/mgmt_util.c:279 remove_adv_monitor+0x103/0x1b0 net/bluetooth/mgmt.c:5454 hci_mgmt_cmd+0x9c9/0xef0 net/bluetooth/hci_sock.c:1719 hci_sock_sendmsg+0x6ca/0xef0 net/bluetooth/hci_sock.c:1839 sock_sendmsg_nosec net/socket.c:712 [inline] __sock_sendmsg+0x219/0x270 net/socket.c:727 sock_write_iter+0x258/0x330 net/socket.c:1131 new_sync_write fs/read_write.c:593 [inline] vfs_write+0x548/0xa90 fs/read_write.c:686 ksys_write+0x145/0x250 fs/read_write.c:738 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 5989: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:576 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x62/0x70 mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2380 [inline] slab_free mm/slub.c:4642 [inline] kfree+0x18e/0x440 mm/slub.c:4841 mgmt_pending_foreach+0xc9/0x120 net/bluetooth/mgmt_util.c:242 mgmt_index_removed+0x10d/0x2f0 net/bluetooth/mgmt.c:9366 hci_sock_bind+0xbe9/0x1000 net/bluetooth/hci_sock.c:1314 __sys_bind_socket net/socket.c:1810 [inline] __sys_bind+0x2c3/0x3e0 net/socket.c:1841 __do_sys_bind net/socket.c:1846 [inline] __se_sys_bind net/socket.c:1844 [inline] __x64_sys_bind+0x7a/0x90 net/socket.c:1844 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- include/net/bluetooth/hci_core.h | 1 - net/bluetooth/hci_core.c | 4 +--- net/bluetooth/mgmt.c | 37 ++++++++++---------------------- 3 files changed, 12 insertions(+), 30 deletions(-)
include/net/bluetooth/hci_core.h +0 -1
@@ -2125,7 +2125,6 @@ void mgmt_advertising_added(struct sock *sk, struct hci_dev *hdev, u8 instance);void mgmt_advertising_removed (struct sock *sk,struct hci_dev *hdev,u8 instance); -void mgmt_adv_monitor_removed (struct hci_dev *hdev,u16 handle);int mgmt_phy_configuration_changed (struct hci_dev *hdev,struct sock *skip);void mgmt_adv_monitor_device_lost (struct hci_dev *hdev,u16 handle,bdaddr_t *bdaddr,u8 addr_type);
net/bluetooth/hci_core.c +1 -3
@@ -1873,10 +1873,8 @@ void hci_free_adv_monitor(struct hci_dev *hdev, struct adv_monitor *monitor)if (monitor->handle)idr_remove (&hdev->adv_monitors_idr, monitor->handle); -if (monitor->state !=ADV_MONITOR_STATE_NOT_REGISTERED ) { +if (monitor->state !=ADV_MONITOR_STATE_NOT_REGISTERED ) hdev->adv_monitors_cnt--; -mgmt_adv_monitor_removed (hdev, monitor->handle); - }kfree (monitor); }
net/bluetooth/mgmt.c +11 -26
@@ -5236,24 +5236,14 @@ static void mgmt_adv_monitor_added(struct sock *sk, struct hci_dev *hdev,mgmt_event (MGMT_EV_ADV_MONITOR_ADDED , hdev, &ev,sizeof (ev), sk); } -void mgmt_adv_monitor_removed (struct hci_dev *hdev,u16 handle) +static void mgmt_adv_monitor_removed (struct sock *sk,struct hci_dev *hdev, +u16 handle) {struct mgmt_ev_adv_monitor_removed ev; -struct mgmt_pending_cmd *cmd; -struct sock *sk_skip =NULL ; -struct mgmt_cp_remove_adv_monitor *cp; - - cmd =pending_find (MGMT_OP_REMOVE_ADV_MONITOR , hdev); -if (cmd) { - cp = cmd->param; - -if (cp->monitor_handle) - sk_skip = cmd->sk; - } ev.monitor_handle =cpu_to_le16 (handle); -mgmt_event (MGMT_EV_ADV_MONITOR_REMOVED , hdev, &ev,sizeof (ev), sk_skip); +mgmt_event (MGMT_EV_ADV_MONITOR_REMOVED , hdev, &ev,sizeof (ev), sk); } static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev,
@@ -5355,8 +5345,7 @@ static int __add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev,if (pending_find (MGMT_OP_SET_LE , hdev) ||pending_find (MGMT_OP_ADD_ADV_PATTERNS_MONITOR , hdev) || -pending_find (MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI , hdev) || -pending_find (MGMT_OP_REMOVE_ADV_MONITOR , hdev)) { +pending_find (MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI , hdev)) { status =MGMT_STATUS_BUSY ; goto unlock; }
@@ -5526,8 +5515,7 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev,struct mgmt_pending_cmd *cmd = data;struct mgmt_cp_remove_adv_monitor *cp; -if (status == -ECANCELED || - cmd !=pending_find (MGMT_OP_REMOVE_ADV_MONITOR , hdev)) +if (status == -ECANCELED )return ;hci_dev_lock (hdev);
@@ -5536,12 +5524,14 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev, rp.monitor_handle = cp->monitor_handle; -if (!status) +if (!status) { +mgmt_adv_monitor_removed (cmd->sk, hdev, cp->monitor_handle);hci_update_passive_scan (hdev); + }mgmt_cmd_complete (cmd->sk, cmd->index, cmd->opcode,mgmt_status (status), &rp,sizeof (rp)); -mgmt_pending_remove (cmd); +mgmt_pending_free (cmd);hci_dev_unlock (hdev); bt_dev_dbg(hdev, "remove monitor %d complete, status %d",
@@ -5551,10 +5541,6 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev,static int mgmt_remove_adv_monitor_sync (struct hci_dev *hdev,void *data) {struct mgmt_pending_cmd *cmd = data; - -if (cmd !=pending_find (MGMT_OP_REMOVE_ADV_MONITOR , hdev)) -return -ECANCELED ; -struct mgmt_cp_remove_adv_monitor *cp = cmd->param;u16 handle =__le16_to_cpu (cp->monitor_handle);
@@ -5573,14 +5559,13 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev,hci_dev_lock (hdev);if (pending_find (MGMT_OP_SET_LE , hdev) || -pending_find (MGMT_OP_REMOVE_ADV_MONITOR , hdev) ||pending_find (MGMT_OP_ADD_ADV_PATTERNS_MONITOR , hdev) ||pending_find (MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI , hdev)) { status =MGMT_STATUS_BUSY ; goto unlock; } - cmd =mgmt_pending_add (sk,MGMT_OP_REMOVE_ADV_MONITOR , hdev, data, len); + cmd =mgmt_pending_new (sk,MGMT_OP_REMOVE_ADV_MONITOR , hdev, data, len);if (!cmd) { status =MGMT_STATUS_NO_RESOURCES ; goto unlock;
@@ -5590,7 +5575,7 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev, mgmt_remove_adv_monitor_complete);if (err) { -mgmt_pending_remove (cmd); +mgmt_pending_free (cmd);if (err == -ENOMEM ) status =MGMT_STATUS_NO_RESOURCES ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 226/508 ptp: remove ptp->n_vclocks check logic in ptp_vclock_in_use()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
[ Upstream commit 87f7ce260a3c838b49e1dc1ceedf1006795157a2 ]
There is no disagreement that we should check both ptp->is_virtual_clock and ptp->n_vclocks to check if the ptp virtual clock is in use.
However, when we acquire ptp->n_vclocks_mux to read ptp->n_vclocks in ptp_vclock_in_use(), we observe a recursive lock in the call trace starting from n_vclocks_store().
============================================
WARNING: possible recursive locking detected 6.15.0-rc6 #1 Not tainted
--------------------------------------------
syz.0.1540/13807 is trying to acquire lock:ffff888035a24868 (&ptp->n_vclocks_mux){+.+.}-{4:4}, at:
ptp_vclock_in_use drivers/ptp/ptp_private.h:103 [inline]ffff888035a24868 (&ptp->n_vclocks_mux){+.+.}-{4:4}, at:
ptp_clock_unregister+0x21/0x250 drivers/ptp/ptp_clock.c:415
but task is already holding lock:ffff888030704868 (&ptp->n_vclocks_mux){+.+.}-{4:4}, at:
n_vclocks_store+0xf1/0x6d0 drivers/ptp/ptp_sysfs.c:215
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(&ptp->n_vclocks_mux);
lock(&ptp->n_vclocks_mux);
*** DEADLOCK ***
....
============================================
The best way to solve this is to remove the logic that checks ptp->n_vclocks in ptp_vclock_in_use().
The reason why this is appropriate is that any path that uses ptp->n_vclocks must unconditionally check if ptp->n_vclocks is greater than 0 before unregistering vclocks, and all functions are already written this way. And in the function that uses ptp->n_vclocks, we already get ptp->n_vclocks_mux before unregistering vclocks.
Therefore, we need to remove the redundant check for ptp->n_vclocks in ptp_vclock_in_use() to prevent recursive locking.
--- drivers/ptp/ptp_private.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/ptp/ptp_private.h +1 -11
@@ -89,17 +89,7 @@ static inline int queue_cnt(const struct timestamp_event_queue *q)/* Check if ptp virtual clock is in use */ static inline bool ptp_vclock_in_use (struct ptp_clock *ptp) { -bool in_use = false; - -if (mutex_lock_interruptible (&ptp->n_vclocks_mux)) -return true; - -if (!ptp->is_virtual_clock && ptp->n_vclocks) - in_use = true; - -mutex_unlock (&ptp->n_vclocks_mux); - -return in_use; +return !ptp->is_virtual_clock; }/* Check if ptp clock shall be free running */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 227/508 ath10k: snoc: fix unbalanced IRQ enable in crash recovery
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Caleb Connolly <[email protected]>
[ Upstream commit 1650d32b92b01db03a1a95d69ee74fcbc34d4b00 ]
In ath10k_snoc_hif_stop() we skip disabling the IRQs in the crash recovery flow, but we still unconditionally call enable again in ath10k_snoc_hif_start().
We can't check the ATH10K_FLAG_CRASH_FLUSH bit since it is cleared before hif_start() is called, so instead check the ATH10K_SNOC_FLAG_RECOVERY flag and skip enabling the IRQs during crash recovery.
This fixes unbalanced IRQ enable splats that happen after recovering from a crash.
--- drivers/net/wireless/ath/ath10k/snoc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/snoc.c +3 -1
@@ -936,7 +936,9 @@ static int ath10k_snoc_hif_start(struct ath10k *ar)bitmap_clear (ar_snoc->pending_ce_irqs,0 ,CE_COUNT_MAX );ath10k_core_napi_enable (ar); -ath10k_snoc_irq_enable (ar); +/* IRQs are left enabled when we restart due to a firmware crash */ +if (!test_bit (ATH10K_SNOC_FLAG_RECOVERY , &ar_snoc->flags)) +ath10k_snoc_irq_enable (ar);ath10k_snoc_rx_post (ar);clear_bit (ATH10K_SNOC_FLAG_RECOVERY , &ar_snoc->flags);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 228/508 wifi: ath11k: remove unused function ath11k_tm_event_wmi()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Govindaraj Saminathan <[email protected]>
[ Upstream commit 86f85575a3f6a20cef1c8bb98e78585fe3a53ccc ]
The function ath11k_tm_event_wmi() is only defined and it is not used anywhere. Hence remove the unused.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
Stable-dep-of: 9f6e82d11bb9 ("wifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()")
--- drivers/net/wireless/ath/ath11k/testmode.c | 64 +--------------------- drivers/net/wireless/ath/ath11k/testmode.h | 8 +-- 2 files changed, 2 insertions(+), 70 deletions(-)
drivers/net/wireless/ath/ath11k/testmode.c +1 -63
@@ -1,6 +1,7 @@// SPDX-License-Identifier: BSD-3-Clause-Clear /* * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved. +* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include "testmode.h"
@@ -20,69 +21,6 @@ static const struct nla_policy ath11k_tm_policy[ATH11K_TM_ATTR_MAX + 1] = { [ATH11K_TM_ATTR_VERSION_MINOR] = { .type = NLA_U32 }, }; -/* Returns true if callee consumes the skb and the skb should be discarded. -* Returns false if skb is not used. Does not sleep. -*/ -bool ath11k_tm_event_wmi (struct ath11k *ar,u32 cmd_id,struct sk_buff *skb) -{ -struct sk_buff *nl_skb; -bool consumed; -int ret; - -ath11k_dbg (ar->ab,ATH11K_DBG_TESTMODE , -"testmode event wmi cmd_id %d skb %pK skb->len %d\n" , - cmd_id, skb, skb->len); - -ath11k_dbg_dump (ar->ab,ATH11K_DBG_TESTMODE ,NULL ,"" , skb->data, skb->len); - -spin_lock_bh (&ar->data_lock); - - consumed = true; - - nl_skb =cfg80211_testmode_alloc_event_skb (ar->hw->wiphy, -2 *sizeof (u32) + skb->len, -GFP_ATOMIC ); -if (!nl_skb) { -ath11k_warn (ar->ab, -"failed to allocate skb for testmode wmi event\n" ); - goto out; - } - - ret =nla_put_u32 (nl_skb,ATH11K_TM_ATTR_CMD ,ATH11K_TM_CMD_WMI ); -if (ret) { -ath11k_warn (ar->ab, -"failed to put testmode wmi event cmd attribute: %d\n" , - ret); -kfree_skb (nl_skb); - goto out; - } - - ret =nla_put_u32 (nl_skb,ATH11K_TM_ATTR_WMI_CMDID , cmd_id); -if (ret) { -ath11k_warn (ar->ab, -"failed to put testmode wmi even cmd_id: %d\n" , - ret); -kfree_skb (nl_skb); - goto out; - } - - ret =nla_put (nl_skb,ATH11K_TM_ATTR_DATA , skb->len, skb->data); -if (ret) { -ath11k_warn (ar->ab, -"failed to copy skb to testmode wmi event: %d\n" , - ret); -kfree_skb (nl_skb); - goto out; - } - -cfg80211_testmode_event (nl_skb,GFP_ATOMIC ); - -out: -spin_unlock_bh (&ar->data_lock); - -return consumed; -} -static int ath11k_tm_cmd_get_version (struct ath11k *ar,struct nlattr *tb[]) {struct sk_buff *skb;
drivers/net/wireless/ath/ath11k/testmode.h +1 -7
@@ -1,24 +1,18 @@/* SPDX-License-Identifier: BSD-3-Clause-Clear */ /* * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved. +* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include "core.h" #ifdef CONFIG_NL80211_TESTMODE -bool ath11k_tm_event_wmi (struct ath11k *ar,u32 cmd_id,struct sk_buff *skb);int ath11k_tm_cmd (struct ieee80211_hw *hw,struct ieee80211_vif *vif,void *data,int len);#else -static inline bool ath11k_tm_event_wmi (struct ath11k *ar,u32 cmd_id, -struct sk_buff *skb) -{ -return false; -} -static inline int ath11k_tm_cmd (struct ieee80211_hw *hw,struct ieee80211_vif *vif,void *data,int len)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 229/508 wifi: ath11k: fix soc_dp_stats debugfs file permission
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit fa645e663165d69f05f95a0c3aa3b3d08f4fdeda ]
Currently the soc_dp_stats debugfs file has the following permissions:
-rw------- 1 root root 0 Mar 4 15:04 /sys/kernel/debug/ath11k/pci-0000:03:00.0/soc_dp_stats
However this file does not actually support write operations -- no .write() method is registered. Therefore use the correct permissions when creating the file.
After the change:
-r-------- 1 root root 0 Mar 4 15:15 /sys/kernel/debug/ath11k/pci-0000:03:00.0/soc_dp_stats
Tested-on: WCN6855 hw2.1 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.30
Stable-dep-of: 9f6e82d11bb9 ("wifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()")
--- drivers/net/wireless/ath/ath11k/debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/debugfs.c +2 -1
@@ -1,6 +1,7 @@// SPDX-License-Identifier: BSD-3-Clause-Clear /* * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved. +* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved. */ #include <linux/vmalloc.h>
@@ -979,7 +980,7 @@ int ath11k_debugfs_pdev_create(struct ath11k_base *ab)debugfs_create_file ("simulate_fw_crash" ,0600 , ab->debugfs_soc, ab, &fops_simulate_fw_crash); -debugfs_create_file ("soc_dp_stats" ,0600 , ab->debugfs_soc, ab, +debugfs_create_file ("soc_dp_stats" ,0400 , ab->debugfs_soc, ab, &fops_soc_dp_stats);if (ab->hw_params.sram_dump.start !=0 )
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 230/508 wifi: ath11k: convert timeouts to secs_to_jiffies()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Easwar Hariharan <[email protected]>
[ Upstream commit b29425972c5234a59b6fb634125420ed74266377 ]
Commit b35108a51cf7 ("jiffies: Define secs_to_jiffies()") introduced secs_to_jiffies(). As the value here is a multiple of 1000, use secs_to_jiffies() instead of msecs_to_jiffies to avoid the multiplication.
This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with the following Coccinelle rules:
@@ constant C; @@
- msecs_to_jiffies(C * 1000)
+ secs_to_jiffies(C)
@@ constant C; @@
- msecs_to_jiffies(C * MSEC_PER_SEC)
+ secs_to_jiffies(C)
Stable-dep-of: 9f6e82d11bb9 ("wifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()")
--- drivers/net/wireless/ath/ath11k/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/debugfs.c +1 -1
@@ -178,7 +178,7 @@ static int ath11k_debugfs_fw_stats_request(struct ath11k *ar,* received 'update stats' event, we keep a 3 seconds timeout in case, * fw_stats_done is not marked yet */ - timeout = jiffies +msecs_to_jiffies (3 *1000 ); + timeout = jiffies +secs_to_jiffies (3 );ath11k_debugfs_fw_stats_reset (ar);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 231/508 wifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baochen Qiang <[email protected]>
[ Upstream commit 9f6e82d11bb9692a90d20b10f87345598945c803 ]
We get report [1] that CPU is running a hot loop in ath11k_debugfs_fw_stats_request():
94.60% 0.00% i3status [kernel.kallsyms] [k] do_syscall_64
|
--94.60%--do_syscall_64
|
--94.55%--__sys_sendmsg
___sys_sendmsg
____sys_sendmsg
netlink_sendmsg
netlink_unicast
genl_rcv
netlink_rcv_skb
genl_rcv_msg
|
--94.55%--genl_family_rcv_msg_dumpit
__netlink_dump_start
netlink_dump
genl_dumpit
nl80211_dump_station
|
--94.55%--ieee80211_dump_station
sta_set_sinfo
|
--94.55%--ath11k_mac_op_sta_statistics
ath11k_debugfs_get_fw_stats
|
--94.55%--ath11k_debugfs_fw_stats_request
|
|--41.73%--_raw_spin_lock_bh
|
|--22.74%--__local_bh_enable_ip
|
|--9.22%--_raw_spin_unlock_bh
|
--6.66%--srso_alias_safe_retThis is because, if for whatever reason ar->fw_stats_done is not set by ath11k_update_stats_event(), ath11k_debugfs_fw_stats_request() won't yield CPU before an up to 3s timeout.
Change to completion mechanism to avoid CPU burning.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.37
--- drivers/net/wireless/ath/ath11k/core.c | 1 + drivers/net/wireless/ath/ath11k/core.h | 2 +- drivers/net/wireless/ath/ath11k/debugfs.c | 38 +++++++++-------------- drivers/net/wireless/ath/ath11k/mac.c | 2 +- drivers/net/wireless/ath/ath11k/wmi.c | 2 +- 5 files changed, 18 insertions(+), 27 deletions(-)
drivers/net/wireless/ath/ath11k/core.c +1 -0
@@ -644,6 +644,7 @@ void ath11k_fw_stats_init(struct ath11k *ar)INIT_LIST_HEAD (&ar->fw_stats.bcn);init_completion (&ar->fw_stats_complete); +init_completion (&ar->fw_stats_done); }void ath11k_fw_stats_free (struct ath11k_fw_stats *stats)
drivers/net/wireless/ath/ath11k/core.h +1 -1
@@ -718,7 +718,7 @@ struct ath11k {u8 alpha2[REG_ALPHA2_LEN +1 ];struct ath11k_fw_stats fw_stats;struct completion fw_stats_complete; -bool fw_stats_done; +struct completion fw_stats_done;/* protected by conf_mutex */ bool ps_state_enable;
drivers/net/wireless/ath/ath11k/debugfs.c +14 -24
@@ -1,7 +1,7 @@// SPDX-License-Identifier: BSD-3-Clause-Clear /* * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved. -* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved. +* Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved. */ #include <linux/vmalloc.h>
@@ -96,7 +96,6 @@ void ath11k_debugfs_add_dbring_entry(struct ath11k *ar,static void ath11k_debugfs_fw_stats_reset (struct ath11k *ar) {spin_lock_bh (&ar->data_lock); - ar->fw_stats_done = false;ath11k_fw_stats_pdevs_free (&ar->fw_stats.pdevs);ath11k_fw_stats_vdevs_free (&ar->fw_stats.vdevs);spin_unlock_bh (&ar->data_lock);
@@ -114,7 +113,7 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats */* WMI_REQUEST_PDEV_STAT request has been already processed */ if (stats->stats_id ==WMI_REQUEST_RSSI_PER_CHAIN_STAT ) { - ar->fw_stats_done = true; +complete (&ar->fw_stats_done);return ; }
@@ -138,7 +137,7 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats * &ar->fw_stats.vdevs);if (is_end) { - ar->fw_stats_done = true; +complete (&ar->fw_stats_done); num_vdev =0 ; }return ;
@@ -158,7 +157,7 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats * &ar->fw_stats.bcn);if (is_end) { - ar->fw_stats_done = true; +complete (&ar->fw_stats_done); num_bcn =0 ; } }
@@ -168,21 +167,15 @@ static int ath11k_debugfs_fw_stats_request(struct ath11k *ar, struct stats_request_params *req_param) {struct ath11k_base *ab = ar->ab; -unsigned long timeout, time_left; +unsigned long time_left;int ret;lockdep_assert_held (&ar->conf_mutex); -/* FW stats can get split when exceeding the stats data buffer limit. -* In that case, since there is no end marking for the back-to-back -* received 'update stats' event, we keep a 3 seconds timeout in case, -* fw_stats_done is not marked yet -*/ - timeout = jiffies +secs_to_jiffies (3 ); -ath11k_debugfs_fw_stats_reset (ar);reinit_completion (&ar->fw_stats_complete); +reinit_completion (&ar->fw_stats_done); ret =ath11k_wmi_send_stats_request_cmd (ar, req_param);
@@ -193,21 +186,18 @@ static int ath11k_debugfs_fw_stats_request(struct ath11k *ar, } time_left =wait_for_completion_timeout (&ar->fw_stats_complete,1 *HZ ); -if (!time_left)return -ETIMEDOUT ; -for (;;) { -if (time_after (jiffies, timeout)) -break ; +/* FW stats can get split when exceeding the stats data buffer limit. +* In that case, since there is no end marking for the back-to-back +* received 'update stats' event, we keep a 3 seconds timeout in case, +* fw_stats_done is not marked yet +*/ + time_left =wait_for_completion_timeout (&ar->fw_stats_done,3 *HZ ); +if (!time_left) +return -ETIMEDOUT ; -spin_lock_bh (&ar->data_lock); -if (ar->fw_stats_done) { -spin_unlock_bh (&ar->data_lock); -break ; - } -spin_unlock_bh (&ar->data_lock); - }return 0 ; }
drivers/net/wireless/ath/ath11k/mac.c +1 -1
@@ -8510,11 +8510,11 @@ static int ath11k_fw_stats_request(struct ath11k *ar,lockdep_assert_held (&ar->conf_mutex);spin_lock_bh (&ar->data_lock); - ar->fw_stats_done = false;ath11k_fw_stats_pdevs_free (&ar->fw_stats.pdevs);spin_unlock_bh (&ar->data_lock);reinit_completion (&ar->fw_stats_complete); +reinit_completion (&ar->fw_stats_done); ret =ath11k_wmi_send_stats_request_cmd (ar, req_param);if (ret) {
drivers/net/wireless/ath/ath11k/wmi.c +1 -1
@@ -7575,7 +7575,7 @@ static void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *sk*/ if (stats.stats_id ==WMI_REQUEST_PDEV_STAT ) {list_splice_tail_init (&stats.pdevs, &ar->fw_stats.pdevs); - ar->fw_stats_done = true; +complete (&ar->fw_stats_done); goto complete; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 232/508 wifi: ath11k: dont use static variables in ath11k_debugfs_fw_stats_process()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baochen Qiang <[email protected]>
[ Upstream commit 2bcf73b2612dda7432f2c2eaad6679bd291791f2 ]
Currently ath11k_debugfs_fw_stats_process() is using static variables to count firmware stat events. Taking num_vdev as an example, if for whatever reason ( say ar->num_started_vdevs is 0 or firmware bug etc.) the following condition
(++num_vdev) == total_vdevs_started
is not met, is_end is not set thus num_vdev won't be cleared. Next time when firmware stats is requested again, even if everything is working fine, we will fail due to the condition above will never be satisfied.
The same applies to num_bcn as well.
Change to use non-static counters so that we have a chance to clear them each time firmware stats is requested. Currently only ath11k_fw_stats_request() and ath11k_debugfs_fw_stats_request() are requesting firmware stats, so clear counters there.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.37
--- drivers/net/wireless/ath/ath11k/core.h | 2 ++ drivers/net/wireless/ath/ath11k/debugfs.c | 16 +++++++--------- drivers/net/wireless/ath/ath11k/mac.c | 2 ++ 3 files changed, 11 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath11k/core.h +2 -0
@@ -538,6 +538,8 @@ struct ath11k_fw_stats {struct list_head pdevs;struct list_head vdevs;struct list_head bcn; +u32 num_vdev_recvd; +u32 num_bcn_recvd; };struct ath11k_dbg_htt_stats {
drivers/net/wireless/ath/ath11k/debugfs.c +7 -9
@@ -98,6 +98,8 @@ static void ath11k_debugfs_fw_stats_reset(struct ath11k *ar)spin_lock_bh (&ar->data_lock);ath11k_fw_stats_pdevs_free (&ar->fw_stats.pdevs);ath11k_fw_stats_vdevs_free (&ar->fw_stats.vdevs); + ar->fw_stats.num_vdev_recvd =0 ; + ar->fw_stats.num_bcn_recvd =0 ;spin_unlock_bh (&ar->data_lock); }
@@ -106,7 +108,6 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *struct ath11k_base *ab = ar->ab;struct ath11k_pdev *pdev;bool is_end; -static unsigned int num_vdev, num_bcn;size_t total_vdevs_started =0 ;int i;
@@ -131,15 +132,14 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats * total_vdevs_started += ar->num_started_vdevs; } - is_end = ((++num_vdev) == total_vdevs_started); + is_end = ((++ar->fw_stats.num_vdev_recvd) == total_vdevs_started);list_splice_tail_init (&stats->vdevs, &ar->fw_stats.vdevs); -if (is_end) { +if (is_end)complete (&ar->fw_stats_done); - num_vdev =0 ; - } +return ; }
@@ -151,15 +151,13 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats */* Mark end until we reached the count of all started VDEVs * within the PDEV */ - is_end = ((++num_bcn) == ar->num_started_vdevs); + is_end = ((++ar->fw_stats.num_bcn_recvd) == ar->num_started_vdevs);list_splice_tail_init (&stats->bcn, &ar->fw_stats.bcn); -if (is_end) { +if (is_end)complete (&ar->fw_stats_done); - num_bcn =0 ; - } } }
drivers/net/wireless/ath/ath11k/mac.c +2 -0
@@ -8511,6 +8511,8 @@ static int ath11k_fw_stats_request(struct ath11k *ar,spin_lock_bh (&ar->data_lock);ath11k_fw_stats_pdevs_free (&ar->fw_stats.pdevs); + ar->fw_stats.num_vdev_recvd =0 ; + ar->fw_stats.num_bcn_recvd =0 ;spin_unlock_bh (&ar->data_lock);reinit_completion (&ar->fw_stats_complete);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 233/508 wifi: ath11k: dont wait when there is no vdev started
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baochen Qiang <[email protected]>
[ Upstream commit 3b6d00fa883075dcaf49221538230e038a9c0b43 ]
For WMI_REQUEST_VDEV_STAT request, firmware might split response into multiple events dut to buffer limit, hence currently in ath11k_debugfs_fw_stats_process() we wait until all events received. In case there is no vdev started, this results in that below condition would never get satisfied
((++ar->fw_stats.num_vdev_recvd) == total_vdevs_started)
finally the requestor would be blocked until wait time out.
The same applies to WMI_REQUEST_BCN_STAT request as well due to:
((++ar->fw_stats.num_bcn_recvd) == ar->num_started_vdevs)
Change to check the number of started vdev first: if it is zero, finish wait directly; if not, follow the old way.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.37
--- drivers/net/wireless/ath/ath11k/debugfs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath11k/debugfs.c +7 -3
@@ -107,7 +107,7 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats * {struct ath11k_base *ab = ar->ab;struct ath11k_pdev *pdev; -bool is_end; +bool is_end = true;size_t total_vdevs_started =0 ;int i;
@@ -132,7 +132,9 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats * total_vdevs_started += ar->num_started_vdevs; } - is_end = ((++ar->fw_stats.num_vdev_recvd) == total_vdevs_started); +if (total_vdevs_started) + is_end = ((++ar->fw_stats.num_vdev_recvd) == + total_vdevs_started);list_splice_tail_init (&stats->vdevs, &ar->fw_stats.vdevs);
@@ -151,7 +153,9 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats */* Mark end until we reached the count of all started VDEVs * within the PDEV */ - is_end = ((++ar->fw_stats.num_bcn_recvd) == ar->num_started_vdevs); +if (ar->num_started_vdevs) + is_end = ((++ar->fw_stats.num_bcn_recvd) == + ar->num_started_vdevs);list_splice_tail_init (&stats->bcn, &ar->fw_stats.bcn);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 234/508 wifi: ath11k: validate ath11k_crypto_mode on top of ath11k_core_qmi_firmware_ready
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rodrigo Gobbi <[email protected]>
[ Upstream commit b0d226a60856a1b765bb9a3848c7b2322fd08c47 ]
if ath11k_crypto_mode is invalid (not ATH11K_CRYPT_MODE_SW/ATH11K_CRYPT_MODE_HW), ath11k_core_qmi_firmware_ready() will not undo some actions that was previously started/configured. Do the validation as soon as possible in order to avoid undoing actions in that case and also to fix the following smatch warning:
drivers/net/wireless/ath/ath11k/core.c:2166 ath11k_core_qmi_firmware_ready()
warn: missing unwind goto?
--- drivers/net/wireless/ath/ath11k/core.c | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/net/wireless/ath/ath11k/core.c +14 -14
@@ -1517,6 +1517,20 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab) {int ret; +switch (ath11k_crypto_mode) { +case ATH11K_CRYPT_MODE_SW : +set_bit (ATH11K_FLAG_HW_CRYPTO_DISABLED , &ab->dev_flags); +set_bit (ATH11K_FLAG_RAW_MODE , &ab->dev_flags); +break ; +case ATH11K_CRYPT_MODE_HW : +clear_bit (ATH11K_FLAG_HW_CRYPTO_DISABLED , &ab->dev_flags); +clear_bit (ATH11K_FLAG_RAW_MODE , &ab->dev_flags); +break ; +default : +ath11k_info (ab,"invalid crypto_mode: %d\n" , ath11k_crypto_mode); +return -EINVAL ; + } + ret =ath11k_core_start_firmware (ab,ATH11K_FIRMWARE_MODE_NORMAL );if (ret) {ath11k_err (ab,"failed to start firmware: %d\n" , ret);
@@ -1535,20 +1549,6 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab) goto err_firmware_stop; } -switch (ath11k_crypto_mode) { -case ATH11K_CRYPT_MODE_SW : -set_bit (ATH11K_FLAG_HW_CRYPTO_DISABLED , &ab->dev_flags); -set_bit (ATH11K_FLAG_RAW_MODE , &ab->dev_flags); -break ; -case ATH11K_CRYPT_MODE_HW : -clear_bit (ATH11K_FLAG_HW_CRYPTO_DISABLED , &ab->dev_flags); -clear_bit (ATH11K_FLAG_RAW_MODE , &ab->dev_flags); -break ; -default : -ath11k_info (ab,"invalid crypto_mode: %d\n" , ath11k_crypto_mode); -return -EINVAL ; - } -if (ath11k_frame_mode ==ATH11K_HW_TXRX_RAW )set_bit (ATH11K_FLAG_RAW_MODE , &ab->dev_flags);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 235/508 regulator: max20086: Fix refcount leak in max20086_parse_regulators_dt()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 06118ae36855b7d3d22688298e74a766ccf0cb7a ]
There is a missing call to of_node_put() if devm_kcalloc() fails. Fix this by changing the code to use cleanup.h magic to drop the refcount.
--- drivers/regulator/max20086-regulator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/max20086-regulator.c +3 -3
@@ -5,6 +5,7 @@// Copyright (C) 2022 Laurent Pinchart <[email protected]> // Copyright (C) 2018 Avnet, Inc. +#include <linux/cleanup.h> #include <linux/err.h> #include <linux/gpio.h> #include <linux/gpio/consumer.h>
@@ -134,11 +135,11 @@ static int max20086_regulators_register(struct max20086 *chip)static int max20086_parse_regulators_dt (struct max20086 *chip,bool *boot_on) {struct of_regulator_match *matches; -struct device_node *node;unsigned int i;int ret; - node =of_get_child_by_name (chip->dev->of_node,"regulators" ); + struct device_node *node __free(device_node) = +of_get_child_by_name (chip->dev->of_node,"regulators" );if (!node) {dev_err (chip->dev,"regulators node not found\n" );return -ENODEV ;
@@ -154,7 +155,6 @@ static int max20086_parse_regulators_dt(struct max20086 *chip, bool *boot_on) ret =of_regulator_match (chip->dev, node, matches, chip->info->num_outputs); -of_node_put (node);if (ret <0 ) {dev_err (chip->dev,"Failed to match regulators\n" );return -EINVAL ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 236/508 pinctrl: qcom: pinctrl-qcm2290: Add missing pins
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wojciech Slenska <[email protected]>
[ Upstream commit 315345610faee8a0568b522dba9e35067d1732ab ]
Added the missing pins to the qcm2290_pins table.
--- drivers/pinctrl/qcom/pinctrl-qcm2290.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/pinctrl/qcom/pinctrl-qcm2290.c +9 -0
@@ -173,6 +173,10 @@ static const struct pinctrl_pin_desc qcm2290_pins[] = {PINCTRL_PIN (62 ,"GPIO_62" ),PINCTRL_PIN (63 ,"GPIO_63" ),PINCTRL_PIN (64 ,"GPIO_64" ), +PINCTRL_PIN (65 ,"GPIO_65" ), +PINCTRL_PIN (66 ,"GPIO_66" ), +PINCTRL_PIN (67 ,"GPIO_67" ), +PINCTRL_PIN (68 ,"GPIO_68" ),PINCTRL_PIN (69 ,"GPIO_69" ),PINCTRL_PIN (70 ,"GPIO_70" ), PINCTRL_PIN(71, "GPIO_71"),
@@ -187,12 +191,17 @@ static const struct pinctrl_pin_desc qcm2290_pins[] = {PINCTRL_PIN (80 ,"GPIO_80" ),PINCTRL_PIN (81 ,"GPIO_81" ),PINCTRL_PIN (82 ,"GPIO_82" ), +PINCTRL_PIN (83 ,"GPIO_83" ), +PINCTRL_PIN (84 ,"GPIO_84" ), +PINCTRL_PIN (85 ,"GPIO_85" ),PINCTRL_PIN (86 ,"GPIO_86" ),PINCTRL_PIN (87 ,"GPIO_87" ),PINCTRL_PIN (88 ,"GPIO_88" ),PINCTRL_PIN (89 ,"GPIO_89" ),PINCTRL_PIN (90 ,"GPIO_90" ),PINCTRL_PIN (91 ,"GPIO_91" ), +PINCTRL_PIN (92 ,"GPIO_92" ), +PINCTRL_PIN (93 ,"GPIO_93" ),PINCTRL_PIN (94 ,"GPIO_94" ),PINCTRL_PIN (95 ,"GPIO_95" ), PINCTRL_PIN(96, "GPIO_96"),
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 237/508 scsi: iscsi: Fix incorrect error path labels for flashnode operations
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit 9b17621366d210ffee83262a8754086ebbde5e55 ]
Correct the error handling goto labels used when host lookup fails in various flashnode-related event handlers:
- iscsi_new_flashnode()
- iscsi_del_flashnode()
- iscsi_login_flashnode()
- iscsi_logout_flashnode()
- iscsi_logout_flashnode_sid()
scsi_host_put() is not required when shost is NULL, so jumping to the correct label avoids unnecessary operations. These functions previously jumped to the wrong goto label (put_host), which did not match the intended cleanup logic.
Use the correct exit labels (exit_new_fnode, exit_del_fnode, etc.) to ensure proper error handling. Also remove the unused put_host label under iscsi_new_flashnode() as it is no longer needed.
No functional changes beyond accurate error path correction.
--- drivers/scsi/scsi_transport_iscsi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +5 -6
@@ -3524,7 +3524,7 @@ static int iscsi_new_flashnode(struct iscsi_transport *transport,pr_err ("%s could not find host no %u\n" , __func__, ev->u.new_flashnode.host_no); err = -ENODEV ; - goto put_host; + goto exit_new_fnode; } index = transport->new_flashnode (shost, data, len);
@@ -3534,7 +3534,6 @@ static int iscsi_new_flashnode(struct iscsi_transport *transport,else err = -EIO ; -put_host:scsi_host_put (shost); exit_new_fnode:
@@ -3559,7 +3558,7 @@ static int iscsi_del_flashnode(struct iscsi_transport *transport,pr_err ("%s could not find host no %u\n" , __func__, ev->u.del_flashnode.host_no); err = -ENODEV ; - goto put_host; + goto exit_del_fnode; } idx = ev->u.del_flashnode.flashnode_idx;
@@ -3601,7 +3600,7 @@ static int iscsi_login_flashnode(struct iscsi_transport *transport,pr_err ("%s could not find host no %u\n" , __func__, ev->u.login_flashnode.host_no); err = -ENODEV ; - goto put_host; + goto exit_login_fnode; } idx = ev->u.login_flashnode.flashnode_idx;
@@ -3653,7 +3652,7 @@ static int iscsi_logout_flashnode(struct iscsi_transport *transport,pr_err ("%s could not find host no %u\n" , __func__, ev->u.logout_flashnode.host_no); err = -ENODEV ; - goto put_host; + goto exit_logout_fnode; } idx = ev->u.logout_flashnode.flashnode_idx;
@@ -3703,7 +3702,7 @@ static int iscsi_logout_flashnode_sid(struct iscsi_transport *transport,pr_err ("%s could not find host no %u\n" , __func__, ev->u.logout_flashnode.host_no); err = -ENODEV ; - goto put_host; + goto exit_logout_sid; } session =iscsi_session_lookup (ev->u.logout_flashnode_sid.sid);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 238/508 net_sched: sch_sfq: fix a potential crash on gso_skb handling
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 82ffbe7776d0ac084031f114167712269bf3d832 ]
SFQ has an assumption of always being able to queue at least one packet.
However, after the blamed commit, sch->q.len can be inflated by packets in sch->gso_skb, and an enqueue() on an empty SFQ qdisc can be followed by an immediate drop.
Fix sfq_drop() to properly clear q->tail in this situation.
Tested:
ip netns add lb
ip link add dev to-lb type veth peer name in-lb netns lb
ethtool -K to-lb tso off # force qdisc to requeue gso_skb
ip netns exec lb ethtool -K in-lb gro on # enable NAPI ip link set dev to-lb up
ip -netns lb link set dev in-lb up
ip addr add dev to-lb 192.168.20.1/24
ip -netns lb addr add dev in-lb 192.168.20.2/24 tc qdisc replace dev to-lb root sfq limit 100
ip netns exec lb netserver
netperf -H 192.168.20.2 -l 100 &
netperf -H 192.168.20.2 -l 100 &
netperf -H 192.168.20.2 -l 100 &
netperf -H 192.168.20.2 -l 100 &
--- net/sched/sch_sfq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/sched/sch_sfq.c +4 -1
@@ -310,7 +310,10 @@ static unsigned int sfq_drop(struct Qdisc *sch, struct sk_buff **to_free)/* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */ x = q->tail->next; slot = &q->slots[x]; - q->tail->next = slot->next; +if (slot->next == x) + q->tail =NULL ;/* no more active slots */ +else + q->tail->next = slot->next; q->ht[slot->hash] =SFQ_EMPTY_SLOT ; goto drop; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 239/508 powerpc/powernv/memtrace: Fix out of bounds issue in memtrace mmap
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ritesh Harjani (IBM) <[email protected]>
[ Upstream commit cd097df4596f3a1e9d75eb8520162de1eb8485b2 ]
memtrace mmap issue has an out of bounds issue. This patch fixes the by checking that the requested mapping region size should stay within the allocated region size.
--- arch/powerpc/platforms/powernv/memtrace.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/powerpc/platforms/powernv/memtrace.c +6 -2
@@ -48,11 +48,15 @@ static ssize_t memtrace_read(struct file *filp, char __user *ubuf,static int memtrace_mmap (struct file *filp,struct vm_area_struct *vma) {struct memtrace_entry *ent = filp->private_data; +unsigned long ent_nrpages = ent->size >>PAGE_SHIFT ; +unsigned long vma_nrpages =vma_pages (vma); -if (ent->size < vma->vm_end - vma->vm_start) +/* The requested page offset should be within object's page count */ +if (vma->vm_pgoff >= ent_nrpages)return -EINVAL ; -if (vma->vm_pgoff <<PAGE_SHIFT >= ent->size) +/* The requested mapping range should remain within the bounds */ +if (vma_nrpages > ent_nrpages - vma->vm_pgoff)return -EINVAL ; vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 240/508 powerpc/vas: Return -EINVAL if the offset is non-zero in mmap()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haren Myneni <[email protected]>
[ Upstream commit 0d67f0dee6c9176bc09a5482dd7346e3a0f14d0b ]
The user space calls mmap() to map VAS window paste address and the kernel returns the complete mapped page for each window. So return -EINVAL if non-zero is passed for offset parameter to mmap().
See Documentation/arch/powerpc/vas-api.rst for mmap() restrictions.
--- arch/powerpc/platforms/book3s/vas-api.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/powerpc/platforms/book3s/vas-api.c +9 -0
@@ -521,6 +521,15 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)return -EINVAL ; } +/* +* Map complete page to the paste address. So the user +* space should pass 0ULL to the offset parameter. +*/ +if (vma->vm_pgoff) { +pr_debug ("Page offset unsupported to map paste address\n" ); +return -EINVAL ; + } +/* Ensure instance has an open send window */ if (!txwin) {pr_err ("No send window open?\n" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 241/508 drm/meson: use unsigned long long / Hz for frequency types
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Blumenstingl <[email protected]>
[ Upstream commit 1017560164b6bbcbc93579266926e6e96675262a ]
Christian reports that 4K output using YUV420 encoding fails with the following error:
Fatal Error, invalid HDMI vclk freq 593406
Modetest shows the following:
3840x2160 59.94 3840 4016 4104 4400 2160 2168 2178 2250 593407 flags: xxxx, xxxx, drm calculated value -------------------------------------^
This indicates that there's a (1kHz) mismatch between the clock calculated by the drm framework and the meson driver.
Relevant function call stack:
(drm framework)
-> meson_encoder_hdmi_atomic_enable()
-> meson_encoder_hdmi_set_vclk()
-> meson_vclk_setup()The video clock requested by the drm framework is 593407kHz. This is passed by meson_encoder_hdmi_atomic_enable() to meson_encoder_hdmi_set_vclk() and the following formula is applied:
- the frequency is halved (which would be 296703.5kHz) and rounded down to the next full integer, which is 296703kHz
- TMDS clock is calculated (296703kHz * 10)
- video encoder clock is calculated - this needs to match a table from meson_vclk.c and so it doubles the previously halved value again (resulting in 593406kHz)
- meson_vclk_setup() can't find (either directly, or by deriving it from 594000kHz * 1000 / 1001 and rounding to the closest integer value - which is 593407kHz as originally requested by the drm framework) a matching clock in it's internal table and errors out with "invalid HDMI vclk freq"
Fix the division precision by switching the whole meson driver to use unsigned long long (64-bit) Hz values for clock frequencies instead of unsigned int (32-bit) kHz to fix the rouding error.
--- drivers/gpu/drm/meson/meson_drv.c | 2 +- drivers/gpu/drm/meson/meson_drv.h | 2 +- drivers/gpu/drm/meson/meson_encoder_hdmi.c | 29 +-- drivers/gpu/drm/meson/meson_vclk.c | 195 +++++++++++---------- drivers/gpu/drm/meson/meson_vclk.h | 13 +- 5 files changed, 126 insertions(+), 115 deletions(-)
drivers/gpu/drm/meson/meson_drv.c +1 -1
@@ -167,7 +167,7 @@ static const struct meson_drm_soc_attr meson_drm_soc_attrs[] = {/* S805X/S805Y HDMI PLL won't lock for HDMI PHY freq > 1,65GHz */ { .limits = { - .max_hdmi_phy_freq = 1650000, + .max_hdmi_phy_freq = 1650000000, }, .attrs = (const struct soc_device_attribute []) { { .soc_id = "GXL (S805*)", },
drivers/gpu/drm/meson/meson_drv.h +1 -1
@@ -37,7 +37,7 @@ struct meson_drm_match_data { };struct meson_drm_soc_limits { -unsigned int max_hdmi_phy_freq; +unsigned long long max_hdmi_phy_freq; };struct meson_drm {
drivers/gpu/drm/meson/meson_encoder_hdmi.c +16 -13
@@ -68,12 +68,12 @@ static void meson_encoder_hdmi_set_vclk(struct meson_encoder_hdmi *encoder_hdmi, {struct meson_drm *priv = encoder_hdmi->priv;int vic =drm_match_cea_mode (mode); -unsigned int phy_freq; -unsigned int vclk_freq; -unsigned int venc_freq; -unsigned int hdmi_freq; +unsigned long long phy_freq; +unsigned long long vclk_freq; +unsigned long long venc_freq; +unsigned long long hdmi_freq; - vclk_freq = mode->clock; + vclk_freq = mode->clock *1000 ;/* For 420, pixel clock is half unlike venc clock */ if (encoder_hdmi->output_bus_fmt ==MEDIA_BUS_FMT_UYYVYY8_0_5X24 )
@@ -105,7 +105,8 @@ static void meson_encoder_hdmi_set_vclk(struct meson_encoder_hdmi *encoder_hdmi,if (mode->flags &DRM_MODE_FLAG_DBLCLK ) venc_freq /=2 ; -dev_dbg (priv->dev,"vclk:%d phy=%d venc=%d hdmi=%d enci=%d\n" , +dev_dbg (priv->dev, +"vclk:%lluHz phy=%lluHz venc=%lluHz hdmi=%lluHz enci=%d\n" , phy_freq, vclk_freq, venc_freq, hdmi_freq, priv->venc.hdmi_use_enci);
@@ -120,10 +121,11 @@ static enum drm_mode_status meson_encoder_hdmi_mode_valid(struct drm_bridge *bristruct meson_encoder_hdmi *encoder_hdmi =bridge_to_meson_encoder_hdmi (bridge);struct meson_drm *priv = encoder_hdmi->priv;bool is_hdmi2_sink = display_info->hdmi.scdc.supported; -unsigned int phy_freq; -unsigned int vclk_freq; -unsigned int venc_freq; -unsigned int hdmi_freq; +unsigned long long clock = mode->clock *1000 ; +unsigned long long phy_freq; +unsigned long long vclk_freq; +unsigned long long venc_freq; +unsigned long long hdmi_freq;int vic =drm_match_cea_mode (mode);enum drm_mode_status status;
@@ -142,12 +144,12 @@ static enum drm_mode_status meson_encoder_hdmi_mode_valid(struct drm_bridge *briif (status !=MODE_OK )return status; -return meson_vclk_dmt_supported_freq (priv, mode->clock); +return meson_vclk_dmt_supported_freq (priv, clock);/* Check against supported VIC modes */ }else if (!meson_venc_hdmi_supported_vic (vic))return MODE_BAD ; - vclk_freq = mode->clock; + vclk_freq = clock;/* For 420, pixel clock is half unlike venc clock */ if (drm_mode_is_420_only(display_info, mode) ||
@@ -177,7 +179,8 @@ static enum drm_mode_status meson_encoder_hdmi_mode_valid(struct drm_bridge *briif (mode->flags &DRM_MODE_FLAG_DBLCLK ) venc_freq /=2 ; -dev_dbg (priv->dev,"%s: vclk:%d phy=%d venc=%d hdmi=%d\n" , +dev_dbg (priv->dev, +"%s: vclk:%lluHz phy=%lluHz venc=%lluHz hdmi=%lluHz\n" , __func__, phy_freq, vclk_freq, venc_freq, hdmi_freq);return meson_vclk_vic_supported_freq (priv, phy_freq, vclk_freq);
drivers/gpu/drm/meson/meson_vclk.c +101 -94
425 lines not on this page · raw message
drivers/gpu/drm/meson/meson_vclk.h +7 -6
@@ -20,17 +20,18 @@ enum { };/* 27MHz is the CVBS Pixel Clock */ -#define MESON_VCLK_CVBS 27000 +#define MESON_VCLK_CVBS (27 * 1000 * 1000)enum drm_mode_status -meson_vclk_dmt_supported_freq (struct meson_drm *priv,unsigned int freq); +meson_vclk_dmt_supported_freq (struct meson_drm *priv,unsigned long long freq);enum drm_mode_status -meson_vclk_vic_supported_freq (struct meson_drm *priv,unsigned int phy_freq, -unsigned int vclk_freq); +meson_vclk_vic_supported_freq (struct meson_drm *priv, +unsigned long long phy_freq, +unsigned long long vclk_freq);void meson_vclk_setup (struct meson_drm *priv,unsigned int target, -unsigned int phy_freq,unsigned int vclk_freq, -unsigned int venc_freq,unsigned int dac_freq, +unsigned long long phy_freq,unsigned long long vclk_freq, +unsigned long long venc_freq,unsigned long long dac_freq,bool hdmi_use_enci);#endif /* __MESON_VCLK_H */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 242/508 drm/meson: fix debug log statement when setting the HDMI clocks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Blumenstingl <[email protected]>
[ Upstream commit d17e61ab63fb7747b340d6a66bf1408cd5c6562b ]
The "phy" and "vclk" frequency labels were swapped, making it more difficult to debug driver errors. Swap the label order to make them match with the actual frequencies printed to correct this.
--- drivers/gpu/drm/meson/meson_encoder_hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/meson/meson_encoder_hdmi.c +1 -1
@@ -106,7 +106,7 @@ static void meson_encoder_hdmi_set_vclk(struct meson_encoder_hdmi *encoder_hdmi, venc_freq /=2 ;dev_dbg (priv->dev, -"vclk:%lluHz phy=%lluHz venc=%lluHz hdmi=%lluHz enci=%d\n" , +"phy:%lluHz vclk=%lluHz venc=%lluHz hdmi=%lluHz enci=%d\n" , phy_freq, vclk_freq, venc_freq, hdmi_freq, priv->venc.hdmi_use_enci);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 243/508 drm/meson: use vclk_freq instead of pixel_freq in debug print
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Blumenstingl <[email protected]>
[ Upstream commit faf2f8382088e8c74bd6eeb236c8c9190e61615e ]
meson_vclk_vic_supported_freq() has a debug print which includes the pixel freq. However, within the whole function the pixel freq is irrelevant, other than checking the end of the params array. Switch to printing the vclk_freq which is being compared / matched against the inputs to the function to avoid confusion when analyzing error reports from users.
--- drivers/gpu/drm/meson/meson_vclk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/meson/meson_vclk.c +3 -3
@@ -790,9 +790,9 @@ meson_vclk_vic_supported_freq(struct meson_drm *priv, }for (i =0 ; params[i].pixel_freq ; ++i) { -DRM_DEBUG_DRIVER ("i = %d pixel_freq = %lluHz alt = %lluHz\n" , - i, params[i].pixel_freq, -PIXEL_FREQ_1000_1001 (params[i].pixel_freq)); +DRM_DEBUG_DRIVER ("i = %d vclk_freq = %lluHz alt = %lluHz\n" , + i, params[i].vclk_freq, +PIXEL_FREQ_1000_1001 (params[i].vclk_freq));DRM_DEBUG_DRIVER ("i = %d phy_freq = %lluHz alt = %lluHz\n" , i, params[i].phy_freq,PHY_FREQ_1000_1001 (params[i].phy_freq));
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 244/508 drm/meson: fix more rounding issues with 59.94Hz modes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Blumenstingl <[email protected]>
[ Upstream commit 0cee6c4d3518b2e757aedae78771f17149f57653 ]
Commit 1017560164b6 ("drm/meson: use unsigned long long / Hz for frequency types") attempts to resolve video playback using 59.94Hz.
using YUV420 by changing the clock calculation to use
Hz instead of kHz (thus yielding more precision).
The basic calculation itself is correct, however the comparisions in meson_vclk_vic_supported_freq() and meson_vclk_setup() don't work anymore for 59.94Hz modes (using the freq * 1000 / 1001 logic). For example, drm/edid specifies a 593407kHz clock for [email protected]. With the mentioend commit we convert this to Hz. Then meson_vclk tries to find a matchig "params" entry (as the clock setup code currently only supports specific frequencies) by taking the venc_freq from the params and calculating the "alt frequency" (used for the 59.94Hz modes) from it, which is:
(594000000Hz * 1000) / 1001 = 593406593Hz
Similar calculation is applied to the phy_freq (TMDS clock), which is 10 times the pixel clock.
Implement a new meson_vclk_freqs_are_matching_param() function whose purpose is to compare if the requested and calculated frequencies. They may not match exactly (for the reasons mentioned above). Allow the clocks to deviate slightly to make the 59.94Hz modes again.
--- drivers/gpu/drm/meson/meson_vclk.c | 55 ++++++++++++++++++------------ 1 file changed, 34 insertions(+), 21 deletions(-)
drivers/gpu/drm/meson/meson_vclk.c +34 -21
@@ -110,10 +110,7 @@#define HDMI_PLL_LOCK BIT(31)#define HDMI_PLL_LOCK_G12A (3 << 30) -#define PIXEL_FREQ_1000_1001 (_freq) \ - DIV_ROUND_CLOSEST_ULL((_freq) * 1000ULL, 1001ULL) -#define PHY_FREQ_1000_1001 (_freq) \ - (PIXEL_FREQ_1000_1001(DIV_ROUND_DOWN_ULL(_freq, 10ULL)) * 10) +#define FREQ_1000_1001 (_freq) DIV_ROUND_CLOSEST_ULL((_freq) * 1000ULL, 1001ULL)/* VID PLL Dividers */ enum {
@@ -772,6 +769,36 @@ static void meson_hdmi_pll_generic_set(struct meson_drm *priv, pll_freq); } +static bool meson_vclk_freqs_are_matching_param (unsigned int idx, +unsigned long long phy_freq, +unsigned long long vclk_freq) +{ +DRM_DEBUG_DRIVER ("i = %d vclk_freq = %lluHz alt = %lluHz\n" , + idx, params[idx].vclk_freq, +FREQ_1000_1001 (params[idx].vclk_freq)); +DRM_DEBUG_DRIVER ("i = %d phy_freq = %lluHz alt = %lluHz\n" , + idx, params[idx].phy_freq, +FREQ_1000_1001 (params[idx].phy_freq)); + +/* Match strict frequency */ +if (phy_freq == params[idx].phy_freq && + vclk_freq == params[idx].vclk_freq) +return true; + +/* Match 1000/1001 variant: vclk deviation has to be less than 1kHz +* (drm EDID is defined in 1kHz steps, so everything smaller must be +* rounding error) and the PHY freq deviation has to be less than +* 10kHz (as the TMDS clock is 10 times the pixel clock, so anything +* smaller must be rounding error as well). +*/ +if (abs (vclk_freq -FREQ_1000_1001 (params[idx].vclk_freq)) <1000 && +abs (phy_freq -FREQ_1000_1001 (params[idx].phy_freq)) <10000 ) +return true; + +/* no match */ +return false; +} + enum drm_mode_status meson_vclk_vic_supported_freq(struct meson_drm *priv, unsigned long long phy_freq,
@@ -790,19 +817,7 @@ meson_vclk_vic_supported_freq(struct meson_drm *priv, }for (i =0 ; params[i].pixel_freq ; ++i) { -DRM_DEBUG_DRIVER ("i = %d vclk_freq = %lluHz alt = %lluHz\n" , - i, params[i].vclk_freq, -PIXEL_FREQ_1000_1001 (params[i].vclk_freq)); -DRM_DEBUG_DRIVER ("i = %d phy_freq = %lluHz alt = %lluHz\n" , - i, params[i].phy_freq, -PHY_FREQ_1000_1001 (params[i].phy_freq)); -/* Match strict frequency */ -if (phy_freq == params[i].phy_freq && - vclk_freq == params[i].vclk_freq) -return MODE_OK ; -/* Match 1000/1001 variant */ -if (phy_freq ==PHY_FREQ_1000_1001 (params[i].phy_freq) && - vclk_freq ==PIXEL_FREQ_1000_1001 (params[i].vclk_freq)) +if (meson_vclk_freqs_are_matching_param (i, phy_freq, vclk_freq))return MODE_OK ; }
@@ -1075,10 +1090,8 @@ void meson_vclk_setup(struct meson_drm *priv, unsigned int target, }for (freq =0 ; params[freq].pixel_freq ; ++freq) { -if ((phy_freq == params[freq].phy_freq || - phy_freq ==PHY_FREQ_1000_1001 (params[freq].phy_freq)) && - (vclk_freq == params[freq].vclk_freq || - vclk_freq ==PIXEL_FREQ_1000_1001 (params[freq].vclk_freq))) { +if (meson_vclk_freqs_are_matching_param (freq, phy_freq, + vclk_freq)) {if (vclk_freq != params[freq].vclk_freq) vic_alternate_clock = true;else
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 245/508 i40e: return false from i40e_reset_vf if reset is in progress
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Malz <[email protected]>
[ Upstream commit a2c90d63b71223d69a813333c1abf4fdacddbbe5 ]
The function i40e_vc_reset_vf attempts, up to 20 times, to handle a VF reset request, using the return value of i40e_reset_vf as an indicator of whether the reset was successfully triggered. Currently, i40e_reset_vf always returns true, which causes new reset requests to be ignored if a different VF reset is already in progress.
This patch updates the return value of i40e_reset_vf to reflect when another VF reset is in progress, allowing the caller to properly use the retry mechanism.
--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +3 -3
@@ -1548,8 +1548,8 @@ static void i40e_cleanup_reset_vf(struct i40e_vf *vf)* @vf: pointer to the VF structure * @flr: VFLR was issued or not * -* Returns true if the VF is in reset, resets successfully, or resets -* are disabled and false otherwise. +* Return: True if reset was performed successfully or if resets are disabled. +* False if reset is already in progress. **/ bool i40e_reset_vf (struct i40e_vf *vf,bool flr) {
@@ -1568,7 +1568,7 @@ bool i40e_reset_vf(struct i40e_vf *vf, bool flr)/* If VF is being reset already we don't need to continue. */ if (test_and_set_bit (I40E_VF_STATE_RESETTING , &vf->vf_states)) -return true; +return false;i40e_trigger_vf_reset (vf, flr);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 246/508 i40e: retry VFLR handling if there is ongoing VF reset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Malz <[email protected]>
[ Upstream commit fb4e9239e029954a37a00818b21e837cebf2aa10 ]
When a VFLR interrupt is received during a VF reset initiated from a different source, the VFLR may be not fully handled. This can leave the VF in an undefined state.
To address this, set the I40E_VFLR_EVENT_PENDING bit again during VFLR handling if the reset is not yet complete. This ensures the driver will properly complete the VF reset in such scenarios.
--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +4 -1
@@ -4267,7 +4267,10 @@ int i40e_vc_process_vflr_event(struct i40e_pf *pf) reg =rd32 (hw,I40E_GLGEN_VFLRSTAT (reg_idx));if (reg &BIT (bit_idx))/* i40e_reset_vf will clear the bit in GLGEN_VFLRSTAT */ -i40e_reset_vf (vf, true); +if (!i40e_reset_vf (vf, true)) { +/* At least one VF did not finish resetting, retry next time */ +set_bit (__I40E_VFLR_EVENT_PENDING, pf->state); + } }return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 247/508 ACPI: CPPC: Fix NULL pointer dereference when nosmp is used
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yunhui Cui <[email protected]>
[ Upstream commit 15eece6c5b05e5f9db0711978c3e3b7f1a2cfe12 ]
With nosmp in cmdline, other CPUs are not brought up, leaving their cpc_desc_ptr NULL. CPU0's iteration via for_each_possible_cpu() dereferences these NULL pointers, causing panic.
Panic backtrace:
[ 0.401123] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000b8 ... [ 0.403255] [<ffffffff809a5818>] cppc_allow_fast_switch+0x6a/0xd4 ... Kernel panic - not syncing: Attempted to kill init!
--- drivers/acpi/cppc_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/cppc_acpi.c +1 -1
@@ -456,7 +456,7 @@ bool cppc_allow_fast_switch(void)struct cpc_desc *cpc_ptr;int cpu; -for_each_possible_cpu (cpu) { +for_each_present_cpu (cpu) { cpc_ptr =per_cpu (cpc_desc_ptr, cpu); desired_reg = &cpc_ptr->cpc_regs[DESIRED_PERF ]; if (!CPC_IN_SYSTEM_MEMORY(desired_reg) &&
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 248/508 net: Fix TOCTOU issue in sk_is_readable()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit 2660a544fdc0940bba15f70508a46cf9a6491230 ]
sk->sk_prot->sock_is_readable is a valid function pointer when sk resides in a sockmap. After the last sk_psock_put() (which usually happens when socket is removed from sockmap), sk->sk_prot gets restored and sk->sk_prot->sock_is_readable becomes NULL.
This makes sk_is_readable() racy, if the value of sk->sk_prot is reloaded after the initial check. Which in turn may lead to a null pointer dereference.
Ensure the function pointer does not turn NULL after the check.
--- include/net/sock.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
include/net/sock.h +5 -2
@@ -3061,8 +3061,11 @@ int sock_copy_user_timeval(struct __kernel_sock_timeval *tv,static inline bool sk_is_readable (struct sock *sk) { -if (sk->sk_prot->sock_is_readable) -return sk->sk_prot->sock_is_readable (sk); +const struct proto *prot =READ_ONCE (sk->sk_prot); + +if (prot->sock_is_readable) +return prot->sock_is_readable (sk); +return false; }#endif /* _SOCK_H */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 249/508 macsec: MACsec SCI assignment for ES = 0
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Fernandez <[email protected]>
[ Upstream commit d9816ec74e6d6aa29219d010bba3f780ba1d9d75 ]
According to 802.1AE standard, when ES and SC flags in TCI are zero, used SCI should be the current active SC_RX. Current code uses the header MAC address. Without this patch, when ES flag is 0 (using a bridge or switch), header MAC will not fit the SCI and MACSec frames will be discarted.
In order to test this issue, MACsec link should be stablished between two interfaces, setting SC and ES flags to zero and a port identifier different than one. For example, using ip macsec tools:
ip link add link $ETH0 macsec0 type macsec port 11 send_sci off end_station off
ip macsec add macsec0 tx sa 0 pn 2 on key 01 $ETH1_KEY
ip macsec add macsec0 rx port 11 address $ETH1_MAC
ip macsec add macsec0 rx port 11 address $ETH1_MAC sa 0 pn 2 on key 02 ip link set dev macsec0 up
ip link add link $ETH1 macsec1 type macsec port 11 send_sci off end_station off
ip macsec add macsec1 tx sa 0 pn 2 on key 01 $ETH0_KEY
ip macsec add macsec1 rx port 11 address $ETH0_MAC
ip macsec add macsec1 rx port 11 address $ETH0_MAC sa 0 pn 2 on key 02 ip link set dev macsec1 up
--- drivers/net/macsec.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-)
drivers/net/macsec.c +34 -6
@@ -243,15 +243,39 @@ static sci_t make_sci(const u8 *addr, __be16 port)return sci; } -static sci_t macsec_frame_sci (struct macsec_eth_header *hdr,bool sci_present) +static sci_t macsec_active_sci (struct macsec_secy *secy) { -sci_t sci; +struct macsec_rx_sc *rx_sc =rcu_dereference_bh (secy->rx_sc); + +/* Case single RX SC */ +if (rx_sc && !rcu_dereference_bh (rx_sc->next)) +return (rx_sc->active) ? rx_sc->sci :0 ; +/* Case no RX SC or multiple */ +else +return 0 ; +} + +static sci_t macsec_frame_sci (struct macsec_eth_header *hdr,bool sci_present, +struct macsec_rxh_data *rxd) +{ +struct macsec_dev *macsec; +sci_t sci =0 ; -if (sci_present) +/* SC = 1 */ +if (sci_present) {memcpy (&sci, hdr->secure_channel_id,sizeof (hdr->secure_channel_id)); -else +/* SC = 0; ES = 0 */ + }else if ((!(hdr->tci_an & (MACSEC_TCI_ES |MACSEC_TCI_SC ))) && + (list_is_singular (&rxd->secys))) { +/* Only one SECY should exist on this scenario */ + macsec = list_first_or_null_rcu(&rxd->secys, struct macsec_dev, + secys); +if (macsec) +return macsec_active_sci (&macsec->secy); + }else { sci =make_sci (hdr->eth.h_source,MACSEC_PORT_ES ); + }return sci; }
@@ -1110,7 +1134,7 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)struct macsec_rxh_data *rxd;struct macsec_dev *macsec;unsigned int len; -sci_t sci; +sci_t sci =0 ;u32 hdr_pn;bool cbit;struct pcpu_rx_sc_stats *rxsc_stats;
@@ -1157,11 +1181,14 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)macsec_skb_cb (skb)->has_sci = !!(hdr->tci_an &MACSEC_TCI_SC );macsec_skb_cb (skb)->assoc_num = hdr->tci_an &MACSEC_AN_MASK ; - sci =macsec_frame_sci (hdr,macsec_skb_cb (skb)->has_sci);rcu_read_lock (); rxd =macsec_data_rcu (skb->dev); + sci =macsec_frame_sci (hdr,macsec_skb_cb (skb)->has_sci, rxd); +if (!sci) + goto drop_nosc; +list_for_each_entry_rcu (macsec, &rxd->secys, secys) {struct macsec_rx_sc *sc =find_rx_sc (&macsec->secy, sci);
@@ -1284,6 +1311,7 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)macsec_rxsa_put (rx_sa); drop_nosa:macsec_rxsc_put (rx_sc); +drop_nosc:rcu_read_unlock (); drop_direct:kfree_skb (skb);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 250/508 net: mdio: C22 is now optional, EOPNOTSUPP if not provided
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Lunn <[email protected]>
[ Upstream commit b063b1924fd9bf0bc157cf644764dc2151d04ccc ]
When performing a C22 operation, check that the bus driver actually provides the methods, and return -EOPNOTSUPP if not. C45 only busses do exist, and in future their C22 methods will be NULL.
Stable-dep-of: 0e629694126c ("net/mdiobus: Fix potential out-of-bounds read/write access")
--- drivers/net/phy/mdio_bus.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/phy/mdio_bus.c +8 -2
@@ -764,7 +764,10 @@ int __mdiobus_read(struct mii_bus *bus, int addr, u32 regnum)lockdep_assert_held_once (&bus->mdio_lock); - retval = bus->read (bus, addr, regnum); +if (bus->read) + retval = bus->read (bus, addr, regnum); +else + retval = -EOPNOTSUPP ;trace_mdio_access (bus,1 , addr, regnum, retval, retval);mdiobus_stats_acct (&bus->stats[addr], true, retval);
@@ -790,7 +793,10 @@ int __mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val)lockdep_assert_held_once (&bus->mdio_lock); - err = bus->write (bus, addr, regnum, val); +if (bus->write) + err = bus->write (bus, addr, regnum, val); +else + err = -EOPNOTSUPP ;trace_mdio_access (bus,0 , addr, regnum, val, err);mdiobus_stats_acct (&bus->stats[addr], false, err);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 251/508 net/mdiobus: Fix potential out-of-bounds read/write access
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Raczynski <[email protected]>
[ Upstream commit 0e629694126ca388916f059453a1c36adde219c4 ]
When using publicly available tools like 'mdio-tools' to read/write data from/to network interface and its PHY via mdiobus, there is no verification of parameters passed to the ioctl and it accepts any mdio address. Currently there is support for 32 addresses in kernel via PHY_MAX_ADDR define, but it is possible to pass higher value than that via ioctl. While read/write operation should generally fail in this case, mdiobus provides stats array, where wrong address may allow out-of-bounds read/write.
Fix that by adding address verification before read/write operation. While this excludes this access from any statistics, it improves security of read/write operation.
--- drivers/net/phy/mdio_bus.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/phy/mdio_bus.c +6 -0
@@ -764,6 +764,9 @@ int __mdiobus_read(struct mii_bus *bus, int addr, u32 regnum)lockdep_assert_held_once (&bus->mdio_lock); +if (addr >=PHY_MAX_ADDR ) +return -ENXIO ; +if (bus->read) retval = bus->read (bus, addr, regnum);else
@@ -793,6 +796,9 @@ int __mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val)lockdep_assert_held_once (&bus->mdio_lock); +if (addr >=PHY_MAX_ADDR ) +return -ENXIO ; +if (bus->write) err = bus->write (bus, addr, regnum, val);else
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 252/508 Bluetooth: Fix NULL pointer deference on eir_get_service_data
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 20a2aa01f5aeb6daad9aeaa7c33dd512c58d81eb ]
The len parameter is considered optional so it can be NULL so it cannot be used for skipping to next entry of EIR_SERVICE_DATA.
--- net/bluetooth/eir.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/bluetooth/eir.c +6 -4
@@ -366,17 +366,19 @@ u8 eir_create_scan_rsp(struct hci_dev *hdev, u8 instance, u8 *ptr)void *eir_get_service_data (u8 *eir,size_t eir_len,u16 uuid,size_t *len) { -while ((eir =eir_get_data (eir, eir_len,EIR_SERVICE_DATA , len))) { +size_t dlen; + +while ((eir =eir_get_data (eir, eir_len,EIR_SERVICE_DATA , &dlen))) {u16 value =get_unaligned_le16 (eir);if (uuid == value) {if (len) - *len -=2 ; + *len = dlen -2 ;return &eir[2 ]; } - eir += *len; - eir_len -= *len; + eir += dlen; + eir_len -= dlen; }return NULL ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 253/508 Bluetooth: hci_sync: Fix broadcast/PA when using an existing instance
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 5725bc608252050ed8a4d47d59225b7dd73474c8 ]
When using and existing adv_info instance for broadcast source it needs to be updated to periodic first before it can be reused, also in case the existing instance already have data hci_set_adv_instance_data cannot be used directly since it would overwrite the existing data so this reappend the original data after the Broadcast ID, if one was generated.
Example:
bluetoothctl># Add PBP to EA so it can be later referenced as the BIS ID bluetoothctl> advertise.service 0x1856 0x00 0x00 bluetoothctl> advertise on
...
< HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 13
Handle: 0x01
Operation: Complete extended advertising data (0x03)
Fragment preference: Minimize fragmentation (0x01)
Data length: 0x09
Service Data: Public Broadcast Announcement (0x1856)
Data[2]: 0000
Flags: 0x06
LE General Discoverable Mode
BR/EDR Not Supported...
bluetoothctl># Attempt to acquire Broadcast Source transport bluetoothctl>transport.acquire /org/bluez/hci0/pac_bcast0/fd0
...
< HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 255
Handle: 0x01
Operation: Complete extended advertising data (0x03)
Fragment preference: Minimize fragmentation (0x01)
Data length: 0x0e
Service Data: Broadcast Audio Announcement (0x1852)
Broadcast ID: 11371620 (0xad8464)
Service Data: Public Broadcast Announcement (0x1856)
Data[2]: 0000
Flags: 0x06
LE General Discoverable Mode
BR/EDR Not Supported--- net/bluetooth/hci_sync.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
net/bluetooth/hci_sync.c +15 -5
@@ -1539,7 +1539,8 @@ static int hci_enable_per_advertising_sync(struct hci_dev *hdev, u8 instance)static int hci_adv_bcast_annoucement (struct hci_dev *hdev,struct adv_info *adv) {u8 bid[3 ]; -u8 ad[4 +3 ]; +u8 ad[HCI_MAX_EXT_AD_LENGTH ]; +u8 len;/* Skip if NULL adv as instance 0x00 is used for general purpose * advertising so it cannot used for the likes of Broadcast Announcement
@@ -1565,8 +1566,10 @@ static int hci_adv_bcast_annoucement(struct hci_dev *hdev, struct adv_info *adv)/* Generate Broadcast ID */ get_random_bytes (bid,sizeof (bid)); -eir_append_service_data (ad,0 ,0x1852 , bid,sizeof (bid)); -hci_set_adv_instance_data (hdev, adv->instance,sizeof (ad), ad,0 ,NULL ); + len =eir_append_service_data (ad,0 ,0x1852 , bid,sizeof (bid)); +memcpy (ad + len, adv->adv_data, adv->adv_data_len); +hci_set_adv_instance_data (hdev, adv->instance, len + adv->adv_data_len, + ad,0 ,NULL );return hci_update_adv_data_sync (hdev, adv->instance); }
@@ -1583,8 +1586,15 @@ int hci_start_per_adv_sync(struct hci_dev *hdev, u8 instance, u8 data_len,if (instance) { adv =hci_find_adv_instance (hdev, instance); -/* Create an instance if that could not be found */ -if (!adv) { +if (adv) { +/* Turn it into periodic advertising */ + adv->periodic = true; + adv->per_adv_data_len = data_len; +if (data) +memcpy (adv->per_adv_data, data, data_len); + adv->flags = flags; + }else if (!adv) { +/* Create an instance if that could not be found */ adv = hci_add_per_instance(hdev, instance, flags, data_len, data, sync_interval,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 254/508 Bluetooth: MGMT: Fix sparse errors
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 7dd38ba4acbea9875b4ee061e20a26413e39d9f4 ]
This fixes the following errors:
net/bluetooth/mgmt.c:5400:59: sparse: sparse: incorrect type in argument 3
(different base types) @@ expected unsigned short [usertype] handle @@
got restricted __le16 [usertype] monitor_handle @@net/bluetooth/mgmt.c:5400:59: sparse: expected unsigned short [usertype] handlenet/bluetooth/mgmt.c:5400:59: sparse: got restricted __le16 [usertype] monitor_handle
--- net/bluetooth/mgmt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/mgmt.c +2 -2
@@ -5237,11 +5237,11 @@ static void mgmt_adv_monitor_added(struct sock *sk, struct hci_dev *hdev, }static void mgmt_adv_monitor_removed (struct sock *sk,struct hci_dev *hdev, -u16 handle) +__le16 handle) {struct mgmt_ev_adv_monitor_removed ev; - ev.monitor_handle =cpu_to_le16 (handle); + ev.monitor_handle = handle;mgmt_event (MGMT_EV_ADV_MONITOR_REMOVED , hdev, &ev,sizeof (ev), sk); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 255/508 net/mlx5: Ensure fw pages are always allocated on same NUMA
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Moshe Shemesh <[email protected]>
[ Upstream commit f37258133c1e95e61db532e14067e28b4881bf24 ]
When firmware asks the driver to allocate more pages, using event of give_pages, the driver should always allocate it from same NUMA, the original device NUMA. Current code uses dev_to_node() which can result in different NUMA as it is changed by other driver flows, such as mlx5_dma_zalloc_coherent_node(). Instead, use saved numa node for allocating firmware pages.
--- drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +1 -1
@@ -285,7 +285,7 @@ static void free_4k(struct mlx5_core_dev *dev, u64 addr, u32 function)static int alloc_system_page (struct mlx5_core_dev *dev,u32 function) {struct device *device =mlx5_core_dma_dev (dev); -int nid =dev_to_node (device); +int nid = dev->priv.numa_node;struct page *page;u64 zero_addr =1 ;u64 addr;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 256/508 net/mlx5: Fix return value when searching for existing flow group
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 8ec40e3f1f72bf8f8accf18020d487caa99f46a4 ]
When attempting to add a rule to an existing flow group, if a matching flow group exists but is not active, the error code returned should be EAGAIN, so that the rule can be added to the matching flow group once it is active, rather than ENOENT, which indicates that no matching flow group was found.
--- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +4 -1
@@ -1918,6 +1918,7 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft,struct mlx5_flow_handle *rule;struct match_list *iter;bool take_write = false; +bool try_again = false;struct fs_fte *fte;u64 version =0 ;int err;
@@ -1977,6 +1978,7 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft,nested_down_write_ref_node (&g->node,FS_LOCK_PARENT );if (!g->node.active) { + try_again = true;up_write_ref_node (&g->node, false);continue ; }
@@ -1998,7 +2000,8 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft,tree_put_node (&fte->node, false);return rule; } - rule =ERR_PTR (-ENOENT ); + err = try_again ? -EAGAIN : -ENOENT ; + rule =ERR_PTR (err); out:kmem_cache_free (steering->ftes_cache, fte);return rule;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 257/508 net/mlx5e: Fix leak of Geneve TLV option object
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jianbo Liu <[email protected]>
[ Upstream commit aa9c44b842096c553871bc68a8cebc7861fa192b ]
Previously, a unique tunnel id was added for the matching on TC non-zero chains, to support inner header rewrite with goto action. Later, it was used to support VF tunnel offload for vxlan, then for Geneve and GRE. To support VF tunnel, a temporary mlx5_flow_spec is used to parse tunnel options. For Geneve, if there is TLV option, a object is created, or refcnt is added if already exists. But the temporary mlx5_flow_spec is directly freed after parsing, which causes the leak because no information regarding the object is saved in flow's mlx5_flow_spec, which is used to free the object when deleting the flow.
To fix the leak, call mlx5_geneve_tlv_option_del() before free the temporary spec if it has TLV object.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +6 -6
@@ -1873,9 +1873,8 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,return err; } -static bool mlx5_flow_has_geneve_opt (struct mlx5e_tc_flow *flow) +static bool mlx5_flow_has_geneve_opt (struct mlx5_flow_spec *spec) { -struct mlx5_flow_spec *spec = &flow->attr->parse_attr->spec;void *headers_v =MLX5_ADDR_OF (fte_match_param, spec->match_value, misc_parameters_3);
@@ -1907,7 +1906,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, }complete_all (&flow->del_hw_done); -if (mlx5_flow_has_geneve_opt (flow)) +if (mlx5_flow_has_geneve_opt (&attr->parse_attr->spec))mlx5_geneve_tlv_option_del (priv->mdev->geneve);mlx5_eswitch_del_vlan_action (esw, attr);
@@ -2415,12 +2414,13 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv, err =mlx5e_tc_tun_parse (filter_dev, priv, tmp_spec, f, match_level);if (err) { -kvfree (tmp_spec);NL_SET_ERR_MSG_MOD (extack,"Failed to parse tunnel attributes" );netdev_warn (priv->netdev,"Failed to parse tunnel attributes" ); -return err; + }else { + err =mlx5e_tc_set_attr_rx_tun (flow, tmp_spec); } - err =mlx5e_tc_set_attr_rx_tun (flow, tmp_spec); +if (mlx5_flow_has_geneve_opt (tmp_spec)) +mlx5_geneve_tlv_option_del (priv->mdev->geneve);kvfree (tmp_spec);if (err)return err;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 258/508 net_sched: prio: fix a race in prio_tune()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit d35acc1be3480505b5931f17e4ea9b7617fea4d3 ]
Gerrard Tai reported a race condition in PRIO, whenever SFQ perturb timer fires at the wrong time.
The race is as follows:
CPU 0 CPU 1
[1]: lock root
[2]: qdisc_tree_flush_backlog()
[3]: unlock root
| | [5]: lock root | [6]: rehash | [7]: qdisc_tree_reduce_backlog() |
[4]: qdisc_put()
This can be abused to underflow a parent's qlen.
Calling qdisc_purge_queue() instead of qdisc_tree_flush_backlog() should fix the race, because all packets will be purged from the qdisc before releasing the lock.
--- net/sched/sch_prio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_prio.c +1 -1
@@ -211,7 +211,7 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt,memcpy (q->prio2band, qopt->priomap,TC_PRIO_MAX +1 );for (i = q->bands; i < oldbands; i++) -qdisc_tree_flush_backlog (q->queues[i]); +qdisc_purge_queue (q->queues[i]);for (i = oldbands; i < q->bands; i++) { q->queues[i] = queues[i];
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 259/508 net_sched: red: fix a race in __red_change()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 85a3e0ede38450ea3053b8c45d28cf55208409b8 ]
Gerrard Tai reported a race condition in RED, whenever SFQ perturb timer fires at the wrong time.
The race is as follows:
CPU 0 CPU 1
[1]: lock root
[2]: qdisc_tree_flush_backlog()
[3]: unlock root
| | [5]: lock root | [6]: rehash | [7]: qdisc_tree_reduce_backlog() |
[4]: qdisc_put()
This can be abused to underflow a parent's qlen.
Calling qdisc_purge_queue() instead of qdisc_tree_flush_backlog() should fix the race, because all packets will be purged from the qdisc before releasing the lock.
--- net/sched/sch_red.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_red.c +1 -1
@@ -283,7 +283,7 @@ static int __red_change(struct Qdisc *sch, struct nlattr **tb, q->userbits = userbits; q->limit = ctl->limit;if (child) { -qdisc_tree_flush_backlog (q->qdisc); +qdisc_purge_queue (q->qdisc); old_child = q->qdisc; q->qdisc = child; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 260/508 net_sched: tbf: fix a race in tbf_change()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 43eb466041216d25dedaef1c383ad7bd89929cbc ]
Gerrard Tai reported a race condition in TBF, whenever SFQ perturb timer fires at the wrong time.
The race is as follows:
CPU 0 CPU 1
[1]: lock root
[2]: qdisc_tree_flush_backlog()
[3]: unlock root
| | [5]: lock root | [6]: rehash | [7]: qdisc_tree_reduce_backlog() |
[4]: qdisc_put()
This can be abused to underflow a parent's qlen.
Calling qdisc_purge_queue() instead of qdisc_tree_flush_backlog() should fix the race, because all packets will be purged from the qdisc before releasing the lock.
--- net/sched/sch_tbf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_tbf.c +1 -1
@@ -451,7 +451,7 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt,sch_tree_lock (sch);if (child) { -qdisc_tree_flush_backlog (q->qdisc); +qdisc_purge_queue (q->qdisc); old = q->qdisc; q->qdisc = child; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 261/508 net_sched: ets: fix a race in ets_qdisc_change()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit d92adacdd8c2960be856e0b82acc5b7c5395fddb ]
Gerrard Tai reported a race condition in ETS, whenever SFQ perturb timer fires at the wrong time.
The race is as follows:
CPU 0 CPU 1
[1]: lock root
[2]: qdisc_tree_flush_backlog()
[3]: unlock root
| | [5]: lock root | [6]: rehash | [7]: qdisc_tree_reduce_backlog() |
[4]: qdisc_put()
This can be abused to underflow a parent's qlen.
Calling qdisc_purge_queue() instead of qdisc_tree_flush_backlog() should fix the race, because all packets will be purged from the qdisc before releasing the lock.
--- net/sched/sch_ets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_ets.c +1 -1
@@ -661,7 +661,7 @@ static int ets_qdisc_change(struct Qdisc *sch, struct nlattr *opt,for (i = q->nbands; i < oldbands; i++) {if (i >= q->nstrict && q->classes[i].qdisc->q.qlen)list_del_init (&q->classes[i].alist); -qdisc_tree_flush_backlog (q->classes[i].qdisc); +qdisc_purge_queue (q->classes[i].qdisc); } q->nstrict = nstrict;memcpy (q->prio2band, priomap,sizeof (priomap));
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 262/508 fs/filesystems: Fix potential unsigned integer underflow in fs_name()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit 1363c134ade81e425873b410566e957fecebb261 ]
fs_name() has @index as unsigned int, so there is underflow risk for operation '@index--'.
Fix by breaking the for loop when '@index == 0' which is also more proper than '@index <= 0' for unsigned integer comparison.
--- fs/filesystems.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
fs/filesystems.c +9 -5
@@ -156,15 +156,19 @@ static int fs_index(const char __user * __name)static int fs_name (unsigned int index,char __user * buf) {struct file_system_type * tmp; -int len, res; +int len, res = -EINVAL ;read_lock (&file_systems_lock); -for (tmp = file_systems; tmp; tmp = tmp->next, index--) -if (index <=0 &&try_module_get (tmp->owner)) +for (tmp = file_systems; tmp; tmp = tmp->next, index--) { +if (index ==0 ) { +if (try_module_get (tmp->owner)) + res =0 ;break ; + } + }read_unlock (&file_systems_lock); -if (!tmp) -return -EINVAL ; +if (res) +return res;/* OK, we got the reference, so we can safely block */ len =strlen (tmp->name) +1 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 263/508 nvmet-fcloop: access fcpreq only when holding reqlock
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wagner <[email protected]>
[ Upstream commit 47a827cd7929d0550c3496d70b417fcb5649b27b ]
The abort handling logic expects that the state and the fcpreq are only accessed when holding the reqlock lock.
While at it, only handle the aborts in the abort handler.
--- drivers/nvme/target/fcloop.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/nvme/target/fcloop.c +16 -15
@@ -613,12 +613,13 @@ fcloop_fcp_recv_work(struct work_struct *work) {struct fcloop_fcpreq *tfcp_req = container_of(work, struct fcloop_fcpreq, fcp_rcv_work); -struct nvmefc_fcp_req *fcpreq = tfcp_req->fcpreq; +struct nvmefc_fcp_req *fcpreq;unsigned long flags;int ret =0 ;bool aborted = false;spin_lock_irqsave (&tfcp_req->reqlock, flags); + fcpreq = tfcp_req->fcpreq;switch (tfcp_req->inistate) {case INI_IO_START : tfcp_req->inistate =INI_IO_ACTIVE ;
@@ -633,16 +634,19 @@ fcloop_fcp_recv_work(struct work_struct *work) }spin_unlock_irqrestore (&tfcp_req->reqlock, flags); -if (unlikely (aborted)) - ret = -ECANCELED ; -else { -if (likely (!check_for_drop (tfcp_req))) - ret =nvmet_fc_rcv_fcp_req (tfcp_req->tport->targetport, - &tfcp_req->tgt_fcp_req, - fcpreq->cmdaddr, fcpreq->cmdlen); -else -pr_info ("%s: dropped command ********\n" , __func__); +if (unlikely (aborted)) { +/* the abort handler will call fcloop_call_host_done */ +return ; + } + +if (unlikely (check_for_drop (tfcp_req))) { +pr_info ("%s: dropped command ********\n" , __func__); +return ; } + + ret =nvmet_fc_rcv_fcp_req (tfcp_req->tport->targetport, + &tfcp_req->tgt_fcp_req, + fcpreq->cmdaddr, fcpreq->cmdlen);if (ret)fcloop_call_host_done (fcpreq, tfcp_req, ret);
@@ -659,9 +663,10 @@ fcloop_fcp_abort_recv_work(struct work_struct *work)unsigned long flags;spin_lock_irqsave (&tfcp_req->reqlock, flags); - fcpreq = tfcp_req->fcpreq;switch (tfcp_req->inistate) {case INI_IO_ABORTED : + fcpreq = tfcp_req->fcpreq; + tfcp_req->fcpreq =NULL ;break ;case INI_IO_COMPLETED : completed = true;
@@ -683,10 +688,6 @@ fcloop_fcp_abort_recv_work(struct work_struct *work)nvmet_fc_rcv_fcp_abort (tfcp_req->tport->targetport, &tfcp_req->tgt_fcp_req); -spin_lock_irqsave (&tfcp_req->reqlock, flags); - tfcp_req->fcpreq =NULL ; -spin_unlock_irqrestore (&tfcp_req->reqlock, flags); -fcloop_call_host_done (fcpreq, tfcp_req, -ECANCELED );/* call_host_done releases reference for abort downcall */ }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 264/508 perf: Ensure bpf_perf_link path is properly serialized
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
[ Upstream commit 7ed9138a72829d2035ecbd8dbd35b1bc3c137c40 ]
Ravi reported that the bpf_perf_link_attach() usage of perf_event_set_bpf_prog() is not serialized by ctx->mutex, unlike the PERF_EVENT_IOC_SET_BPF case.
--- kernel/events/core.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-)
kernel/events/core.c +30 -4
@@ -5726,6 +5726,9 @@ static int perf_event_set_output(struct perf_event *event,static int perf_event_set_filter (struct perf_event *event,void __user *arg);static int perf_copy_attr (struct perf_event_attr __user *uattr,struct perf_event_attr *attr); +static int __perf_event_set_bpf_prog (struct perf_event *event, +struct bpf_prog *prog, +u64 bpf_cookie);static long _perf_ioctl (struct perf_event *event,unsigned int cmd,unsigned long arg) {
@@ -5794,7 +5797,7 @@ static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned lonif (IS_ERR (prog))return PTR_ERR (prog); - err =perf_event_set_bpf_prog (event, prog,0 ); + err =__perf_event_set_bpf_prog (event, prog,0 );if (err) {bpf_prog_put (prog);return err;
@@ -10350,8 +10353,9 @@ static inline bool perf_event_is_tracing(struct perf_event *event)return false; } -int perf_event_set_bpf_prog (struct perf_event *event,struct bpf_prog *prog, -u64 bpf_cookie) +static int __perf_event_set_bpf_prog (struct perf_event *event, +struct bpf_prog *prog, +u64 bpf_cookie) {bool is_kprobe, is_uprobe, is_tracepoint, is_syscall_tp;
@@ -10389,6 +10393,20 @@ int perf_event_set_bpf_prog(struct perf_event *event, struct bpf_prog *prog,return perf_event_attach_bpf_prog (event, prog, bpf_cookie); } +int perf_event_set_bpf_prog (struct perf_event *event, +struct bpf_prog *prog, +u64 bpf_cookie) +{ +struct perf_event_context *ctx; +int ret; + + ctx =perf_event_ctx_lock (event); + ret =__perf_event_set_bpf_prog (event, prog, bpf_cookie); +perf_event_ctx_unlock (event, ctx); + +return ret; +} +void perf_event_free_bpf_prog (struct perf_event *event) {if (!perf_event_is_tracing (event)) {
@@ -10408,7 +10426,15 @@ static void perf_event_free_filter(struct perf_event *event) { } -int perf_event_set_bpf_prog (struct perf_event *event,struct bpf_prog *prog, +static int __perf_event_set_bpf_prog (struct perf_event *event, +struct bpf_prog *prog, +u64 bpf_cookie) +{ +return -ENOENT ; +} + +int perf_event_set_bpf_prog (struct perf_event *event, +struct bpf_prog *prog,u64 bpf_cookie) {return -ENOENT ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 265/508 bio: Fix bio_first_folio() for SPARSEMEM without VMEMMAP
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit f826ec7966a63d48e16e0868af4e038bf9a1a3ae ]
It is possible for physically contiguous folios to have discontiguous struct pages if SPARSEMEM is enabled and SPARSEMEM_VMEMMAP is not. This is correctly handled by folio_page_idx(), so remove this open-coded implementation.
--- include/linux/bio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/bio.h +1 -1
@@ -287,7 +287,7 @@ static inline void bio_first_folio(struct folio_iter *fi, struct bio *bio, fi->folio =page_folio (bvec->bv_page); fi->offset = bvec->bv_offset + -PAGE_SIZE * (bvec->bv_page - &fi->folio->page); +PAGE_SIZE *folio_page_idx (fi->folio, bvec->bv_page); fi->_seg_count = bvec->bv_len; fi->length =min (folio_size (fi->folio) - fi->offset, fi->_seg_count); fi->_next =folio_next (fi->folio);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 266/508 tools/resolve_btfids: Fix build when cross compiling kernel with clang.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suleiman Souhlal <[email protected]>
commit a298bbab903e3fb4cbe16d36d6195e68fad1b776 upstream.
When cross compiling the kernel with clang, we need to override CLANG_CROSS_FLAGS when preparing the step libraries.
Prior to commit d1d096312176 ("tools: fix annoying "mkdir -p ..." logs when building tools in parallel"), MAKEFLAGS would have been set to a value that wouldn't set a value for CLANG_CROSS_FLAGS, hiding the fact that we weren't properly overriding it.
--- tools/bpf/resolve_btfids/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bpf/resolve_btfids/Makefile +1 -1
@@ -19,7 +19,7 @@ endif # Overrides for the prepare step libraries. HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH)" \ - CROSS_COMPILE="" EXTRA_CFLAGS="$(HOSTCFLAGS)" + CROSS_COMPILE="" CLANG_CROSS_FLAGS="" EXTRA_CFLAGS="$(HOSTCFLAGS)" RM ?= rm HOSTCC ?= gcc
Greg Kroah-Hartman
maintainerPATCH 267/508 ALSA: usb-audio: Add implicit feedback quirk for RODE AI-1
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Heimann <[email protected]>
commit 6a3439a417b910e662c666993798e0691bc81147 upstream.
The RODE AI-1 audio interface requires implicit feedback sync between playback endpoint 0x03 and feedback endpoint 0x84 on interface 3, but doesn't advertise this in its USB descriptors.
Without this quirk, the device receives audio data but produces no output.
--- sound/usb/implicit.c | 1 + 1 file changed, 1 insertion(+)
sound/usb/implicit.c +1 -0
@@ -57,6 +57,7 @@ static const struct snd_usb_implicit_fb_IMPLICIT_FB_FIXED_DEV (0x31e9 ,0x0002 ,0x81 ,2 ),/* Solid State Logic SSL2+ */ IMPLICIT_FB_FIXED_DEV (0x0499 ,0x172f ,0x81 ,2 ),/* Steinberg UR22C */ IMPLICIT_FB_FIXED_DEV (0x0d9a ,0x00df ,0x81 ,2 ),/* RTX6001 */ +IMPLICIT_FB_FIXED_DEV (0x19f7 ,0x000a ,0x84 ,3 ),/* RODE AI-1 */ IMPLICIT_FB_FIXED_DEV (0x22f0 ,0x0006 ,0x81 ,3 ),/* Allen&Heath Qu-16 */ IMPLICIT_FB_FIXED_DEV (0x1686 ,0xf029 ,0x82 ,2 ),/* Zoom UAC-2 */ IMPLICIT_FB_FIXED_DEV(0x2466, 0x8003, 0x86, 2), /* Fractal Audio Axe-Fx II */
Greg Kroah-Hartman
maintainerPATCH 268/508 HID: usbhid: Eliminate recurrent out-of-bounds bug in usbhid_parse()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Terry Junge <[email protected]>
commit fe7f7ac8e0c708446ff017453add769ffc15deed upstream.
Update struct hid_descriptor to better reflect the mandatory and optional parts of the HID Descriptor as per USB HID 1.11 specification.
Note: the kernel currently does not parse any optional HID class descriptors, only the mandatory report descriptor.
Update all references to member element desc[0] to rpt_desc.
Add test to verify bLength and bNumDescriptors values are valid.
Replace the for loop with direct access to the mandatory HID class descriptor member for the report descriptor. This eliminates the possibility of getting an out-of-bounds fault.
Add a warning message if the HID descriptor contains any unsupported optional HID class descriptors.
--- drivers/hid/hid-hyperv.c | 4 ++-- drivers/hid/usbhid/hid-core.c | 25 ++++++++++++++----------- drivers/usb/gadget/function/f_hid.c | 12 ++++++------ include/linux/hid.h | 3 ++- 4 files changed, 24 insertions(+), 20 deletions(-)
drivers/hid/hid-hyperv.c +2 -2
@@ -200,7 +200,7 @@ static void mousevsc_on_receive_device_i goto cleanup; input_device->report_desc_size =le16_to_cpu ( - desc->desc[0 ].wDescriptorLength); + desc->rpt_desc.wDescriptorLength);if (input_device->report_desc_size ==0 ) { input_device->dev_info_status = -EINVAL ; goto cleanup;
@@ -218,7 +218,7 @@ static void mousevsc_on_receive_device_imemcpy (input_device->report_desc, ((unsigned char *)desc) + desc->bLength, -le16_to_cpu (desc->desc[0 ].wDescriptorLength)); +le16_to_cpu (desc->rpt_desc.wDescriptorLength));/* Send the ack */ memset (&ack,0 ,sizeof (struct mousevsc_prt_msg ));
drivers/hid/usbhid/hid-core.c +14 -11
@@ -982,12 +982,11 @@ static int usbhid_parse(struct hid_devicstruct usb_host_interface *interface = intf->cur_altsetting;struct usb_device *dev =interface_to_usbdev (intf);struct hid_descriptor *hdesc; +struct hid_class_descriptor *hcdesc;u32 quirks =0 ;unsigned int rsize =0 ;char *rdesc; -int ret, n; -int num_descriptors; -size_t offset = offsetof(struct hid_descriptor , desc); +int ret; quirks =hid_lookup_quirk (hid);
@@ -1009,20 +1008,19 @@ static int usbhid_parse(struct hid_devicreturn -ENODEV ; } -if (hdesc->bLength <sizeof (struct hid_descriptor )) { -dbg_hid ("hid descriptor is too short\n" ); +if (!hdesc->bNumDescriptors || + hdesc->bLength !=sizeof (*hdesc) + + (hdesc->bNumDescriptors -1 ) *sizeof (*hcdesc)) { +dbg_hid ("hid descriptor invalid, bLen=%hhu bNum=%hhu\n" , + hdesc->bLength, hdesc->bNumDescriptors);return -EINVAL ; } hid->version =le16_to_cpu (hdesc->bcdHID); hid->country = hdesc->bCountryCode; - num_descriptors =min_t (int, hdesc->bNumDescriptors, - (hdesc->bLength - offset) /sizeof (struct hid_class_descriptor )); - -for (n =0 ; n < num_descriptors; n++) -if (hdesc->desc[n].bDescriptorType ==HID_DT_REPORT ) - rsize =le16_to_cpu (hdesc->desc[n].wDescriptorLength); +if (hdesc->rpt_desc.bDescriptorType ==HID_DT_REPORT ) + rsize =le16_to_cpu (hdesc->rpt_desc.wDescriptorLength);if (!rsize || rsize >HID_MAX_DESCRIPTOR_SIZE ) {dbg_hid ("weird size of report descriptor (%u)\n" , rsize);
@@ -1050,6 +1048,11 @@ static int usbhid_parse(struct hid_devic goto err; } +if (hdesc->bNumDescriptors >1 ) +hid_warn (intf, +"%u unsupported optional hid class descriptors\n" , + (int )(hdesc->bNumDescriptors -1 )); + hid->quirks |= quirks;return 0 ;
drivers/usb/gadget/function/f_hid.c +6 -6
@@ -114,8 +114,8 @@ static struct hid_descriptor hidg_desc = .bcdHID = cpu_to_le16(0x0101), .bCountryCode = 0x00, .bNumDescriptors = 0x1, -/*.desc[0].bDescriptorType = DYNAMIC */ -/*.desc[0].wDescriptorLenght = DYNAMIC */ +/*.rpt_desc.bDescriptorType = DYNAMIC */ +/*.rpt_desc.wDescriptorLength = DYNAMIC */ };/* Super-Speed Support */
@@ -724,8 +724,8 @@ static int hidg_setup(struct usb_functiostruct hid_descriptor hidg_desc_copy = hidg_desc;VDBG (cdev,"USB_REQ_GET_DESCRIPTOR: HID\n" ); - hidg_desc_copy.desc[0 ].bDescriptorType =HID_DT_REPORT ; - hidg_desc_copy.desc[0 ].wDescriptorLength = + hidg_desc_copy.rpt_desc.bDescriptorType =HID_DT_REPORT ; + hidg_desc_copy.rpt_desc.wDescriptorLength =cpu_to_le16 (hidg->report_desc_length); length = min_t(unsigned short, length,
@@ -966,8 +966,8 @@ static int hidg_bind(struct usb_configur* We can use hidg_desc struct here but we should not relay * that its content won't change after returning from this function. */ - hidg_desc.desc[0 ].bDescriptorType =HID_DT_REPORT ; - hidg_desc.desc[0 ].wDescriptorLength = + hidg_desc.rpt_desc.bDescriptorType =HID_DT_REPORT ; + hidg_desc.rpt_desc.wDescriptorLength =cpu_to_le16 (hidg->report_desc_length); hidg_hs_in_ep_desc.bEndpointAddress =
include/linux/hid.h +2 -1
@@ -703,8 +703,9 @@ struct hid_descriptor {__le16 bcdHID;__u8 bCountryCode;__u8 bNumDescriptors; +struct hid_class_descriptor rpt_desc; -struct hid_class_descriptor desc[1 ]; +struct hid_class_descriptor opt_descs[]; } __attribute__ ((packed));#define HID_DEVICE (b, g, ven, prod) \
Greg Kroah-Hartman
maintainerPATCH 269/508 Revert "io_uring: ensure deferred completions are posted for multishot"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
This reverts commit b82c386898f7b00cb49abe3fbd622017aaa61230 which is commit 687b2bae0efff9b25e071737d6af5004e6e35af5 upstream.
Jens writes:
There's some missing dependencies that makes this not work right, I'll bring it back in a series instead.
--- io_uring/io_uring.c | 8 -------- 1 file changed, 8 deletions(-)
io_uring/io_uring.c +0 -8
@@ -820,14 +820,6 @@ bool io_post_aux_cqe(struct io_ring_ctx {bool filled; -/* -* If multishot has already posted deferred completions, ensure that -* those are flushed first before posting this one. If not, CQEs -* could get reordered. -*/ -if (!wq_list_empty (&ctx->submit_state.compl_reqs)) -__io_submit_flush_completions (ctx); -io_cq_lock (ctx); filled =io_fill_cqe_aux (ctx, user_data, res, cflags, allow_overflow);io_cq_unlock_post (ctx);
Greg Kroah-Hartman
maintainerPATCH 270/508 posix-cpu-timers: fix race between handle_posix_cpu_timers() and posix_cpu_timer_del()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Nesterov <[email protected]>
commit f90fff1e152dedf52b932240ebbd670d83330eca upstream.
If an exiting non-autoreaping task has already passed exit_notify() and calls handle_posix_cpu_timers() from IRQ, it can be reaped by its parent or debugger right after unlock_task_sighand().
If a concurrent posix_cpu_timer_del() runs at that moment, it won't be able to detect timer->it.cpu.firing != 0: cpu_timer_task_rcu() and/or lock_task_sighand() will fail.
Add the tsk->exit_state check into run_posix_cpu_timers() to fix this.
This fix is not needed if CONFIG_POSIX_CPU_TIMERS_TASK_WORK=y, because exit_task_work() is called before exit_notify(). But the check still makes sense, task_work_add(&tsk->posix_cputimers_work.work) will fail anyway in this case.
--- kernel/time/posix-cpu-timers.c | 9 +++++++++ 1 file changed, 9 insertions(+)
kernel/time/posix-cpu-timers.c +9 -0
@@ -1439,6 +1439,15 @@ void run_posix_cpu_timers(void)lockdep_assert_irqs_disabled ();/* +* Ensure that release_task(tsk) can't happen while +* handle_posix_cpu_timers() is running. Otherwise, a concurrent +* posix_cpu_timer_del() may fail to lock_task_sighand(tsk) and +* miss timer->it.cpu.firing != 0. +*/ +if (tsk->exit_state) +return ; + +/* * If the actual expiry is deferred to task work context and the * work is already scheduled there is no point to do anything here. */
Greg Kroah-Hartman
maintainerPATCH 271/508 drm/amd/display: Do not add -mhard-float to dml_ccflags for clang
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 7db038d9790eda558dd6c1dde4cdd58b64789c47 upstream.
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it warns:
clang-16: error: argument unused during compilation: '-mhard-float' [-Werror,-Wunused-command-line-argument]
Similar to commit 84edc2eff827 ("selftest/fpu: avoid clang warning"), just add this flag to GCC builds. Commit 0f0727d971f6 ("drm/amd/display:
readd -msse2 to prevent Clang from emitting libcalls to undefined SW FP routines") added '-msse2' to prevent clang from emitting software floating point routines.
--- drivers/gpu/drm/amd/display/dc/dml/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dml/Makefile +2 -1
@@ -26,7 +26,8 @@ # subcomponents. ifdef CONFIG_X86 -dml_ccflags := -mhard-float -msse +dml_ccflags-$(CONFIG_CC_IS_GCC) := -mhard-float +dml_ccflags := $(dml_ccflags-y) -msse endif ifdef CONFIG_PPC64
Greg Kroah-Hartman
maintainerPATCH 272/508 mips: Include KBUILD_CPPFLAGS in CHECKFLAGS invocation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 08f6554ff90ef189e6b8f0303e57005bddfdd6a7 upstream.
A future change will move CLANG_FLAGS from KBUILD_{A,C}FLAGS to KBUILD_CPPFLAGS so that '--target' is available while preprocessing. When that occurs, the following error appears when building ARCH=mips with clang (tip of tree error shown):
clang: error: unsupported option '-mabi=' for target 'x86_64-pc-linux-gnu'
Add KBUILD_CPPFLAGS in the CHECKFLAGS invocation to keep everything working after the move.
--- arch/mips/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/Makefile +1 -1
@@ -351,7 +351,7 @@ KBUILD_CFLAGS += -fno-asynchronous-unwin KBUILD_LDFLAGS += -m $(ld-emul) ifdef need-compiler -CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ +CHECKFLAGS += $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ grep -E -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \ sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g') endif
Greg Kroah-Hartman
maintainerPATCH 273/508 kbuild: Add CLANG_FLAGS to as-instr
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit cff6e7f50bd315e5b39c4e46c704ac587ceb965f upstream.
A future change will move CLANG_FLAGS from KBUILD_{A,C}FLAGS to KBUILD_CPPFLAGS so that '--target' is available while preprocessing. When that occurs, the following errors appear multiple times when building ARCH=powerpc powernv_defconfig:
ld.lld: error: vmlinux.a(arch/powerpc/kernel/head_64.o):(.text+0x12d4): relocation R_PPC64_ADDR16_HI out of range: -4611686018409717520 is not in [-2147483648, 2147483647]; references '__start___soft_mask_table' ld.lld: error: vmlinux.a(arch/powerpc/kernel/head_64.o):(.text+0x12e8): relocation R_PPC64_ADDR16_HI out of range: -4611686018409717392 is not in [-2147483648, 2147483647]; references '__stop___soft_mask_table'
Diffing the .o.cmd files reveals that -DHAVE_AS_ATHIGH=1 is not present anymore, because as-instr only uses KBUILD_AFLAGS, which will no longer contain '--target'.
Mirror Kconfig's as-instr and add CLANG_FLAGS explicitly to the invocation to ensure the target information is always present.
--- scripts/Makefile.compiler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.compiler +1 -1
@@ -38,7 +38,7 @@ as-option = $(call try-run,\ # Usage: aflags-y += $(call as-instr,instr,option1,option2) as-instr = $(call try-run,\ - printf "%b\n" "$(1)" | $(CC) -Werror $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3)) + printf "%b\n" "$(1)" | $(CC) -Werror $(CLANG_FLAGS) $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3)) # __cc-option # Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
Greg Kroah-Hartman
maintainerPATCH 274/508 kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
commit feb843a469fb0ab00d2d23cfb9bcc379791011bb upstream.
When preprocessing arch/*/kernel/vmlinux.lds.S, the target triple is not passed to $(CPP) because we add it only to KBUILD_{C,A}FLAGS.
As a result, the linker script is preprocessed with predefined macros for the build host instead of the target.
Assuming you use an x86 build machine, compare the following:
$ clang -dM -E -x c /dev/null $ clang -dM -E -x c /dev/null -target aarch64-linux-gnu
There is no actual problem presumably because our linker scripts do not rely on such predefined macros, but it is better to define correct ones.
Move $(CLANG_FLAGS) to KBUILD_CPPFLAGS, so that all *.c, *.S, *.lds.S will be processed with the proper target triple.
[Note]
After the patch submission, we got an actual problem that needs this commit. (CBL issue 1859)
--- scripts/Makefile.clang | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/Makefile.clang +1 -2
@@ -36,6 +36,5 @@ endif # so they can be implemented or wrapped in cc-option. CLANG_FLAGS += -Werror=unknown-warning-option CLANG_FLAGS += -Werror=ignored-optimization-argument -KBUILD_CFLAGS += $(CLANG_FLAGS) -KBUILD_AFLAGS += $(CLANG_FLAGS) +KBUILD_CPPFLAGS += $(CLANG_FLAGS) export CLANG_FLAGS
Greg Kroah-Hartman
maintainerPATCH 275/508 kbuild: Add KBUILD_CPPFLAGS to as-option invocation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 43fc0a99906e04792786edf8534d8d58d1e9de0c upstream.
After commit feb843a469fb ("kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS"), there is an error while building certain PowerPC assembly files with clang:
arch/powerpc/lib/copypage_power7.S: Assembler messages:
arch/powerpc/lib/copypage_power7.S:34: Error: junk at end of line: 0b01000' arch/powerpc/lib/copypage_power7.S:35: Error: junk at end of line: 0b01010' arch/powerpc/lib/copypage_power7.S:37: Error: junk at end of line: 0b01000' arch/powerpc/lib/copypage_power7.S:38: Error: junk at end of line: 0b01010' arch/powerpc/lib/copypage_power7.S:40: Error: junk at end of line: `0b01010'
clang: error: assembler command failed with exit code 1 (use -v to see invocation)
as-option only uses KBUILD_AFLAGS, so after removing CLANG_FLAGS from KBUILD_AFLAGS, there is no more '--target=' or '--prefix=' flags. As a result of those missing flags, the host target
will be tested during as-option calls and likely fail, meaning necessary flags may not get added when building assembly files, resulting in errors like seen above.
Add KBUILD_CPPFLAGS to as-option invocations to clear up the errors. This should have been done in commit d5c8d6e0fa61 ("kbuild: Update assembler calls to use proper flags and language target"), which switched from using the assembler target to the assembler-with-cpp target, so flags that affect preprocessing are passed along in all relevant tests. as-option now mirrors cc-option.
--- scripts/Makefile.compiler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.compiler +1 -1
@@ -32,7 +32,7 @@ try-run = $(shell set -e; \ # Usage: aflags-y += $(call as-option,-Wa$(comma)-isa=foo,) as-option = $(call try-run,\ - $(CC) -Werror $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp /dev/null -o "$$TMP",$(1),$(2)) + $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp /dev/null -o "$$TMP",$(1),$(2)) # as-instr # Usage: aflags-y += $(call as-instr,instr,option1,option2)
Greg Kroah-Hartman
maintainerPATCH 276/508 usb: usbtmc: Fix read_stb function and get_stb ioctl
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Penkler <[email protected]>
commit acb3dac2805d3342ded7dbbd164add32bbfdf21c upstream.
The usbtmc488_ioctl_read_stb function relied on a positive return from usbtmc_get_stb to reset the srq condition in the driver. The USBTMC_IOCTL_GET_STB case tested for a positive return to return the stb to the user.
Commit: <cac01bd178d6> ("usb: usbtmc: Fix erroneous get_stb ioctl error returns") changed the return value of usbtmc_get_stb to 0 on success instead of returning the value of usb_control_msg which is positive in the normal case. This change caused the function usbtmc488_ioctl_read_stb and the USBTMC_IOCTL_GET_STB ioctl to no longer function correctly.
Change the test in usbtmc488_ioctl_read_stb to test for failure first and return the failure code immediately.
Change the test for the USBTMC_IOCTL_GET_STB ioctl to test for 0 instead of a positive value.
--- drivers/usb/class/usbtmc.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/usb/class/usbtmc.c +9 -8
@@ -565,14 +565,15 @@ static int usbtmc488_ioctl_read_stb(stru rv =usbtmc_get_stb (file_data, &stb); -if (rv >0 ) { - srq_asserted =atomic_xchg (&file_data->srq_asserted, - srq_asserted); -if (srq_asserted) - stb |=0x40 ;/* Set RQS bit */ +if (rv <0 ) +return rv; + + srq_asserted =atomic_xchg (&file_data->srq_asserted, srq_asserted); +if (srq_asserted) + stb |=0x40 ;/* Set RQS bit */ + + rv =put_user (stb, (__u8 __user *)arg); - rv =put_user (stb, (__u8 __user *)arg); - }return rv; }
@@ -2201,7 +2202,7 @@ static long usbtmc_ioctl(struct file *ficase USBTMC_IOCTL_GET_STB : retval =usbtmc_get_stb (file_data, &tmp_byte); -if (retval >0 ) +if (!retval) retval =put_user (tmp_byte, (__u8 __user *)arg);break ;
Greg Kroah-Hartman
maintainerPATCH 277/508 VMCI: fix race between vmci_host_setup_notify and vmci_ctx_unset_notify
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wupeng Ma <[email protected]>
commit 1bd6406fb5f36c2bb1e96e27d4c3e9f4d09edde4 upstream.
During our test, it is found that a warning can be trigger in try_grab_folio as follow:
------------[ cut here ]------------ WARNING: CPU: 0 PID: 1678 at mm/gup.c:147 try_grab_folio+0x106/0x130 Modules linked in: CPU: 0 UID: 0 PID: 1678 Comm: syz.3.31 Not tainted 6.15.0-rc5 #163 PREEMPT(undef) RIP: 0010:try_grab_folio+0x106/0x130 Call Trace: <TASK> follow_huge_pmd+0x240/0x8e0 follow_pmd_mask.constprop.0.isra.0+0x40b/0x5c0 follow_pud_mask.constprop.0.isra.0+0x14a/0x170 follow_page_mask+0x1c2/0x1f0 __get_user_pages+0x176/0x950 __gup_longterm_locked+0x15b/0x1060 ? gup_fast+0x120/0x1f0 gup_fast_fallback+0x17e/0x230 get_user_pages_fast+0x5f/0x80 vmci_host_unlocked_ioctl+0x21c/0xf80 RIP: 0033:0x54d2cd ---[ end trace 0000000000000000 ]---
Digging into the source, context->notify_page may init by get_user_pages_fast and can be seen in vmci_ctx_unset_notify which will try to put_page. However get_user_pages_fast is not finished here and lead to following try_grab_folio warning. The race condition is shown as follow:
cpu0 cpu1vmci_host_do_set_notifyvmci_host_setup_notifyget_user_pages_fast(uva, 1, FOLL_WRITE, &context->notify_page); lockless_pages_from_mmgup_pgd_rangegup_huge_pmd // update &context->notify_page
vmci_host_do_set_notify vmci_ctx_unset_notify notify_page = context->notify_page; if (notify_page) put_page(notify_page); // page is freed
__gup_longterm_locked__get_user_pagesfollow_trans_huge_pmdtry_grab_folio // warn here
To slove this, use local variable page to make notify_page can be seen after finish get_user_pages_fast.
--- drivers/misc/vmw_vmci/vmci_host.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/misc/vmw_vmci/vmci_host.c +5 -6
@@ -227,6 +227,7 @@ static int drv_cp_harray_to_user(void __static int vmci_host_setup_notify (struct vmci_ctx *context,unsigned long uva) { +struct page *page;int retval;if (context->notify_page) {
@@ -243,13 +244,11 @@ static int vmci_host_setup_notify(struct/* * Lock physical page backing a given user VA. */ - retval =get_user_pages_fast (uva,1 ,FOLL_WRITE , &context->notify_page); -if (retval !=1 ) { - context->notify_page =NULL ; + retval =get_user_pages_fast (uva,1 ,FOLL_WRITE , &page); +if (retval !=1 )return VMCI_ERROR_GENERIC ; - } -if (context->notify_page ==NULL ) -return VMCI_ERROR_UNAVAILABLE ; + + context->notify_page = page;/* * Map the locked page and set up notify pointer.
Greg Kroah-Hartman
maintainerPATCH 278/508 usb: cdnsp: Fix issue with detecting command completion event
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pawel Laszczak <[email protected]>
commit f4ecdc352646f7d23f348e5c544dbe3212c94fc8 upstream.
In some cases, there is a small-time gap in which CMD_RING_BUSY can be cleared by controller but adding command completion event to event ring will be delayed. As the result driver will return error code.
This behavior has been detected on usbtest driver (test 9) with configuration including ep1in/ep1out bulk and ep2in/ep2out isoc endpoint.
Probably this gap occurred because controller was busy with adding some other events to event ring.
The CMD_RING_BUSY is cleared to '0' when the Command Descriptor has been executed and not when command completion event has been added to event ring.
To fix this issue for this test the small delay is sufficient less than 10us) but to make sure the problem doesn't happen again in the future the patch introduces 10 retries to check with delay about 20us before returning error code.
--- drivers/usb/cdns3/cdnsp-gadget.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/usb/cdns3/cdnsp-gadget.c +17 -1
@@ -546,6 +546,7 @@ int cdnsp_wait_for_cmd_compl(struct cdnsdma_addr_t cmd_deq_dma;union cdnsp_trb *event;u32 cycle_state; +u32 retry =10 ;int ret, val;u64 cmd_dma;u32 flags;
@@ -577,8 +578,23 @@ int cdnsp_wait_for_cmd_compl(struct cdns flags =le32_to_cpu (event->event_cmd.flags);/* Check the owner of the TRB. */ -if ((flags &TRB_CYCLE ) != cycle_state) +if ((flags &TRB_CYCLE ) != cycle_state) { +/* +* Give some extra time to get chance controller +* to finish command before returning error code. +* Checking CMD_RING_BUSY is not sufficient because +* this bit is cleared to '0' when the Command +* Descriptor has been executed by controller +* and not when command completion event has +* be added to event ring. +*/ +if (retry--) { +udelay (20 ); +continue ; + } +return -EINVAL ; + } cmd_dma =le64_to_cpu (event->event_cmd.cmd_trb);
Greg Kroah-Hartman
maintainerPATCH 279/508 usb: cdnsp: Fix issue with detecting USB 3.2 speed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pawel Laszczak <[email protected]>
commit 2852788cfbe9ca1ab68509d65804413871f741f9 upstream.
Patch adds support for detecting SuperSpeedPlus Gen1 x2 and SuperSpeedPlus Gen2 x2 speed.
--- drivers/usb/cdns3/cdnsp-gadget.c | 3 ++- drivers/usb/cdns3/cdnsp-gadget.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/usb/cdns3/cdnsp-gadget.c +2 -1
@@ -28,7 +28,8 @@unsigned int cdnsp_port_speed (unsigned int port_status) {/*Detect gadget speed based on PORTSC register*/ -if (DEV_SUPERSPEEDPLUS (port_status)) +if (DEV_SUPERSPEEDPLUS (port_status) || +DEV_SSP_GEN1x2 (port_status) ||DEV_SSP_GEN2x2 (port_status))return USB_SPEED_SUPER_PLUS ;else if (DEV_SUPERSPEED (port_status))return USB_SPEED_SUPER ;
drivers/usb/cdns3/cdnsp-gadget.h +4 -0
@@ -285,11 +285,15 @@ struct cdnsp_port_regs {#define XDEV_HS (0x3 << 10)#define XDEV_SS (0x4 << 10)#define XDEV_SSP (0x5 << 10) +#define XDEV_SSP1x2 (0x6 << 10) +#define XDEV_SSP2x2 (0x7 << 10)#define DEV_UNDEFSPEED (p) (((p) & DEV_SPEED_MASK) == (0x0 << 10))#define DEV_FULLSPEED (p) (((p) & DEV_SPEED_MASK) == XDEV_FS)#define DEV_HIGHSPEED (p) (((p) & DEV_SPEED_MASK) == XDEV_HS)#define DEV_SUPERSPEED (p) (((p) & DEV_SPEED_MASK) == XDEV_SS)#define DEV_SUPERSPEEDPLUS (p) (((p) & DEV_SPEED_MASK) == XDEV_SSP) +#define DEV_SSP_GEN1x2 (p) (((p) & DEV_SPEED_MASK) == XDEV_SSP1x2) +#define DEV_SSP_GEN2x2 (p) (((p) & DEV_SPEED_MASK) == XDEV_SSP2x2)#define DEV_SUPERSPEED_ANY (p) (((p) & DEV_SPEED_MASK) >= XDEV_SS)#define DEV_PORT_SPEED (p) (((p) >> 10) & 0x0f)/* Port Link State Write Strobe - set this when changing link state */
Greg Kroah-Hartman
maintainerPATCH 280/508 usb: Flush altsetting 0 endpoints before reinitializating them after reset.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 89bb3dc13ac29a563f4e4c555e422882f64742bd upstream.
usb core avoids sending a Set-Interface altsetting 0 request after device reset, and instead relies on calling usb_disable_interface() and usb_enable_interface() to flush and reset host-side of those endpoints.
xHCI hosts allocate and set up endpoint ring buffers and host_ep->hcpriv during usb_hcd_alloc_bandwidth() callback, which in this case is called before flushing the endpoint in usb_disable_interface().
Call usb_disable_interface() before usb_hcd_alloc_bandwidth() to ensure URBs are flushed before new ring buffers for the endpoints are allocated.
Otherwise host driver will attempt to find and remove old stale URBs from a freshly allocated new ringbuffer.
--- drivers/usb/core/hub.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/usb/core/hub.c +14 -2
@@ -6087,6 +6087,7 @@ static int usb_reset_and_verify_device(sstruct usb_hub *parent_hub;struct usb_hcd *hcd =bus_to_hcd (udev->bus);struct usb_device_descriptor descriptor; +struct usb_interface *intf;struct usb_host_bos *bos;int i, j, ret =0 ;int port1 = udev->portnum;
@@ -6140,6 +6141,18 @@ static int usb_reset_and_verify_device(sif (!udev->actconfig) goto done; +/* +* Some devices can't handle setting default altsetting 0 with a +* Set-Interface request. Disable host-side endpoints of those +* interfaces here. Enable and reset them back after host has set +* its internal endpoint structures during usb_hcd_alloc_bandwith() +*/ +for (i =0 ; i < udev->actconfig->desc.bNumInterfaces; i++) { + intf = udev->actconfig->interface[i]; +if (intf->cur_altsetting->desc.bAlternateSetting ==0 ) +usb_disable_interface (udev, intf, true); + } +mutex_lock (hcd->bandwidth_mutex); ret =usb_hcd_alloc_bandwidth (udev, udev->actconfig,NULL ,NULL );if (ret <0 ) {
@@ -6171,12 +6184,11 @@ static int usb_reset_and_verify_device(s*/ for (i =0 ; i < udev->actconfig->desc.bNumInterfaces; i++) {struct usb_host_config *config = udev->actconfig; -struct usb_interface *intf = config->interface[i];struct usb_interface_descriptor *desc; + intf = config->interface[i]; desc = &intf->cur_altsetting->desc;if (desc->bAlternateSetting ==0 ) { -usb_disable_interface (udev, intf, true);usb_enable_interface (udev, intf, true); ret =0 ; }else {
Greg Kroah-Hartman
maintainerPATCH 281/508 usb: typec: tcpm/tcpci_maxim: Fix bounds check in process_rx()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Sunil Dhamne <[email protected]>
commit 0736299d090f5c6a1032678705c4bc0a9511a3db upstream.
Register read of TCPC_RX_BYTE_CNT returns the total size consisting of:
PD message (pending read) size + 1 Byte for Frame Type (SOP*)
This is validated against the max PD message (struct pd_message) size without accounting for the extra byte for the frame type. Note that the struct pd_message does not contain a field for the frame_type. This results in false negatives when the "PD message (pending read)" is equal to the max PD message size.
--- drivers/usb/typec/tcpm/tcpci_maxim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpci_maxim.c +2 -1
@@ -171,7 +171,8 @@ static void process_rx(struct max_tcpci_return ; } -if (count >sizeof (struct pd_message ) || count +1 >TCPC_RECEIVE_BUFFER_LEN ) { +if (count >sizeof (struct pd_message ) +1 || + count +1 >TCPC_RECEIVE_BUFFER_LEN ) {dev_err (chip->dev,"Invalid TCPC_RX_BYTE_CNT %d\n" , count);return ; }
Greg Kroah-Hartman
maintainerPATCH 282/508 xen/arm: call uaccess_ttbr0_enable for dm_op hypercall
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Stabellini <[email protected]>
commit 7f9bbc1140ff8796230bc2634055763e271fd692 upstream.
dm_op hypercalls might come from userspace and pass memory addresses as parameters. The memory addresses typically correspond to buffers allocated in userspace to hold extra hypercall parameters.
On ARM, when CONFIG_ARM64_SW_TTBR0_PAN is enabled, they might not be accessible by Xen, as a result ioreq hypercalls might fail. See the existing comment in arch/arm64/xen/hypercall.S regarding privcmd_call for reference.
For privcmd_call, Linux calls uaccess_ttbr0_enable before issuing the hypercall thanks to commit 9cf09d68b89a. We need to do the same for dm_op. This resolves the problem.
Message-ID: <alpine.DEB.2.22.394.2505121446370.8380@ubuntu-linux-20-04-desktop>
--- arch/arm64/xen/hypercall.S | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
arch/arm64/xen/hypercall.S +20 -1
@@ -83,7 +83,26 @@ HYPERCALL3(vcpu_op); HYPERCALL1(platform_op_raw); HYPERCALL2(multicall); HYPERCALL2(vm_assist); -HYPERCALL3(dm_op); + +SYM_FUNC_START(HYPERVISOR_dm_op) + mov x16, #__HYPERVISOR_dm_op; \ + /* + * dm_op hypercalls are issued by the userspace. The kernel needs to + * enable access to TTBR0_EL1 as the hypervisor would issue stage 1 + * translations to user memory via AT instructions. Since AT + * instructions are not affected by the PAN bit (ARMv8.1), we only + * need the explicit uaccess_enable/disable if the TTBR0 PAN emulation + * is enabled (it implies that hardware UAO and PAN disabled). + */ + uaccess_ttbr0_enable x6, x7, x8 + hvc XEN_IMM + + /* + * Disable userspace access from kernel once the hyp call completed. + */ + uaccess_ttbr0_disable x6, x7 + ret +SYM_FUNC_END(HYPERVISOR_dm_op); SYM_FUNC_START(privcmd_call) mov x16, x0
Greg Kroah-Hartman
maintainerPATCH 283/508 x86/iopl: Cure TIF_IO_BITMAP inconsistencies
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 8b68e978718f14fdcb080c2a7791c52a0d09bc6d upstream.
io_bitmap_exit() is invoked from exit_thread() when a task exists or when a fork fails. In the latter case the exit_thread() cleans up resources which were allocated during fork().
io_bitmap_exit() invokes task_update_io_bitmap(), which in turn ends up in tss_update_io_bitmap(). tss_update_io_bitmap() operates on the current task. If current has TIF_IO_BITMAP set, but no bitmap installed, tss_update_io_bitmap() crashes with a NULL pointer dereference.
There are two issues, which lead to that problem:
1) io_bitmap_exit() should not invoke task_update_io_bitmap() when the task, which is cleaned up, is not the current task. That's a clear indicator for a cleanup after a failed fork().
2) A task should not have TIF_IO_BITMAP set and neither a bitmap installed nor IOPL emulation level 3 activated.
This happens when a kernel thread is created in the context of a user space thread, which has TIF_IO_BITMAP set as the thread flags are copied and the IO bitmap pointer is cleared.
Other than in the failed fork() case this has no impact because kernel threads including IO workers never return to user space and therefore never invoke tss_update_io_bitmap().
Cure this by adding the missing cleanups and checks:
1) Prevent io_bitmap_exit() to invoke task_update_io_bitmap() if the to be cleaned up task is not the current task.
2) Clear TIF_IO_BITMAP in copy_thread() unconditionally. For user space forks it is set later, when the IO bitmap is inherited in io_bitmap_share().
For paranoia sake, add a warning into tss_update_io_bitmap() to catch the case, when that code is invoked with inconsistent state.
--- arch/x86/kernel/ioport.c | 13 +++++++++---- arch/x86/kernel/process.c | 6 ++++++ 2 files changed, 15 insertions(+), 4 deletions(-)
arch/x86/kernel/ioport.c +9 -4
@@ -33,8 +33,9 @@ void io_bitmap_share(struct task_structset_tsk_thread_flag (tsk,TIF_IO_BITMAP ); } -static void task_update_io_bitmap (struct task_struct *tsk) +static void task_update_io_bitmap (void ) { +struct task_struct *tsk = current;struct thread_struct *t = &tsk->thread;if (t->iopl_emul ==3 || t->io_bitmap) {
@@ -54,7 +55,12 @@ void io_bitmap_exit(struct task_struct *struct io_bitmap *iobm = tsk->thread.io_bitmap; tsk->thread.io_bitmap =NULL ; -task_update_io_bitmap (tsk); +/* +* Don't touch the TSS when invoked on a failed fork(). TSS +* reflects the state of @current and not the state of @tsk. +*/ +if (tsk == current) +task_update_io_bitmap ();if (iobm &&refcount_dec_and_test (&iobm->refcnt))kfree (iobm); }
@@ -192,8 +198,7 @@ SYSCALL_DEFINE1(iopl, unsigned int, leve } t->iopl_emul = level; -task_update_io_bitmap (current); - +task_update_io_bitmap ();return 0 ; }
arch/x86/kernel/process.c +6 -0
@@ -154,6 +154,7 @@ int copy_thread(struct task_struct *p, c frame->ret_addr = (unsigned long ) ret_from_fork; p->thread.sp = (unsigned long ) fork_frame; p->thread.io_bitmap =NULL ; +clear_tsk_thread_flag (p,TIF_IO_BITMAP ); p->thread.iopl_warn =0 ;memset (p->thread.ptrace_bps,0 ,sizeof (p->thread.ptrace_bps));
@@ -428,6 +429,11 @@ void native_tss_update_io_bitmap(void) }else {struct io_bitmap *iobm = t->io_bitmap; +if (WARN_ON_ONCE (!iobm)) { +clear_thread_flag (TIF_IO_BITMAP ); +native_tss_invalidate_io_bitmap (); + } +/* * Only copy bitmap data when the sequence number differs. The * update time is accounted to the incoming task.