perf test stat: Update test expectations and events
Subsystems (274)
Sasha Levin
maintainerPATCH 316/752 mailbox: sprd: clear delivery flag before handling TX done
In reply to Sasha LevinFrom: Otto Pflüger <[email protected]>
[ Upstream commit c77661d60d4223bf2ff10d409beb0c3b2021183b ]
If there are any pending messages in the mailbox queue, they are sent as soon as a TX done event arrives from the driver. This may trigger a new delivery interrupt while the previous one is still being handled. If the delivery status is cleared after this, the interrupt is lost. To prevent this from happening, clear the delivery status immediately after checking it and before any new messages are sent.
--- drivers/mailbox/sprd-mailbox.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mailbox/sprd-mailbox.c +5 -5
@@ -166,6 +166,11 @@ static irqreturn_t sprd_mbox_inbox_isr(int irq, void *data)return IRQ_NONE ; } +/* Clear FIFO delivery and overflow status first */ +writel (fifo_sts & + (SPRD_INBOX_FIFO_DELIVER_MASK |SPRD_INBOX_FIFO_OVERLOW_MASK ), + priv->inbox_base +SPRD_MBOX_FIFO_RST ); +while (send_sts) { id =__ffs (send_sts); send_sts &= (send_sts -1 );
@@ -181,11 +186,6 @@ static irqreturn_t sprd_mbox_inbox_isr(int irq, void *data)mbox_chan_txdone (chan,0 ); } -/* Clear FIFO delivery and overflow status */ -writel (fifo_sts & - (SPRD_INBOX_FIFO_DELIVER_MASK |SPRD_INBOX_FIFO_OVERLOW_MASK ), - priv->inbox_base +SPRD_MBOX_FIFO_RST ); -/* Clear irq status */ writel (SPRD_MBOX_IRQ_CLR , priv->inbox_base +SPRD_MBOX_IRQ_STS );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 317/752 clk: amlogic: remove potentially unsafe flags from S4 video clocks
In reply to Sasha LevinFrom: Chuan Liu <[email protected]>
[ Upstream commit 4aca7e92023cac5018b4053bae324450f884c937 ]
The video clocks enci, encp, vdac and hdmitx share the same clock source. Adding CLK_SET_RATE_PARENT to the mux may unintentionally change the shared parent clock, which could affect other video clocks.
--- drivers/clk/meson/s4-peripherals.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/clk/meson/s4-peripherals.c +0 -4
@@ -1106,7 +1106,6 @@ static struct clk_regmap s4_cts_enci_sel = { .ops = &clk_regmap_mux_ops, .parent_hws = s4_cts_parents, .num_parents = ARRAY_SIZE(s4_cts_parents), - .flags = CLK_SET_RATE_PARENT, }, };
@@ -1122,7 +1121,6 @@ static struct clk_regmap s4_cts_encp_sel = { .ops = &clk_regmap_mux_ops, .parent_hws = s4_cts_parents, .num_parents = ARRAY_SIZE(s4_cts_parents), - .flags = CLK_SET_RATE_PARENT, }, };
@@ -1138,7 +1136,6 @@ static struct clk_regmap s4_cts_vdac_sel = { .ops = &clk_regmap_mux_ops, .parent_hws = s4_cts_parents, .num_parents = ARRAY_SIZE(s4_cts_parents), - .flags = CLK_SET_RATE_PARENT, }, };
@@ -1169,7 +1166,6 @@ static struct clk_regmap s4_hdmi_tx_sel = { .ops = &clk_regmap_mux_ops, .parent_hws = s4_hdmi_tx_parents, .num_parents = ARRAY_SIZE(s4_hdmi_tx_parents), - .flags = CLK_SET_RATE_PARENT, }, };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 318/752 clk: renesas: rzg2l: Deassert reset on assert timeout
In reply to Sasha LevinFrom: Biju Das <[email protected]>
[ Upstream commit 0b0201f259e1158a875c5fd01adf318ae5d32352 ]
If the assert() fails due to timeout error, set the reset register bit back to deasserted state. This change is needed especially for handling assert error in suspend() callback that expect the device to be in operational state in case of failure.
--- drivers/clk/renesas/rzg2l-cpg.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/clk/renesas/rzg2l-cpg.c +5 -4
@@ -1647,6 +1647,7 @@ static int __rzg2l_cpg_assert(struct reset_controller_dev *rcdev,u32 mask =BIT (info->resets[id].bit);s8 monbit = info->resets[id].monbit;u32 value = mask <<16 ; +u32 mon;int ret; dev_dbg(rcdev->dev, "%s id:%ld offset:0x%x\n",
@@ -1667,10 +1668,10 @@ static int __rzg2l_cpg_assert(struct reset_controller_dev *rcdev,return 0 ; } - ret =readl_poll_timeout_atomic (priv->base + reg, value, - assert == !!(value & mask),10 ,200 ); -if (ret && !assert) { - value = mask <<16 ; + ret =readl_poll_timeout_atomic (priv->base + reg, mon, + assert == !!(mon & mask),10 ,200 ); +if (ret) { + value ^= mask;writel (value, priv->base +CLK_RST_R (info->resets[id].off)); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 319/752 clk: microchip: core: correct return value on *_get_parent()
In reply to Sasha LevinFrom: Brian Masney <[email protected]>
[ Upstream commit 5df96d141cccb37f0c3112a22fc1112ea48e9246 ]
roclk_get_parent() and sclk_get_parent() has the possibility of returning -EINVAL, however the framework expects this call to always succeed since the return value is unsigned.
If there is no parent map defined, then the current value programmed in the hardware is used. Let's use that same value in the case where -EINVAL is currently returned.
This index is only used by clk_core_get_parent_by_index(), and it validates that it doesn't overflow the number of available parents.
--- drivers/clk/microchip/clk-core.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/clk/microchip/clk-core.c +12 -13
@@ -283,14 +283,13 @@ static u8 roclk_get_parent(struct clk_hw *hw) v = (readl (refo->ctrl_reg) >>REFO_SEL_SHIFT ) &REFO_SEL_MASK ; -if (!refo->parent_map) -return v; - -for (i =0 ; i <clk_hw_get_num_parents (hw); i++) -if (refo->parent_map[i] == v) -return i; +if (refo->parent_map) { +for (i =0 ; i <clk_hw_get_num_parents (hw); i++) +if (refo->parent_map[i] == v) +return i; + } -return -EINVAL ; +return v; } static unsigned long roclk_calc_rate(unsigned long parent_rate,
@@ -817,13 +816,13 @@ static u8 sclk_get_parent(struct clk_hw *hw) v = (readl (sclk->mux_reg) >>OSC_CUR_SHIFT ) &OSC_CUR_MASK ; -if (!sclk->parent_map) -return v; +if (sclk->parent_map) { +for (i =0 ; i <clk_hw_get_num_parents (hw); i++) +if (sclk->parent_map[i] == v) +return i; + } -for (i =0 ; i <clk_hw_get_num_parents (hw); i++) -if (sclk->parent_map[i] == v) -return i; -return -EINVAL ; +return v; }static int sclk_set_parent (struct clk_hw *hw,u8 index)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 320/752 HID: i2c-hid: Add FocalTech FT8112
In reply to Sasha LevinFrom: Daniel Peng <[email protected]>
[ Upstream commit 3d9586f1f90c9101b1abf5b0e9d70ca45f5f16db ]
Information for touchscreen model HKO/RB116AS01-2 as below:
- HID :FTSC1000
- slave address:0X38
- Interface:HID over I2C
- Touch control lC:FT8112
- I2C ID: PNP0C50
--- drivers/hid/i2c-hid/i2c-hid-of-elan.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/hid/i2c-hid/i2c-hid-of-elan.c +8 -0
@@ -168,6 +168,13 @@ static const struct elan_i2c_hid_chip_data elan_ekth6a12nay_chip_data = { .power_after_backlight = true, }; +static const struct elan_i2c_hid_chip_data focaltech_ft8112_chip_data = { + .post_power_delay_ms =10 , + .post_gpio_reset_on_delay_ms =150 , + .hid_descriptor_address =0x0001 , + .main_supply_name ="vcc33" , +}; +static const struct elan_i2c_hid_chip_data ilitek_ili9882t_chip_data = { .post_power_delay_ms =1 , .post_gpio_reset_on_delay_ms =200 ,
@@ -191,6 +198,7 @@ static const struct elan_i2c_hid_chip_data ilitek_ili2901_chip_data = {static const struct of_device_id elan_i2c_hid_of_match[] = { { .compatible ="elan,ekth6915" , .data = &elan_ekth6915_chip_data }, { .compatible ="elan,ekth6a12nay" , .data = &elan_ekth6a12nay_chip_data }, + { .compatible ="focaltech,ft8112" , .data = &focaltech_ft8112_chip_data }, { .compatible ="ilitek,ili9882t" , .data = &ilitek_ili9882t_chip_data }, { .compatible ="ilitek,ili2901" , .data = &ilitek_ili2901_chip_data }, { }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 321/752 m68k: nommu: fix memmove() with differently aligned src and dest for 68000
In reply to Sasha LevinFrom: Daniel Palmer <[email protected]>
[ Upstream commit 590fe2f46c8698bb758f9002cb247ca10ce95569 ]
68000 has different alignment needs to 68020+.memcpy() checks if the destination is aligned and does a smaller copy to fix the alignment and then critically for 68000 it checks if the source is still unaligned and if it is reverts to smaller copies.
memmove() does not currently do the second part and malfunctions if one of the pointers is aligned and the other isn't.
This is apparently getting triggered by printk. If I put breakpoints into the new checks added by this commit the first hit looks like this:
memmove (n=205, src=0x2f3971 <printk_shared_pbufs+205>, dest=0x2f3980 <printk_shared_pbufs+220>) at arch/m68k/lib/memmove.c:82
--- arch/m68k/lib/memmove.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/m68k/lib/memmove.c +18 -0
@@ -24,6 +24,15 @@ void *memmove(void *dest, const void *src, size_t n) src = csrc; n--; } +#if defined(CONFIG_M68000 ) +if ((long )src &1 ) { +char *cdest = dest; +const char *csrc = src; +for (; n; n--) + *cdest++ = *csrc++; +return xdest; + } +#endif if (n >2 && (long )dest &2 ) {short *sdest = dest;const short *ssrc = src;
@@ -66,6 +75,15 @@ void *memmove(void *dest, const void *src, size_t n) src = csrc; n--; } +#if defined(CONFIG_M68000 ) +if ((long )src &1 ) { +char *cdest = dest; +const char *csrc = src; +for (; n; n--) + *--cdest = *--csrc; +return xdest; + } +#endif if (n >2 && (long )dest &2 ) {short *sdest = dest;const short *ssrc = src;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 322/752 9p/xen: protect xen_9pfs_front_free against concurrent calls
In reply to Sasha LevinFrom: Stefano Stabellini <[email protected]>
[ Upstream commit ce8ded2e61f47747e31eeefb44dc24a2160a7e32 ]
The xenwatch thread can race with other back-end change notifications and call xen_9pfs_front_free() twice, hitting the observed general protection fault due to a double-free. Guard the teardown path so only one caller can release the front-end state at a time, preventing the crash.
This is a fix for the following double-free:
[ 27.052347] Oops: general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b6b6b: 0000 [#1] SMP DEBUG_PAGEALLOC NOPTI [ 27.052357] CPU: 0 UID: 0 PID: 32 Comm: xenwatch Not tainted 6.18.0-02087-g51ab33fc0a8b-dirty #60 PREEMPT(none) [ 27.052363] RIP: e030:xen_9pfs_front_free+0x1d/0x150 [ 27.052368] Code: 90 90 90 90 90 90 90 90 90 90 90 90 90 41 55 41 54 55 48 89 fd 48 c7 c7 48 d0 92 85 53 e8 cb cb 05 00 48 8b 45 08 48 8b 55 00 <48> 3b 28 0f 85 f9 28 35 fe 48 3b 6a 08 0f 85 ef 28 35 fe 48 89 42 [ 27.052377] RSP: e02b:ffffc9004016fdd0 EFLAGS: 00010246 [ 27.052381] RAX: 6b6b6b6b6b6b6b6b RBX: ffff88800d66e400 RCX: 0000000000000000 [ 27.052385] RDX: 6b6b6b6b6b6b6b6b RSI: 0000000000000000 RDI: 0000000000000000 [ 27.052389] RBP: ffff88800a887040 R08: 0000000000000000 R09: 0000000000000000 [ 27.052393] R10: 0000000000000000 R11: 0000000000000000 R12: ffff888009e46b68 [ 27.052397] R13: 0000000000000200 R14: 0000000000000000 R15: ffff88800a887040 [ 27.052404] FS: 0000000000000000(0000) GS:ffff88808ca57000(0000) knlGS:0000000000000000 [ 27.052408] CS: e030 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 27.052412] CR2: 00007f9714004360 CR3: 0000000004834000 CR4: 0000000000050660 [ 27.052418] Call Trace: [ 27.052420] <TASK> [ 27.052422] xen_9pfs_front_changed+0x5d5/0x720 [ 27.052426] ? xenbus_otherend_changed+0x72/0x140 [ 27.052430] ? __pfx_xenwatch_thread+0x10/0x10 [ 27.052434] xenwatch_thread+0x94/0x1c0 [ 27.052438] ? __pfx_autoremove_wake_function+0x10/0x10 [ 27.052442] kthread+0xf8/0x240 [ 27.052445] ? __pfx_kthread+0x10/0x10 [ 27.052449] ? __pfx_kthread+0x10/0x10 [ 27.052452] ret_from_fork+0x16b/0x1a0 [ 27.052456] ? __pfx_kthread+0x10/0x10 [ 27.052459] ret_from_fork_asm+0x1a/0x30 [ 27.052463] </TASK> [ 27.052465] Modules linked in: [ 27.052471] ---[ end trace 0000000000000000 ]---
Message-ID: <[email protected]>
--- net/9p/trans_xen.c | 85 ++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 41 deletions(-)
net/9p/trans_xen.c +44 -41
@@ -274,45 +274,52 @@ static void xen_9pfs_front_free(struct xen_9pfs_front_priv *priv) {int i, j; -write_lock (&xen_9pfs_lock); -list_del (&priv->list); -write_unlock (&xen_9pfs_lock); - -for (i =0 ; i <XEN_9PFS_NUM_RINGS ; i++) { -struct xen_9pfs_dataring *ring = &priv->rings[i]; - -cancel_work_sync (&ring->work); - -if (!priv->rings[i].intf) -break ; -if (priv->rings[i].irq >0 ) -unbind_from_irqhandler (priv->rings[i].irq, ring); -if (priv->rings[i].data.in) { -for (j =0 ; - j < (1 << priv->rings[i].intf->ring_order); - j++) { -grant_ref_t ref; - - ref = priv->rings[i].intf->ref[j]; -gnttab_end_foreign_access (ref,NULL ); - } -free_pages_exact (priv->rings[i].data.in, +if (priv->rings) { +for (i =0 ; i <XEN_9PFS_NUM_RINGS ; i++) { +struct xen_9pfs_dataring *ring = &priv->rings[i]; + +cancel_work_sync (&ring->work); + +if (!priv->rings[i].intf) +break ; +if (priv->rings[i].irq >0 ) +unbind_from_irqhandler (priv->rings[i].irq, ring); +if (priv->rings[i].data.in) { +for (j =0 ; + j < (1 << priv->rings[i].intf->ring_order); + j++) { +grant_ref_t ref; + + ref = priv->rings[i].intf->ref[j]; +gnttab_end_foreign_access (ref,NULL ); + } +free_pages_exact (priv->rings[i].data.in,1UL << (priv->rings[i].intf->ring_order +XEN_PAGE_SHIFT )); + } +gnttab_end_foreign_access (priv->rings[i].ref,NULL ); +free_page ((unsigned long )priv->rings[i].intf); } -gnttab_end_foreign_access (priv->rings[i].ref,NULL ); -free_page ((unsigned long )priv->rings[i].intf); +kfree (priv->rings); } -kfree (priv->rings);kfree (priv->tag);kfree (priv); }static void xen_9pfs_front_remove (struct xenbus_device *dev) { -struct xen_9pfs_front_priv *priv =dev_get_drvdata (&dev->dev); +struct xen_9pfs_front_priv *priv; +write_lock (&xen_9pfs_lock); + priv =dev_get_drvdata (&dev->dev); +if (priv ==NULL ) { +write_unlock (&xen_9pfs_lock); +return ; + }dev_set_drvdata (&dev->dev,NULL ); +list_del (&priv->list); +write_unlock (&xen_9pfs_lock); +xen_9pfs_front_free (priv); }
@@ -379,7 +386,7 @@ static int xen_9pfs_front_init(struct xenbus_device *dev) {int ret, i;struct xenbus_transaction xbt; -struct xen_9pfs_front_priv *priv =dev_get_drvdata (&dev->dev); +struct xen_9pfs_front_priv *priv;char *versions, *v;unsigned int max_rings, max_ring_order, len =0 ;
@@ -407,6 +414,10 @@ static int xen_9pfs_front_init(struct xenbus_device *dev)if (p9_xen_trans.maxsize >XEN_FLEX_RING_SIZE (max_ring_order)) p9_xen_trans.maxsize =XEN_FLEX_RING_SIZE (max_ring_order) /2 ; + priv =kzalloc (sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + priv->dev = dev; priv->rings =kcalloc (XEN_9PFS_NUM_RINGS ,sizeof (*priv->rings),GFP_KERNEL );if (!priv->rings) {
@@ -465,6 +476,11 @@ static int xen_9pfs_front_init(struct xenbus_device *dev) goto error; } +write_lock (&xen_9pfs_lock); +dev_set_drvdata (&dev->dev, priv); +list_add_tail (&priv->list, &xen_9pfs_devs); +write_unlock (&xen_9pfs_lock); +xenbus_switch_state (dev, XenbusStateInitialised);return 0 ;
@@ -479,19 +495,6 @@ static int xen_9pfs_front_init(struct xenbus_device *dev)static int xen_9pfs_front_probe (struct xenbus_device *dev,const struct xenbus_device_id *id) { -struct xen_9pfs_front_priv *priv =NULL ; - - priv =kzalloc (sizeof (*priv),GFP_KERNEL ); -if (!priv) -return -ENOMEM ; - - priv->dev = dev; -dev_set_drvdata (&dev->dev, priv); - -write_lock (&xen_9pfs_lock); -list_add_tail (&priv->list, &xen_9pfs_devs); -write_unlock (&xen_9pfs_lock); -return 0 ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 323/752 dmaengine: stm32-dma3: use module_platform_driver
In reply to Sasha LevinFrom: Amelie Delaunay <[email protected]>
[ Upstream commit 0d41ed4ea496fabbb4dc21171e32d9a924c2a661 ]
Without module_platform_driver(), stm32-dma3 doesn't have a module_exit procedure. Once stm32-dma3 module is inserted, it can't be removed, marked busy.
Use module_platform_driver() instead of subsys_initcall() to register (insmod) and unregister (rmmod) stm32-dma3 driver.
--- drivers/dma/stm32/stm32-dma3.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/dma/stm32/stm32-dma3.c +1 -6
@@ -1914,12 +1914,7 @@ static struct platform_driver stm32_dma3_driver = { }, }; -static int __init stm32_dma3_init (void ) -{ -return platform_driver_register (&stm32_dma3_driver); -} - -subsys_initcall (stm32_dma3_init); +module_platform_driver (stm32_dma3_driver);MODULE_DESCRIPTION ("STM32 DMA3 controller driver" );MODULE_AUTHOR ("Amelie Delaunay <[email protected]>" );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 324/752 soundwire: dmi-quirks: add mapping for Avell B.ON (OEM rebranded of NUC15)
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit 59946373755d71dbd7614ba235e0093159f80b69 ]
Avell B.ON is an OEM re-branded NUC15 'Bishop County' LAPBC510 and LAPBC710.
--- drivers/soundwire/dmi-quirks.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/soundwire/dmi-quirks.c +11 -0
@@ -122,6 +122,17 @@ static const struct dmi_system_id adr_remap_quirk_table[] = { }, .driver_data = (void *)intel_tgl_bios, }, + { +/* +* quirk used for Avell B.ON (OEM rebrand of NUC15 'Bishop County' +* LAPBC510 and LAPBC710) +*/ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Avell High Performance" ), + DMI_MATCH(DMI_PRODUCT_NAME, "B.ON"), + }, + .driver_data = (void *)intel_tgl_bios, + }, {/* quirk used for NUC15 'Rooks County' LAPRC510 and LAPRC710 skews */ .matches = {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 325/752 soundwire: intel_auxdevice: add cs42l45 codec to wake_capable_list
In reply to Sasha LevinFrom: Maciej Strozek <[email protected]>
[ Upstream commit f87e5575a6bd1925cd55f500b61b661724372e5f ]
Add cs42l45 to the wake_capable_list because it can generate jack events whilst the bus is stopped.
--- drivers/soundwire/intel_auxdevice.c | 1 + 1 file changed, 1 insertion(+)
drivers/soundwire/intel_auxdevice.c +1 -0
@@ -52,6 +52,7 @@ struct wake_capable_part {static struct wake_capable_part wake_capable_list[] = { {0x01fa ,0x4243 }, + {0x01fa ,0x4245 }, {0x025d ,0x5682 }, {0x025d ,0x700 }, {0x025d ,0x711 },
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 326/752 staging: rtl8723bs: fix missing status update on sdio_alloc_irq() failure
In reply to Sasha LevinFrom: Liang Jie <[email protected]>
[ Upstream commit 618b4aec12faabc7579a6b0df046842d798a4c7c ]
The return value of sdio_alloc_irq() was not stored in status. If sdio_alloc_irq() fails after rtw_drv_register_netdev() succeeds, status remains _SUCCESS and the error path skips resource cleanup, while rtw_drv_init() still returns success.
Store the return value of sdio_alloc_irq() in status and reuse the existing error handling which relies on status.
--- drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +2 -1
@@ -377,7 +377,8 @@ static int rtw_drv_init(if (status != _SUCCESS) goto free_if1; -if (sdio_alloc_irq (dvobj) != _SUCCESS) + status =sdio_alloc_irq (dvobj); +if (status != _SUCCESS) goto free_if1; status = _SUCCESS;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 327/752 serial: 8250_dw: handle clock enable errors in runtime_resume
In reply to Sasha LevinFrom: Artem Shimko <[email protected]>
[ Upstream commit d31228143a489ba6ba797896a07541ce06828c09 ]
Add error checking for clk_prepare_enable() calls in dw8250_runtime_resume(). Currently if either clock fails to enable, the function returns success while leaving clocks in inconsistent state.
This change implements comprehensive error handling by checking the return values of both clk_prepare_enable() calls. If the second clock enable operation fails after the first clock has already been successfully enabled, the code now properly cleans up by disabling and unpreparing the first clock before returning. The error code is then propagated to the caller, ensuring that clock enable failures are properly reported rather than being silently ignored.
--- drivers/tty/serial/8250/8250_dw.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_dw.c +9 -2
@@ -741,11 +741,18 @@ static int dw8250_runtime_suspend(struct device *dev)static int dw8250_runtime_resume (struct device *dev) { +int ret;struct dw8250_data *data =dev_get_drvdata (dev); -clk_prepare_enable (data->pclk); + ret =clk_prepare_enable (data->pclk); +if (ret) +return ret; -clk_prepare_enable (data->clk); + ret =clk_prepare_enable (data->clk); +if (ret) { +clk_disable_unprepare (data->pclk); +return ret; + }return 0 ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 328/752 usb: typec: ucsi: psy: Fix voltage and current max for non-Fixed PDOs
In reply to Sasha LevinFrom: Benson Leung <[email protected]>
[ Upstream commit 6811e0a08bdce6b2767414caf17fda24c2e4e032 ]
ucsi_psy_get_voltage_max and ucsi_psy_get_current_max are calculated using whichever pdo is in the last position of the src_pdos array, presuming it to be a fixed pdo, so the pdo_fixed_voltage or pdo_max_current helpers are used on that last pdo.
However, non-Fixed PDOs such as Battery PDOs, Augmented PDOs (used for AVS and for PPS) may exist, and are always at the end of the array if they do. In the event one of these more advanced chargers are attached the helpers for fixed return mangled values.
Here's an example case of a Google Pixel Flex Dual Port 67W USB-C Fast Charger with PPS support:
POWER_SUPPLY_NAME=ucsi-source-psy-cros_ec_ucsi.4.auto2 POWER_SUPPLY_TYPE=USB
POWER_SUPPLY_CHARGE_TYPE=Standard
POWER_SUPPLY_USB_TYPE=C [PD] PD_PPS PD_DRP
POWER_SUPPLY_ONLINE=1
POWER_SUPPLY_VOLTAGE_MIN=5000000 POWER_SUPPLY_VOLTAGE_MAX=13400000 POWER_SUPPLY_VOLTAGE_NOW=20000000 POWER_SUPPLY_CURRENT_MAX=5790000
POWER_SUPPLY_CURRENT_NOW=3250000
Voltage Max is reading as 13.4V, but that's an incorrect decode of the PPS APDO in the last position. Same goes for CURRENT_MAX. 5.79A is incorrect.
Instead, enumerate through the src_pdos and filter just for Fixed PDOs for now, and find the one with the highest voltage and current respectively.
After, from the same charger:
POWER_SUPPLY_NAME=ucsi-source-psy-cros_ec_ucsi.4.auto2 POWER_SUPPLY_TYPE=USB POWER_SUPPLY_CHARGE_TYPE=Standard POWER_SUPPLY_USB_TYPE=C [PD] PD_PPS PD_DRP POWER_SUPPLY_ONLINE=1 POWER_SUPPLY_VOLTAGE_MIN=5000000 POWER_SUPPLY_VOLTAGE_MAX=20000000 POWER_SUPPLY_VOLTAGE_NOW=20000000 POWER_SUPPLY_CURRENT_MAX=4000000 POWER_SUPPLY_CURRENT_NOW=3250000
--- drivers/usb/typec/ucsi/psy.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-)
drivers/usb/typec/ucsi/psy.c +20 -10
@@ -88,15 +88,20 @@ static int ucsi_psy_get_voltage_max(struct ucsi_connector *con, union power_supply_propval *val) {u32 pdo; +int max_voltage =0 ;switch (UCSI_CONSTAT (con,PWR_OPMODE )) {case UCSI_CONSTAT_PWR_OPMODE_PD : -if (con->num_pdos >0 ) { - pdo = con->src_pdos[con->num_pdos -1 ]; - val->intval =pdo_fixed_voltage (pdo) *1000 ; - }else { - val->intval =0 ; +for (int i =0 ; i < con->num_pdos; i++) { +int pdo_voltage =0 ; + + pdo = con->src_pdos[i]; +if (pdo_type (pdo) ==PDO_TYPE_FIXED ) + pdo_voltage =pdo_fixed_voltage (pdo) *1000 ; + max_voltage = (pdo_voltage > max_voltage) ? pdo_voltage + : max_voltage; } + val->intval = max_voltage;break ;case UCSI_CONSTAT_PWR_OPMODE_TYPEC3_0 :case UCSI_CONSTAT_PWR_OPMODE_TYPEC1_5 :
@@ -144,6 +149,7 @@ static int ucsi_psy_get_current_max(struct ucsi_connector *con, union power_supply_propval *val) {u32 pdo; +int max_current =0 ;if (!UCSI_CONSTAT (con,CONNECTED )) { val->intval =0 ;
@@ -152,12 +158,16 @@ static int ucsi_psy_get_current_max(struct ucsi_connector *con,switch (UCSI_CONSTAT (con,PWR_OPMODE )) {case UCSI_CONSTAT_PWR_OPMODE_PD : -if (con->num_pdos >0 ) { - pdo = con->src_pdos[con->num_pdos -1 ]; - val->intval =pdo_max_current (pdo) *1000 ; - }else { - val->intval =0 ; +for (int i =0 ; i < con->num_pdos; i++) { +int pdo_current =0 ; + + pdo = con->src_pdos[i]; +if (pdo_type (pdo) ==PDO_TYPE_FIXED ) + pdo_current =pdo_max_current (pdo) *1000 ; + max_current = (pdo_current > max_current) ? pdo_current + : max_current; } + val->intval = max_current;break ;case UCSI_CONSTAT_PWR_OPMODE_TYPEC1_5 : val->intval =UCSI_TYPEC_1_5_CURRENT *1000 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 329/752 fpga: of-fpga-region: Fail if any bridge is missing
In reply to Sasha LevinFrom: Romain Gantois <[email protected]>
[ Upstream commit c141c8221bc5089de915d9f26044df892c343c7e ]
When parsing the region bridge list from the "fpga-bridges" device tree property, the of-fpga-region driver will silently ignore bridges which fail to be obtained, for example due to a missing bridge driver or invalid phandle.
This can lead to hardware issues if a region bridge stays coupled when partial programming is performed.
Fail if any of the bridges specified in "fpga-bridges" cannot be obtained.
--- drivers/fpga/of-fpga-region.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/fpga/of-fpga-region.c +4 -4
@@ -83,7 +83,7 @@ static struct fpga_manager *of_fpga_region_get_mgr(struct device_node *np)* done with the bridges. * * Return: 0 for success (even if there are no bridges specified) -* or -EBUSY if any of the bridges are in use. +* or an error code if any of the bridges are not available. */ static int of_fpga_region_get_bridges (struct fpga_region *region) {
@@ -130,10 +130,10 @@ static int of_fpga_region_get_bridges(struct fpga_region *region) ®ion->bridge_list);of_node_put (br); -/* If any of the bridges are in use, give up */ -if (ret == -EBUSY ) { +/* If any of the bridges are not available, give up */ +if (ret) {fpga_bridges_put (®ion->bridge_list); -return -EBUSY ; +return ret; } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 330/752 most: core: fix resource leak in most_register_interface error paths
In reply to Sasha LevinFrom: Navaneeth K <[email protected]>
[ Upstream commit 1f4c9d8a1021281750c6cda126d6f8a40cc24e71 ]
The function most_register_interface() did not correctly release resources if it failed early (before registering the device). In these cases, it returned an error code immediately, leaking the memory allocated for the interface.
Fix this by initializing the device early via device_initialize() and calling put_device() on all error paths.
The most_register_interface() is expected to call put_device() on error which frees the resources allocated in the caller. The put_device() either calls release_mdev() or dim2_release(), depending on the caller.
Switch to using device_add() instead of device_register() to handle the split initialization.
--- drivers/most/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/most/core.c +5 -1
@@ -1286,15 +1286,19 @@ int most_register_interface(struct most_interface *iface) !iface->poison_channel || (iface->num_channels > MAX_CHANNELS))return -EINVAL ; +device_initialize (iface->dev); + id =ida_alloc (&mdev_id,GFP_KERNEL );if (id <0 ) {dev_err (iface->dev,"Failed to allocate device ID\n" ); +put_device (iface->dev);return id; } iface->p =kzalloc (sizeof (*iface->p),GFP_KERNEL );if (!iface->p) {ida_free (&mdev_id, id); +put_device (iface->dev);return -ENOMEM ; }
@@ -1304,7 +1308,7 @@ int most_register_interface(struct most_interface *iface) iface->dev->bus = &mostbus; iface->dev->groups = interface_attr_groups;dev_set_drvdata (iface->dev, iface); -if (device_register (iface->dev)) { +if (device_add (iface->dev)) {dev_err (iface->dev,"Failed to register interface device\n" );kfree (iface->p);put_device (iface->dev);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 331/752 dmaengine: sun6i: Choose appropriate burst length under maxburst
In reply to Sasha LevinFrom: Chen-Yu Tsai <[email protected]>
[ Upstream commit 7178c3586ab42693b28bb81014320a7783e5c435 ]
maxburst, as provided by the client, specifies the largest amount of data that is allowed to be transferred in one burst. This limit is normally provided to avoid a data burst overflowing the target FIFO. It does not mean that the DMA engine can only do bursts in that size.
Let the driver pick the largest supported burst length within the given limit. This lets the driver work correctly with some clients that give a large maxburst value. In particular, the 8250_dw driver will give a quarter of the UART's FIFO size as maxburst. On some systems the FIFO size is 256 bytes, giving a maxburst of 64 bytes, while the hardware only supports bursts of up to 16 bytes.
--- drivers/dma/sun6i-dma.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
drivers/dma/sun6i-dma.c +20 -6
@@ -583,6 +583,22 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id)return ret; } +static u32 find_burst_size (const u32 burst_lengths,u32 maxburst) +{ +if (!maxburst) +return 1 ; + +if (BIT (maxburst) & burst_lengths) +return maxburst; + +/* Hardware only does power-of-two bursts. */ +for (u32 burst =rounddown_pow_of_two (maxburst); burst >0 ; burst /=2 ) +if (BIT (burst) & burst_lengths) +return burst; + +return 1 ; +} + static int set_config(struct sun6i_dma_dev *sdev, struct dma_slave_config *sconfig, enum dma_transfer_direction direction,
@@ -616,15 +632,13 @@ static int set_config(struct sun6i_dma_dev *sdev,return -EINVAL ;if (!(BIT (dst_addr_width) & sdev->slave.dst_addr_widths))return -EINVAL ; -if (!(BIT (src_maxburst) & sdev->cfg->src_burst_lengths)) -return -EINVAL ; -if (!(BIT (dst_maxburst) & sdev->cfg->dst_burst_lengths)) -return -EINVAL ; src_width =convert_buswidth (src_addr_width); dst_width =convert_buswidth (dst_addr_width); - dst_burst =convert_burst (dst_maxburst); - src_burst =convert_burst (src_maxburst); + src_burst =find_burst_size (sdev->cfg->src_burst_lengths, src_maxburst); + dst_burst =find_burst_size (sdev->cfg->dst_burst_lengths, dst_maxburst); + dst_burst =convert_burst (dst_burst); + src_burst =convert_burst (src_burst); *p_cfg =DMA_CHAN_CFG_SRC_WIDTH (src_width) |DMA_CHAN_CFG_DST_WIDTH (dst_width);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 332/752 dmaengine: stm32-mdma: initialize m2m_hw_period and ccr to fix warnings
In reply to Sasha LevinFrom: Clément Le Goffic <[email protected]>
[ Upstream commit aaf3bc0265744adbc2d364964ef409cf118d193d ]
m2m_hw_period is initialized only when chan_config->m2m_hw is true. This triggers a warning:
‘m2m_hw_period’ may be used uninitialized [-Wmaybe-uninitialized] Although m2m_hw_period is only used when chan_config->m2m_hw is true and ignored otherwise, initialize it unconditionally to 0.
ccr is initialized by stm32_mdma_set_xfer_param() when the sg list is not empty. This triggers a warning:
‘ccr’ may be used uninitialized [-Wmaybe-uninitialized] Indeed, it could be used uninitialized if the sg list is empty. Initialize it to 0.
--- drivers/dma/stm32/stm32-mdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/stm32/stm32-mdma.c +1 -1
@@ -731,7 +731,7 @@ static int stm32_mdma_setup_xfer(struct stm32_mdma_chan *chan,struct stm32_mdma_chan_config *chan_config = &chan->chan_config;struct scatterlist *sg;dma_addr_t src_addr, dst_addr; -u32 m2m_hw_period, ccr, ctcr, ctbr; +u32 m2m_hw_period =0 , ccr =0 , ctcr, ctbr;int i, ret =0 ;if (chan_config->m2m_hw)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 333/752 phy: ti: phy-j721e-wiz: restore mux selection during resume
In reply to Sasha LevinFrom: "Thomas Richard (TI.com)" <[email protected]>
[ Upstream commit 53f6240e88c9e8715e09fc19942f13450db4cb33 ]
While suspend and resume mux selection was getting lost. So save and restore these values in suspend and resume operations.
--- drivers/phy/ti/phy-j721e-wiz.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/phy/ti/phy-j721e-wiz.c +17 -2
@@ -393,6 +393,7 @@ struct wiz {struct clk *output_clks[WIZ_MAX_OUTPUT_CLOCKS ];struct clk_onecell_data clk_data;const struct wiz_data *data; +int mux_sel_status[WIZ_MUX_NUM_CLOCKS ]; };static int wiz_reset (struct wiz *wiz)
@@ -1654,11 +1655,25 @@ static void wiz_remove(struct platform_device *pdev)pm_runtime_disable (dev); } +static int wiz_suspend_noirq (struct device *dev) +{ +struct wiz *wiz =dev_get_drvdata (dev); +int i; + +for (i =0 ; i <WIZ_MUX_NUM_CLOCKS ; i++) +regmap_field_read (wiz->mux_sel_field[i], &wiz->mux_sel_status[i]); + +return 0 ; +} +static int wiz_resume_noirq (struct device *dev) {struct device_node *node = dev->of_node;struct wiz *wiz =dev_get_drvdata (dev); -int ret; +int ret, i; + +for (i =0 ; i <WIZ_MUX_NUM_CLOCKS ; i++) +regmap_field_write (wiz->mux_sel_field[i], wiz->mux_sel_status[i]);/* Enable supplemental Control override if available */ if (wiz->sup_legacy_clk_override)
@@ -1680,7 +1695,7 @@ static int wiz_resume_noirq(struct device *dev)return ret; } -static DEFINE_NOIRQ_DEV_PM_OPS(wiz_pm_ops, NULL, wiz_resume_noirq); +static DEFINE_NOIRQ_DEV_PM_OPS(wiz_pm_ops, wiz_suspend_noirq, wiz_resume_noirq);static struct platform_driver wiz_driver = { .probe = wiz_probe,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 334/752 phy: cadence-torrent: restore parent clock for refclk during resume
In reply to Sasha LevinFrom: "Thomas Richard (TI.com)" <[email protected]>
[ Upstream commit 434e1a0ee145d0389b192252be4c993f86cf1134 ]
While suspend and resume, parent clock config for refclk was getting lost. So save and restore it in suspend and resume operations.
--- drivers/phy/cadence/phy-cadence-torrent.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/phy/cadence/phy-cadence-torrent.c +23 -0
@@ -397,6 +397,7 @@ struct cdns_torrent_refclk_driver {struct clk_hw hw;struct regmap_field *cmn_fields[REFCLK_OUT_NUM_CMN_CONFIG ];struct clk_init_data clk_data; +u8 parent_index; };#define to_cdns_torrent_refclk_driver (_hw) \
@@ -3326,11 +3327,29 @@ static const struct cdns_torrent_vals sgmii_qsgmii_xcvr_diag_ln_vals = { .num_regs = ARRAY_SIZE(sgmii_qsgmii_xcvr_diag_ln_regs), }; +static void cdns_torrent_refclk_driver_suspend (struct cdns_torrent_phy *cdns_phy) +{ +struct clk_hw *hw = cdns_phy->clk_hw_data->hws[CDNS_TORRENT_REFCLK_DRIVER ]; +struct cdns_torrent_refclk_driver *refclk_driver =to_cdns_torrent_refclk_driver (hw); + + refclk_driver->parent_index =cdns_torrent_refclk_driver_get_parent (hw); +} + +static int cdns_torrent_refclk_driver_resume (struct cdns_torrent_phy *cdns_phy) +{ +struct clk_hw *hw = cdns_phy->clk_hw_data->hws[CDNS_TORRENT_REFCLK_DRIVER ]; +struct cdns_torrent_refclk_driver *refclk_driver =to_cdns_torrent_refclk_driver (hw); + +return cdns_torrent_refclk_driver_set_parent (hw, refclk_driver->parent_index); +} +static int cdns_torrent_phy_suspend_noirq (struct device *dev) {struct cdns_torrent_phy *cdns_phy =dev_get_drvdata (dev);int i; +cdns_torrent_refclk_driver_suspend (cdns_phy); +reset_control_assert (cdns_phy->phy_rst);reset_control_assert (cdns_phy->apb_rst);for (i =0 ; i < cdns_phy->nsubnodes; i++)
@@ -3352,6 +3371,10 @@ static int cdns_torrent_phy_resume_noirq(struct device *dev)int node = cdns_phy->nsubnodes;int ret, i; + ret =cdns_torrent_refclk_driver_resume (cdns_phy); +if (ret) +return ret; + ret =cdns_torrent_clk (cdns_phy);if (ret)return ret;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 335/752 misc: bcm_vk: Fix possible null-pointer dereferences in bcm_vk_read()
In reply to Sasha LevinFrom: Tuo Li <[email protected]>
[ Upstream commit ba75ecb97d3f4e95d59002c13afb6519205be6cb ]
In the function bcm_vk_read(), the pointer entry is checked, indicating that it can be NULL. If entry is NULL and rc is set to -EMSGSIZE, the following code may cause null-pointer dereferences:
struct vk_msg_blk tmp_msg = entry->to_h_msg[0]; set_msg_id(&tmp_msg, entry->usr_msg_id); tmp_msg.size = entry->to_h_blks - 1;
To prevent these possible null-pointer dereferences, copy to_h_msg, usr_msg_id, and to_h_blks from iter into temporary variables, and return these temporary variables to the application instead of accessing them through a potentially NULL entry.
--- drivers/misc/bcm-vk/bcm_vk_msg.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/misc/bcm-vk/bcm_vk_msg.c +8 -4
@@ -1010,6 +1010,9 @@ ssize_t bcm_vk_read(struct file *p_file,struct device *dev = &vk->pdev->dev;struct bcm_vk_msg_chan *chan = &vk->to_h_msg_chan;struct bcm_vk_wkent *entry =NULL , *iter; +struct vk_msg_blk tmp_msg; +u32 tmp_usr_msg_id; +u32 tmp_blks;u32 q_num;u32 rsp_length;
@@ -1034,6 +1037,9 @@ ssize_t bcm_vk_read(struct file *p_file, entry = iter; }else {/* buffer not big enough */ + tmp_msg = iter->to_h_msg[0 ]; + tmp_usr_msg_id = iter->usr_msg_id; + tmp_blks = iter->to_h_blks; rc = -EMSGSIZE ; } goto read_loop_exit;
@@ -1052,14 +1058,12 @@ ssize_t bcm_vk_read(struct file *p_file,bcm_vk_free_wkent (dev, entry); }else if (rc == -EMSGSIZE ) { -struct vk_msg_blk tmp_msg = entry->to_h_msg[0 ]; -/* * in this case, return just the first block, so * that app knows what size it is looking for. */ -set_msg_id (&tmp_msg, entry->usr_msg_id); - tmp_msg.size = entry->to_h_blks -1 ; +set_msg_id (&tmp_msg, tmp_usr_msg_id); + tmp_msg.size = tmp_blks -1 ;if (copy_to_user (buf, &tmp_msg,VK_MSGQ_BLK_SIZE ) !=0 ) {dev_err (dev,"Error return 1st block in -EMSGSIZE\n" ); rc = -EFAULT ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 336/752 pinctrl: mediatek: make devm allocations safer and clearer in mtk_eint_do_init()
In reply to Sasha LevinFrom: Liang Jie <[email protected]>
[ Upstream commit 255b721c96046d4c57fa2268e4c72607868ce91f ]
mtk_eint_do_init() allocates several pointer arrays which are then populated in a per-instance loop and freed on error. The arrays are currently allocated with devm_kmalloc(), so their entries are left uninitialised until the per-instance allocations succeed.
On a failure in the middle of the loop, the error path iterates over the full nbase range and calls devm_kfree() on each element. For indices which were never initialised, the corresponding array entries contain stack garbage. If any of those happen to be non-zero, devm_kfree() will pass them to devres_destroy(), which will WARN because there is no matching devm_kmalloc() resource for such bogus pointers.
Improve the robustness and readability by:
- Using devm_kcalloc() for the pointer arrays so that all entries start as NULL, ensuring that only genuinely initialised elements may be freed and preventing spurious WARN_ON()s in the error path.
- Switching the allocations to sizeof(*ptr) / sizeof(**ptr) forms, avoiding hard-coded element types and making the code more resilient to future type changes.
- Dropping the redundant NULL checks before devm_kfree(), as devm_kfree() safely handles NULL pointers.
The functional behaviour in the successful initialisation path remains unchanged, while the error handling becomes simpler and less error-prone.
--- drivers/pinctrl/mediatek/mtk-eint.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/pinctrl/mediatek/mtk-eint.c +17 -12
@@ -539,24 +539,32 @@ int mtk_eint_do_init(struct mtk_eint *eint, struct mtk_eint_pin *eint_pin) } } - eint->pin_list =devm_kmalloc (eint->dev, eint->nbase *sizeof (u16 *),GFP_KERNEL ); + eint->pin_list =devm_kcalloc (eint->dev, eint->nbase, +sizeof (*eint->pin_list),GFP_KERNEL );if (!eint->pin_list) goto err_pin_list; - eint->wake_mask =devm_kmalloc (eint->dev, eint->nbase *sizeof (u32 *),GFP_KERNEL ); + eint->wake_mask =devm_kcalloc (eint->dev, eint->nbase, +sizeof (*eint->wake_mask),GFP_KERNEL );if (!eint->wake_mask) goto err_wake_mask; - eint->cur_mask =devm_kmalloc (eint->dev, eint->nbase *sizeof (u32 *),GFP_KERNEL ); + eint->cur_mask =devm_kcalloc (eint->dev, eint->nbase, +sizeof (*eint->cur_mask),GFP_KERNEL );if (!eint->cur_mask) goto err_cur_mask;for (i =0 ; i < eint->nbase; i++) { - eint->pin_list[i] =devm_kzalloc (eint->dev, eint->base_pin_num[i] *sizeof (u16), + eint->pin_list[i] =devm_kzalloc (eint->dev, + eint->base_pin_num[i] *sizeof (**eint->pin_list),GFP_KERNEL ); port =DIV_ROUND_UP (eint->base_pin_num[i],32 ); - eint->wake_mask[i] =devm_kzalloc (eint->dev, port *sizeof (u32),GFP_KERNEL ); - eint->cur_mask[i] =devm_kzalloc (eint->dev, port *sizeof (u32),GFP_KERNEL ); + eint->wake_mask[i] =devm_kzalloc (eint->dev, + port *sizeof (**eint->wake_mask), +GFP_KERNEL ); + eint->cur_mask[i] =devm_kzalloc (eint->dev, + port *sizeof (**eint->cur_mask), +GFP_KERNEL );if (!eint->pin_list[i] || !eint->wake_mask[i] || !eint->cur_mask[i]) goto err_eint; }
@@ -592,12 +600,9 @@ int mtk_eint_do_init(struct mtk_eint *eint, struct mtk_eint_pin *eint_pin) err_eint:for (i =0 ; i < eint->nbase; i++) { -if (eint->cur_mask[i]) -devm_kfree (eint->dev, eint->cur_mask[i]); -if (eint->wake_mask[i]) -devm_kfree (eint->dev, eint->wake_mask[i]); -if (eint->pin_list[i]) -devm_kfree (eint->dev, eint->pin_list[i]); +devm_kfree (eint->dev, eint->cur_mask[i]); +devm_kfree (eint->dev, eint->wake_mask[i]); +devm_kfree (eint->dev, eint->pin_list[i]); }devm_kfree (eint->dev, eint->cur_mask); err_cur_mask:
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 337/752 misc: eeprom: Fix EWEN/EWDS/ERAL commands for 93xx56 and 93xx66
In reply to Sasha LevinFrom: Markus Perkins <[email protected]>
[ Upstream commit b54c82d6cbfc76647ba558e8e3647eb2b0ba0e2b ]
commit 14374fbb3f06 ("misc: eeprom_93xx46: Add new 93c56 and 93c66 compatible strings") added support for 93xx56 and 93xx66 eeproms, but didn't take into account that the write enable/disable + erase all commands are hardcoded for the 6-bit address of the 93xx46.
This commit fixes the command word generation by increasing the number of shifts as the address field grows, keeping the command intact.
Also, the check for 8-bit or 16-bit mode is no longer required as this is already taken into account in the edev->addrlen field.
--- drivers/misc/eeprom/eeprom_93xx46.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/misc/eeprom/eeprom_93xx46.c +3 -8
@@ -45,6 +45,7 @@ struct eeprom_93xx46_platform_data {#define OP_START 0x4#define OP_WRITE (OP_START | 0x1)#define OP_READ (OP_START | 0x2) +/* The following addresses are offset for the 1K EEPROM variant in 16-bit mode */ #define ADDR_EWDS 0x00#define ADDR_ERAL 0x20#define ADDR_EWEN 0x30
@@ -191,10 +192,7 @@ static int eeprom_93xx46_ew(struct eeprom_93xx46_dev *edev, int is_on) bits = edev->addrlen +3 ; cmd_addr =OP_START << edev->addrlen; -if (edev->pdata->flags &EE_ADDR8 ) - cmd_addr |= (is_on ?ADDR_EWEN :ADDR_EWDS ) <<1 ; -else - cmd_addr |= (is_on ?ADDR_EWEN :ADDR_EWDS ); + cmd_addr |= (is_on ?ADDR_EWEN :ADDR_EWDS ) << (edev->addrlen -6 );if (has_quirk_instruction_length (edev)) { cmd_addr <<=2 ;
@@ -328,10 +326,7 @@ static int eeprom_93xx46_eral(struct eeprom_93xx46_dev *edev) bits = edev->addrlen +3 ; cmd_addr =OP_START << edev->addrlen; -if (edev->pdata->flags &EE_ADDR8 ) - cmd_addr |=ADDR_ERAL <<1 ; -else - cmd_addr |=ADDR_ERAL ; + cmd_addr |=ADDR_ERAL << (edev->addrlen -6 );if (has_quirk_instruction_length (edev)) { cmd_addr <<=2 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 338/752 misc: ti_fpc202: fix a potential memory leak in probe function
In reply to Sasha LevinFrom: Felix Gu <[email protected]>
[ Upstream commit dad9f13d967b4e53e8eaf5f9c690f8e778ad9802 ]
Use for_each_child_of_node_scoped() to simplify the code and ensure the device node reference is automatically released when the loop scope ends.
--- drivers/misc/ti_fpc202.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/misc/ti_fpc202.c +1 -2
@@ -309,7 +309,6 @@ static void fpc202_remove_port(struct fpc202_priv *priv, int port_id)static int fpc202_probe (struct i2c_client *client) {struct device *dev = &client->dev; -struct device_node *i2c_handle;struct fpc202_priv *priv;int ret, port_id;
@@ -357,7 +356,7 @@ static int fpc202_probe(struct i2c_client *client)bitmap_zero (priv->probed_ports,FPC202_NUM_PORTS ); -for_each_child_of_node (dev->of_node, i2c_handle) { +for_each_child_of_node_scoped (dev->of_node, i2c_handle) { ret =of_property_read_u32 (i2c_handle,"reg" , &port_id);if (ret) {if (ret == -EINVAL )
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 339/752 pinctrl: renesas: rzt2h: Allow .get_direction() for IRQ function GPIOs
In reply to Sasha LevinFrom: Cosmin Tanislav <[email protected]>
[ Upstream commit 49b039a61a314c18074c15a7047705399e1240e6 ]
Setting up an IRQ would normally be done in the .activate() and .deactivate() ops of the IRQ domain, but for hierarchical IRQ domains the .activate() and .deactivate() ops are overridden in the gpiochip_hierarchy_setup_domain_ops() function.
As such, activating and deactivating need to be done in the .translate() and .free() ops of the IRQ domain.
For RZ/T2H and RZ/N2H, interrupts go through the pin controller, into the ICU, which level-translates them and forwards them to the GIC.
To use a GPIO as an interrupt it needs to be put into peripheral function mode 0, which will connect it to the IRQ lines of the ICU.
The IRQ chip .child_to_parent_hwirq() callback is called as part of the IRQ fwspec parsing logic (as part of irq_create_of_mapping()) which happens before the IRQ is requested (as part of gpiochip_lock_as_irq()).
gpiochip_lock_as_irq() calls gpiod_get_direction() if the .get_direction() callback is provided to ensure that the GPIO line is set up as input.
In our case, IRQ function is separate from GPIO, and both cannot be true at the same time.
Return GPIO_LINE_DIRECTION_IN even if pin is in IRQ function to allow this setup to work.
Hold the spinlock to ensure atomicity between reading the PMC register (which determines whether the pin is in GPIO mode or not) and reading the function of the pin when it is not in GPIO mode.
--- drivers/pinctrl/renesas/pinctrl-rzt2h.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/pinctrl/renesas/pinctrl-rzt2h.c +20 -1
@@ -51,6 +51,7 @@#define PFC_MASK GENMASK_ULL(5, 0)#define PFC_PIN_MASK (pin) (PFC_MASK << ((pin) * 8)) +#define PFC_FUNC_INTERRUPT 0/* * Use 16 lower bits [15:0] for pin identifier
@@ -486,6 +487,7 @@ static int rzt2h_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)struct rzt2h_pinctrl *pctrl =gpiochip_get_data (chip);u8 port =RZT2H_PIN_ID_TO_PORT (offset);u8 bit =RZT2H_PIN_ID_TO_PIN (offset); +u64 reg64;u16 reg;int ret;
@@ -493,8 +495,25 @@ static int rzt2h_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)if (ret)return ret; -if (rzt2h_pinctrl_readb (pctrl, port,PMC (port)) &BIT (bit)) +guard (spinlock_irqsave)(&pctrl->lock); + +if (rzt2h_pinctrl_readb (pctrl, port,PMC (port)) &BIT (bit)) { +/* +* When a GPIO is being requested as an IRQ, the pinctrl +* framework expects to be able to read the GPIO's direction. +* IRQ function is separate from GPIO, and enabling it takes the +* pin out of GPIO mode. +* At this point, .child_to_parent_hwirq() has already been +* called to enable the IRQ function. +* Default to input direction for IRQ function. +*/ + reg64 =rzt2h_pinctrl_readq (pctrl, port,PFC (port)); + reg64 = (reg64 >> (bit *8 )) &PFC_MASK ; +if (reg64 ==PFC_FUNC_INTERRUPT ) +return GPIO_LINE_DIRECTION_IN ; +return -EINVAL ; + } reg =rzt2h_pinctrl_readw (pctrl, port,PM (port)); reg = (reg >> (bit *2 )) &PM_MASK ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 340/752 iio: bmi270_i2c: Add MODULE_DEVICE_TABLE for BMI260/270
In reply to Sasha LevinFrom: "Derek J. Clark" <[email protected]>
[ Upstream commit f69b5ac682dbc61e6aca806c22ce2ae74d598e45 ]
Currently BMI260 & BMI270 devices do not automatically load this driver. To fix this, add missing MODULE_DEVICE_TABLE for the i2c, acpi, and of device tables so the driver will load when the hardware is detected.
Tested on my OneXPlayer F1 Pro.
--- drivers/iio/imu/bmi270/bmi270_i2c.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/imu/bmi270/bmi270_i2c.c +3 -0
@@ -37,6 +37,7 @@ static const struct i2c_device_id bmi270_i2c_id[] = { { "bmi270", (kernel_ulong_t)&bmi270_chip_info }, { } }; +MODULE_DEVICE_TABLE (i2c, bmi270_i2c_id);static const struct acpi_device_id bmi270_acpi_match[] = { /* GPD Win Mini, Aya Neo AIR Pro, OXP Mini Pro, etc. */
@@ -45,12 +46,14 @@ static const struct acpi_device_id bmi270_acpi_match[] = { { "BMI0260", (kernel_ulong_t)&bmi260_chip_info }, { } }; +MODULE_DEVICE_TABLE(acpi, bmi270_acpi_match); static const struct of_device_id bmi270_of_match[] = { { .compatible = "bosch,bmi260", .data = &bmi260_chip_info }, { .compatible = "bosch,bmi270", .data = &bmi270_chip_info }, { } }; +MODULE_DEVICE_TABLE(of, bmi270_of_match); static struct i2c_driver bmi270_i2c_driver = { .driver = {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 341/752 usb: gadget: f_fs: fix DMA-BUF OUT queues
In reply to Sasha LevinFrom: Sam Day <[email protected]>
[ Upstream commit 0145e7acd29855dfba4a2f387d455b5d9a520f0e ]
Currently, DMA_FROM_DEVICE is used when attaching DMABUFs to IN endpoints and DMA_TO_DEVICE for OUT endpoints. This is inverted from how it should be.
The result is IOMMU read-only mappings placed on OUT queues, triggering arm-smmu write faults.
Put differently, OUT endpoints flow data from host -> gadget, meaning the UDC peripheral needs to have write access to the buffer to fill it with the incoming data.
This commit flips the directions and updates the implicit-sync helpers so IN endpoints act as readers and OUT endpoints as writers.
--- drivers/usb/gadget/function/f_fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/gadget/function/f_fs.c +3 -3
@@ -1489,7 +1489,7 @@ static int ffs_dmabuf_attach(struct file *file, int fd) goto err_dmabuf_detach; } - dir = epfile->in ?DMA_FROM_DEVICE :DMA_TO_DEVICE ; + dir = epfile->in ?DMA_TO_DEVICE :DMA_FROM_DEVICE ; err =ffs_dma_resv_lock (dmabuf, nonblock);if (err)
@@ -1619,7 +1619,7 @@ static int ffs_dmabuf_transfer(struct file *file,/* Make sure we don't have writers */ timeout = nonblock ?0 :msecs_to_jiffies (DMABUF_ENQUEUE_TIMEOUT_MS ); retl =dma_resv_wait_timeout (dmabuf->resv, -dma_resv_usage_rw (epfile->in), +dma_resv_usage_rw (!epfile->in), true, timeout);if (retl ==0 ) retl = -EBUSY ;
@@ -1664,7 +1664,7 @@ static int ffs_dmabuf_transfer(struct file *file,dma_fence_init (&fence->base, &ffs_dmabuf_fence_ops, &priv->lock, priv->context, seqno); - resv_dir = epfile->in ?DMA_RESV_USAGE_WRITE :DMA_RESV_USAGE_READ ; + resv_dir = epfile->in ?DMA_RESV_USAGE_READ :DMA_RESV_USAGE_WRITE ;dma_resv_add_fence (dmabuf->resv, &fence->base, resv_dir);dma_resv_unlock (dmabuf->resv);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 342/752 usb: gadget: f_fs: Fix ioctl error handling
In reply to Sasha LevinFrom: Sam Day <[email protected]>
[ Upstream commit 8e4c1d06183c25022f6b0002a5cab84979ca6337 ]
When ffs_epfile_ioctl handles FUNCTIONFS_DMABUF_* ioctls, it's currently falling through when copy_from_user fails.
However, this fallthrough isn't being checked properly, so the handler continues executing further than it should. It then tries the secondary dispatch where it ultimately gives up and returns -ENOTTY.
The end result is invalid ioctl invocations will yield a -ENOTTY rather than an -EFAULT.
It's a common pattern elsewhere in the kernel code to directly return -EFAULT when copy_from_user fails. So we update ffs_epfile_ioctl to do the same and fix this issue.
--- drivers/usb/gadget/function/f_fs.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/usb/gadget/function/f_fs.c +6 -12
@@ -1724,10 +1724,8 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code, {int fd; -if (copy_from_user (&fd, (void __user *)value,sizeof (fd))) { - ret = -EFAULT ; -break ; - } +if (copy_from_user (&fd, (void __user *)value,sizeof (fd))) +return -EFAULT ;return ffs_dmabuf_attach (file, fd); }
@@ -1735,10 +1733,8 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code, {int fd; -if (copy_from_user (&fd, (void __user *)value,sizeof (fd))) { - ret = -EFAULT ; -break ; - } +if (copy_from_user (&fd, (void __user *)value,sizeof (fd))) +return -EFAULT ;return ffs_dmabuf_detach (file, fd); }
@@ -1746,10 +1742,8 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code, {struct usb_ffs_dmabuf_transfer_req req; -if (copy_from_user (&req, (void __user *)value,sizeof (req))) { - ret = -EFAULT ; -break ; - } +if (copy_from_user (&req, (void __user *)value,sizeof (req))) +return -EFAULT ;return ffs_dmabuf_transfer (file, &req); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 343/752 usb: chipidea: udc: fix DMA and SG cleanup in _ep_nuke()
In reply to Sasha LevinFrom: Mario Peter <[email protected]>
[ Upstream commit cea2a1257a3b5ea3e769a445b34af13e6aa5a123 ]
The ChipIdea UDC driver can encounter "not page aligned sg buffer" errors when a USB device is reconnected after being disconnected during an active transfer. This occurs because _ep_nuke() returns requests to the gadget layer without properly unmapping DMA buffers or cleaning up scatter-gather bounce buffers.
Root cause:
When a disconnect happens during a multi-segment DMA transfer, the request's num_mapped_sgs field and sgt.sgl pointer remain set with stale values. The request is returned to the gadget driver with status -ESHUTDOWN but still has active DMA state. If the gadget driver reuses this request on reconnect without reinitializing it, the stale DMA state causes _hardware_enqueue() to skip DMA mapping (seeing non-zero num_mapped_sgs) and attempt to use freed/invalid DMA addresses, leading to alignment errors and potential memory corruption.
The normal completion path via _hardware_dequeue() properly calls usb_gadget_unmap_request_by_dev() and sglist_do_debounce() before returning the request. The _ep_nuke() path must do the same cleanup to ensure requests are returned in a clean, reusable state.
Fix:
Add DMA unmapping and bounce buffer cleanup to _ep_nuke() to mirror the cleanup sequence in _hardware_dequeue():
- Call usb_gadget_unmap_request_by_dev() if num_mapped_sgs is set
- Call sglist_do_debounce() with copy=false if bounce buffer exists
This ensures that when requests are returned due to endpoint shutdown, they don't retain stale DMA mappings. The 'false' parameter to sglist_do_debounce() prevents copying data back (appropriate for shutdown path where transfer was aborted).
--- drivers/usb/chipidea/udc.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/chipidea/udc.c +7 -0
@@ -931,6 +931,13 @@ __acquires(hwep->lock)list_del_init (&hwreq->queue); hwreq->req.status = -ESHUTDOWN ; +/* Unmap DMA and clean up bounce buffers before giving back */ +usb_gadget_unmap_request_by_dev (hwep->ci->dev->parent, + &hwreq->req, hwep->dir); + +if (hwreq->sgt.sgl) +sglist_do_debounce (hwreq, false); +if (hwreq->req.complete !=NULL ) {spin_unlock (hwep->lock);usb_gadget_giveback_request (&hwep->ep, &hwreq->req);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 344/752 staging: rtl8723bs: fix memory leak on failure path
In reply to Sasha LevinFrom: Diksha Kumari <[email protected]>
[ Upstream commit abe850d82c8cb72d28700673678724e779b1826e ]
cfg80211_inform_bss_frame() may return NULL on failure. In that case, the allocated buffer 'buf' is not freed and the function returns early, leading to potential memory leak.
Fix this by ensuring that 'buf' is freed on both success and failure paths.
--- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +2 -1
@@ -315,9 +315,10 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl len, notify_signal, GFP_ATOMIC);if (unlikely (!bss)) - goto exit; + goto free_buf;cfg80211_put_bss (wiphy, bss); +free_buf:kfree (buf); exit:
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 345/752 serial: 8250: 8250_omap.c: Add support for handling UART error conditions
In reply to Sasha LevinFrom: Moteen Shah <[email protected]>
[ Upstream commit 623b07b370e9963122d167e04fdc1dc713ebfbaf ]
The DMA IRQ handler does not accounts for the overrun(OE) or any other errors being reported by the IP before triggering a DMA transaction which leads to the interrupts not being handled resulting into an IRQ storm.
The way to handle OE is to:
1. Reset the RX FIFO.
2. Read the UART_RESUME register, which clears the internal flag
Earlier, the driver issued DMA transations even in case of OE which shouldn't be done according to the OE handling mechanism mentioned above, as we are resetting the FIFO's, refer section: "12.1.6.4.8.1.3.6 Overrun During Receive" [0].
[0] https://www.ti.com/lit/pdf/spruiu1
--- drivers/tty/serial/8250/8250_omap.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_omap.c +21 -2
@@ -100,6 +100,9 @@#define OMAP_UART_REV_52 0x0502#define OMAP_UART_REV_63 0x0603 +/* Resume register */ +#define UART_OMAP_RESUME 0x0B +/* Interrupt Enable Register 2 */ #define UART_OMAP_IER2 0x1B#define UART_OMAP_IER2_RHR_IT_DIS BIT(2)
@@ -119,7 +122,6 @@/* Timeout low and High */ #define UART_OMAP_TO_L 0x26#define UART_OMAP_TO_H 0x27 -struct omap8250_priv {void __iomem *membase;int line;
@@ -1256,6 +1258,20 @@ static u16 omap_8250_handle_rx_dma(struct uart_8250_port *up, u8 iir, u16 statusreturn status; } +static void am654_8250_handle_uart_errors (struct uart_8250_port *up,u8 iir,u16 status) +{ +if (status &UART_LSR_OE ) { +serial8250_clear_and_reinit_fifos (up); +serial_in (up,UART_LSR ); +serial_in (up,UART_OMAP_RESUME ); + }else { +if (status & (UART_LSR_FE |UART_LSR_PE |UART_LSR_BI )) +serial_in (up,UART_RX ); +if (iir &UART_IIR_XOFF ) +serial_in (up,UART_IIR ); + } +} +static void am654_8250_handle_rx_dma (struct uart_8250_port *up,u8 iir,u16 status) {
@@ -1266,7 +1282,8 @@ static void am654_8250_handle_rx_dma(struct uart_8250_port *up, u8 iir,* Queue a new transfer if FIFO has data. */ if ((status & (UART_LSR_DR |UART_LSR_BI )) && - (up->ier &UART_IER_RDI )) { + (up->ier &UART_IER_RDI ) && !(status &UART_LSR_OE )) { +am654_8250_handle_uart_errors (up, iir, status);omap_8250_rx_dma (up);serial_out (up,UART_OMAP_EFR2 ,UART_OMAP_EFR2_TIMEOUT_BEHAVE ); }else if ((iir &0x3f ) ==UART_IIR_RX_TIMEOUT ) {
@@ -1282,6 +1299,8 @@ static void am654_8250_handle_rx_dma(struct uart_8250_port *up, u8 iir,serial_out (up,UART_OMAP_EFR2 ,0x0 ); up->ier |=UART_IER_RLSI |UART_IER_RDI ;serial_out (up,UART_IER , up->ier); + }else { +am654_8250_handle_uart_errors (up, iir, status); } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 346/752 serial: 8250: 8250_omap.c: Clear DMA RX running status only after DMA termination is done
In reply to Sasha LevinFrom: Moteen Shah <[email protected]>
[ Upstream commit a5fd8945a478ff9be14812693891d7c9b4185a50 ]
Clear rx_running flag only after DMA teardown polling completes. In the previous implementation the flag was being cleared while hardware teardown was still in progress, creating a mismatch between software state (flag = 0, "ready") and hardware state (still terminating).
--- drivers/tty/serial/8250/8250_omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_omap.c +1 -1
@@ -931,7 +931,6 @@ static void __dma_rx_do_complete(struct uart_8250_port *p) goto out; cookie = dma->rx_cookie; - dma->rx_running =0 ;/* Re-enable RX FIFO interrupt now that transfer is complete */ if (priv->habit &UART_HAS_RHR_IT_DIS ) {
@@ -965,6 +964,7 @@ static void __dma_rx_do_complete(struct uart_8250_port *p) goto out; ret =tty_insert_flip_string (tty_port, dma->rx_buf, count); + dma->rx_running =0 ; p->port.icount.rx += ret; p->port.icount.buf_overrun += count - ret; out:
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 347/752 fix it87_wdt early reboot by reporting running timer
In reply to Sasha LevinFrom: René Rebe <[email protected]>
[ Upstream commit 88b2ab346436f799b99894a3e9518a3ffa344524 ]
Some products, such as the Ugreen DXP4800 Plus NAS, ship with the it87 wdt enabled by the firmware and a broken BIOS option that does not allow to change the time or turn it off. As this makes installing Linux rather difficult, change the it87_wdt to report it running to the watchdog core.
--- drivers/watchdog/it87_wdt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/watchdog/it87_wdt.c +12 -0
@@ -188,6 +188,12 @@ static void _wdt_update_timeout(unsigned int t)superio_outb (t >>8 ,WDTVALMSB ); } +/* Internal function, should be called after superio_select(GPIO) */ +static bool _wdt_running (void ) +{ +return superio_inb (WDTVALLSB ) || (max_units >255 &&superio_inb (WDTVALMSB )); +} +static int wdt_update_timeout (unsigned int t) {int ret;
@@ -374,6 +380,12 @@ static int __init it87_wdt_init(void) } } +/* wdt already left running by firmware? */ +if (_wdt_running ()) { +pr_info ("Left running by firmware.\n" ); +set_bit (WDOG_HW_RUNNING , &wdt_dev.status); + } +superio_exit ();if (timeout <1 || timeout > max_units *60 ) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 348/752 binder: don't use %pK through printk
In reply to Sasha LevinFrom: Thomas Weißschuh <[email protected]>
[ Upstream commit 56d21267663bad91e8b10121224ec46366a7937e ]
In the past %pK was preferable to %p as it would not leak raw pointer values into the kernel log. Since commit ad67b74d2469 ("printk: hash addresses printed with %p") the regular %p has been improved to avoid this issue. Furthermore, restricted pointers ("%pK") were never meant to be used through printk(). They can still unintentionally leak raw pointers or acquire sleeping locks in atomic contexts.
Switch to the regular pointer formatting which is safer and easier to reason about.
There are still a few users of %pK left, but these use it through seq_file, for which its usage is safe.
--- drivers/android/binder.c | 2 +- drivers/android/binder_alloc.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/android/binder.c +1 -1
@@ -4523,7 +4523,7 @@ static int binder_thread_write(struct binder_proc *proc, } }binder_debug (BINDER_DEBUG_DEAD_BINDER , -"%d:%d BC_DEAD_BINDER_DONE %016llx found %pK\n" , +"%d:%d BC_DEAD_BINDER_DONE %016llx found %p\n" , proc->pid, thread->pid, (u64 )cookie, death);if (death ==NULL ) {
drivers/android/binder_alloc.c +3 -3
@@ -81,7 +81,7 @@ static void binder_insert_free_buffer(struct binder_alloc *alloc, new_buffer_size =binder_alloc_buffer_size (alloc, new_buffer);binder_alloc_debug (BINDER_DEBUG_BUFFER_ALLOC , -"%d: add free buffer, size %zd, at %pK\n" , +"%d: add free buffer, size %zd, at %p\n" , alloc->pid, new_buffer_size, new_buffer);while (*p) {
@@ -572,7 +572,7 @@ static struct binder_buffer *binder_alloc_new_buf_locked( }binder_alloc_debug (BINDER_DEBUG_BUFFER_ALLOC , -"%d: binder_alloc_buf size %zd got buffer %pK size %zd\n" , +"%d: binder_alloc_buf size %zd got buffer %p size %zd\n" , alloc->pid, size, buffer, buffer_size);/*
@@ -748,7 +748,7 @@ static void binder_free_buf_locked(struct binder_alloc *alloc,ALIGN (buffer->extra_buffers_size,sizeof (void *));binder_alloc_debug (BINDER_DEBUG_BUFFER_ALLOC , -"%d: binder_free_buf %pK size %zd buffer_size %zd\n" , +"%d: binder_free_buf %p size %zd buffer_size %zd\n" , alloc->pid, buffer, size, buffer_size);BUG_ON (buffer->free);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 349/752 watchdog: imx7ulp_wdt: handle the nowayout option
In reply to Sasha LevinFrom: Oleksandr Suvorov <[email protected]>
[ Upstream commit d303d37ef5cf86c8c3b2daefd2a7d7fd8ca1ec14 ]
The module parameter nowayout indicates whether the watchdog should ever be allowed to stop, but the driver currently ignores this option.
Pass the nowayout parameter to the watchdog core by setting the WDOG_NO_WAY_OUT flag accordingly.
--- drivers/watchdog/imx7ulp_wdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/imx7ulp_wdt.c +1 -0
@@ -346,6 +346,7 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev)watchdog_stop_on_reboot (wdog);watchdog_stop_on_unregister (wdog);watchdog_set_drvdata (wdog, imx7ulp_wdt); +watchdog_set_nowayout (wdog, nowayout); imx7ulp_wdt->hw =of_device_get_match_data (dev); ret =imx7ulp_wdt_init (imx7ulp_wdt, wdog->timeout * imx7ulp_wdt->hw->wdog_clock_rate);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 350/752 watchdog: rzv2h_wdt: Discard pm_runtime_put() return value
In reply to Sasha LevinFrom: "Rafael J. Wysocki" <[email protected]>
[ Upstream commit 2dea984a74265a67e3210f818416a83b87f70200 ]
Failing device probe due to pm_runtime_put() returning an error is not particularly useful.
Returning an error code from pm_runtime_put() merely means that it has not queued up a work item to check whether or not the device can be suspended and there are many perfectly valid situations in which that can happen, like after writing "on" to the devices' runtime PM "control" attribute in sysfs for one example. It also happens when the kernel is configured with CONFIG_PM unset.
Accordingly, update rzt2h_wdt_wdtdcr_init() to simply discard the return value of pm_runtime_put() and return success to the caller after invoking that function.
This will facilitate a planned change of the pm_runtime_put() return type to void in the future.
--- drivers/watchdog/rzv2h_wdt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/watchdog/rzv2h_wdt.c +1 -3
@@ -270,9 +270,7 @@ static int rzt2h_wdt_wdtdcr_init(struct platform_device *pdev,rzt2h_wdt_wdtdcr_count_stop (priv); - ret =pm_runtime_put (&pdev->dev); -if (ret <0 ) -return ret; +pm_runtime_put (&pdev->dev);return 0 ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 351/752 phy: mvebu-cp110-utmi: fix dr_mode property read from dts
In reply to Sasha LevinFrom: Aleksandar Gerasimovski <[email protected]>
[ Upstream commit e2ce913452ab56b3330539cc443b97b7ea8c3a1a ]
The problem with the current implementation is that it does not consider that the USB controller can have multiple PHY handles with different arguments count, as for example we have in our cn9131 based platform:
"phys = <&cp0_comphy1 0>, <&cp0_utmi0>;".
In such case calling "of_usb_get_dr_mode_by_phy" with -1 (no phy-cells) leads to not proper phy detection, taking the "marvell,cp110-utmi-phy" dts definition we can call the "of_usb_get_dr_mode_by_phy" with 0 (#phy-cells = <0>) and safely look for that phy.
--- drivers/phy/marvell/phy-mvebu-cp110-utmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/marvell/phy-mvebu-cp110-utmi.c +1 -1
@@ -338,7 +338,7 @@ static int mvebu_cp110_utmi_phy_probe(struct platform_device *pdev)return -ENOMEM ; } - port->dr_mode =of_usb_get_dr_mode_by_phy (child,-1 ); + port->dr_mode =of_usb_get_dr_mode_by_phy (child,0 );if ((port->dr_mode !=USB_DR_MODE_HOST ) && (port->dr_mode !=USB_DR_MODE_PERIPHERAL )) { dev_err(&pdev->dev,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 352/752 phy: fsl-imx8mq-usb: disable bind/unbind platform driver feature
In reply to Sasha LevinFrom: Xu Yang <[email protected]>
[ Upstream commit 27ee0869d77b2cb404770ac49bdceae3aedf658b ]
Disabling PHYs in runtime usually causes the client with external abort exception or similar issue due to lack of API to notify clients about PHY removal. This patch removes the possibility to unbind i.MX PHY drivers in runtime.
--- drivers/phy/freescale/phy-fsl-imx8mq-usb.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/freescale/phy-fsl-imx8mq-usb.c +1 -0
@@ -711,6 +711,7 @@ static struct platform_driver imx8mq_usb_phy_driver = { .driver = { .name = "imx8mq-usb-phy", .of_match_table = imx8mq_usb_phy_of_match, + .suppress_bind_attrs = true, } };module_platform_driver (imx8mq_usb_phy_driver);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 353/752 Revert "mfd: da9052-spi: Change read-mask to write-mask"
In reply to Sasha LevinFrom: Marcus Folkesson <[email protected]>
[ Upstream commit 12daa9c1954542bf98bb942fb2dadf19de79a44b ]
This reverts commit 2e3378f6c79a1b3f7855ded1ef306ea4406352ed.
Almost every register in this chip can be customized via OTP memory. Somehow the value for R19, which decide if the flag is set on read or write operation, seems to have been overwritten for the chip the original patch were written for.
Revert the change to follow the default behavior.
--- drivers/mfd/da9052-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/da9052-spi.c +1 -1
@@ -37,7 +37,7 @@ static int da9052_spi_probe(struct spi_device *spi)spi_set_drvdata (spi, da9052); config = da9052_regmap_config; - config.write_flag_mask =1 ; + config.read_flag_mask =1 ; config.reg_bits =7 ; config.pad_bits =1 ; config.val_bits =8 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 354/752 mfd: intel-lpss: Add Intel Nova Lake-S PCI IDs
In reply to Sasha LevinFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit cefd793fa17de708d043adab50e7f96f414b0f1d ]
Add Intel Nova Lake-S LPSS PCI IDs.
--- drivers/mfd/intel-lpss-pci.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/mfd/intel-lpss-pci.c +13 -0
@@ -437,6 +437,19 @@ static const struct pci_device_id intel_lpss_pci_ids[] = { { PCI_VDEVICE(INTEL, 0x5ac4), (kernel_ulong_t)&bxt_spi_info }, { PCI_VDEVICE(INTEL, 0x5ac6), (kernel_ulong_t)&bxt_spi_info }, { PCI_VDEVICE(INTEL, 0x5aee), (kernel_ulong_t)&bxt_uart_info }, +/* NVL-S */ + { PCI_VDEVICE(INTEL, 0x6e28), (kernel_ulong_t)&bxt_uart_info }, + { PCI_VDEVICE(INTEL, 0x6e29), (kernel_ulong_t)&bxt_uart_info }, + { PCI_VDEVICE(INTEL, 0x6e2a), (kernel_ulong_t)&tgl_spi_info }, + { PCI_VDEVICE(INTEL, 0x6e2b), (kernel_ulong_t)&tgl_spi_info }, + { PCI_VDEVICE(INTEL, 0x6e4c), (kernel_ulong_t)&ehl_i2c_info }, + { PCI_VDEVICE(INTEL, 0x6e4d), (kernel_ulong_t)&ehl_i2c_info }, + { PCI_VDEVICE(INTEL, 0x6e4e), (kernel_ulong_t)&ehl_i2c_info }, + { PCI_VDEVICE(INTEL, 0x6e4f), (kernel_ulong_t)&ehl_i2c_info }, + { PCI_VDEVICE(INTEL, 0x6e5c), (kernel_ulong_t)&bxt_uart_info }, + { PCI_VDEVICE(INTEL, 0x6e5e), (kernel_ulong_t)&tgl_spi_info }, + { PCI_VDEVICE(INTEL, 0x6e7a), (kernel_ulong_t)&ehl_i2c_info }, + { PCI_VDEVICE(INTEL, 0x6e7b), (kernel_ulong_t)&ehl_i2c_info },/* ARL-H */ { PCI_VDEVICE(INTEL, 0x7725), (kernel_ulong_t)&bxt_uart_info }, { PCI_VDEVICE(INTEL, 0x7726), (kernel_ulong_t)&bxt_uart_info },
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 355/752 iio: Use IRQF_NO_THREAD
In reply to Sasha LevinFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 04d390af97f2c28166f7ddfe1a6bda622e3a4766 ]
The interrupt handler iio_trigger_generic_data_rdy_poll() will invoke other interrupt handler and this supposed to happen from within the hardirq.
Use IRQF_NO_THREAD to forbid forced-threading.
--- drivers/iio/accel/bma180.c | 5 +++-- drivers/iio/adc/ad7766.c | 2 +- drivers/iio/gyro/itg3200_buffer.c | 8 +++----- drivers/iio/light/si1145.c | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-)
drivers/iio/accel/bma180.c +3 -2
@@ -986,8 +986,9 @@ static int bma180_probe(struct i2c_client *client) } ret =devm_request_irq (dev, client->irq, - iio_trigger_generic_data_rdy_poll,IRQF_TRIGGER_RISING , -"bma180_event" , data->trig); + iio_trigger_generic_data_rdy_poll, +IRQF_TRIGGER_RISING |IRQF_NO_THREAD , +"bma180_event" , data->trig);if (ret) {dev_err (dev,"unable to request IRQ\n" ); goto err_trigger_free;
drivers/iio/adc/ad7766.c +1 -1
@@ -261,7 +261,7 @@ static int ad7766_probe(struct spi_device *spi)* don't enable the interrupt to avoid extra load on the system */ ret =devm_request_irq (&spi->dev, spi->irq, ad7766_irq, -IRQF_TRIGGER_FALLING |IRQF_NO_AUTOEN , +IRQF_TRIGGER_FALLING |IRQF_NO_AUTOEN |IRQF_NO_THREAD ,dev_name (&spi->dev), ad7766->trig);if (ret <0 )
drivers/iio/gyro/itg3200_buffer.c +3 -5
@@ -118,11 +118,9 @@ int itg3200_probe_trigger(struct iio_dev *indio_dev)if (!st->trig)return -ENOMEM ; - ret =request_irq (st->i2c->irq, - &iio_trigger_generic_data_rdy_poll, -IRQF_TRIGGER_RISING , -"itg3200_data_rdy" , - st->trig); + ret =request_irq (st->i2c->irq, &iio_trigger_generic_data_rdy_poll, +IRQF_TRIGGER_RISING |IRQF_NO_THREAD , +"itg3200_data_rdy" , st->trig);if (ret) goto error_free_trig;
drivers/iio/light/si1145.c +1 -1
@@ -1248,7 +1248,7 @@ static int si1145_probe_trigger(struct iio_dev *indio_dev) ret =devm_request_irq (&client->dev, client->irq, iio_trigger_generic_data_rdy_poll, -IRQF_TRIGGER_FALLING , +IRQF_TRIGGER_FALLING |IRQF_NO_THREAD ,"si1145_irq" , trig);if (ret <0 ) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 356/752 iio: magnetometer: Remove IRQF_ONESHOT
In reply to Sasha LevinFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit a54e9440925e6617c98669066b4753c4cdcea8a0 ]
Passing IRQF_ONESHOT ensures that the interrupt source is masked until the secondary (threaded) handler is done. If only a primary handler is used then the flag makes no sense because the interrupt can not fire (again) while its handler is running.
The flag also disallows force-threading of the primary handler and the irq-core will warn about this.
The force-threading functionality is required on PREEMPT_RT because the handler is using locks with can sleep on PREEMPT_RT.
Remove IRQF_ONESHOT from irqflags.
--- drivers/iio/magnetometer/ak8975.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/magnetometer/ak8975.c +1 -1
@@ -581,7 +581,7 @@ static int ak8975_setup_irq(struct ak8975_data *data) irq =gpiod_to_irq (data->eoc_gpiod); rc =devm_request_irq (&client->dev, irq, ak8975_irq_handler, -IRQF_TRIGGER_RISING |IRQF_ONESHOT , +IRQF_TRIGGER_RISING ,dev_name (&client->dev), data);if (rc <0 ) {dev_err (&client->dev,"irq %d request failed: %d\n" , irq, rc);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 357/752 MIPS: Loongson: Make cpumask_of_node() robust against NUMA_NO_NODE
In reply to Sasha LevinFrom: John Garry <[email protected]>
[ Upstream commit d55d3fe2d1470ac5b6e93efe7998b728013c9fc8 ]
The arch definition of cpumask_of_node() cannot handle NUMA_NO_NODE - which is a valid index - so add a check for this.
--- arch/mips/include/asm/mach-loongson64/topology.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/mach-loongson64/topology.h +1 -1
@@ -7,7 +7,7 @@#define cpu_to_node (cpu) (cpu_logical_map(cpu) >> 2)extern cpumask_t __node_cpumask[]; -#define cpumask_of_node (node) (&__node_cpumask[node]) +#define cpumask_of_node (node) ((node) == NUMA_NO_NODE ? cpu_all_mask : &__node_cpumask[node])struct pci_bus ;extern int pcibus_to_node (struct pci_bus *);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 358/752 fs: ntfs3: check return value of indx_find to avoid infinite loop
In reply to Sasha LevinFrom: Jaehun Gou <[email protected]>
[ Upstream commit 1732053c8a6b360e2d5afb1b34fe9779398b072c ]
We found an infinite loop bug in the ntfs3 file system that can lead to a Denial-of-Service (DoS) condition.
A malformed dentry in the ntfs3 filesystem can cause the kernel to hang during the lookup operations. By setting the HAS_SUB_NODE flag in an INDEX_ENTRY within a directory's INDEX_ALLOCATION block and manipulating the VCN pointer, an attacker can cause the indx_find() function to repeatedly read the same block, allocating 4 KB of memory each time. The kernel lacks VCN loop detection and depth limits, causing memory exhaustion and an OOM crash.
This patch adds a return value check for fnd_push() to prevent a memory exhaustion vulnerability caused by infinite loops. When the index exceeds the size of the fnd->nodes array, fnd_push() returns -EINVAL. The indx_find() function checks this return value and stops processing, preventing further memory allocation.
--- fs/ntfs3/index.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/ntfs3/index.c +6 -1
@@ -1190,7 +1190,12 @@ int indx_find(struct ntfs_index *indx, struct ntfs_inode *ni,return -EINVAL ; } -fnd_push (fnd, node, e); + err =fnd_push (fnd, node, e); + +if (err) { +put_indx_node (node); +return err; + } } *entry = e;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 359/752 fs: ntfs3: fix infinite loop in attr_load_runs_range on inconsistent metadata
In reply to Sasha LevinFrom: Jaehun Gou <[email protected]>
[ Upstream commit 4b90f16e4bb5607fb35e7802eb67874038da4640 ]
We found an infinite loop bug in the ntfs3 file system that can lead to a Denial-of-Service (DoS) condition.
A malformed NTFS image can cause an infinite loop when an attribute header indicates an empty run list, while directory entries reference it as containing actual data. In NTFS, setting evcn=-1 with svcn=0 is a valid way to represent an empty run list, and run_unpack() correctly handles this by checking if evcn + 1 equals svcn and returning early without parsing any run data. However, this creates a problem when there is metadata inconsistency, where the attribute header claims to be empty (evcn=-1) but the caller expects to read actual data. When run_unpack() immediately returns success upon seeing this condition, it leaves the runs_tree uninitialized with run->runs as a NULL. The calling function attr_load_runs_range() assumes that a successful return means that the runs were loaded and sets clen to 0, expecting the next run_lookup_entry() call to succeed. Because runs_tree remains uninitialized, run_lookup_entry() continues to fail, and the loop increments vcn by zero (vcn += 0), leading to an infinite loop.
This patch adds a retry counter to detect when run_lookup_entry() fails consecutively after attr_load_runs_vcn(). If the run is still not found on the second attempt, it indicates corrupted metadata and returns -EINVAL, preventing the Denial-of-Service (DoS) vulnerability.
--- fs/ntfs3/attrib.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
fs/ntfs3/attrib.c +12 -3
@@ -1354,19 +1354,28 @@ int attr_load_runs_range(struct ntfs_inode *ni, enum ATTR_TYPE type,CLST vcn;CLST vcn_last = (to -1 ) >> cluster_bits;CLST lcn, clen; -int err; +int err =0 ; +int retry =0 ;for (vcn = from >> cluster_bits; vcn <= vcn_last; vcn += clen) {if (!run_lookup_entry (run, vcn, &lcn, &clen,NULL )) { +if (retry !=0 ) {/* Next run_lookup_entry(vcn) also failed. */ + err = -EINVAL ; +break ; + } err =attr_load_runs_vcn (ni, type, name, name_len, run, vcn);if (err) -return err; +break ; + clen =0 ;/* Next run_lookup_entry(vcn) must be success. */ + retry++; } +else + retry =0 ; } -return 0 ; +return err; }#ifdef CONFIG_NTFS3_LZX_XPRESS
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 360/752 fs: ntfs3: fix infinite loop triggered by zero-sized ATTR_LIST
In reply to Sasha LevinFrom: Jaehun Gou <[email protected]>
[ Upstream commit 06909b2549d631a47fcda249d34be26f7ca1711d ]
We found an infinite loop bug in the ntfs3 file system that can lead to a Denial-of-Service (DoS) condition.
A malformed NTFS image can cause an infinite loop when an ATTR_LIST attribute indicates a zero data size while the driver allocates memory for it.
When ntfs_load_attr_list() processes a resident ATTR_LIST with data_size set to zero, it still allocates memory because of al_aligned(0). This creates an inconsistent state where ni->attr_list.size is zero, but ni->attr_list.le is non-null. This causes ni_enum_attr_ex to incorrectly assume that no attribute list exists and enumerates only the primary MFT record. When it finds ATTR_LIST, the code reloads it and restarts the enumeration, repeating indefinitely. The mount operation never completes, hanging the kernel thread.
This patch adds validation to ensure that data_size is non-zero before memory allocation. When a zero-sized ATTR_LIST is detected, the function returns -EINVAL, preventing a DoS vulnerability.
--- fs/ntfs3/attrlist.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/ntfs3/attrlist.c +9 -0
@@ -52,6 +52,11 @@ int ntfs_load_attr_list(struct ntfs_inode *ni, struct ATTRIB *attr)if (!attr->non_res) { lsize =le32_to_cpu (attr->res.data_size); +if (!lsize) { + err = -EINVAL ; + goto out; + } +/* attr is resident: lsize < record_size (1K or 4K) */ le =kvmalloc (al_aligned (lsize),GFP_KERNEL );if (!le) {
@@ -66,6 +71,10 @@ int ntfs_load_attr_list(struct ntfs_inode *ni, struct ATTRIB *attr)u16 run_off =le16_to_cpu (attr->nres.run_off); lsize =le64_to_cpu (attr->nres.data_size); +if (!lsize) { + err = -EINVAL ; + goto out; + }run_init (&ni->attr_list.run);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 361/752 fs/ntfs3: drop preallocated clusters for sparse and compressed files
In reply to Sasha LevinFrom: Konstantin Komarov <[email protected]>
[ Upstream commit 3a6aba7f3cf2b46816e08548c254d98de9c74eba ]
Do not keep preallocated clusters for sparsed and compressed files. Preserving preallocation in these cases causes fsx failures when running with sparse files and preallocation enabled.
--- fs/ntfs3/attrib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ntfs3/attrib.c +3 -1
@@ -448,8 +448,10 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type, is_ext =is_attr_ext (attr_b); align = sbi->cluster_size; -if (is_ext) +if (is_ext) { align <<= attr_b->nres.c_unit; + keep_prealloc = false; + } old_valid =le64_to_cpu (attr_b->nres.valid_size); old_size =le64_to_cpu (attr_b->nres.data_size);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 362/752 ntfs3: fix circular locking dependency in run_unpack_ex
In reply to Sasha LevinFrom: Szymon Wilczek <[email protected]>
[ Upstream commit 08ce2fee1b869ecbfbd94e0eb2630e52203a2e03 ]
Syzbot reported a circular locking dependency between wnd->rw_lock (sbi->used.bitmap) and ni->file.run_lock.
The deadlock scenario:
1. ntfs_extend_mft() takes ni->file.run_lock then wnd->rw_lock.
2. run_unpack_ex() takes wnd->rw_lock then tries to acquire ni->file.run_lock inside ntfs_refresh_zone().
This creates an AB-BA deadlock.
Fix this by using down_read_trylock() instead of down_read() when acquiring run_lock in run_unpack_ex(). If the lock is contended, skip ntfs_refresh_zone() - the MFT zone will be refreshed on the next MFT operation. This breaks the circular dependency since we never block waiting for run_lock while holding wnd->rw_lock.
--- fs/ntfs3/run.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
fs/ntfs3/run.c +8 -5
@@ -1124,11 +1124,14 @@ int run_unpack_ex(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,struct rw_semaphore *lock =is_mounted (sbi) ? &sbi->mft.ni->file.run_lock :NULL ; -if (lock) -down_read (lock); -ntfs_refresh_zone (sbi); -if (lock) -up_read (lock); +if (lock) { +if (down_read_trylock (lock)) { +ntfs_refresh_zone (sbi); +up_read (lock); + } + }else { +ntfs_refresh_zone (sbi); + } }up_write (&wnd->rw_lock);if (err)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 363/752 fs/ntfs3: avoid calling run_get_entry() when run == NULL in ntfs_read_run_nb_ra()
In reply to Sasha LevinFrom: Konstantin Komarov <[email protected]>
[ Upstream commit c5226b96c08a010ebef5fdf4c90572bcd89e4299 ]
When ntfs_read_run_nb_ra() is invoked with run == NULL the code later assumes run is valid and may call run_get_entry(NULL, ...), and also uses clen/idx without initializing them. Smatch reported uninitialized variable warnings and this can lead to undefined behaviour. This patch fixes it.
--- fs/ntfs3/fsntfs.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/ntfs3/fsntfs.c +6 -0
@@ -1252,6 +1252,12 @@ int ntfs_read_run_nb(struct ntfs_sb_info *sbi, const struct runs_tree *run, }while (len32); +if (!run) { + err = -EINVAL ; + goto out; + } + +/* Get next fragment to read. */ vcn_next = vcn + clen;if (!run_get_entry (run, ++idx, &vcn, &lcn, &clen) || vcn != vcn_next) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 364/752 ceph: supply snapshot context in ceph_uninline_data()
In reply to Sasha LevinFrom: ethanwu <[email protected]>
[ Upstream commit 305ff6b3a03c230d3c07b61457e961406d979693 ]
The ceph_uninline_data function was missing proper snapshot context handling for its OSD write operations. Both CEPH_OSD_OP_CREATE and CEPH_OSD_OP_WRITE requests were passing NULL instead of the appropriate snapshot context, which could lead to unnecessary object clone.
Reproducer:../src/vstart.sh --new -x --localhost --bluestore
// turn on cephfs inline data
./bin/ceph fs set a inline_data true --yes-i-really-really-mean-it
// allow fs_a client to take snapshot
./bin/ceph auth caps client.fs_a mds 'allow rwps fsname=a' mon 'allow r fsname=a' osd 'allow rw tag cephfs data=a' // mount cephfs with fuse, since kernel cephfs doesn't support inline write
ceph-fuse --id fs_a -m 127.0.0.1:40318 --conf ceph.conf -d /mnt/mycephfs/
// bump snapshot seq
mkdir /mnt/mycephfs/.snap/snap1
echo "foo" > /mnt/mycephfs/test
// umount and mount it again using kernel cephfs client
umount /mnt/mycephfs
mount -t ceph [email protected]=/ /mnt/mycephfs/ -o conf=./ceph.conf
echo "bar" >> /mnt/mycephfs/test
./bin/rados listsnaps -p cephfs.a.data $(printf "%x\n" $(stat -c %i /mnt/mycephfs/test)).00000000
will see this object does unnecessary clone
1000000000a.00000000 (seq:2):
cloneid snaps size overlap 2 2 4 [] head - 8
but it's expected to see
10000000000.00000000 (seq:2):
cloneid snaps size overlap
head - 8
since there's no snapshot between these 2 writes
clone happened because the first osd request CEPH_OSD_OP_CREATE doesn't pass snap context so object is created with snap seq 0, but later data writeback is equipped with snapshot context.snap.seq(1) > object snap seq(0), so osd does object clone.
This fix properly acquiring the snapshot context before performing write operations.
--- fs/ceph/addr.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
fs/ceph/addr.c +22 -2
@@ -2203,6 +2203,7 @@ int ceph_uninline_data(struct file *file)struct ceph_osd_request *req =NULL ;struct ceph_cap_flush *prealloc_cf =NULL ;struct folio *folio =NULL ; +struct ceph_snap_context *snapc =NULL ;u64 inline_version =CEPH_INLINE_NONE ;struct page *pages[1 ];int err =0 ;
@@ -2230,6 +2231,24 @@ int ceph_uninline_data(struct file *file)if (inline_version ==1 )/* initial version, no data */ goto out_uninline; +down_read (&fsc->mdsc->snap_rwsem); +spin_lock (&ci->i_ceph_lock); +if (__ceph_have_pending_cap_snap (ci)) { +struct ceph_cap_snap *capsnap = +list_last_entry (&ci->i_cap_snaps, + struct ceph_cap_snap, + ci_item); + snapc =ceph_get_snap_context (capsnap->context); + }else { +if (!ci->i_head_snapc) { + ci->i_head_snapc =ceph_get_snap_context ( + ci->i_snap_realm->cached_context); + } + snapc =ceph_get_snap_context (ci->i_head_snapc); + } +spin_unlock (&ci->i_ceph_lock); +up_read (&fsc->mdsc->snap_rwsem); + folio =read_mapping_folio (inode->i_mapping,0 , file);if (IS_ERR (folio)) { err =PTR_ERR (folio);
@@ -2245,7 +2264,7 @@ int ceph_uninline_data(struct file *file) req =ceph_osdc_new_request (&fsc->client->osdc, &ci->i_layout,ceph_vino (inode),0 , &len,0 ,1 ,CEPH_OSD_OP_CREATE ,CEPH_OSD_FLAG_WRITE , -NULL ,0 ,0 , false); + snapc,0 ,0 , false);if (IS_ERR (req)) { err =PTR_ERR (req); goto out_unlock;
@@ -2261,7 +2280,7 @@ int ceph_uninline_data(struct file *file) req =ceph_osdc_new_request (&fsc->client->osdc, &ci->i_layout,ceph_vino (inode),0 , &len,1 ,3 ,CEPH_OSD_OP_WRITE ,CEPH_OSD_FLAG_WRITE , -NULL , ci->i_truncate_seq, + snapc, ci->i_truncate_seq, ci->i_truncate_size, false);if (IS_ERR (req)) { err =PTR_ERR (req);
@@ -2324,6 +2343,7 @@ int ceph_uninline_data(struct file *file)folio_put (folio); } out: +ceph_put_snap_context (snapc);ceph_free_cap_flush (prealloc_cf);doutc (cl,"%llx.%llx inline_version %llu = %d\n" ,ceph_vinop (inode), inline_version, err);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 365/752 libceph: define and enforce CEPH_MAX_KEY_LEN
In reply to Sasha LevinFrom: Ilya Dryomov <[email protected]>
[ Upstream commit ac431d597a9bdfc2ba6b314813f29a6ef2b4a3bf ]
When decoding the key, verify that the key material would fit into a fixed-size buffer in process_auth_done() and generally has a sane length.
The new CEPH_MAX_KEY_LEN check replaces the existing check for a key with no key material which is a) not universal since CEPH_CRYPTO_NONE has to be excluded and b) doesn't provide much value since a smaller than needed key is just as invalid as no key -- this has to be handled elsewhere anyway.
--- net/ceph/crypto.c | 8 +++++--- net/ceph/crypto.h | 2 +- net/ceph/messenger_v2.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-)
net/ceph/crypto.c +5 -3
@@ -37,9 +37,6 @@ static int set_secret(struct ceph_crypto_key *key, void *buf)return -ENOTSUPP ; } -if (!key->len) -return -EINVAL ; - key->key =kmemdup (buf, key->len,GFP_NOIO );if (!key->key) { ret = -ENOMEM ;
@@ -83,6 +80,11 @@ int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end)ceph_decode_copy (p, &key->created,sizeof (key->created)); key->len =ceph_decode_16 (p);ceph_decode_need (p, end, key->len, bad); +if (key->len >CEPH_MAX_KEY_LEN ) { +pr_err ("secret too big %d\n" , key->len); +return -EINVAL ; + } + ret =set_secret (key, *p);memzero_explicit (*p, key->len); *p += key->len;
net/ceph/crypto.h +1 -1
@@ -5,7 +5,7 @@#include <linux/ceph/types.h> #include <linux/ceph/buffer.h> -#define CEPH_KEY_LEN 16 +#define CEPH_MAX_KEY_LEN 16#define CEPH_MAX_CON_SECRET_LEN 64/*
net/ceph/messenger_v2.c +1 -1
@@ -2361,7 +2361,7 @@ static int process_auth_reply_more(struct ceph_connection *con,*/ static int process_auth_done (struct ceph_connection *con,void *p,void *end) { -u8 session_key_buf[CEPH_KEY_LEN +16 ]; +u8 session_key_buf[CEPH_MAX_KEY_LEN +16 ];u8 con_secret_buf[CEPH_MAX_CON_SECRET_LEN +16 ];u8 *session_key =PTR_ALIGN (&session_key_buf[0 ],16 );u8 *con_secret =PTR_ALIGN (&con_secret_buf[0 ],16 );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 366/752 thermal: int340x: Fix sysfs group leak on DLVR registration failure
In reply to Sasha LevinFrom: Kaushlendra Kumar <[email protected]>
[ Upstream commit 15176b818e048ccf6ef4b96db34eda7b7e98938a ]
When DLVR sysfs group creation fails in proc_thermal_rfim_add(), the function returns immediately without cleaning up the FIVR group that may have been created earlier.
Add proper error unwinding to remove the FIVR group before returning failure.
--- .../thermal/intel/int340x_thermal/processor_thermal_rfim.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c +4 -1
@@ -451,8 +451,11 @@ int proc_thermal_rfim_add(struct pci_dev *pdev, struct proc_thermal_device *procbreak ; } ret =sysfs_create_group (&pdev->dev.kobj, &dlvr_attribute_group); -if (ret) +if (ret) { +if (proc_priv->mmio_feature_mask &PROC_THERMAL_FEATURE_FIVR ) +sysfs_remove_group (&pdev->dev.kobj, &fivr_attribute_group);return ret; + } }if (proc_priv->mmio_feature_mask &PROC_THERMAL_FEATURE_DVFS ) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 367/752 ACPI: x86: Force enabling of PWM2 on the Yogabook YB1-X90
In reply to Sasha LevinFrom: Yauhen Kharuzhy <[email protected]>
[ Upstream commit a8c975302868c716afef0f50467bebbd069a35b8 ]
The PWM2 on YB1-X90 tablets is used for keyboard backlight control but it is disabled in the ACPI DSDT table. Add it to the override_status_ids list to allow keyboard function control driver (drivers/platform/x86/lenovo/yogabook.c) to use it.
--- drivers/acpi/x86/utils.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/acpi/x86/utils.c +12 -0
@@ -81,6 +81,18 @@ static const struct override_status_id override_status_ids[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Mipad2"), }), +/* +* Lenovo Yoga Book uses PWM2 for touch keyboard backlight control. +* It needs to be enabled only for the Android device version (YB1-X90* +* aka YETI-11); the Windows version (YB1-X91*) uses ACPI control +* methods. +*/ + PRESENT_ENTRY_HID("80862289", "2", INTEL_ATOM_AIRMONT, { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"), + DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "YETI-11"), + }), + /* * The INT0002 device is necessary to clear wakeup interrupt sources * on Cherry Trail devices, without it we get nobody cared IRQ msgs.
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 368/752 include: uapi: netfilter_bridge.h: Cover for musl libc
In reply to Sasha LevinFrom: Phil Sutter <[email protected]>
[ Upstream commit 4edd4ba71ce0df015303dba75ea9d20d1a217546 ]
Musl defines its own struct ethhdr and thus defines __UAPI_DEF_ETHHDR to zero. To avoid struct redefinition errors, user space is therefore supposed to include netinet/if_ether.h before (or instead of) linux/if_ether.h. To relieve them from this burden, include the libc header here if not building for kernel space.
--- include/uapi/linux/netfilter_bridge.h | 4 ++++ 1 file changed, 4 insertions(+)
include/uapi/linux/netfilter_bridge.h +4 -0
@@ -5,6 +5,10 @@/* bridge-specific defines for netfilter. */ +#ifndef __KERNEL__ +#include <netinet/if_ether.h> /* for __UAPI_DEF_ETHHDR if defined */ +#endif +#include <linux/in.h> #include <linux/netfilter.h> #include <linux/if_ether.h>
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 369/752 ARM: 9467/1: mm: Don't use %pK through printk
In reply to Sasha LevinFrom: Thomas Weissschuh <[email protected]>
[ Upstream commit 012ea376a5948b025f260aa45d2a6ec5d96674ea ]
Restricted pointers ("%pK") were never meant to be used through printk(). They can acquire sleeping locks in atomic contexts.
Switch to %px over the more secure %p as this usage is a debugging aid, gated behind CONFIG_DEBUG_VIRTUAL and used by WARN().
--- arch/arm/mm/physaddr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mm/physaddr.c +1 -1
@@ -38,7 +38,7 @@ static inline bool __virt_addr_valid(unsigned long x)phys_addr_t __virt_to_phys (unsigned long x) {WARN (!__virt_addr_valid (x), -"virt_to_phys used for non-linear address: %pK (%pS)\n" , +"virt_to_phys used for non-linear address: %px (%pS)\n" , (void *)x, (void *)x);return __virt_to_phys_nodebug (x);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 370/752 drm/amd/display: Fix writeback on DCN 3.2+
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 9ef84a307582a92ef055ef0bd3db10fd8ac75960 ]
[WHAT]
1. Set no scaling for writeback as they are hardcoded in DCN3.2+.
2. Set no fast plane update for writeback commits.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +15 -4
@@ -10411,10 +10411,10 @@ static void dm_set_writeback(struct amdgpu_display_manager *dm, wb_info->dwb_params.capture_rate = dwb_capture_rate_0; - wb_info->dwb_params.scaler_taps.h_taps =4 ; - wb_info->dwb_params.scaler_taps.v_taps =4 ; - wb_info->dwb_params.scaler_taps.h_taps_c =2 ; - wb_info->dwb_params.scaler_taps.v_taps_c =2 ; + wb_info->dwb_params.scaler_taps.h_taps =1 ; + wb_info->dwb_params.scaler_taps.v_taps =1 ; + wb_info->dwb_params.scaler_taps.h_taps_c =1 ; + wb_info->dwb_params.scaler_taps.v_taps_c =1 ; wb_info->dwb_params.subsample_position =DWB_INTERSTITIAL_SUBSAMPLING ; wb_info->mcif_buf_params.luma_pitch = afb->base.pitches[0 ];
@@ -11430,6 +11430,8 @@ static bool should_reset_plane(struct drm_atomic_state *state,struct drm_crtc_state *old_crtc_state, *new_crtc_state;struct dm_crtc_state *old_dm_crtc_state, *new_dm_crtc_state;struct amdgpu_device *adev =drm_to_adev (plane->dev); +struct drm_connector_state *new_con_state; +struct drm_connector *connector;int i;/*
@@ -11440,6 +11442,15 @@ static bool should_reset_plane(struct drm_atomic_state *state, state->allow_modeset)return true; +/* Check for writeback commit */ +for_each_new_connector_in_state (state, connector, new_con_state, i) { +if (connector->connector_type !=DRM_MODE_CONNECTOR_WRITEBACK ) +continue ; + +if (new_con_state->writeback_job) +return true; + } +if (amdgpu_in_reset (adev) && state->allow_modeset)return true;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 371/752 drm/amdgpu: Skip vcn poison irq release on VF
In reply to Sasha LevinFrom: Lijo Lazar <[email protected]>
[ Upstream commit 8980be03b3f9a4b58197ef95d3b37efa41a25331 ]
VF doesn't enable VCN poison irq in VCNv2.5. Skip releasing it and avoid call trace during deinitialization.
[ 71.913601] [drm] clean up the vf2pf work item [ 71.915088] ------------[ cut here ]------------ [ 71.915092] WARNING: CPU: 3 PID: 1079 at /tmp/amd.aFkFvSQl/amd/amdgpu/amdgpu_irq.c:641 amdgpu_irq_put+0xc6/0xe0 [amdgpu] [ 71.915355] Modules linked in: amdgpu(OE-) amddrm_ttm_helper(OE) amdttm(OE) amddrm_buddy(OE) amdxcp(OE) amddrm_exec(OE) amd_sched(OE) amdkcl(OE) drm_suballoc_helper drm_display_helper cec rc_core i2c_algo_bit video wmi binfmt_misc nls_iso8859_1 intel_rapl_msr intel_rapl_common input_leds joydev serio_raw mac_hid qemu_fw_cfg sch_fq_codel dm_multipath scsi_dh_rdac scsi_dh_emc scsi_dh_alua efi_pstore ip_tables x_tables autofs4 btrfs blake2b_generic raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1 raid0 hid_generic crct10dif_pclmul crc32_pclmul polyval_clmulni polyval_generic ghash_clmulni_intel usbhid 8139too sha256_ssse3 sha1_ssse3 hid psmouse bochs i2c_i801 ahci drm_vram_helper libahci i2c_smbus lpc_ich drm_ttm_helper 8139cp mii ttm aesni_intel crypto_simd cryptd [ 71.915484] CPU: 3 PID: 1079 Comm: rmmod Tainted: G OE 6.8.0-87-generic #88~22.04.1-Ubuntu [ 71.915489] Hardware name: Red Hat KVM/RHEL, BIOS 1.16.3-2.el9_5.1 04/01/2014 [ 71.915492] RIP: 0010:amdgpu_irq_put+0xc6/0xe0 [amdgpu] [ 71.915768] Code: 75 84 b8 ea ff ff ff eb d4 44 89 ea 48 89 de 4c 89 e7 e8 fd fc ff ff 5b 41 5c 41 5d 41 5e 5d 31 d2 31 f6 31 ff e9 55 30 3b c7 <0f> 0b eb d4 b8 fe ff ff ff eb a8 e9 b7 3b 8a 00 66 2e 0f 1f 84 00 [ 71.915771] RSP: 0018:ffffcf0800eafa30 EFLAGS: 00010246 [ 71.915775] RAX: 0000000000000000 RBX: ffff891bda4b0668 RCX: 0000000000000000 [ 71.915777] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 [ 71.915779] RBP: ffffcf0800eafa50 R08: 0000000000000000 R09: 0000000000000000 [ 71.915781] R10: 0000000000000000 R11: 0000000000000000 R12: ffff891bda480000 [ 71.915782] R13: 0000000000000000 R14: 0000000000000001 R15: 0000000000000000 [ 71.915792] FS: 000070cff87c4c40(0000) GS:ffff893abfb80000(0000) knlGS:0000000000000000 [ 71.915795] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 71.915797] CR2: 00005fa13073e478 CR3: 000000010d634006 CR4: 0000000000770ef0 [ 71.915800] PKRU: 55555554 [ 71.915802] Call Trace: [ 71.915805] <TASK> [ 71.915809] vcn_v2_5_hw_fini+0x19e/0x1e0 [amdgpu]
--- drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c +3 -1
@@ -521,7 +521,9 @@ static int vcn_v2_5_hw_fini(struct amdgpu_ip_block *ip_block) RREG32_SOC15(VCN, i, mmUVD_STATUS))) vinst->set_pg_state (vinst,AMD_PG_STATE_GATE ); -if (amdgpu_ras_is_supported (adev,AMDGPU_RAS_BLOCK__VCN )) +/* VF doesn't enable interrupt operations for RAS */ +if (!amdgpu_sriov_vf (adev) && +amdgpu_ras_is_supported (adev,AMDGPU_RAS_BLOCK__VCN ))amdgpu_irq_put (adev, &vinst->ras_poison_irq,0 ); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 372/752 mshv: clear eventfd counter on irqfd shutdown
In reply to Sasha LevinFrom: Carlos López <[email protected]>
[ Upstream commit 2b4246153e2184e3a3b4edc8cc35337d7a2455a6 ]
While unhooking from the irqfd waitqueue, clear the internal eventfd counter by using eventfd_ctx_remove_wait_queue() instead of remove_wait_queue(), preventing potential spurious interrupts. This removes the need to store a pointer into the workqueue, as the eventfd already keeps track of it.
This mimicks what other similar subsystems do on their equivalent paths with their irqfds (KVM, Xen, ACRN support, etc).
--- drivers/hv/mshv_eventfd.c | 5 ++--- drivers/hv/mshv_eventfd.h | 1 - 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/hv/mshv_eventfd.c +2 -3
@@ -244,12 +244,13 @@ static void mshv_irqfd_shutdown(struct work_struct *work) {struct mshv_irqfd *irqfd = container_of(work, struct mshv_irqfd, irqfd_shutdown); +u64 cnt;/* * Synchronize with the wait-queue and unhook ourselves to prevent * further events. */ -remove_wait_queue (irqfd->irqfd_wqh, &irqfd->irqfd_wait); +eventfd_ctx_remove_wait_queue (irqfd->irqfd_eventfd_ctx, &irqfd->irqfd_wait, &cnt);if (irqfd->irqfd_resampler) {mshv_irqfd_resampler_shutdown (irqfd);
@@ -368,8 +369,6 @@ static void mshv_irqfd_queue_proc(struct file *file, wait_queue_head_t *wqh,struct mshv_irqfd *irqfd = container_of(polltbl, struct mshv_irqfd, irqfd_polltbl); - irqfd->irqfd_wqh = wqh; -/* * TODO: Ensure there isn't already an exclusive, priority waiter, e.g. * that the irqfd isn't already bound to another partition. Only the
drivers/hv/mshv_eventfd.h +0 -1
@@ -32,7 +32,6 @@ struct mshv_irqfd {struct mshv_lapic_irq irqfd_lapic_irq;struct hlist_node irqfd_hnode;poll_table irqfd_polltbl; -wait_queue_head_t *irqfd_wqh;wait_queue_entry_t irqfd_wait;struct work_struct irqfd_shutdown;struct mshv_irqfd_resampler *irqfd_resampler;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 373/752 ASoC: rt721-sdca: Fix issue of fail to detect OMTP jack type
In reply to Sasha LevinFrom: Jack Yu <[email protected]>
[ Upstream commit 5578da7d957fbaf91f6c39ba2363c2d2e4273183 ]
Add related HP-JD settings to fix issue of fail to detect OMTP jack type.
--- sound/soc/codecs/rt721-sdca.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/rt721-sdca.c +2 -2
@@ -245,12 +245,12 @@ static void rt721_sdca_jack_preset(struct rt721_sdca_priv *rt721)regmap_write (rt721->mbq_regmap,0x5b10007 ,0x2000 );regmap_write (rt721->mbq_regmap,0x5B10017 ,0x1b0f );rt_sdca_index_write (rt721->mbq_regmap,RT721_CBJ_CTRL , -RT721_CBJ_A0_GAT_CTRL1 ,0x2a02 ); +RT721_CBJ_A0_GAT_CTRL1 ,0x2205 );rt_sdca_index_write (rt721->mbq_regmap,RT721_CAP_PORT_CTRL ,RT721_HP_AMP_2CH_CAL4 ,0xa105 );rt_sdca_index_write (rt721->mbq_regmap,RT721_VENDOR_ANA_CTL ,RT721_UAJ_TOP_TCON14 ,0x3b33 ); -regmap_write (rt721->mbq_regmap,0x310400 ,0x3023 ); +regmap_write (rt721->mbq_regmap,0x310400 ,0x3043 );rt_sdca_index_write (rt721->mbq_regmap,RT721_VENDOR_ANA_CTL ,RT721_UAJ_TOP_TCON14 ,0x3f33 ); rt_sdca_index_write(rt721->mbq_regmap, RT721_VENDOR_ANA_CTL,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 374/752 regulator: core: Remove regulator supply_name length limit
In reply to Sasha LevinFrom: Bjorn Andersson <[email protected]>
[ Upstream commit e243cdd87b911ce9968b62e4ab2b680dfadc4341 ]
When creating the regulator object, associated with a consumer device, the supply_name is string formatted into a statically sized buffer on the stack, then strdup()'ed onto the heap.
Not only is the dance on the stack unnecessary, but when the device's name is long we might not fit the constructed supply_name in the fixed 64 byte buffer on the stack.
One such case can be seen on the Qualcomm Rb3Gen2 board, where we find a PCIe controller, with a PCIe switch, with a USB controller, with a USB hub, consuming a regulator. In this example the dev->kobj.name itself is 62 characters long.
Drop the temporary buffer on the stack and kasprintf() the string directly on the heap, both to simplify the code, and to remove the length limitation.
--- drivers/regulator/core.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/regulator/core.c +1 -11
@@ -1838,8 +1838,6 @@ static const struct file_operations constraint_flags_fops = {#endif }; -#define REG_STR_SIZE 64 -static void link_and_create_debugfs (struct regulator *regulator,struct regulator_dev *rdev,struct device *dev) {
@@ -1887,15 +1885,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,lockdep_assert_held_once (&rdev->mutex.base);if (dev) { -char buf[REG_STR_SIZE ]; -int size; - - size =snprintf (buf,REG_STR_SIZE ,"%s-%s" , - dev->kobj.name, supply_name); -if (size >=REG_STR_SIZE ) -return NULL ; - - supply_name =kstrdup (buf,GFP_KERNEL ); + supply_name =kasprintf (GFP_KERNEL ,"%s-%s" , dev->kobj.name, supply_name);if (supply_name ==NULL )return NULL ; }else {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 375/752 ALSA: hda/tas2781: Ignore reset check for SPI device
In reply to Sasha LevinFrom: Baojun Xu <[email protected]>
[ Upstream commit 908ef80e31e4d3bd953a0088fe57640cd9ae7b3e ]
In the SPI driver probe, the device should be in the default state, so the device status check is not necessary. It should be forced to do the firmware download as I2C device.
--- .../hda/codecs/side-codecs/tas2781_hda_spi.c | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-)
sound/hda/codecs/side-codecs/tas2781_hda_spi.c +7 -13
@@ -634,7 +634,7 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context)struct tasdevice_priv *tas_priv = context;struct tas2781_hda *tas_hda =dev_get_drvdata (tas_priv->dev);struct hda_codec *codec = tas_priv->codec; -int ret, val; +int ret;pm_runtime_get_sync (tas_priv->dev);guard (mutex)(&tas_priv->codec_lock);
@@ -673,20 +673,14 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context) tas_priv->rcabin.profile_cfg_id =0 ; tas_priv->fw_state =TASDEVICE_DSP_FW_ALL_OK ; - ret =tasdevice_spi_dev_read (tas_priv, tas_priv->index, -TAS2781_REG_CLK_CONFIG , &val); -if (ret <0 ) - goto out; -if (val ==TAS2781_REG_CLK_CONFIG_RESET ) { - ret =tasdevice_prmg_load (tas_priv,0 ); -if (ret <0 ) { -dev_err (tas_priv->dev,"FW download failed = %d\n" , - ret); - goto out; - } - tas_priv->fw_state =TASDEVICE_DSP_FW_ALL_OK ; + ret =tasdevice_prmg_load (tas_priv,0 ); +if (ret <0 ) { +dev_err (tas_priv->dev,"FW download failed = %d\n" , ret); + goto out; } + tas_priv->fw_state =TASDEVICE_DSP_FW_ALL_OK ; +if (tas_priv->fmw->nr_programs >0 ) tas_priv->tasdevice[tas_priv->index].cur_prog =0 ;if (tas_priv->fmw->nr_configurations >0 )
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 376/752 drm/amd/display: Fix system resume lag issue
In reply to Sasha LevinFrom: Tom Chung <[email protected]>
[ Upstream commit 64c94cd9be2e188ed07efeafa6a109bce638c967 ]
[Why]
System will try to apply idle power optimizations setting during system resume. But system power state is still in D3 state, and it will cause the idle power optimizations command not actually to be sent to DMUB and cause some platforms to go into IPS.
[How]
Set power state to D0 first before calling the dc_dmub_srv_apply_idle_power_optimizations(dm->dc, false)
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +10 -0
@@ -3407,7 +3407,17 @@ static int dm_resume(struct amdgpu_ip_block *ip_block)struct dc_commit_streams_params commit_params = {};if (dm->dc->caps.ips_support) { +if (!amdgpu_in_reset (adev)) +mutex_lock (&dm->dc_lock); + +/* Need to set POWER_STATE_D0 first or it will not execute +* idle_power_optimizations command to DMUB. +*/ +dc_dmub_srv_set_power_state (dm->dc->ctx->dmub_srv,DC_ACPI_CM_POWER_STATE_D0 );dc_dmub_srv_apply_idle_power_optimizations (dm->dc, false); + +if (!amdgpu_in_reset (adev)) +mutex_unlock (&dm->dc_lock); }if (amdgpu_in_reset (adev)) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 377/752 drm/amd/display: Avoid updating surface with the same surface under MPO
In reply to Sasha LevinFrom: Wayne Lin <[email protected]>
[ Upstream commit 1a38ded4bc8ac09fd029ec656b1e2c98cc0d238c ]
[Why & How]
Although it's dummy updates of surface update for committing stream updates, we should not have dummy_updates[j].surface all indicating to the same surface under multiple surfaces case. Otherwise, copy_surface_update_to_plane() in update_planes_and_stream_state() will update to the same surface only.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
@@ -10724,7 +10724,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)continue ; }for (j =0 ; j < status->plane_count; j++) - dummy_updates[j].surface = status->plane_states[0 ]; + dummy_updates[j].surface = status->plane_states[j];sort (dummy_updates, status->plane_count,sizeof (*dummy_updates), dm_plane_layer_index_cmp,NULL );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 378/752 drm/amdgpu: return when ras table checksum is error
In reply to Sasha LevinFrom: Gangliang Xie <[email protected]>
[ Upstream commit 044f8d3b1fac6ac89c560f61415000e6bdab3a03 ]
end the function flow when ras table checksum is error
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +3 -1
@@ -1475,10 +1475,12 @@ int amdgpu_ras_eeprom_check(struct amdgpu_ras_eeprom_control *control) } res =__verify_ras_table_checksum (control); -if (res) +if (res) {dev_err (adev->dev,"RAS table incorrect checksum or error:%d\n" , res); +return -EINVAL ; + }/* Warn if we are at 90% of the threshold or above */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 379/752 drm/amdgpu: Adjust usleep_range in fence wait
In reply to Sasha LevinFrom: Ce Sun <[email protected]>
[ Upstream commit 3ee1c72606bd2842f0f377fd4b118362af0323ae ]
Tune the sleep interval in the PSP fence wait loop from 10-100us to 60-100us.This adjustment results in an overall wait window of 1.2s (60us * 20000 iterations) to 2 seconds (100us * 20000 iterations), which guarantees that we can retrieve the correct fence value
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -1
@@ -726,7 +726,7 @@ psp_cmd_submit_buf(struct psp_context *psp, ras_intr =amdgpu_ras_intr_triggered ();if (ras_intr)break ; -usleep_range (10 ,100 ); +usleep_range (60 ,100 );amdgpu_device_invalidate_hdp (psp->adev,NULL ); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 380/752 ALSA: hda/realtek: Fix headset mic on ASUS Zenbook 14 UX3405MA
In reply to Sasha LevinFrom: Erik Sanjaya <[email protected]>
[ Upstream commit 91062e119b4eafde553c894ca072cd615a6dae2e ]
The ASUS Zenbook 14 UX3405MA uses an ALC294 codec with CS35L41 amplifiers over SPI. The existing quirk for this model only configured the amplifiers, leaving the headset microphone on the combo jack non-functional.
Introduce a new fixup that configures pin 0x19 as headset mic input and chains to ALC245_FIXUP_CS35L41_SPI_2 to preserve speaker functionality.
Similar to the fix done for the UM3406HA in commit 018f659753fd ("ALSA: hda/realtek: Fix headset mic on ASUS Zenbook 14").
--- sound/hda/codecs/realtek/alc269.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
sound/hda/codecs/realtek/alc269.c +11 -1
@@ -3777,6 +3777,7 @@ enum {ALC294_FIXUP_ASUS_MIC ,ALC294_FIXUP_ASUS_HEADSET_MIC ,ALC294_FIXUP_ASUS_I2C_HEADSET_MIC , +ALC294_FIXUP_ASUS_SPI_HEADSET_MIC ,ALC294_FIXUP_ASUS_SPK ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE , ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
@@ -5121,6 +5122,15 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id =ALC287_FIXUP_CS35L41_I2C_2 }, + [ALC294_FIXUP_ASUS_SPI_HEADSET_MIC] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl []) { + {0x19 ,0x04a11020 },/* use as headset mic */ + { } + }, + .chained = true, + .chain_id =ALC245_FIXUP_CS35L41_SPI_2 + }, [ALC294_FIXUP_ASUS_SPK] = { .type = HDA_FIXUP_VERBS, .v.verbs = (const struct hda_verb []) {
@@ -7027,7 +7037,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1043 ,0x19ce ,"ASUS B9450FA" ,ALC294_FIXUP_ASUS_HPE ),SND_PCI_QUIRK (0x1043 ,0x19e1 ,"ASUS UX581LV" ,ALC295_FIXUP_ASUS_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1043 ,0x1a13 ,"Asus G73Jw" ,ALC269_FIXUP_ASUS_G73JW ), -SND_PCI_QUIRK (0x1043 ,0x1a63 ,"ASUS UX3405MA" ,ALC245_FIXUP_CS35L41_SPI_2 ), +SND_PCI_QUIRK (0x1043 ,0x1a63 ,"ASUS UX3405MA" ,ALC294_FIXUP_ASUS_SPI_HEADSET_MIC ),SND_PCI_QUIRK (0x1043 ,0x1a83 ,"ASUS UM5302LA" ,ALC294_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x1043 ,0x1a8e ,"ASUS G712LWS" ,ALC294_FIXUP_LENOVO_MIC_LOCATION ), SND_PCI_QUIRK(0x1043, 0x1a8f, "ASUS UX582ZS", ALC245_FIXUP_CS35L41_SPI_2),
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 381/752 ALSA: usb-audio: Update the number of packets properly at receiving
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit cf044e44190234a41a788de1cdbb6c21f4a52e1e ]
At receiving the packets from the implicit feedback source, we didn't update ctx->packets field but only the ctx->packet_size[] data. In exceptional cases, this might lead to unexpectedly superfluous data transfer (although this won't happen usually due to the nature of USB isochronous transfer). Fix it to update the field properly.
--- sound/usb/endpoint.c | 1 + 1 file changed, 1 insertion(+)
sound/usb/endpoint.c +1 -0
@@ -481,6 +481,7 @@ int snd_usb_queue_pending_output_urbs(struct snd_usb_endpoint *ep,/* copy over the length information */ if (implicit_fb) { + ctx->packets = packet->packets;for (i =0 ; i < packet->packets; i++) ctx->packet_size[i] = packet->packet_size[i]; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 382/752 drm/amdgpu: Add HAINAN clock adjustment
In reply to Sasha LevinFrom: decce6 <[email protected]>
[ Upstream commit 49fe2c57bdc0acff9d2551ae337270b6fd8119d9 ]
This patch limits the clock speeds of the AMD Radeon R5 M420 GPU from 850/1000MHz (core/memory) to 800/950 MHz, making it work stably. This patch is for amdgpu.
--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +5 -0
@@ -3469,6 +3469,11 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev, max_sclk =60000 ; max_mclk =80000 ; } +if ((adev->pdev->device ==0x666f ) && + (adev->pdev->revision ==0x00 )) { + max_sclk =80000 ; + max_mclk =95000 ; + } }else if (adev->asic_type ==CHIP_OLAND ) { if ((adev->pdev->revision == 0xC7) || (adev->pdev->revision == 0x80) ||
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 383/752 drm/amd/display: bypass post csc for additional color spaces in dal
In reply to Sasha LevinFrom: Clay King <[email protected]>
[ Upstream commit 7d9ec9dc20ecdb1661f4538cd9112cd3d6a5f15a ]
[Why]
For RGB BT2020 full and limited color spaces, overlay adjustments were applied twice (once by MM and once by DAL). This results in incorrect colours and a noticeable difference between mpo and non-mpo cases.
[How]
Add RGB BT2020 full and limited color spaces to list that bypasses post csc adjustment.
--- .../drm/amd/display/dc/dpp/dcn30/dcn30_dpp.c | 21 ++++++++++++++++--- .../drm/amd/display/dc/dpp/dcn30/dcn30_dpp.h | 4 ++++ .../amd/display/dc/dpp/dcn401/dcn401_dpp.c | 6 +++--- 3 files changed, 25 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/dpp/dcn30/dcn30_dpp.c +18 -3
@@ -360,10 +360,10 @@ void dpp3_cnv_setup ( tbl_entry.color_space = input_color_space; -if (color_space >=COLOR_SPACE_YCBCR601 ) - select =INPUT_CSC_SELECT_ICSC ; -else +if (dpp3_should_bypass_post_csc_for_colorspace (color_space)) select =INPUT_CSC_SELECT_BYPASS ; +else + select =INPUT_CSC_SELECT_ICSC ;dpp3_program_post_csc (dpp_base, color_space, select, &tbl_entry);
@@ -1521,3 +1521,18 @@ bool dpp3_construct(return true; } +bool dpp3_should_bypass_post_csc_for_colorspace (enum dc_color_space dc_color_space) +{ +switch (dc_color_space) { +case COLOR_SPACE_UNKNOWN : +case COLOR_SPACE_SRGB : +case COLOR_SPACE_XR_RGB : +case COLOR_SPACE_SRGB_LIMITED : +case COLOR_SPACE_MSREF_SCRGB : +case COLOR_SPACE_2020_RGB_FULLRANGE : +case COLOR_SPACE_2020_RGB_LIMITEDRANGE : +return true; +default : +return false; + } +}
drivers/gpu/drm/amd/display/dc/dpp/dcn30/dcn30_dpp.h +4 -0
@@ -642,4 +642,8 @@ void dpp3_program_cm_dealpha(void dpp3_cm_get_gamut_remap (struct dpp *dpp_base,struct dpp_grph_csc_adjustment *adjust); + +bool dpp3_should_bypass_post_csc_for_colorspace ( +enum dc_color_space dc_color_space); +#endif /* __DC_HWSS_DCN30_H__ */
drivers/gpu/drm/amd/display/dc/dpp/dcn401/dcn401_dpp.c +3 -3
@@ -206,10 +206,10 @@ void dpp401_dpp_setup( tbl_entry.color_space = input_color_space; -if (color_space >=COLOR_SPACE_YCBCR601 ) - select =INPUT_CSC_SELECT_ICSC ; -else +if (dpp3_should_bypass_post_csc_for_colorspace (color_space)) select =INPUT_CSC_SELECT_BYPASS ; +else + select =INPUT_CSC_SELECT_ICSC ;dpp3_program_post_csc (dpp_base, color_space, select, &tbl_entry);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 384/752 spi: spidev: fix lock inversion between spi_lock and buf_lock
In reply to Sasha LevinFrom: Fabian Godehardt <[email protected]>
[ Upstream commit 40534d19ed2afb880ecf202dab26a8e7a5808d16 ]
The spidev driver previously used two mutexes, spi_lock and buf_lock, but acquired them in different orders depending on the code path:
write()/read(): buf_lock -> spi_lock
ioctl(): spi_lock -> buf_lock
This AB-BA locking pattern triggers lockdep warnings and can cause real deadlocks:
WARNING: possible circular locking dependency detected spidev_ioctl() -> mutex_lock(&spidev->buf_lock) spidev_sync_write() -> mutex_lock(&spidev->spi_lock) *** DEADLOCK ***
The issue is reproducible with a simple userspace program that performs write() and SPI_IOC_WR_MAX_SPEED_HZ ioctl() calls from separate threads on the same spidev file descriptor.
Fix this by simplifying the locking model and removing the lock inversion entirely. spidev_sync() no longer performs any locking, and all callers serialize access using spi_lock.
buf_lock is removed since its functionality is fully covered by spi_lock, eliminating the possibility of lock ordering issues.
This removes the lock inversion and prevents deadlocks without changing userspace ABI or behaviour.
--- drivers/spi/spidev.c | 63 ++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 41 deletions(-)
drivers/spi/spidev.c +22 -41
@@ -74,7 +74,6 @@ struct spidev_data {struct list_head device_entry;/* TX/RX buffers are NULL unless this device is open (users > 0) */ -struct mutex buf_lock;unsigned users;u8 *tx_buffer;u8 *rx_buffer;
@@ -102,24 +101,6 @@ spidev_sync_unlocked(struct spi_device *spi, struct spi_message *message)return status; } -static ssize_t -spidev_sync (struct spidev_data *spidev,struct spi_message *message) -{ -ssize_t status; -struct spi_device *spi; - -mutex_lock (&spidev->spi_lock); - spi = spidev->spi; - -if (spi ==NULL ) - status = -ESHUTDOWN ; -else - status =spidev_sync_unlocked (spi, message); - -mutex_unlock (&spidev->spi_lock); -return status; -} -static inline ssize_t spidev_sync_write (struct spidev_data *spidev,size_t len) {
@@ -132,7 +113,8 @@ spidev_sync_write(struct spidev_data *spidev, size_t len)spi_message_init (&m);spi_message_add_tail (&t, &m); -return spidev_sync (spidev, &m); + +return spidev_sync_unlocked (spidev->spi, &m); } static inline ssize_t
@@ -147,7 +129,8 @@ spidev_sync_read(struct spidev_data *spidev, size_t len)spi_message_init (&m);spi_message_add_tail (&t, &m); -return spidev_sync (spidev, &m); + +return spidev_sync_unlocked (spidev->spi, &m); }/*-------------------------------------------------------------------------*/
@@ -157,7 +140,7 @@ static ssize_t spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) { struct spidev_data *spidev; -ssize_t status; +ssize_t status = -ESHUTDOWN ;/* chipselect only toggles at start or end of operation */ if (count > bufsiz)
@@ -165,7 +148,11 @@ spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) spidev = filp->private_data; -mutex_lock (&spidev->buf_lock); +mutex_lock (&spidev->spi_lock); + +if (spidev->spi ==NULL ) + goto err_spi_removed; + status =spidev_sync_read (spidev, count);if (status >0 ) {unsigned long missing;
@@ -176,7 +163,9 @@ spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)else status = status - missing; } -mutex_unlock (&spidev->buf_lock); + +err_spi_removed: +mutex_unlock (&spidev->spi_lock);return status; }
@@ -187,7 +176,7 @@ spidev_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) { struct spidev_data *spidev; -ssize_t status; +ssize_t status = -ESHUTDOWN ;unsigned long missing;/* chipselect only toggles at start or end of operation */
@@ -196,13 +185,19 @@ spidev_write(struct file *filp, const char __user *buf, spidev = filp->private_data; -mutex_lock (&spidev->buf_lock); +mutex_lock (&spidev->spi_lock); + +if (spidev->spi ==NULL ) + goto err_spi_removed; + missing =copy_from_user (spidev->tx_buffer, buf, count);if (missing ==0 ) status =spidev_sync_write (spidev, count);else status = -EFAULT ; -mutex_unlock (&spidev->buf_lock); + +err_spi_removed: +mutex_unlock (&spidev->spi_lock);return status; }
@@ -379,14 +374,6 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ctlr = spi->controller; -/* use the buffer lock here for triple duty: -* - prevent I/O (from us) so calling spi_setup() is safe; -* - prevent concurrent SPI_IOC_WR_* from morphing -* data fields while SPI_IOC_RD_* reads them; -* - SPI_IOC_MESSAGE needs the buffer locked "normally". -*/ -mutex_lock (&spidev->buf_lock); -switch (cmd) {/* read requests */ case SPI_IOC_RD_MODE :
@@ -510,7 +497,6 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)break ; } -mutex_unlock (&spidev->buf_lock);spi_dev_put (spi);mutex_unlock (&spidev->spi_lock);return retval;
@@ -541,9 +527,6 @@ spidev_compat_ioc_message(struct file *filp, unsigned int cmd,return -ESHUTDOWN ; } -/* SPI_IOC_MESSAGE needs the buffer locked "normally" */ -mutex_lock (&spidev->buf_lock); -/* Check message and copy into scratch area */ ioc =spidev_get_ioc_message (cmd, u_ioc, &n_ioc);if (IS_ERR (ioc)) {
@@ -564,7 +547,6 @@ spidev_compat_ioc_message(struct file *filp, unsigned int cmd,kfree (ioc); done: -mutex_unlock (&spidev->buf_lock);spi_dev_put (spi);mutex_unlock (&spidev->spi_lock);return retval;
@@ -800,7 +782,6 @@ static int spidev_probe(struct spi_device *spi)/* Initialize the driver data */ spidev->spi = spi;mutex_init (&spidev->spi_lock); -mutex_init (&spidev->buf_lock);INIT_LIST_HEAD (&spidev->device_entry);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 385/752 drm/radeon: Add HAINAN clock adjustment
In reply to Sasha LevinFrom: decce6 <[email protected]>
[ Upstream commit 908d318f23d6b5d625bea093c5fc056238cdb7ff ]
This patch limits the clock speeds of the AMD Radeon R5 M420 GPU from 850/1000MHz (core/memory) to 800/950 MHz, making it work stably. This patch is for radeon.
--- drivers/gpu/drm/radeon/si_dpm.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/radeon/si_dpm.c +5 -0
@@ -2925,6 +2925,11 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev, max_sclk =60000 ; max_mclk =80000 ; } +if ((rdev->pdev->device ==0x666f ) && + (rdev->pdev->revision ==0x00 )) { + max_sclk =80000 ; + max_mclk =95000 ; + } }else if (rdev->family ==CHIP_OLAND ) { if ((rdev->pdev->revision == 0xC7) || (rdev->pdev->revision == 0x80) ||
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 386/752 ALSA: usb-audio: Add sanity check for OOB writes at silencing
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit fba2105a157fffcf19825e4eea498346738c9948 ]
At silencing the playback URB packets in the implicit fb mode before the actual playback, we blindly assume that the received packets fit with the buffer size. But when the setup in the capture stream differs from the playback stream (e.g. due to the USB core limitation of max packet size), such an inconsistency may lead to OOB writes to the buffer, resulting in a crash.
For addressing it, add a sanity check of the transfer buffer size at prepare_silent_urb(), and stop the data copy if the received data overflows. Also, report back the transfer error properly from there, too.
Note that this doesn't fix the root cause of the playback error itself, but this merely covers the kernel Oops.
--- sound/usb/endpoint.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-)
sound/usb/endpoint.c +22 -17
@@ -275,8 +275,8 @@ static inline bool has_tx_length_quirk(struct snd_usb_audio *chip)return chip->quirk_flags &QUIRK_FLAG_TX_LENGTH ; } -static void prepare_silent_urb (struct snd_usb_endpoint *ep, -struct snd_urb_ctx *ctx) +static int prepare_silent_urb (struct snd_usb_endpoint *ep, +struct snd_urb_ctx *ctx) {struct urb *urb = ctx->urb;unsigned int offs =0 ;
@@ -289,28 +289,34 @@ static void prepare_silent_urb(struct snd_usb_endpoint *ep, extra =sizeof (packet_length);for (i =0 ; i < ctx->packets; ++i) { -unsigned int offset; -unsigned int length; -int counts; - - counts =snd_usb_endpoint_next_packet_size (ep, ctx, i,0 ); - length = counts * ep->stride;/* number of silent bytes */ - offset = offs * ep->stride + extra * i; - urb->iso_frame_desc[i].offset = offset; +int length; + + length =snd_usb_endpoint_next_packet_size (ep, ctx, i,0 ); +if (length <0 ) +return length; + length *= ep->stride;/* number of silent bytes */ +if (offs + length + extra > ctx->buffer_size) +break ; + urb->iso_frame_desc[i].offset = offs; urb->iso_frame_desc[i].length = length + extra;if (extra) { packet_length =cpu_to_le32 (length); -memcpy (urb->transfer_buffer + offset, +memcpy (urb->transfer_buffer + offs, &packet_length,sizeof (packet_length)); + offs += extra; } -memset (urb->transfer_buffer + offset + extra, +memset (urb->transfer_buffer + offs, ep->silence_value, length); - offs += counts; + offs += length; } - urb->number_of_packets = ctx->packets; - urb->transfer_buffer_length = offs * ep->stride + ctx->packets * extra; +if (!offs) +return -EPIPE ; + + urb->number_of_packets = i; + urb->transfer_buffer_length = offs; ctx->queued =0 ; +return 0 ; }/*
@@ -332,8 +338,7 @@ static int prepare_outbound_urb(struct snd_usb_endpoint *ep,if (data_subs && ep->prepare_data_urb)return ep->prepare_data_urb (data_subs, urb, in_stream_lock);/* no data provider, so send silence */ -prepare_silent_urb (ep, ctx); -break ; +return prepare_silent_urb (ep, ctx);case SND_USB_ENDPOINT_TYPE_SYNC :if (snd_usb_get_speed (ep->chip->dev) >=USB_SPEED_HIGH ) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 387/752 btrfs: replace BUG() with error handling in __btrfs_balance()
In reply to Sasha LevinFrom: Adarsh Das <[email protected]>
[ Upstream commit be6324a809dbda76d5fdb23720ad9b20e5c1905c ]
We search with offset (u64)-1 which should never match exactly. Previously this was handled with BUG(). Now logs an error and return -EUCLEAN.
--- fs/btrfs/volumes.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/btrfs/volumes.c +8 -2
@@ -4264,8 +4264,14 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)* this shouldn't happen, it means the last relocate * failed */ -if (ret ==0 ) -BUG ();/* FIXME break ? */ +if (unlikely (ret ==0 )) { +btrfs_err (fs_info, +"unexpected exact match of CHUNK_ITEM in chunk tree, offset 0x%llx" , + key.offset); +mutex_unlock (&fs_info->reclaim_bgs_lock); + ret = -EUCLEAN ; + goto error; + } ret =btrfs_previous_item (chunk_root, path,0 ,BTRFS_CHUNK_ITEM_KEY );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 388/752 ASoC: amd: amd_sdw: add machine driver quirk for Lenovo models
In reply to Sasha LevinFrom: Vijendar Mukunda <[email protected]>
[ Upstream commit 3acf517e1ae05ef66561b7a2782690387ce46e21 ]
This patch adds a quirk to include the codec amplifier function for Lenovo models listed in the quirk table.
Note: In these models, the RT722 codec amplifier is excluded, and an external amplifier is used instead.
--- sound/soc/amd/acp/acp-sdw-legacy-mach.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
sound/soc/amd/acp/acp-sdw-legacy-mach.c +16 -0
@@ -95,6 +95,22 @@ static const struct dmi_system_id soc_sdw_quirk_table[] = { }, .driver_data = (void *)(ASOC_SDW_CODEC_SPKR), }, + { + .callback = soc_sdw_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "21YW"), + }, + .driver_data = (void *)(ASOC_SDW_CODEC_SPKR), + }, + { + .callback = soc_sdw_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "21YX"), + }, + .driver_data = (void *)(ASOC_SDW_CODEC_SPKR), + }, {} };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 389/752 ALSA: hda/hdmi: Add quirk for TUXEDO IBS14G6
In reply to Sasha LevinFrom: Aaron Erhardt <[email protected]>
[ Upstream commit d649c58bcad8fb9b749e3837136a201632fa109d ]
Depending on the timing during boot, the BIOS might report wrong pin capabilities, which can lead to HDMI audio being disabled. Therefore, force HDMI audio connection on TUXEDO InfinityBook S 14 Gen6.
--- sound/hda/codecs/hdmi/hdmi.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/codecs/hdmi/hdmi.c +1 -0
@@ -1557,6 +1557,7 @@ static const struct snd_pci_quirk force_connect_list[] = {SND_PCI_QUIRK (0x1043 ,0x86ae ,"ASUS" ,1 ),/* Z170 PRO */ SND_PCI_QUIRK (0x1043 ,0x86c7 ,"ASUS" ,1 ),/* Z170M PLUS */ SND_PCI_QUIRK (0x1462 ,0xec94 ,"MS-7C94" ,1 ), +SND_PCI_QUIRK (0x1558 ,0x14a1 ,"TUXEDO InfinityBook S 14 Gen6" ,1 ),SND_PCI_QUIRK (0x8086 ,0x2060 ,"Intel NUC5CPYB" ,1 ), SND_PCI_QUIRK(0x8086, 0x2081, "Intel NUC 10", 1), {}
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 390/752 arm64: hugetlbpage: avoid unused-but-set-parameter warning (gcc-16)
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 729a2e8e9ac47099a967567389cc9d73ef4194ca ]
gcc-16 warns about an instance that older compilers did not:
arch/arm64/mm/hugetlbpage.c: In function 'huge_pte_clear':arch/arm64/mm/hugetlbpage.c:369:57: error: parameter 'addr' set but not used [-Werror=unused-but-set-parameter=]
The issue here is that __pte_clear() does not actually use its second argument, but when CONFIG_ARM64_CONTPTE is enabled it still gets updated.
Replace the macro with an inline function to let the compiler see the argument getting passed down.
--- arch/arm64/include/asm/pgtable.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm64/include/asm/pgtable.h +7 -2
@@ -175,8 +175,6 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) __pte(__phys_to_pte_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))#define pte_none (pte) (!pte_val(pte)) -#define __pte_clear (mm, addr, ptep) \ - __set_pte(ptep, __pte(0))#define pte_page (pte) (pfn_to_page(pte_pfn(pte)))/*
@@ -1316,6 +1314,13 @@ static inline bool pud_user_accessible_page(pud_t pud)/* * Atomic pte/pmd modifications. */ + +static inline void __pte_clear (struct mm_struct *mm, +unsigned long addr,pte_t *ptep) +{ +__set_pte (ptep,__pte (0 )); +} +static inline int __ptep_test_and_clear_young (struct vm_area_struct *vma,unsigned long address,pte_t *ptep)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 391/752 drm/amd/display: Remove conditional for shaper 3DLUT power-on
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 1b38a87b8f8020e8ef4563e7752a64182b5a39b9 ]
[Why]
Shaper programming has high chance to fail on first time after power-on or reboot. This can be verified by running IGT's kms_colorop.
[How]
Always power on the shaper and 3DLUT before programming by removing the debug flag of low power mode.
--- drivers/gpu/drm/amd/display/dc/mpc/dcn32/dcn32_mpc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/mpc/dcn32/dcn32_mpc.c +1 -2
@@ -724,8 +724,7 @@ bool mpc32_program_shaper(return false; } -if (mpc->ctx->dc->debug.enable_mem_low_power.bits.mpc) -mpc32_power_on_shaper_3dlut (mpc, mpcc_id, true); +mpc32_power_on_shaper_3dlut (mpc, mpcc_id, true); current_mode =mpc32_get_shaper_current (mpc, mpcc_id);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 392/752 drm/amdgpu: avoid sdma ring reset in sriov
In reply to Sasha LevinFrom: Victor Zhao <[email protected]>
[ Upstream commit 5cc7bbd9f1b74d9fe2f7ac08d6ba0477e8d2d65f ]
sdma ring reset is not supported in SRIOV. kfd driver does not check reset mask, and could queue sdma ring reset during unmap_queues_cpsch.
Avoid the ring reset for sriov.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +3 -0
@@ -558,6 +558,9 @@ int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id,struct amdgpu_ring *gfx_ring = &sdma_instance->ring;struct amdgpu_ring *page_ring = &sdma_instance->page; +if (amdgpu_sriov_vf (adev)) +return -EOPNOTSUPP ; +mutex_lock (&sdma_instance->engine_reset_mutex);if (!caller_handles_kernel_queues) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 393/752 rtc: zynqmp: correct frequency value
In reply to Sasha LevinFrom: Tomas Melin <[email protected]>
[ Upstream commit 2724fb4d429cbb724dcb6fa17953040918ebe3a2 ]
Fix calibration value in case a clock reference is provided. The actual calibration value written into register is frequency - 1.
--- drivers/rtc/rtc-zynqmp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/rtc/rtc-zynqmp.c +3 -0
@@ -345,7 +345,10 @@ static int xlnx_rtc_probe(struct platform_device *pdev) &xrtcdev->freq);if (ret) xrtcdev->freq =RTC_CALIB_DEF ; + }else { + xrtcdev->freq--; } + ret =readl (xrtcdev->reg_base +RTC_CALIB_RD );if (!ret)writel (xrtcdev->freq, (xrtcdev->reg_base +RTC_CALIB_WR ));
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 394/752 ntb: ntb_hw_switchtec: Fix array-index-out-of-bounds access
In reply to Sasha LevinFrom: Maciej Grochowski <[email protected]>
[ Upstream commit c8ba7ad2cc1c7b90570aa347b8ebbe279f1eface ]
Number of MW LUTs depends on NTB configuration and can be set to MAX_MWS, This patch protects against invalid index out of bounds access to mw_sizes When invalid access print message to user that configuration is not valid.
--- drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +6 -0
@@ -1314,6 +1314,12 @@ static void switchtec_ntb_init_shared(struct switchtec_ntb *sndev)for (i =0 ; i < sndev->nr_lut_mw; i++) {int idx = sndev->nr_direct_mw + i; +if (idx >=MAX_MWS ) { +dev_err (&sndev->stdev->dev, +"Total number of MW cannot be bigger than %d" ,MAX_MWS ); +break ; + } + sndev->self_shared->mw_sizes[idx] =LUT_SIZE ; } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 395/752 ntb: ntb_hw_switchtec: Fix shift-out-of-bounds for 0 mw lut
In reply to Sasha LevinFrom: Maciej Grochowski <[email protected]>
[ Upstream commit 186615f8855a0be4ee7d3fcd09a8ecc10e783b08 ]
Number of MW LUTs depends on NTB configuration and can be set to zero, in such scenario rounddown_pow_of_two will cause undefined behaviour and should not be performed.
This patch ensures that rounddown_pow_of_two is called on valid value.
--- drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +4 -2
@@ -1202,7 +1202,8 @@ static void switchtec_ntb_init_mw(struct switchtec_ntb *sndev) sndev->mmio_self_ctrl); sndev->nr_lut_mw =ioread16 (&sndev->mmio_self_ctrl->lut_table_entries); - sndev->nr_lut_mw =rounddown_pow_of_two (sndev->nr_lut_mw); +if (sndev->nr_lut_mw) + sndev->nr_lut_mw =rounddown_pow_of_two (sndev->nr_lut_mw);dev_dbg (&sndev->stdev->dev,"MWs: %d direct, %d lut\n" , sndev->nr_direct_mw, sndev->nr_lut_mw);
@@ -1212,7 +1213,8 @@ static void switchtec_ntb_init_mw(struct switchtec_ntb *sndev) sndev->peer_nr_lut_mw =ioread16 (&sndev->mmio_peer_ctrl->lut_table_entries); - sndev->peer_nr_lut_mw =rounddown_pow_of_two (sndev->peer_nr_lut_mw); +if (sndev->peer_nr_lut_mw) + sndev->peer_nr_lut_mw =rounddown_pow_of_two (sndev->peer_nr_lut_mw);dev_dbg (&sndev->stdev->dev,"Peer MWs: %d direct, %d lut\n" , sndev->peer_nr_direct_mw, sndev->peer_nr_lut_mw);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 396/752 iommu/amd: serialize sequence allocation under concurrent TLB invalidations
In reply to Sasha LevinFrom: Ankit Soni <[email protected]>
[ Upstream commit 9e249c48412828e807afddc21527eb734dc9bd3d ]
With concurrent TLB invalidations, completion wait randomly gets timed out because cmd_sem_val was incremented outside the IOMMU spinlock, allowing CMD_COMPL_WAIT commands to be queued out of sequence and breaking the ordering assumption in wait_on_sem().
Move the cmd_sem_val increment under iommu->lock so completion sequence allocation is serialized with command queuing.
And remove the unnecessary return.
--- drivers/iommu/amd/amd_iommu_types.h | 2 +- drivers/iommu/amd/init.c | 2 +- drivers/iommu/amd/iommu.c | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-)
drivers/iommu/amd/amd_iommu_types.h +1 -1
@@ -791,7 +791,7 @@ struct amd_iommu {u32 flags;volatile u64 *cmd_sem; -atomic64_t cmd_sem_val; +u64 cmd_sem_val;/* * Track physical address to directly use it in build_completion_wait() * and avoid adding any special checks and handling for kdump.
drivers/iommu/amd/init.c +1 -1
@@ -1879,7 +1879,7 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h, iommu->pci_seg = pci_seg;raw_spin_lock_init (&iommu->lock); -atomic64_set (&iommu->cmd_sem_val,0 ); + iommu->cmd_sem_val =0 ;/* Add IOMMU to internal data structures */ list_add_tail (&iommu->list, &amd_iommu_list);
drivers/iommu/amd/iommu.c +12 -6
@@ -1386,6 +1386,12 @@ static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)return iommu_queue_command_sync (iommu, cmd, true); } +static u64 get_cmdsem_val (struct amd_iommu *iommu) +{ +lockdep_assert_held (&iommu->lock); +return ++iommu->cmd_sem_val; +} +/* * This function queues a completion wait command into the command * buffer of an IOMMU
@@ -1400,11 +1406,11 @@ static int iommu_completion_wait(struct amd_iommu *iommu)if (!iommu->need_sync)return 0 ; - data =atomic64_inc_return (&iommu->cmd_sem_val); -build_completion_wait (&cmd, iommu, data); -raw_spin_lock_irqsave (&iommu->lock, flags); + data =get_cmdsem_val (iommu); +build_completion_wait (&cmd, iommu, data); + ret =__iommu_queue_command_sync (iommu, &cmd, false);raw_spin_unlock_irqrestore (&iommu->lock, flags);
@@ -3086,10 +3092,11 @@ static void iommu_flush_irt_and_complete(struct amd_iommu *iommu, u16 devid)return ;build_inv_irt (&cmd, devid); - data =atomic64_inc_return (&iommu->cmd_sem_val); -build_completion_wait (&cmd2, iommu, data);raw_spin_lock_irqsave (&iommu->lock, flags); + data =get_cmdsem_val (iommu); +build_completion_wait (&cmd2, iommu, data); + ret =__iommu_queue_command_sync (iommu, &cmd, true);if (ret) goto out_err;
@@ -3103,7 +3110,6 @@ static void iommu_flush_irt_and_complete(struct amd_iommu *iommu, u16 devid) out_err:raw_spin_unlock_irqrestore (&iommu->lock, flags); -return ; }static inline u8 iommu_get_int_tablen (struct iommu_dev_data *dev_data)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 397/752 xfrm6: fix uninitialized saddr in xfrm6_get_saddr()
In reply to Sasha LevinFrom: Jiayuan Chen <[email protected]>
[ Upstream commit 1799d8abeabc68ec05679292aaf6cba93b343c05 ]
xfrm6_get_saddr() does not check the return value of ipv6_dev_get_saddr(). When ipv6_dev_get_saddr() fails to find a suitable source address (returns -EADDRNOTAVAIL), saddr->in6 is left uninitialized, but xfrm6_get_saddr() still returns 0 (success).
This causes the caller xfrm_tmpl_resolve_one() to use the uninitialized address in xfrm_state_find(), triggering KMSAN warning:
=====================================================
BUG: KMSAN: uninit-value in xfrm_state_find+0x2424/0xa940 xfrm_state_find+0x2424/0xa940 xfrm_resolve_and_create_bundle+0x906/0x5a20 xfrm_lookup_with_ifid+0xcc0/0x3770 xfrm_lookup_route+0x63/0x2b0 ip_route_output_flow+0x1ce/0x270 udp_sendmsg+0x2ce1/0x3400 inet_sendmsg+0x1ef/0x2a0 __sock_sendmsg+0x278/0x3d0 __sys_sendto+0x593/0x720 __x64_sys_sendto+0x130/0x200 x64_sys_call+0x332b/0x3e70 do_syscall_64+0xd3/0xf80 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Local variable tmp.i.i created at:
xfrm_resolve_and_create_bundle+0x3e3/0x5a20 xfrm_lookup_with_ifid+0xcc0/0x3770 =====================================================
Fix by checking the return value of ipv6_dev_get_saddr() and propagating the error.
--- net/ipv6/xfrm6_policy.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/ipv6/xfrm6_policy.c +5 -2
@@ -57,6 +57,7 @@ static int xfrm6_get_saddr(xfrm_address_t *saddr,struct dst_entry *dst;struct net_device *dev;struct inet6_dev *idev; +int err; dst =xfrm6_dst_lookup (params);if (IS_ERR (dst))
@@ -68,9 +69,11 @@ static int xfrm6_get_saddr(xfrm_address_t *saddr,return -EHOSTUNREACH ; } dev = idev->dev; -ipv6_dev_get_saddr (dev_net (dev), dev, ¶ms->daddr->in6,0 , - &saddr->in6); + err =ipv6_dev_get_saddr (dev_net (dev), dev, ¶ms->daddr->in6,0 , + &saddr->in6);dst_release (dst); +if (err) +return -EHOSTUNREACH ;return 0 ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 398/752 xfrm: skip templates check for packet offload tunnel mode
In reply to Sasha LevinFrom: Leon Romanovsky <[email protected]>
[ Upstream commit 0a4524bc69882a4ddb235bb6b279597721bda197 ]
In packet offload, hardware is responsible to check templates. The result of its operation is forwarded through secpath by relevant drivers. That secpath is actually removed in __xfrm_policy_check2().
In case packet is forwarded, this secpath is reset in RX, but pushed again to TX where policy is rechecked again against dummy secpath in xfrm_policy_ok().
Such situation causes to unexpected XfrmInTmplMismatch increase.
As a solution, simply skip template mismatch check.
--- net/xfrm/xfrm_policy.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/xfrm/xfrm_policy.c +9 -2
@@ -3801,8 +3801,8 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,struct xfrm_tmpl *tp[XFRM_MAX_DEPTH ];struct xfrm_tmpl *stp[XFRM_MAX_DEPTH ];struct xfrm_tmpl **tpp = tp; +int i, k =0 ;int ti =0 ; -int i, k; sp =skb_sec_path (skb);if (!sp)
@@ -3828,6 +3828,12 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, tpp = stp; } +if (pol->xdo.type ==XFRM_DEV_OFFLOAD_PACKET && sp == &dummy) +/* This policy template was already checked by HW +* and secpath was removed in __xfrm_policy_check2. +*/ + goto out; +/* For each tunnel xfrm, find the first matching tmpl. * For each tmpl before that, find corresponding xfrm. * Order is _important_. Later we will implement
@@ -3837,7 +3843,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,* verified to allow them to be skipped in future policy * checks (e.g. nested tunnels). */ -for (i = xfrm_nr-1 , k =0 ; i >=0 ; i--) { +for (i = xfrm_nr -1 ; i >=0 ; i--) { k =xfrm_policy_ok (tpp[i], sp, k, family, if_id);if (k <0 ) {if (k <-1 )
@@ -3853,6 +3859,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, goto reject; } +out:xfrm_pols_put (pols, npols); sp->verified_cnt = k;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 399/752 ipmi: ipmb: initialise event handler read bytes
In reply to Sasha LevinFrom: Matt Johnston <[email protected]>
[ Upstream commit 9f235ccecd03c436cb1683eac16b12f119e54aa9 ]
IPMB doesn't use i2c reads, but the handler needs to set a value. Otherwise an i2c read will return an uninitialised value from the bus driver.
Message-ID: <[email protected]>
--- drivers/char/ipmi/ipmi_ipmb.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/char/ipmi/ipmi_ipmb.c +5 -0
@@ -202,11 +202,16 @@ static int ipmi_ipmb_slave_cb(struct i2c_client *client,break ;case I2C_SLAVE_READ_REQUESTED : + *val =0xff ; +ipmi_ipmb_check_msg_done (iidev); +break ; +case I2C_SLAVE_STOP :ipmi_ipmb_check_msg_done (iidev);break ;case I2C_SLAVE_READ_PROCESSED : + *val =0xff ;break ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 400/752 xfrm: always flush state and policy upon NETDEV_UNREGISTER event
In reply to Sasha LevinFrom: Tetsuo Handa <[email protected]>
[ Upstream commit 4efa91a28576054aae0e6dad9cba8fed8293aef8 ]
syzbot is reporting that "struct xfrm_state" refcount is leaking.
unregister_netdevice: waiting for netdevsim0 to become free. Usage count = 2
ref_tracker: netdev@ffff888052f24618 has 1/1 users at
__netdev_tracker_alloc include/linux/netdevice.h:4400 [inline]
netdev_tracker_alloc include/linux/netdevice.h:4412 [inline]
xfrm_dev_state_add+0x3a5/0x1080 net/xfrm/xfrm_device.c:316
xfrm_state_construct net/xfrm/xfrm_user.c:986 [inline]
xfrm_add_sa+0x34ff/0x5fa0 net/xfrm/xfrm_user.c:1022
xfrm_user_rcv_msg+0x58e/0xc00 net/xfrm/xfrm_user.c:3507
netlink_rcv_skb+0x158/0x420 net/netlink/af_netlink.c:2550
xfrm_netlink_rcv+0x71/0x90 net/xfrm/xfrm_user.c:3529
netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
netlink_unicast+0x5aa/0x870 net/netlink/af_netlink.c:1344
netlink_sendmsg+0x8c8/0xdd0 net/netlink/af_netlink.c:1894
sock_sendmsg_nosec net/socket.c:727 [inline]
__sock_sendmsg net/socket.c:742 [inline]
____sys_sendmsg+0xa5d/0xc30 net/socket.c:2592
___sys_sendmsg+0x134/0x1d0 net/socket.c:2646
__sys_sendmsg+0x16d/0x220 net/socket.c:2678
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7fThis is because commit d77e38e612a0 ("xfrm: Add an IPsec hardware offloading API") implemented xfrm_dev_unregister() as no-op despite xfrm_dev_state_add() from xfrm_state_construct() acquires a reference to "struct net_device".
I guess that that commit expected that NETDEV_DOWN event is fired before NETDEV_UNREGISTER event fires, and also assumed that xfrm_dev_state_add() is called only if (dev->features & NETIF_F_HW_ESP) != 0.
Sabrina Dubroca identified steps to reproduce the same symptoms as below.
echo 0 > /sys/bus/netdevsim/new_device
dev=$(ls -1 /sys/bus/netdevsim/devices/netdevsim0/net/)
ip xfrm state add src 192.168.13.1 dst 192.168.13.2 proto esp \
spi 0x1000 mode tunnel aead 'rfc4106(gcm(aes))' $key 128 \
offload crypto dev $dev dir out
ethtool -K $dev esp-hw-offload off
echo 0 > /sys/bus/netdevsim/del_deviceLike these steps indicate, the NETIF_F_HW_ESP bit can be cleared after xfrm_dev_state_add() acquired a reference to "struct net_device". Also, xfrm_dev_state_add() does not check for the NETIF_F_HW_ESP bit when acquiring a reference to "struct net_device".
Commit 03891f820c21 ("xfrm: handle NETDEV_UNREGISTER for xfrm device") re-introduced the NETDEV_UNREGISTER event to xfrm_dev_event(), but that commit for unknown reason chose to share xfrm_dev_down() between the NETDEV_DOWN event and the NETDEV_UNREGISTER event.
I guess that that commit missed the behavior in the previous paragraph.
Therefore, we need to re-introduce xfrm_dev_unregister() in order to release the reference to "struct net_device" by unconditionally flushing state and policy.
--- net/xfrm/xfrm_device.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
net/xfrm/xfrm_device.c +11 -1
@@ -544,6 +544,14 @@ static int xfrm_dev_down(struct net_device *dev)return NOTIFY_DONE ; } +static int xfrm_dev_unregister (struct net_device *dev) +{ +xfrm_dev_state_flush (dev_net (dev), dev, true); +xfrm_dev_policy_flush (dev_net (dev), dev, true); + +return NOTIFY_DONE ; +} +static int xfrm_dev_event (struct notifier_block *this,unsigned long event,void *ptr) {struct net_device *dev =netdev_notifier_info_to_dev (ptr);
@@ -556,8 +564,10 @@ static int xfrm_dev_event(struct notifier_block *this, unsigned long event, voidreturn xfrm_api_check (dev);case NETDEV_DOWN : -case NETDEV_UNREGISTER :return xfrm_dev_down (dev); + +case NETDEV_UNREGISTER : +return xfrm_dev_unregister (dev); }return NOTIFY_DONE ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 401/752 ipv6: Move ipv6_fl_list from ipv6_pinfo to inet_sock.
In reply to Sasha LevinFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 1c17f4373d4db1e1f0ebd3ddcd8e7a642927a826 ]
In {tcp6,udp6,raw6}_sock, struct ipv6_pinfo is always placed at the beginning of a new cache line because
1. __alignof__(struct tcp_sock) is 64 due to ____cacheline_aligned of __cacheline_group_begin(tcp_sock_write_tx)
2. __alignof__(struct udp_sock) is 64 due to ____cacheline_aligned of struct numa_drop_counters
3. in raw6_sock, struct numa_drop_counters is placed before struct ipv6_pinfo
. struct ipv6_pinfo is 136 bytes, but the last cache line is only used by ipv6_fl_list:
$ pahole -C ipv6_pinfo vmlinux
struct ipv6_pinfo {
...
/* --- cacheline 2 boundary (128 bytes) --- */
struct ipv6_fl_socklist * ipv6_fl_list; /* 128 8 *//* size: 136, cachelines: 3, members: 23 */
Let's move ipv6_fl_list from struct ipv6_pinfo to struct inet_sock to save a full cache line for {tcp6,udp6,raw6}_sock.
Now, struct ipv6_pinfo is 128 bytes, and {tcp6,udp6,raw6}_sock have 64 bytes less, while {tcp,udp,raw}_sock retain the same size.
Before:
# grep -E "^(RAW|UDP[^L\-]|TCP)" /proc/slabinfo | awk '{print $1, "\t", $4}'
RAWv6 1408
UDPv6 1472
TCPv6 2560
RAW 1152
UDP 1280
TCP 2368After:
# grep -E "^(RAW|UDP[^L\-]|TCP)" /proc/slabinfo | awk '{print $1, "\t", $4}'
RAWv6 1344
UDPv6 1408
TCPv6 2496
RAW 1152
UDP 1280
TCP 2368Also, ipv6_fl_list and inet_flags (SNDFLOW bit) are placed in the same cache line.
$ pahole -C inet_sock vmlinux ... /* --- cacheline 11 boundary (704 bytes) was 56 bytes ago --- */ struct ipv6_pinfo * pinet6; /* 760 8 */ /* --- cacheline 12 boundary (768 bytes) --- */ struct ipv6_fl_socklist * ipv6_fl_list; /* 768 8 */ unsigned long inet_flags; /* 776 8 */
Doc churn is due to the insufficient Type column (only 1 space short).
Stable-dep-of: 858d2a4f67ff ("tcp: fix potential race in tcp_v6_syn_recv_sock()")
--- .../networking/net_cachelines/inet_sock.rst | 79 ++++++++++--------- .../chelsio/inline_crypto/chtls/chtls_cm.c | 4 +- include/linux/ipv6.h | 1 - include/net/inet_sock.h | 1 + net/ipv6/ip6_flowlabel.c | 44 +++++------ net/ipv6/tcp_ipv6.c | 13 +-- net/sctp/ipv6.c | 8 +- 7 files changed, 76 insertions(+), 74 deletions(-)
Documentation/networking/net_cachelines/inet_sock.rst +40 -39
@@ -5,42 +5,43 @@ inet_sock struct fast path usage breakdown ========================================== -======================= ===================== =================== =================== ====================================================================================================== -Type Name fastpath_tx_access fastpath_rx_access comment -======================= ===================== =================== =================== ====================================================================================================== -struct sock sk read_mostly read_mostly tcp_init_buffer_space,tcp_init_transfer,tcp_finish_connect,tcp_connect,tcp_send_rcvq,tcp_send_syn_data -struct ipv6_pinfo* pinet6 -be16 inet_sport read_mostly __tcp_transmit_skb -be32 inet_daddr read_mostly ip_select_ident_segs -be32 inet_rcv_saddr -be16 inet_dport read_mostly __tcp_transmit_skb -u16 inet_num -be32 inet_saddr -s16 uc_ttl read_mostly __ip_queue_xmit/ip_select_ttl -u16 cmsg_flags -struct ip_options_rcu* inet_opt read_mostly __ip_queue_xmit -u16 inet_id read_mostly ip_select_ident_segs -u8 tos read_mostly ip_queue_xmit -u8 min_ttl -u8 mc_ttl -u8 pmtudisc -u8:1 recverr -u8:1 is_icsk -u8:1 freebind -u8:1 hdrincl -u8:1 mc_loop -u8:1 transparent -u8:1 mc_all -u8:1 nodefrag -u8:1 bind_address_no_port -u8:1 recverr_rfc4884 -u8:1 defer_connect read_mostly tcp_sendmsg_fastopen -u8 rcv_tos -u8 convert_csum -int uc_index -int mc_index -be32 mc_addr -struct ip_mc_socklist* mc_list -struct inet_cork_full cork read_mostly __tcp_transmit_skb -struct local_port_range -======================= ===================== =================== =================== ====================================================================================================== +======================== ===================== =================== =================== ====================================================================================================== +Type Name fastpath_tx_access fastpath_rx_access comment +======================== ===================== =================== =================== ====================================================================================================== +struct sock sk read_mostly read_mostly tcp_init_buffer_space,tcp_init_transfer,tcp_finish_connect,tcp_connect,tcp_send_rcvq,tcp_send_syn_data +struct ipv6_pinfo* pinet6 +struct ipv6_fl_socklist* ipv6_fl_list read_mostly tcp_v6_connect,__ip6_datagram_connect,udpv6_sendmsg,rawv6_sendmsg +be16 inet_sport read_mostly __tcp_transmit_skb +be32 inet_daddr read_mostly ip_select_ident_segs +be32 inet_rcv_saddr +be16 inet_dport read_mostly __tcp_transmit_skb +u16 inet_num +be32 inet_saddr +s16 uc_ttl read_mostly __ip_queue_xmit/ip_select_ttl +u16 cmsg_flags +struct ip_options_rcu* inet_opt read_mostly __ip_queue_xmit +u16 inet_id read_mostly ip_select_ident_segs +u8 tos read_mostly ip_queue_xmit +u8 min_ttl +u8 mc_ttl +u8 pmtudisc +u8:1 recverr +u8:1 is_icsk +u8:1 freebind +u8:1 hdrincl +u8:1 mc_loop +u8:1 transparent +u8:1 mc_all +u8:1 nodefrag +u8:1 bind_address_no_port +u8:1 recverr_rfc4884 +u8:1 defer_connect read_mostly tcp_sendmsg_fastopen +u8 rcv_tos +u8 convert_csum +int uc_index +int mc_index +be32 mc_addr +struct ip_mc_socklist* mc_list +struct inet_cork_full cork read_mostly __tcp_transmit_skb +struct local_port_range +======================== ===================== =================== =================== ======================================================================================================
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c +2 -2
@@ -1199,12 +1199,12 @@ static struct sock *chtls_recv_sock(struct sock *lsk,struct ipv6_pinfo *newnp =inet6_sk (newsk);struct ipv6_pinfo *np =inet6_sk (lsk); -inet_sk (newsk)->pinet6 = &newtcp6sk->inet6; + newinet->pinet6 = &newtcp6sk->inet6; + newinet->ipv6_fl_list =NULL ;memcpy (newnp, np,sizeof (struct ipv6_pinfo )); newsk->sk_v6_daddr = treq->ir_v6_rmt_addr; newsk->sk_v6_rcv_saddr = treq->ir_v6_loc_addr;inet6_sk (newsk)->saddr = treq->ir_v6_loc_addr; - newnp->ipv6_fl_list =NULL ; newnp->pktoptions =NULL ; newsk->sk_bound_dev_if = treq->ir_iif; newinet->inet_opt =NULL ;
include/linux/ipv6.h +0 -1
@@ -271,7 +271,6 @@ struct ipv6_pinfo {struct ipv6_mc_socklist __rcu *ipv6_mc_list;struct ipv6_ac_socklist *ipv6_ac_list; -struct ipv6_fl_socklist __rcu *ipv6_fl_list; };/* We currently use available bits from inet_sk(sk)->inet_flags,
include/net/inet_sock.h +1 -0
@@ -214,6 +214,7 @@ struct inet_sock {struct sock sk;#if IS_ENABLED (CONFIG_IPV6 )struct ipv6_pinfo *pinet6; +struct ipv6_fl_socklist __rcu *ipv6_fl_list;#endif /* Socket demultiplex comparisons on incoming packets. */ #define inet_daddr sk.__sk_common.skc_daddr
net/ipv6/ip6_flowlabel.c +21 -23
141 lines not on this page · raw message
net/ipv6/tcp_ipv6.c +7 -6
@@ -1387,7 +1387,9 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *if (!newsk)return NULL ; -inet_sk (newsk)->pinet6 =tcp_inet6_sk (newsk); + newinet =inet_sk (newsk); + newinet->pinet6 =tcp_inet6_sk (newsk); + newinet->ipv6_fl_list =NULL ; newnp =tcp_inet6_sk (newsk); newtp =tcp_sk (newsk);
@@ -1406,7 +1408,6 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff * newnp->ipv6_mc_list =NULL ; newnp->ipv6_ac_list =NULL ; - newnp->ipv6_fl_list =NULL ; newnp->pktoptions =NULL ; newnp->opt =NULL ; newnp->mcast_oif =inet_iif (skb);
@@ -1454,10 +1455,12 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff * newsk->sk_gso_type =SKB_GSO_TCPV6 ;inet6_sk_rx_dst_set (newsk, skb); -inet_sk (newsk)->pinet6 =tcp_inet6_sk (newsk); + newinet =inet_sk (newsk); + newinet->pinet6 =tcp_inet6_sk (newsk); + newinet->ipv6_fl_list =NULL ; + newinet->inet_opt =NULL ; newtp =tcp_sk (newsk); - newinet =inet_sk (newsk); newnp =tcp_inet6_sk (newsk);memcpy (newnp, np,sizeof (struct ipv6_pinfo ));
@@ -1470,10 +1473,8 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *First: no IPv4 options. */ - newinet->inet_opt =NULL ; newnp->ipv6_mc_list =NULL ; newnp->ipv6_ac_list =NULL ; - newnp->ipv6_fl_list =NULL ;/* Clone RX bits */ newnp->rxopt.all = np->rxopt.all;
net/sctp/ipv6.c +5 -3
@@ -782,9 +782,10 @@ static struct sock *sctp_v6_create_accept_sk(struct sock *sk, struct sctp_association *asoc, bool kern) { -struct sock *newsk;struct ipv6_pinfo *newnp, *np =inet6_sk (sk);struct sctp6_sock *newsctp6sk; +struct inet_sock *newinet; +struct sock *newsk; newsk =sk_alloc (sock_net (sk),PF_INET6 ,GFP_KERNEL , sk->sk_prot, kern);if (!newsk)
@@ -796,7 +797,9 @@ static struct sock *sctp_v6_create_accept_sk(struct sock *sk,sock_reset_flag (sk,SOCK_ZAPPED ); newsctp6sk = (struct sctp6_sock *)newsk; -inet_sk (newsk)->pinet6 = &newsctp6sk->inet6; + newinet =inet_sk (newsk); + newinet->pinet6 = &newsctp6sk->inet6; + newinet->ipv6_fl_list =NULL ;sctp_sk (newsk)->v4mapped =sctp_sk (sk)->v4mapped;
@@ -805,7 +808,6 @@ static struct sock *sctp_v6_create_accept_sk(struct sock *sk,memcpy (newnp, np,sizeof (struct ipv6_pinfo )); newnp->ipv6_mc_list =NULL ; newnp->ipv6_ac_list =NULL ; - newnp->ipv6_fl_list =NULL ;sctp_v6_copy_ip_options (sk, newsk);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 402/752 tcp: fix potential race in tcp_v6_syn_recv_sock()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 858d2a4f67ff69e645a43487ef7ea7f28f06deae ]
Code in tcp_v6_syn_recv_sock() after the call to tcp_v4_syn_recv_sock() is done too late.
After tcp_v4_syn_recv_sock(), the child socket is already visible from TCP ehash table and other cpus might use it.
Since newinet->pinet6 is still pointing to the listener ipv6_pinfo bad things can happen as syzbot found.
Move the problematic code in tcp_v6_mapped_child_init() and call this new helper from tcp_v4_syn_recv_sock() before the ehash insertion.
This allows the removal of one tcp_sync_mss(), since tcp_v4_syn_recv_sock() will call it with the correct context.
--- include/net/inet_connection_sock.h | 4 +- include/net/tcp.h | 4 +- net/ipv4/syncookies.c | 2 +- net/ipv4/tcp_fastopen.c | 2 +- net/ipv4/tcp_ipv4.c | 8 ++- net/ipv4/tcp_minisocks.c | 2 +- net/ipv6/tcp_ipv6.c | 98 +++++++++++++----------------- net/mptcp/subflow.c | 6 +- net/smc/af_smc.c | 6 +- 9 files changed, 66 insertions(+), 66 deletions(-)
include/net/inet_connection_sock.h +3 -1
@@ -42,7 +42,9 @@ struct inet_connection_sock_af_ops {struct request_sock *req, struct dst_entry *dst, struct request_sock *req_unhash, - bool *own_req); + bool *own_req, + void (*opt_child_init)(struct sock *newsk, + const struct sock *sk));u16 net_header_len;int (*setsockopt)(struct sock *sk,int level,int optname,sockptr_t optval,unsigned int optlen);
include/net/tcp.h +3 -1
@@ -528,7 +528,9 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,struct request_sock *req, struct dst_entry *dst, struct request_sock *req_unhash, - bool *own_req); + bool *own_req, + void (*opt_child_init)(struct sock *newsk, + const struct sock *sk));int tcp_v4_do_rcv (struct sock *sk,struct sk_buff *skb);int tcp_v4_connect (struct sock *sk,struct sockaddr *uaddr,int addr_len);int tcp_connect (struct sock *sk);
net/ipv4/syncookies.c +1 -1
@@ -203,7 +203,7 @@ struct sock *tcp_get_cookie_sock(struct sock *sk, struct sk_buff *skb,bool own_req; child = icsk->icsk_af_ops->syn_recv_sock (sk, skb, req, dst, -NULL , &own_req); +NULL , &own_req,NULL );if (child) {refcount_set (&req->rsk_refcnt,1 );sock_rps_save_rxhash (child, skb);
net/ipv4/tcp_fastopen.c +1 -1
@@ -247,7 +247,7 @@ static struct sock *tcp_fastopen_create_child(struct sock *sk,bool own_req; child =inet_csk (sk)->icsk_af_ops->syn_recv_sock (sk, skb, req,NULL , -NULL , &own_req); +NULL , &own_req,NULL );if (!child)return NULL ;
net/ipv4/tcp_ipv4.c +7 -1
@@ -1756,7 +1756,9 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,struct request_sock *req, struct dst_entry *dst, struct request_sock *req_unhash, - bool *own_req) + bool *own_req, + void (*opt_child_init)(struct sock *newsk, + const struct sock *sk)) { struct inet_request_sock *ireq;bool found_dup_sk = false;
@@ -1808,6 +1810,10 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, }sk_setup_caps (newsk, dst); +#if IS_ENABLED (CONFIG_IPV6 ) +if (opt_child_init) +opt_child_init (newsk, sk); +#endif tcp_ca_openreq_child (newsk, dst);tcp_sync_mss (newsk,dst_mtu (dst));
net/ipv4/tcp_minisocks.c +1 -1
@@ -911,7 +911,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,* socket is created, wait for troubles. */ child =inet_csk (sk)->icsk_af_ops->syn_recv_sock (sk, skb, req,NULL , - req, &own_req); + req, &own_req,NULL );if (!child) goto listen_overflow;
net/ipv6/tcp_ipv6.c +42 -56
114 lines not on this page · raw message
net/mptcp/subflow.c +4 -2
@@ -807,7 +807,9 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,struct request_sock *req, struct dst_entry *dst, struct request_sock *req_unhash, - bool *own_req) + bool *own_req, + void (*opt_child_init)(struct sock *newsk, + const struct sock *sk)) { struct mptcp_subflow_context *listener = mptcp_subflow_ctx(sk);struct mptcp_subflow_request_sock *subflow_req;
@@ -854,7 +856,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, create_child: child = listener->icsk_af_ops->syn_recv_sock (sk, skb, req, dst, - req_unhash, own_req); + req_unhash, own_req, opt_child_init);if (child && *own_req) {struct mptcp_subflow_context *ctx =mptcp_subflow_ctx (child);
net/smc/af_smc.c +4 -2
@@ -124,7 +124,9 @@ static struct sock *smc_tcp_syn_recv_sock(const struct sock *sk,struct request_sock *req, struct dst_entry *dst, struct request_sock *req_unhash, - bool *own_req) + bool *own_req, + void (*opt_child_init)(struct sock *newsk, + const struct sock *sk)) { struct smc_sock *smc;struct sock *child;
@@ -142,7 +144,7 @@ static struct sock *smc_tcp_syn_recv_sock(const struct sock *sk,/* passthrough to original syn recv sock fct */ child = smc->ori_af_ops->syn_recv_sock (sk, skb, req, dst, req_unhash, - own_req); + own_req, opt_child_init);/* child must not inherit smc or its ops */ if (child) {rcu_assign_sk_user_data (child,NULL );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 403/752 psp: use sk->sk_hash in psp_write_headers()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit f891007ab1c77436950d10e09eae54507f1865ff ]
udp_flow_src_port() is indirectly using sk->sk_txhash as a base, because __tcp_transmit_skb() uses skb_set_hash_from_sk().
This is problematic because this field can change over the lifetime of a TCP flow, thanks to calls to sk_rethink_txhash().
Problem is that some NIC might (ab)use the PSP UDP source port in their RSS computation, and PSP packets for a given flow could jump from one queue to another.
In order to avoid surprises, it is safer to let Protective Load Balancing (PLB) get its entropy from the IPv6 flowlabel, and change psp_write_headers() to use sk->sk_hash which does not change for the duration of the flow.
We might add a sysctl to select the behavior, if there is a need for it.
--- net/psp/psp_main.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)
net/psp/psp_main.c +38 -1
@@ -165,9 +165,46 @@ static void psp_write_headers(struct net *net, struct sk_buff *skb, __be32 spi, {struct udphdr *uh =udp_hdr (skb);struct psphdr *psph = (struct psphdr *)(uh +1 ); +const struct sock *sk = skb->sk; uh->dest =htons (PSP_DEFAULT_UDP_PORT ); - uh->source =udp_flow_src_port (net, skb,0 ,0 , false); + +/* A bit of theory: Selection of the source port. +* +* We need some entropy, so that multiple flows use different +* source ports for better RSS spreading at the receiver. +* +* We also need that all packets belonging to one TCP flow +* use the same source port through their duration, +* so that all these packets land in the same receive queue. +* +* udp_flow_src_port() is using sk_txhash, inherited from +* skb_set_hash_from_sk() call in __tcp_transmit_skb(). +* This field is subject to reshuffling, thanks to +* sk_rethink_txhash() calls in various TCP functions. +* +* Instead, use sk->sk_hash which is constant through +* the whole flow duration. +*/ +if (likely (sk)) { +u32 hash = sk->sk_hash; +int min, max; + +/* These operations are cheap, no need to cache the result +* in another socket field. +*/ +inet_get_local_port_range (net, &min, &max); +/* Since this is being sent on the wire obfuscate hash a bit +* to minimize possibility that any useful information to an +* attacker is leaked. Only upper 16 bits are relevant in the +* computation for 16 bit port value because we use a +* reciprocal divide. +*/ + hash ^= hash <<16 ; + uh->source =htons ((((u64 )hash * (max - min)) >>32 ) + min); + }else { + uh->source =udp_flow_src_port (net, skb,0 ,0 , false); + } uh->check =0 ; uh->len =htons (udp_len);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 404/752 espintcp: Fix race condition in espintcp_close()
In reply to Sasha LevinFrom: Hyunwoo Kim <[email protected]>
[ Upstream commit e1512c1db9e8794d8d130addd2615ec27231d994 ]
This issue was discovered during a code audit.
After cancel_work_sync() is called from espintcp_close(), espintcp_tx_work() can still be scheduled from paths such as the Delayed ACK handler or ksoftirqd.
As a result, the espintcp_tx_work() worker may dereference a freed espintcp ctx or sk.
The following is a simple race scenario:
cpu0 cpu1
espintcp_close()
cancel_work_sync(&ctx->work);
espintcp_write_space()
schedule_work(&ctx->work);To prevent this race condition, cancel_work_sync() is replaced with disable_work_sync().
--- net/xfrm/espintcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/xfrm/espintcp.c +1 -1
@@ -536,7 +536,7 @@ static void espintcp_close(struct sock *sk, long timeout) sk->sk_prot = &tcp_prot;barrier (); -cancel_work_sync (&ctx->work); +disable_work_sync (&ctx->work);strp_done (&ctx->strp);skb_queue_purge (&ctx->out_queue);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 405/752 net: usb: kaweth: remove TX queue manipulation in kaweth_set_rx_mode
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 64868f5ecadeb359a49bc4485bfa7c497047f13a ]
kaweth_set_rx_mode(), the ndo_set_rx_mode callback, calls netif_stop_queue() and netif_wake_queue(). These are TX queue flow control functions unrelated to RX multicast configuration.
The premature netif_wake_queue() can re-enable TX while tx_urb is still in-flight, leading to a double usb_submit_urb() on the same URB:
kaweth_start_xmit() {
netif_stop_queue();
usb_submit_urb(kaweth->tx_urb);
}kaweth_set_rx_mode() {
netif_stop_queue();
netif_wake_queue(); // wakes TX queue before URB is done
}kaweth_start_xmit() {
netif_stop_queue();
usb_submit_urb(kaweth->tx_urb); // URB submitted while active
}This triggers the WARN in usb_submit_urb():
"URB submitted while active"
This is a similar class of bug fixed in rtl8150 by
- commit 958baf5eaee3 ("net: usb: Remove disruptive netif_wake_queue in rtl8150_set_multicast").
Also kaweth_set_rx_mode() is already functionally broken, the real set_rx_mode action is performed by kaweth_async_set_rx_mode(), which in turn is not a no-op only at ndo_open() time.
--- drivers/net/usb/kaweth.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/usb/kaweth.c +0 -2
@@ -765,7 +765,6 @@ static void kaweth_set_rx_mode(struct net_device *net)netdev_dbg (net,"Setting Rx mode to %d\n" , packet_filter_bitmap); -netif_stop_queue (net);if (net->flags &IFF_PROMISC ) { packet_filter_bitmap |=KAWETH_PACKET_FILTER_PROMISCUOUS ;
@@ -775,7 +774,6 @@ static void kaweth_set_rx_mode(struct net_device *net) } kaweth->packet_filter_bitmap = packet_filter_bitmap; -netif_wake_queue (net); }/****************************************************************
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 406/752 net: usb: lan78xx: scan all MDIO addresses on LAN7801
In reply to Sasha LevinFrom: Martin Pålsson <[email protected]>
[ Upstream commit f1e2f0ce704e4a14e3f367d3b97d3dd2d8e183b7 ]
The LAN7801 is designed exclusively for external PHYs (unlike the LAN7800/LAN7850 which have internal PHYs), but lan78xx_mdio_init() restricts PHY scanning to MDIO addresses 0-7 by setting phy_mask to ~(0xFF). This prevents discovery of external PHYs wired to addresses outside that range.
One such case is the DP83TC814 100BASE-T1 PHY, which is typically configured at MDIO address 10 via PHYAD bootstrap pins and goes undetected with the current mask.
Remove the restrictive phy_mask assignment for the LAN7801 so that the default mask of 0 applies, allowing all 32 MDIO addresses to be scanned during bus registration.
--- drivers/net/usb/lan78xx.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/usb/lan78xx.c +0 -2
@@ -2094,8 +2094,6 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev) dev->mdiobus->phy_mask = ~(1 <<1 );break ;case ID_REV_CHIP_ID_7801_ : -/* scan thru PHYAD[2..0] */ - dev->mdiobus->phy_mask = ~(0xFF );break ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 407/752 proc: Fix pointer error dereference
In reply to Sasha LevinFrom: Ethan Tidmore <[email protected]>
[ Upstream commit f6a495484a27150fb85f943e1a7464da88c2a797 ]
The function try_lookup_noperm() can return an error pointer. Add check for error pointer.
Detected by Smatch:fs/proc/base.c:2148 proc_fill_cache() error:
'child' dereferencing possible ERR_PTR()
--- fs/proc/base.c | 3 +++ 1 file changed, 3 insertions(+)
fs/proc/base.c +3 -0
@@ -2128,6 +2128,9 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,ino_t ino =1 ; child =try_lookup_noperm (&qname, dir); +if (IS_ERR (child)) + goto end_instantiate; +if (!child) {DECLARE_WAIT_QUEUE_HEAD_ONSTACK (wq); child =d_alloc_parallel (dir, &qname, &wq);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 408/752 net: phy: qcom: qca807x: normalize return value of gpio_get
In reply to Sasha LevinFrom: Dmitry Torokhov <[email protected]>
[ Upstream commit 2bb995e6155cb4f254574598cbd6fe1dcc99766a ]
The GPIO get callback is expected to return 0 or 1 (or a negative error code). Ensure that the value returned by qca807x_gpio_get() is normalized to the [0, 1] range.
--- drivers/net/phy/qcom/qca807x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/qcom/qca807x.c +1 -1
@@ -375,7 +375,7 @@ static int qca807x_gpio_get(struct gpio_chip *gc, unsigned int offset) reg =QCA807X_MMD7_LED_FORCE_CTRL (offset); val =phy_read_mmd (priv->phy,MDIO_MMD_AN , reg); -return FIELD_GET (QCA807X_GPIO_FORCE_MODE_MASK , val); +return !!FIELD_GET (QCA807X_GPIO_FORCE_MODE_MASK , val); }static int qca807x_gpio_set (struct gpio_chip *gc,unsigned int offset,int value)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 409/752 net: ethernet: xscale: Check for PTP support properly
In reply to Sasha LevinFrom: Linus Walleij <[email protected]>
[ Upstream commit 594163ea88a03bdb412063af50fc7177ef3cbeae ]
In ixp4xx_get_ts_info() ixp46x_ptp_find() is called unconditionally despite this feature only existing on ixp46x, leading to the following splat from tcpdump:
root@OpenWrt:~# tcpdump -vv -X -i eth0 (...) Unable to handle kernel NULL pointer dereference at virtual address 00000238 when read (...) Call trace: ptp_clock_index from ixp46x_ptp_find+0x1c/0x38 ixp46x_ptp_find from ixp4xx_get_ts_info+0x4c/0x64 ixp4xx_get_ts_info from __ethtool_get_ts_info+0x90/0x108 __ethtool_get_ts_info from __dev_ethtool+0xa00/0x2648 __dev_ethtool from dev_ethtool+0x160/0x234 dev_ethtool from dev_ioctl+0x2cc/0x460 dev_ioctl from sock_ioctl+0x1ec/0x524 sock_ioctl from sys_ioctl+0x51c/0xa94 sys_ioctl from ret_fast_syscall+0x0/0x44 (...) Segmentation fault
Check for ixp46x in ixp46x_ptp_find() before trying to set up PTP to avoid this.
To avoid altering the returned error code from ixp4xx_hwtstamp_set() which before this patch was -EOPNOTSUPP, we return -EOPNOTSUPP from ixp4xx_hwtstamp_set() if ixp46x_ptp_find() fails no matter the error code. The helper function ixp46x_ptp_find() helper returns -ENODEV.
--- drivers/net/ethernet/xscale/ixp4xx_eth.c | 5 +---- drivers/net/ethernet/xscale/ptp_ixp46x.c | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/xscale/ixp4xx_eth.c +1 -4
@@ -403,15 +403,12 @@ static int ixp4xx_hwtstamp_set(struct net_device *netdev,int ret;int ch; -if (!cpu_is_ixp46x ()) -return -EOPNOTSUPP ; -if (!netif_running (netdev))return -EINVAL ; ret =ixp46x_ptp_find (&port->timesync_regs, &port->phc_index);if (ret) -return ret; +return -EOPNOTSUPP ; ch =PORT2CHANNEL (port); regs = port->timesync_regs;
drivers/net/ethernet/xscale/ptp_ixp46x.c +3 -0
@@ -232,6 +232,9 @@ static struct ixp_clock ixp_clock;int ixp46x_ptp_find (struct ixp46x_ts_regs *__iomem *regs,int *phc_index) { +if (!cpu_is_ixp46x ()) +return -ENODEV ; + *regs = ixp_clock.regs; *phc_index =ptp_clock_index (ixp_clock.ptp_clock);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 410/752 udplite: Fix null-ptr-deref in __udp_enqueue_schedule_skb().
In reply to Sasha LevinFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 470c7ca2b4c3e3a51feeb952b7f97a775b5c49cd ]
syzbot reported null-ptr-deref of udp_sk(sk)->udp_prod_queue. [0]
Since the cited commit, udp_lib_init_sock() can fail, as can udp_init_sock() and udpv6_init_sock().
Let's handle the error in udplite_sk_init() and udplitev6_sk_init().
[0]:
BUG: KASAN: null-ptr-deref in instrument_atomic_read include/linux/instrumented.h:82 [inline] BUG: KASAN: null-ptr-deref in atomic_read include/linux/atomic/atomic-instrumented.h:32 [inline] BUG: KASAN: null-ptr-deref in __udp_enqueue_schedule_skb+0x151/0x1480 net/ipv4/udp.c:1719 Read of size 4 at addr 0000000000000008 by task syz.2.18/2944 CPU: 1 UID: 0 PID: 2944 Comm: syz.2.18 Not tainted syzkaller #0 PREEMPTLAZY Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/25/2025 Call Trace: <IRQ> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 kasan_report+0xa2/0xe0 mm/kasan/report.c:595 check_region_inline mm/kasan/generic.c:-1 [inline] kasan_check_range+0x264/0x2c0 mm/kasan/generic.c:200 instrument_atomic_read include/linux/instrumented.h:82 [inline] atomic_read include/linux/atomic/atomic-instrumented.h:32 [inline] __udp_enqueue_schedule_skb+0x151/0x1480 net/ipv4/udp.c:1719 __udpv6_queue_rcv_skb net/ipv6/udp.c:795 [inline] udpv6_queue_rcv_one_skb+0xa2e/0x1ad0 net/ipv6/udp.c:906 udp6_unicast_rcv_skb+0x227/0x380 net/ipv6/udp.c:1064 ip6_protocol_deliver_rcu+0xe17/0x1540 net/ipv6/ip6_input.c:438 ip6_input_finish+0x191/0x350 net/ipv6/ip6_input.c:489 NF_HOOK+0x354/0x3f0 include/linux/netfilter.h:318 ip6_input+0x16c/0x2b0 net/ipv6/ip6_input.c:500 NF_HOOK+0x354/0x3f0 include/linux/netfilter.h:318 __netif_receive_skb_one_core net/core/dev.c:6149 [inline] __netif_receive_skb+0xd3/0x370 net/core/dev.c:6262 process_backlog+0x4d6/0x1160 net/core/dev.c:6614 __napi_poll+0xae/0x320 net/core/dev.c:7678 napi_poll net/core/dev.c:7741 [inline] net_rx_action+0x60d/0xdc0 net/core/dev.c:7893 handle_softirqs+0x209/0x8d0 kernel/softirq.c:622 do_softirq+0x52/0x90 kernel/softirq.c:523 </IRQ> <TASK> __local_bh_enable_ip+0xe7/0x120 kernel/softirq.c:450 local_bh_enable include/linux/bottom_half.h:33 [inline] rcu_read_unlock_bh include/linux/rcupdate.h:924 [inline] __dev_queue_xmit+0x109c/0x2dc0 net/core/dev.c:4856 __ip6_finish_output net/ipv6/ip6_output.c:-1 [inline] ip6_finish_output+0x158/0x4e0 net/ipv6/ip6_output.c:219 NF_HOOK_COND include/linux/netfilter.h:307 [inline] ip6_output+0x342/0x580 net/ipv6/ip6_output.c:246 ip6_send_skb+0x1d7/0x3c0 net/ipv6/ip6_output.c:1984 udp_v6_send_skb+0x9a5/0x1770 net/ipv6/udp.c:1442 udp_v6_push_pending_frames+0xa2/0x140 net/ipv6/udp.c:1469 udpv6_sendmsg+0xfe0/0x2830 net/ipv6/udp.c:1759 sock_sendmsg_nosec net/socket.c:727 [inline] __sock_sendmsg+0xe5/0x270 net/socket.c:742 __sys_sendto+0x3eb/0x580 net/socket.c:2206 __do_sys_sendto net/socket.c:2213 [inline] __se_sys_sendto net/socket.c:2209 [inline] __x64_sys_sendto+0xde/0x100 net/socket.c:2209 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xd2/0xf20 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7f67b4d9c629 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f67b5c98028 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 00007f67b5015fa0 RCX: 00007f67b4d9c629 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003 RBP: 00007f67b4e32b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000040000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f67b5016038 R14: 00007f67b5015fa0 R15: 00007ffe3cb66dd8 </TASK>
--- net/ipv4/udplite.c | 3 +-- net/ipv6/udplite.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
net/ipv4/udplite.c +1 -2
@@ -20,10 +20,9 @@ EXPORT_SYMBOL(udplite_table);/* Designate sk as UDP-Lite socket */ static int udplite_sk_init (struct sock *sk) { -udp_init_sock (sk);pr_warn_once ("UDP-Lite is deprecated and scheduled to be removed in 2025, " "please contact the netdev mailing list\n" ); -return 0 ; +return udp_init_sock (sk); }static int udplite_rcv (struct sk_buff *skb)
net/ipv6/udplite.c +1 -2
@@ -16,10 +16,9 @@static int udplitev6_sk_init (struct sock *sk) { -udpv6_init_sock (sk);pr_warn_once ("UDP-Lite is deprecated and scheduled to be removed in 2025, " "please contact the netdev mailing list\n" ); -return 0 ; +return udpv6_init_sock (sk); }static int udplitev6_rcv (struct sk_buff *skb)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 411/752 bnxt_en: Fix RSS context delete logic
In reply to Sasha LevinFrom: Pavan Chebbi <[email protected]>
[ Upstream commit e123d9302d223767bd910bfbcfe607bae909f8ac ]
We need to free the corresponding RSS context VNIC in FW everytime an RSS context is deleted in driver. Commit 667ac333dbb7 added a check to delete the VNIC in FW only when netif_running() is true to help delete RSS contexts with interface down.
Having that condition will make the driver leak VNICs in FW whenever close() happens with active RSS contexts. On the subsequent open(), as part of RSS context restoration, we will end up trying to create extra VNICs for which we did not make any reservation. FW can fail this request, thereby making us lose active RSS contexts.
Suppose an RSS context is deleted already and we try to process a delete request again, then the HWRM functions will check for validity of the request and they simply return if the resource is already freed. So, even for delete-when-down cases, netif_running() check is not necessary.
Remove the netif_running() condition check when deleting an RSS context.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -6
@@ -10809,12 +10809,10 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,struct bnxt_ntuple_filter *ntp_fltr;int i; -if (netif_running (bp->dev)) { -bnxt_hwrm_vnic_free_one (bp, &rss_ctx->vnic); -for (i =0 ; i <BNXT_MAX_CTX_PER_VNIC ; i++) { -if (vnic->fw_rss_cos_lb_ctx[i] !=INVALID_HW_RING_ID ) -bnxt_hwrm_vnic_ctx_free_one (bp, vnic, i); - } +bnxt_hwrm_vnic_free_one (bp, &rss_ctx->vnic); +for (i =0 ; i <BNXT_MAX_CTX_PER_VNIC ; i++) { +if (vnic->fw_rss_cos_lb_ctx[i] !=INVALID_HW_RING_ID ) +bnxt_hwrm_vnic_ctx_free_one (bp, vnic, i); }if (!all)return ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 412/752 bnxt_en: Fix deleting of Ntuple filters
In reply to Sasha LevinFrom: Pavan Chebbi <[email protected]>
[ Upstream commit c1bbd9900d65ac65b9fce9f129e3369a04871570 ]
Ntuple filters can be deleted when the interface is down. The current code blindly sends the filter delete command to FW. When the interface is down, all the VNICs are deleted in the FW. When the VNIC is freed in the FW, all the associated filters are also freed. We need not send the free command explicitly. Sending such command will generate FW error in the dmesg.
In order to fix this, we can safely return from bnxt_hwrm_cfa_ntuple_filter_free() when BNXT_STATE_OPEN is not true which confirms the VNICs have been deleted.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +3 -0
@@ -6201,6 +6201,9 @@ int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp,int rc;set_bit (BNXT_FLTR_FW_DELETED , &fltr->base.state); +if (!test_bit (BNXT_STATE_OPEN , &bp->state)) +return 0 ; + rc =hwrm_req_init (bp, req,HWRM_CFA_NTUPLE_FILTER_FREE );if (rc)return rc;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 413/752 ovpn: tcp - fix packet extraction from stream
In reply to Sasha LevinFrom: Ralf Lici <[email protected]>
[ Upstream commit d4f687fbbce45b5e88438e89b5e26c0c15847992 ]
When processing TCP stream data in ovpn_tcp_recv, we receive large cloned skbs from __strp_rcv that may contain multiple coalesced packets. The current implementation has two bugs:
1. Header offset overflow: Using pskb_pull with large offsets on coalesced skbs causes skb->data - skb->head to exceed the u16 storage of skb->network_header. This causes skb_reset_network_header to fail on the inner decapsulated packet, resulting in packet drops.
2. Unaligned protocol headers: Extracting packets from arbitrary positions within the coalesced TCP stream provides no alignment guarantees for the packet data causing performance penalties on architectures without efficient unaligned access. Additionally, openvpn's 2-byte length prefix on TCP packets causes the subsequent 4-byte opcode and packet ID fields to be inherently misaligned.
Fix both issues by allocating a new skb for each openvpn packet and using skb_copy_bits to extract only the packet content into the new buffer, skipping the 2-byte length prefix. Also, check the length before invoking the function that performs the allocation to avoid creating an invalid skb.
If the packet has to be forwarded to userspace the 2-byte prefix can be pushed to the head safely, without misalignment.
As a side effect, this approach also avoids the expensive linearization that pskb_pull triggers on cloned skbs with page fragments. In testing, this resulted in TCP throughput improvements of up to 74%.
--- drivers/net/ovpn/tcp.c | 53 ++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 17 deletions(-)
drivers/net/ovpn/tcp.c +36 -17
@@ -70,37 +70,56 @@ static void ovpn_tcp_to_userspace(struct ovpn_peer *peer, struct sock *sk, peer->tcp.sk_cb.sk_data_ready (sk); } -static void ovpn_tcp_rcv (struct strparser *strp,struct sk_buff *skb) +static struct sk_buff *ovpn_tcp_skb_packet (const struct ovpn_peer *peer, +struct sk_buff *orig_skb, +const int pkt_len,const int pkt_off) { - struct ovpn_peer *peer = container_of(strp, struct ovpn_peer, tcp.strp); -struct strp_msg *msg =strp_msg (skb); -size_t pkt_len = msg->full_len -2 ; -size_t off = msg->offset +2 ; -u8 opcode; +struct sk_buff *ovpn_skb; +int err; -/* ensure skb->data points to the beginning of the openvpn packet */ -if (!pskb_pull (skb, off)) { -net_warn_ratelimited ("%s: packet too small for peer %u\n" , -netdev_name (peer->ovpn->dev), peer->id); +/* create a new skb with only the content of the current packet */ + ovpn_skb =netdev_alloc_skb (peer->ovpn->dev, pkt_len); +if (unlikely (!ovpn_skb)) goto err; - } -/* strparser does not trim the skb for us, therefore we do it now */ -if (pskb_trim (skb, pkt_len) !=0 ) { -net_warn_ratelimited ("%s: trimming skb failed for peer %u\n" , +skb_copy_header (ovpn_skb, orig_skb); + err =skb_copy_bits (orig_skb, pkt_off,skb_put (ovpn_skb, pkt_len), + pkt_len); +if (unlikely (err)) { +net_warn_ratelimited ("%s: skb_copy_bits failed for peer %u\n" ,netdev_name (peer->ovpn->dev), peer->id); +kfree_skb (ovpn_skb); goto err; } -/* we need the first 4 bytes of data to be accessible +consume_skb (orig_skb); +return ovpn_skb; +err: +kfree_skb (orig_skb); +return NULL ; +} + +static void ovpn_tcp_rcv (struct strparser *strp,struct sk_buff *skb) +{ + struct ovpn_peer *peer = container_of(strp, struct ovpn_peer, tcp.strp); +struct strp_msg *msg =strp_msg (skb); +int pkt_len = msg->full_len -2 ; +u8 opcode; + +/* we need at least 4 bytes of data in the packet * to extract the opcode and the key ID later on */ -if (!pskb_may_pull (skb,OVPN_OPCODE_SIZE )) { +if (unlikely (pkt_len <OVPN_OPCODE_SIZE )) {net_warn_ratelimited ("%s: packet too small to fetch opcode for peer %u\n" ,netdev_name (peer->ovpn->dev), peer->id); goto err; } +/* extract the packet into a new skb */ + skb =ovpn_tcp_skb_packet (peer, skb, pkt_len, msg->offset +2 ); +if (unlikely (!skb)) + goto err; +/* DATA_V2 packets are handled in kernel, the rest goes to user space */ opcode =ovpn_opcode_from_skb (skb,0 );if (unlikely (opcode !=OVPN_DATA_V2 )) {
@@ -113,7 +132,7 @@ static void ovpn_tcp_rcv(struct strparser *strp, struct sk_buff *skb)/* The packet size header must be there when sending the packet * to userspace, therefore we put it back */ -skb_push (skb,2 ); + *(__be16 *)__skb_push (skb,sizeof (u16)) =htons (pkt_len);ovpn_tcp_to_userspace (peer, strp->sk, skb);return ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 414/752 ksmbd: fix signededness bug in smb_direct_prepare_negotiation()
In reply to Sasha LevinFrom: Nicholas Carlini <[email protected]>
[ Upstream commit 6b4f875aac344cdd52a1f34cc70ed2f874a65757 ]
smb_direct_prepare_negotiation() casts an unsigned __u32 value from sp->max_recv_size and req->preferred_send_size to a signed int before computing min_t(int, ...). A maliciously provided preferred_send_size of 0x80000000 will return as smaller than max_recv_size, and then be used to set the maximum allowed alowed receive size for the next message.
By sending a second message with a large value (>1420 bytes) the attacker can then achieve a heap buffer overflow.
This fix replaces min_t(int, ...) with min_t(u32)
--- fs/smb/server/transport_rdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/server/transport_rdma.c +2 -2
@@ -2414,9 +2414,9 @@ static int smb_direct_prepare(struct ksmbd_transport *t) goto put; req = (struct smbdirect_negotiate_req *)recvmsg->packet; - sp->max_recv_size =min_t (int, sp->max_recv_size, + sp->max_recv_size =min_t (u32, sp->max_recv_size,le32_to_cpu (req->preferred_send_size)); - sp->max_send_size =min_t (int, sp->max_send_size, + sp->max_send_size =min_t (u32, sp->max_send_size,le32_to_cpu (req->max_receive_size)); sp->max_fragmented_send_size =le32_to_cpu (req->max_fragmented_size);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 415/752 dma-mapping: avoid random addr value print out on error path
In reply to Sasha LevinFrom: Jiri Pirko <[email protected]>
[ Upstream commit 47322c469d4a63ac45b705ca83680671ff71c975 ]
dma_addr is unitialized in dma_direct_map_phys() when swiotlb is forced and DMA_ATTR_MMIO is set which leads to random value print out in warning. Fix that by just returning DMA_MAPPING_ERROR.
--- kernel/dma/direct.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/dma/direct.h +1 -1
@@ -88,7 +88,7 @@ static inline dma_addr_t dma_direct_map_phys(struct device *dev,if (is_swiotlb_force_bounce (dev)) {if (attrs &DMA_ATTR_MMIO ) - goto err_overflow; +return DMA_MAPPING_ERROR ;return swiotlb_map (dev, phys, size, dir, attrs); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 416/752 wifi: cfg80211: wext: fix IGTK key ID off-by-one
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit c8d7f21ead727485ebf965e2b4d42d4a4f0840f6 ]
The IGTK key ID must be 4 or 5, but the code checks against key ID + 1, so must check against 5/6 rather than 4/5. Fix that.
--- net/wireless/wext-compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/wext-compat.c +1 -1
@@ -684,7 +684,7 @@ static int cfg80211_wext_siwencodeext(struct net_device *dev, idx = erq->flags &IW_ENCODE_INDEX ;if (cipher ==WLAN_CIPHER_SUITE_AES_CMAC ) { -if (idx <4 || idx >5 ) { +if (idx <5 || idx >6 ) { idx = wdev->wext.default_mgmt_key;if (idx <0 )return -EINVAL ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 417/752 wifi: brcmfmac: Fix potential kernel oops when probe fails
In reply to Sasha LevinFrom: Marek Szyprowski <[email protected]>
[ Upstream commit 243307a0d1b0d01538e202c00454c28b21d4432e ]
When probe of the sdio brcmfmac device fails for some reasons (i.e. missing firmware), the sdiodev->bus is set to error instead of NULL, thus the cleanup later in brcmf_sdio_remove() tries to free resources via invalid bus pointer. This happens because sdiodev->bus is set 2 times:
first in brcmf_sdio_probe() and second time in brcmf_sdiod_probe(). Fix this by chaning the brcmf_sdio_probe() function to return the error code and set sdio->bus only there.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 7 +++---- drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 7 ++++--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c +3 -4
@@ -951,11 +951,10 @@ int brcmf_sdiod_probe(struct brcmf_sdio_dev *sdiodev) goto out;/* try to attach to the target device */ - sdiodev->bus =brcmf_sdio_probe (sdiodev); -if (IS_ERR (sdiodev->bus)) { - ret =PTR_ERR (sdiodev->bus); + ret =brcmf_sdio_probe (sdiodev); +if (ret) goto out; - } +brcmf_sdiod_host_fixup (sdiodev->func2->card->host); out:if (ret)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +4 -3
@@ -4445,7 +4445,7 @@ brcmf_sdio_prepare_fw_request(struct brcmf_sdio *bus)return fwreq; } -struct brcmf_sdio *brcmf_sdio_probe (struct brcmf_sdio_dev *sdiodev) +int brcmf_sdio_probe (struct brcmf_sdio_dev *sdiodev) {int ret;struct brcmf_sdio *bus;
@@ -4551,11 +4551,12 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) goto fail; } -return bus; +return 0 ; fail:brcmf_sdio_remove (bus); -return ERR_PTR (ret); + sdiodev->bus =NULL ; +return ret; }/* Detach and free everything */
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h +1 -1
@@ -358,7 +358,7 @@ void brcmf_sdiod_freezer_uncount(struct brcmf_sdio_dev *sdiodev);int brcmf_sdiod_probe (struct brcmf_sdio_dev *sdiodev);int brcmf_sdiod_remove (struct brcmf_sdio_dev *sdiodev); -struct brcmf_sdio *brcmf_sdio_probe (struct brcmf_sdio_dev *sdiodev); +int brcmf_sdio_probe (struct brcmf_sdio_dev *sdiodev);void brcmf_sdio_remove (struct brcmf_sdio *bus);void brcmf_sdio_isr (struct brcmf_sdio *bus,bool in_isr);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 418/752 Remove WARN_ALL_UNSEEDED_RANDOM kernel config option
In reply to Sasha LevinFrom: Linus Torvalds <[email protected]>
[ Upstream commit 7dff99b354601dd01829e1511711846e04340a69 ]
This config option goes way back - it used to be an internal debug option to random.c (at that point called DEBUG_RANDOM_BOOT), then was renamed and exposed as a config option as CONFIG_WARN_UNSEEDED_RANDOM, and then further renamed to the current CONFIG_WARN_ALL_UNSEEDED_RANDOM.
It was all done with the best of intentions: the more limited rate-limited reports were reporting some cases, but if you wanted to see all the gory details, you'd enable this "ALL" option.
However, it turns out - perhaps not surprisingly - that when people don't care about and fix the first rate-limited cases, they most certainly don't care about any others either, and so warning about all of them isn't actually helping anything.
And the non-ratelimited reporting causes problems, where well-meaning people enable debug options, but the excessive flood of messages that nobody cares about will hide actual real information when things go wrong.
I just got a kernel bug report (which had nothing to do with randomness) where two thirds of the the truncated dmesg was just variations of
random: get_random_u32 called from __get_random_u32_below+0x10/0x70 with crng_init=0
and in the process early boot messages had been lost (in addition to making the messages that _hadn't_ been lost harder to read).
The proper way to find these things for the hypothetical developer that cares - if such a person exists - is almost certainly with boot time tracing. That gives you the option to get call graphs etc too, which is likely a requirement for fixing any problems anyway.
See Documentation/trace/boottime-trace.rst for that option.
And if we for some reason do want to re-introduce actual printing of these things, it will need to have some uniqueness filtering rather than this "just print it all" model.
--- drivers/char/random.c | 12 +----------- kernel/configs/debug.config | 1 - lib/Kconfig.debug | 27 --------------------------- 3 files changed, 1 insertion(+), 39 deletions(-)
drivers/char/random.c +1 -11
@@ -96,8 +96,7 @@ static ATOMIC_NOTIFIER_HEAD(random_ready_notifier);/* Control how we warn userspace. */ static struct ratelimit_state urandom_warning =RATELIMIT_STATE_INIT_FLAGS ("urandom_warning" ,HZ ,3 ,RATELIMIT_MSG_ON_RELEASE ); -static int ratelimit_disable__read_mostly = -IS_ENABLED (CONFIG_WARN_ALL_UNSEEDED_RANDOM ); +static int ratelimit_disable__read_mostly =0 ;module_param_named (ratelimit_disable, ratelimit_disable, int,0644 );MODULE_PARM_DESC (ratelimit_disable,"Disable random ratelimit suppression" );
@@ -168,12 +167,6 @@ int __cold execute_with_initialized_rng(struct notifier_block *nb)return ret; } -#define warn_unseeded_randomness () \ - if (IS_ENABLED(CONFIG_WARN_ALL_UNSEEDED_RANDOM) && !crng_ready()) \ - printk_deferred(KERN_NOTICE "random: %s called from %pS with crng_init=%d\n", \ - __func__, (void *)_RET_IP_, crng_init) - -/********************************************************************* * * Fast key erasure RNG, the "crng".
@@ -434,7 +427,6 @@ static void _get_random_bytes(void *buf, size_t len)*/ void get_random_bytes (void *buf,size_t len) { -warn_unseeded_randomness ();_get_random_bytes (buf, len); }EXPORT_SYMBOL (get_random_bytes);
@@ -523,8 +515,6 @@ type get_random_ ##type(void) \ struct batch_ ##type *batch; \unsigned long next_gen ; \ \ - warn_unseeded_randomness(); \ - \if (!crng_ready ()) { \_get_random_bytes (&ret,sizeof (ret )); \return ret; \
kernel/configs/debug.config +0 -1
@@ -29,7 +29,6 @@ CONFIG_SECTION_MISMATCH_WARN_ONLY=y # CONFIG_UBSAN_ALIGNMENT is not set # CONFIG_UBSAN_DIV_ZERO is not set # CONFIG_UBSAN_TRAP is not set -# CONFIG_WARN_ALL_UNSEEDED_RANDOM is not set CONFIG_DEBUG_FS=y CONFIG_DEBUG_FS_ALLOW_ALL=y CONFIG_DEBUG_IRQFLAGS=y
lib/Kconfig.debug +0 -27
@@ -1684,33 +1684,6 @@ config STACKTRACE It is also used by various kernel debugging features that require stack trace generation. -config WARN_ALL_UNSEEDED_RANDOM - bool "Warn for all uses of unseeded randomness" - default n - help - Some parts of the kernel contain bugs relating to their use of - cryptographically secure random numbers before it's actually possible - to generate those numbers securely. This setting ensures that these - flaws don't go unnoticed, by enabling a message, should this ever - occur. This will allow people with obscure setups to know when things - are going wrong, so that they might contact developers about fixing - it. - - Unfortunately, on some models of some architectures getting - a fully seeded CRNG is extremely difficult, and so this can - result in dmesg getting spammed for a surprisingly long - time. This is really bad from a security perspective, and - so architecture maintainers really need to do what they can - to get the CRNG seeded sooner after the system is booted. - However, since users cannot do anything actionable to - address this, by default this option is disabled. - - Say Y here if you want to receive warnings for all uses of - unseeded randomness. This will be of use primarily for - those developers interested in improving the security of - Linux kernels running on their architecture (or - subarchitecture). - config DEBUG_KOBJECT bool "kobject debugging" depends on DEBUG_KERNEL
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 419/752 Bluetooth: L2CAP: Fix invalid response to L2CAP_ECRED_RECONF_REQ
In reply to Sasha LevinFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 7accb1c4321acb617faf934af59d928b0b047e2b ]
This fixes responding with an invalid result caused by checking the wrong size of CID which should have been (cmd_len - sizeof(*req)) and on top of it the wrong result was use L2CAP_CR_LE_INVALID_PARAMS which is invalid/reserved for reconf when running test like L2CAP/ECFC/BI-03-C:
Quoted 1 line
ACL Data RX: Handle 64 flags
0x02dlen 14
LE L2CAP: Enhanced Credit Reconfigure Request (0x19) ident 2 len 6
MTU: 64
MPS: 64
Source CID: 64
< ACL Data TX: Handle 64 flags 0x00 dlen 10
LE L2CAP: Enhanced Credit Reconfigure Respond (0x1a) ident 2 len 2
! Result: Reserved (0x000c)
Result: Reconfiguration failed - one or more Destination CIDs invalid (0x0003)Fiix L2CAP/ECFC/BI-04-C which expects L2CAP_RECONF_INVALID_MPS (0x0002) when more than one channel gets its MPS reduced:
Quoted 1 line
ACL Data RX: Handle 64 flags
0x02dlen 16
LE L2CAP: Enhanced Credit Reconfigure Request (0x19) ident 2 len 8
MTU: 264
MPS: 99
Source CID: 64
! Source CID: 65
< ACL Data TX: Handle 64 flags 0x00 dlen 10
LE L2CAP: Enhanced Credit Reconfigure Respond (0x1a) ident 2 len 2
! Result: Reconfiguration successful (0x0000)
Result: Reconfiguration failed - reduction in size of MPS not allowed for more than one channel at a time (0x0002)Fix L2CAP/ECFC/BI-05-C when SCID is invalid (85 unconnected):
Quoted 1 line
ACL Data RX: Handle 64 flags
0x02dlen 14
LE L2CAP: Enhanced Credit Reconfigure Request (0x19) ident 2 len 6
MTU: 65
MPS: 64
! Source CID: 85
< ACL Data TX: Handle 64 flags 0x00 dlen 10
LE L2CAP: Enhanced Credit Reconfigure Respond (0x1a) ident 2 len 2
! Result: Reconfiguration successful (0x0000)
Result: Reconfiguration failed - one or more Destination CIDs invalid (0x0003)Fix L2CAP/ECFC/BI-06-C when MPS < L2CAP_ECRED_MIN_MPS (64):
Quoted 1 line
ACL Data RX: Handle 64 flags
0x02dlen 14
LE L2CAP: Enhanced Credit Reconfigure Request (0x19) ident 2 len 6
MTU: 672
! MPS: 63
Source CID: 64
< ACL Data TX: Handle 64 flags 0x00 dlen 10
LE L2CAP: Enhanced Credit Reconfigure Respond (0x1a) ident 2 len 2
! Result: Reconfiguration failed - reduction in size of MPS not allowed for more than one channel at a time (0x0002)
Result: Reconfiguration failed - other unacceptable parameters (0x0004)Fix L2CAP/ECFC/BI-07-C when MPS reduced for more than one channel:
Quoted 1 line
ACL Data RX: Handle 64 flags
0x02dlen 16
LE L2CAP: Enhanced Credit Reconfigure Request (0x19) ident 3 len 8
MTU: 84! MPS: 71
Source CID: 64
! Source CID: 65
< ACL Data TX: Handle 64 flags 0x00 dlen 10
LE L2CAP: Enhanced Credit Reconfigure Respond (0x1a) ident 2 len 2
! Result: Reconfiguration successful (0x0000)
Result: Reconfiguration failed - reduction in size of MPS not allowed for more than one channel at a time (0x0002)--- include/net/bluetooth/l2cap.h | 2 ++ net/bluetooth/l2cap_core.c | 63 +++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 18 deletions(-)
include/net/bluetooth/l2cap.h +2 -0
@@ -493,6 +493,8 @@ struct l2cap_ecred_reconf_req {#define L2CAP_RECONF_SUCCESS 0x0000#define L2CAP_RECONF_INVALID_MTU 0x0001#define L2CAP_RECONF_INVALID_MPS 0x0002 +#define L2CAP_RECONF_INVALID_CID 0x0003 +#define L2CAP_RECONF_INVALID_PARAMS 0x0004struct l2cap_ecred_reconf_rsp {__le16 result;
net/bluetooth/l2cap_core.c +45 -18
101 lines not on this page · raw message
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 420/752 Bluetooth: L2CAP: Fix result of L2CAP_ECRED_CONN_RSP when MTU is too short
In reply to Sasha LevinFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit c28d2bff70444a85b3b86aaf241ece9408c7858c ]
Test L2CAP/ECFC/BV-26-C expect the response to L2CAP_ECRED_CONN_REQ with and MTU value < L2CAP_ECRED_MIN_MTU (64) to be L2CAP_CR_LE_INVALID_PARAMS rather than L2CAP_CR_LE_UNACCEPT_PARAMS.
Also fix not including the correct number of CIDs in the response since the spec requires all CIDs being rejected to be included in the response.
--- include/net/bluetooth/l2cap.h | 6 +++--- net/bluetooth/l2cap_core.c | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-)
include/net/bluetooth/l2cap.h +3 -3
@@ -284,9 +284,9 @@ struct l2cap_conn_rsp {#define L2CAP_CR_LE_BAD_KEY_SIZE 0x0007#define L2CAP_CR_LE_ENCRYPTION 0x0008#define L2CAP_CR_LE_INVALID_SCID 0x0009 -#define L2CAP_CR_LE_SCID_IN_USE 0X000A -#define L2CAP_CR_LE_UNACCEPT_PARAMS 0X000B -#define L2CAP_CR_LE_INVALID_PARAMS 0X000C +#define L2CAP_CR_LE_SCID_IN_USE 0x000A +#define L2CAP_CR_LE_UNACCEPT_PARAMS 0x000B +#define L2CAP_CR_LE_INVALID_PARAMS 0x000C/* connect/create channel status */ #define L2CAP_CS_NO_INFO 0x0000
net/bluetooth/l2cap_core.c +8 -6
@@ -5035,13 +5035,15 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,struct l2cap_chan *chan, *pchan;u16 mtu, mps;__le16 psm; -u8 result, len =0 ; +u8 result, rsp_len =0 ;int i, num_scid;bool defer = false;if (!enable_ecred)return -EINVAL ; +memset (pdu,0 ,sizeof (*pdu)); +if (cmd_len <sizeof (*req) || (cmd_len -sizeof (*req)) %sizeof (u16)) { result =L2CAP_CR_LE_INVALID_PARAMS ; goto response;
@@ -5050,6 +5052,9 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, cmd_len -=sizeof (*req); num_scid = cmd_len /sizeof (u16); +/* Always respond with the same number of scids as in the request */ + rsp_len = cmd_len; +if (num_scid >L2CAP_ECRED_MAX_CID ) { result =L2CAP_CR_LE_INVALID_PARAMS ; goto response;
@@ -5059,7 +5064,7 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, mps =__le16_to_cpu (req->mps);if (mtu <L2CAP_ECRED_MIN_MTU || mps <L2CAP_ECRED_MIN_MPS ) { - result =L2CAP_CR_LE_UNACCEPT_PARAMS ; + result =L2CAP_CR_LE_INVALID_PARAMS ; goto response; }
@@ -5079,8 +5084,6 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,BT_DBG ("psm 0x%2.2x mtu %u mps %u" ,__le16_to_cpu (psm), mtu, mps); -memset (pdu,0 ,sizeof (*pdu)); -/* Check if we have socket listening on psm */ pchan =l2cap_global_chan_by_psm (BT_LISTEN , psm, &conn->hcon->src, &conn->hcon->dst,LE_LINK );
@@ -5105,7 +5108,6 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,BT_DBG ("scid[%d] 0x%4.4x" , i, scid); pdu->dcid[i] =0x0000 ; - len +=sizeof (*pdu->dcid);/* Check for valid dynamic CID range */ if (scid <L2CAP_CID_DYN_START || scid >L2CAP_CID_LE_DYN_END ) {
@@ -5172,7 +5174,7 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,return 0 ;l2cap_send_cmd (conn, cmd->ident,L2CAP_ECRED_CONN_RSP , -sizeof (*pdu) + len, pdu); +sizeof (*pdu) + rsp_len, pdu);return 0 ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 421/752 Bluetooth: hci_qca: Cleanup on all setup failures
In reply to Sasha LevinFrom: Jinwang Li <[email protected]>
[ Upstream commit 5c4e9a8b18457ad28b57069ef0f14661e3192b2e ]
The setup process previously combined error handling and retry gating under one condition. As a result, the final failed attempt exited without performing cleanup.
Update the failure path to always perform power and port cleanup on setup failure, and reopen the port only when retrying.
--- drivers/bluetooth/hci_qca.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/bluetooth/hci_qca.c +14 -10
@@ -2045,19 +2045,23 @@ static int qca_setup(struct hci_uart *hu) } out: -if (ret && retries <MAX_INIT_RETRIES ) { -bt_dev_warn (hdev,"Retry BT power ON:%d" , retries); +if (ret) {qca_power_shutdown (hu); -if (hu->serdev) { -serdev_device_close (hu->serdev); - ret =serdev_device_open (hu->serdev); -if (ret) { -bt_dev_err (hdev,"failed to open port" ); -return ret; + +if (retries <MAX_INIT_RETRIES ) { +bt_dev_warn (hdev,"Retry BT power ON:%d" , retries); +if (hu->serdev) { +serdev_device_close (hu->serdev); + ret =serdev_device_open (hu->serdev); +if (ret) { +bt_dev_err (hdev,"failed to open port" ); +return ret; + } } + retries++; + goto retry; } - retries++; - goto retry; +return ret; }/* Setup bdaddr */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 422/752 Bluetooth: L2CAP: Fix response to L2CAP_ECRED_CONN_REQ
In reply to Sasha LevinFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 05761c2c2b5bfec85c47f60c903c461e9b56cf87 ]
Similar to 03dba9cea72f ("Bluetooth: L2CAP: Fix not responding with L2CAP_CR_LE_ENCRYPTION") the result code L2CAP_CR_LE_ENCRYPTION shall be used when BT_SECURITY_MEDIUM is set since that means security mode 2 which mean it doesn't require authentication which results in qualification test L2CAP/ECFC/BV-32-C failing.
--- net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +2 -1
@@ -5096,7 +5096,8 @@ static inline int l2cap_ecred_conn_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 ; goto unlock; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 423/752 Bluetooth: L2CAP: Fix not checking output MTU is acceptable on L2CAP_ECRED_CONN_REQ
In reply to Sasha LevinFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit a8d1d73c81d1e70d2aa49fdaf59d933bb783ffe5 ]
Upon receiving L2CAP_ECRED_CONN_REQ the given MTU shall be checked against the suggested MTU of the listening socket as that is required by the likes of PTS L2CAP/ECFC/BV-27-C test which expects L2CAP_CR_LE_UNACCEPT_PARAMS if the MTU is lowers than socket omtu.
In order to be able to set chan->omtu the code now allows setting setsockopt(BT_SNDMTU), but it is only allowed when connection has not been stablished since there is no procedure to reconfigure the output MTU.
--- net/bluetooth/l2cap_core.c | 8 ++++++++ net/bluetooth/l2cap_sock.c | 15 +++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-)
net/bluetooth/l2cap_core.c +8 -0
@@ -5101,6 +5101,14 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, goto unlock; } +/* Check if the listening channel has set an output MTU then the +* requested MTU shall be less than or equal to that value. +*/ +if (pchan->omtu && mtu < pchan->omtu) { + result =L2CAP_CR_LE_UNACCEPT_PARAMS ; + goto unlock; + } + result =L2CAP_CR_LE_SUCCESS ;for (i =0 ; i < num_scid; i++) {
net/bluetooth/l2cap_sock.c +11 -4
@@ -1029,10 +1029,17 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,break ; } -/* Setting is not supported as it's the remote side that -* decides this. -*/ - err = -EPERM ; +/* Only allow setting output MTU when not connected */ +if (sk->sk_state ==BT_CONNECTED ) { + err = -EISCONN ; +break ; + } + + err =copy_safe_from_sockptr (&mtu,sizeof (mtu), optval, optlen); +if (err) +break ; + + chan->omtu = mtu;break ;case BT_RCVMTU :
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 424/752 Bluetooth: L2CAP: Fix missing key size check for L2CAP_LE_CONN_REQ
In reply to Sasha LevinFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 138d7eca445ef37a0333425d269ee59900ca1104 ]
This adds a check for encryption key size upon receiving L2CAP_LE_CONN_REQ which is required by L2CAP/LE/CFC/BV-15-C which expects L2CAP_CR_LE_BAD_KEY_SIZE.
--- net/bluetooth/l2cap_core.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/bluetooth/l2cap_core.c +7 -0
@@ -4900,6 +4900,13 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, goto response_unlock; } +/* Check if Key Size is sufficient for the security level */ +if (!l2cap_check_enc_key_size (conn->hcon, pchan)) { + result =L2CAP_CR_LE_BAD_KEY_SIZE ; + chan =NULL ; + goto response_unlock; + } +/* Check for valid dynamic CID range */ if (scid <L2CAP_CID_DYN_START || scid >L2CAP_CID_LE_DYN_END ) { result =L2CAP_CR_LE_INVALID_SCID ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 425/752 net: do not pass flow_id to set_rps_cpu()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 8a8a9fac9efa6423fd74938b940cb7d731780718 ]
Blamed commit made the assumption that the RPS table for each receive queue would have the same size, and that it would not change.
Compute flow_id in set_rps_cpu(), do not assume we can use the value computed by get_rps_cpu(). Otherwise we risk out-of-bound access and/or crashes.
--- net/core/dev.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
net/core/dev.c +5 -7
@@ -4932,8 +4932,7 @@ static bool rps_flow_is_active(struct rps_dev_flow *rflow,static struct rps_dev_flow *set_rps_cpu (struct net_device *dev,struct sk_buff *skb, -struct rps_dev_flow *rflow,u16 next_cpu,u32 hash, -u32 flow_id) +struct rps_dev_flow *rflow,u16 next_cpu,u32 hash) {if (next_cpu < nr_cpu_ids) {u32 head;
@@ -4944,6 +4943,7 @@ set_rps_cpu(struct net_device *dev, struct sk_buff *skb,struct rps_dev_flow *tmp_rflow;unsigned int tmp_cpu;u16 rxq_index; +u32 flow_id;int rc;/* Should we steer this flow to a different hardware queue? */
@@ -4959,6 +4959,7 @@ set_rps_cpu(struct net_device *dev, struct sk_buff *skb,if (!flow_table) goto out; + flow_id =rfs_slot (hash, flow_table); tmp_rflow = &flow_table->flows[flow_id]; tmp_cpu =READ_ONCE (tmp_rflow->cpu);
@@ -5006,7 +5007,6 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,struct rps_dev_flow_table *flow_table;struct rps_map *map;int cpu =-1 ; -u32 flow_id;u32 tcpu;u32 hash;
@@ -5053,8 +5053,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,/* OK, now we know there is a match, * we can look at the local (per receive queue) flow table */ - flow_id =rfs_slot (hash, flow_table); - rflow = &flow_table->flows[flow_id]; + rflow = &flow_table->flows[rfs_slot (hash, flow_table)]; tcpu = rflow->cpu;/*
@@ -5073,8 +5072,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb, ((int)(READ_ONCE(per_cpu(softnet_data, tcpu).input_queue_head) - rflow->last_qtail)) >= 0)) { tcpu = next_cpu; - rflow =set_rps_cpu (dev, skb, rflow, next_cpu, hash, - flow_id); + rflow =set_rps_cpu (dev, skb, rflow, next_cpu, hash); }if (tcpu < nr_cpu_ids &&cpu_online (tcpu)) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 426/752 tls: Fix race condition in tls_sw_cancel_work_tx()
In reply to Sasha LevinFrom: Hyunwoo Kim <[email protected]>
[ Upstream commit 7bb09315f93dce6acc54bf59e5a95ba7365c2be4 ]
This issue was discovered during a code audit.
After cancel_delayed_work_sync() is called from tls_sk_proto_close(), tx_work_handler() can still be scheduled from paths such as the Delayed ACK handler or ksoftirqd.
As a result, the tx_work_handler() worker may dereference a freed TLS object.
The following is a simple race scenario:
cpu0 cpu1
tls_sk_proto_close()
tls_sw_cancel_work_tx()
tls_write_space()
tls_sw_write_space()
if (!test_and_set_bit(BIT_TX_SCHEDULED, &tx_ctx->tx_bitmask))
set_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask);
cancel_delayed_work_sync(&ctx->tx_work.work);
schedule_delayed_work(&tx_ctx->tx_work.work, 0);To prevent this race condition, cancel_delayed_work_sync() is replaced with disable_delayed_work_sync().
--- net/tls/tls_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/tls/tls_sw.c +1 -1
@@ -2533,7 +2533,7 @@ void tls_sw_cancel_work_tx(struct tls_context *tls_ctx)set_bit (BIT_TX_CLOSING , &ctx->tx_bitmask);set_bit (BIT_TX_SCHEDULED , &ctx->tx_bitmask); -cancel_delayed_work_sync (&ctx->tx_work.work); +disable_delayed_work_sync (&ctx->tx_work.work); }void tls_sw_release_resources_tx (struct sock *sk)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 427/752 kcm: fix zero-frag skb in frag_list on partial sendmsg error
In reply to Sasha LevinFrom: Jiayuan Chen <[email protected]>
[ Upstream commit ca220141fa8ebae09765a242076b2b77338106b0 ]
Syzkaller reported a warning in kcm_write_msgs() when processing a message with a zero-fragment skb in the frag_list.
When kcm_sendmsg() fills MAX_SKB_FRAGS fragments in the current skb, it allocates a new skb (tskb) and links it into the frag_list before copying data. If the copy subsequently fails (e.g. -EFAULT from user memory), tskb remains in the frag_list with zero fragments:
head skb (msg being assembled, NOT yet in sk_write_queue)
+-----------+
| frags[17] | (MAX_SKB_FRAGS, all filled with data)
| frag_list-+--> tskb
+-----------+ +----------+
| frags[0] | (empty! copy failed before filling)
+----------+For SOCK_SEQPACKET with partial data already copied, the error path saves this message via partial_message for later completion. For SOCK_SEQPACKET, sock_write_iter() automatically sets MSG_EOR, so a subsequent zero-length write(fd, NULL, 0) completes the message and queues it to sk_write_queue. kcm_write_msgs() then walks the frag_list and hits:
WARN_ON(!skb_shinfo(skb)->nr_frags)
TCP has a similar pattern where skbs are enqueued before data copy and cleaned up on failure via tcp_remove_empty_skb(). KCM was missing the equivalent cleanup.
Fix this by tracking the predecessor skb (frag_prev) when allocating a new frag_list entry. On error, if the tail skb has zero frags, use frag_prev to unlink and free it in O(1) without walking the singly-linked frag_list. frag_prev is safe to dereference because the entire message chain is only held locally (or in kcm->seq_skb) and is not added to sk_write_queue until MSG_EOR, so the send path cannot free it underneath us.
Also change the WARN_ON to WARN_ON_ONCE to avoid flooding the log if the condition is somehow hit repeatedly.
There are currently no KCM selftests in the kernel tree; a simple reproducer is available at [1].
[1] https://gist.github.com/mrpre/a94d431c757e8d6f168f4dd1a3749daa
--- net/kcm/kcmsock.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
net/kcm/kcmsock.c +19 -2
@@ -628,7 +628,7 @@ static int kcm_write_msgs(struct kcm_sock *kcm) skb = txm->frag_skb; } -if (WARN_ON (!skb_shinfo (skb)->nr_frags) || +if (WARN_ON_ONCE (!skb_shinfo (skb)->nr_frags) ||WARN_ON_ONCE (!skb_frag_page (&skb_shinfo (skb)->frags[0 ]))) { ret = -EINVAL ; goto out;
@@ -749,7 +749,7 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) {struct sock *sk = sock->sk;struct kcm_sock *kcm =kcm_sk (sk); -struct sk_buff *skb =NULL , *head =NULL ; +struct sk_buff *skb =NULL , *head =NULL , *frag_prev =NULL ;size_t copy, copied =0 ;long timeo =sock_sndtimeo (sk, msg->msg_flags &MSG_DONTWAIT ); int eor = (sock->type == SOCK_DGRAM) ?
@@ -824,6 +824,7 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)else skb->next = tskb; + frag_prev = skb; skb = tskb; skb->ip_summed =CHECKSUM_UNNECESSARY ;continue ;
@@ -933,6 +934,22 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) out_error:kcm_push (kcm); +/* When MAX_SKB_FRAGS was reached, a new skb was allocated and +* linked into the frag_list before data copy. If the copy +* subsequently failed, this skb has zero frags. Remove it from +* the frag_list to prevent kcm_write_msgs from later hitting +* WARN_ON(!skb_shinfo(skb)->nr_frags). +*/ +if (frag_prev && !skb_shinfo (skb)->nr_frags) { +if (head == frag_prev) +skb_shinfo (head)->frag_list =NULL ; +else + frag_prev->next =NULL ; +kfree_skb (skb); +/* Update skb as it may be saved in partial_message via goto */ + skb = frag_prev; + } +if (sock->type ==SOCK_SEQPACKET ) {/* Wrote some bytes before encountering an * error, return partial success.
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 428/752 dpll: zl3073x: Cache reference monitor status
In reply to Sasha LevinFrom: Ivan Vecera <[email protected]>
[ Upstream commit 5534a8202d7cf9b2e4557517745583c43662b6a8 ]
Instead of reading the ZL_REG_REF_MON_STATUS register every time the reference status is needed, cache this value in the zl3073x_ref struct.
This is achieved by:
* Adding a mon_status field to struct zl3073x_ref
* Introducing zl3073x_dev_ref_status_update() to read the status for all references into this new cache field
* Calling this update function from the periodic work handler
* Adding zl3073x_ref_is_status_ok() and zl3073x_dev_ref_is_status_ok() helpers to check the cached value
* Refactoring all callers in dpll.c to use the new zl3073x_dev_ref_is_status_ok() helper, removing direct register reads
This change consolidates all status register reads into a single periodic function and reduces I/O bus traffic in dpll callbacks.
Stable-dep-of: 4cfe066a82cd ("dpll: zl3073x: fix REF_PHASE_OFFSET_COMP register width for some chip IDs")
--- drivers/dpll/zl3073x/core.c | 18 +++++++ drivers/dpll/zl3073x/core.h | 15 ++++++ drivers/dpll/zl3073x/dpll.c | 96 ++++++++----------------------------- drivers/dpll/zl3073x/ref.h | 14 ++++++ 4 files changed, 68 insertions(+), 75 deletions(-)
drivers/dpll/zl3073x/core.c +18 -0
@@ -591,6 +591,21 @@ zl3073x_dev_state_fetch(struct zl3073x_dev *zldev)return rc; } +static void +zl3073x_dev_ref_status_update (struct zl3073x_dev *zldev) +{ +int i, rc; + +for (i =0 ; i <ZL3073X_NUM_REFS ; i++) { + rc =zl3073x_read_u8 (zldev,ZL_REG_REF_MON_STATUS (i), + &zldev->ref[i].mon_status); +if (rc) +dev_warn (zldev->dev, +"Failed to get REF%u status: %pe\n" , i, +ERR_PTR (rc)); + } +} +/** * zl3073x_ref_phase_offsets_update - update reference phase offsets * @zldev: pointer to zl3073x_dev structure
@@ -710,6 +725,9 @@ zl3073x_dev_periodic_work(struct kthread_work *work)struct zl3073x_dpll *zldpll;int rc; +/* Update input references status */ +zl3073x_dev_ref_status_update (zldev); +/* Update DPLL-to-connected-ref phase offsets registers */ rc =zl3073x_ref_phase_offsets_update (zldev,-1 );if (rc)
drivers/dpll/zl3073x/core.h +15 -0
@@ -227,6 +227,21 @@ zl3073x_dev_ref_is_enabled(struct zl3073x_dev *zldev, u8 index)return zl3073x_ref_is_enabled (ref); } +/* +* zl3073x_dev_ref_is_status_ok - check the given input reference status +* @zldev: pointer to zl3073x device +* @index: input reference index +* +* Return: true if the status is ok, false otherwise +*/ +static inline bool +zl3073x_dev_ref_is_status_ok (struct zl3073x_dev *zldev,u8 index) +{ +const struct zl3073x_ref *ref =zl3073x_ref_state_get (zldev, index); + +return zl3073x_ref_is_status_ok (ref); +} +/** * zl3073x_dev_synth_dpll_get - get DPLL ID the synth is driven by * @zldev: pointer to zl3073x device
drivers/dpll/zl3073x/dpll.c +21 -75
154 lines not on this page · raw message
drivers/dpll/zl3073x/ref.h +14 -0
@@ -14,10 +14,12 @@ struct zl3073x_dev;* struct zl3073x_ref - input reference state * @ffo: current fractional frequency offset * @config: reference config +* @mon_status: reference monitor status */ struct zl3073x_ref {s64 ffo;u8 config; +u8 mon_status; };int zl3073x_ref_state_fetch (struct zl3073x_dev *zldev,u8 index);
@@ -63,4 +65,16 @@ zl3073x_ref_is_enabled(const struct zl3073x_ref *ref) return !!FIELD_GET(ZL_REF_CONFIG_ENABLE, ref->config); } +/** +* zl3073x_ref_is_status_ok - check the given input reference status +* @ref: pointer to ref state +* +* Return: true if the status is ok, false otherwise +*/ +static inline bool +zl3073x_ref_is_status_ok (const struct zl3073x_ref *ref) +{ +return ref->mon_status ==ZL_REF_MON_STATUS_OK ; +} +#endif /* _ZL3073X_REF_H */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 429/752 dpll: zl3073x: Cache all reference properties in zl3073x_ref
In reply to Sasha LevinFrom: Ivan Vecera <[email protected]>
[ Upstream commit 5bc02b190a3fb703bf8cadc4d778fc22cd4d1e78 ]
Expand the zl3073x_ref structure to cache all reference-related hardware registers, including frequency components, embedded-sync settings and phase compensation. Previously, these registers were read on-demand from various functions in dpll.c leading to frequent mailbox operations.
Modify zl3073x_ref_state_fetch() to read and populate all these new fields at once. Refactor all "getter" functions in dpll.c to read from this new cached state instead of performing direct register access.
Remove the standalone zl3073x_dpll_input_ref_frequency_get() helper, as its functionality is now replaced by zl3073x_ref_freq_get() which operates on the cached state and add a corresponding zl3073x_dev_... wrapper.
Introduce a new function, zl3073x_ref_state_set(), to handle writing changes back to the hardware. This function compares the provided state with the current cached state and writes *only* the modified register values to the device via a single mailbox sequence before updating the local cache.
Refactor all dpll "setter" functions to modify a local copy of the ref state and then call zl3073x_ref_state_set() to commit the changes.
As a cleanup, update callers in dpll.c that already have a struct zl3073x_ref * to use the direct helpers instead of the zl3073x_dev_... wrappers.
This change centralizes all reference-related register I/O into ref.c, significantly reduces bus traffic, and simplifies the logic in dpll.c.
Stable-dep-of: 4cfe066a82cd ("dpll: zl3073x: fix REF_PHASE_OFFSET_COMP register width for some chip IDs")
--- drivers/dpll/zl3073x/core.h | 15 ++ drivers/dpll/zl3073x/dpll.c | 308 +++++++++--------------------------- drivers/dpll/zl3073x/ref.c | 94 ++++++++++- drivers/dpll/zl3073x/ref.h | 54 +++++++ 4 files changed, 239 insertions(+), 232 deletions(-)
drivers/dpll/zl3073x/core.h +15 -0
@@ -197,6 +197,21 @@ zl3073x_dev_ref_ffo_get(struct zl3073x_dev *zldev, u8 index)return zl3073x_ref_ffo_get (ref); } +/** +* zl3073x_dev_ref_freq_get - get input reference frequency +* @zldev: pointer to zl3073x device +* @index: input reference index +* +* Return: frequency of given input reference +*/ +static inline u32 +zl3073x_dev_ref_freq_get (struct zl3073x_dev *zldev,u8 index) +{ +const struct zl3073x_ref *ref =zl3073x_ref_state_get (zldev, index); + +return zl3073x_ref_freq_get (ref); +} +/** * zl3073x_dev_ref_is_diff - check if the given input reference is differential * @zldev: pointer to zl3073x device
drivers/dpll/zl3073x/dpll.c +77 -231
461 lines not on this page · raw message
drivers/dpll/zl3073x/ref.c +93 -1
112 lines not on this page · raw message
drivers/dpll/zl3073x/ref.h +54 -0
84 lines not on this page · raw message
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 430/752 dpll: zl3073x: fix REF_PHASE_OFFSET_COMP register width for some chip IDs
In reply to Sasha LevinFrom: Ivan Vecera <[email protected]>
[ Upstream commit 4cfe066a82cdf9e83e48b16000f55280efc98325 ]
The REF_PHASE_OFFSET_COMP register is 48-bit wide on most zl3073x chip variants, but only 32-bit wide on chip IDs 0x0E30, 0x0E93..0x0E97 and 0x1F60. The driver unconditionally uses 48-bit read/write operations, which on 32-bit variants causes reading 2 bytes past the register boundary (corrupting the value) and writing 2 bytes into the adjacent register.
Fix this by storing the chip ID in the device structure during probe and adding a helper to detect the affected variants. Use the correct register width for read/write operations and the matching sign extension bit (31 vs 47) when interpreting the phase compensation value.
--- drivers/dpll/zl3073x/core.c | 1 + drivers/dpll/zl3073x/core.h | 28 ++++++++++++++++++++++++++++ drivers/dpll/zl3073x/dpll.c | 7 +++++-- drivers/dpll/zl3073x/ref.c | 25 ++++++++++++++++++++----- drivers/dpll/zl3073x/regs.h | 1 + 5 files changed, 55 insertions(+), 7 deletions(-)
drivers/dpll/zl3073x/core.c +1 -0
@@ -1023,6 +1023,7 @@ int zl3073x_dev_probe(struct zl3073x_dev *zldev,"Unknown or non-match chip ID: 0x%0x\n" , id); } + zldev->chip_id = id;/* Read revision, firmware version and custom config version */ rc =zl3073x_read_u16 (zldev,ZL_REG_REVISION , &revision);
drivers/dpll/zl3073x/core.h +28 -0
@@ -35,6 +35,7 @@ struct zl3073x_dpll;* @dev: pointer to device * @regmap: regmap to access device registers * @multiop_lock: to serialize multiple register operations +* @chip_id: chip ID read from hardware * @ref: array of input references' invariants * @out: array of outs' invariants * @synth: array of synths' invariants
@@ -48,6 +49,7 @@ struct zl3073x_dev {struct device *dev;struct regmap *regmap;struct mutex multiop_lock; +u16 chip_id;/* Invariants */ struct zl3073x_ref ref[ZL3073X_NUM_REFS ];
@@ -144,6 +146,32 @@ int zl3073x_write_hwreg_seq(struct zl3073x_dev *zldev,int zl3073x_ref_phase_offsets_update (struct zl3073x_dev *zldev,int channel); +/** +* zl3073x_dev_is_ref_phase_comp_32bit - check ref phase comp register size +* @zldev: pointer to zl3073x device +* +* Some chip IDs have a 32-bit wide ref_phase_offset_comp register instead +* of the default 48-bit. +* +* Return: true if the register is 32-bit, false if 48-bit +*/ +static inline bool +zl3073x_dev_is_ref_phase_comp_32bit (struct zl3073x_dev *zldev) +{ +switch (zldev->chip_id) { +case 0x0E30 : +case 0x0E93 : +case 0x0E94 : +case 0x0E95 : +case 0x0E96 : +case 0x0E97 : +case 0x1F60 : +return true; +default : +return false; + } +} +static inline bool zl3073x_is_n_pin (u8 id) {
drivers/dpll/zl3073x/dpll.c +5 -2
@@ -459,8 +459,11 @@ zl3073x_dpll_input_pin_phase_adjust_get(const struct dpll_pin *dpll_pin, ref_id =zl3073x_input_pin_ref_get (pin->id); ref =zl3073x_ref_state_get (zldev, ref_id); -/* Perform sign extension for 48bit signed value */ - phase_comp =sign_extend64 (ref->phase_comp,47 ); +/* Perform sign extension based on register width */ +if (zl3073x_dev_is_ref_phase_comp_32bit (zldev)) + phase_comp =sign_extend64 (ref->phase_comp,31 ); +else + phase_comp =sign_extend64 (ref->phase_comp,47 );/* Reverse two's complement negation applied during set and convert * to 32bit signed int
drivers/dpll/zl3073x/ref.c +20 -5
@@ -121,8 +121,16 @@ int zl3073x_ref_state_fetch(struct zl3073x_dev *zldev, u8 index)return rc;/* Read phase compensation register */ - rc =zl3073x_read_u48 (zldev,ZL_REG_REF_PHASE_OFFSET_COMP , - &ref->phase_comp); +if (zl3073x_dev_is_ref_phase_comp_32bit (zldev)) { +u32 val; + + rc =zl3073x_read_u32 (zldev,ZL_REG_REF_PHASE_OFFSET_COMP_32 , + &val); + ref->phase_comp = val; + }else { + rc =zl3073x_read_u48 (zldev,ZL_REG_REF_PHASE_OFFSET_COMP , + &ref->phase_comp); + }if (rc)return rc;
@@ -179,9 +187,16 @@ int zl3073x_ref_state_set(struct zl3073x_dev *zldev, u8 index,if (!rc && dref->sync_ctrl != ref->sync_ctrl) rc =zl3073x_write_u8 (zldev,ZL_REG_REF_SYNC_CTRL , ref->sync_ctrl); -if (!rc && dref->phase_comp != ref->phase_comp) - rc =zl3073x_write_u48 (zldev,ZL_REG_REF_PHASE_OFFSET_COMP , - ref->phase_comp); +if (!rc && dref->phase_comp != ref->phase_comp) { +if (zl3073x_dev_is_ref_phase_comp_32bit (zldev)) + rc =zl3073x_write_u32 (zldev, +ZL_REG_REF_PHASE_OFFSET_COMP_32 , + ref->phase_comp); +else + rc =zl3073x_write_u48 (zldev, +ZL_REG_REF_PHASE_OFFSET_COMP , + ref->phase_comp); + }if (rc)return rc;
drivers/dpll/zl3073x/regs.h +1 -0
@@ -194,6 +194,7 @@#define ZL_REF_CONFIG_DIFF_EN BIT(2)#define ZL_REG_REF_PHASE_OFFSET_COMP ZL_REG(10, 0x28, 6) +#define ZL_REG_REF_PHASE_OFFSET_COMP_32 ZL_REG(10, 0x28, 4)#define ZL_REG_REF_SYNC_CTRL ZL_REG(10, 0x2e, 1)#define ZL_REF_SYNC_CTRL_MODE GENMASK(2, 0)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 431/752 tipc: fix duplicate publication key in tipc_service_insert_publ()
In reply to Sasha LevinFrom: Tung Nguyen <[email protected]>
[ Upstream commit 3aa677625c8fad39989496c51bcff3872c1f16f1 ]
TIPC uses named table to store TIPC services represented by type and instance. Each time an application calls TIPC API bind() to bind a type/instance to a socket, an entry is created and inserted into the named table. It looks like this:
named table:
key1, entry1 (type, instance ...)
key2, entry2 (type, instance ...)
In the above table, each entry represents a route for sending data from one socket to the other. For all publications originated from the same node, the key is UNIQUE to identify each entry. It is calculated by this formula:
key = socket portid + number of bindings + 1 (1)
where:
- socket portid: unique and calculated by using linux kernel function get_random_u32_below(). So, the value is randomized.
- number of bindings: the number of times a type/instance pair is bound to a socket. This number is linearly increased, starting from 0.
While the socket portid is unique and randomized by linux kernel, the linear increment of "number of bindings" in formula (1) makes "key" not unique anymore. For example:
- Socket 1 is created with its associated port number 20062001. Type 1000, instance 1 is bound to socket 1:
key1: 20062001 + 0 + 1 = 20062002
Then, bind() is called a second time on Socket 1 to by the same type 1000, instance 1:
key2: 20062001 + 1 + 1 = 20062003
Named table:
key1 (20062002), entry1 (1000, 1 ...)
key2 (20062003), entry2 (1000, 1 ...)
- Socket 2 is created with its associated port number 20062002. Type 1000, instance 1 is bound to socket 2:
key3: 20062002 + 0 + 1 = 20062003
TIPC looks up the named table and finds out that key2 with the same value already exists and rejects the insertion into the named table. This leads to failure of bind() call from application on Socket 2 with error message EINVAL "Invalid argument".
This commit fixes this issue by adding more port id checking to make sure that the key is unique to publications originated from the same port id and node.
--- net/tipc/name_table.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/tipc/name_table.c +4 -2
@@ -348,7 +348,8 @@ static bool tipc_service_insert_publ(struct net *net,/* Return if the publication already exists */ list_for_each_entry (_p, &sr->all_publ, all_publ) { -if (_p->key == key && (!_p->sk.node || _p->sk.node == node)) { +if (_p->key == key && _p->sk.ref == p->sk.ref && + (!_p->sk.node || _p->sk.node == node)) {pr_debug ("Failed to bind duplicate %u,%u,%u/%u:%u/%u\n" , p->sr.type, p->sr.lower, p->sr.upper, node, p->sk.ref, key);
@@ -388,7 +389,8 @@ static struct publication *tipc_service_remove_publ(struct service_range *r,u32 node = sk->node;list_for_each_entry (p, &r->all_publ, all_publ) { -if (p->key != key || (node && node != p->sk.node)) +if (p->key != key || p->sk.ref != sk->ref || + (node && node != p->sk.node))continue ;list_del (&p->all_publ);list_del (&p->local_publ);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 432/752 RDMA/core: Fix stale RoCE GIDs during netdev events at registration
In reply to Sasha LevinFrom: Jiri Pirko <[email protected]>
[ Upstream commit 9af0feae8016ba58ad7ff784a903404986b395b1 ]
RoCE GID entries become stale when netdev properties change during the IB device registration window. This is reproducible with a udev rule that sets a MAC address when a VF netdev appears:
ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth4", \
RUN+="/sbin/ip link set eth4 address 88:22:33:44:55:66"After VF creation, show_gids displays GIDs derived from the original random MAC rather than the configured one.
The root cause is a race between netdev event processing and device registration:
CPU 0 (driver) CPU 1 (udev/workqueue)
────────────── ──────────────────────
ib_register_device()
ib_cache_setup_one()
gid_table_setup_one()
_gid_table_setup_one()
← GID table allocated
rdma_roce_rescan_device()
← GIDs populated with
OLD MAC
ip link set eth4 addr NEW_MAC NETDEV_CHANGEADDR queued netdevice_event_work_handler()
ib_enum_all_roce_netdevs()
← Iterates DEVICE_REGISTERED ← Device NOT marked yet, SKIP!
enable_device_and_get()
xa_set_mark(DEVICE_REGISTERED)
← Too late, event was lost
The netdev event handler uses ib_enum_all_roce_netdevs() which only iterates devices marked DEVICE_REGISTERED. However, this mark is set late in the registration process, after the GID cache is already populated. Events arriving in this window are silently dropped.
Fix this by introducing a new xarray mark DEVICE_GID_UPDATES that is set immediately after the GID table is allocated and initialized. Use the new mark in ib_enum_all_roce_netdevs() function to iterate devices instead of DEVICE_REGISTERED.
This is safe because:
- After _gid_table_setup_one(), all required structures exist (port_data, immutable, cache.gid)
- The GID table mutex serializes concurrent access between the initial rescan and event handlers
- Event handlers correctly update stale GIDs even when racing with rescan
- The mark is cleared in ib_cache_cleanup_one() before teardown
This also fixes similar races for IP address events (inetaddr_event, inet6addr_event) which use the same enumeration path.
--- drivers/infiniband/core/cache.c | 13 +++++++++++ drivers/infiniband/core/core_priv.h | 3 +++ drivers/infiniband/core/device.c | 34 ++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 1 deletion(-)
drivers/infiniband/core/cache.c +13 -0
@@ -927,6 +927,13 @@ static int gid_table_setup_one(struct ib_device *ib_dev)if (err)return err; +/* +* Mark the device as ready for GID cache updates. This allows netdev +* event handlers to update the GID cache even before the device is +* fully registered. +*/ +ib_device_enable_gid_updates (ib_dev); +rdma_roce_rescan_device (ib_dev);return err;
@@ -1639,6 +1646,12 @@ void ib_cache_release_one(struct ib_device *device)void ib_cache_cleanup_one (struct ib_device *device) { +/* +* Clear the GID updates mark first to prevent event handlers from +* accessing the device while it's being torn down. +*/ +ib_device_disable_gid_updates (device); +/* The cleanup function waits for all in-progress workqueue * elements and cleans up the GID cache. This function should be * called after the device was removed from the devices list and
drivers/infiniband/core/core_priv.h +3 -0
@@ -100,6 +100,9 @@ void ib_enum_all_roce_netdevs(roce_netdev_filter filter,roce_netdev_callback cb, void *cookie); +void ib_device_enable_gid_updates (struct ib_device *device); +void ib_device_disable_gid_updates (struct ib_device *device); + typedef int (*nldev_callback)(struct ib_device *device, struct sk_buff *skb, struct netlink_callback *cb,
drivers/infiniband/core/device.c +33 -1
@@ -93,6 +93,7 @@ static struct workqueue_struct *ib_unreg_wq; static DEFINE_XARRAY_FLAGS(devices, XA_FLAGS_ALLOC);static DECLARE_RWSEM (devices_rwsem);#define DEVICE_REGISTERED XA_MARK_1 +#define DEVICE_GID_UPDATES XA_MARK_2static u32 highest_client_id;#define CLIENT_REGISTERED XA_MARK_1
@@ -2441,11 +2442,42 @@ void ib_enum_all_roce_netdevs(roce_netdev_filter filter,unsigned long index;down_read (&devices_rwsem); - xa_for_each_marked (&devices, index, dev, DEVICE_REGISTERED) +xa_for_each_marked (&devices, index, dev,DEVICE_GID_UPDATES )ib_enum_roce_netdev (dev, filter, filter_cookie, cb, cookie);up_read (&devices_rwsem); } +/** +* ib_device_enable_gid_updates - Mark device as ready for GID cache updates +* @device: Device to mark +* +* Called after GID table is allocated and initialized. After this mark is set, +* netdevice event handlers can update the device's GID cache. This allows +* events that arrive during device registration to be processed, avoiding +* stale GID entries when netdev properties change during the device +* registration process. +*/ +void ib_device_enable_gid_updates (struct ib_device *device) +{ +down_write (&devices_rwsem); +xa_set_mark (&devices, device->index,DEVICE_GID_UPDATES ); +up_write (&devices_rwsem); +} + +/** +* ib_device_disable_gid_updates - Clear the GID updates mark +* @device: Device to unmark +* +* Called before GID table cleanup to prevent event handlers from accessing +* the device while it's being torn down. +*/ +void ib_device_disable_gid_updates (struct ib_device *device) +{ +down_write (&devices_rwsem); +xa_clear_mark (&devices, device->index,DEVICE_GID_UPDATES ); +up_write (&devices_rwsem); +} +/* * ib_enum_all_devs - enumerate all ib_devices * @cb: Callback to call for each found ib_device
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 433/752 net: wan: farsync: Fix use-after-free bugs caused by unfinished tasklets
In reply to Sasha LevinFrom: Duoming Zhou <[email protected]>
[ Upstream commit bae8a5d2e759da2e0cba33ab2080deee96a09373 ]
When the FarSync T-series card is being detached, the fst_card_info is deallocated in fst_remove_one(). However, the fst_tx_task or fst_int_task may still be running or pending, leading to use-after-free bugs when the already freed fst_card_info is accessed in fst_process_tx_work_q() or fst_process_int_work_q().
A typical race condition is depicted below:
CPU 0 (cleanup) | CPU 1 (tasklet)
| fst_start_xmit()
fst_remove_one() | tasklet_schedule()
unregister_hdlc_device()|
| fst_process_tx_work_q() //handler
kfree(card) //free | do_bottom_half_tx()
| card-> //useThe following KASAN trace was captured:
==================================================================
BUG: KASAN: slab-use-after-free in do_bottom_half_tx+0xb88/0xd00
Read of size 4 at addr ffff88800aad101c by task ksoftirqd/3/32
...
Call Trace:
<IRQ>
dump_stack_lvl+0x55/0x70
print_report+0xcb/0x5d0
? do_bottom_half_tx+0xb88/0xd00
kasan_report+0xb8/0xf0
? do_bottom_half_tx+0xb88/0xd00
do_bottom_half_tx+0xb88/0xd00
? _raw_spin_lock_irqsave+0x85/0xe0
? __pfx__raw_spin_lock_irqsave+0x10/0x10
? __pfx___hrtimer_run_queues+0x10/0x10
fst_process_tx_work_q+0x67/0x90
tasklet_action_common+0x1fa/0x720
? hrtimer_interrupt+0x31f/0x780
handle_softirqs+0x176/0x530
__irq_exit_rcu+0xab/0xe0
sysvec_apic_timer_interrupt+0x70/0x80
...
Allocated by task 41 on cpu 3 at 72.330843s:
kasan_save_stack+0x24/0x50
kasan_save_track+0x17/0x60
__kasan_kmalloc+0x7f/0x90
fst_add_one+0x1a5/0x1cd0
local_pci_probe+0xdd/0x190
pci_device_probe+0x341/0x480
really_probe+0x1c6/0x6a0
__driver_probe_device+0x248/0x310
driver_probe_device+0x48/0x210
__device_attach_driver+0x160/0x320
bus_for_each_drv+0x101/0x190
__device_attach+0x198/0x3a0
device_initial_probe+0x78/0xa0
pci_bus_add_device+0x81/0xc0
pci_bus_add_devices+0x7e/0x190
enable_slot+0x9b9/0x1130
acpiphp_check_bridge.part.0+0x2e1/0x460
acpiphp_hotplug_notify+0x36c/0x3c0
acpi_device_hotplug+0x203/0xb10
acpi_hotplug_work_fn+0x59/0x80
...
Freed by task 41 on cpu 1 at 75.138639s:
kasan_save_stack+0x24/0x50
kasan_save_track+0x17/0x60
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x43/0x70
kfree+0x135/0x410
fst_remove_one+0x2ca/0x540
pci_device_remove+0xa6/0x1d0
device_release_driver_internal+0x364/0x530
pci_stop_bus_device+0x105/0x150
pci_stop_and_remove_bus_device+0xd/0x20
disable_slot+0x116/0x260
acpiphp_disable_and_eject_slot+0x4b/0x190
acpiphp_hotplug_notify+0x230/0x3c0
acpi_device_hotplug+0x203/0xb10
acpi_hotplug_work_fn+0x59/0x80
...
The buggy address belongs to the object at ffff88800aad1000
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 28 bytes inside of
freed 1024-byte region
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xaad0
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x100000000000040(head|node=0|zone=1)
page_type: f5(slab)
raw: 0100000000000040 ffff888007042dc0 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080100010 00000000f5000000 0000000000000000
head: 0100000000000040 ffff888007042dc0 dead000000000122 0000000000000000
head: 0000000000000000 0000000080100010 00000000f5000000 0000000000000000
head: 0100000000000003 ffffea00002ab401 00000000ffffffff 00000000ffffffff
head: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88800aad0f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88800aad0f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88800aad1000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88800aad1080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88800aad1100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================Fix this by ensuring that both fst_tx_task and fst_int_task are properly canceled before the fst_card_info is released. Add tasklet_kill() in fst_remove_one() to synchronize with any pending or running tasklets. Since unregister_hdlc_device() stops data transmission and reception, and fst_disable_intr() prevents further interrupts, it is appropriate to place tasklet_kill() after these calls.
The bugs were identified through static analysis. To reproduce the issue and validate the fix, a FarSync T-series card was simulated in QEMU and delays(e.g., mdelay()) were introduced within the tasklet handler to increase the likelihood of triggering the race condition.
--- drivers/net/wan/farsync.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wan/farsync.c +2 -0
@@ -2550,6 +2550,8 @@ fst_remove_one(struct pci_dev *pdev)fst_disable_intr (card);free_irq (card->irq, card); +tasklet_kill (&fst_tx_task); +tasklet_kill (&fst_int_task);iounmap (card->ctlmem);iounmap (card->mem);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 434/752 netconsole: avoid OOB reads, msg is not nul-terminated
In reply to Sasha LevinFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 82aec772fca2223bc5774bd9af486fd95766e578 ]
msg passed to netconsole from the console subsystem is not guaranteed to be nul-terminated. Before recent
commit 7eab73b18630 ("netconsole: convert to NBCON console infrastructure") the message would be placed in printk_shared_pbufs, a static global buffer, so KASAN had harder time catching OOB accesses. Now we see:
printk: console [netcon_ext0] enabled
BUG: KASAN: slab-out-of-bounds in string+0x1f7/0x240
Read of size 1 at addr ffff88813b6d4c00 by task pr/netcon_ext0/594
CPU: 65 UID: 0 PID: 594 Comm: pr/netcon_ext0 Not tainted 6.19.0-11754-g4246fd6547c9
Call Trace:
kasan_report+0xe4/0x120
string+0x1f7/0x240
vsnprintf+0x655/0xba0
scnprintf+0xba/0x120
netconsole_write+0x3fe/0xa10
nbcon_emit_next_record+0x46e/0x860
nbcon_kthread_func+0x623/0x750
Allocated by task 1:
nbcon_alloc+0x1ea/0x450
register_console+0x26b/0xe10
init_netconsole+0xbb0/0xda0
The buggy address belongs to the object at ffff88813b6d4000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 0 bytes to the right of
allocated 3072-byte region [ffff88813b6d4000, ffff88813b6d4c00)--- drivers/net/netconsole.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/netconsole.c +2 -1
@@ -1537,7 +1537,8 @@ static void send_msg_no_fragmentation(struct netconsole_target *nt,if (release_len) { release =init_utsname ()->release; -scnprintf (nt->buf,MAX_PRINT_CHUNK ,"%s,%s" , release, msg); +scnprintf (nt->buf,MAX_PRINT_CHUNK ,"%s,%.*s" , release, + msg_len, msg); msg_len += release_len; }else {memcpy (nt->buf, msg, msg_len);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 435/752 RDMA/ionic: Fix potential NULL pointer dereference in ionic_query_port
In reply to Sasha LevinFrom: Kamal Heib <[email protected]>
[ Upstream commit fd80bd7105f88189f47d465ca8cb7d115570de30 ]
The function ionic_query_port() calls ib_device_get_netdev() without checking the return value which could lead to NULL pointer dereference, Fix it by checking the return value and return -ENODEV if the 'ndev' is NULL.
--- drivers/infiniband/hw/ionic/ionic_ibdev.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/ionic/ionic_ibdev.c +2 -0
@@ -81,6 +81,8 @@ static int ionic_query_port(struct ib_device *ibdev, u32 port,return -EINVAL ; ndev =ib_device_get_netdev (ibdev, port); +if (!ndev) +return -ENODEV ;if (netif_running (ndev) &&netif_carrier_ok (ndev)) { attr->state =IB_PORT_ACTIVE ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 436/752 RDMA/efa: Fix typo in efa_alloc_mr()
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit f22c77ce49db0589103d96487dca56f5b2136362 ]
The pattern is to check the entire driver request space, not just sizeof something unrelated.
--- drivers/infiniband/hw/efa/efa_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/efa/efa_verbs.c +1 -1
@@ -1663,7 +1663,7 @@ static struct efa_mr *efa_alloc_mr(struct ib_pd *ibpd, int access_flags,struct efa_mr *mr;if (udata && udata->inlen && - !ib_is_udata_cleared (udata,0 ,sizeof (udata->inlen))) { + !ib_is_udata_cleared (udata,0 , udata->inlen)) {ibdev_dbg (&dev->ibdev,"Incompatible ABI params, udata not cleared\n" );return ERR_PTR (-EINVAL );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 437/752 net: Drop the lock in skb_may_tx_timestamp()
In reply to Sasha LevinFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 983512f3a87fd8dc4c94dfa6b596b6e57df5aad7 ]
skb_may_tx_timestamp() may acquire sock::sk_callback_lock. The lock must not be taken in IRQ context, only softirq is okay. A few drivers receive the timestamp via a dedicated interrupt and complete the TX timestamp from that handler. This will lead to a deadlock if the lock is already write-locked on the same CPU.
Taking the lock can be avoided. The socket (pointed by the skb) will remain valid until the skb is released. The ->sk_socket and ->file member will be set to NULL once the user closes the socket which may happen before the timestamp arrives.
If we happen to observe the pointer while the socket is closing but before the pointer is set to NULL then we may use it because both pointer (and the file's cred member) are RCU freed.
Drop the lock. Use READ_ONCE() to obtain the individual pointer. Add a matching WRITE_ONCE() where the pointer are cleared.
--- include/net/sock.h | 2 +- net/core/skbuff.c | 23 ++++++++++++++++++----- net/socket.c | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-)
include/net/sock.h +1 -1
@@ -2067,7 +2067,7 @@ static inline int sk_rx_queue_get(const struct sock *sk)static inline void sk_set_socket (struct sock *sk,struct socket *sock) { - sk->sk_socket = sock; +WRITE_ONCE (sk->sk_socket, sock);if (sock) {WRITE_ONCE (sk->sk_uid,SOCK_INODE (sock)->i_uid);WRITE_ONCE (sk->sk_ino,SOCK_INODE (sock)->i_ino);
net/core/skbuff.c +18 -5
@@ -5513,15 +5513,28 @@ static void __skb_complete_tx_timestamp(struct sk_buff *skb,static bool skb_may_tx_timestamp (struct sock *sk,bool tsonly) { -bool ret; +struct socket *sock; +struct file *file; +bool ret = false;if (likely (tsonly ||READ_ONCE (sock_net (sk)->core.sysctl_tstamp_allow_data)))return true; -read_lock_bh (&sk->sk_callback_lock); - ret = sk->sk_socket && sk->sk_socket->file && -file_ns_capable (sk->sk_socket->file, &init_user_ns,CAP_NET_RAW ); -read_unlock_bh (&sk->sk_callback_lock); +/* The sk pointer remains valid as long as the skb is. The sk_socket and +* file pointer may become NULL if the socket is closed. Both structures +* (including file->cred) are RCU freed which means they can be accessed +* within a RCU read section. +*/ +rcu_read_lock (); + sock =READ_ONCE (sk->sk_socket); +if (!sock) + goto out; + file =READ_ONCE (sock->file); +if (!file) + goto out; + ret =file_ns_capable (file, &init_user_ns,CAP_NET_RAW ); +out: +rcu_read_unlock ();return ret; }
net/socket.c +1 -1
@@ -674,7 +674,7 @@ static void __sock_release(struct socket *sock, struct inode *inode)iput (SOCK_INODE (sock));return ; } - sock->file =NULL ; +WRITE_ONCE (sock->file,NULL ); }/**
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 438/752 net: usb: pegasus: enable basic endpoint checking
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 3d7e6ce34f4fcc7083510c28b17a7c36462a25d4 ]
pegasus_probe() fills URBs with hardcoded endpoint pipes without verifying the endpoint descriptors:
- usb_rcvbulkpipe(dev, 1) for RX data
- usb_sndbulkpipe(dev, 2) for TX data
- usb_rcvintpipe(dev, 3) for status interrupts
A malformed USB device can present these endpoints with transfer types that differ from what the driver assumes.
Add a pegasus_usb_ep enum for endpoint numbers, replacing magic constants throughout. Add usb_check_bulk_endpoints() and usb_check_int_endpoints() calls before any resource allocation to verify endpoint types before use, rejecting devices with mismatched descriptors at probe time, and avoid triggering assertion.
Similar fix to
- commit 90b7f2961798 ("net: usb: rtl8150: enable basic endpoint checking")
- commit 9e7021d2aeae ("net: usb: catc: enable basic endpoint checking")
--- drivers/net/usb/pegasus.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-)
drivers/net/usb/pegasus.c +30 -5
@@ -31,6 +31,17 @@ static const char driver_name[] = "pegasus"; BMSR_100FULL | BMSR_ANEGCAPABLE)#define CARRIER_CHECK_DELAY (2 * HZ) +/* +* USB endpoints. +*/ + +enum pegasus_usb_ep { +PEGASUS_USB_EP_CONTROL =0 , +PEGASUS_USB_EP_BULK_IN =1 , +PEGASUS_USB_EP_BULK_OUT =2 , +PEGASUS_USB_EP_INT_IN =3 , +}; +static bool loopback;static bool mii_mode;static char *devid;
@@ -545,7 +556,7 @@ static void read_bulk_callback(struct urb *urb) goto tl_sched; goon:usb_fill_bulk_urb (pegasus->rx_urb, pegasus->usb, -usb_rcvbulkpipe (pegasus->usb,1 ), +usb_rcvbulkpipe (pegasus->usb,PEGASUS_USB_EP_BULK_IN ), pegasus->rx_skb->data,PEGASUS_MTU , read_bulk_callback, pegasus); rx_status =usb_submit_urb (pegasus->rx_urb,GFP_ATOMIC );
@@ -585,7 +596,7 @@ static void rx_fixup(struct tasklet_struct *t)return ; }usb_fill_bulk_urb (pegasus->rx_urb, pegasus->usb, -usb_rcvbulkpipe (pegasus->usb,1 ), +usb_rcvbulkpipe (pegasus->usb,PEGASUS_USB_EP_BULK_IN ), pegasus->rx_skb->data,PEGASUS_MTU , read_bulk_callback, pegasus); try_again:
@@ -713,7 +724,7 @@ static netdev_tx_t pegasus_start_xmit(struct sk_buff *skb, ((__le16 *) pegasus->tx_buff)[0 ] =cpu_to_le16 (l16);skb_copy_from_linear_data (skb, pegasus->tx_buff +2 , skb->len);usb_fill_bulk_urb (pegasus->tx_urb, pegasus->usb, -usb_sndbulkpipe (pegasus->usb,2 ), +usb_sndbulkpipe (pegasus->usb,PEGASUS_USB_EP_BULK_OUT ), pegasus->tx_buff, count, write_bulk_callback, pegasus);if ((res =usb_submit_urb (pegasus->tx_urb,GFP_ATOMIC ))) {
@@ -840,7 +851,7 @@ static int pegasus_open(struct net_device *net)set_registers (pegasus, EthID,6 , net->dev_addr);usb_fill_bulk_urb (pegasus->rx_urb, pegasus->usb, -usb_rcvbulkpipe (pegasus->usb,1 ), +usb_rcvbulkpipe (pegasus->usb,PEGASUS_USB_EP_BULK_IN ), pegasus->rx_skb->data,PEGASUS_MTU , read_bulk_callback, pegasus);if ((res =usb_submit_urb (pegasus->rx_urb,GFP_KERNEL ))) {
@@ -851,7 +862,7 @@ static int pegasus_open(struct net_device *net) }usb_fill_int_urb (pegasus->intr_urb, pegasus->usb, -usb_rcvintpipe (pegasus->usb,3 ), +usb_rcvintpipe (pegasus->usb,PEGASUS_USB_EP_INT_IN ), pegasus->intr_buff,sizeof (pegasus->intr_buff), intr_callback, pegasus, pegasus->intr_interval);if ((res =usb_submit_urb (pegasus->intr_urb,GFP_KERNEL ))) {
@@ -1136,10 +1147,24 @@ static int pegasus_probe(struct usb_interface *intf,pegasus_t *pegasus;int dev_index = id - pegasus_ids;int res = -ENOMEM ; +static const u8 bulk_ep_addr[] = { +PEGASUS_USB_EP_BULK_IN |USB_DIR_IN , +PEGASUS_USB_EP_BULK_OUT |USB_DIR_OUT , +0 }; +static const u8 int_ep_addr[] = { +PEGASUS_USB_EP_INT_IN |USB_DIR_IN , +0 };if (pegasus_blacklisted (dev))return -ENODEV ; +/* Verify that all required endpoints are present */ +if (!usb_check_bulk_endpoints (intf, bulk_ep_addr) || + !usb_check_int_endpoints (intf, int_ep_addr)) { +dev_err (&intf->dev,"Missing or invalid endpoints\n" ); +return -ENODEV ; + } + net =alloc_etherdev (sizeof (struct pegasus ));if (!net) goto out;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 439/752 erofs: fix interlaced plain identification for encoded extents
In reply to Sasha LevinFrom: Gao Xiang <[email protected]>
[ Upstream commit 4a2d046e4b13202a6301a993961f5b30ae4d7119 ]
Only plain data whose start position and on-disk physical length are both aligned to the block size should be classified as interlaced plain extents. Otherwise, it must be treated as shifted plain extents.
This issue was found by syzbot using a crafted compressed image containing plain extents with unaligned physical lengths, which can cause OOB read in z_erofs_transform_plain().
--- fs/erofs/zmap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/erofs/zmap.c +5 -4
@@ -513,6 +513,7 @@ static int z_erofs_map_blocks_ext(struct inode *inode,unsigned int recsz =z_erofs_extent_recsize (vi->z_advise);erofs_off_t pos =round_up (Z_EROFS_MAP_HEADER_END (erofs_iloc (inode) + vi->inode_isize + vi->xattr_isize), recsz); +unsigned int bmask = sb->s_blocksize -1 ;bool in_mbox =erofs_inode_in_metabox (inode);erofs_off_t lend = inode->i_size;erofs_off_t l, r, mid, pa, la, lstart;
@@ -596,17 +597,17 @@ static int z_erofs_map_blocks_ext(struct inode *inode, map->m_flags |=EROFS_MAP_MAPPED |EROFS_MAP_FULL_MAPPED |EROFS_MAP_ENCODED ; fmt = map->m_plen >>Z_EROFS_EXTENT_PLEN_FMT_BIT ; +if (map->m_plen &Z_EROFS_EXTENT_PLEN_PARTIAL ) + map->m_flags |=EROFS_MAP_PARTIAL_REF ; + map->m_plen &=Z_EROFS_EXTENT_PLEN_MASK ;if (fmt) map->m_algorithmformat = fmt -1 ; -else if (interlaced && !erofs_blkoff (sb, map->m_pa)) +else if (interlaced && !((map->m_pa | map->m_plen) & bmask)) map->m_algorithmformat =Z_EROFS_COMPRESSION_INTERLACED ;else map->m_algorithmformat =Z_EROFS_COMPRESSION_SHIFTED ; -if (map->m_plen &Z_EROFS_EXTENT_PLEN_PARTIAL ) - map->m_flags |=EROFS_MAP_PARTIAL_REF ; - map->m_plen &=Z_EROFS_EXTENT_PLEN_MASK ; } } map->m_llen = lend - map->m_la;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 440/752 RDMA/umem: Fix double dma_buf_unpin in failure path
In reply to Sasha LevinFrom: Jacob Moroni <[email protected]>
[ Upstream commit 104016eb671e19709721c1b0048dd912dc2e96be ]
In ib_umem_dmabuf_get_pinned_with_dma_device(), the call to ib_umem_dmabuf_map_pages() can fail. If this occurs, the dmabuf is immediately unpinned but the umem_dmabuf->pinned flag is still set. Then, when ib_umem_release() is called, it calls ib_umem_dmabuf_revoke() which will call dma_buf_unpin() again.
Fix this by removing the immediate unpin upon failure and just let the ib_umem_release/revoke path handle it. This also ensures the proper unmap-unpin unwind ordering if the dmabuf_map_pages call happened to fail due to dma_resv_wait_timeout (and therefore has a non-NULL umem_dmabuf->sgt).
--- drivers/infiniband/core/umem_dmabuf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/infiniband/core/umem_dmabuf.c +1 -3
@@ -221,13 +221,11 @@ ib_umem_dmabuf_get_pinned_with_dma_device(struct ib_device *device, err =ib_umem_dmabuf_map_pages (umem_dmabuf);if (err) - goto err_unpin; + goto err_release;dma_resv_unlock (umem_dmabuf->attach->dmabuf->resv);return umem_dmabuf; -err_unpin: -dma_buf_unpin (umem_dmabuf->attach); err_release:dma_resv_unlock (umem_dmabuf->attach->dmabuf->resv);ib_umem_release (&umem_dmabuf->umem);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 441/752 tcp: re-enable acceptance of FIN packets when RWIN is 0
In reply to Sasha LevinFrom: Simon Baatz <[email protected]>
[ Upstream commit 1e3bb184e94125bae7c1703472109a646d0f79d9 ]
Commit 2bd99aef1b19 ("tcp: accept bare FIN packets under memory pressure") allowed accepting FIN packets in tcp_data_queue() even when the receive window was closed, to prevent ACK/FIN loops with broken clients.
Such a FIN packet is in sequence, but because the FIN consumes a sequence number, it extends beyond the window. Before commit 9ca48d616ed7 ("tcp: do not accept packets beyond window"), tcp_sequence() only required the seq to be within the window. After that change, the entire packet (including the FIN) must fit within the window. As a result, such FIN packets are now dropped and the handling path is no longer reached.
Be more lenient by not counting the sequence number consumed by the FIN when calling tcp_sequence(), restoring the previous behavior for cases where only the FIN extends beyond the window.
--- net/ipv4/tcp_input.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
net/ipv4/tcp_input.c +14 -4
@@ -4595,15 +4595,24 @@ static enum skb_drop_reason tcp_disordered_ack_check(const struct sock *sk,*/ static enum skb_drop_reason tcp_sequence (const struct sock *sk, -u32 seq,u32 end_seq) +u32 seq,u32 end_seq, +const struct tcphdr *th) {const struct tcp_sock *tp =tcp_sk (sk); +u32 seq_limit;if (before (end_seq, tp->rcv_wup))return SKB_DROP_REASON_TCP_OLD_SEQUENCE ; -if (after (end_seq, tp->rcv_nxt +tcp_receive_window (tp))) { -if (after (seq, tp->rcv_nxt +tcp_receive_window (tp))) + seq_limit = tp->rcv_nxt +tcp_receive_window (tp); +if (unlikely (after (end_seq, seq_limit))) { +/* Some stacks are known to handle FIN incorrectly; allow the +* FIN to extend beyond the window and check it in detail later. +*/ +if (!after (end_seq - th->fin, seq_limit)) +return SKB_NOT_DROPPED_YET ; + +if (after (seq, seq_limit))return SKB_DROP_REASON_TCP_INVALID_SEQUENCE ;/* Only accept this packet if receive queue is empty. */
@@ -6119,7 +6128,8 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, step1:/* Step 1: check sequence number */ - reason =tcp_sequence (sk,TCP_SKB_CB (skb)->seq,TCP_SKB_CB (skb)->end_seq); + reason =tcp_sequence (sk,TCP_SKB_CB (skb)->seq, +TCP_SKB_CB (skb)->end_seq, th);if (reason) {/* RFC793, page 37: "In all states except SYN-SENT, all reset * (RST) segments are validated by checking their SEQ-fields."
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 442/752 dpll: zl3073x: Remove redundant cleanup in devm_dpll_init()
In reply to Sasha LevinFrom: Felix Gu <[email protected]>
[ Upstream commit 676c7af91fcd740d34e7cb788cbc58e3bcafde39 ]
The devm_add_action_or_reset() function already executes the cleanup action on failure before returning an error, so the explicit goto error and subsequent zl3073x_dev_dpll_fini() call causes double cleanup.
--- drivers/dpll/zl3073x/core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/dpll/zl3073x/core.c +1 -5
@@ -978,11 +978,7 @@ zl3073x_devm_dpll_init(struct zl3073x_dev *zldev, u8 num_dplls) }/* Add devres action to release DPLL related resources */ - rc =devm_add_action_or_reset (zldev->dev, zl3073x_dev_dpll_fini, zldev); -if (rc) - goto error; - -return 0 ; +return devm_add_action_or_reset (zldev->dev, zl3073x_dev_dpll_fini, zldev); error:zl3073x_dev_dpll_fini (zldev);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 443/752 net: mana: Fix double destroy_workqueue on service rescan PCI path
In reply to Sasha LevinFrom: Dipayaan Roy <[email protected]>
[ Upstream commit f975a0955276579e2176a134366ed586071c7c6a ]
While testing corner cases in the driver, a use-after-free crash was found on the service rescan PCI path.
When mana_serv_reset() calls mana_gd_suspend(), mana_gd_cleanup() destroys gc->service_wq. If the subsequent mana_gd_resume() fails with -ETIMEDOUT or -EPROTO, the code falls through to mana_serv_rescan() which triggers pci_stop_and_remove_bus_device(). This invokes the PCI .remove callback (mana_gd_remove), which calls mana_gd_cleanup() a second time, attempting to destroy the already- freed workqueue. Fix this by NULL-checking gc->service_wq in mana_gd_cleanup() and setting it to NULL after destruction.
Call stack of issue for reference:
[Sat Feb 21 18:53:48 2026] Call Trace: [Sat Feb 21 18:53:48 2026] <TASK> [Sat Feb 21 18:53:48 2026] mana_gd_cleanup+0x33/0x70 [mana] [Sat Feb 21 18:53:48 2026] mana_gd_remove+0x3a/0xc0 [mana] [Sat Feb 21 18:53:48 2026] pci_device_remove+0x41/0xb0 [Sat Feb 21 18:53:48 2026] device_remove+0x46/0x70 [Sat Feb 21 18:53:48 2026] device_release_driver_internal+0x1e3/0x250 [Sat Feb 21 18:53:48 2026] device_release_driver+0x12/0x20 [Sat Feb 21 18:53:48 2026] pci_stop_bus_device+0x6a/0x90 [Sat Feb 21 18:53:48 2026] pci_stop_and_remove_bus_device+0x13/0x30 [Sat Feb 21 18:53:48 2026] mana_do_service+0x180/0x290 [mana] [Sat Feb 21 18:53:48 2026] mana_serv_func+0x24/0x50 [mana] [Sat Feb 21 18:53:48 2026] process_one_work+0x190/0x3d0 [Sat Feb 21 18:53:48 2026] worker_thread+0x16e/0x2e0 [Sat Feb 21 18:53:48 2026] kthread+0xf7/0x130 [Sat Feb 21 18:53:48 2026] ? __pfx_worker_thread+0x10/0x10 [Sat Feb 21 18:53:48 2026] ? __pfx_kthread+0x10/0x10 [Sat Feb 21 18:53:48 2026] ret_from_fork+0x269/0x350 [Sat Feb 21 18:53:48 2026] ? __pfx_kthread+0x10/0x10 [Sat Feb 21 18:53:48 2026] ret_from_fork_asm+0x1a/0x30 [Sat Feb 21 18:53:48 2026] </TASK>
--- drivers/net/ethernet/microsoft/mana/gdma_main.c | 5 ++++- drivers/net/ethernet/microsoft/mana/mana_en.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/microsoft/mana/gdma_main.c +4 -1
@@ -1866,7 +1866,10 @@ static void mana_gd_cleanup(struct pci_dev *pdev)mana_gd_remove_irqs (pdev); -destroy_workqueue (gc->service_wq); +if (gc->service_wq) { +destroy_workqueue (gc->service_wq); + gc->service_wq =NULL ; + }dev_dbg (&pdev->dev,"mana gdma cleanup successful\n" ); }
drivers/net/ethernet/microsoft/mana/mana_en.c +3 -1
@@ -3580,7 +3580,9 @@ void mana_rdma_remove(struct gdma_dev *gd) }WRITE_ONCE (gd->rdma_teardown, true); -flush_workqueue (gc->service_wq); + +if (gc->service_wq) +flush_workqueue (gc->service_wq);if (gd->adev)remove_adev (gd);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 444/752 net: add a common function to compute features for upper devices
In reply to Sasha LevinFrom: Hangbin Liu <[email protected]>
[ Upstream commit 28098defc79fe7d29e6bfe4eb6312991f6bdc3d3 ]
Some high level software drivers need to compute features from lower devices. But each has their own implementations and may lost some feature compute. Let's use one common function to compute features for kinds of these devices.
The new helper uses the current bond implementation as the reference one, as the latter already handles all the relevant aspects: netdev features, TSO limits and dst retention.
Stable-dep-of: bb4c698633c0 ("team: avoid NETDEV_CHANGEMTU event when unregistering slave")
--- include/linux/netdev_features.h | 18 +++++++ include/linux/netdevice.h | 1 + net/core/dev.c | 88 +++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+)
include/linux/netdev_features.h +18 -0
@@ -255,6 +255,24 @@ static inline int find_next_netdev_feature(u64 feature, unsigned long start) NETIF_F_GSO_UDP_TUNNEL | \ NETIF_F_GSO_UDP_TUNNEL_CSUM) +/* virtual device features */ +#define MASTER_UPPER_DEV_VLAN_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ + NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE | \ + NETIF_F_GSO_ENCAP_ALL | \ + NETIF_F_HIGHDMA | NETIF_F_LRO) + +#define MASTER_UPPER_DEV_ENC_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ + NETIF_F_RXCSUM | NETIF_F_GSO_SOFTWARE | \ + NETIF_F_GSO_PARTIAL) + +#define MASTER_UPPER_DEV_MPLS_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ + NETIF_F_GSO_SOFTWARE) + +#define MASTER_UPPER_DEV_XFRM_FEATURES (NETIF_F_HW_ESP | NETIF_F_HW_ESP_TX_CSUM | \ + NETIF_F_GSO_ESP) + +#define MASTER_UPPER_DEV_GSO_PARTIAL_FEATURES (NETIF_F_GSO_ESP) +static inline netdev_features_t netdev_base_features (netdev_features_t features) { features &= ~NETIF_F_ONE_FOR_ALL ;
include/linux/netdevice.h +1 -0
@@ -5306,6 +5306,7 @@ static inline netdev_features_t netdev_add_tso_features(netdev_features_t featurint __netdev_update_features (struct net_device *dev);void netdev_update_features (struct net_device *dev);void netdev_change_features (struct net_device *dev); +void netdev_compute_master_upper_features (struct net_device *dev,bool update_header);void netif_stacked_transfer_operstate (const struct net_device *rootdev,struct net_device *dev);
net/core/dev.c +88 -0
94 lines not on this page · raw message
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 445/752 team: use common function to compute the features
In reply to Sasha LevinFrom: Hangbin Liu <[email protected]>
[ Upstream commit 745cd46c2a47144dd656185b9be0a1e5e9b02d2d ]
Use the new helper netdev_compute_master_upper_features() to compute the team device features. This helper performs both the feature computation and the netdev_change_features() call.
Note that such change replace the lower layer traversing currently done using team->port_list with netdev_for_each_lower_dev(). Such change is safe as port_list contains exactly the same elements as team->dev->adj_list.lower and the helper is always invoked under the RTNL lock.
With this change, the explicit netdev_change_features() in team_add_slave() can be safely removed, as team_port_add() already takes care of the notification via netdev_compute_master_upper_features(), and same thing for team_del_slave()
This also fixes missing computations for MPLS, XFRM, and TSO/GSO partial features.
Stable-dep-of: bb4c698633c0 ("team: avoid NETDEV_CHANGEMTU event when unregistering slave")
--- drivers/net/team/team_core.c | 83 +++--------------------------------- 1 file changed, 6 insertions(+), 77 deletions(-)
drivers/net/team/team_core.c +6 -77
@@ -982,63 +982,6 @@ static void team_port_disable(struct team *team,team_lower_state_changed (port); } -#define TEAM_VLAN_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ - NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE | \ - NETIF_F_HIGHDMA | NETIF_F_LRO | \ - NETIF_F_GSO_ENCAP_ALL) - -#define TEAM_ENC_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ - NETIF_F_RXCSUM | NETIF_F_GSO_SOFTWARE) - -static void __team_compute_features (struct team *team) -{ -struct team_port *port; -netdev_features_t vlan_features =TEAM_VLAN_FEATURES ; -netdev_features_t enc_features =TEAM_ENC_FEATURES ; -unsigned short max_hard_header_len =ETH_HLEN ; -unsigned int dst_release_flag =IFF_XMIT_DST_RELEASE | -IFF_XMIT_DST_RELEASE_PERM ; - -rcu_read_lock (); -if (list_empty (&team->port_list)) - goto done; - - vlan_features =netdev_base_features (vlan_features); - enc_features =netdev_base_features (enc_features); - -list_for_each_entry_rcu (port, &team->port_list, list) { - vlan_features =netdev_increment_features (vlan_features, - port->dev->vlan_features, -TEAM_VLAN_FEATURES ); - enc_features = -netdev_increment_features (enc_features, - port->dev->hw_enc_features, -TEAM_ENC_FEATURES ); - - dst_release_flag &= port->dev->priv_flags; -if (port->dev->hard_header_len > max_hard_header_len) - max_hard_header_len = port->dev->hard_header_len; - } -done: -rcu_read_unlock (); - - team->dev->vlan_features = vlan_features; - team->dev->hw_enc_features = enc_features |NETIF_F_GSO_ENCAP_ALL | -NETIF_F_HW_VLAN_CTAG_TX | -NETIF_F_HW_VLAN_STAG_TX ; - team->dev->hard_header_len = max_hard_header_len; - - team->dev->priv_flags &= ~IFF_XMIT_DST_RELEASE ; -if (dst_release_flag == (IFF_XMIT_DST_RELEASE |IFF_XMIT_DST_RELEASE_PERM )) - team->dev->priv_flags |=IFF_XMIT_DST_RELEASE ; -} - -static void team_compute_features (struct team *team) -{ -__team_compute_features (team); -netdev_change_features (team->dev); -} -static int team_port_enter (struct team *team,struct team_port *port) {int err =0 ;
@@ -1306,7 +1249,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev, port->index =-1 ;list_add_tail_rcu (&port->list, &team->port_list);team_port_enable (team, port); -__team_compute_features (team); +netdev_compute_master_upper_features (team->dev, true);__team_port_change_port_added (port, !!netif_oper_up (port_dev));__team_options_change_check (team);
@@ -1389,7 +1332,7 @@ static int team_port_del(struct team *team, struct net_device *port_dev)dev_set_mtu (port_dev, port->orig.mtu);kfree_rcu (port, rcu);netdev_info (dev,"Port device %s removed\n" , portname); -__team_compute_features (team); +netdev_compute_master_upper_features (team->dev, true);return 0 ; }
@@ -1977,33 +1920,19 @@ static int team_add_slave(struct net_device *dev, struct net_device *port_dev, struct netlink_ext_ack *extack) {struct team *team =netdev_priv (dev); -int err;ASSERT_RTNL (); - err =team_port_add (team, port_dev, extack); - -if (!err) -netdev_change_features (dev); - -return err; +return team_port_add (team, port_dev, extack); }static int team_del_slave (struct net_device *dev,struct net_device *port_dev) {struct team *team =netdev_priv (dev); -int err;ASSERT_RTNL (); - err =team_port_del (team, port_dev); - -if (err) -return err; - -netdev_change_features (dev); - -return err; +return team_port_del (team, port_dev); } static netdev_features_t team_fix_features(struct net_device *dev,
@@ -2197,7 +2126,7 @@ static void team_setup(struct net_device *dev) dev->features |=NETIF_F_GRO ; - dev->hw_features =TEAM_VLAN_FEATURES | + dev->hw_features =MASTER_UPPER_DEV_VLAN_FEATURES |NETIF_F_HW_VLAN_CTAG_RX |NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_STAG_RX |
@@ -3001,7 +2930,7 @@ static int team_device_event(struct notifier_block *unused,case NETDEV_FEAT_CHANGE :if (!port->team->notifier_ctx) { port->team->notifier_ctx = true; -team_compute_features (port->team); +netdev_compute_master_upper_features (port->team->dev, true); port->team->notifier_ctx = false; }break ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 446/752 team: avoid NETDEV_CHANGEMTU event when unregistering slave
In reply to Sasha LevinFrom: Tetsuo Handa <[email protected]>
[ Upstream commit bb4c698633c0e19717586a6524a33196cff01a32 ]
syzbot is reporting
unregister_netdevice: waiting for netdevsim0 to become free. Usage count = 3
ref_tracker: netdev@ffff88807dcf8618 has 1/2 users at
__netdev_tracker_alloc include/linux/netdevice.h:4400 [inline]
netdev_hold include/linux/netdevice.h:4429 [inline]
inetdev_init+0x201/0x4e0 net/ipv4/devinet.c:286
inetdev_event+0x251/0x1610 net/ipv4/devinet.c:1600
notifier_call_chain+0x19d/0x3a0 kernel/notifier.c:85
call_netdevice_notifiers_mtu net/core/dev.c:2318 [inline]
netif_set_mtu_ext+0x5aa/0x800 net/core/dev.c:9886
netif_set_mtu+0xd7/0x1b0 net/core/dev.c:9907
dev_set_mtu+0x126/0x260 net/core/dev_api.c:248
team_port_del+0xb07/0xcb0 drivers/net/team/team_core.c:1333
team_del_slave drivers/net/team/team_core.c:1936 [inline]
team_device_event+0x207/0x5b0 drivers/net/team/team_core.c:2929
notifier_call_chain+0x19d/0x3a0 kernel/notifier.c:85
call_netdevice_notifiers_extack net/core/dev.c:2281 [inline]
call_netdevice_notifiers net/core/dev.c:2295 [inline]
__dev_change_net_namespace+0xcb7/0x2050 net/core/dev.c:12592
do_setlink+0x2ce/0x4590 net/core/rtnetlink.c:3060
rtnl_changelink net/core/rtnetlink.c:3776 [inline]
__rtnl_newlink net/core/rtnetlink.c:3935 [inline]
rtnl_newlink+0x15a9/0x1be0 net/core/rtnetlink.c:4072
rtnetlink_rcv_msg+0x7d5/0xbe0 net/core/rtnetlink.c:6958
netlink_rcv_skb+0x232/0x4b0 net/netlink/af_netlink.c:2550
netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
netlink_unicast+0x80f/0x9b0 net/netlink/af_netlink.c:1344
netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1894problem. Ido Schimmel found steps to reproduce
ip link add name team1 type team
ip link add name dummy1 mtu 1499 master team1 type dummy ip netns add ns1
ip link set dev dummy1 netns ns1
ip -n ns1 link del dev dummy1
and also found that the same issue was fixed in the bond driver in commit f51048c3e07b ("bonding: avoid NETDEV_CHANGEMTU event when unregistering slave").
Let's do similar thing for the team driver, with commit ad7c7b2172c3 ("net:
hold netdev instance lock during sysfs operations") and commit 303a8487a657 ("net: s/__dev_set_mtu/__netif_set_mtu/") also applied.
--- drivers/net/team/team_core.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/net/team/team_core.c +21 -5
@@ -1291,7 +1291,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev,static void __team_port_change_port_removed (struct team_port *port); -static int team_port_del (struct team *team,struct net_device *port_dev) +static int team_port_del (struct team *team,struct net_device *port_dev,bool unregister) {struct net_device *dev = team->dev;struct team_port *port;
@@ -1329,7 +1329,13 @@ static int team_port_del(struct team *team, struct net_device *port_dev)__team_port_change_port_removed (port);team_port_set_orig_dev_addr (port); -dev_set_mtu (port_dev, port->orig.mtu); +if (unregister) { +netdev_lock_ops (port_dev); +__netif_set_mtu (port_dev, port->orig.mtu); +netdev_unlock_ops (port_dev); + }else { +dev_set_mtu (port_dev, port->orig.mtu); + }kfree_rcu (port, rcu);netdev_info (dev,"Port device %s removed\n" , portname);netdev_compute_master_upper_features (team->dev, true);
@@ -1633,7 +1639,7 @@ static void team_uninit(struct net_device *dev)ASSERT_RTNL ();list_for_each_entry_safe (port, tmp, &team->port_list, list) -team_port_del (team, port->dev); +team_port_del (team, port->dev, false);__team_change_mode (team,NULL );/* cleanup */ __team_options_unregister (team, team_options,ARRAY_SIZE (team_options));
@@ -1932,7 +1938,16 @@ static int team_del_slave(struct net_device *dev, struct net_device *port_dev)ASSERT_RTNL (); -return team_port_del (team, port_dev); +return team_port_del (team, port_dev, false); +} + +static int team_del_slave_on_unregister (struct net_device *dev,struct net_device *port_dev) +{ +struct team *team =netdev_priv (dev); + +ASSERT_RTNL (); + +return team_port_del (team, port_dev, true); } static netdev_features_t team_fix_features(struct net_device *dev,
@@ -2925,7 +2940,7 @@ static int team_device_event(struct notifier_block *unused, !!netif_oper_up(port->dev));break ;case NETDEV_UNREGISTER : -team_del_slave (port->team->dev, dev); +team_del_slave_on_unregister (port->team->dev, dev);break ;case NETDEV_FEAT_CHANGE :if (!port->team->notifier_ctx) {
@@ -2998,3 +3013,4 @@ MODULE_LICENSE("GPL v2");MODULE_AUTHOR ("Jiri Pirko <[email protected]>" );MODULE_DESCRIPTION ("Ethernet team device driver" );MODULE_ALIAS_RTNL_LINK (DRV_NAME ); +MODULE_IMPORT_NS ("NETDEV_INTERNAL" );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 447/752 net/mlx5: DR, Fix circular locking dependency in dump
In reply to Sasha LevinFrom: Shay Drory <[email protected]>
[ Upstream commit 2700b7e603af39ca55fe9fc876ca123efd44680f ]
Fix a circular locking dependency between dbg_mutex and the domain rx/tx mutexes that could lead to a deadlock.
The dump path in dr_dump_domain_all() was acquiring locks in the order:
dbg_mutex -> rx.mutex -> tx.mutex
While the table/matcher creation paths acquire locks in the order:
rx.mutex -> tx.mutex -> dbg_mutex
This inverted lock ordering creates a circular dependency. Fix this by changing dr_dump_domain_all() to acquire the domain lock before dbg_mutex, matching the order used in mlx5dr_table_create() and mlx5dr_matcher_create().
Lockdep splat:
======================================================
WARNING: possible circular locking dependency detected 6.19.0-rc6net_next_e817c4e #1 Not tainted
------------------------------------------------------
sos/30721 is trying to acquire lock:
ffff888102df5900 (&dmn->info.rx.mutex){+.+.}-{4:4}, at:dr_dump_start+0x131/0x450 [mlx5_core]
but task is already holding lock:
ffff888102df5bc0 (&dmn->dump_info.dbg_mutex){+.+.}-{4:4}, at:dr_dump_start+0x10b/0x450 [mlx5_core]
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (&dmn->dump_info.dbg_mutex){+.+.}-{4:4}:
__mutex_lock+0x91/0x1060
mlx5dr_matcher_create+0x377/0x5e0 [mlx5_core]
mlx5_cmd_dr_create_flow_group+0x62/0xd0 [mlx5_core]
mlx5_create_flow_group+0x113/0x1c0 [mlx5_core]
mlx5_chains_create_prio+0x453/0x2290 [mlx5_core]
mlx5_chains_get_table+0x2e2/0x980 [mlx5_core]
esw_chains_create+0x1e6/0x3b0 [mlx5_core]
esw_create_offloads_fdb_tables.cold+0x62/0x63f [mlx5_core]
esw_offloads_enable+0x76f/0xd20 [mlx5_core]
mlx5_eswitch_enable_locked+0x35a/0x500 [mlx5_core]
mlx5_devlink_eswitch_mode_set+0x561/0x950 [mlx5_core]
devlink_nl_eswitch_set_doit+0x67/0xe0
genl_family_rcv_msg_doit+0xe0/0x130
genl_rcv_msg+0x188/0x290
netlink_rcv_skb+0x4b/0xf0
genl_rcv+0x24/0x40
netlink_unicast+0x1ed/0x2c0
netlink_sendmsg+0x210/0x450
__sock_sendmsg+0x38/0x60
__sys_sendto+0x119/0x180
__x64_sys_sendto+0x20/0x30
do_syscall_64+0x70/0xd00
entry_SYSCALL_64_after_hwframe+0x4b/0x53-> #1 (&dmn->info.tx.mutex){+.+.}-{4:4}:
__mutex_lock+0x91/0x1060
mlx5dr_table_create+0x11d/0x530 [mlx5_core]
mlx5_cmd_dr_create_flow_table+0x62/0x140 [mlx5_core]
__mlx5_create_flow_table+0x46f/0x960 [mlx5_core]
mlx5_create_flow_table+0x16/0x20 [mlx5_core]
esw_create_offloads_fdb_tables+0x136/0x240 [mlx5_core]
esw_offloads_enable+0x76f/0xd20 [mlx5_core]
mlx5_eswitch_enable_locked+0x35a/0x500 [mlx5_core]
mlx5_devlink_eswitch_mode_set+0x561/0x950 [mlx5_core]
devlink_nl_eswitch_set_doit+0x67/0xe0
genl_family_rcv_msg_doit+0xe0/0x130
genl_rcv_msg+0x188/0x290
netlink_rcv_skb+0x4b/0xf0
genl_rcv+0x24/0x40
netlink_unicast+0x1ed/0x2c0
netlink_sendmsg+0x210/0x450
__sock_sendmsg+0x38/0x60
__sys_sendto+0x119/0x180
__x64_sys_sendto+0x20/0x30
do_syscall_64+0x70/0xd00
entry_SYSCALL_64_after_hwframe+0x4b/0x53-> #0 (&dmn->info.rx.mutex){+.+.}-{4:4}:
__lock_acquire+0x18b6/0x2eb0
lock_acquire+0xd3/0x2c0
__mutex_lock+0x91/0x1060
dr_dump_start+0x131/0x450 [mlx5_core]
seq_read_iter+0xe3/0x410
seq_read+0xfb/0x130
full_proxy_read+0x53/0x80
vfs_read+0xba/0x330
ksys_read+0x65/0xe0
do_syscall_64+0x70/0xd00
entry_SYSCALL_64_after_hwframe+0x4b/0x53
Possible unsafe locking scenario: CPU0 CPU1
---- ----
lock(&dmn->dump_info.dbg_mutex);
lock(&dmn->info.tx.mutex);
lock(&dmn->dump_info.dbg_mutex); lock(&dmn->info.rx.mutex);
*** DEADLOCK ***
--- drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_dbg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_dbg.c +2 -2
@@ -1050,8 +1050,8 @@ static int dr_dump_domain_all(struct seq_file *file, struct mlx5dr_domain *dmn)struct mlx5dr_table *tbl;int ret; -mutex_lock (&dmn->dump_info.dbg_mutex);mlx5dr_domain_lock (dmn); +mutex_lock (&dmn->dump_info.dbg_mutex); ret =dr_dump_domain (file, dmn);if (ret <0 )
@@ -1064,8 +1064,8 @@ static int dr_dump_domain_all(struct seq_file *file, struct mlx5dr_domain *dmn) } unlock_mutex: -mlx5dr_domain_unlock (dmn);mutex_unlock (&dmn->dump_info.dbg_mutex); +mlx5dr_domain_unlock (dmn);return ret; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 448/752 net/mlx5: LAG, disable MPESW in lag_disable_change()
In reply to Sasha LevinFrom: Shay Drory <[email protected]>
[ Upstream commit bd7b9f83fb9f85228c3ac9748d9cba9fab7fb5a2 ]
mlx5_lag_disable_change() unconditionally called mlx5_disable_lag() when LAG was active, which is incorrect for MLX5_LAG_MODE_MPESW. Hnece, call mlx5_disable_mpesw() when running in MPESW mode.
--- drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 8 ++++++-- drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c | 8 ++++---- drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.h | 5 +++++ 3 files changed, 15 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +6 -2
@@ -1652,8 +1652,12 @@ void mlx5_lag_disable_change(struct mlx5_core_dev *dev)mutex_lock (&ldev->lock); ldev->mode_changes_in_progress++; -if (__mlx5_lag_is_active (ldev)) -mlx5_disable_lag (ldev); +if (__mlx5_lag_is_active (ldev)) { +if (ldev->mode ==MLX5_LAG_MODE_MPESW ) +mlx5_lag_disable_mpesw (ldev); +else +mlx5_disable_lag (ldev); + }mutex_unlock (&ldev->lock);mlx5_devcom_comp_unlock (dev->priv.hca_devcom_comp);
drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c +4 -4
@@ -65,7 +65,7 @@ static int mlx5_mpesw_metadata_set(struct mlx5_lag *ldev)return err; } -static int enable_mpesw (struct mlx5_lag *ldev) +static int mlx5_lag_enable_mpesw (struct mlx5_lag *ldev) {struct mlx5_core_dev *dev0;int err;
@@ -124,7 +124,7 @@ static int enable_mpesw(struct mlx5_lag *ldev)return err; } -static void disable_mpesw (struct mlx5_lag *ldev) +void mlx5_lag_disable_mpesw (struct mlx5_lag *ldev) {if (ldev->mode ==MLX5_LAG_MODE_MPESW ) {mlx5_mpesw_metadata_cleanup (ldev);
@@ -150,9 +150,9 @@ static void mlx5_mpesw_work(struct work_struct *work) }if (mpesww->op ==MLX5_MPESW_OP_ENABLE ) - mpesww->result =enable_mpesw (ldev); + mpesww->result =mlx5_lag_enable_mpesw (ldev);else if (mpesww->op ==MLX5_MPESW_OP_DISABLE ) -disable_mpesw (ldev); +mlx5_lag_disable_mpesw (ldev); unlock:mutex_unlock (&ldev->lock);mlx5_devcom_comp_unlock (devcom);
drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.h +5 -0
@@ -31,5 +31,10 @@ int mlx5_lag_mpesw_do_mirred(struct mlx5_core_dev *mdev,bool mlx5_lag_is_mpesw (struct mlx5_core_dev *dev);void mlx5_lag_mpesw_disable (struct mlx5_core_dev *dev);int mlx5_lag_mpesw_enable (struct mlx5_core_dev *dev); +#ifdef CONFIG_MLX5_ESWITCH +void mlx5_lag_disable_mpesw (struct mlx5_lag *ldev); +#else +static inline void mlx5_lag_disable_mpesw (struct mlx5_lag *ldev) {} +#endif /* CONFIG_MLX5_ESWITCH */ #endif /* __MLX5_LAG_MPESW_H__ */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 449/752 net/mlx5: E-switch, Clear legacy flag when moving to switchdev
In reply to Sasha LevinFrom: Shay Drory <[email protected]>
[ Upstream commit d7073e8b978ae925f1f0f08754f33f84d8547ea7 ]
The cited commit introduced MLX5_PRIV_FLAGS_SWITCH_LEGACY to identify when a transition to legacy mode is requested via devlink. However, the logic failed to clear this flag if the mode was subsequently changed back to MLX5_ESWITCH_OFFLOADS (switchdev). Consequently, if a user toggled from legacy to switchdev, the flag remained set, leaving the driver with wrong state indicating
Fix this by explicitly clearing the MLX5_PRIV_FLAGS_SWITCH_LEGACY bit when the requested mode is MLX5_ESWITCH_OFFLOADS.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
@@ -3854,6 +3854,8 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,if (mode ==DEVLINK_ESWITCH_MODE_LEGACY ) esw->dev->priv.flags |=MLX5_PRIV_FLAGS_SWITCH_LEGACY ; +if (mlx5_mode ==MLX5_ESWITCH_OFFLOADS ) + esw->dev->priv.flags &= ~MLX5_PRIV_FLAGS_SWITCH_LEGACY ;mlx5_eswitch_disable_locked (esw);if (mode ==DEVLINK_ESWITCH_MODE_SWITCHDEV ) {if (mlx5_devlink_trap_get_num_active (esw->dev)) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 450/752 net/mlx5: Fix missing devlink lock in SRIOV enable error path
In reply to Sasha LevinFrom: Shay Drory <[email protected]>
[ Upstream commit 60253042c0b87b61596368489c44d12ba720d11c ]
The cited commit miss to add locking in the error path of mlx5_sriov_enable(). When pci_enable_sriov() fails, mlx5_device_disable_sriov() is called to clean up. This cleanup function now expects to be called with the devlink instance lock held.
Add the missing devl_lock(devlink) and devl_unlock(devlink)
--- drivers/net/ethernet/mellanox/mlx5/core/sriov.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/sriov.c +2 -0
@@ -193,7 +193,9 @@ static int mlx5_sriov_enable(struct pci_dev *pdev, int num_vfs) err =pci_enable_sriov (pdev, num_vfs);if (err) {mlx5_core_warn (dev,"pci_enable_sriov failed : %d\n" , err); +devl_lock (devlink);mlx5_device_disable_sriov (dev, num_vfs, true, true); +devl_unlock (devlink); }return err; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 451/752 net/mlx5e: Fix "scheduling while atomic" in IPsec MAC address query
In reply to Sasha LevinFrom: Jianbo Liu <[email protected]>
[ Upstream commit 859380694f434597407632c29f30fdb5e763e6cc ]
Fix a "scheduling while atomic" bug in mlx5e_ipsec_init_macs() by replacing mlx5_query_mac_address() with ether_addr_copy() to get the local MAC address directly from netdev->dev_addr.
The issue occurs because mlx5_query_mac_address() queries the hardware which involves mlx5_cmd_exec() that can sleep, but it is called from the mlx5e_ipsec_handle_event workqueue which runs in atomic context.
The MAC address is already available in netdev->dev_addr, so no need to query hardware. This avoids the sleeping call and resolves the bug.
Call trace: BUG: scheduling while atomic: kworker/u112:2/69344/0x00000200 __schedule+0x7ab/0xa20 schedule+0x1c/0xb0 schedule_timeout+0x6e/0xf0 __wait_for_common+0x91/0x1b0 cmd_exec+0xa85/0xff0 [mlx5_core] mlx5_cmd_exec+0x1f/0x50 [mlx5_core] mlx5_query_nic_vport_mac_address+0x7b/0xd0 [mlx5_core] mlx5_query_mac_address+0x19/0x30 [mlx5_core] mlx5e_ipsec_init_macs+0xc1/0x720 [mlx5_core] mlx5e_ipsec_build_accel_xfrm_attrs+0x422/0x670 [mlx5_core] mlx5e_ipsec_handle_event+0x2b9/0x460 [mlx5_core] process_one_work+0x178/0x2e0 worker_thread+0x2ea/0x430
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +1 -2
@@ -259,7 +259,6 @@ static void mlx5e_ipsec_init_limits(struct mlx5e_ipsec_sa_entry *sa_entry,static void mlx5e_ipsec_init_macs (struct mlx5e_ipsec_sa_entry *sa_entry,struct mlx5_accel_esp_xfrm_attrs *attrs) { -struct mlx5_core_dev *mdev =mlx5e_ipsec_sa2dev (sa_entry);struct mlx5e_ipsec_addr *addrs = &attrs->addrs;struct net_device *netdev = sa_entry->dev;struct xfrm_state *x = sa_entry->x;
@@ -276,7 +275,7 @@ static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry, attrs->type != XFRM_DEV_OFFLOAD_PACKET)return ; -mlx5_query_mac_address (mdev, addr); +ether_addr_copy (addr, netdev->dev_addr);switch (attrs->dir) {case XFRM_DEV_OFFLOAD_IN : src = attrs->dmac;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 452/752 net: consume xmit errors of GSO frames
In reply to Sasha LevinFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 7aa767d0d3d04e50ae94e770db7db8197f666970 ]
udpgro_frglist.sh and udpgro_bench.sh are the flakiest tests currently in NIPA. They fail in the same exact way, TCP GRO test stalls occasionally and the test gets killed after 10min.
These tests use veth to simulate GRO. They attach a trivial ("return XDP_PASS;") XDP program to the veth to force TSO off and NAPI on.
Digging into the failure mode we can see that the connection is completely stuck after a burst of drops. The sender's snd_nxt is at sequence number N [1], but the receiver claims to have received (rcv_nxt) up to N + 3 * MSS [2]. Last piece of the puzzle is that senders rtx queue is not empty (let's say the block in the rtx queue is at sequence number N - 4 * MSS [3]).
In this state, sender sends a retransmission from the rtx queue with a single segment, and sequence numbers N-4*MSS:N-3*MSS [3]. Receiver sees it and responds with an ACK all the way up to N + 3 * MSS [2]. But sender will reject this ack as TCP_ACK_UNSENT_DATA because it has no recollection of ever sending data that far out [1]. And we are stuck.
The root cause is the mess of the xmit return codes. veth returns an error when it can't xmit a frame. We end up with a loss event like this:
-------------------------------------------------
| GSO super frame 1 | GSO super frame 2 | |-----------------------------------------------| | seg | seg | seg | seg | seg | seg | seg | seg | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
-------------------------------------------------
x ok ok <ok>| ok ok ok <x>
\\
snd_nxt
"x" means packet lost by veth, and "ok" means it went thru. Since veth has TSO disabled in this test it sees individual segments. Segment 1 is on the retransmit queue and will be resent.
So why did the sender not advance snd_nxt even tho it clearly did send up to seg 8? tcp_write_xmit() interprets the return code from the core to mean that data has not been sent at all. Since TCP deals with GSO super frames, not individual segment the crux of the problem is that loss of a single segment can be interpreted as loss of all. TCP only sees the last return code for the last segment of the GSO frame (in <> brackets in the diagram above).
Of course for the problem to occur we need a setup or a device without a Qdisc. Otherwise Qdisc layer disconnects the protocol layer from the device errors completely.
We have multiple ways to fix this.
1) make veth not return an error when it lost a packet. While this is what I think we did in the past, the issue keeps reappearing and it's annoying to debug. The game of whack a mole is not great.
2) fix the damn return codes
We only talk about NETDEV_TX_OK and NETDEV_TX_BUSY in the documentation, so maybe we should make the return code from ndo_start_xmit() a boolean. I like that the most, but perhaps some ancient, not-really-networking protocol would suffer.
3) make TCP ignore the errors
It is not entirely clear to me what benefit TCP gets from interpreting the result of ip_queue_xmit()? Specifically once the connection is established and we're pushing data - packet loss is just packet loss?
4) this fix
Ignore the rc in the Qdisc-less+GSO case, since it's unreliable. We already always return OK in the TCQ_F_CAN_BYPASS case. In the Qdisc-less case let's be a bit more conservative and only mask the GSO errors. This path is taken by non-IP-"networks" like CAN, MCTP etc, so we could regress some ancient thing. This is the simplest, but also maybe the hackiest fix?
Similar fix has been proposed by Eric in the past but never committed because original reporter was working with an OOT driver and wasn't providing feedback (see Link).
--- net/core/dev.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
net/core/dev.c +18 -5
@@ -4762,6 +4762,8 @@ int __dev_queue_xmit(struct sk_buff *skb, struct net_device *sb_dev)* to -1 or to their cpu id, but not to our id. */ if (READ_ONCE (txq->xmit_lock_owner) != cpu) { +bool is_list = false; +if (dev_xmit_recursion ()) goto recursion_alert;
@@ -4772,17 +4774,28 @@ int __dev_queue_xmit(struct sk_buff *skb, struct net_device *sb_dev)HARD_TX_LOCK (dev, txq, cpu);if (!netif_xmit_stopped (txq)) { + is_list = !!skb->next; +dev_xmit_recursion_inc (); skb =dev_hard_start_xmit (skb, dev, txq, &rc);dev_xmit_recursion_dec (); -if (dev_xmit_complete (rc)) { -HARD_TX_UNLOCK (dev, txq); - goto out; - } + +/* GSO segments a single SKB into +* a list of frames. TCP expects error +* to mean none of the data was sent. +*/ +if (is_list) + rc =NETDEV_TX_OK ; }HARD_TX_UNLOCK (dev, txq); +if (!skb)/* xmit completed */ + goto out; +net_crit_ratelimited ("Virtual device %s asks to queue packet!\n" , dev->name); +/* NETDEV_TX_BUSY or queue was stopped */ +if (!is_list) + rc = -ENETDOWN ; }else {/* Recursion is detected! It is possible, * unfortunately
@@ -4790,10 +4803,10 @@ int __dev_queue_xmit(struct sk_buff *skb, struct net_device *sb_dev) recursion_alert:net_crit_ratelimited ("Dead loop on virtual device %s, fix it urgently!\n" , dev->name); + rc = -ENETDOWN ; } } - rc = -ENETDOWN ;rcu_read_unlock_bh ();dev_core_stats_tx_dropped_inc (dev);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 453/752 dpaa2-switch: validate num_ifs to prevent out-of-bounds write
In reply to Sasha LevinFrom: Junrui Luo <[email protected]>
[ Upstream commit 8a5752c6dcc085a3bfc78589925182e4e98468c5 ]
The driver obtains sw_attr.num_ifs from firmware via dpsw_get_attributes() but never validates it against DPSW_MAX_IF (64). This value controls iteration in dpaa2_switch_fdb_get_flood_cfg(), which writes port indices into the fixed-size cfg->if_id[DPSW_MAX_IF] array. When firmware reports num_ifs >= 64, the loop can write past the array bounds.
Add a bound check for num_ifs in dpaa2_switch_init().
dpaa2_switch_fdb_get_flood_cfg() appends the control interface (port num_ifs) after all matched ports. When num_ifs == DPSW_MAX_IF and all ports match the flood filter, the loop fills all 64 slots and the control interface write overflows by one entry.
The check uses >= because num_ifs == DPSW_MAX_IF is also functionally broken.
build_if_id_bitmap() silently drops any ID >= 64:
if (id[i] < DPSW_MAX_IF)
bmap[id[i] / 64] |= ...--- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +7 -0
@@ -3034,6 +3034,13 @@ static int dpaa2_switch_init(struct fsl_mc_device *sw_dev) goto err_close; } +if (ethsw->sw_attr.num_ifs >=DPSW_MAX_IF ) { +dev_err (dev,"DPSW num_ifs %u exceeds max %u\n" , + ethsw->sw_attr.num_ifs,DPSW_MAX_IF ); + err = -EINVAL ; + goto err_close; + } + err =dpsw_get_api_version (ethsw->mc_io,0 , ðsw->major, ðsw->minor);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 454/752 netfilter: nf_conntrack_h323: fix OOB read in decode_choice()
In reply to Sasha LevinFrom: Vahagn Vardanian <[email protected]>
[ Upstream commit baed0d9ba91d4f390da12d5039128ee897253d60 ]
In decode_choice(), the boundary check before get_len() uses the variable len, which is still 0 from its initialization at the top of the function:
unsigned int type, ext, len = 0;
...
if (ext || (son->attr & OPEN)) {
BYTE_ALIGN(bs);
if (nf_h323_error_boundary(bs, len, 0)) /* len is 0 here */
return H323_ERROR_BOUND;
len = get_len(bs); /* OOB read */When the bitstream is exactly consumed (bs->cur == bs->end), the check nf_h323_error_boundary(bs, 0, 0) evaluates to (bs->cur + 0 > bs->end), which is false. The subsequent get_len() call then dereferences *bs->cur++, reading 1 byte past the end of the buffer. If that byte has bit 7 set, get_len() reads a second byte as well.
This can be triggered remotely by sending a crafted Q.931 SETUP message with a User-User Information Element containing exactly 2 bytes of PER-encoded data ({0x08, 0x00}) to port 1720 through a firewall with the nf_conntrack_h323 helper active. The decoder fully consumes the PER buffer before reaching this code path, resulting in a 1-2 byte heap-buffer-overflow read confirmed by AddressSanitizer.
Fix this by checking for 2 bytes (the maximum that get_len() may read) instead of the uninitialized len. This matches the pattern used at every other get_len() call site in the same file, where the caller checks for 2 bytes of available data before calling get_len().
--- net/netfilter/nf_conntrack_h323_asn1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_h323_asn1.c +1 -1
@@ -796,7 +796,7 @@ static int decode_choice(struct bitstr *bs, const struct field_t *f,if (ext || (son->attr &OPEN )) {BYTE_ALIGN (bs); -if (nf_h323_error_boundary (bs, len,0 )) +if (nf_h323_error_boundary (bs,2 ,0 ))return H323_ERROR_BOUND ; len =get_len (bs);if (nf_h323_error_boundary (bs, len,0 ))
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 455/752 rpmsg: core: fix race in driver_override_show() and use core helper
In reply to Sasha LevinFrom: Gui-Dong Han <[email protected]>
[ Upstream commit 42023d4b6d2661a40ee2dcf7e1a3528a35c638ca ]
The driver_override_show function reads the driver_override string without holding the device_lock. However, the store function modifies and frees the string while holding the device_lock. This creates a race condition where the string can be freed by the store function while being read by the show function, leading to a use-after-free.
To fix this, replace the rpmsg_string_attr macro with explicit show and store functions. The new driver_override_store uses the standard driver_set_override helper. Since the introduction of driver_set_override, the comments in include/linux/rpmsg.h have stated that this helper must be used to set or clear driver_override, but the implementation was not updated until now.
Because driver_set_override modifies and frees the string while holding the device_lock, the new driver_override_show now correctly holds the device_lock during the read operation to prevent the race.
Additionally, since rpmsg_string_attr has only ever been used for driver_override, removing the macro simplifies the code.
--- drivers/rpmsg/rpmsg_core.c | 66 ++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 39 deletions(-)
drivers/rpmsg/rpmsg_core.c +27 -39
@@ -352,50 +352,38 @@ field##_show(struct device *dev, \ } \static DEVICE_ATTR_RO (field); -#define rpmsg_string_attr (field, member) \ -static ssize_t \ -field##_store(struct device *dev, struct device_attribute *attr, \ - const char *buf, size_t sz) \ -{ \ - struct rpmsg_device *rpdev = to_rpmsg_device(dev); \ - const char *old; \ - char *new; \ - \ - new = kstrndup(buf, sz, GFP_KERNEL); \ - if (!new) \ - return -ENOMEM; \ - new[strcspn(new, "\n")] = '\0'; \ - \ - device_lock(dev); \ - old = rpdev->member; \ - if (strlen(new)) { \ - rpdev->member = new; \ - } else { \ - kfree(new); \ - rpdev->member = NULL; \ - } \ - device_unlock(dev); \ - \ - kfree(old); \ - \ - return sz; \ -} \ -static ssize_t \ -field##_show(struct device *dev, \ - struct device_attribute *attr, char *buf) \ -{ \ - struct rpmsg_device *rpdev = to_rpmsg_device(dev); \ - \ - return sprintf(buf, "%s\n", rpdev->member); \ -} \ -static DEVICE_ATTR_RW(field) -/* for more info, see Documentation/ABI/testing/sysfs-bus-rpmsg */ rpmsg_show_attr (name, id.name,"%s\n" );rpmsg_show_attr (src, src,"0x%x\n" );rpmsg_show_attr (dst, dst,"0x%x\n" );rpmsg_show_attr (announce, announce ?"true" :"false" ,"%s\n" ); -rpmsg_string_attr (driver_override, driver_override); + +static ssize_t driver_override_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +struct rpmsg_device *rpdev =to_rpmsg_device (dev); +int ret; + + ret =driver_set_override (dev, &rpdev->driver_override, buf, count); +if (ret) +return ret; + +return count; +} + +static ssize_t driver_override_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct rpmsg_device *rpdev =to_rpmsg_device (dev); +ssize_t len; + +device_lock (dev); + len =sysfs_emit (buf,"%s\n" , rpdev->driver_override); +device_unlock (dev); +return len; +} +static DEVICE_ATTR_RW (driver_override);static ssize_t modalias_show (struct device *dev,struct device_attribute *attr,char *buf)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 456/752 clk: renesas: rzg2l: Fix intin variable size
In reply to Sasha LevinFrom: Chris Brandt <[email protected]>
[ Upstream commit a00655d98cd885472c311f01dff3e668d1288d0a ]
INTIN is a 12-bit register value, so u8 is too small.
--- drivers/clk/renesas/rzg2l-cpg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/renesas/rzg2l-cpg.c +1 -1
@@ -122,8 +122,8 @@ struct div_hw_data {struct rzg2l_pll5_param {u32 pl5_fracin; +u16 pl5_intin;u8 pl5_refdiv; -u8 pl5_intin;u8 pl5_postdiv1;u8 pl5_postdiv2;u8 pl5_spread;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 457/752 clk: renesas: rzg2l: Select correct div round macro
In reply to Sasha LevinFrom: Chris Brandt <[email protected]>
[ Upstream commit f9451374dcfdfe669ee55b58ee6c11e8638980e4 ]
Variable foutvco_rate is an unsigned long, not an unsigned long long.
--- drivers/clk/renesas/rzg2l-cpg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/renesas/rzg2l-cpg.c +2 -2
@@ -572,8 +572,8 @@ rzg2l_cpg_get_foutpostdiv_rate(struct rzg2l_pll5_param *params, foutvco_rate =div_u64 (mul_u32_u32 (EXTAL_FREQ_IN_MEGA_HZ *MEGA , (params->pl5_intin <<24 ) + params->pl5_fracin), params->pl5_refdiv) >>24 ; - foutpostdiv_rate =DIV_ROUND_CLOSEST_ULL (foutvco_rate, - params->pl5_postdiv1 * params->pl5_postdiv2); + foutpostdiv_rate =DIV_ROUND_CLOSEST (foutvco_rate, + params->pl5_postdiv1 * params->pl5_postdiv2);return foutpostdiv_rate; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 458/752 hfsplus: ensure sb->s_fs_info is always cleaned up
In reply to Sasha LevinFrom: Mehdi Ben Hadj Khelifa <[email protected]>
[ Upstream commit 126fb0ce99431126b44a6c360192668c818f641f ]
When hfsplus was converted to the new mount api a bug was introduced by changing the allocation pattern of sb->s_fs_info. If setup_bdev_super() fails after a new superblock has been allocated by sget_fc(), but before hfsplus_fill_super() takes ownership of the filesystem-specific s_fs_info data it was leaked.
Fix this by freeing sb->s_fs_info in hfsplus_kill_super().
--- fs/hfsplus/super.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
fs/hfsplus/super.c +9 -4
@@ -350,8 +350,6 @@ static void hfsplus_put_super(struct super_block *sb)hfs_btree_close (sbi->ext_tree);kfree (sbi->s_vhdr_buf);kfree (sbi->s_backup_vhdr_buf); -call_rcu (&sbi->rcu, delayed_free); -hfs_dbg ("finished\n" ); }
@@ -656,7 +654,6 @@ static int hfsplus_fill_super(struct super_block *sb, struct fs_context *fc) out_unload_nls:unload_nls (sbi->nls);unload_nls (nls); -kfree (sbi);return err; }
@@ -715,10 +712,18 @@ static int hfsplus_init_fs_context(struct fs_context *fc)return 0 ; } +static void hfsplus_kill_super (struct super_block *sb) +{ +struct hfsplus_sb_info *sbi =HFSPLUS_SB (sb); + +kill_block_super (sb); +call_rcu (&sbi->rcu, delayed_free); +} +static struct file_system_type hfsplus_fs_type = { .owner =THIS_MODULE , .name ="hfsplus" , - .kill_sb = kill_block_super, + .kill_sb = hfsplus_kill_super, .fs_flags =FS_REQUIRES_DEV , .init_fs_context = hfsplus_init_fs_context, };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 459/752 arm64: dts: ti: am62p-verdin: Fix SD regulator startup delay
In reply to Sasha LevinFrom: Francesco Dolcini <[email protected]>
[ Upstream commit de86dbc0fb00bd3773db4b05d9f5926f0faa2244 ]
The power switch used to power the SD card interface might have more than 2ms turn-on time, increase the startup delay to 20ms to prevent failures.
--- arch/arm64/boot/dts/ti/k3-am62p-verdin.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/ti/k3-am62p-verdin.dtsi +1 -1
@@ -112,7 +112,7 @@ reg_sd1_vmmc: regulator-sdhci1-vmmc { regulator-max-microvolt = <3300000>; regulator-min-microvolt = <3300000>; regulator-name = "+V3.3_SD"; - startup-delay-us = <2000>; + startup-delay-us = <20000>; }; reg_sd1_vqmmc: regulator-sdhci1-vqmmc {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 460/752 drm/panthor: fix for dma-fence safe access rules
In reply to Sasha LevinFrom: Chia-I Wu <[email protected]>
[ Upstream commit efe24898485c5c831e629d9c6fb9350c35cb576f ]
Commit 506aa8b02a8d6 ("dma-fence: Add safe access helpers and document the rules") details the dma-fence safe access rules. The most common culprit is that drm_sched_fence_get_timeline_name may race with group_free_queue.
--- drivers/gpu/drm/panthor/panthor_sched.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/panthor/panthor_sched.c +4 -0
@@ -22,6 +22,7 @@#include <linux/module.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/rcupdate.h> #include "panthor_devfreq.h" #include "panthor_device.h"
@@ -926,6 +927,9 @@ static void group_release_work(struct work_struct *work) release_work);u32 i; +/* dma-fences may still be accessing group->queues under rcu lock. */ +synchronize_rcu (); +for (i =0 ; i < group->queue_count; i++)group_free_queue (group, group->queues[i]);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 461/752 ASoC: SOF: ipc4-control: If there is no data do not send bytes update
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit 2fa74713744dc5e908fff851c20f5f89fd665fb7 ]
When the bytes control have no data (payload) then there is no need to send an IPC message as there is nothing to send.
--- sound/soc/sof/ipc4-control.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
sound/soc/sof/ipc4-control.c +10 -2
@@ -412,8 +412,16 @@ static int sof_ipc4_set_get_bytes_data(struct snd_sof_dev *sdev,int ret =0 ;/* Send the new data to the firmware only if it is powered up */ -if (set && !pm_runtime_active (sdev->dev)) -return 0 ; +if (set) { +if (!pm_runtime_active (sdev->dev)) +return 0 ; + +if (!data->size) { +dev_dbg (sdev->dev,"%s: No data to be sent.\n" , + scontrol->name); +return 0 ; + } + } msg->extension =SOF_IPC4_MOD_EXT_MSG_PARAM_ID (data->type);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 462/752 ASoC: SOF: ipc4-topology: Correct the allocation size for bytes controls
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit a653820700b81c9e6f05ac23b7969ecec1a18e85 ]
The size of the data behind of scontrol->ipc_control_data for bytes controls is:
[1] sizeof(struct sof_ipc4_control_data) + // kernel only struct
[2] sizeof(struct sof_abi_hdr)) + payload
The max_size specifies the size of [2] and it is coming from topology.
Change the function to take this into account and allocate adequate amount of memory behind scontrol->ipc_control_data.
With the change we will allocate [1] amount more memory to be able to hold the full size of data.
--- sound/soc/sof/ipc4-topology.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-)
sound/soc/sof/ipc4-topology.c +27 -8
@@ -2861,22 +2861,41 @@ static int sof_ipc4_control_load_bytes(struct snd_sof_dev *sdev, struct snd_sof_struct sof_ipc4_msg *msg;int ret; -if (scontrol->max_size < (sizeof (*control_data) +sizeof (struct sof_abi_hdr ))) { -dev_err (sdev->dev,"insufficient size for a bytes control %s: %zu.\n" , +/* +* The max_size is coming from topology and indicates the maximum size +* of sof_abi_hdr plus the payload, which excludes the local only +* 'struct sof_ipc4_control_data' +*/ +if (scontrol->max_size <sizeof (struct sof_abi_hdr )) { +dev_err (sdev->dev, +"insufficient maximum size for a bytes control %s: %zu.\n" , scontrol->name, scontrol->max_size);return -EINVAL ; } -if (scontrol->priv_size > scontrol->max_size -sizeof (*control_data)) { -dev_err (sdev->dev,"scontrol %s bytes data size %zu exceeds max %zu.\n" , - scontrol->name, scontrol->priv_size, - scontrol->max_size -sizeof (*control_data)); +if (scontrol->priv_size > scontrol->max_size) { +dev_err (sdev->dev, +"bytes control %s initial data size %zu exceeds max %zu.\n" , + scontrol->name, scontrol->priv_size, scontrol->max_size); +return -EINVAL ; + } + +if (scontrol->priv_size <sizeof (struct sof_abi_hdr )) { +dev_err (sdev->dev, +"bytes control %s initial data size %zu is insufficient.\n" , + scontrol->name, scontrol->priv_size);return -EINVAL ; } - scontrol->size =sizeof (struct sof_ipc4_control_data ) + scontrol->priv_size; +/* +* The used size behind the cdata pointer, which can be smaller than +* the maximum size +*/ + scontrol->size =sizeof (*control_data) + scontrol->priv_size; - scontrol->ipc_control_data =kzalloc (scontrol->max_size,GFP_KERNEL ); +/* Allocate the cdata: local struct size + maximum payload size */ + scontrol->ipc_control_data =kzalloc (sizeof (*control_data) + scontrol->max_size, +GFP_KERNEL );if (!scontrol->ipc_control_data)return -ENOMEM ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 463/752 ASoC: SOF: ipc4-control: Use the correct size for scontrol->ipc_control_data
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit c1876fc33c5976837e4c73719c7582617efc6919 ]
The size of the data behind scontrol->ipc_control_data is stored in scontrol->size, use this when copying data for backup/restore.
--- sound/soc/sof/ipc4-control.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/sof/ipc4-control.c +3 -3
@@ -66,7 +66,7 @@ static int sof_ipc4_set_get_kcontrol_data(struct snd_sof_control *scontrol,* configuration */ memcpy (scontrol->ipc_control_data, scontrol->old_ipc_control_data, - scontrol->max_size); + scontrol->size);kfree (scontrol->old_ipc_control_data); scontrol->old_ipc_control_data =NULL ;/* Send the last known good configuration to firmware */
@@ -567,7 +567,7 @@ static int sof_ipc4_bytes_ext_put(struct snd_sof_control *scontrol,if (!scontrol->old_ipc_control_data) {/* Create a backup of the current, valid bytes control */ scontrol->old_ipc_control_data =kmemdup (scontrol->ipc_control_data, - scontrol->max_size,GFP_KERNEL ); + scontrol->size,GFP_KERNEL );if (!scontrol->old_ipc_control_data)return -ENOMEM ; }
@@ -575,7 +575,7 @@ static int sof_ipc4_bytes_ext_put(struct snd_sof_control *scontrol,/* Copy the whole binary data which includes the ABI header and the payload */ if (copy_from_user (data, tlvd->tlv, header.length)) {memcpy (scontrol->ipc_control_data, scontrol->old_ipc_control_data, - scontrol->max_size); + scontrol->size);kfree (scontrol->old_ipc_control_data); scontrol->old_ipc_control_data =NULL ;return -EFAULT ;
Signature · 1 line
2.51.0