6.1.160-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 279/634 spi: cadence-quadspi: Add clock configuration for StarFive JH7110 QSPI
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: William Qiu <[email protected]>
[ Upstream commit 33f1ef6d4eb6bca726608ed939c9fd94d96ceefd ]
Add JH7110's clock initialization code to the driver.
Stable-dep-of: 1889dd208197 ("spi: cadence-quadspi: Fix clock disable on probe failure path")
--- drivers/spi/spi-cadence-quadspi.c | 67 +++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
drivers/spi/spi-cadence-quadspi.c +67 -0
@@ -47,6 +47,12 @@#define CQSPI_OP_WIDTH (part) ((part).nbytes ? ilog2((part).buswidth) : 0) +enum { +CLK_QSPI_APB =0 , +CLK_QSPI_AHB , +CLK_QSPI_NUM , +}; +struct cqspi_st ;struct cqspi_flash_pdata {
@@ -64,6 +70,7 @@ struct cqspi_st {struct platform_device *pdev;struct spi_master *master;struct clk *clk; +struct clk *clks[CLK_QSPI_NUM ];unsigned int sclk;void __iomem *iobase;
@@ -91,6 +98,8 @@ struct cqspi_st {bool wr_completion;bool slow_sram;bool apb_ahb_hazard; + +bool is_jh7110;/* Flag for StarFive JH7110 SoC */ };struct cqspi_driver_platdata {
@@ -99,6 +108,8 @@ struct cqspi_driver_platdata {int (*indirect_read_dma)(struct cqspi_flash_pdata *f_pdata,u_char *rxbuf,loff_t from_addr,size_t n_rx);u32 (*get_dma_status)(struct cqspi_st *cqspi); +int (*jh7110_clk_init)(struct platform_device *pdev, +struct cqspi_st *cqspi); };/* Operation timeout value */
@@ -1592,6 +1603,51 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)return 0 ; } +static int cqspi_jh7110_clk_init (struct platform_device *pdev,struct cqspi_st *cqspi) +{ +static struct clk_bulk_data qspiclk[] = { + { .id ="apb" }, + { .id ="ahb" }, + }; + +int ret =0 ; + + ret =devm_clk_bulk_get (&pdev->dev,ARRAY_SIZE (qspiclk), qspiclk); +if (ret) { +dev_err (&pdev->dev,"%s: failed to get qspi clocks\n" , __func__); +return ret; + } + + cqspi->clks[CLK_QSPI_APB ] = qspiclk[0 ].clk; + cqspi->clks[CLK_QSPI_AHB ] = qspiclk[1 ].clk; + + ret =clk_prepare_enable (cqspi->clks[CLK_QSPI_APB ]); +if (ret) { +dev_err (&pdev->dev,"%s: failed to enable CLK_QSPI_APB\n" , __func__); +return ret; + } + + ret =clk_prepare_enable (cqspi->clks[CLK_QSPI_AHB ]); +if (ret) { +dev_err (&pdev->dev,"%s: failed to enable CLK_QSPI_AHB\n" , __func__); + goto disable_apb_clk; + } + + cqspi->is_jh7110 = true; + +return 0 ; + +disable_apb_clk: +clk_disable_unprepare (cqspi->clks[CLK_QSPI_APB ]); + +return ret; +} + +static void cqspi_jh7110_disable_clk (struct platform_device *pdev,struct cqspi_st *cqspi) +{ +clk_disable_unprepare (cqspi->clks[CLK_QSPI_AHB ]); +clk_disable_unprepare (cqspi->clks[CLK_QSPI_APB ]); +}static int cqspi_probe (struct platform_device *pdev) {const struct cqspi_driver_platdata *ddata;
@@ -1618,6 +1674,7 @@ static int cqspi_probe(struct platform_device *pdev) cqspi->pdev = pdev; cqspi->master = master; + cqspi->is_jh7110 = false;platform_set_drvdata (pdev, cqspi);/* Obtain configuration from OF. */
@@ -1729,6 +1786,12 @@ static int cqspi_probe(struct platform_device *pdev)if (ddata->quirks &CQSPI_NEEDS_APB_AHB_HAZARD_WAR ) cqspi->apb_ahb_hazard = true; +if (ddata->jh7110_clk_init) { + ret =cqspi_jh7110_clk_init (pdev, cqspi); +if (ret) + goto probe_clk_failed; + } +if (of_device_is_compatible (pdev->dev.of_node,"xlnx,versal-ospi-1.0" )) { ret =dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 ));
@@ -1793,6 +1856,9 @@ static int cqspi_remove(struct platform_device *pdev)clk_disable_unprepare (cqspi->clk); +if (cqspi->is_jh7110) +cqspi_jh7110_disable_clk (pdev, cqspi); +pm_runtime_put_sync (&pdev->dev);pm_runtime_disable (&pdev->dev);
@@ -1860,6 +1926,7 @@ static const struct cqspi_driver_platdata versal_ospi = {static const struct cqspi_driver_platdata jh7110_qspi = { .quirks =CQSPI_DISABLE_DAC_MODE , + .jh7110_clk_init = cqspi_jh7110_clk_init, };static const struct cqspi_driver_platdata pensando_cdns_qspi = {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 280/634 spi: cadence-quadspi: add missing clk_disable_unprepare() in cqspi_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Yingliang <[email protected]>
[ Upstream commit 5cb475174cce1bfedf1025b6e235e2c43d81144f ]
cqspi_jh7110_clk_init() is called after clk_prepare_enable(cqspi->clk), if it fails, it should goto label 'probe_reset_failed' to disable cqspi->clk.
In the error path after calling cqspi_jh7110_clk_init(), cqspi_jh7110_disable_clk() need be called.
Stable-dep-of: 1889dd208197 ("spi: cadence-quadspi: Fix clock disable on probe failure path")
--- drivers/spi/spi-cadence-quadspi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-cadence-quadspi.c +3 -1
@@ -1789,7 +1789,7 @@ static int cqspi_probe(struct platform_device *pdev)if (ddata->jh7110_clk_init) { ret =cqspi_jh7110_clk_init (pdev, cqspi);if (ret) - goto probe_clk_failed; + goto probe_reset_failed; } if (of_device_is_compatible(pdev->dev.of_node,
@@ -1836,6 +1836,8 @@ static int cqspi_probe(struct platform_device *pdev) probe_setup_failed:cqspi_controller_enable (cqspi,0 ); probe_reset_failed: +if (cqspi->is_jh7110) +cqspi_jh7110_disable_clk (pdev, cqspi);clk_disable_unprepare (cqspi->clk); probe_clk_failed:pm_runtime_put_sync (dev);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 281/634 spi: cadence-quadspi: Fix clock disable on probe failure path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anurag Dutta <[email protected]>
[ Upstream commit 1889dd2081975ce1f6275b06cdebaa8d154847a9 ]
When cqspi_request_mmap_dma() returns -EPROBE_DEFER after runtime PM is enabled, the error path calls clk_disable_unprepare() on an already disabled clock, causing an imbalance.
Use pm_runtime_get_sync() to increment the usage counter and resume the device. This prevents runtime_suspend() from being invoked and causing a double clock disable.
--- drivers/spi/spi-cadence-quadspi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-cadence-quadspi.c +3 -1
@@ -1838,7 +1838,9 @@ static int cqspi_probe(struct platform_device *pdev) probe_reset_failed:if (cqspi->is_jh7110)cqspi_jh7110_disable_clk (pdev, cqspi); -clk_disable_unprepare (cqspi->clk); + +if (pm_runtime_get_sync (&pdev->dev) >=0 ) +clk_disable_unprepare (cqspi->clk); probe_clk_failed:pm_runtime_put_sync (dev); probe_pm_failed:
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 282/634 block: rnbd-clt: Fix leaked ID in init_dev()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit c9b5645fd8ca10f310e41b07540f98e6a9720f40 ]
If kstrdup() fails in init_dev(), then the newly allocated ID is lost.
--- drivers/block/rnbd/rnbd-clt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/block/rnbd/rnbd-clt.c +8 -5
@@ -1440,9 +1440,11 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess, goto out_alloc; } - ret =ida_alloc_max (&index_ida, (1 << (MINORBITS -RNBD_PART_BITS )) -1 , -GFP_KERNEL ); -if (ret <0 ) { + dev->clt_device_id =ida_alloc_max (&index_ida, + (1 << (MINORBITS -RNBD_PART_BITS )) -1 , +GFP_KERNEL ); +if (dev->clt_device_id <0 ) { + ret = dev->clt_device_id;pr_err ("Failed to initialize device '%s' from session %s, allocating idr failed, err: %d\n" , pathname, sess->sessname, ret); goto out_queues;
@@ -1451,10 +1453,9 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess, dev->pathname =kstrdup (pathname,GFP_KERNEL );if (!dev->pathname) { ret = -ENOMEM ; - goto out_queues; + goto out_ida; } - dev->clt_device_id = ret; dev->sess = sess; dev->access_mode = access_mode; dev->nr_poll_queues = nr_poll_queues;
@@ -1470,6 +1471,8 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess,return dev; +out_ida: +ida_free (&index_ida, dev->clt_device_id); out_queues:kfree (dev->hw_queues); out_alloc:
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 283/634 ksmbd: skip lock-range check on equal size to avoid size==0 underflow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qianchang Zhao <[email protected]>
commit 5d510ac31626ed157d2182149559430350cf2104 upstream.
When size equals the current i_size (including 0), the code used to call check_lock_range(filp, i_size, size - 1, WRITE), which computes size - 1 and can underflow for size==0. Skip the equal case.
--- fs/smb/server/vfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/smb/server/vfs.c +4 -1
@@ -330,6 +330,9 @@ static int check_lock_range(struct filestruct file_lock_context *ctx =file_inode (filp)->i_flctx;int error =0 ; +if (start == end) +return 0 ; +if (!ctx ||list_empty_careful (&ctx->flc_posix))return 0 ;
@@ -830,7 +833,7 @@ int ksmbd_vfs_truncate(struct ksmbd_workif (size < inode->i_size) { err =check_lock_range (filp, size, inode->i_size -1 ,WRITE ); - }else { + }else if (size > inode->i_size) { err =check_lock_range (filp, inode->i_size, size -1 ,WRITE ); }
Greg Kroah-Hartman
maintainerPATCH 284/634 ksmbd: Fix refcount leak when invalid session is found on session lookup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit cafb57f7bdd57abba87725eb4e82bbdca4959644 upstream.
When a session is found but its state is not SMB2_SESSION_VALID, It indicates that no valid session was found, but it is missing to decrement the reference count acquired by the session lookup, which results in a reference count leak. This patch fixes the issue by explicitly calling ksmbd_user_session_put to release the reference to the session.
--- fs/smb/server/mgmt/user_session.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/smb/server/mgmt/user_session.c +3 -1
@@ -312,8 +312,10 @@ struct ksmbd_session *ksmbd_session_look sess =ksmbd_session_lookup (conn, id);if (!sess && conn->binding) sess =ksmbd_session_lookup_slowpath (id); -if (sess && sess->state !=SMB2_SESSION_VALID ) +if (sess && sess->state !=SMB2_SESSION_VALID ) { +ksmbd_user_session_put (sess); sess =NULL ; + }return sess; }
Greg Kroah-Hartman
maintainerPATCH 285/634 ksmbd: fix buffer validation by including null terminator size in EA length
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit 95d7a890e4b03e198836d49d699408fd1867cb55 upstream.
The smb2_set_ea function, which handles Extended Attributes (EA), was performing buffer validation checks that incorrectly omitted the size of the null terminating character (+1 byte) for EA Name.
This patch fixes the issue by explicitly adding '+ 1' to EaNameLength where the null terminator is expected to be present in the buffer, ensuring the validation accurately reflects the total required buffer size.
--- fs/smb/server/smb2pdu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/server/smb2pdu.c +2 -2
@@ -2354,7 +2354,7 @@ static int smb2_set_ea(struct smb2_ea_inint rc =0 ;unsigned int next =0 ; -if (buf_len <sizeof (struct smb2_ea_info ) + eabuf->EaNameLength + +if (buf_len <sizeof (struct smb2_ea_info ) + eabuf->EaNameLength +1 +le16_to_cpu (eabuf->EaValueLength))return -EINVAL ;
@@ -2430,7 +2430,7 @@ next:break ; } -if (buf_len <sizeof (struct smb2_ea_info ) + eabuf->EaNameLength + +if (buf_len <sizeof (struct smb2_ea_info ) + eabuf->EaNameLength +1 +le16_to_cpu (eabuf->EaValueLength)) { rc = -EINVAL ;break ;
Greg Kroah-Hartman
maintainerPATCH 286/634 HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ping Cheng <[email protected]>
commit 7953794f741e94d30df9dafaaa4c031c85b891d6 upstream.
HID_GD_Z is mapped to ABS_Z for stylus and pen in hid-input.c. But HID_GD_Z should be used to report ABS_DISTANCE for stylus and pen as described at:
Documentation/input/event-codes.rst#n226
* ABS_DISTANCE:
- Used to describe the distance of a tool from an interaction surface. This event should only be emitted while the tool is hovering, meaning in close proximity of the device and while the value of the BTN_TOUCH code is 0. If the input device may be used freely in three dimensions, consider ABS_Z instead.
- BTN_TOOL_<name> should be set to 1 when the tool comes into detectable proximity and set to 0 when the tool leaves detectable proximity. BTN_TOOL_<name> signals the type of tool that is currently detected by the hardware and is otherwise independent of ABS_DISTANCE and/or BTN_TOUCH.
This patch makes the correct mapping. The ABS_DISTANCE is currently not mapped by any HID usage in hid-generic driver.
--- drivers/hid/hid-input.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/hid/hid-input.c +17 -1
@@ -871,7 +871,7 @@ static void hidinput_configure_usage(strswitch (usage->hid) {/* These usage IDs map directly to the usage codes. */ -case HID_GD_X :case HID_GD_Y :case HID_GD_Z : +case HID_GD_X :case HID_GD_Y :case HID_GD_RX :case HID_GD_RY :case HID_GD_RZ :if (field->flags &HID_MAIN_ITEM_RELATIVE )map_rel (usage->hid &0xf );
@@ -879,6 +879,22 @@ static void hidinput_configure_usage(strmap_abs_clear (usage->hid &0xf );break ; +case HID_GD_Z : +/* HID_GD_Z is mapped to ABS_DISTANCE for stylus/pen */ +if (field->flags &HID_MAIN_ITEM_RELATIVE ) { +map_rel (usage->hid &0xf ); + }else { +if (field->application ==HID_DG_PEN || + field->physical ==HID_DG_PEN || + field->logical ==HID_DG_STYLUS || + field->physical ==HID_DG_STYLUS || + field->application ==HID_DG_DIGITIZER ) +map_abs_clear (ABS_DISTANCE ); +else +map_abs_clear (usage->hid &0xf ); + } +break ; +case HID_GD_WHEEL :if (field->flags &HID_MAIN_ITEM_RELATIVE ) {set_bit (REL_WHEEL , input->relbit);
Greg Kroah-Hartman
maintainerPATCH 287/634 Input: ti_am335x_tsc - fix off-by-one error in wire_order validation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junjie Cao <[email protected]>
commit 248d3a73a0167dce15ba100477c3e778c4787178 upstream.
The current validation 'wire_order[i] > ARRAY_SIZE(config_pins)' allows wire_order[i] to equal ARRAY_SIZE(config_pins), which causes out-of-bounds access when used as index in 'config_pins[wire_order[i]]'.
Since config_pins has 4 elements (indices 0-3), the valid range for wire_order should be 0-3. Fix the off-by-one error by using >= instead of > in the validation check.
--- drivers/input/touchscreen/ti_am335x_tsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/ti_am335x_tsc.c +1 -1
@@ -86,7 +86,7 @@ static int titsc_config_wires(struct tit wire_order[i] = ts_dev->config_inp[i] &0x0F ;if (WARN_ON (analog_line[i] >7 ))return -EINVAL ; -if (WARN_ON (wire_order[i] >ARRAY_SIZE (config_pins))) +if (WARN_ON (wire_order[i] >=ARRAY_SIZE (config_pins)))return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 288/634 Input: i8042 - add TUXEDO InfinityBook Max Gen10 AMD to i8042 quirk table
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoffer Sandberg <[email protected]>
commit aed3716db7fff74919cc5775ca3a80c8bb246489 upstream.
The device occasionally wakes up from suspend with missing input on the internal keyboard and the following suspend attempt results in an instant wake-up. The quirks fix both issues for this device.
--- drivers/input/serio/i8042-acpipnpio.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/serio/i8042-acpipnpio.h +7 -0
@@ -1169,6 +1169,13 @@ static const struct dmi_system_id i8042_ .driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS | SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP) }, + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "X5KK45xS_X5SP45xS"), + }, + .driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS | + SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP) + }, /* * A lot of modern Clevo barebones have touchpad and/or keyboard issues * after suspend fixable with the forcenorestore quirk.
Greg Kroah-Hartman
maintainerPATCH 289/634 ACPI: CPPC: Fix missing PCC check for guaranteed_perf
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengjie Zhang <[email protected]>
commit 6ea3a44cef28add2d93b1ef119d84886cb1e3c9b upstream.
The current implementation overlooks the 'guaranteed_perf' register in this check.
If the Guaranteed Performance register is located in the PCC subspace, the function currently attempts to read it without acquiring the lock and without sending the CMD_READ doorbell to the firmware. This can result in reading stale data.
--- drivers/acpi/cppc_acpi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/cppc_acpi.c +2 -1
@@ -1267,7 +1267,8 @@ int cppc_get_perf_caps(int cpunum, struc/* Are any of the regs PCC ?*/ if (CPC_IN_PCC (highest_reg) ||CPC_IN_PCC (lowest_reg) ||CPC_IN_PCC (lowest_non_linear_reg) ||CPC_IN_PCC (nominal_reg) || -CPC_IN_PCC (low_freq_reg) ||CPC_IN_PCC (nom_freq_reg)) { +CPC_IN_PCC (low_freq_reg) ||CPC_IN_PCC (nom_freq_reg) || +CPC_IN_PCC (guaranteed_reg)) {if (pcc_ss_id <0 ) {pr_debug ("Invalid pcc_ss_id\n" );return -ENODEV ;
Greg Kroah-Hartman
maintainerPATCH 290/634 spi: fsl-cpm: Check length parity before switching to 16 bit mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
commit 1417927df8049a0194933861e9b098669a95c762 upstream.
Commit fc96ec826bce ("spi: fsl-cpm: Use 16 bit mode for large transfers with even size") failed to make sure that the size is really even before switching to 16 bit mode. Until recently the problem went unnoticed because kernfs uses a pre-allocated bounce buffer of size PAGE_SIZE for reading EEPROM.
But commit 8ad6249c51d0 ("eeprom: at25: convert to spi-mem API") introduced an additional dynamically allocated bounce buffer whose size is exactly the size of the transfer, leading to a buffer overrun in the fsl-cpm driver when that size is odd.
Add the missing length parity verification and remain in 8 bit mode when the length is not even.
--- drivers/spi/spi-fsl-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-fsl-spi.c +1 -1
@@ -352,7 +352,7 @@ static int fsl_spi_prepare_message(strucif (t->bits_per_word ==16 || t->bits_per_word ==32 ) t->bits_per_word =8 ;/* pretend its 8 bits */ if (t->bits_per_word ==8 && t->len >=256 && - (mpc8xxx_spi->flags &SPI_CPM1 )) + !(t->len &1 ) && (mpc8xxx_spi->flags &SPI_CPM1 )) t->bits_per_word =16 ; } }
Greg Kroah-Hartman
maintainerPATCH 291/634 mmc: sdhci-esdhc-imx: add alternate ARCH_S32 dependency to Kconfig
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jared Kangas <[email protected]>
commit d3ecb12e2e04ce53c95f933c462f2d8b150b965b upstream.
MMC_SDHCI_ESDHC_IMX requires ARCH_MXC despite also being used on ARCH_S32, which results in unmet dependencies when compiling strictly for ARCH_S32. Resolve this by adding ARCH_S32 as an alternative to ARCH_MXC in the driver's dependencies.
--- drivers/mmc/host/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/Kconfig +2 -2
@@ -279,14 +279,14 @@ config MMC_SDHCI_ESDHC_MCF config MMC_SDHCI_ESDHC_IMX tristate "SDHCI support for the Freescale eSDHC/uSDHC i.MX controller" - depends on ARCH_MXC || COMPILE_TEST + depends on ARCH_MXC || ARCH_S32 || COMPILE_TEST depends on MMC_SDHCI_PLTFM depends on OF select MMC_SDHCI_IO_ACCESSORS select MMC_CQHCI help This selects the Freescale eSDHC/uSDHC controller support - found on i.MX25, i.MX35 i.MX5x and i.MX6x. + found on i.MX25, i.MX35, i.MX5x, i.MX6x, and S32G. If you have a controller with this interface, say Y or M here.
Greg Kroah-Hartman
maintainerPATCH 292/634 net/hsr: fix NULL pointer dereference in prp_get_untagged_frame()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shaurya Rane <[email protected]>
commit 188e0fa5a679570ea35474575e724d8211423d17 upstream.
prp_get_untagged_frame() calls __pskb_copy() to create frame->skb_std but doesn't check if the allocation failed. If __pskb_copy() returns NULL, skb_clone() is called with a NULL pointer, causing a crash:
Oops: general protection fault, probably for non-canonical address 0xdffffc000000000f: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000078-0x000000000000007f] CPU: 0 UID: 0 PID: 5625 Comm: syz.1.18 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 RIP: 0010:skb_clone+0xd7/0x3a0 net/core/skbuff.c:2041 Code: 03 42 80 3c 20 00 74 08 4c 89 f7 e8 23 29 05 f9 49 83 3e 00 0f 85 a0 01 00 00 e8 94 dd 9d f8 48 8d 6b 7e 49 89 ee 49 c1 ee 03 <43> 0f b6 04 26 84 c0 0f 85 d1 01 00 00 44 0f b6 7d 00 41 83 e7 0c RSP: 0018:ffffc9000d00f200 EFLAGS: 00010207 RAX: ffffffff892235a1 RBX: 0000000000000000 RCX: ffff88803372a480 RDX: 0000000000000000 RSI: 0000000000000820 RDI: 0000000000000000 RBP: 000000000000007e R08: ffffffff8f7d0f77 R09: 1ffffffff1efa1ee R10: dffffc0000000000 R11: fffffbfff1efa1ef R12: dffffc0000000000 R13: 0000000000000820 R14: 000000000000000f R15: ffff88805144cc00 FS: 0000555557f6d500(0000) GS:ffff88808d72f000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000555581d35808 CR3: 000000005040e000 CR4: 0000000000352ef0 Call Trace: <TASK> hsr_forward_do net/hsr/hsr_forward.c:-1 [inline] hsr_forward_skb+0x1013/0x2860 net/hsr/hsr_forward.c:741 hsr_handle_frame+0x6ce/0xa70 net/hsr/hsr_slave.c:84 __netif_receive_skb_core+0x10b9/0x4380 net/core/dev.c:5966 __netif_receive_skb_one_core net/core/dev.c:6077 [inline] __netif_receive_skb+0x72/0x380 net/core/dev.c:6192 netif_receive_skb_internal net/core/dev.c:6278 [inline] netif_receive_skb+0x1cb/0x790 net/core/dev.c:6337 tun_rx_batched+0x1b9/0x730 drivers/net/tun.c:1485 tun_get_user+0x2b65/0x3e90 drivers/net/tun.c:1953 tun_chr_write_iter+0x113/0x200 drivers/net/tun.c:1999 new_sync_write fs/read_write.c:593 [inline] vfs_write+0x5c9/0xb30 fs/read_write.c:686 ksys_write+0x145/0x250 fs/read_write.c:738 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f0449f8e1ff Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 f9 92 02 00 48 8b 54 24 18 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 44 24 08 e8 4c 93 02 00 48 RSP: 002b:00007ffd7ad94c90 EFLAGS: 00000293 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f044a1e5fa0 RCX: 00007f0449f8e1ff RDX: 000000000000003e RSI: 0000200000000500 RDI: 00000000000000c8 RBP: 00007ffd7ad94d20 R08: 0000000000000000 R09: 0000000000000000 R10: 000000000000003e R11: 0000000000000293 R12: 0000000000000001 R13: 00007f044a1e5fa0 R14: 00007f044a1e5fa0 R15: 0000000000000003 </TASK>
Add a NULL check immediately after __pskb_copy() to handle allocation failures gracefully.
--- net/hsr/hsr_forward.c | 2 ++ 1 file changed, 2 insertions(+)
net/hsr/hsr_forward.c +2 -0
@@ -176,6 +176,8 @@ struct sk_buff *prp_get_untagged_frame(s__pskb_copy (frame->skb_prp,skb_headroom (frame->skb_prp),GFP_ATOMIC ); +if (!frame->skb_std) +return NULL ; }else {/* Unexpected */ WARN_ONCE(1, "%s:%d: Unexpected frame received (port_src %s)\n",
Greg Kroah-Hartman
maintainerPATCH 293/634 ALSA: vxpocket: Fix resource leak in vxpocket_probe error path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
[ Upstream commit 2a03b40deacbd293ac9aed0f9b11197dad54fe5f ]
When vxpocket_config() fails, vxpocket_probe() returns the error code directly without freeing the sound card resources allocated by snd_card_new(), which leads to a memory leak.
Add proper error handling to free the sound card and clear the allocation bit when vxpocket_config() fails.
--- sound/pcmcia/vx/vxpocket.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/pcmcia/vx/vxpocket.c +7 -1
@@ -295,7 +295,13 @@ static int vxpocket_probe(struct pcmcia_device *p_dev) vxp->p_dev = p_dev; -return vxpocket_config (p_dev); + err =vxpocket_config (p_dev); +if (err <0 ) { + card_alloc &= ~(1 << i); +snd_card_free (card); +return err; + } +return 0 ; }static void vxpocket_detach (struct pcmcia_device *link)
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 294/634 ALSA: pcmcia: Fix resource leak in snd_pdacf_probe error path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
[ Upstream commit 5032347c04ba7ff9ba878f262e075d745c06a2a8 ]
When pdacf_config() fails, snd_pdacf_probe() returns the error code directly without freeing the sound card resources allocated by snd_card_new(), which leads to a memory leak.
Add proper error handling to free the sound card and clear the card list entry when pdacf_config() fails.
--- sound/pcmcia/pdaudiocf/pdaudiocf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/pcmcia/pdaudiocf/pdaudiocf.c +7 -1
@@ -132,7 +132,13 @@ static int snd_pdacf_probe(struct pcmcia_device *link) link->config_index =1 ; link->config_regs =PRESENT_OPTION ; -return pdacf_config (link); + err =pdacf_config (link); +if (err <0 ) { + card_list[i] =NULL ; +snd_card_free (card); +return err; + } +return 0 ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 295/634 ALSA: usb-mixer: us16x08: validate meter packet indices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shipei Qu <[email protected]>
[ Upstream commit 5526c1c6ba1d0913c7dfcbbd6fe1744ea7c55f1e ]
get_meter_levels_from_urb() parses the 64-byte meter packets sent by the device and fills the per-channel arrays meter_level[], comp_level[] and master_level[] in struct snd_us16x08_meter_store.
Currently the function derives the channel index directly from the meter packet (MUB2(meter_urb, s) - 1) and uses it to index those arrays without validating the range. If the packet contains a negative or out-of-range channel number, the driver may write past the end of these arrays.
Introduce a local channel variable and validate it before updating the arrays. We reject negative indices, limit meter_level[] and comp_level[] to SND_US16X08_MAX_CHANNELS, and guard master_level[] updates with ARRAY_SIZE(master_level).
--- sound/usb/mixer_us16x08.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
sound/usb/mixer_us16x08.c +14 -6
@@ -656,17 +656,25 @@ static void get_meter_levels_from_urb(int s, u8 *meter_urb) {int val =MUC2 (meter_urb, s) + (MUC3 (meter_urb, s) <<8 ); +int ch =MUB2 (meter_urb, s) -1 ; + +if (ch <0 ) +return ;if (MUA0 (meter_urb, s) ==0x61 &&MUA1 (meter_urb, s) ==0x02 &&MUA2 (meter_urb, s) ==0x04 &&MUB0 (meter_urb, s) ==0x62 ) { -if (MUC0 (meter_urb, s) ==0x72 ) - store->meter_level[MUB2 (meter_urb, s) -1 ] = val; -if (MUC0 (meter_urb, s) ==0xb2 ) - store->comp_level[MUB2 (meter_urb, s) -1 ] = val; +if (ch <SND_US16X08_MAX_CHANNELS ) { +if (MUC0 (meter_urb, s) ==0x72 ) + store->meter_level[ch] = val; +if (MUC0 (meter_urb, s) ==0xb2 ) + store->comp_level[ch] = val; + } }if (MUA0 (meter_urb, s) ==0x61 &&MUA1 (meter_urb, s) ==0x02 && -MUA2 (meter_urb, s) ==0x02 &&MUB0 (meter_urb, s) ==0x62 ) - store->master_level[MUB2 (meter_urb, s) -1 ] = val; +MUA2 (meter_urb, s) ==0x02 &&MUB0 (meter_urb, s) ==0x62 ) { +if (ch <ARRAY_SIZE (store->master_level)) + store->master_level[ch] = val; + } }/* Function to retrieve current meter values from the device.
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 296/634 ipmi: Fix the race between __scan_channels() and deliver_response()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinhui Guo <[email protected]>
[ Upstream commit 936750fdba4c45e13bbd17f261bb140dd55f5e93 ]
The race window between __scan_channels() and deliver_response() causes the parameters of some channels to be set to 0.
1.[CPUA] __scan_channels() issues an IPMI request and waits with
wait_event() until all channels have been scanned. wait_event() internally calls might_sleep(), which might yield the CPU. (Moreover, an interrupt can preempt wait_event() and force the task to yield the CPU.)
2.[CPUB] deliver_response() is invoked when the CPU receives the
IPMI response. After processing a IPMI response, deliver_response() directly assigns intf->wchannels to intf->channel_list and sets intf->channels_ready to true. However, not all channels are actually ready for use.
3.[CPUA] Since intf->channels_ready is already true, wait_event()
never enters __wait_event(). __scan_channels() immediately clears intf->null_user_handler and exits.
4.[CPUB] Once intf->null_user_handler is set to NULL, deliver_response()
ignores further IPMI responses, leaving the remaining channels zero-initialized and unusable.
CPUA CPUB
------------------------------- ----------------------------- __scan_channels()
intf->null_user_handler
= channel_handler;
send_channel_info_cmd(intf,
0);
wait_event(intf->waitq,
intf->channels_ready);
do {
might_sleep();
deliver_response()
channel_handler()
intf->channel_list =
intf->wchannels + set;
intf->channels_ready = true;
send_channel_info_cmd(intf,
intf->curr_channel);
if (condition)
break;
__wait_event(wq_head,
condition);
} while(0)
intf->null_user_handler
= NULL;
deliver_response()
if (!msg->user)
if (intf->null_user_handler)
rv = -EINVAL;
return rv;------------------------------- -----------------------------
Fix the race between __scan_channels() and deliver_response() by deferring both the assignment intf->channel_list = intf->wchannels and the flag intf->channels_ready = true until all channels have been successfully scanned or until the IPMI request has failed.
Message-ID: <[email protected]>
--- drivers/char/ipmi/ipmi_msghandler.c | 2 -- 1 file changed, 2 deletions(-)
drivers/char/ipmi/ipmi_msghandler.c +0 -2
@@ -3414,8 +3414,6 @@ channel_handler(struct ipmi_smi *intf, struct ipmi_recv_msg *msg) intf->channels_ready = true;wake_up (&intf->waitq); }else { - intf->channel_list = intf->wchannels + set; - intf->channels_ready = true; rv =send_channel_info_cmd (intf, intf->curr_channel); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 297/634 ipmi: Fix __scan_channels() failing to rescan channels
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinhui Guo <[email protected]>
[ Upstream commit 6bd30d8fc523fb880b4be548e8501bc0fe8f42d4 ]
channel_handler() sets intf->channels_ready to true but never clears it, so __scan_channels() skips any rescan. When the BMC firmware changes a rescan is required. Allow it by clearing the flag before starting a new scan.
Message-ID: <[email protected]>
--- drivers/char/ipmi/ipmi_msghandler.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/char/ipmi/ipmi_msghandler.c +13 -5
@@ -613,7 +613,8 @@ static void __ipmi_bmc_unregister(struct ipmi_smi *intf);static int __ipmi_bmc_register (struct ipmi_smi *intf,struct ipmi_device_id *id,bool guid_set,guid_t *guid,int intf_num); -static int __scan_channels (struct ipmi_smi *intf,struct ipmi_device_id *id); +static int __scan_channels (struct ipmi_smi *intf, +struct ipmi_device_id *id,bool rescan);/**
@@ -2665,7 +2666,7 @@ static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,if (__ipmi_bmc_register (intf, &id, guid_set, &guid, intf_num))need_waiter (intf);/* Retry later on an error. */ else -__scan_channels (intf, &id); +__scan_channels (intf, &id, false);if (!intf_set) {
@@ -2685,7 +2686,7 @@ static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, goto out_noprocessing; }else if (memcmp (&bmc->fetch_id, &bmc->id,sizeof (bmc->id)))/* Version info changes, scan the channels again. */ -__scan_channels (intf, &bmc->fetch_id); +__scan_channels (intf, &bmc->fetch_id, true); bmc->dyn_id_expiry = jiffies +IPMI_DYN_DEV_ID_EXPIRY ;
@@ -3435,10 +3436,17 @@ channel_handler(struct ipmi_smi *intf, struct ipmi_recv_msg *msg)/* * Must be holding intf->bmc_reg_mutex to call this. */ -static int __scan_channels (struct ipmi_smi *intf,struct ipmi_device_id *id) +static int __scan_channels (struct ipmi_smi *intf, +struct ipmi_device_id *id, +bool rescan) {int rv; +if (rescan) { +/* Clear channels_ready to force channels rescan. */ + intf->channels_ready = false; + } +if (ipmi_version_major (id) >1 || (ipmi_version_major (id) ==1 &&ipmi_version_minor (id) >=5 )) {
@@ -3641,7 +3649,7 @@ int ipmi_add_smi(struct module *owner, }mutex_lock (&intf->bmc_reg_mutex); - rv =__scan_channels (intf, &id); + rv =__scan_channels (intf, &id, false);mutex_unlock (&intf->bmc_reg_mutex);if (rv) goto out_err_bmc_reg;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 298/634 firmware: imx: scu-irq: Init workqueue before request mbox channel
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit 81fb53feb66a3aefbf6fcab73bb8d06f5b0c54ad ]
With mailbox channel requested, there is possibility that interrupts may come in, so need to make sure the workqueue is initialized before the queue is scheduled by mailbox rx callback.
--- drivers/firmware/imx/imx-scu-irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/imx/imx-scu-irq.c +2 -2
@@ -148,6 +148,8 @@ int imx_scu_enable_general_irq_channel(struct device *dev) cl->dev = dev; cl->rx_callback = imx_scu_irq_callback; +INIT_WORK (&imx_sc_irq_work, imx_scu_irq_work_handler); +/* SCU general IRQ uses general interrupt channel 3 */ ch =mbox_request_channel_byname (cl,"gip3" );if (IS_ERR (ch)) {
@@ -157,8 +159,6 @@ int imx_scu_enable_general_irq_channel(struct device *dev)return ret; } -INIT_WORK (&imx_sc_irq_work, imx_scu_irq_work_handler); -if (!of_parse_phandle_with_args (dev->of_node,"mboxes" ,"#mbox-cells" ,0 , &spec)) { i =of_alias_get_id (spec.np,"mu" );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 299/634 ti-sysc: allow OMAP2 and OMAP4 timers to be reserved on AM33xx
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthias Schiffer <[email protected]>
[ Upstream commit 3f61783920504b2cf99330b372d82914bb004d8e ]
am33xx.dtsi has the same clock setup as am35xx.dtsi, setting ti,no-reset-on-init and ti,no-idle on timer1_target and timer2_target, so AM33 needs the same workaround as AM35 to avoid ti-sysc probe failing on certain target modules.
--- drivers/bus/ti-sysc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/bus/ti-sysc.c +9 -2
@@ -37,6 +37,7 @@ enum sysc_soc {SOC_UNKNOWN ,SOC_2420 ,SOC_2430 , +SOC_AM33 ,SOC_3430 ,SOC_AM35 , SOC_3630,
@@ -3016,6 +3017,7 @@ static void ti_sysc_idle(struct work_struct *work)static const struct soc_device_attribute sysc_soc_match[] = {SOC_FLAG ("OMAP242*" ,SOC_2420 ),SOC_FLAG ("OMAP243*" ,SOC_2430 ), +SOC_FLAG ("AM33*" ,SOC_AM33 ),SOC_FLAG ("AM35*" ,SOC_AM35 ),SOC_FLAG ("OMAP3[45]*" ,SOC_3430 ),SOC_FLAG ("OMAP3[67]*" ,SOC_3630 ),
@@ -3223,10 +3225,15 @@ static int sysc_check_active_timer(struct sysc *ddata)* can be dropped if we stop supporting old beagleboard revisions * A to B4 at some point. */ -if (sysc_soc->soc ==SOC_3430 || sysc_soc->soc ==SOC_AM35 ) +switch (sysc_soc->soc) { +case SOC_AM33 : +case SOC_3430 : +case SOC_AM35 : error = -ENXIO ; -else +break ; +default : error = -EBUSY ; + }if ((ddata->cfg.quirks &SYSC_QUIRK_NO_RESET_ON_INIT ) && (ddata->cfg.quirks &SYSC_QUIRK_NO_IDLE ))
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 300/634 clk: mvebu: cp110 add CLK_IGNORE_UNUSED to pcie_x10, pcie_x11 & pcie_x4
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josua Mayer <[email protected]>
[ Upstream commit f0e6bc0c3ef4b4afb299bd6912586cafd5d864e9 ]
CP110 based platforms rely on the bootloader for pci port initialization.
TF-A actively prevents non-uboot re-configuration of pci lanes, and many boards do not have software control over the pci card reset.
If a pci port had link at boot-time and the clock is stopped at a later point, the link fails and can not be recovered.
PCI controller driver probe - and by extension ownership of a driver for the pci clocks - may be delayed especially on large modular kernels, causing the clock core to start disabling unused clocks.
Add the CLK_IGNORE_UNUSED flag to the three pci port's clocks to ensure they are not stopped before the pci controller driver has taken ownership and tested for an existing link.
This fixes failed pci link detection when controller driver probes late, e.g. with arm64 defconfig and CONFIG_PHY_MVEBU_CP110_COMPHY=m.
--- drivers/clk/mvebu/cp110-system-controller.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/clk/mvebu/cp110-system-controller.c +20 -0
@@ -110,6 +110,25 @@ static const char * const gate_base_names[] = { [CP110_GATE_EIP197 ] ="eip197" }; +static unsigned long gate_flags (const u8 bit_idx) +{ +switch (bit_idx) { +case CP110_GATE_PCIE_X1_0 : +case CP110_GATE_PCIE_X1_1 : +case CP110_GATE_PCIE_X4 : +/* +* If a port had an active link at boot time, stopping +* the clock creates a failed state from which controller +* driver can not recover. +* Prevent stopping this clock till after a driver has taken +* ownership. +*/ +return CLK_IGNORE_UNUSED ; +default : +return 0 ; + } +}; +struct cp110_gate_clk {struct clk_hw hw;struct regmap *regmap;
@@ -171,6 +190,7 @@ static struct clk_hw *cp110_register_gate(const char *name, init.ops = &cp110_gate_ops; init.parent_names = &parent_name; init.num_parents =1 ; + init.flags =gate_flags (bit_idx); gate->regmap = regmap; gate->bit_idx = bit_idx;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 301/634 powerpc/addnote: Fix overflow on 32-bit builds
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Collins <[email protected]>
[ Upstream commit 825ce89a3ef17f84cf2c0eacfa6b8dc9fd11d13f ]
The PUT_64[LB]E() macros need to cast the value to unsigned long long like the GET_64[LB]E() macros. Caused lots of warnings when compiled on 32-bit, and clobbered addresses (36-bit P4080).
--- arch/powerpc/boot/addnote.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/powerpc/boot/addnote.c +4 -3
@@ -68,8 +68,8 @@ static int e_class = ELFCLASS32;#define PUT_16BE (off, v)(buf[off] = ((v) >> 8) & 0xff, \ buf[(off) + 1] = (v) & 0xff)#define PUT_32BE (off, v)(PUT_16BE((off), (v) >> 16L), PUT_16BE((off) + 2, (v))) -#define PUT_64BE (off, v)((PUT_32BE((off), (v) >> 32L), \ - PUT_32BE((off) + 4, (v)))) +#define PUT_64BE (off, v)((PUT_32BE((off), (unsigned long long)(v) >> 32L), \ + PUT_32BE((off) + 4, (unsigned long long)(v))))#define GET_16LE (off) ((buf[off]) + (buf[(off)+1] << 8))#define GET_32LE (off) (GET_16LE(off) + (GET_16LE((off)+2U) << 16U))
@@ -78,7 +78,8 @@ static int e_class = ELFCLASS32;#define PUT_16LE (off, v) (buf[off] = (v) & 0xff, \ buf[(off) + 1] = ((v) >> 8) & 0xff)#define PUT_32LE (off, v) (PUT_16LE((off), (v)), PUT_16LE((off) + 2, (v) >> 16L)) -#define PUT_64LE (off, v) (PUT_32LE((off), (v)), PUT_32LE((off) + 4, (v) >> 32L)) +#define PUT_64LE (off, v) (PUT_32LE((off), (unsigned long long)(v)), \ + PUT_32LE((off) + 4, (unsigned long long)(v) >> 32L))#define GET_16 (off) (e_data == ELFDATA2MSB ? GET_16BE(off) : GET_16LE(off))#define GET_32 (off) (e_data == ELFDATA2MSB ? GET_32BE(off) : GET_32LE(off))
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 302/634 scsi: qla2xxx: Fix lost interrupts with qlini_mode=disabled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Battersby <[email protected]>
[ Upstream commit 4f6aaade2a22ac428fa99ed716cf2b87e79c9837 ]
When qla2xxx is loaded with qlini_mode=disabled, ha->flags.disable_msix_handshake is used before it is set, resulting in the wrong interrupt handler being used on certain HBAs (qla2xxx_msix_rsp_q_hs() is used when qla2xxx_msix_rsp_q() should be used). The only difference between these two interrupt handlers is that the _hs() version writes to a register to clear the "RISC" interrupt, whereas the other version does not. So this bug results in the RISC interrupt being cleared when it should not be. This occasionally causes a different interrupt handler qla24xx_msix_default() for a different vector to see ((stat & HSRX_RISC_INT) == 0) and ignore its interrupt, which then causes problems like:
qla2xxx [0000:02:00.0]-d04c:6: MBX Command timeout for cmd 20,
iocontrol=8 jiffies=1090c0300 mb[0-3]=[0x4000 0x0 0x40 0xda] mb7 0x500 host_status 0x40000010 hccr 0x3f00
qla2xxx [0000:02:00.0]-101e:6: Mailbox cmd timeout occurred, cmd=0x20,
mb[0]=0x20. Scheduling ISP abort
(the cmd varies; sometimes it is 0x20, 0x22, 0x54, 0x5a, 0x5d, or 0x6a)
This problem can be reproduced with a 16 or 32 Gbps HBA by loading qla2xxx with qlini_mode=disabled and running a high IOPS test while triggering frequent RSCN database change events.
While analyzing the problem I discovered that even with disable_msix_handshake forced to 0, it is not necessary to clear the RISC interrupt from qla2xxx_msix_rsp_q_hs() (more below). So just completely remove qla2xxx_msix_rsp_q_hs() and the logic for selecting it, which also fixes the bug with qlini_mode=disabled.
The test below describes the justification for not needing qla2xxx_msix_rsp_q_hs():
Force disable_msix_handshake to 0:qla24xx_config_rings():
if (0 && (ha->fw_attributes & BIT_6) && (IS_MSIX_NACK_CAPABLE(ha)) &&
(ha->flags.msix_enabled)) {In qla24xx_msix_rsp_q() and qla2xxx_msix_rsp_q_hs(), check:
(rd_reg_dword(®->host_status) & HSRX_RISC_INT)
Count the number of calls to each function with HSRX_RISC_INT set and the number with HSRX_RISC_INT not set while performing some I/O.
If qla2xxx_msix_rsp_q_hs() clears the RISC interrupt (original code):
qla24xx_msix_rsp_q: 50% of calls have HSRX_RISC_INT set qla2xxx_msix_rsp_q_hs: 5% of calls have HSRX_RISC_INT set
(# of qla2xxx_msix_rsp_q_hs interrupts) =
(# of qla24xx_msix_rsp_q interrupts) * 3
If qla2xxx_msix_rsp_q_hs() does not clear the RISC interrupt (patched code):
qla24xx_msix_rsp_q: 100% of calls have HSRX_RISC_INT set qla2xxx_msix_rsp_q_hs: 9% of calls have HSRX_RISC_INT set
(# of qla2xxx_msix_rsp_q_hs interrupts) =
(# of qla24xx_msix_rsp_q interrupts) * 3
In the case of the original code, qla24xx_msix_rsp_q() was seeing HSRX_RISC_INT set only 50% of the time because qla2xxx_msix_rsp_q_hs() was clearing it when it shouldn't have been. In the patched code, qla24xx_msix_rsp_q() sees HSRX_RISC_INT set 100% of the time, which makes sense if that interrupt handler needs to clear the RISC interrupt (which it does). qla2xxx_msix_rsp_q_hs() sees HSRX_RISC_INT only 9% of the time, which is just overlap from the other interrupt during the high IOPS test.
Tested with SCST on:
QLE2742 FW:v9.08.02 (32 Gbps 2-port)
QLE2694L FW:v9.10.11 (16 Gbps 4-port)
QLE2694L FW:v9.08.02 (16 Gbps 4-port)
QLE2672 FW:v8.07.12 (16 Gbps 2-port)
both initiator and target mode
--- drivers/scsi/qla2xxx/qla_def.h | 1 - drivers/scsi/qla2xxx/qla_gbl.h | 2 +- drivers/scsi/qla2xxx/qla_isr.c | 32 +++----------------------------- drivers/scsi/qla2xxx/qla_mid.c | 4 +--- 4 files changed, 5 insertions(+), 34 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +0 -1
@@ -3461,7 +3461,6 @@ struct isp_operations {#define QLA_MSIX_RSP_Q 0x01#define QLA_ATIO_VECTOR 0x02#define QLA_MSIX_QPAIR_MULTIQ_RSP_Q 0x03 -#define QLA_MSIX_QPAIR_MULTIQ_RSP_Q_HS 0x04#define QLA_MIDX_DEFAULT 0#define QLA_MIDX_RSP_Q 1
drivers/scsi/qla2xxx/qla_gbl.h +1 -1
@@ -776,7 +776,7 @@ extern int qla2x00_dfs_remove(scsi_qla_host_t *);/* Globa function prototypes for multi-q */ extern int qla25xx_request_irq (struct qla_hw_data *,struct qla_qpair *, -struct qla_msix_entry *,int ); +struct qla_msix_entry *);extern int qla25xx_init_req_que (struct scsi_qla_host *,struct req_que *);extern int qla25xx_init_rsp_que (struct scsi_qla_host *,struct rsp_que *); extern int qla25xx_create_req_que(struct qla_hw_data *, uint16_t, uint8_t,
drivers/scsi/qla2xxx/qla_isr.c +3 -29
@@ -4313,32 +4313,6 @@ qla2xxx_msix_rsp_q(int irq, void *dev_id)return IRQ_HANDLED ; } -irqreturn_t -qla2xxx_msix_rsp_q_hs (int irq,void *dev_id) -{ -struct qla_hw_data *ha; -struct qla_qpair *qpair; -struct device_reg_24xx __iomem *reg; -unsigned long flags; - - qpair = dev_id; -if (!qpair) { -ql_log (ql_log_info,NULL ,0x505b , -"%s: NULL response queue pointer.\n" , __func__); -return IRQ_NONE ; - } - ha = qpair->hw; - - reg = &ha->iobase->isp24; -spin_lock_irqsave (&ha->hardware_lock, flags); -wrt_reg_dword (®->hccr,HCCRX_CLR_RISC_INT ); -spin_unlock_irqrestore (&ha->hardware_lock, flags); - -queue_work (ha->wq, &qpair->q_work); - -return IRQ_HANDLED ; -} -/* Interrupt handling helpers. */ struct qla_init_msix_entry {
@@ -4351,7 +4325,6 @@ static const struct qla_init_msix_entry msix_entries[] = { { "rsp_q", qla24xx_msix_rsp_q }, { "atio_q", qla83xx_msix_atio_q }, { "qpair_multiq", qla2xxx_msix_rsp_q }, - { "qpair_multiq_hs", qla2xxx_msix_rsp_q_hs }, }; static const struct qla_init_msix_entry qla82xx_msix_entries[] = {
@@ -4638,9 +4611,10 @@ qla2x00_free_irqs(scsi_qla_host_t *vha) }int qla25xx_request_irq (struct qla_hw_data *ha,struct qla_qpair *qpair, -struct qla_msix_entry *msix,int vector_type) +struct qla_msix_entry *msix) { -const struct qla_init_msix_entry *intr = &msix_entries[vector_type]; +const struct qla_init_msix_entry *intr = + &msix_entries[QLA_MSIX_QPAIR_MULTIQ_RSP_Q ];scsi_qla_host_t *vha =pci_get_drvdata (ha->pdev);int ret;
drivers/scsi/qla2xxx/qla_mid.c +1 -3
@@ -908,9 +908,7 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options, rsp->options, rsp->id, rsp->rsp_q_in, rsp->rsp_q_out); - ret =qla25xx_request_irq (ha, qpair, qpair->msix, - ha->flags.disable_msix_handshake ? -QLA_MSIX_QPAIR_MULTIQ_RSP_Q :QLA_MSIX_QPAIR_MULTIQ_RSP_Q_HS ); + ret =qla25xx_request_irq (ha, qpair, qpair->msix);if (ret) goto que_failed;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 303/634 scsi: qla2xxx: Fix initiator mode with qlini_mode=exclusive
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Battersby <[email protected]>
[ Upstream commit 8f58fc64d559b5fda1b0a5e2a71422be61e79ab9 ]
When given the module parameter qlini_mode=exclusive, qla2xxx in initiator mode is initially unable to successfully send SCSI commands to devices it finds while scanning, resulting in an escalating series of resets until an adapter reset clears the issue. Fix by checking the active mode instead of the module parameter.
--- drivers/scsi/qla2xxx/qla_os.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +1 -7
@@ -3458,13 +3458,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) ha->mqenable =0 ;if (ha->mqenable) { -bool startit = false; - -if (QLA_TGT_MODE_ENABLED ()) - startit = false; - -if (ql2x_ini_mode ==QLA2XXX_INI_MODE_ENABLED ) - startit = true; +bool startit = !!(host->active_mode &MODE_INITIATOR );/* Create start of day qpairs for Block MQ */ for (i =0 ; i < ha->max_qpairs; i++)
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 304/634 scsi: qla2xxx: Use reinit_completion on mbx_intr_comp
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Battersby <[email protected]>
[ Upstream commit 957aa5974989fba4ae4f807ebcb27f12796edd4d ]
If a mailbox command completes immediately after wait_for_completion_timeout() times out, ha->mbx_intr_comp could be left in an inconsistent state, causing the next mailbox command not to wait for the hardware. Fix by reinitializing the completion before use.
--- drivers/scsi/qla2xxx/qla_mbx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/qla2xxx/qla_mbx.c +2 -0
@@ -253,6 +253,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)/* Issue set host interrupt command to send cmd out. */ ha->flags.mbox_int =0 ;clear_bit (MBX_INTERRUPT , &ha->mbx_cmd_flags); +reinit_completion (&ha->mbx_intr_comp);/* Unlock mbx registers and wait for interrupt */ ql_dbg(ql_dbg_mbx, vha, 0x100f,
@@ -279,6 +280,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) "cmd=%x Timeout.\n", command);spin_lock_irqsave (&ha->hardware_lock, flags);clear_bit (MBX_INTR_WAIT , &ha->mbx_cmd_flags); +reinit_completion (&ha->mbx_intr_comp);spin_unlock_irqrestore (&ha->hardware_lock, flags);if (chip_reset != ha->chip_reset) {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 305/634 via_wdt: fix critical boot hang due to unnamed resource allocation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Qiang <[email protected]>
[ Upstream commit 7aa31ee9ec92915926e74731378c009c9cc04928 ]
The VIA watchdog driver uses allocate_resource() to reserve a MMIO region for the watchdog control register. However, the allocated resource was not given a name, which causes the kernel resource tree to contain an entry marked as "<BAD>" under /proc/iomem on x86 platforms.
During boot, this unnamed resource can lead to a critical hang because subsequent resource lookups and conflict checks fail to handle the invalid entry properly.
--- drivers/watchdog/via_wdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/via_wdt.c +1 -0
@@ -165,6 +165,7 @@ static int wdt_probe(struct pci_dev *pdev,dev_err (&pdev->dev,"cannot enable PCI device\n" );return -ENODEV ; } + wdt_res.name ="via_wdt" ;/* * Allocate a MMIO region which contains watchdog control register
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 306/634 reset: fix BIT macro reference
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Encrow Thorne <[email protected]>
[ Upstream commit f3d8b64ee46c9b4b0b82b1a4642027728bac95b8 ]
RESET_CONTROL_FLAGS_BIT_* macros use BIT(), but reset.h does not include bits.h. This causes compilation errors when including reset.h standalone.
Include bits.h to make reset.h self-contained.
--- include/linux/reset.h | 1 + 1 file changed, 1 insertion(+)
include/linux/reset.h +1 -0
@@ -2,6 +2,7 @@#ifndef _LINUX_RESET_H_#define _LINUX_RESET_H_ +#include <linux/bits.h> #include <linux/err.h> #include <linux/errno.h> #include <linux/types.h>
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 307/634 exfat: fix remount failure in different process environments
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuezhang Mo <[email protected]>
[ Upstream commit 51fc7b4ce10ccab8ea5e4876bcdc42cf5202a0ef ]
The kernel test robot reported that the exFAT remount operation failed. The reason for the failure was that the process's umask is different between mount and remount, causing fs_fmask and fs_dmask are changed.
Potentially, both gid and uid may also be changed. Therefore, when initializing fs_context for remount, inherit these mount options from the options used during mount.
--- fs/exfat/super.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
fs/exfat/super.c +15 -4
@@ -763,10 +763,21 @@ static int exfat_init_fs_context(struct fs_context *fc)ratelimit_state_init (&sbi->ratelimit,DEFAULT_RATELIMIT_INTERVAL ,DEFAULT_RATELIMIT_BURST ); - sbi->options.fs_uid =current_uid (); - sbi->options.fs_gid =current_gid (); - sbi->options.fs_fmask = current->fs->umask; - sbi->options.fs_dmask = current->fs->umask; +if (fc->purpose ==FS_CONTEXT_FOR_RECONFIGURE && fc->root) { +struct super_block *sb = fc->root->d_sb; +struct exfat_mount_options *cur_opts = &EXFAT_SB (sb)->options; + + sbi->options.fs_uid = cur_opts->fs_uid; + sbi->options.fs_gid = cur_opts->fs_gid; + sbi->options.fs_fmask = cur_opts->fs_fmask; + sbi->options.fs_dmask = cur_opts->fs_dmask; + }else { + sbi->options.fs_uid =current_uid (); + sbi->options.fs_gid =current_gid (); + sbi->options.fs_fmask = current->fs->umask; + sbi->options.fs_dmask = current->fs->umask; + } + sbi->options.allow_utime =-1 ; sbi->options.iocharset = exfat_default_iocharset; sbi->options.errors =EXFAT_ERRORS_RO ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 308/634 usbip: Fix locking bug in RT-enabled kernels
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Xu <[email protected]>
[ Upstream commit 09bf21bf5249880f62fe759b53b14b4b52900c6c ]
Interrupts are disabled before entering usb_hcd_giveback_urb(). A spinlock_t becomes a sleeping lock on PREEMPT_RT, so it cannot be acquired with disabled interrupts.
Save the interrupt status and restore it after usb_hcd_giveback_urb().
syz reported:
BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48 Call Trace: dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120 rt_spin_lock+0xc7/0x2c0 kernel/locking/spinlock_rt.c:57 spin_lock include/linux/spinlock_rt.h:44 [inline] mon_bus_complete drivers/usb/mon/mon_main.c:134 [inline] mon_complete+0x5c/0x200 drivers/usb/mon/mon_main.c:147 usbmon_urb_complete include/linux/usb/hcd.h:738 [inline] __usb_hcd_giveback_urb+0x254/0x5e0 drivers/usb/core/hcd.c:1647 vhci_urb_enqueue+0xb4f/0xe70 drivers/usb/usbip/vhci_hcd.c:818
--- drivers/usb/usbip/vhci_hcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/usbip/vhci_hcd.c +3 -3
@@ -830,15 +830,15 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag no_need_xmit:usb_hcd_unlink_urb_from_ep (hcd, urb); no_need_unlink: -spin_unlock_irqrestore (&vhci->lock, flags);if (!ret) {/* usb_hcd_giveback_urb() should be called with * irqs disabled */ -local_irq_disable (); +spin_unlock (&vhci->lock);usb_hcd_giveback_urb (hcd, urb, urb->status); -local_irq_enable (); +spin_lock (&vhci->lock); } +spin_unlock_irqrestore (&vhci->lock, flags);return ret; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 309/634 usb: typec: ucsi: Handle incorrect num_connectors capability
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Pearson <[email protected]>
[ Upstream commit 30cd2cb1abf4c4acdb1ddb468c946f68939819fb ]
The UCSI spec states that the num_connectors field is 7 bits, and the 8th bit is reserved and should be set to zero.
Some buggy FW has been known to set this bit, and it can lead to a system not booting.
Flag that the FW is not behaving correctly, and auto-fix the value so that the system boots correctly.
Found on Lenovo P1 G8 during Linux enablement program. The FW will be fixed, but seemed worth addressing in case it hit platforms that aren't officially Linux supported.
--- drivers/usb/typec/ucsi/ucsi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/typec/ucsi/ucsi.c +6 -0
@@ -1276,6 +1276,12 @@ static int ucsi_init(struct ucsi *ucsi) ret = -ENODEV ; goto err_reset; } +/* Check if reserved bit set. This is out of spec but happens in buggy FW */ +if (ucsi->cap.num_connectors &0x80 ) { +dev_warn (ucsi->dev,"UCSI: Invalid num_connectors %d. Likely buggy FW\n" , + ucsi->cap.num_connectors); + ucsi->cap.num_connectors &=0x7f ;// clear bit and carry on + }/* Allocate the connectors. Released in ucsi_unregister() */ connector =kcalloc (ucsi->cap.num_connectors +1 ,sizeof (*connector),GFP_KERNEL );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 310/634 iio: adc: ti_am335x_adc: Limit step_avg to valid range for gcc complains
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit c9fb952360d0c78bbe98239bd6b702f05c2dbb31 ]
FIELD_PREP() checks that a value fits into the available bitfield, add a check for step_avg to fix gcc complains.
which gcc complains about:
drivers/iio/adc/ti_am335x_adc.c: In function 'tiadc_step_config':
include/linux/compiler_types.h:572:38: error: call to
'__compiletime_assert_491' declared with attribute error: FIELD_PREP: value too large for the field include/linux/mfd/ti_am335x_tscadc.h:58:29: note:
in expansion of macro 'FIELD_PREP'
#define STEPCONFIG_AVG(val) FIELD_PREP(GENMASK(4, 2), (val))
^~~~~~~~~~
drivers/iio/adc/ti_am335x_adc.c:127:17: note: in expansion of macro 'STEPCONFIG_AVG'
stepconfig = STEPCONFIG_AVG(ffs(adc_dev->step_avg[i]) - 1)--- drivers/iio/adc/ti_am335x_adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ti_am335x_adc.c +1 -1
@@ -124,7 +124,7 @@ static void tiadc_step_config(struct iio_dev *indio_dev) chan = adc_dev->channel_line[i]; -if (adc_dev->step_avg[i]) +if (adc_dev->step_avg[i] && adc_dev->step_avg[i] <=STEPCONFIG_AVG_16 ) stepconfig =STEPCONFIG_AVG (ffs (adc_dev->step_avg[i]) -1 ) |STEPCONFIG_FIFO1 ;else
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 311/634 usb: xhci: limit run_graceperiod for only usb 3.0 devices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyu Xie <[email protected]>
[ Upstream commit 8d34983720155b8f05de765f0183d9b0e1345cc0 ]
run_graceperiod blocks usb 2.0 devices from auto suspending after xhci_start for 500ms.
Log shows:
[ 13.387170] xhci_hub_control:1271: xhci-hcd PNP0D10:03: Get port status 7-1 read: 0x2a0, return 0x100 [ 13.387177] hub_event:5779: hub 7-0:1.0: state 7 ports 1 chg 0000 evt 0000 [ 13.387182] hub_suspend:3903: hub 7-0:1.0: hub_suspend [ 13.387188] hcd_bus_suspend:2250: usb usb7: bus auto-suspend, wakeup 1 [ 13.387191] hcd_bus_suspend:2279: usb usb7: suspend raced with wakeup event [ 13.387193] hcd_bus_resume:2303: usb usb7: usb auto-resume [ 13.387296] hub_event:5779: hub 3-0:1.0: state 7 ports 1 chg 0000 evt 0000 [ 13.393343] handle_port_status:2034: xhci-hcd PNP0D10:02: handle_port_status: starting usb5 port polling. [ 13.393353] xhci_hub_control:1271: xhci-hcd PNP0D10:02: Get port status 5-1 read: 0x206e1, return 0x10101 [ 13.400047] hub_suspend:3903: hub 3-0:1.0: hub_suspend [ 13.403077] hub_resume:3948: hub 7-0:1.0: hub_resume [ 13.403080] xhci_hub_control:1271: xhci-hcd PNP0D10:03: Get port status 7-1 read: 0x2a0, return 0x100 [ 13.403085] hub_event:5779: hub 7-0:1.0: state 7 ports 1 chg 0000 evt 0000 [ 13.403087] hub_suspend:3903: hub 7-0:1.0: hub_suspend [ 13.403090] hcd_bus_suspend:2250: usb usb7: bus auto-suspend, wakeup 1 [ 13.403093] hcd_bus_suspend:2279: usb usb7: suspend raced with wakeup event [ 13.403095] hcd_bus_resume:2303: usb usb7: usb auto-resume [ 13.405002] handle_port_status:1913: xhci-hcd PNP0D10:04: Port change event, 9-1, id 1, portsc: 0x6e1 [ 13.405016] hub_activate:1169: usb usb5-port1: status 0101 change 0001 [ 13.405026] xhci_clear_port_change_bit:658: xhci-hcd PNP0D10:02: clear port1 connect change, portsc: 0x6e1 [ 13.413275] hcd_bus_suspend:2250: usb usb3: bus auto-suspend, wakeup 1 [ 13.419081] hub_resume:3948: hub 7-0:1.0: hub_resume [ 13.419086] xhci_hub_control:1271: xhci-hcd PNP0D10:03: Get port status 7-1 read: 0x2a0, return 0x100 [ 13.419095] hub_event:5779: hub 7-0:1.0: state 7 ports 1 chg 0000 evt 0000 [ 13.419100] hub_suspend:3903: hub 7-0:1.0: hub_suspend [ 13.419106] hcd_bus_suspend:2250: usb usb7: bus auto-suspend, wakeup 1 [ 13.419110] hcd_bus_suspend:2279: usb usb7: suspend raced with wakeup event [ 13.419112] hcd_bus_resume:2303: usb usb7: usb auto-resume [ 13.420455] handle_port_status:2034: xhci-hcd PNP0D10:04: handle_port_status: starting usb9 port polling. [ 13.420493] handle_port_status:1913: xhci-hcd PNP0D10:05: Port change event, 10-1, id 1, portsc: 0x6e1 [ 13.425332] hcd_bus_suspend:2279: usb usb3: suspend raced with wakeup event [ 13.431931] handle_port_status:2034: xhci-hcd PNP0D10:05: handle_port_status: starting usb10 port polling. [ 13.435080] hub_resume:3948: hub 7-0:1.0: hub_resume [ 13.435084] xhci_hub_control:1271: xhci-hcd PNP0D10:03: Get port status 7-1 read: 0x2a0, return 0x100 [ 13.435092] hub_event:5779: hub 7-0:1.0: state 7 ports 1 chg 0000 evt 0000 [ 13.435096] hub_suspend:3903: hub 7-0:1.0: hub_suspend [ 13.435102] hcd_bus_suspend:2250: usb usb7: bus auto-suspend, wakeup 1 [ 13.435106] hcd_bus_suspend:2279: usb usb7: suspend raced with wakeup event
usb7 and other usb 2.0 root hub were rapidly toggling between suspend and resume states. More, "suspend raced with wakeup event" confuses people.
So, limit run_graceperiod for only usb 3.0 devices
--- drivers/usb/host/xhci-hub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-hub.c +1 -1
@@ -1652,7 +1652,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)* SS devices are only visible to roothub after link training completes. * Keep polling roothubs for a grace period after xHC start */ -if (xhci->run_graceperiod) { +if (hcd->speed >=HCD_USB3 && xhci->run_graceperiod) {if (time_before (jiffies, xhci->run_graceperiod)) status =1 ;else
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 312/634 usb: usb-storage: No additional quirks need to be added to the EL-R12 optical drive.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Changcheng <[email protected]>
[ Upstream commit 955a48a5353f4fe009704a9a4272a3adf627cd35 ]
The optical drive of EL-R12 has the same vid and pid as INIC-3069, as follows:
T: Bus=02 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 3 Spd=5000 MxCh= 0 D: Ver= 3.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs= 1 P: Vendor=13fd ProdID=3940 Rev= 3.10 S: Manufacturer=HL-DT-ST S: Product= DVD+-RW GT80N S: SerialNumber=423349524E4E38303338323439202020 C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=144mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=02 Prot=50 Driver=usb-storage E: Ad=83(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=0a(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
This will result in the optical drive device also adding the quirks of US_FL_NO_ATA_1X. When performing an erase operation, it will fail, and the reason for the failure is as follows:
[ 388.967742] sr 5:0:0:0: [sr0] tag#0 Send: scmd 0x00000000d20c33a7 [ 388.967742] sr 5:0:0:0: [sr0] tag#0 CDB: ATA command pass through(12)/Blank a1 11 00 00 00 00 00 00 00 00 00 00 [ 388.967773] sr 5:0:0:0: [sr0] tag#0 Done: SUCCESS Result: hostbyte=DID_TARGET_FAILURE driverbyte=DRIVER_OK cmd_age=0s [ 388.967773] sr 5:0:0:0: [sr0] tag#0 CDB: ATA command pass through(12)/Blank a1 11 00 00 00 00 00 00 00 00 00 00 [ 388.967803] sr 5:0:0:0: [sr0] tag#0 Sense Key : Illegal Request [current] [ 388.967803] sr 5:0:0:0: [sr0] tag#0 Add. Sense: Invalid field in cdb [ 388.967803] sr 5:0:0:0: [sr0] tag#0 scsi host busy 1 failed 0 [ 388.967803] sr 5:0:0:0: Notifying upper driver of completion (result 8100002) [ 388.967834] sr 5:0:0:0: [sr0] tag#0 0 sectors total, 0 bytes done.
For the EL-R12 standard optical drive, all operational commands and usage scenarios were tested without adding the IGNORE_RESIDUE quirks, and no issues were encountered. It can be reasonably concluded that removing the IGNORE_RESIDUE quirks has no impact.
--- drivers/usb/storage/unusual_uas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/unusual_uas.h +1 -1
@@ -98,7 +98,7 @@ UNUSUAL_DEV(0x125f, 0xa94a, 0x0160, 0x0160, US_FL_NO_ATA_1X),/* Reported-by: Benjamin Tissoires <[email protected]> */ -UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x9999, +UNUSUAL_DEV(0x13fd, 0x3940, 0x0309, 0x0309, "Initio Corporation", "INIC-3069", USB_SC_DEVICE, USB_PR_DEVICE, NULL,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 313/634 serial: sprd: Return -EPROBE_DEFER when uart clock is not ready
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenhua Lin <[email protected]>
[ Upstream commit 29e8a0c587e328ed458380a45d6028adf64d7487 ]
In sprd_clk_init(), when devm_clk_get() returns -EPROBE_DEFER for either uart or source clock, we should propagate the error instead of just warning and continuing with NULL clocks.
Currently the driver only emits a warning when clock acquisition fails and proceeds with NULL clock pointers. This can lead to issues later when the clocks are actually needed. More importantly, when the clock provider is not ready yet and returns -EPROBE_DEFER, we should return this error to allow deferred probing.
This change adds explicit checks for -EPROBE_DEFER after both:
1. devm_clk_get(uport->dev, uart)
2. devm_clk_get(uport->dev, source)
When -EPROBE_DEFER is encountered, the function now returns -EPROBE_DEFER to let the driver framework retry probing later when the clock dependencies are resolved.
--- drivers/tty/serial/sprd_serial.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/tty/serial/sprd_serial.c +6 -0
@@ -1136,6 +1136,9 @@ static int sprd_clk_init(struct uart_port *uport) clk_uart =devm_clk_get (uport->dev,"uart" );if (IS_ERR (clk_uart)) { +if (PTR_ERR (clk_uart) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +dev_warn (uport->dev,"uart%d can't get uart clock\n" , uport->line); clk_uart =NULL ;
@@ -1143,6 +1146,9 @@ static int sprd_clk_init(struct uart_port *uport) clk_parent =devm_clk_get (uport->dev,"source" );if (IS_ERR (clk_parent)) { +if (PTR_ERR (clk_parent) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +dev_warn (uport->dev,"uart%d can't get source clock\n" , uport->line); clk_parent =NULL ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 314/634 nvme-fc: dont hold rport lock when putting ctrl
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wagner <[email protected]>
[ Upstream commit b71cbcf7d170e51148d5467820ae8a72febcb651 ]
nvme_fc_ctrl_put can acquire the rport lock when freeing the ctrl object:
nvme_fc_ctrl_put
nvme_fc_ctrl_free
spin_lock_irqsave(rport->lock)
Thus we can't hold the rport lock when calling nvme_fc_ctrl_put.
Justin suggested use the safe list iterator variant because nvme_fc_ctrl_put will also modify the rport->list.
--- drivers/nvme/host/fc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvme/host/fc.c +4 -2
@@ -1501,14 +1501,14 @@ nvme_fc_match_disconn_ls(struct nvme_fc_rport *rport, {struct fcnvme_ls_disconnect_assoc_rqst *rqst = &lsop->rqstbuf->rq_dis_assoc; -struct nvme_fc_ctrl *ctrl, *ret =NULL ; +struct nvme_fc_ctrl *ctrl, *tmp, *ret =NULL ;struct nvmefc_ls_rcv_op *oldls =NULL ;u64 association_id =be64_to_cpu (rqst->associd.association_id);unsigned long flags;spin_lock_irqsave (&rport->lock, flags); -list_for_each_entry (ctrl, &rport->ctrl_list, ctrl_list) { +list_for_each_entry_safe (ctrl, tmp, &rport->ctrl_list, ctrl_list) {if (!nvme_fc_ctrl_get (ctrl))continue ;spin_lock (&ctrl->lock);
@@ -1521,7 +1521,9 @@ nvme_fc_match_disconn_ls(struct nvme_fc_rport *rport,if (ret)/* leave the ctrl get reference */ break ; +spin_unlock_irqrestore (&rport->lock, flags);nvme_fc_ctrl_put (ctrl); +spin_lock_irqsave (&rport->lock, flags); }spin_unlock_irqrestore (&rport->lock, flags);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 315/634 platform/x86/intel/hid: Add Dell Pro Rugged 10/12 tablet to VGBS DMI quirks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chia-Lin Kao (AceLan) <[email protected]>
[ Upstream commit b169e1733cadb614e87f69d7a5ae1b186c50d313 ]
Dell Pro Rugged 10/12 tablets has a reliable VGBS method.
If VGBS is not called on boot, the on-screen keyboard won't appear if the device is booted without a keyboard.
Call VGBS on boot on thess devices to get the initial state of SW_TABLET_MODE in a reliable way.
--- drivers/platform/x86/intel/hid.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/platform/x86/intel/hid.c +12 -0
@@ -144,6 +144,18 @@ static const struct dmi_system_id dmi_vgbs_allow_list[] = { DMI_MATCH(DMI_PRODUCT_NAME, "HP Elite Dragonfly G2 Notebook PC"), }, }, + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Dell Pro Rugged 10 Tablet RA00260"), + }, + }, + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Dell Pro Rugged 12 Tablet RA02260"), + }, + }, { } };
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 316/634 block: rnbd-clt: Fix signedness bug in init_dev()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 1ddb815fdfd45613c32e9bd1f7137428f298e541 ]
The "dev->clt_device_id" variable is set using ida_alloc_max() which returns an int and in particular it returns negative error codes. Change the type from u32 to int to fix the error checking.
--- drivers/block/rnbd/rnbd-clt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rnbd/rnbd-clt.h +1 -1
@@ -112,7 +112,7 @@ struct rnbd_clt_dev {struct rnbd_queue *hw_queues;u32 device_id;/* local Idr index - used to track minor number allocations. */ -u32 clt_device_id; +int clt_device_id;struct mutex lock;enum rnbd_clt_dev_state dev_state;refcount_t refcount;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 317/634 vhost/vsock: improve RCU read sections around vhost_vsock_get()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Garzarella <[email protected]>
[ Upstream commit d8ee3cfdc89b75dc059dc21c27bef2c1440f67eb ]
vhost_vsock_get() uses hash_for_each_possible_rcu() to find the vhost_vsock associated with the guest_cid. hash_for_each_possible_rcu() should only be called within an RCU read section, as mentioned in the following comment in include/linux/rculist.h:
/**
* hlist_for_each_entry_rcu - iterate over rcu list of given type
* @pos: the type * to use as a loop cursor.
* @head: the head for your list.
* @member: the name of the hlist_node within the struct.
* @cond: optional lockdep expression if called from non-RCU protection.
*
* This list-traversal primitive may safely run concurrently with
* the _rcu list-mutation primitives such as hlist_add_head_rcu()
* as long as the traversal is guarded by rcu_read_lock(). */
Currently, all calls to vhost_vsock_get() are between rcu_read_lock() and rcu_read_unlock() except for calls in vhost_vsock_set_cid() and vhost_vsock_reset_orphans(). In both cases, the current code is safe, but we can make improvements to make it more robust.
About vhost_vsock_set_cid(), when building the kernel with CONFIG_PROVE_RCU_LIST enabled, we get the following RCU warning when the user space issues ioctl(dev, VHOST_VSOCK_SET_GUEST_CID, ...) :
WARNING: suspicious RCU usage
6.18.0-rc7 #62 Not tainted
-----------------------------
drivers/vhost/vsock.c:74 RCU-list traversed in non-reader section!!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by rpc-libvirtd/3443:
#0: ffffffffc05032a8 (vhost_vsock_mutex){+.+.}-{4:4}, at: vhost_vsock_dev_ioctl+0x2ff/0x530 [vhost_vsock]
stack backtrace: CPU: 2 UID: 0 PID: 3443 Comm: rpc-libvirtd Not tainted 6.18.0-rc7 #62 PREEMPT(none) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-7.fc42 06/10/2025 Call Trace: <TASK> dump_stack_lvl+0x75/0xb0 dump_stack+0x14/0x1a lockdep_rcu_suspicious.cold+0x4e/0x97 vhost_vsock_get+0x8f/0xa0 [vhost_vsock] vhost_vsock_dev_ioctl+0x307/0x530 [vhost_vsock] __x64_sys_ioctl+0x4f2/0xa00 x64_sys_call+0xed0/0x1da0 do_syscall_64+0x73/0xfa0 entry_SYSCALL_64_after_hwframe+0x76/0x7e ... </TASK>
This is not a real problem, because the vhost_vsock_get() caller, i.e. vhost_vsock_set_cid(), holds the vhost_vsock_mutex used by the hash table writers. Anyway, to prevent that warning, add lockdep_is_held() condition to hash_for_each_possible_rcu() to verify that either the caller is in an RCU read section or vhost_vsock_mutex is held when CONFIG_PROVE_RCU_LIST is enabled; and also clarify the comment for vhost_vsock_get() to better describe the locking requirements and the scope of the returned pointer validity.
About vhost_vsock_reset_orphans(), currently this function is only called via vsock_for_each_connected_socket(), which holds the vsock_table_lock spinlock (which is also an RCU read-side critical section). However, add an explicit RCU read lock there to make the code more robust and explicit about the RCU requirements, and to prevent issues if the calling context changes in the future or if vhost_vsock_reset_orphans() is called from other contexts.
Message-Id: <[email protected]>
Message-ID: <20251126210313.GA499503@fedora>
--- drivers/vhost/vsock.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/vsock.c +11 -4
@@ -64,14 +64,15 @@ static u32 vhost_transport_get_local_cid(void)return VHOST_VSOCK_DEFAULT_HOST_CID ; } -/* Callers that dereference the return value must hold vhost_vsock_mutex or the -* RCU read lock. +/* Callers must be in an RCU read section or hold the vhost_vsock_mutex. +* The return value can only be dereferenced while within the section. */ static struct vhost_vsock *vhost_vsock_get (u32 guest_cid) {struct vhost_vsock *vsock; -hash_for_each_possible_rcu (vhost_vsock_hash, vsock, hash, guest_cid) { +hash_for_each_possible_rcu (vhost_vsock_hash, vsock, hash, guest_cid, +lockdep_is_held (&vhost_vsock_mutex)) {u32 other_cid = vsock->guest_cid;/* Skip instances that have no CID yet */
@@ -693,9 +694,15 @@ static void vhost_vsock_reset_orphans(struct sock *sk)* executing. */ +rcu_read_lock (); +/* If the peer is still valid, no need to reset connection */ -if (vhost_vsock_get (vsk->remote_addr.svm_cid)) +if (vhost_vsock_get (vsk->remote_addr.svm_cid)) { +rcu_read_unlock ();return ; + } + +rcu_read_unlock ();/* If the close timeout is pending, let it expire. This avoids races * with the timeout callback.
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 318/634 KEYS: trusted: Fix a memory leak in tpm2_load_cmd
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <[email protected]>
commit 62cd5d480b9762ce70d720a81fa5b373052ae05f upstream.
'tpm2_load_cmd' allocates a tempoary blob indirectly via 'tpm2_key_decode' but it is not freed in the failure paths. Address this by wrapping the blob into with a cleanup helper.
--- security/keys/trusted-keys/trusted_tpm2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
security/keys/trusted-keys/trusted_tpm2.c +4 -2
@@ -375,6 +375,7 @@ static int tpm2_load_cmd(struct tpm_chipstruct trusted_key_options *options, u32 *blob_handle) { + u8 *blob_ref __free(kfree) = NULL;struct tpm_buf buf;unsigned int private_len;unsigned int public_len;
@@ -388,6 +389,9 @@ static int tpm2_load_cmd(struct tpm_chip/* old form */ blob = payload->blob; payload->old_format =1 ; + }else { +/* Bind for cleanup: */ + blob_ref = blob; }/* new format carries keyhandle but old format doesn't */
@@ -446,8 +450,6 @@ static int tpm2_load_cmd(struct tpm_chip (__be32 *) &buf.data[TPM_HEADER_SIZE]); out: -if (blob != payload->blob) -kfree (blob);tpm_buf_destroy (&buf);if (rc >0 )
Greg Kroah-Hartman
maintainerPATCH 319/634 mmc: sdhci-msm: Avoid early clock doubling during HS400 transition
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarthak Garg <[email protected]>
commit b1f856b1727c2eaa4be2c6d7cd7a8ed052bbeb87 upstream.
According to the hardware programming guide, the clock frequency must remain below 52MHz during the transition to HS400 mode.
However,in the current implementation, the timing is set to HS400 (a DDR mode) before adjusting the clock. This causes the clock to double prematurely to 104MHz during the transition phase, violating the specification and potentially resulting in CRC errors or CMD timeouts.
This change ensures that clock doubling is avoided during intermediate transitions and is applied only when the card requires a 200MHz clock for HS400 operation.
--- drivers/mmc/host/sdhci-msm.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
drivers/mmc/host/sdhci-msm.c +15 -12
@@ -340,41 +340,43 @@ static void sdhci_msm_v5_variant_writel_writel_relaxed (val, host->ioaddr + offset); } -static unsigned int msm_get_clock_mult_for_bus_mode (struct sdhci_host *host) +static unsigned int msm_get_clock_mult_for_bus_mode (struct sdhci_host *host, +unsigned int clock, +unsigned int timing) { -struct mmc_ios ios = host->mmc->ios;/* * The SDHC requires internal clock frequency to be double the * actual clock that will be set for DDR mode. The controller * uses the faster clock(100/400MHz) for some of its parts and * send the actual required clock (50/200MHz) to the card. */ -if (ios.timing ==MMC_TIMING_UHS_DDR50 || - ios.timing ==MMC_TIMING_MMC_DDR52 || - ios.timing ==MMC_TIMING_MMC_HS400 || +if (timing ==MMC_TIMING_UHS_DDR50 || + timing ==MMC_TIMING_MMC_DDR52 || + (timing ==MMC_TIMING_MMC_HS400 && + clock ==MMC_HS200_MAX_DTR ) || host->flags &SDHCI_HS400_TUNING )return 2 ;return 1 ; }static void msm_set_clock_rate_for_bus_mode (struct sdhci_host *host, -unsigned int clock) +unsigned int clock, +unsigned int timing) {struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_msm_host *msm_host =sdhci_pltfm_priv (pltfm_host); -struct mmc_ios curr_ios = host->mmc->ios;struct clk *core_clk = msm_host->bulk_clks[0 ].clk;unsigned long achieved_rate;unsigned int desired_rate;unsigned int mult;int rc; - mult =msm_get_clock_mult_for_bus_mode (host); + mult =msm_get_clock_mult_for_bus_mode (host, clock, timing); desired_rate = clock * mult; rc =dev_pm_opp_set_rate (mmc_dev (host->mmc), desired_rate);if (rc) {pr_err ("%s: Failed to set clock at rate %u at timing %d\n" , -mmc_hostname (host->mmc), desired_rate, curr_ios.timing); +mmc_hostname (host->mmc), desired_rate, timing);return ; }
@@ -393,7 +395,7 @@ static void msm_set_clock_rate_for_bus_m msm_host->clk_rate = desired_rate;pr_debug ("%s: Setting clock at rate %lu at timing %d\n" , -mmc_hostname (host->mmc), achieved_rate, curr_ios.timing); +mmc_hostname (host->mmc), achieved_rate, timing); }/* Platform specific tuning */
@@ -1235,7 +1237,7 @@ static int sdhci_msm_execute_tuning(stru*/ if (host->flags &SDHCI_HS400_TUNING ) {sdhci_msm_hc_select_mode (host); -msm_set_clock_rate_for_bus_mode (host, ios.clock); +msm_set_clock_rate_for_bus_mode (host, ios.clock, ios.timing); host->flags &= ~SDHCI_HS400_TUNING ; }
@@ -1860,6 +1862,7 @@ static void sdhci_msm_set_clock(struct s {struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_msm_host *msm_host =sdhci_pltfm_priv (pltfm_host); +struct mmc_ios ios = host->mmc->ios;if (!clock) { host->mmc->actual_clock = msm_host->clk_rate =0 ;
@@ -1868,7 +1871,7 @@ static void sdhci_msm_set_clock(struct ssdhci_msm_hc_select_mode (host); -msm_set_clock_rate_for_bus_mode (host, clock); +msm_set_clock_rate_for_bus_mode (host, ios.clock, ios.timing); out:__sdhci_msm_set_clock (host, clock); }
Greg Kroah-Hartman
maintainerPATCH 320/634 lib/crypto: x86/blake2s: Fix 32-bit arg treated as 64-bit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 2f22115709fc7ebcfa40af3367a508fbbd2f71e9 upstream.
In the C code, the 'inc' argument to the assembly functions blake2s_compress_ssse3() and blake2s_compress_avx512() is declared with type u32, matching blake2s_compress(). The assembly code then reads it from the 64-bit %rcx. However, the ABI doesn't guarantee zero-extension to 64 bits, nor do gcc or clang guarantee it. Therefore, fix these functions to read this argument from the 32-bit %ecx.
In theory, this bug could have caused the wrong 'inc' value to be used, causing incorrect BLAKE2s hashes. In practice, probably not: I've fixed essentially this same bug in many other assembly files too, but there's never been a real report of it having caused a problem. In x86_64, all writes to 32-bit registers are zero-extended to 64 bits. That results in zero-extension in nearly all situations. I've only been able to demonstrate a lack of zero-extension with a somewhat contrived example involving truncation, e.g. when the C code has a u64 variable holding 0x1234567800000040 and passes it as a u32 expecting it to be truncated to 0x40 (64). But that's not what the real code does, of course.
--- arch/x86/crypto/blake2s-core.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/crypto/blake2s-core.S +2 -2
@@ -54,7 +54,7 @@ SYM_FUNC_START(blake2s_compress_ssse3) movdqa ROT16(%rip),%xmm12 movdqa ROR328(%rip),%xmm13 movdqu 0x20(%rdi),%xmm14 - movq %rcx,%xmm15 + movd %ecx,%xmm15 leaq SIGMA+0xa0(%rip),%r8 jmp .Lbeginofloop .align 32
@@ -179,7 +179,7 @@ SYM_FUNC_START(blake2s_compress_avx512) vmovdqu (%rdi),%xmm0 vmovdqu 0x10(%rdi),%xmm1 vmovdqu 0x20(%rdi),%xmm4 - vmovq %rcx,%xmm5 + vmovd %ecx,%xmm5 vmovdqa IV(%rip),%xmm14 vmovdqa IV+16(%rip),%xmm15 jmp .Lblake2s_compress_avx512_mainloop
Greg Kroah-Hartman
maintainerPATCH 321/634 s390/dasd: Fix gendisk parent after copy pair swap
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Haberland <[email protected]>
commit c943bfc6afb8d0e781b9b7406f36caa8bbf95cb9 upstream.
After a copy pair swap the block device's "device" symlink points to the secondary CCW device, but the gendisk's parent remained the primary, leaving /sys/block/<dasdx> under the wrong parent.
Move the gendisk to the secondary's device with device_move(), keeping the sysfs topology consistent after the swap.
--- drivers/s390/block/dasd_eckd.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/s390/block/dasd_eckd.c +8 -0
@@ -6190,6 +6190,7 @@ static int dasd_eckd_copy_pair_swap(strustruct dasd_copy_relation *copy;struct dasd_block *block;struct gendisk *gdp; +int rc; copy = device->copy;if (!copy)
@@ -6224,6 +6225,13 @@ static int dasd_eckd_copy_pair_swap(stru/* swap blocklayer device link */ gdp = block->gdp;dasd_add_link_to_gendisk (gdp, secondary); + rc =device_move (disk_to_dev (gdp), &secondary->cdev->dev,DPM_ORDER_NONE ); +if (rc) { +dev_err (&primary->cdev->dev, +"copy_pair_swap: moving blockdevice parent %s->%s failed (%d)\n" , +dev_name (&primary->cdev->dev), +dev_name (&secondary->cdev->dev), rc); + }/* re-enable device */ dasd_device_remove_stop_bits (primary,DASD_STOPPED_PPRC );
Greg Kroah-Hartman
maintainerPATCH 322/634 block: rate-limit capacity change info log
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Chen <[email protected]>
commit 3179a5f7f86bcc3acd5d6fb2a29f891ef5615852 upstream.
loop devices under heavy stress-ng loop streessor can trigger many capacity change events in a short time. Each event prints an info message from set_capacity_and_notify(), flooding the console and contributing to soft lockups on slow consoles.
Switch the printk in set_capacity_and_notify() to pr_info_ratelimited() so frequent capacity changes do not spam the log while still reporting occasional changes.
--- block/genhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/genhd.c +1 -1
@@ -88,7 +88,7 @@ bool set_capacity_and_notify(struct gend (disk->flags & GENHD_FL_HIDDEN))return false; -pr_info ("%s: detected capacity change from %lld to %lld\n" , +pr_info_ratelimited ("%s: detected capacity change from %lld to %lld\n" , disk->disk_name, capacity, size);/*
Greg Kroah-Hartman
maintainerPATCH 323/634 floppy: fix for PAGE_SIZE != 4KB
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rene Rebe <[email protected]>
commit 82d20481024cbae2ea87fe8b86d12961bfda7169 upstream.
For years I wondered why the floppy driver does not just work on sparc64, e.g:
root@SUNW_375_0066:# disktype /dev/fd0 disktype: Can't open /dev/fd0: No such device or address
[ 525.341906] disktype: attempt to access beyond end of device fd0: rw=0, sector=0, nr_sectors = 16 limit=8 [ 525.341991] floppy: error 10 while reading block 0
Turns out floppy.c __floppy_read_block_0 tries to read one page for the first test read to determine the disk size and thus fails if that is greater than 4k. Adjust minimum MAX_DISK_SIZE to PAGE_SIZE to fix floppy on sparc64 and likely all other PAGE_SIZE != 4KB configs.
--- drivers/block/floppy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/floppy.c +1 -1
@@ -331,7 +331,7 @@ static bool initialized;* This default is used whenever the current disk size is unknown. * [Now it is rather a minimum] */ -#define MAX_DISK_SIZE 4/* 3984 */ +#define MAX_DISK_SIZE (PAGE_SIZE / 1024)/* * globals used by 'result()'
Greg Kroah-Hartman
maintainerPATCH 324/634 kallsyms: Fix wrong "big" kernel symbol type read from procfs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zheng Yejian <[email protected]>
commit f3f9f42232dee596d15491ca3f611d02174db49c upstream.
Currently when the length of a symbol is longer than 0x7f characters, its type shown in /proc/kallsyms can be incorrect.
I found this issue when reading the code, but it can be reproduced by following steps:
1. Define a function which symbol length is 130 characters:
#define X13(x) x##x##x##x##x##x##x##x##x##x##x##x##x
static noinline void X13(x123456789)(void)
{
printk("hello world\n");
}2. The type in vmlinux is 't':
$ nm vmlinux | grep x123456
ffffffff816290f0 t x123456789x123456789x123456789x12[...] 3. Then boot the kernel, the type shown in /proc/kallsyms becomes 'g'
instead of the expected 't':
# cat /proc/kallsyms | grep x123456
ffffffff816290f0 g x123456789x123456789x123456789x12[...]The root cause is that, after commit 73bbb94466fd ("kallsyms: support "big" kernel symbols"), ULEB128 was used to encode symbol name length. That is, for "big" kernel symbols of which name length is longer than 0x7f characters, the length info is encoded into 2 bytes.
kallsyms_get_symbol_type() expects to read the first char of the symbol name which indicates the symbol type. However, due to the "big" symbol case not being handled, the symbol type read from /proc/kallsyms may be wrong, so handle it properly.
--- kernel/kallsyms.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/kallsyms.c +4 -1
@@ -103,8 +103,11 @@ static char kallsyms_get_symbol_type(uns {/* * Get just the first code, look it up in the token table, -* and return the first char from this token. +* and return the first char from this token. If MSB of length +* is 1, it is a "big" symbol, so needs an additional byte. */ +if (kallsyms_names[off] &0x80 ) + off++;return kallsyms_token_table[kallsyms_token_index[kallsyms_names[off +1 ]]]; }
Greg Kroah-Hartman
maintainerPATCH 325/634 fs/ntfs3: fix mount failure for sparse runs in run_unpack()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
commit 801f614ba263cb37624982b27b4c82f3c3c597a9 upstream.
Some NTFS volumes failed to mount because sparse data runs were not handled correctly during runlist unpacking. The code performed arithmetic on the special SPARSE_LCN64 marker, leading to invalid LCN values and mount errors.
Add an explicit check for the case described above, marking the run as sparse without applying arithmetic.
--- fs/ntfs3/run.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ntfs3/run.c +5 -1
@@ -984,8 +984,12 @@ int run_unpack(struct runs_tree *run, stif (!dlcn)return -EINVAL ; -if (check_add_overflow (prev_lcn, dlcn, &lcn)) +/* Check special combination: 0 + SPARSE_LCN64. */ +if (!prev_lcn && dlcn ==SPARSE_LCN64 ) { + lcn =SPARSE_LCN64 ; + }else if (check_add_overflow (prev_lcn, dlcn, &lcn)) {return -EINVAL ; + } prev_lcn = lcn; }else return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 326/634 ktest.pl: Fix uninitialized var in config-bisect.pl
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit d3042cbe84a060b4df764eb6c5300bbe20d125ca upstream.
The error path of copying the old config used the wrong variable in the error message:
$ mkdir /tmp/build $ ./tools/testing/ktest/config-bisect.pl -b /tmp/build config-good /tmp/config-bad $ chmod 0 /tmp/build $ ./tools/testing/ktest/config-bisect.pl -b /tmp/build config-good /tmp/config-bad good cp /tmp/build//.config config-good.tmp ... [0 seconds] FAILED! Use of uninitialized value $config in concatenation (.) or string at ./tools/testing/ktest/config-bisect.pl line 744. failed to copy to config-good.tmp
When it should have shown:
failed to copy /tmp/build//.config to config-good.tmp
--- tools/testing/ktest/config-bisect.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/ktest/config-bisect.pl +2 -2
@@ -741,9 +741,9 @@ if ($start) { die "Can not find file $bad\n"; } if ($val eq "good") { - run_command "cp $output_config $good" or die "failed to copy $config to $good\n"; + run_command "cp $output_config $good" or die "failed to copy $output_config to $good\n"; } elsif ($val eq "bad") { - run_command "cp $output_config $bad" or die "failed to copy $config to $bad\n"; + run_command "cp $output_config $bad" or die "failed to copy $output_config to $bad\n"; } }
Greg Kroah-Hartman
maintainerPATCH 327/634 ext4: xattr: fix null pointer deref in ext4_raw_inode()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karina Yankevich <[email protected]>
commit b97cb7d6a051aa6ebd57906df0e26e9e36c26d14 upstream.
If ext4_get_inode_loc() fails (e.g. if it returns -EFSCORRUPTED), iloc.bh will remain set to NULL. Since ext4_xattr_inode_dec_ref_all() lacks error checking, this will lead to a null pointer dereference in ext4_raw_inode(), called right after ext4_get_inode_loc().
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Message-ID: <[email protected]>
--- fs/ext4/xattr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ext4/xattr.c +5 -1
@@ -1138,7 +1138,11 @@ ext4_xattr_inode_dec_ref_all(handle_t *hif (block_csum) end = (void *)bh->b_data + bh->b_size;else { -ext4_get_inode_loc (parent, &iloc); + err =ext4_get_inode_loc (parent, &iloc); +if (err) { +EXT4_ERROR_INODE (parent,"parent inode loc (error %d)" , err); +return ; + } end = (void *)ext4_raw_inode (&iloc) +EXT4_SB (parent->i_sb)->s_inode_size; }
Greg Kroah-Hartman
maintainerPATCH 328/634 ext4: clear i_state_flags when alloc inode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haibo Chen <[email protected]>
commit 4091c8206cfd2e3bb529ef260887296b90d9b6a2 upstream.
i_state_flags used on 32-bit archs, need to clear this flag when alloc inode.
Find this issue when umount ext4, sometimes track the inode as orphan accidently, cause ext4 mesg dump.
Message-ID: <[email protected]>
--- fs/ext4/ialloc.c | 1 - fs/ext4/inode.c | 1 - fs/ext4/super.c | 1 + 3 files changed, 1 insertion(+), 2 deletions(-)
fs/ext4/ialloc.c +0 -1
@@ -1300,7 +1300,6 @@ got: sizeof(gen)); } -ext4_clear_state_flags (ei);/* Only relevant on 32-bit archs */ ext4_set_inode_state (inode,EXT4_STATE_NEW ); ei->i_extra_isize = sbi->s_want_extra_isize;
fs/ext4/inode.c +0 -1
@@ -4937,7 +4937,6 @@ struct inode *__ext4_iget(struct super_b ei->i_projid =make_kprojid (&init_user_ns, i_projid);set_nlink (inode,le16_to_cpu (raw_inode->i_links_count)); -ext4_clear_state_flags (ei);/* Only relevant on 32-bit archs */ ei->i_inline_off =0 ; ei->i_dir_start_lookup =0 ; ei->i_dtime =le32_to_cpu (raw_inode->i_dtime);
fs/ext4/super.c +1 -0
@@ -1327,6 +1327,7 @@ static struct inode *ext4_alloc_inode(stinode_set_iversion (&ei->vfs_inode,1 ); ei->i_flags =0 ; +ext4_clear_state_flags (ei);/* Only relevant on 32-bit archs */ spin_lock_init (&ei->i_raw_lock);INIT_LIST_HEAD (&ei->i_prealloc_list);atomic_set (&ei->i_prealloc_active,0 );
Greg Kroah-Hartman
maintainerPATCH 329/634 ext4: fix incorrect group number assertion in mb_check_buddy
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongjian Sun <[email protected]>
commit 3f7a79d05c692c7cfec70bf104b1b3c3d0ce6247 upstream.
When the MB_CHECK_ASSERT macro is enabled, an assertion failure can occur in __mb_check_buddy when checking preallocated blocks (pa) in a block group:
Assertion failure in mb_free_blocks() : "groupnr == e4b->bd_group"
This happens when a pa at the very end of a block group (e.g., pa_pstart=32765, pa_len=3 in a group of 32768 blocks) becomes exhausted - its pa_pstart is advanced by pa_len to 32768, which lies in the next block group. If this exhausted pa (with pa_len == 0) is still in the bb_prealloc_list during the buddy check, the assertion incorrectly flags it as belonging to the wrong group. A possible sequence is as follows:
ext4_mb_new_blocks
ext4_mb_release_context
pa->pa_pstart += EXT4_C2B(sbi, ac->ac_b_ex.fe_len)
pa->pa_len -= ac->ac_b_ex.fe_len
__mb_check_buddy
for each pa in group
ext4_get_group_no_and_offset
MB_CHECK_ASSERT(groupnr == e4b->bd_group)To fix this, we modify the check to skip block group validation for exhausted preallocations (where pa_len == 0). Such entries are in a transitional state and will be removed from the list soon, so they should not trigger an assertion. This change prevents the false positive while maintaining the integrity of the checks for active allocations.
Message-ID: <[email protected]>
--- fs/ext4/mballoc.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ext4/mballoc.c +2 -0
@@ -767,6 +767,8 @@ static void __mb_check_buddy(struct ext4ext4_group_t groupnr;struct ext4_prealloc_space *pa; pa = list_entry(cur, struct ext4_prealloc_space, pa_group_list); +if (!pa->pa_len) +continue ;ext4_get_group_no_and_offset (sb, pa->pa_pstart, &groupnr, &k);MB_CHECK_ASSERT (groupnr == e4b->bd_group);for (i =0 ; i < pa->pa_len; i++)
Greg Kroah-Hartman
maintainerPATCH 330/634 ext4: align max orphan file size with e2fsprogs limit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit 7c11c56eb32eae96893eebafdbe3decadefe88ad upstream.
Kernel commit 0a6ce20c1564 ("ext4: verify orphan file size is not too big") limits the maximum supported orphan file size to 8 << 20.
However, in e2fsprogs, the orphan file size is set to 32–512 filesystem blocks when creating a filesystem.
With 64k block size, formatting an ext4 fs >32G gives an orphan file bigger than the kernel allows, so mount prints an error and fails:
EXT4-fs (vdb): orphan file too big: 8650752
EXT4-fs (vdb): mount failed
To prevent this issue and allow previously created 64KB filesystems to mount, we updates the maximum allowed orphan file size in the kernel to 512 filesystem blocks.
Message-ID: <[email protected]>
--- fs/ext4/orphan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/orphan.c +3 -1
@@ -8,6 +8,8 @@#include "ext4.h" #include "ext4_jbd2.h" +#define EXT4_MAX_ORPHAN_FILE_BLOCKS 512 +static int ext4_orphan_file_add (handle_t *handle,struct inode *inode) {int i, j, start;
@@ -589,7 +591,7 @@ int ext4_init_orphan_info(struct super_b* consuming absurd amounts of memory when pinning blocks of orphan * file in memory. */ -if (inode->i_size >8 <<20 ) { +if (inode->i_size > (EXT4_MAX_ORPHAN_FILE_BLOCKS << inode->i_blkbits)) {ext4_msg (sb,KERN_ERR ,"orphan file too big: %llu" , (unsigned long long )inode->i_size); ret = -EFSCORRUPTED ;
Greg Kroah-Hartman
maintainerPATCH 331/634 jbd2: use a weaker annotation in journal handling
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Byungchul Park <[email protected]>
commit 40a71b53d5a6d4ea17e4d54b99b2ac03a7f5e783 upstream.
jbd2 journal handling code doesn't want jbd2_might_wait_for_commit() to be placed between start_this_handle() and stop_this_handle(). So it marks the region with rwsem_acquire_read() and rwsem_release().
However, the annotation is too strong for that purpose. We don't have to use more than try lock annotation for that.
rwsem_acquire_read() implies:
1. might be a waiter on contention of the lock.
2. enter to the critical section of the lock.
All we need in here is to act 2, not 1. So trylock version of annotation is sufficient for that purpose. Now that dept partially relies on lockdep annotaions, dept interpets rwsem_acquire_read() as a potential wait and might report a deadlock by the wait.
Replace it with trylock version of annotation.
Message-ID: <[email protected]>
--- fs/jbd2/transaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jbd2/transaction.c +1 -1
@@ -460,7 +460,7 @@ repeat:read_unlock (&journal->j_state_lock); current->journal_info = handle; -rwsem_acquire_read (&journal->j_trans_commit_map,0 ,0 , _THIS_IP_); +rwsem_acquire_read (&journal->j_trans_commit_map,0 ,1 , _THIS_IP_);jbd2_journal_free_transaction (new_transaction);/* * Ensure that no allocations done while the transaction is open are
Greg Kroah-Hartman
maintainerPATCH 332/634 media: v4l2-mem2mem: Fix outdated documentation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Pinchart <[email protected]>
commit 082b86919b7a94de01d849021b4da820a6cb89dc upstream.
Commit cbd9463da1b1 ("media: v4l2-mem2mem: Avoid calling .device_run in v4l2_m2m_job_finish") deferred calls to .device_run() to a work queue to avoid recursive calls when a job is finished right away from .device_run(). It failed to update the v4l2_m2m_job_finish() documentation that still states the function must not be called from .device_run(). Fix it.
--- include/media/v4l2-mem2mem.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/media/v4l2-mem2mem.h +1 -2
@@ -185,8 +185,7 @@ void v4l2_m2m_try_schedule(struct v4l2_m* other instances to take control of the device. * * This function has to be called only after &v4l2_m2m_ops->device_run -* callback has been called on the driver. To prevent recursion, it should -* not be called directly from the &v4l2_m2m_ops->device_run callback though. +* callback has been called on the driver. */ void v4l2_m2m_job_finish (struct v4l2_m2m_dev *m2m_dev,struct v4l2_m2m_ctx *m2m_ctx);
Greg Kroah-Hartman
maintainerPATCH 333/634 usb: usb-storage: Maintain minimal modifications to the bcdDevice range.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Changcheng <[email protected]>
commit 0831269b5f71594882accfceb02638124f88955d upstream.
We cannot determine which models require the NO_ATA_1X and IGNORE_RESIDUE quirks aside from the EL-R12 optical drive device.
--- drivers/usb/storage/unusual_uas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/unusual_uas.h +1 -1
@@ -98,7 +98,7 @@ UNUSUAL_DEV(0x125f, 0xa94a, 0x0160, 0x01 US_FL_NO_ATA_1X),/* Reported-by: Benjamin Tissoires <[email protected]> */ -UNUSUAL_DEV(0x13fd, 0x3940, 0x0309, 0x0309, +UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x0309, "Initio Corporation", "INIC-3069", USB_SC_DEVICE, USB_PR_DEVICE, NULL,
Greg Kroah-Hartman
maintainerPATCH 334/634 media: dvb-usb: dtv5100: fix out-of-bounds in dtv5100_i2c_msg()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
commit b91e6aafe8d356086cc621bc03e35ba2299e4788 upstream.
rlen value is a user-controlled value, but dtv5100_i2c_msg() does not check the size of the rlen value. Therefore, if it is set to a value larger than sizeof(st->data), an out-of-bounds vuln occurs for st->data.
Therefore, we need to add proper range checking to prevent this vuln.
--- drivers/media/usb/dvb-usb/dtv5100.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/media/usb/dvb-usb/dtv5100.c +5 -0
@@ -55,6 +55,11 @@ static int dtv5100_i2c_msg(struct dvb_us } index = (addr <<8 ) + wbuf[0 ]; +if (rlen >sizeof (st->data)) { +warn ("rlen = %x is too big!\n" , rlen); +return -EINVAL ; + } +memcpy (st->data, rbuf, rlen);msleep (1 );/* avoid I2C errors */ return usb_control_msg(d->udev, pipe, request,
Greg Kroah-Hartman
maintainerPATCH 335/634 media: pvrusb2: Fix incorrect variable used in trace message
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit be440980eace19c035a0745fd6b6e42707bc4f49 upstream.
The pvr2_trace message is reporting an error about control read transfers, however it is using the incorrect variable write_len instead of read_lean. Fix this by using the correct variable read_len.
--- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +1 -1
@@ -3620,7 +3620,7 @@ static int pvr2_send_request_ex(struct ppvr2_trace (PVR2_TRACE_ERROR_LEGS ,"Attempted to execute %d byte control-read transfer (limit=%d)" , - write_len,PVR2_CTL_BUFFSIZE ); + read_len,PVR2_CTL_BUFFSIZE );return -EINVAL ; }if ((!write_len) && (!read_len)) {
Greg Kroah-Hartman
maintainerPATCH 336/634 phy: broadcom: bcm63xx-usbh: fix section mismatches
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 356d1924b9a6bc2164ce2bf1fad147b0c37ae085 upstream.
Platform drivers can be probed after their init sections have been discarded (e.g. on probe deferral or manual rebind through sysfs) so the probe function and match table must not live in init.
--- drivers/phy/broadcom/phy-bcm63xx-usbh.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/phy/broadcom/phy-bcm63xx-usbh.c +3 -3
@@ -374,7 +374,7 @@ static struct phy *bcm63xx_usbh_phy_xlatreturn of_phy_simple_xlate (dev, args); } -static int __init bcm63xx_usbh_phy_probe (struct platform_device *pdev) +static int bcm63xx_usbh_phy_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct bcm63xx_usbh_phy *usbh;
@@ -431,7 +431,7 @@ static int __init bcm63xx_usbh_phy_probereturn 0 ; } -static const struct of_device_id bcm63xx_usbh_phy_ids[]__initconst = { +static const struct of_device_id bcm63xx_usbh_phy_ids[] = { { .compatible ="brcm,bcm6318-usbh-phy" , .data = &usbh_bcm6318 }, { .compatible ="brcm,bcm6328-usbh-phy" , .data = &usbh_bcm6328 }, { .compatible ="brcm,bcm6358-usbh-phy" , .data = &usbh_bcm6358 },
@@ -442,7 +442,7 @@ static const struct of_device_id bcm63xx };MODULE_DEVICE_TABLE (of, bcm63xx_usbh_phy_ids); -static struct platform_driver bcm63xx_usbh_phy_driver__refdata = { +static struct platform_driver bcm63xx_usbh_phy_driver = { .driver = { .name ="bcm63xx-usbh-phy" , .of_match_table = bcm63xx_usbh_phy_ids,
Greg Kroah-Hartman
maintainerPATCH 337/634 USB: lpc32xx_udc: Fix error handling in probe
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit c84117912bddd9e5d87e68daf182410c98181407 upstream.
lpc32xx_udc_probe() acquires an i2c_client reference through isp1301_get_client() but fails to release it in both error handling paths and the normal removal path. This could result in a reference count leak for the I2C device, preventing proper cleanup and potentially leading to resource exhaustion. Add put_device() to release the reference in the probe failure path and in the remove function.
Calling path: isp1301_get_client() -> of_find_i2c_device_by_node() -> i2c_find_device_by_fwnode(). As comments of i2c_find_device_by_fwnode() says, 'The user must call put_device(&client->dev) once done with the i2c client.'
Found by code review.
--- drivers/usb/gadget/udc/lpc32xx_udc.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/usb/gadget/udc/lpc32xx_udc.c +15 -6
@@ -3027,7 +3027,7 @@ static int lpc32xx_udc_probe(struct plat pdev->dev.dma_mask = &lpc32xx_usbd_dmamask; retval =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 ));if (retval) -return retval; + goto i2c_fail; udc->board = &lpc32xx_usbddata;
@@ -3045,28 +3045,32 @@ static int lpc32xx_udc_probe(struct plat/* Get IRQs */ for (i =0 ; i <4 ; i++) { udc->udp_irq[i] =platform_get_irq (pdev, i); -if (udc->udp_irq[i] <0 ) -return udc->udp_irq[i]; +if (udc->udp_irq[i] <0 ) { + retval = udc->udp_irq[i]; + goto i2c_fail; + } } udc->udp_baseaddr =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (udc->udp_baseaddr)) {dev_err (udc->dev,"IO map failure\n" ); -return PTR_ERR (udc->udp_baseaddr); + retval =PTR_ERR (udc->udp_baseaddr); + goto i2c_fail; }/* Get USB device clock */ udc->usb_slv_clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (udc->usb_slv_clk)) {dev_err (udc->dev,"failed to acquire USB device clock\n" ); -return PTR_ERR (udc->usb_slv_clk); + retval =PTR_ERR (udc->usb_slv_clk); + goto i2c_fail; }/* Enable USB device clock */ retval =clk_prepare_enable (udc->usb_slv_clk);if (retval <0 ) {dev_err (udc->dev,"failed to start USB device clock\n" ); -return retval; + goto i2c_fail; }/* Setup deferred workqueue data */
@@ -3168,6 +3172,8 @@ dma_alloc_fail:dma_free_coherent (&pdev->dev,UDCA_BUFF_SIZE , udc->udca_v_base, udc->udca_p_base); i2c_fail: +if (udc->isp1301_i2c_client) +put_device (&udc->isp1301_i2c_client->dev);clk_disable_unprepare (udc->usb_slv_clk);dev_err (udc->dev,"%s probe failed, %d\n" , driver_name, retval);
@@ -3193,6 +3199,9 @@ static int lpc32xx_udc_remove(struct pladma_free_coherent (&pdev->dev,UDCA_BUFF_SIZE , udc->udca_v_base, udc->udca_p_base); +if (udc->isp1301_i2c_client) +put_device (&udc->isp1301_i2c_client->dev); +clk_disable_unprepare (udc->usb_slv_clk);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 338/634 usb: phy: fsl-usb: Fix use-after-free in delayed work during device removal
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit 41ca62e3e21e48c2903b3b45e232cf4f2ff7434f upstream.
The delayed work item otg_event is initialized in fsl_otg_conf() and scheduled under two conditions:
1. When a host controller binds to the OTG controller.
2. When the USB ID pin state changes (cable insertion/removal).
A race condition occurs when the device is removed via fsl_otg_remove():
the fsl_otg instance may be freed while the delayed work is still pending or executing. This leads to use-after-free when the work function fsl_otg_event() accesses the already freed memory.
The problematic scenario:
(detach thread) | (delayed work)
fsl_otg_remove() |
kfree(fsl_otg_dev) //FREE| fsl_otg_event()
| og = container_of(...) //USE
| og-> //USEFix this by calling disable_delayed_work_sync() in fsl_otg_remove() before deallocating the fsl_otg structure. This ensures the delayed work is properly canceled and completes execution prior to memory deallocation.
This bug was identified through static analysis.
--- drivers/usb/phy/phy-fsl-usb.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/phy/phy-fsl-usb.c +1 -0
@@ -987,6 +987,7 @@ static int fsl_otg_remove(struct platfor {struct fsl_usb2_platform_data *pdata =dev_get_platdata (&pdev->dev); +disable_delayed_work_sync (&fsl_otg_dev->otg_event);usb_remove_phy (&fsl_otg_dev->phy);free_irq (fsl_otg_dev->irq, fsl_otg_dev);
Greg Kroah-Hartman
maintainerPATCH 339/634 usb: phy: isp1301: fix non-OF device reference imbalance
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit b4b64fda4d30a83a7f00e92a0c8a1d47699609f3 upstream.
A recent change fixing a device reference leak in a UDC driver introduced a potential use-after-free in the non-OF case as the isp1301_get_client() helper only increases the reference count for the returned I2C device in the OF case.
Increment the reference count also for non-OF so that the caller can decrement it unconditionally.
Note that this is inherently racy just as using the returned I2C device is since nothing is preventing the PHY driver from being unbound while in use.
--- drivers/usb/phy/phy-isp1301.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/phy/phy-isp1301.c +6 -1
@@ -150,7 +150,12 @@ struct i2c_client *isp1301_get_client(streturn client;/* non-DT: only one ISP1301 chip supported */ -return isp1301_i2c_client; +if (isp1301_i2c_client) { +get_device (&isp1301_i2c_client->dev); +return isp1301_i2c_client; + } + +return NULL ; }EXPORT_SYMBOL_GPL (isp1301_get_client);
Greg Kroah-Hartman
maintainerPATCH 340/634 usb: dwc3: of-simple: fix clock resource leak in dwc3_of_simple_probe
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miaoqian Lin <[email protected]>
commit 3b4961313d31e200c9e974bb1536cdea217f78b5 upstream.
When clk_bulk_prepare_enable() fails, the error path jumps to err_resetc_assert, skipping clk_bulk_put_all() and leaking the clock references acquired by clk_bulk_get_all().
Add err_clk_put_all label to properly release clock resources in all error paths.
Found via static analysis and code review.
--- drivers/usb/dwc3/dwc3-of-simple.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/dwc3/dwc3-of-simple.c +4 -3
@@ -71,11 +71,11 @@ static int dwc3_of_simple_probe(struct p simple->num_clocks = ret; ret =clk_bulk_prepare_enable (simple->num_clocks, simple->clks);if (ret) - goto err_resetc_assert; + goto err_clk_put_all; ret =of_platform_populate (np,NULL ,NULL , dev);if (ret) - goto err_clk_put; + goto err_clk_disable;pm_runtime_set_active (dev);pm_runtime_enable (dev);
@@ -83,8 +83,9 @@ static int dwc3_of_simple_probe(struct preturn 0 ; -err_clk_put: +err_clk_disable:clk_bulk_disable_unprepare (simple->num_clocks, simple->clks); +err_clk_put_all:clk_bulk_put_all (simple->num_clocks, simple->clks); err_resetc_assert:
Greg Kroah-Hartman
maintainerPATCH 341/634 usb: renesas_usbhs: Fix a resource leak in usbhs_pipe_malloc()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit 36cc7e09df9e43db21b46519b740145410dd9f4a upstream.
usbhsp_get_pipe() set pipe's flags to IS_USED. In error paths, usbhsp_put_pipe() is required to clear pipe's flags to prevent pipe exhaustion.
--- drivers/usb/renesas_usbhs/pipe.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/renesas_usbhs/pipe.c +2 -0
@@ -713,11 +713,13 @@ struct usbhs_pipe *usbhs_pipe_malloc(str/* make sure pipe is not busy */ ret =usbhsp_pipe_barrier (pipe);if (ret <0 ) { +usbhsp_put_pipe (pipe);dev_err (dev,"pipe setup failed %d\n" ,usbhs_pipe_number (pipe));return NULL ; }if (usbhsp_setup_pipecfg (pipe, is_host, dir_in, &pipecfg)) { +usbhsp_put_pipe (pipe);dev_err (dev,"can't setup pipe\n" );return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 342/634 char: applicom: fix NULL pointer dereference in ac_ioctl
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianchu Chen <[email protected]>
commit 82d12088c297fa1cef670e1718b3d24f414c23f7 upstream.
Discovered by Atuin - Automated Vulnerability Discovery Engine.
In ac_ioctl, the validation of IndexCard and the check for a valid RamIO pointer are skipped when cmd is 6. However, the function unconditionally executes readb(apbs[IndexCard].RamIO + VERS) at the end.
If cmd is 6, IndexCard may reference a board that does not exist (where RamIO is NULL), leading to a NULL pointer dereference.
Fix this by skipping the readb access when cmd is 6, as this command is a global information query and does not target a specific board context.
--- drivers/char/applicom.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/char/applicom.c +4 -1
@@ -836,7 +836,10 @@ static long ac_ioctl(struct file *file, ret = -ENOTTY ;break ; } - Dummy =readb (apbs[IndexCard].RamIO +VERS ); + +if (cmd !=6 ) + Dummy =readb (apbs[IndexCard].RamIO +VERS ); +kfree (adgl);mutex_unlock (&ac_mutex);return ret;
Greg Kroah-Hartman
maintainerPATCH 343/634 intel_th: Fix error handling in intel_th_output_open
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit 6d5925b667e4ed9e77c8278cc215191d29454a3f upstream.
intel_th_output_open() calls bus_find_device_by_devt() which internally increments the device reference count via get_device(), but this reference is not properly released in several error paths. When device driver is unavailable, file operations cannot be obtained, or the driver's open method fails, the function returns without calling put_device(), leading to a permanent device reference count leak. This prevents the device from being properly released and could cause resource exhaustion over time.
Found by code review.
--- drivers/hwtracing/intel_th/core.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/hwtracing/intel_th/core.c +15 -5
@@ -810,13 +810,17 @@ static int intel_th_output_open(struct iint err; dev =bus_find_device_by_devt (&intel_th_bus, inode->i_rdev); -if (!dev || !dev->driver) -return -ENODEV ; +if (!dev || !dev->driver) { + err = -ENODEV ; + goto out_no_device; + } thdrv =to_intel_th_driver (dev->driver); fops =fops_get (thdrv->fops); -if (!fops) -return -ENODEV ; +if (!fops) { + err = -ENODEV ; + goto out_put_device; + }replace_fops (file, fops);
@@ -824,10 +828,16 @@ static int intel_th_output_open(struct iif (file->f_op->open) { err = file->f_op->open (inode, file); -return err; +if (err) + goto out_put_device; }return 0 ; + +out_put_device: +put_device (dev); +out_no_device: +return err; }static const struct file_operations intel_th_output_fops = {
Greg Kroah-Hartman
maintainerPATCH 344/634 cpufreq: nforce2: fix reference count leak in nforce2
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miaoqian Lin <[email protected]>
commit 9600156bb99852c216a2128cdf9f114eb67c350f upstream.
There are two reference count leaks in this driver:
1. In nforce2_fsb_read(): pci_get_subsys() increases the reference count of the PCI device, but pci_dev_put() is never called to release it, thus leaking the reference.
2. In nforce2_detect_chipset(): pci_get_subsys() gets a reference to the nforce2_dev which is stored in a global variable, but the reference is never released when the module is unloaded.
Fix both by:
- Adding pci_dev_put(nforce2_sub5) in nforce2_fsb_read() after reading the configuration.
- Adding pci_dev_put(nforce2_dev) in nforce2_exit() to release the global device reference.
Found via static analysis.
--- drivers/cpufreq/cpufreq-nforce2.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/cpufreq/cpufreq-nforce2.c +3 -0
@@ -145,6 +145,8 @@ static unsigned int nforce2_fsb_read(intpci_read_config_dword (nforce2_sub5,NFORCE2_BOOTFSB , &fsb); fsb /=1000000 ; +pci_dev_put (nforce2_sub5); +/* Check if PLL register is already set */ pci_read_config_byte (nforce2_dev,NFORCE2_PLLENABLE , (u8 *)&temp);
@@ -432,6 +434,7 @@ static int __init nforce2_init(void) static void __exit nforce2_exit(void) {cpufreq_unregister_driver (&nforce2_driver); +pci_dev_put (nforce2_dev); }module_init (nforce2_init);
Greg Kroah-Hartman
maintainerPATCH 345/634 scsi: Revert "scsi: qla2xxx: Perform lockless command completion in abort path"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Battersby <[email protected]>
commit b57fbc88715b6d18f379463f48a15b560b087ffe upstream.
This reverts commit 0367076b0817d5c75dfb83001ce7ce5c64d803a9.
The commit being reverted added code to __qla2x00_abort_all_cmds() to call sp->done() without holding a spinlock. But unlike the older code below it, this new code failed to check sp->cmd_type and just assumed TYPE_SRB, which results in a jump to an invalid pointer in target-mode with TYPE_TGT_CMD:
qla2xxx [0000:65:00.0]-d034:8: qla24xx_do_nack_work create sess success
0000000009f7a79b
qla2xxx [0000:65:00.0]-5003:8: ISP System Error - mbx1=1ff5h mbx2=10h
mbx3=0h mbx4=0h mbx5=191h mbx6=0h mbx7=0h.
qla2xxx [0000:65:00.0]-d01e:8: -> fwdump no buffer
qla2xxx [0000:65:00.0]-f03a:8: qla_target(0): System error async event
0x8002 occurred
qla2xxx [0000:65:00.0]-00af:8: Performing ISP error recovery -
ha=0000000058183fda.
BUG: kernel NULL pointer dereference, address: 0000000000000000 PF: supervisor instruction fetch in kernel mode PF: error_code(0x0010) - not-present page PGD 0 P4D 0 Oops: 0010 [#1] SMP CPU: 2 PID: 9446 Comm: qla2xxx_8_dpc Tainted: G O 6.1.133 #1 Hardware name: Supermicro Super Server/X11SPL-F, BIOS 4.2 12/15/2023 RIP: 0010:0x0 Code: Unable to access opcode bytes at 0xffffffffffffffd6. RSP: 0018:ffffc90001f93dc8 EFLAGS: 00010206 RAX: 0000000000000282 RBX: 0000000000000355 RCX: ffff88810d16a000 RDX: ffff88810dbadaa8 RSI: 0000000000080000 RDI: ffff888169dc38c0 RBP: ffff888169dc38c0 R08: 0000000000000001 R09: 0000000000000045 R10: ffffffffa034bdf0 R11: 0000000000000000 R12: ffff88810800bb40 R13: 0000000000001aa8 R14: ffff888100136610 R15: ffff8881070f7400 FS: 0000000000000000(0000) GS:ffff88bf80080000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 000000010c8ff006 CR4: 00000000003706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> ? __die+0x4d/0x8b ? page_fault_oops+0x91/0x180 ? trace_buffer_unlock_commit_regs+0x38/0x1a0 ? exc_page_fault+0x391/0x5e0 ? asm_exc_page_fault+0x22/0x30 __qla2x00_abort_all_cmds+0xcb/0x3e0 [qla2xxx_scst] qla2x00_abort_all_cmds+0x50/0x70 [qla2xxx_scst] qla2x00_abort_isp_cleanup+0x3b7/0x4b0 [qla2xxx_scst] qla2x00_abort_isp+0xfd/0x860 [qla2xxx_scst] qla2x00_do_dpc+0x581/0xa40 [qla2xxx_scst] kthread+0xa8/0xd0 </TASK>
Then commit 4475afa2646d ("scsi: qla2xxx: Complete command early within lock") added the spinlock back, because not having the lock caused a race and a crash. But qla2x00_abort_srb() in the switch below already checks for qla2x00_chip_is_down() and handles it the same way, so the code above the switch is now redundant and still buggy in target-mode. Remove it.
--- drivers/scsi/qla2xxx/qla_os.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +0 -6
@@ -1869,12 +1869,6 @@ __qla2x00_abort_all_cmds(struct qla_qpaifor (cnt =1 ; cnt < req->num_outstanding_cmds; cnt++) { sp = req->outstanding_cmds[cnt];if (sp) { -if (qla2x00_chip_is_down (vha)) { - req->outstanding_cmds[cnt] =NULL ; - sp->done (sp, res); -continue ; - } -switch (sp->cmd_type) {case TYPE_SRB :qla2x00_abort_srb (qp, sp, res, &flags);
Greg Kroah-Hartman
maintainerPATCH 346/634 scsi: aic94xx: fix use-after-free in device removal path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
commit f6ab594672d4cba08540919a4e6be2e202b60007 upstream.
The asd_pci_remove() function fails to synchronize with pending tasklets before freeing the asd_ha structure, leading to a potential use-after-free vulnerability.
When a device removal is triggered (via hot-unplug or module unload), race condition can occur.
The fix adds tasklet_kill() before freeing the asd_ha structure, ensuring all scheduled tasklets complete before cleanup proceeds.
--- drivers/scsi/aic94xx/aic94xx_init.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/aic94xx/aic94xx_init.c +3 -0
@@ -897,6 +897,9 @@ static void asd_pci_remove(struct pci_deasd_disable_ints (asd_ha); +/* Ensure all scheduled tasklets complete before freeing resources */ +tasklet_kill (&asd_ha->seq.dl_tasklet); +asd_remove_dev_attrs (asd_ha);/* XXX more here as needed */
Greg Kroah-Hartman
maintainerPATCH 347/634 NFSD: use correct reservation type in nfsd4_scsi_fence_client
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dai Ngo <[email protected]>
commit 6f52063db9aabdaabea929b1e998af98c2e8d917 upstream.
The reservation type argument for the pr_preempt call should match the one used in nfsd4_block_get_device_info_scsi.
--- fs/nfsd/blocklayout.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfsd/blocklayout.c +2 -1
@@ -334,7 +334,8 @@ nfsd4_scsi_fence_client(struct nfs4_layostruct block_device *bdev = ls->ls_file->nf_file->f_path.mnt->mnt_sb->s_bdev; bdev->bd_disk->fops->pr_ops->pr_preempt (bdev,NFSD_MDS_PR_KEY , -nfsd4_scsi_pr_key (clp),0 , true); +nfsd4_scsi_pr_key (clp), +PR_EXCLUSIVE_ACCESS_REG_ONLY , true); }const struct nfsd4_layout_ops scsi_layout_ops = {
Greg Kroah-Hartman
maintainerPATCH 348/634 scsi: target: Reset t_task_cdb pointer in error case
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Vatoropin <[email protected]>
commit 5053eab38a4c4543522d0c320c639c56a8b59908 upstream.
If allocation of cmd->t_task_cdb fails, it remains NULL but is later dereferenced in the 'err' path.
In case of error, reset NULL t_task_cdb value to point at the default fixed-size buffer.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/target/target_core_transport.c | 1 + 1 file changed, 1 insertion(+)
drivers/target/target_core_transport.c +1 -0
@@ -1524,6 +1524,7 @@ target_cmd_init_cdb(struct se_cmd *cmd,if (scsi_command_size (cdb) >sizeof (cmd->__t_task_cdb)) { cmd->t_task_cdb =kzalloc (scsi_command_size (cdb), gfp);if (!cmd->t_task_cdb) { + cmd->t_task_cdb = &cmd->__t_task_cdb[0 ]; pr_err("Unable to allocate cmd->t_task_cdb" " %u > sizeof(cmd->__t_task_cdb): %lu ops\n", scsi_command_size(cdb),
Greg Kroah-Hartman
maintainerPATCH 349/634 f2fs: invalidate dentry cache on failed whiteout creation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepanshu Kartikey <[email protected]>
commit d33f89b34aa313f50f9a512d58dd288999f246b0 upstream.
F2FS can mount filesystems with corrupted directory depth values that get runtime-clamped to MAX_DIR_HASH_DEPTH. When RENAME_WHITEOUT operations are performed on such directories, f2fs_rename performs directory modifications (updating target entry and deleting source entry) before attempting to add the whiteout entry via f2fs_add_link.
If f2fs_add_link fails due to the corrupted directory structure, the function returns an error to VFS, but the partial directory modifications have already been committed to disk. VFS assumes the entire rename operation failed and does not update the dentry cache, leaving stale mappings.
In the error path, VFS does not call d_move() to update the dentry cache. This results in new_dentry still pointing to the old inode (new_inode) which has already had its i_nlink decremented to zero. The stale cache causes subsequent operations to incorrectly reference the freed inode.
This causes subsequent operations to use cached dentry information that no longer matches the on-disk state. When a second rename targets the same entry, VFS attempts to decrement i_nlink on the stale inode, which may already have i_nlink=0, triggering a WARNING in drop_nlink().
Example sequence:
1. First rename (RENAME_WHITEOUT): file2 → file1
- f2fs updates file1 entry on disk (points to inode 8)
- f2fs deletes file2 entry on disk
- f2fs_add_link(whiteout) fails (corrupted directory)
- Returns error to VFS
- VFS does not call d_move() due to error
- VFS cache still has: file1 → inode 7 (stale!)
- inode 7 has i_nlink=0 (already decremented)
2. Second rename: file3 → file1
- VFS uses stale cache: file1 → inode 7
- Tries to drop_nlink on inode 7 (i_nlink already 0)
- WARNING in drop_nlink()
Fix this by explicitly invalidating old_dentry and new_dentry when f2fs_add_link fails during whiteout creation. This forces VFS to refresh from disk on subsequent operations, ensuring cache consistency even when the rename partially succeeds.
Reproducer:
1. Mount F2FS image with corrupted i_current_depth
2. renameat2(file2, file1, RENAME_WHITEOUT)
3. renameat2(file3, file1, 0)
4. System triggers WARNING in drop_nlink()
--- fs/f2fs/namei.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/f2fs/namei.c +4 -2
@@ -1028,9 +1028,11 @@ static int f2fs_rename(struct user_namesif (whiteout) {set_inode_flag (whiteout,FI_INC_LINK ); err =f2fs_add_link (old_dentry, whiteout); -if (err) +if (err) { +d_invalidate (old_dentry); +d_invalidate (new_dentry); goto put_out_dir; - + }spin_lock (&whiteout->i_lock); whiteout->i_state &= ~I_LINKABLE ;spin_unlock (&whiteout->i_lock);
Greg Kroah-Hartman
maintainerPATCH 350/634 f2fs: fix return value of f2fs_recover_fsync_data()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
commit 01fba45deaddcce0d0b01c411435d1acf6feab7b upstream.
With below scripts, it will trigger panic in f2fs:
mkfs.f2fs -f /dev/vdd
mount /dev/vdd /mnt/f2fs
touch /mnt/f2fs/foo
sync
echo 111 >> /mnt/f2fs/foof2fs_io fsync /mnt/f2fs/foof2fs_io shutdown 2 /mnt/f2fs
umount /mnt/f2fs
mount -o ro,norecovery /dev/vdd /mnt/f2fs or
mount -o ro,disable_roll_forward /dev/vdd /mnt/f2fs
F2FS-fs (vdd): f2fs_recover_fsync_data: recovery fsync data, check_only: 0 F2FS-fs (vdd): Mounted with checkpoint version = 7f5c361f F2FS-fs (vdd): Stopped filesystem due to reason: 0
F2FS-fs (vdd): f2fs_recover_fsync_data: recovery fsync data, check_only: 1 Filesystem f2fs get_tree() didn't set fc->root, returned 1
------------[ cut here ]------------ kernel BUG at fs/super.c:1761! Oops: invalid opcode: 0000 [#1] SMP PTI CPU: 3 UID: 0 PID: 722 Comm: mount Not tainted 6.18.0-rc2+ #721 PREEMPT(voluntary) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:vfs_get_tree.cold+0x18/0x1a Call Trace: <TASK> fc_mount+0x13/0xa0 path_mount+0x34e/0xc50 __x64_sys_mount+0x121/0x150 do_syscall_64+0x84/0x800 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7fa6cc126cfe
The root cause is we missed to handle error number returned from f2fs_recover_fsync_data() when mounting image w/ ro,norecovery or ro,disable_roll_forward mount option, result in returning a positive error number to vfs_get_tree(), fix it.
--- fs/f2fs/super.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
fs/f2fs/super.c +9 -5
@@ -4497,11 +4497,15 @@ try_onemore: } }else { err =f2fs_recover_fsync_data (sbi, true); - -if (!f2fs_readonly (sb) && err >0 ) { - err = -EINVAL ; -f2fs_err (sbi,"Need to recover fsync data" ); - goto free_meta; +if (err >0 ) { +if (!f2fs_readonly (sb)) { +f2fs_err (sbi,"Need to recover fsync data" ); + err = -EINVAL ; + goto free_meta; + }else { +f2fs_info (sbi,"drop all fsynced data" ); + err =0 ; + } } }
Greg Kroah-Hartman
maintainerPATCH 351/634 tools/testing/nvdimm: Use per-DIMM device handle
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
commit f59b701b4674f7955170b54c4167c5590f4714eb upstream.
KASAN reports a global-out-of-bounds access when running these nfit
tests: clear.sh, pmem-errors.sh, pfn-meta-errors.sh, btt-errors.sh, daxdev-errors.sh, and inject-error.sh.
[] BUG: KASAN: global-out-of-bounds in nfit_test_ctl+0x769f/0x7840 [nfit_test] [] Read of size 4 at addr ffffffffc03ea01c by task ndctl/1215
[] The buggy address belongs to the variable:
[] handle+0x1c/0x1df4 [nfit_test]
nfit_test_search_spa() uses handle[nvdimm->id] to retrieve a device handle and triggers a KASAN error when it reads past the end of the handle array. It should not be indexing the handle array at all.
The correct device handle is stored in per-DIMM test data. Each DIMM has a struct nfit_mem that embeds a struct acpi_nfit_memdev that describes the NFIT device handle. Use that device handle here.
--- tools/testing/nvdimm/test/nfit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/testing/nvdimm/test/nfit.c +6 -1
@@ -670,6 +670,7 @@ static int nfit_test_search_spa(struct n .addr = spa->spa, .region = NULL, }; +struct nfit_mem *nfit_mem;u64 dpa; ret = device_for_each_child(&bus->dev, &ctx,
@@ -687,8 +688,12 @@ static int nfit_test_search_spa(struct n*/ nd_mapping = &nd_region->mapping[nd_region->ndr_mappings -1 ]; nvdimm = nd_mapping->nvdimm; + nfit_mem =nvdimm_provider_data (nvdimm); +if (!nfit_mem) +return -EINVAL ; - spa->devices[0 ].nfit_device_handle = handle[nvdimm->id]; + spa->devices[0 ].nfit_device_handle = +__to_nfit_memdev (nfit_mem)->device_handle; spa->num_nvdimms =1 ; spa->devices[0 ].dpa = dpa;
Greg Kroah-Hartman
maintainerPATCH 352/634 media: vidtv: initialize local pointers upon transfer of memory ownership
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
commit 98aabfe2d79f74613abc2b0b1cef08f97eaf5322 upstream.
vidtv_channel_si_init() creates a temporary list (program, service, event) and ownership of the memory itself is transferred to the PAT/SDT/EIT tables through vidtv_psi_pat_program_assign(), vidtv_psi_sdt_service_assign(), vidtv_psi_eit_event_assign().
The problem here is that the local pointer where the memory ownership transfer was completed is not initialized to NULL. This causes the vidtv_psi_pmt_create_sec_for_each_pat_entry() function to fail, and in the flow that jumps to free_eit, the memory that was freed by vidtv_psi_*_table_destroy() can be accessed again by vidtv_psi_*_event_destroy() due to the uninitialized local pointer, so it is freed once again.
Therefore, to prevent use-after-free and double-free vulnerability, local pointers must be initialized to NULL when transferring memory ownership.
--- drivers/media/test-drivers/vidtv/vidtv_channel.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/test-drivers/vidtv/vidtv_channel.c +3 -0
@@ -461,12 +461,15 @@ int vidtv_channel_si_init(struct vidtv_m/* assemble all programs and assign to PAT */ vidtv_psi_pat_program_assign (m->si.pat, programs); + programs =NULL ;/* assemble all services and assign to SDT */ vidtv_psi_sdt_service_assign (m->si.sdt, services); + services =NULL ;/* assemble all events and assign to EIT */ vidtv_psi_eit_event_assign (m->si.eit, events); + events =NULL ; m->si.pmt_secs =vidtv_psi_pmt_create_sec_for_each_pat_entry (m->si.pat, m->pcr_pid);
Greg Kroah-Hartman
maintainerPATCH 353/634 ocfs2: fix kernel BUG in ocfs2_find_victim_chain
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prithvi Tambewagh <[email protected]>
commit 039bef30e320827bac8990c9f29d2a68cd8adb5f upstream.
syzbot reported a kernel BUG in ocfs2_find_victim_chain() because the cl_next_free_rec field of the allocation chain list (next free slot in the chain list) is 0, triggring the BUG_ON(!cl->cl_next_free_rec) condition in ocfs2_find_victim_chain() and panicking the kernel.
To fix this, an if condition is introduced in ocfs2_claim_suballoc_bits(), just before calling ocfs2_find_victim_chain(), the code block in it being executed when either of the following conditions is true:
1. cl_next_free_rec is equal to 0, indicating that there are no free chains in the allocation chain list
2. cl_next_free_rec is greater than cl_count (the total number of chains in the allocation chain list)
Either of them being true is indicative of the fact that there are no chains left for usage.
This is addressed using ocfs2_error(), which prints
the error log for debugging purposes, rather than panicking the kernel.
--- fs/ocfs2/suballoc.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/ocfs2/suballoc.c +10 -0
@@ -1923,6 +1923,16 @@ static int ocfs2_claim_suballoc_bits(str } cl = (struct ocfs2_chain_list *) &fe->id2.i_chain; +if (!le16_to_cpu (cl->cl_next_free_rec) || +le16_to_cpu (cl->cl_next_free_rec) >le16_to_cpu (cl->cl_count)) { + status =ocfs2_error (ac->ac_inode->i_sb, +"Chain allocator dinode %llu has invalid next " +"free chain record %u, but only %u total\n" , + (unsigned long long )le64_to_cpu (fe->i_blkno), +le16_to_cpu (cl->cl_next_free_rec), +le16_to_cpu (cl->cl_count)); + goto bail; + } victim =ocfs2_find_victim_chain (cl); ac->ac_chain = victim;
Greg Kroah-Hartman
maintainerPATCH 354/634 KVM: x86: Dont clear async #PF queue when CR0.PG is disabled (e.g. on #SMI)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxim Levitsky <[email protected]>
commit ab4e41eb9fabd4607304fa7cfe8ec9c0bd8e1552 upstream.
Fix an interaction between SMM and PV asynchronous #PFs where an #SMI can cause KVM to drop an async #PF ready event, and thus result in guest tasks becoming permanently stuck due to the task that encountered the #PF never being resumed. Specifically, don't clear the completion queue when paging is disabled, and re-check for completed async #PFs if/when paging is enabled.
Prior to commit 2635b5c4a0e4 ("KVM: x86: interrupt based APF 'page ready' event delivery"), flushing the APF queue without notifying the guest of completed APF requests when paging is disabled was "necessary", in that delivering a #PF to the guest when paging is disabled would likely confuse and/or crash the guest. And presumably the original async #PF development assumed that a guest would only disable paging when there was no intent to ever re-enable paging.
That assumption fails in several scenarios, most visibly on an emulated SMI, as entering SMM always disables CR0.PG (i.e. initially runs with paging disabled). When the SMM handler eventually executes RSM, the interrupted paging-enabled is restored, and the async #PF event is lost.
Similarly, invoking firmware, e.g. via EFI runtime calls, might require a transition through paging modes and thus also disable paging with valid entries in the competion queue.
To avoid dropping completion events, drop the "clear" entirely, and handle paging-enable transitions in the same way KVM already handles APIC enable/disable events: if a vCPU's APIC is disabled, APF completion events are not kept pending and not injected while APIC is disabled. Once a vCPU's APIC is re-enabled, KVM raises KVM_REQ_APF_READY so that the vCPU recognizes any pending pending #APF ready events.
[sean: rework changelog to call out #PF injection, drop "real mode"
references, expand the code comment]
--- arch/x86/kvm/x86.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
arch/x86/kvm/x86.c +15 -10
@@ -853,6 +853,13 @@ bool kvm_require_dr(struct kvm_vcpu *vcp }EXPORT_SYMBOL_GPL (kvm_require_dr); +static bool kvm_pv_async_pf_enabled (struct kvm_vcpu *vcpu) +{ +u64 mask =KVM_ASYNC_PF_ENABLED |KVM_ASYNC_PF_DELIVERY_AS_INT ; + +return (vcpu->arch.apf.msr_en_val & mask) == mask; +} +static inline u64 pdptr_rsvd_bits (struct kvm_vcpu *vcpu) {return vcpu->arch.reserved_gpa_bits |rsvd_bits (5 ,8 ) |rsvd_bits (1 ,2 );
@@ -939,15 +946,20 @@ void kvm_post_set_cr0(struct kvm_vcpu *v }if ((cr0 ^ old_cr0) &X86_CR0_PG ) { -kvm_clear_async_pf_completion_queue (vcpu); -kvm_async_pf_hash_reset (vcpu); -/* * Clearing CR0.PG is defined to flush the TLB from the guest's * perspective. */ if (!(cr0 &X86_CR0_PG ))kvm_make_request (KVM_REQ_TLB_FLUSH_GUEST , vcpu); +/* +* Check for async #PF completion events when enabling paging, +* as the vCPU may have previously encountered async #PFs (it's +* entirely legal for the guest to toggle paging on/off without +* waiting for the async #PF queue to drain). +*/ +else if (kvm_pv_async_pf_enabled (vcpu)) +kvm_make_request (KVM_REQ_APF_READY , vcpu); }if ((cr0 ^ old_cr0) &KVM_MMU_CR0_ROLE_BITS )
@@ -3358,13 +3370,6 @@ static int set_msr_mce(struct kvm_vcpu *return 0 ; } -static inline bool kvm_pv_async_pf_enabled (struct kvm_vcpu *vcpu) -{ -u64 mask =KVM_ASYNC_PF_ENABLED |KVM_ASYNC_PF_DELIVERY_AS_INT ; - -return (vcpu->arch.apf.msr_en_val & mask) == mask; -} -static int kvm_pv_enable_async_pf (struct kvm_vcpu *vcpu,u64 data) {gpa_t gpa = data & ~0x3f ;
Greg Kroah-Hartman
maintainerPATCH 355/634 platform/chrome: cros_ec_ishtp: Fix UAF after unbinding driver
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tzung-Bi Shih <[email protected]>
commit 944edca81e7aea15f83cf9a13a6ab67f711e8abd upstream.
After unbinding the driver, another kthread cros_ec_console_log_work is still accessing the device, resulting an UAF and crash.
The driver doesn't unregister the EC device in .remove() which should shutdown sub-devices synchronously. Fix it.
--- drivers/platform/chrome/cros_ec_ishtp.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/chrome/cros_ec_ishtp.c +1 -0
@@ -715,6 +715,7 @@ static void cros_ec_ishtp_remove(structcancel_work_sync (&client_data->work_ishtp_reset);cancel_work_sync (&client_data->work_ec_evt); +cros_ec_unregister (client_data->ec_dev);cros_ish_deinit (cros_ish_cl);ishtp_put_device (cl_device); }
Greg Kroah-Hartman
maintainerPATCH 356/634 scs: fix a wrong parameter in __scs_magic
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhichi Lin <[email protected]>
commit 08bd4c46d5e63b78e77f2605283874bbe868ab19 upstream.
__scs_magic() needs a 'void *' variable, but a 'struct task_struct *' is given. 'task_scs(tsk)' is the starting address of the task's shadow call stack, and '__scs_magic(task_scs(tsk))' is the end address of the task's shadow call stack. Here should be '__scs_magic(task_scs(tsk))'.
The user-visible effect of this bug is that when CONFIG_DEBUG_STACK_USAGE is enabled, the shadow call stack usage checking function (scs_check_usage) would scan an incorrect memory range. This could lead to:
1. **Inaccurate stack usage reporting**: The function would calculate wrong usage statistics for the shadow call stack, potentially showing incorrect value in kmsg.
2. **Potential kernel crash**: If the value of __scs_magic(tsk)is greater than that of __scs_magic(task_scs(tsk)), the for loop may access unmapped memory, potentially causing a kernel panic. However, this scenario is unlikely because task_struct is allocated via the slab allocator (which typically returns lower addresses), while the shadow call stack returned by task_scs(tsk) is allocated via vmalloc(which typically returns higher addresses).
However, since this is purely a debugging feature (CONFIG_DEBUG_STACK_USAGE), normal production systems should be not unaffected. The bug only impacts developers and testers who are actively debugging stack usage with this configuration enabled.
--- kernel/scs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/scs.c +1 -1
@@ -125,7 +125,7 @@ static void scs_check_usage(struct task_if (!IS_ENABLED (CONFIG_DEBUG_STACK_USAGE ))return ; -for (p =task_scs (tsk); p <__scs_magic (tsk); ++p) { +for (p =task_scs (tsk); p <__scs_magic (task_scs (tsk)); ++p) {if (!READ_ONCE_NOCHECK (*p))break ; used +=sizeof (*p);
Greg Kroah-Hartman
maintainerPATCH 357/634 parisc: Do not reprogram affinitiy on ASP chip
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit dca7da244349eef4d78527cafc0bf80816b261f5 upstream.
The ASP chip is a very old variant of the GSP chip and is used e.g. in HP 730 workstations. When trying to reprogram the affinity it will crash with a HPMC as the relevant registers don't seem to be at the usual location. Let's avoid the crash by checking the sversion. Also note, that reprogramming isn't necessary either, as the HP730 is a just a single-CPU machine.
--- drivers/parisc/gsc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/parisc/gsc.c +3 -1
@@ -154,7 +154,9 @@ static int gsc_set_affinity_irq(struct i gsc_dev->eim = ((u32 ) gsc_dev->gsc_irq.txn_addr) | gsc_dev->gsc_irq.txn_data;/* switch IRQ's for devices below LASI/WAX to other CPU */ -gsc_writel (gsc_dev->eim, gsc_dev->hpa +OFFSET_IAR ); +/* ASP chip (svers 0x70) does not support reprogramming */ +if (gsc_dev->gsc->id.sversion !=0x70 ) +gsc_writel (gsc_dev->eim, gsc_dev->hpa +OFFSET_IAR );irq_data_update_effective_affinity (d, &tmask);
Greg Kroah-Hartman
maintainerPATCH 358/634 libceph: make decode_pool() more resilient against corrupted osdmaps
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit 8c738512714e8c0aa18f8a10c072d5b01c83db39 upstream.
If the osdmap is (maliciously) corrupted such that the encoded length of ceph_pg_pool envelope is less than what is expected for a particular encoding version, out-of-bounds reads may ensue because the only bounds check that is there is based on that length value.
This patch adds explicit bounds checks for each field that is decoded or skipped.
--- net/ceph/osdmap.c | 118 ++++++++++++++++++++++++------------------------------ 1 file changed, 53 insertions(+), 65 deletions(-)
net/ceph/osdmap.c +53 -65
@@ -806,51 +806,49 @@ static int decode_pool(void **p, void *eceph_decode_need (p, end, len, bad); pool_end = *p + len; +ceph_decode_need (p, end,4 +4 +4 , bad); pi->type =ceph_decode_8 (p); pi->size =ceph_decode_8 (p); pi->crush_ruleset =ceph_decode_8 (p); pi->object_hash =ceph_decode_8 (p); - pi->pg_num =ceph_decode_32 (p); pi->pgp_num =ceph_decode_32 (p); - *p +=4 +4 ;/* skip lpg* */ - *p +=4 ;/* skip last_change */ - *p +=8 +4 ;/* skip snap_seq, snap_epoch */ +/* lpg*, last_change, snap_seq, snap_epoch */ +ceph_decode_skip_n (p, end,8 +4 +8 +4 , bad);/* skip snaps */ - num =ceph_decode_32 (p); +ceph_decode_32_safe (p, end, num, bad);while (num--) { - *p +=8 ;/* snapid key */ - *p +=1 +1 ;/* versions */ - len =ceph_decode_32 (p); - *p += len; +/* snapid key, pool snap (with versions) */ +ceph_decode_skip_n (p, end,8 +2 , bad); +ceph_decode_skip_string (p, end, bad); } -/* skip removed_snaps */ - num =ceph_decode_32 (p); - *p += num * (8 +8 ); +/* removed_snaps */ +ceph_decode_skip_map (p, end,64 ,64 , bad); +ceph_decode_need (p, end,8 +8 +4 , bad); *p +=8 ;/* skip auid */ pi->flags =ceph_decode_64 (p); *p +=4 ;/* skip crash_replay_interval */ if (ev >=7 ) - pi->min_size =ceph_decode_8 (p); +ceph_decode_8_safe (p, end, pi->min_size, bad);else pi->min_size = pi->size - pi->size /2 ;if (ev >=8 ) - *p +=8 +8 ;/* skip quota_max_* */ +/* quota_max_* */ +ceph_decode_skip_n (p, end,8 +8 , bad);if (ev >=9 ) { -/* skip tiers */ - num =ceph_decode_32 (p); - *p += num *8 ; +/* tiers */ +ceph_decode_skip_set (p, end,64 , bad); +ceph_decode_need (p, end,8 +1 +8 +8 , bad); *p +=8 ;/* skip tier_of */ *p +=1 ;/* skip cache_mode */ - pi->read_tier =ceph_decode_64 (p); pi->write_tier =ceph_decode_64 (p); }else {
@@ -858,86 +856,76 @@ static int decode_pool(void **p, void *e pi->write_tier =-1 ; } -if (ev >=10 ) { -/* skip properties */ - num =ceph_decode_32 (p); -while (num--) { - len =ceph_decode_32 (p); - *p += len;/* key */ - len =ceph_decode_32 (p); - *p += len;/* val */ - } - } +if (ev >=10 ) +/* properties */ +ceph_decode_skip_map (p, end, string, string, bad);if (ev >=11 ) { -/* skip hit_set_params */ - *p +=1 +1 ;/* versions */ - len =ceph_decode_32 (p); - *p += len; +/* hit_set_params (with versions) */ +ceph_decode_skip_n (p, end,2 , bad); +ceph_decode_skip_string (p, end, bad); - *p +=4 ;/* skip hit_set_period */ - *p +=4 ;/* skip hit_set_count */ +/* hit_set_period, hit_set_count */ +ceph_decode_skip_n (p, end,4 +4 , bad); }if (ev >=12 ) - *p +=4 ;/* skip stripe_width */ +/* stripe_width */ +ceph_decode_skip_32 (p, end, bad); -if (ev >=13 ) { - *p +=8 ;/* skip target_max_bytes */ - *p +=8 ;/* skip target_max_objects */ - *p +=4 ;/* skip cache_target_dirty_ratio_micro */ - *p +=4 ;/* skip cache_target_full_ratio_micro */ - *p +=4 ;/* skip cache_min_flush_age */ - *p +=4 ;/* skip cache_min_evict_age */ - } - -if (ev >=14 ) { -/* skip erasure_code_profile */ - len =ceph_decode_32 (p); - *p += len; - } +if (ev >=13 ) +/* target_max_*, cache_target_*, cache_min_* */ +ceph_decode_skip_n (p, end,16 +8 +8 , bad); + +if (ev >=14 ) +/* erasure_code_profile */ +ceph_decode_skip_string (p, end, bad);/* * last_force_op_resend_preluminous, will be overridden if the * map was encoded with RESEND_ON_SPLIT */ if (ev >=15 ) - pi->last_force_request_resend =ceph_decode_32 (p); +ceph_decode_32_safe (p, end, pi->last_force_request_resend, bad);else pi->last_force_request_resend =0 ;if (ev >=16 ) - *p +=4 ;/* skip min_read_recency_for_promote */ +/* min_read_recency_for_promote */ +ceph_decode_skip_32 (p, end, bad);if (ev >=17 ) - *p +=8 ;/* skip expected_num_objects */ +/* expected_num_objects */ +ceph_decode_skip_64 (p, end, bad);if (ev >=19 ) - *p +=4 ;/* skip cache_target_dirty_high_ratio_micro */ +/* cache_target_dirty_high_ratio_micro */ +ceph_decode_skip_32 (p, end, bad);if (ev >=20 ) - *p +=4 ;/* skip min_write_recency_for_promote */ +/* min_write_recency_for_promote */ +ceph_decode_skip_32 (p, end, bad);if (ev >=21 ) - *p +=1 ;/* skip use_gmt_hitset */ +/* use_gmt_hitset */ +ceph_decode_skip_8 (p, end, bad);if (ev >=22 ) - *p +=1 ;/* skip fast_read */ +/* fast_read */ +ceph_decode_skip_8 (p, end, bad); -if (ev >=23 ) { - *p +=4 ;/* skip hit_set_grade_decay_rate */ - *p +=4 ;/* skip hit_set_search_last_n */ - } +if (ev >=23 ) +/* hit_set_grade_decay_rate, hit_set_search_last_n */ +ceph_decode_skip_n (p, end,4 +4 , bad);if (ev >=24 ) { -/* skip opts */ - *p +=1 +1 ;/* versions */ - len =ceph_decode_32 (p); - *p += len; +/* opts (with versions) */ +ceph_decode_skip_n (p, end,2 , bad); +ceph_decode_skip_string (p, end, bad); }if (ev >=25 ) - pi->last_force_request_resend =ceph_decode_32 (p); +ceph_decode_32_safe (p, end, pi->last_force_request_resend, bad);/* ignore the rest */
Greg Kroah-Hartman
maintainerPATCH 359/634 KVM: x86: WARN if hrtimer callback for periodic APIC timer fires with period=0
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 0ea9494be9c931ddbc084ad5e11fda91b554cf47 upstream.
WARN and don't restart the hrtimer if KVM's callback runs with the guest's APIC timer in periodic mode but with a period of '0', as not advancing the hrtimer's deadline would put the CPU into an infinite loop of hrtimer events. Observing a period of '0' should be impossible, even when the hrtimer is running on a different CPU than the vCPU, as KVM is supposed to cancel the hrtimer before changing (or zeroing) the period, e.g. when switching from periodic to one-shot.
--- arch/x86/kvm/lapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/lapic.c +1 -1
@@ -2637,7 +2637,7 @@ static enum hrtimer_restart apic_timer_fapic_timer_expired (apic, true); -if (lapic_is_periodic (apic)) { +if (lapic_is_periodic (apic) && !WARN_ON_ONCE (!apic->lapic_timer.period)) {advance_periodic_target_expiration (apic);hrtimer_add_expires_ns (&ktimer->timer, ktimer->period);return HRTIMER_RESTART ;
Greg Kroah-Hartman
maintainerPATCH 360/634 KVM: x86: Explicitly set new periodic hrtimer expiration in apic_timer_fn()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: fuqiang wang <[email protected]>
commit 9633f180ce994ab293ce4924a9b7aaf4673aa114 upstream.
When restarting an hrtimer to emulate a the guest's APIC timer in periodic mode, explicitly set the expiration using the target expiration computed by advance_periodic_target_expiration() instead of adding the period to the existing timer. This will allow making adjustments to the expiration, e.g. to deal with expirations far in the past, without having to implement the same logic in both advance_periodic_target_expiration() and apic_timer_fn().
--- arch/x86/kvm/lapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/lapic.c +1 -1
@@ -2639,7 +2639,7 @@ static enum hrtimer_restart apic_timer_fif (lapic_is_periodic (apic) && !WARN_ON_ONCE (!apic->lapic_timer.period)) {advance_periodic_target_expiration (apic); -hrtimer_add_expires_ns (&ktimer->timer, ktimer->period); +hrtimer_set_expires (&ktimer->timer, ktimer->target_expiration);return HRTIMER_RESTART ; }else return HRTIMER_NORESTART ;
Greg Kroah-Hartman
maintainerPATCH 361/634 KVM: x86: Fix VM hard lockup after prolonged inactivity with periodic HV timer
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: fuqiang wang <[email protected]>
commit 18ab3fc8e880791aa9f7c000261320fc812b5465 upstream.
When advancing the target expiration for the guest's APIC timer in periodic mode, set the expiration to "now" if the target expiration is in the past (similar to what is done in update_target_expiration()). Blindly adding the period to the previous target expiration can result in KVM generating a practically unbounded number of hrtimer IRQs due to programming an expired timer over and over. In extreme scenarios, e.g. if userspace pauses/suspends a VM for an extended duration, this can even cause hard lockups in the host.
Currently, the bug only affects Intel CPUs when using the hypervisor timer (HV timer), a.k.a. the VMX preemption timer. Unlike the software timer, a.k.a. hrtimer, which KVM keeps running even on exits to userspace, the HV timer only runs while the guest is active. As a result, if the vCPU does not run for an extended duration, there will be a huge gap between the target expiration and the current time the vCPU resumes running. Because the target expiration is incremented by only one period on each timer expiration, this leads to a series of timer expirations occurring rapidly after the vCPU/VM resumes.
More critically, when the vCPU first triggers a periodic HV timer expiration after resuming, advancing the expiration by only one period will result in a target expiration in the past. As a result, the delta may be calculated as a negative value. When the delta is converted into an absolute value (tscdeadline is an unsigned u64), the resulting value can overflow what the HV timer is capable of programming. I.e. the large value will exceed the VMX Preemption Timer's maximum bit width of cpu_preemption_timer_multi + 32, and thus cause KVM to switch from the HV timer to the software timer (hrtimers).
After switching to the software timer, periodic timer expiration callbacks may be executed consecutively within a single clock interrupt handler, because hrtimers honors KVM's request for an expiration in the past and immediately re-invokes KVM's callback after reprogramming. And because the interrupt handler runs with IRQs disabled, restarting KVM's hrtimer over and over until the target expiration is advanced to "now" can result in a hard lockup.
E.g. the following hard lockup was triggered in the host when running a Windows VM (only relevant because it used the APIC timer in periodic mode) after resuming the VM from a long suspend (in the host).
NMI watchdog: Watchdog detected hard LOCKUP on cpu 45
...
RIP: 0010:advance_periodic_target_expiration+0x4d/0x80 [kvm] ... RSP: 0018:ff4f88f5d98d8ef0 EFLAGS: 00000046 RAX: fff0103f91be678e RBX: fff0103f91be678e RCX: 00843a7d9e127bcc RDX: 0000000000000002 RSI: 0052ca4003697505 RDI: ff440d5bfbdbd500 RBP: ff440d5956f99200 R08: ff2ff2a42deb6a84 R09: 000000000002a6c0 R10: 0122d794016332b3 R11: 0000000000000000 R12: ff440db1af39cfc0 R13: ff440db1af39cfc0 R14: ffffffffc0d4a560 R15: ff440db1af39d0f8 FS: 00007f04a6ffd700(0000) GS:ff440db1af380000(0000) knlGS:000000e38a3b8000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000d5651feff8 CR3: 000000684e038002 CR4: 0000000000773ee0 PKRU: 55555554 Call Trace: <IRQ> apic_timer_fn+0x31/0x50 [kvm] __hrtimer_run_queues+0x100/0x280 hrtimer_interrupt+0x100/0x210 ? ttwu_do_wakeup+0x19/0x160 smp_apic_timer_interrupt+0x6a/0x130 apic_timer_interrupt+0xf/0x20 </IRQ>
Moreover, if the suspend duration of the virtual machine is not long enough to trigger a hard lockup in this scenario, since commit 98c25ead5eda ("KVM: VMX: Move preemption timer <=> hrtimer dance to common x86"), KVM will continue using the software timer until the guest reprograms the APIC timer in some way. Since the periodic timer does not require frequent APIC timer register programming, the guest may continue to use the software timer in perpetuity.
--- arch/x86/kvm/lapic.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
arch/x86/kvm/lapic.c +23 -5
@@ -1891,15 +1891,33 @@ static void advance_periodic_target_expiktime_t delta;/* -* Synchronize both deadlines to the same time source or -* differences in the periods (caused by differences in the -* underlying clocks or numerical approximation errors) will -* cause the two to drift apart over time as the errors -* accumulate. +* Use kernel time as the time source for both the hrtimer deadline and +* TSC-based deadline so that they stay synchronized. Computing each +* deadline independently will cause the two deadlines to drift apart +* over time as differences in the periods accumulate, e.g. due to +* differences in the underlying clocks or numerical approximation errors. */ apic->lapic_timer.target_expiration =ktime_add_ns (apic->lapic_timer.target_expiration, apic->lapic_timer.period); + +/* +* If the new expiration is in the past, e.g. because userspace stopped +* running the VM for an extended duration, then force the expiration +* to "now" and don't try to play catch-up with the missed events. KVM +* will only deliver a single interrupt regardless of how many events +* are pending, i.e. restarting the timer with an expiration in the +* past will do nothing more than waste host cycles, and can even lead +* to a hard lockup in extreme cases. +*/ +if (ktime_before (apic->lapic_timer.target_expiration, now)) + apic->lapic_timer.target_expiration = now; + +/* +* Note, ensuring the expiration isn't in the past also prevents delta +* from going negative, which could cause the TSC deadline to become +* excessively large due to it an unsigned value. +*/ delta =ktime_sub (apic->lapic_timer.target_expiration, now); apic->lapic_timer.tscdeadline =kvm_read_l1_tsc (apic->vcpu, tscl) +nsec_to_cycles (apic->vcpu, delta);
Greg Kroah-Hartman
maintainerPATCH 362/634 KVM: nSVM: Avoid incorrect injection of SVM_EXIT_CR0_SEL_WRITE
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yosry Ahmed <[email protected]>
commit 3d80f4c93d3d26d0f9a0dd2844961a632eeea634 upstream.
When emulating L2 instructions, svm_check_intercept() checks whether a write to CR0 should trigger a synthesized #VMEXIT with SVM_EXIT_CR0_SEL_WRITE. However, it does not check whether L1 enabled the intercept for SVM_EXIT_WRITE_CR0, which has higher priority according to the APM (24593—Rev. 3.42—March 2024, Table 15-7):
When both selective and non-selective CR0-write intercepts are active at the same time, the non-selective intercept takes priority. With respect to exceptions, the priority of this intercept is the same as the generic CR0-write intercept.
Make sure L1 does NOT intercept SVM_EXIT_WRITE_CR0 before checking if SVM_EXIT_CR0_SEL_WRITE needs to be injected.
Opportunistically tweak the "not CR0" logic to explicitly bail early so that it's more obvious that only CR0 has a selective intercept, and that modifying icpt_info.exit_code is functionally necessary so that the call to nested_svm_exit_handled() checks the correct exit code.
--- arch/x86/kvm/svm/svm.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
arch/x86/kvm/svm/svm.c +19 -5
@@ -4346,15 +4346,29 @@ static int svm_check_intercept(struct kvcase SVM_EXIT_WRITE_CR0 : {unsigned long cr0, val; -if (info->intercept == x86_intercept_cr_write) +/* +* Adjust the exit code accordingly if a CR other than CR0 is +* being written, and skip straight to the common handling as +* only CR0 has an additional selective intercept. +*/ +if (info->intercept == x86_intercept_cr_write && info->modrm_reg) { icpt_info.exit_code += info->modrm_reg; +break ; + } -if (icpt_info.exit_code !=SVM_EXIT_WRITE_CR0 || - info->intercept == x86_intercept_clts) +/* +* Convert the exit_code to SVM_EXIT_CR0_SEL_WRITE if a +* selective CR0 intercept is triggered (the common logic will +* treat the selective intercept as being enabled). Note, the +* unconditional intercept has higher priority, i.e. this is +* only relevant if *only* the selective intercept is enabled. +*/ +if (vmcb12_is_intercept (&svm->nested.ctl,INTERCEPT_CR0_WRITE ) || + !(vmcb12_is_intercept (&svm->nested.ctl,INTERCEPT_SELECTIVE_CR0 )))break ; -if (!(vmcb12_is_intercept (&svm->nested.ctl, -INTERCEPT_SELECTIVE_CR0 ))) +/* CLTS never triggers INTERCEPT_SELECTIVE_CR0 */ +if (info->intercept == x86_intercept_clts)break ; cr0 = vcpu->arch.cr0 & ~SVM_CR0_SELECTIVE_MASK ;
Greg Kroah-Hartman
maintainerPATCH 363/634 KVM: SVM: Mark VMCB_NPT as dirty on nested VMRUN
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jim Mattson <[email protected]>
commit 7c8b465a1c91f674655ea9cec5083744ec5f796a upstream.
Mark the VMCB_NPT bit as dirty in nested_vmcb02_prepare_save() on every nested VMRUN.
If L1 changes the PAT MSR between two VMRUN instructions on the same L1 vCPU, the g_pat field in the associated vmcb02 will change, and the VMCB_NPT clean bit should be cleared.
--- arch/x86/kvm/svm/nested.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kvm/svm/nested.c +1 -0
@@ -520,6 +520,7 @@ static void nested_vmcb02_prepare_save(sstruct vmcb *vmcb02 = svm->nested.vmcb02.ptr;nested_vmcb02_compute_g_pat (svm); +vmcb_mark_dirty (vmcb02,VMCB_NPT );/* Load the nested guest state */ if (svm->nested.vmcb12_gpa != svm->nested.last_vmcb12_gpa) {
Greg Kroah-Hartman
maintainerPATCH 364/634 KVM: nSVM: Propagate SVM_EXIT_CR0_SEL_WRITE correctly for LMSW emulation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yosry Ahmed <[email protected]>
commit 5674a76db0213f9db1e4d08e847ff649b46889c0 upstream.
When emulating L2 instructions, svm_check_intercept() checks whether a write to CR0 should trigger a synthesized #VMEXIT with SVM_EXIT_CR0_SEL_WRITE. For MOV-to-CR0, SVM_EXIT_CR0_SEL_WRITE is only triggered if any bit other than CR0.MP and CR0.TS is updated. However, according to the APM (24593—Rev. 3.42—March 2024, Table 15-7):
The LMSW instruction treats the selective CR0-write intercept as a non-selective intercept (i.e., it intercepts regardless of the value being written).
Skip checking the changed bits for x86_intercept_lmsw and always inject SVM_EXIT_CR0_SEL_WRITE.
--- arch/x86/kvm/svm/svm.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
arch/x86/kvm/svm/svm.c +9 -9
@@ -4371,20 +4371,20 @@ static int svm_check_intercept(struct kvif (info->intercept == x86_intercept_clts)break ; - cr0 = vcpu->arch.cr0 & ~SVM_CR0_SELECTIVE_MASK ; - val = info->src_val & ~SVM_CR0_SELECTIVE_MASK ; - +/* LMSW always triggers INTERCEPT_SELECTIVE_CR0 */ if (info->intercept == x86_intercept_lmsw) { - cr0 &=0xfUL ; - val &=0xfUL ; -/* lmsw can't clear PE - catch this here */ -if (cr0 &X86_CR0_PE ) - val |=X86_CR0_PE ; + icpt_info.exit_code =SVM_EXIT_CR0_SEL_WRITE ; +break ; } +/* +* MOV-to-CR0 only triggers INTERCEPT_SELECTIVE_CR0 if any bit +* other than SVM_CR0_SELECTIVE_MASK is changed. +*/ + cr0 = vcpu->arch.cr0 & ~SVM_CR0_SELECTIVE_MASK ; + val = info->src_val & ~SVM_CR0_SELECTIVE_MASK ;if (cr0 ^ val) icpt_info.exit_code =SVM_EXIT_CR0_SEL_WRITE ; -break ; }case SVM_EXIT_READ_DR0 :
Greg Kroah-Hartman
maintainerPATCH 365/634 KVM: SVM: Mark VMCB_PERM_MAP as dirty on nested VMRUN
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jim Mattson <[email protected]>
commit 93c9e107386dbe1243287a5b14ceca894de372b9 upstream.
Mark the VMCB_PERM_MAP bit as dirty in nested_vmcb02_prepare_control() on every nested VMRUN.
If L1 changes MSR interception (INTERCEPT_MSR_PROT) between two VMRUN instructions on the same L1 vCPU, the msrpm_base_pa in the associated vmcb02 will change, and the VMCB_PERM_MAP clean bit should be cleared.
--- arch/x86/kvm/svm/nested.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kvm/svm/nested.c +1 -0
@@ -639,6 +639,7 @@ static void nested_vmcb02_prepare_contro vmcb02->control.nested_ctl = vmcb01->control.nested_ctl; vmcb02->control.iopm_base_pa = vmcb01->control.iopm_base_pa; vmcb02->control.msrpm_base_pa = vmcb01->control.msrpm_base_pa; +vmcb_mark_dirty (vmcb02,VMCB_PERM_MAP );/* Done at vmrun: asid. */
Greg Kroah-Hartman
maintainerPATCH 366/634 KVM: nSVM: Set exit_code_hi to -1 when synthesizing SVM_EXIT_ERR (failed VMRUN)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit f402ecd7a8b6446547076f4bd24bd5d4dcc94481 upstream.
Set exit_code_hi to -1u as a temporary band-aid to fix a long-standing (effectively since KVM's inception) bug where KVM treats the exit code as a 32-bit value, when in reality it's a 64-bit value. Per the APM, offset 0x70 is a single 64-bit value:
070h 63:0 EXITCODE
And a sane reading of the error values defined in "Table C-1. SVM Intercept Codes" is that negative values use the full 64 bits:
–1 VMEXIT_INVALID Invalid guest state in VMCB.
–2 VMEXIT_BUSYBUSY bit was set in the VMSA
–3 VMEXIT_IDLE_REQUIREDThe sibling thread is not in an idle state -4 VMEXIT_INVALID_PMC Invalid PMC state
And that interpretation is confirmed by testing on Milan and Turin (by setting bits in CR0[63:32] to generate VMEXIT_INVALID on VMRUN).
Furthermore, Xen has treated exitcode as a 64-bit value since HVM support was adding in 2006 (see Xen commit d1bd157fbc ("Big merge the HVM full-virtualisation abstractions.")).
--- arch/x86/kvm/svm/nested.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/svm/nested.c +2 -2
@@ -834,7 +834,7 @@ int nested_svm_vmrun(struct kvm_vcpu *vcif (!nested_vmcb_check_save (vcpu) || !nested_vmcb_check_controls (vcpu)) { vmcb12->control.exit_code =SVM_EXIT_ERR ; - vmcb12->control.exit_code_hi =0 ; + vmcb12->control.exit_code_hi =-1u ; vmcb12->control.exit_info_1 =0 ; vmcb12->control.exit_info_2 =0 ; goto out;
@@ -867,7 +867,7 @@ out_exit_err: svm->soft_int_injected = false; svm->vmcb->control.exit_code =SVM_EXIT_ERR ; - svm->vmcb->control.exit_code_hi =0 ; + svm->vmcb->control.exit_code_hi =-1u ; svm->vmcb->control.exit_info_1 =0 ; svm->vmcb->control.exit_info_2 =0 ;
Greg Kroah-Hartman
maintainerPATCH 367/634 KVM: nSVM: Clear exit_code_hi in VMCB when synthesizing nested VM-Exits
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit da01f64e7470988f8607776aa7afa924208863fb upstream.
Explicitly clear exit_code_hi in the VMCB when synthesizing "normal" nested VM-Exits, as the full exit code is a 64-bit value (spoiler alert), and all exit codes for non-failing VMRUN use only bits 31:0.
--- arch/x86/kvm/svm/svm.c | 2 ++ arch/x86/kvm/svm/svm.h | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-)
arch/x86/kvm/svm/svm.c +2 -0
@@ -2531,6 +2531,7 @@ static bool check_selective_cr0_intercepif (cr0 ^ val) { svm->vmcb->control.exit_code =SVM_EXIT_CR0_SEL_WRITE ; + svm->vmcb->control.exit_code_hi =0 ; ret = (nested_svm_exit_handled (svm) ==NESTED_EXIT_DONE ); }
@@ -4445,6 +4446,7 @@ static int svm_check_intercept(struct kvif (static_cpu_has (X86_FEATURE_NRIPS )) vmcb->control.next_rip = info->next_rip; vmcb->control.exit_code = icpt_info.exit_code; + vmcb->control.exit_code_hi =0 ; vmexit =nested_svm_exit_handled (svm); ret = (vmexit == NESTED_EXIT_DONE) ? X86EMUL_INTERCEPTED
arch/x86/kvm/svm/svm.h +4 -3
@@ -606,9 +606,10 @@ int nested_svm_vmexit(struct vcpu_svm *sstatic inline int nested_svm_simple_vmexit (struct vcpu_svm *svm,u32 exit_code) { - svm->vmcb->control.exit_code = exit_code; - svm->vmcb->control.exit_info_1 =0 ; - svm->vmcb->control.exit_info_2 =0 ; + svm->vmcb->control.exit_code = exit_code; + svm->vmcb->control.exit_code_hi =0 ; + svm->vmcb->control.exit_info_1 =0 ; + svm->vmcb->control.exit_info_2 =0 ;return nested_svm_vmexit (svm); }
Greg Kroah-Hartman
maintainerPATCH 368/634 xfs: fix a memory leak in xfs_buf_item_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit fc40459de82543b565ebc839dca8f7987f16f62e upstream.
xfs_buf_item_get_format() may allocate memory for bip->bli_formats, free the memory in the error path.
--- fs/xfs/xfs_buf_item.c | 1 + 1 file changed, 1 insertion(+)
fs/xfs/xfs_buf_item.c +1 -0
@@ -900,6 +900,7 @@ xfs_buf_item_init( map_size =DIV_ROUND_UP (chunks,NBWORD );if (map_size >XFS_BLF_DATAMAP_SIZE ) { +xfs_buf_item_free_format (bip);kmem_cache_free (xfs_buf_item_cache, bip); xfs_err(mp, "buffer item dirty bitmap (%u uints) too small to reflect %u bytes!",
Greg Kroah-Hartman
maintainerPATCH 369/634 tracing: Do not register unsupported perf events
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit ef7f38df890f5dcd2ae62f8dbde191d72f3bebae upstream.
Synthetic events currently do not have a function to register perf events. This leads to calling the tracepoint register functions with a NULL function pointer which triggers:
------------[ cut here ]------------ WARNING: kernel/tracepoint.c:175 at tracepoint_add_func+0x357/0x370, CPU#2: perf/2272 Modules linked in: kvm_intel kvm irqbypass CPU: 2 UID: 0 PID: 2272 Comm: perf Not tainted 6.18.0-ftest-11964-ge022764176fc-dirty #323 PREEMPTLAZY Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.17.0-debian-1.17.0-1 04/01/2014 RIP: 0010:tracepoint_add_func+0x357/0x370 Code: 28 9c e8 4c 0b f5 ff eb 0f 4c 89 f7 48 c7 c6 80 4d 28 9c e8 ab 89 f4 ff 31 c0 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc cc <0f> 0b 49 c7 c6 ea ff ff ff e9 ee fe ff ff 0f 0b e9 f9 fe ff ff 0f RSP: 0018:ffffabc0c44d3c40 EFLAGS: 00010246 RAX: 0000000000000001 RBX: ffff9380aa9e4060 RCX: 0000000000000000 RDX: 000000000000000a RSI: ffffffff9e1d4a98 RDI: ffff937fcf5fd6c8 RBP: 0000000000000001 R08: 0000000000000007 R09: ffff937fcf5fc780 R10: 0000000000000003 R11: ffffffff9c193910 R12: 000000000000000a R13: ffffffff9e1e5888 R14: 0000000000000000 R15: ffffabc0c44d3c78 FS: 00007f6202f5f340(0000) GS:ffff93819f00f000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055d3162281a8 CR3: 0000000106a56003 CR4: 0000000000172ef0 Call Trace: <TASK> tracepoint_probe_register+0x5d/0x90 synth_event_reg+0x3c/0x60 perf_trace_event_init+0x204/0x340 perf_trace_init+0x85/0xd0 perf_tp_event_init+0x2e/0x50 perf_try_init_event+0x6f/0x230 ? perf_event_alloc+0x4bb/0xdc0 perf_event_alloc+0x65a/0xdc0 __se_sys_perf_event_open+0x290/0x9f0 do_syscall_64+0x93/0x7b0 ? entry_SYSCALL_64_after_hwframe+0x76/0x7e ? trace_hardirqs_off+0x53/0xc0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
Instead, have the code return -ENODEV, which doesn't warn and has perf error out with:
# perf record -e synthetic:futex_wait Error: The sys_perf_event_open() syscall returned with 19 (No such device) for event (synthetic:futex_wait). "dmesg | grep -i perf" may provide additional information.
Ideally perf should support synthetic events, but for now just fix the warning. The support can come later.
--- kernel/trace/trace_events.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/trace/trace_events.c +2 -0
@@ -675,6 +675,8 @@ int trace_event_reg(struct trace_event_c#ifdef CONFIG_PERF_EVENTS case TRACE_REG_PERF_REGISTER : +if (!call->class->perf_probe) +return -ENODEV ;return tracepoint_probe_register (call->tp, call->class->perf_probe, call);
Greg Kroah-Hartman
maintainerPATCH 370/634 PM: runtime: Do not clear needs_force_resume with enabled runtime PM
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit 359afc8eb02a518fbdd0cbd462c8c2827c6cbec2 upstream.
Commit 89d9cec3b1e9 ("PM: runtime: Clear power.needs_force_resume in pm_runtime_reinit()") added provisional clearing of power.needs_force_resume to pm_runtime_reinit(), but it is done unconditionally which is a mistake because pm_runtime_reinit() may race with driver probing and removal [1].
To address this, notice that power.needs_force_resume should never be set when runtime PM is enabled and so it only needs to be cleared when runtime PM is disabled, and update pm_runtime_init() to only clear that flag when runtime PM is disabled.
--- drivers/base/power/runtime.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/base/power/runtime.c +12 -10
@@ -1786,16 +1786,18 @@ void pm_runtime_init(struct device *dev)*/ void pm_runtime_reinit (struct device *dev) { -if (!pm_runtime_enabled (dev)) { -if (dev->power.runtime_status ==RPM_ACTIVE ) -pm_runtime_set_suspended (dev); -if (dev->power.irq_safe) { -spin_lock_irq (&dev->power.lock); - dev->power.irq_safe =0 ; -spin_unlock_irq (&dev->power.lock); -if (dev->parent) -pm_runtime_put (dev->parent); - } +if (pm_runtime_enabled (dev)) +return ; + +if (dev->power.runtime_status ==RPM_ACTIVE ) +pm_runtime_set_suspended (dev); + +if (dev->power.irq_safe) { +spin_lock_irq (&dev->power.lock); + dev->power.irq_safe =0 ; +spin_unlock_irq (&dev->power.lock); +if (dev->parent) +pm_runtime_put (dev->parent); }/* * Clear power.needs_force_resume in case it has been set by
Greg Kroah-Hartman
maintainerPATCH 371/634 r8169: fix RTL8117 Wake-on-Lan in DASH mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: René Rebe <[email protected]>
commit dd75c723ef566f7f009c047f47e0eee95fe348ab upstream.
Wake-on-Lan does currently not work for r8169 in DASH mode, e.g. the ASUS Pro WS X570-ACE with RTL8168fp/RTL8117.
Fix by not returning early in rtl_prepare_power_down when dash_enabled. While this fixes WoL, it still kills the OOB RTL8117 remote management BMC connection. Fix by not calling rtl8168_driver_stop if WoL is enabled.
--- drivers/net/ethernet/realtek/r8169_main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +1 -4
@@ -2565,9 +2565,6 @@ static void rtl_wol_enable_rx(struct rtlstatic void rtl_prepare_power_down (struct rtl8169_private *tp) { -if (tp->dash_enabled) -return ; -if (tp->mac_version ==RTL_GIGA_MAC_VER_32 || tp->mac_version ==RTL_GIGA_MAC_VER_33 )rtl_ephy_write (tp,0x19 ,0xff64 );
@@ -4752,7 +4749,7 @@ static void rtl8169_down(struct rtl8169_rtl_disable_exit_l1 (tp);rtl_prepare_power_down (tp); -if (tp->dash_type !=RTL_DASH_NONE ) +if (tp->dash_type !=RTL_DASH_NONE && !tp->saved_wolopts)rtl8168_driver_stop (tp); }
Greg Kroah-Hartman
maintainerPATCH 372/634 fsnotify: do not generate ACCESS/MODIFY events on child for special files
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
commit 635bc4def026a24e071436f4f356ea08c0eed6ff upstream.
inotify/fanotify do not allow users with no read access to a file to subscribe to events (e.g. IN_ACCESS/IN_MODIFY), but they do allow the same user to subscribe for watching events on children when the user has access to the parent directory (e.g. /dev).
Users with no read access to a file but with read access to its parent directory can still stat the file and see if it was accessed/modified via atime/mtime change.
The same is not true for special files (e.g. /dev/null). Users will not generally observe atime/mtime changes when other users read/write to special files, only when someone sets atime/mtime via utimensat().
Align fsnotify events with this stat behavior and do not generate ACCESS/MODIFY events to parent watchers on read/write of special files. The events are still generated to parent watchers on utimensat(). This closes some side-channels that could be possibly used for information exfiltration [1].
[1] https://snee.la/pdf/pubs/file-notification-attacks.pdf
--- fs/notify/fsnotify.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/notify/fsnotify.c +8 -1
@@ -224,8 +224,15 @@ int __fsnotify_parent(struct dentry *den/* * Include parent/name in notification either if some notification * groups require parent info or the parent is interested in this event. +* The parent interest in ACCESS/MODIFY events does not apply to special +* files, where read/write are not on the filesystem of the parent and +* events can provide an undesirable side-channel for information +* exfiltration. */ - parent_interested = mask & p_mask &ALL_FSNOTIFY_EVENTS ; + parent_interested = mask & p_mask &ALL_FSNOTIFY_EVENTS && + !(data_type ==FSNOTIFY_EVENT_PATH && +d_is_special (dentry) && + (mask & (FS_ACCESS |FS_MODIFY )));if (parent_needed || parent_interested) {/* When notifying parent, child should be passed as data */ WARN_ON_ONCE (inode !=fsnotify_data_inode (data, data_type));
Greg Kroah-Hartman
maintainerPATCH 373/634 nfsd: Mark variable __maybe_unused to avoid W=1 build break
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit ebae102897e760e9e6bc625f701dd666b2163bd1 upstream.
Clang is not happy about set but (in some cases) unused variable:
fs/nfsd/export.c:1027:17: error: variable 'inode' set but not used [-Werror,-Wunused-but-set-variable]
since it's used as a parameter to dprintk() which might be configured a no-op. To avoid uglifying code with the specific ifdeffery just mark the variable __maybe_unused.
The commit [1], which introduced this behaviour, is quite old and hence the Fixes tag points to the first of the Git era.
--- fs/nfsd/export.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/export.c +1 -1
@@ -990,7 +990,7 @@ exp_rootfh(struct net *net, struct auth_ {struct svc_export *exp;struct path path; -struct inode *inode; +struct inode *inode__maybe_unused ;struct svc_fh fh;int err;struct nfsd_net *nn =net_generic (net, nfsd_net_id);
Greg Kroah-Hartman
maintainerPATCH 374/634 svcrdma: return 0 on success from svc_rdma_copy_inline_range
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joshua Rogers <[email protected]>
commit 94972027ab55b200e031059fd6c7a649f8248020 upstream.
The function comment specifies 0 on success and -EINVAL on invalid parameters. Make the tail return 0 after a successful copy loop.
--- net/sunrpc/xprtrdma/svc_rdma_rw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/xprtrdma/svc_rdma_rw.c +1 -1
@@ -830,7 +830,7 @@ static int svc_rdma_copy_inline_range(st offset += page_len; } -return -EINVAL ; +return 0 ; }/**
Greg Kroah-Hartman
maintainerPATCH 375/634 powerpc/kexec: Enable SMT before waking offline CPUs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nysal Jan K.A. <[email protected]>
commit c2296a1e42418556efbeb5636c4fa6aa6106713a upstream.
If SMT is disabled or a partial SMT state is enabled, when a new kernel image is loaded for kexec, on reboot the following warning is observed:
kexec: Waking offline cpu 228.
WARNING: CPU: 0 PID: 9062 at arch/powerpc/kexec/core_64.c:223 kexec_prepare_cpus+0x1b0/0x1bc [snip] NIP kexec_prepare_cpus+0x1b0/0x1bc LR kexec_prepare_cpus+0x1a0/0x1bc Call Trace: kexec_prepare_cpus+0x1a0/0x1bc (unreliable) default_machine_kexec+0x160/0x19c machine_kexec+0x80/0x88 kernel_kexec+0xd0/0x118 __do_sys_reboot+0x210/0x2c4 system_call_exception+0x124/0x320 system_call_vectored_common+0x15c/0x2ec
This occurs as add_cpu() fails due to cpu_bootable() returning false for CPUs that fail the cpu_smt_thread_allowed() check or non primary threads if SMT is disabled.
Fix the issue by enabling SMT and resetting the number of SMT threads to the number of threads per core, before attempting to wake up all present CPUs.
--- arch/powerpc/kexec/core_64.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/powerpc/kexec/core_64.c +19 -0
@@ -202,6 +202,23 @@ static void kexec_prepare_cpus_wait(intmb (); } + +/* +* The add_cpu() call in wake_offline_cpus() can fail as cpu_bootable() +* returns false for CPUs that fail the cpu_smt_thread_allowed() check +* or non primary threads if SMT is disabled. Re-enable SMT and set the +* number of SMT threads to threads per core. +*/ +static void kexec_smt_reenable (void ) +{ +#if defined(CONFIG_SMP ) && defined(CONFIG_HOTPLUG_SMT ) +lock_device_hotplug (); + cpu_smt_num_threads = threads_per_core; + cpu_smt_control =CPU_SMT_ENABLED ; +unlock_device_hotplug (); +#endif +} +/* * We need to make sure each present CPU is online. The next kernel will scan * the device tree and assume primary threads are online and query secondary
@@ -216,6 +233,8 @@ static void wake_offline_cpus(void) {int cpu =0 ; +kexec_smt_reenable (); +for_each_present_cpu (cpu) {if (!cpu_online (cpu)) { printk(KERN_INFO "kexec: Waking offline cpu %d.\n",
Greg Kroah-Hartman
maintainerPATCH 376/634 io_uring/poll: correctly handle io_poll_add() return value on update
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
Commit 84230ad2d2afbf0c44c32967e525c0ad92e26b4e upstream.
When the core of io_uring was updated to handle completions consistently and with fixed return codes, the POLL_REMOVE opcode with updates got slightly broken. If a POLL_ADD is pending and then POLL_REMOVE is used to update the events of that request, if that update causes the POLL_ADD to now trigger, then that completion is lost and a CQE is never posted.
Additionally, ensure that if an update does cause an existing POLL_ADD to complete, that the completion value isn't always overwritten with -ECANCELED. For that case, whatever io_poll_add() set the value to should just be retained.
--- io_uring/poll.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
io_uring/poll.c +7 -2
@@ -1038,12 +1038,17 @@ found: ret2 =io_poll_add (preq, issue_flags & ~IO_URING_F_UNLOCKED );/* successfully updated, don't complete poll request */ -if (!ret2 || ret2 == -EIOCBQUEUED ) +if (ret2 ==IOU_ISSUE_SKIP_COMPLETE ) goto out; +/* request completed as part of the update, complete it */ +else if (ret2 ==IOU_OK ) + goto complete; } -req_set_fail (preq);io_req_set_res (preq, -ECANCELED ,0 ); +complete: +if (preq->cqe.res <0 ) +req_set_fail (preq);io_req_task_complete (preq, &locked); out:io_ring_submit_unlock (ctx, issue_flags);
Greg Kroah-Hartman
maintainerPATCH 377/634 io_uring: fix filename leak in __io_openat_prep()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prithvi Tambewagh <[email protected]>
Commit b14fad555302a2104948feaff70503b64c80ac01 upstream.
__io_openat_prep() allocates a struct filename using getname(). However,
for the condition of the file being installed in the fixed file table as well as having O_CLOEXEC flag set, the function returns early. At that point, the request doesn't have REQ_F_NEED_CLEANUP flag set. Due to this, the memory for the newly allocated struct filename is not cleaned up, causing a memory leak.
Fix this by setting the REQ_F_NEED_CLEANUP for the request just after the successful getname() call, so that when the request is torn down, the filename will be cleaned up, along with other resources needing cleanup.
--- io_uring/openclose.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/openclose.c +1 -1
@@ -54,13 +54,13 @@ static int __io_openat_prep(struct io_ki open->filename =NULL ;return ret; } + req->flags |=REQ_F_NEED_CLEANUP ; open->file_slot =READ_ONCE (sqe->file_index);if (open->file_slot && (open->how.flags &O_CLOEXEC ))return -EINVAL ; open->nofile =rlimit (RLIMIT_NOFILE ); - req->flags |=REQ_F_NEED_CLEANUP ;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 378/634 drm/amd/display: Use GFP_ATOMIC in dc_create_plane_state()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 3c41114dcdabb7b25f5bc33273c6db9c7af7f4a7 upstream.
This can get called from an atomic context.
--- drivers/gpu/drm/amd/display/dc/core/dc_surface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_surface.c +1 -1
@@ -104,7 +104,7 @@ void enable_surface_flip_reporting(strucstruct dc_plane_state *dc_create_plane_state (struct dc *dc) {struct dc_plane_state *plane_state =kvzalloc (sizeof (*plane_state), -GFP_KERNEL ); +GFP_ATOMIC );if (NULL == plane_state)return NULL ;
Greg Kroah-Hartman
maintainerPATCH 379/634 amba: tegra-ahb: Fix device leak on SMMU enable
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 500e1368e46928f4b2259612dcabb6999afae2a6 upstream.
Make sure to drop the reference taken to the AHB platform device when looking up its driver data while enabling the SMMU.
Note that holding a reference to a device does not prevent its driver data from going away.
--- drivers/amba/tegra-ahb.c | 1 + 1 file changed, 1 insertion(+)
drivers/amba/tegra-ahb.c +1 -0
@@ -144,6 +144,7 @@ int tegra_ahb_enable_smmu(struct device_if (!dev)return -EPROBE_DEFER ; ahb =dev_get_drvdata (dev); +put_device (dev); val =gizmo_readl (ahb,AHB_ARBITRATION_XBAR_CTRL ); val |=AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE ;gizmo_writel (ahb, val,AHB_ARBITRATION_XBAR_CTRL );
Greg Kroah-Hartman
maintainerPATCH 380/634 soc: qcom: ocmem: fix device leak on lookup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit b5c16ea57b030b8e9428ec726e26219dfe05c3d9 upstream.
Make sure to drop the reference taken to the ocmem platform device when looking up its driver data.
Note that holding a reference to a device does not prevent its driver data from going away so there is no point in keeping the reference.
Also note that commit 0ff027027e05 ("soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem") fixed the leak in a lookup error path, but the reference is still leaking on success.
--- drivers/soc/qcom/ocmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/ocmem.c +1 -1
@@ -211,9 +211,9 @@ struct ocmem *of_get_ocmem(struct deviceof_node_put (devnode); ocmem =platform_get_drvdata (pdev); +put_device (&pdev->dev);if (!ocmem) {dev_err (dev,"Cannot get ocmem\n" ); -put_device (&pdev->dev);return ERR_PTR (-ENODEV ); }return ocmem;
Greg Kroah-Hartman
maintainerPATCH 381/634 soc: amlogic: canvas: fix device leak on lookup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 32200f4828de9d7e6db379909898e718747f4e18 upstream.
Make sure to drop the reference taken to the canvas platform device when looking up its driver data.
Note that holding a reference to a device does not prevent its driver data from going away so there is no point in keeping the reference.
Also note that commit 28f851e6afa8 ("soc: amlogic: canvas: add missing put_device() call in meson_canvas_get()") fixed the leak in a lookup error path, but the reference is still leaking on success.
--- drivers/soc/amlogic/meson-canvas.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/soc/amlogic/meson-canvas.c +2 -3
@@ -72,10 +72,9 @@ struct meson_canvas *meson_canvas_get(st* current state, this driver probe cannot return -EPROBE_DEFER */ canvas =dev_get_drvdata (&canvas_pdev->dev); -if (!canvas) { -put_device (&canvas_pdev->dev); +put_device (&canvas_pdev->dev); +if (!canvas)return ERR_PTR (-EINVAL ); - }return canvas; }
Greg Kroah-Hartman
maintainerPATCH 382/634 rpmsg: glink: fix rpmsg device leak
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit a53e356df548f6b0e82529ef3cc6070f42622189 upstream.
While testing rpmsg-char interface it was noticed that duplicate sysfs entries are getting created and below warning is noticed.
Reason for this is that we are leaking rpmsg device pointer, setting it null without actually unregistering device.
Any further attempts to unregister fail because rpdev is NULL, resulting in a leak.
Fix this by unregistering rpmsg device before removing its reference from rpmsg channel.
sysfs: cannot create duplicate filename '/devices/platform/soc@0/3700000.remot eproc/remoteproc/remoteproc1/3700000.remoteproc:glink-edge/3700000.remoteproc:
glink-edge.adsp_apps.-1.-1'
[ 114.115347] CPU: 0 UID: 0 PID: 9 Comm: kworker/0:0 Not tainted 6.16.0-rc4 #7 PREEMPT [ 114.115355] Hardware name: Qualcomm Technologies, Inc. Robotics RB3gen2 (DT) [ 114.115358] Workqueue: events qcom_glink_work [ 114.115371] Call trace:8 [ 114.115374] show_stack+0x18/0x24 (C) [ 114.115382] dump_stack_lvl+0x60/0x80 [ 114.115388] dump_stack+0x18/0x24 [ 114.115393] sysfs_warn_dup+0x64/0x80 [ 114.115402] sysfs_create_dir_ns+0xf4/0x120 [ 114.115409] kobject_add_internal+0x98/0x260 [ 114.115416] kobject_add+0x9c/0x108 [ 114.115421] device_add+0xc4/0x7a0 [ 114.115429] rpmsg_register_device+0x5c/0xb0 [ 114.115434] qcom_glink_work+0x4bc/0x820 [ 114.115438] process_one_work+0x148/0x284 [ 114.115446] worker_thread+0x2c4/0x3e0 [ 114.115452] kthread+0x12c/0x204 [ 114.115457] ret_from_fork+0x10/0x20 [ 114.115464] kobject: kobject_add_internal failed for 3700000.remoteproc: glink-edge.adsp_apps.-1.-1 with -EEXIST, don't try to register things with the same name in the same directory. [ 114.250045] rpmsg 3700000.remoteproc:glink-edge.adsp_apps.-1.-1:
device_add failed: -17
--- drivers/rpmsg/qcom_glink_native.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/rpmsg/qcom_glink_native.c +8 -0
@@ -1242,6 +1242,7 @@ static void qcom_glink_destroy_ept(struc {struct glink_channel *channel =to_glink_channel (ept);struct qcom_glink *glink = channel->glink; +struct rpmsg_channel_info chinfo;unsigned long flags;spin_lock_irqsave (&channel->recv_lock, flags);
@@ -1249,6 +1250,13 @@ static void qcom_glink_destroy_ept(strucspin_unlock_irqrestore (&channel->recv_lock, flags);/* Decouple the potential rpdev from the channel */ +if (channel->rpdev) { +strscpy_pad (chinfo.name, channel->name,sizeof (chinfo.name)); + chinfo.src =RPMSG_ADDR_ANY ; + chinfo.dst =RPMSG_ADDR_ANY ; + +rpmsg_unregister_device (glink->dev, &chinfo); + } channel->rpdev =NULL ;qcom_glink_send_close_req (glink, channel);
Greg Kroah-Hartman
maintainerPATCH 383/634 platform/x86: intel: chtwc_int33fe: dont dereference swnode args
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
commit 527250cd9092461f1beac3e4180a4481bffa01b5 upstream.
Members of struct software_node_ref_args should not be dereferenced directly but set using the provided macros. Commit d7cdbbc93c56 ("software node: allow referencing firmware nodes") changed the name of the software node member and caused a build failure. Remove all direct dereferences of the ref struct as a fix.
However, this driver also seems to abuse the software node interface by waiting for a node with an arbitrary name "intel-xhci-usb-sw" to appear in the system before setting up the reference for the I2C device, while the actual software node already exists in the intel-xhci-usb-role-switch module and should be used to set up a static reference. Add a FIXME for a future improvement.
--- drivers/platform/x86/intel/chtwc_int33fe.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
drivers/platform/x86/intel/chtwc_int33fe.c +20 -9
@@ -77,7 +77,7 @@ static const struct software_node max170* software node. */ static struct software_node_ref_args fusb302_mux_refs[] = { - { .node =NULL }, +SOFTWARE_NODE_REFERENCE (NULL ), };static const struct property_entry fusb302_properties[] = {
@@ -190,11 +190,6 @@ static void cht_int33fe_remove_nodes(str {software_node_unregister_node_group (node_group); -if (fusb302_mux_refs[0 ].node) { -fwnode_handle_put (software_node_fwnode (fusb302_mux_refs[0 ].node)); - fusb302_mux_refs[0 ].node =NULL ; - } -if (data->dp) { data->dp->secondary =NULL ;fwnode_handle_put (data->dp);
@@ -202,7 +197,15 @@ static void cht_int33fe_remove_nodes(str } } -static int cht_int33fe_add_nodes (struct cht_int33fe_data *data) +static void cht_int33fe_put_swnode (void *data) +{ +struct fwnode_handle *fwnode = data; + +fwnode_handle_put (fwnode); + fusb302_mux_refs[0 ] =SOFTWARE_NODE_REFERENCE (NULL ); +} + +static int cht_int33fe_add_nodes (struct device *dev,struct cht_int33fe_data *data) {const struct software_node *mux_ref_node;int ret;
@@ -212,17 +215,25 @@ static int cht_int33fe_add_nodes(struct* until the mux driver has created software node for the mux device. * It means we depend on the mux driver. This function will return * -EPROBE_DEFER until the mux device is registered. +* +* FIXME: the relevant software node exists in intel-xhci-usb-role-switch +* and - if exported - could be used to set up a static reference. */ mux_ref_node =software_node_find_by_name (NULL ,"intel-xhci-usb-sw" );if (!mux_ref_node)return -EPROBE_DEFER ; + ret =devm_add_action_or_reset (dev, cht_int33fe_put_swnode, +software_node_fwnode (mux_ref_node)); +if (ret) +return ret; +/* * Update node used in "usb-role-switch" property. Note that we * rely on software_node_register_node_group() to use the original * instance of properties instead of copying them. */ - fusb302_mux_refs[0 ].node = mux_ref_node; + fusb302_mux_refs[0 ] =SOFTWARE_NODE_REFERENCE (mux_ref_node); ret =software_node_register_node_group (node_group);if (ret)
@@ -345,7 +356,7 @@ static int cht_int33fe_typec_probe(strucreturn fusb302_irq; } - ret =cht_int33fe_add_nodes (data); + ret =cht_int33fe_add_nodes (dev, data);if (ret)return ret;
Greg Kroah-Hartman
maintainerPATCH 384/634 i2c: amd-mp2: fix reference leak in MP2 PCI device
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit a6ee6aac66fb394b7f6e6187c73bdcd873f2d139 upstream.
In i2c_amd_probe(), amd_mp2_find_device() utilizes driver_find_next_device() which internally calls driver_find_device() to locate the matching device. driver_find_device() increments the reference count of the found device by calling get_device(), but amd_mp2_find_device() fails to call put_device() to decrement the reference count before returning. This results in a reference count leak of the PCI device each time i2c_amd_probe() is executed, which may prevent the device from being properly released and cause a memory leak.
Found by code review.
--- drivers/i2c/busses/i2c-amd-mp2-pci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-amd-mp2-pci.c +4 -1
@@ -449,13 +449,16 @@ struct amd_mp2_dev *amd_mp2_find_device( {struct device *dev;struct pci_dev *pci_dev; +struct amd_mp2_dev *mp2_dev; dev =driver_find_next_device (&amd_mp2_pci_driver.driver,NULL );if (!dev)return NULL ; pci_dev =to_pci_dev (dev); -return (struct amd_mp2_dev *)pci_get_drvdata (pci_dev); + mp2_dev = (struct amd_mp2_dev *)pci_get_drvdata (pci_dev); +put_device (dev); +return mp2_dev; }EXPORT_SYMBOL_GPL (amd_mp2_find_device);
Greg Kroah-Hartman
maintainerPATCH 385/634 hwmon: (max16065) Use local variable to avoid TOCTOU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gui-Dong Han <[email protected]>
commit b8d5acdcf525f44e521ca4ef51dce4dac403dab4 upstream.
In max16065_current_show, data->curr_sense is read twice: once for the error check and again for the calculation. Since i2c_smbus_read_byte_data returns negative error codes on failure, if the data changes to an error code between the check and the use, ADC_TO_CURR results in an incorrect calculation.
Read data->curr_sense into a local variable to ensure consistency. Note that data->curr_gain is constant and safe to access directly.
This aligns max16065_current_show with max16065_input_show, which already uses a local variable for the same reason.
--- drivers/hwmon/max16065.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/hwmon/max16065.c +4 -3
@@ -216,12 +216,13 @@ static ssize_t max16065_current_show(str struct device_attribute *da, char *buf) { struct max16065_data *data = max16065_update_device(dev); +int curr_sense = data->curr_sense; -if (unlikely (data->curr_sense <0 )) -return data->curr_sense; +if (unlikely (curr_sense <0 )) +return curr_sense;return sysfs_emit (buf,"%d\n" , -ADC_TO_CURR (data->curr_sense, data->curr_gain)); +ADC_TO_CURR (curr_sense, data->curr_gain)); } static ssize_t max16065_limit_store(struct device *dev,
Greg Kroah-Hartman
maintainerPATCH 386/634 hwmon: (w83791d) Convert macros to functions to avoid TOCTOU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gui-Dong Han <[email protected]>
commit 670d7ef945d3a84683594429aea6ab2cdfa5ceb4 upstream.
The macro FAN_FROM_REG evaluates its arguments multiple times. When used in lockless contexts involving shared driver data, this leads to Time-of-Check to Time-of-Use (TOCTOU) race conditions, potentially causing divide-by-zero errors.
Convert the macro to a static function. This guarantees that arguments are evaluated only once (pass-by-value), preventing the race conditions.
Additionally, in store_fan_div, move the calculation of the minimum limit inside the update lock. This ensures that the read-modify-write sequence operates on consistent data.
Adhere to the principle of minimal changes by only converting macros that evaluate arguments multiple times and are used in lockless contexts.
--- drivers/hwmon/w83791d.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/hwmon/w83791d.c +11 -6
@@ -218,9 +218,14 @@ static u8 fan_to_reg(long rpm, int div)return clamp_val ((1350000 + rpm * div /2 ) / (rpm * div),1 ,254 ); } -#define FAN_FROM_REG (val, div) ((val) == 0 ? -1 : \ - ((val) == 255 ? 0 : \ - 1350000 / ((val) * (div)))) +static int fan_from_reg (int val,int div) +{ +if (val ==0 ) +return -1 ; +if (val ==255 ) +return 0 ; +return 1350000 / (val * div); +}/* for temp1 which is 8-bit resolution, LSB = 1 degree Celsius */ #define TEMP1_FROM_REG (val) ((val) * 1000)
@@ -521,7 +526,7 @@ static ssize_t show_##reg(struct devicestruct w83791d_data *data =w83791d_update_device (dev); \int nr = sensor_attr->index; \return sprintf (buf,"%d\n" , \ -FAN_FROM_REG (data->reg[nr],DIV_FROM_REG (data->fan_div[nr]))); \ +fan_from_reg (data->reg[nr],DIV_FROM_REG (data->fan_div[nr]))); \ }show_fan_reg (fan);
@@ -585,10 +590,10 @@ static ssize_t store_fan_div(struct deviif (err)return err; +mutex_lock (&data->update_lock);/* Save fan_min */ - min =FAN_FROM_REG (data->fan_min[nr],DIV_FROM_REG (data->fan_div[nr])); + min =fan_from_reg (data->fan_min[nr],DIV_FROM_REG (data->fan_div[nr])); -mutex_lock (&data->update_lock); data->fan_div[nr] =div_to_reg (nr, val);switch (nr) {
Greg Kroah-Hartman
maintainerPATCH 387/634 hwmon: (w83l786ng) Convert macros to functions to avoid TOCTOU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gui-Dong Han <[email protected]>
commit 07272e883fc61574b8367d44de48917f622cdd83 upstream.
The macros FAN_FROM_REG and TEMP_FROM_REG evaluate their arguments multiple times. When used in lockless contexts involving shared driver data, this causes Time-of-Check to Time-of-Use (TOCTOU) race conditions.
Convert the macros to static functions. This guarantees that arguments are evaluated only once (pass-by-value), preventing the race conditions.
Adhere to the principle of minimal changes by only converting macros that evaluate arguments multiple times and are used in lockless contexts.
--- drivers/hwmon/w83l786ng.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/hwmon/w83l786ng.c +18 -8
@@ -77,15 +77,25 @@ FAN_TO_REG(long rpm, int div)return clamp_val ((1350000 + rpm * div /2 ) / (rpm * div),1 ,254 ); } -#define FAN_FROM_REG (val, div) ((val) == 0 ? -1 : \ - ((val) == 255 ? 0 : \ - 1350000 / ((val) * (div)))) +static int fan_from_reg (int val,int div) +{ +if (val ==0 ) +return -1 ; +if (val ==255 ) +return 0 ; +return 1350000 / (val * div); +}/* for temp */ #define TEMP_TO_REG (val) (clamp_val(((val) < 0 ? (val) + 0x100 * 1000 \ : (val)) / 1000, 0, 0xff)) -#define TEMP_FROM_REG (val) (((val) & 0x80 ? \ - (val) - 0x100 : (val)) * 1000) + +static int temp_from_reg (int val) +{ +if (val &0x80 ) +return (val -0x100 ) *1000 ; +return val *1000 ; +}/* * The analog voltage inputs have 8mV LSB. Since the sysfs output is
@@ -281,7 +291,7 @@ static ssize_t show_##reg(struct deviceint nr =to_sensor_dev_attr (attr)->index; \struct w83l786ng_data *data =w83l786ng_update_device (dev); \return sprintf (buf,"%d\n" , \ -FAN_FROM_REG (data->reg[nr],DIV_FROM_REG (data->fan_div[nr]))); \ +fan_from_reg (data->reg[nr],DIV_FROM_REG (data->fan_div[nr]))); \ }show_fan_reg (fan);
@@ -348,7 +358,7 @@ store_fan_div(struct device *dev, struct/* Save fan_min */ mutex_lock (&data->update_lock); - min =FAN_FROM_REG (data->fan_min[nr],DIV_FROM_REG (data->fan_div[nr])); + min =fan_from_reg (data->fan_min[nr],DIV_FROM_REG (data->fan_div[nr])); data->fan_div[nr] =DIV_TO_REG (val);
@@ -410,7 +420,7 @@ show_temp(struct device *dev, struct devint nr = sensor_attr->nr;int index = sensor_attr->index;struct w83l786ng_data *data =w83l786ng_update_device (dev); -return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp[nr][index])); +return sprintf (buf,"%d\n" ,temp_from_reg (data->temp[nr][index])); } static ssize_t
Greg Kroah-Hartman
maintainerPATCH 388/634 wifi: cfg80211: sme: store capped length in __cfg80211_connect_result()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 2b77b9551d1184cb5af8271ff350e6e2c1b3db0d ]
The QGenie AI code review tool says we should store the capped length to wdev->u.client.ssid_len. The AI is correct.
--- net/wireless/sme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/sme.c +1 -1
@@ -896,7 +896,7 @@ void __cfg80211_connect_result(struct net_device *dev, ssid_len =min (ssid->datalen,IEEE80211_MAX_SSID_LEN );memcpy (wdev->u.client.ssid, ssid->data, ssid_len); - wdev->u.client.ssid_len = ssid->datalen; + wdev->u.client.ssid_len = ssid_len;break ; }rcu_read_unlock ();
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 389/634 cfg80211: Update Transition Disable policy during port authorization
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinayak Yadawad <[email protected]>
[ Upstream commit 0ff57171d6d225558c81a69439d5323e35b40549 ]
In case of 4way handshake offload, transition disable policy updated by the AP during EAPOL 3/4 is not updated to the upper layer. This results in mismatch between transition disable policy between the upper layer and the driver. This patch addresses this issue by updating transition disable policy as part of port authorization indication.
Stable-dep-of: a519be2f5d95 ("wifi: mac80211: do not use old MBSSID elements")
--- .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 2 +- include/net/cfg80211.h | 4 +++- include/uapi/linux/nl80211.h | 3 +++ net/wireless/core.h | 5 ++++- net/wireless/nl80211.c | 8 +++++++- net/wireless/nl80211.h | 3 ++- net/wireless/sme.c | 12 ++++++++---- net/wireless/util.c | 4 +++- 8 files changed, 31 insertions(+), 10 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +1 -1
@@ -6009,7 +6009,7 @@ brcmf_bss_roaming_done(struct brcmf_cfg80211_info *cfg,brcmf_dbg (CONN ,"Report roaming result\n" );if (profile->use_fwsup ==BRCMF_PROFILE_FWSUP_1X && profile->is_ft) { -cfg80211_port_authorized (ndev, profile->bssid,GFP_KERNEL ); +cfg80211_port_authorized (ndev, profile->bssid,NULL ,0 ,GFP_KERNEL );brcmf_dbg (CONN ,"Report port authorized\n" ); }
include/net/cfg80211.h +3 -1
@@ -7825,6 +7825,8 @@ void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,* * @dev: network device * @bssid: the BSSID of the AP +* @td_bitmap: transition disable policy +* @td_bitmap_len: Length of transition disable policy * @gfp: allocation flags * * This function should be called by a driver that supports 4 way handshake
@@ -7835,7 +7837,7 @@ void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,* indicate the 802.11 association. */ void cfg80211_port_authorized (struct net_device *dev,const u8 *bssid, -gfp_t gfp); +const u8 * td_bitmap,u8 td_bitmap_len,gfp_t gfp);/** * cfg80211_disconnected - notify cfg80211 that connection was dropped
include/uapi/linux/nl80211.h +3 -0
@@ -2749,6 +2749,8 @@ enum nl80211_commands {* When used with %NL80211_CMD_FRAME_TX_STATUS, indicates the ack RX * timestamp. When used with %NL80211_CMD_FRAME RX notification, indicates * the incoming frame RX timestamp. +* @NL80211_ATTR_TD_BITMAP: Transition Disable bitmap, for subsequent +* (re)associations. * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3276,6 +3278,7 @@ enum nl80211_attrs {NL80211_ATTR_TX_HW_TIMESTAMP ,NL80211_ATTR_RX_HW_TIMESTAMP , + NL80211_ATTR_TD_BITMAP,/* add attributes here, update the policy in nl80211.c */
net/wireless/core.h +4 -1
@@ -277,6 +277,8 @@ struct cfg80211_event { } ij;struct {u8 bssid[ETH_ALEN ]; +const u8 *td_bitmap; +u8 td_bitmap_len; } pa; }; };
@@ -421,7 +423,8 @@ int cfg80211_disconnect(struct cfg80211_registered_device *rdev, bool wextev);void __cfg80211_roamed (struct wireless_dev *wdev,struct cfg80211_roam_info *info); -void __cfg80211_port_authorized (struct wireless_dev *wdev,const u8 *bssid); +void __cfg80211_port_authorized (struct wireless_dev *wdev,const u8 *bssid, +const u8 *td_bitmap,u8 td_bitmap_len);int cfg80211_mgd_wext_connect (struct cfg80211_registered_device *rdev,struct wireless_dev *wdev);void cfg80211_autodisconnect_wk (struct work_struct *work);
net/wireless/nl80211.c +7 -1
@@ -18016,7 +18016,8 @@ void nl80211_send_roamed(struct cfg80211_registered_device *rdev, }void nl80211_send_port_authorized (struct cfg80211_registered_device *rdev, -struct net_device *netdev,const u8 *bssid) +struct net_device *netdev,const u8 *bssid, +const u8 *td_bitmap,u8 td_bitmap_len) {struct sk_buff *msg;void *hdr;
@@ -18036,6 +18037,11 @@ void nl80211_send_port_authorized(struct cfg80211_registered_device *rdev, nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid)) goto nla_put_failure; +if ((td_bitmap_len >0 ) && td_bitmap) +if (nla_put (msg,NL80211_ATTR_TD_BITMAP , + td_bitmap_len, td_bitmap)) + goto nla_put_failure; +genlmsg_end (msg, hdr); genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
net/wireless/nl80211.h +2 -1
@@ -83,7 +83,8 @@ void nl80211_send_roamed(struct cfg80211_registered_device *rdev,struct net_device *netdev, struct cfg80211_roam_info *info, gfp_t gfp);void nl80211_send_port_authorized (struct cfg80211_registered_device *rdev, -struct net_device *netdev,const u8 *bssid); +struct net_device *netdev,const u8 *bssid, +const u8 *td_bitmap,u8 td_bitmap_len);void nl80211_send_disconnected (struct cfg80211_registered_device *rdev,struct net_device *netdev,u16 reason,const u8 *ie,size_t ie_len,bool from_ap);
net/wireless/sme.c +8 -4
@@ -1270,7 +1270,8 @@ void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info, }EXPORT_SYMBOL (cfg80211_roamed); -void __cfg80211_port_authorized (struct wireless_dev *wdev,const u8 *bssid) +void __cfg80211_port_authorized (struct wireless_dev *wdev,const u8 *bssid, +const u8 *td_bitmap,u8 td_bitmap_len) {ASSERT_WDEV_LOCK (wdev);
@@ -1283,11 +1284,11 @@ void __cfg80211_port_authorized(struct wireless_dev *wdev, const u8 *bssid)return ;nl80211_send_port_authorized (wiphy_to_rdev (wdev->wiphy), wdev->netdev, - bssid); + bssid, td_bitmap, td_bitmap_len); }void cfg80211_port_authorized (struct net_device *dev,const u8 *bssid, -gfp_t gfp) +const u8 *td_bitmap,u8 td_bitmap_len,gfp_t gfp) {struct wireless_dev *wdev = dev->ieee80211_ptr;struct cfg80211_registered_device *rdev =wiphy_to_rdev (wdev->wiphy);
@@ -1297,12 +1298,15 @@ void cfg80211_port_authorized(struct net_device *dev, const u8 *bssid,if (WARN_ON (!bssid))return ; - ev =kzalloc (sizeof (*ev), gfp); + ev =kzalloc (sizeof (*ev) + td_bitmap_len, gfp);if (!ev)return ; ev->type =EVENT_PORT_AUTHORIZED ;memcpy (ev->pa.bssid, bssid,ETH_ALEN ); + ev->pa.td_bitmap = ((u8 *)ev) +sizeof (*ev); + ev->pa.td_bitmap_len = td_bitmap_len; +memcpy ((void *)ev->pa.td_bitmap, td_bitmap, td_bitmap_len);/* * Use the wdev event list so that if there are pending
net/wireless/util.c +3 -1
@@ -1113,7 +1113,9 @@ void cfg80211_process_wdev_events(struct wireless_dev *wdev)__cfg80211_leave (wiphy_to_rdev (wdev->wiphy), wdev);break ;case EVENT_PORT_AUTHORIZED : -__cfg80211_port_authorized (wdev, ev->pa.bssid); +__cfg80211_port_authorized (wdev, ev->pa.bssid, + ev->pa.td_bitmap, + ev->pa.td_bitmap_len);break ; }wdev_unlock (wdev);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 390/634 wifi: mac80211: mlme: handle EHT channel puncturing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit aa87cd8b35736a5183745ab0ec4b82419024dfd7 ]
Handle the Puncturing info received from the AP in the EHT Operation element in beacons.
If the info is invalid:
- during association: disable EHT connection for the AP
- after association: disconnect
This commit includes many (internal) bugfixes and spec updates various people.
Stable-dep-of: a519be2f5d95 ("wifi: mac80211: do not use old MBSSID elements")
--- include/net/mac80211.h | 5 +- net/mac80211/cfg.c | 2 +- net/mac80211/chan.c | 2 +- net/mac80211/ieee80211_i.h | 2 +- net/mac80211/mlme.c | 224 ++++++++++++++++++++++++++++++++++++- 5 files changed, 228 insertions(+), 7 deletions(-)
include/net/mac80211.h +4 -1
@@ -339,7 +339,7 @@ struct ieee80211_vif_chanctx_switch {* @BSS_CHANGED_FILS_DISCOVERY: FILS discovery status changed. * @BSS_CHANGED_UNSOL_BCAST_PROBE_RESP: Unsolicited broadcast probe response * status changed. -* +* @BSS_CHANGED_EHT_PUNCTURING: The channel puncturing bitmap changed. */ enum ieee80211_bss_change {BSS_CHANGED_ASSOC =1 <<0 ,
@@ -374,6 +374,7 @@ enum ieee80211_bss_change {BSS_CHANGED_HE_BSS_COLOR =1 <<29 ,BSS_CHANGED_FILS_DISCOVERY =1 <<30 ,BSS_CHANGED_UNSOL_BCAST_PROBE_RESP =1 <<31 , + BSS_CHANGED_EHT_PUNCTURING = BIT_ULL(32), /* when adding here, make sure to change ieee80211_reconfig */ };
@@ -639,6 +640,7 @@ struct ieee80211_fils_discovery {* @tx_pwr_env_num: number of @tx_pwr_env. * @pwr_reduction: power constraint of BSS. * @eht_support: does this BSS support EHT +* @eht_puncturing: bitmap to indicate which channels are punctured in this BSS * @csa_active: marks whether a channel switch is going on. Internally it is * write-protected by sdata_lock and local->mtx so holding either is fine * for read access.
@@ -718,6 +720,7 @@ struct ieee80211_bss_conf {u8 tx_pwr_env_num;u8 pwr_reduction;bool eht_support; +u16 eht_puncturing;bool csa_active;bool mu_mimo_owner;
net/mac80211/cfg.c +1 -1
@@ -4154,7 +4154,7 @@ static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy,struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev);struct ieee80211_link_data *link;int ret; -u32 changed =0 ; +u64 changed =0 ; link =sdata_dereference (sdata->link[link_id], sdata);
net/mac80211/chan.c +1 -1
@@ -1936,7 +1936,7 @@ int ieee80211_link_use_reserved_context(struct ieee80211_link_data *link)int ieee80211_link_change_bandwidth (struct ieee80211_link_data *link,const struct cfg80211_chan_def *chandef, -u32 *changed) +u64 *changed) {struct ieee80211_sub_if_data *sdata = link->sdata;struct ieee80211_bss_conf *link_conf = link->conf;
net/mac80211/ieee80211_i.h +1 -1
@@ -2465,7 +2465,7 @@ int ieee80211_link_unreserve_chanctx(struct ieee80211_link_data *link);int __must_check ieee80211_link_change_bandwidth (struct ieee80211_link_data *link,const struct cfg80211_chan_def *chandef, -u32 *changed); +u64 *changed);void ieee80211_link_release_channel (struct ieee80211_link_data *link);void ieee80211_link_vlan_copy_chanctx (struct ieee80211_link_data *link); void ieee80211_link_copy_chanctx_to_vlans(struct ieee80211_link_data *link,
net/mac80211/mlme.c +221 -3
281 lines not on this page · raw message
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 391/634 wifi: cfg80211: move puncturing bitmap validation from mac80211
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aloka Dixit <[email protected]>
[ Upstream commit b25413fed3d43e1ed3340df4d928971bb8639f66 ]
- Move ieee80211_valid_disable_subchannel_bitmap() from mlme.c to chan.c, rename it as cfg80211_valid_disable_subchannel_bitmap() and export it.
- Modify the prototype to include struct cfg80211_chan_def instead of only bandwidth to support a check which returns false if the primary channel is punctured.
Stable-dep-of: a519be2f5d95 ("wifi: mac80211: do not use old MBSSID elements")
--- include/net/cfg80211.h | 12 +++++++ net/mac80211/mlme.c | 73 ++++-------------------------------------- net/wireless/chan.c | 69 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 67 deletions(-)
include/net/cfg80211.h +12 -0
@@ -9056,4 +9056,16 @@ static inline int cfg80211_color_change_notify(struct net_device *dev) 0, 0); } +/** +* cfg80211_valid_disable_subchannel_bitmap - validate puncturing bitmap +* @bitmap: bitmap to be validated +* @chandef: channel definition +* +* Validate the puncturing bitmap. +* +* Return: %true if the bitmap is valid. %false otherwise. +*/ +bool cfg80211_valid_disable_subchannel_bitmap (u16 *bitmap, +const struct cfg80211_chan_def *chandef); +#endif /* __NET_CFG80211_H */
net/mac80211/mlme.c +6 -67
97 lines not on this page · raw message
net/wireless/chan.c +69 -0
72 lines not on this page · raw message
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 392/634 wifi: nl80211: validate and configure puncturing bitmap
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aloka Dixit <[email protected]>
[ Upstream commit d7c1a9a0ed180d8884798ce97afe7283622a484f ]
- New feature flag, NL80211_EXT_FEATURE_PUNCT, to advertise driver support for preamble puncturing in AP mode.
- New attribute, NL80211_ATTR_PUNCT_BITMAP, to receive a puncturing bitmap from the userspace during AP bring up (NL80211_CMD_START_AP) and channel switch (NL80211_CMD_CHANNEL_SWITCH) operations. Each bit corresponds to a 20 MHz channel in the operating bandwidth, lowest bit for the lowest channel. Bit set to 1 indicates that the channel is punctured. Higher 16 bits are reserved.
- New members added to structures cfg80211_ap_settings and cfg80211_csa_settings to propagate the bitmap to the driver after validation.
Stable-dep-of: a519be2f5d95 ("wifi: mac80211: do not use old MBSSID elements")
--- include/net/cfg80211.h | 8 ++++++++ include/uapi/linux/nl80211.h | 11 +++++++++++ net/wireless/nl80211.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+)
include/net/cfg80211.h +8 -0
@@ -1325,6 +1325,9 @@ struct cfg80211_unsol_bcast_probe_resp {* @fils_discovery: FILS discovery transmission parameters * @unsol_bcast_probe_resp: Unsolicited broadcast probe response parameters * @mbssid_config: AP settings for multiple bssid +* @punct_bitmap: Preamble puncturing bitmap. Each bit represents +* a 20 MHz channel, lowest bit corresponding to the lowest channel. +* Bit set to 1 indicates that the channel is punctured. */ struct cfg80211_ap_settings {struct cfg80211_chan_def chandef;
@@ -1359,6 +1362,7 @@ struct cfg80211_ap_settings {struct cfg80211_fils_discovery fils_discovery;struct cfg80211_unsol_bcast_probe_resp unsol_bcast_probe_resp;struct cfg80211_mbssid_config mbssid_config; +u16 punct_bitmap; };/**
@@ -1376,6 +1380,9 @@ struct cfg80211_ap_settings {* @radar_required: whether radar detection is required on the new channel * @block_tx: whether transmissions should be blocked while changing * @count: number of beacons until switch +* @punct_bitmap: Preamble puncturing bitmap. Each bit represents +* a 20 MHz channel, lowest bit corresponding to the lowest channel. +* Bit set to 1 indicates that the channel is punctured. */ struct cfg80211_csa_settings {struct cfg80211_chan_def chandef;
@@ -1388,6 +1395,7 @@ struct cfg80211_csa_settings {bool radar_required;bool block_tx;u8 count; +u16 punct_bitmap; };/**
include/uapi/linux/nl80211.h +11 -0
@@ -2751,6 +2751,12 @@ enum nl80211_commands {* the incoming frame RX timestamp. * @NL80211_ATTR_TD_BITMAP: Transition Disable bitmap, for subsequent * (re)associations. +* +* @NL80211_ATTR_PUNCT_BITMAP: (u32) Preamble puncturing bitmap, lowest +* bit corresponds to the lowest 20 MHz channel. Each bit set to 1 +* indicates that the sub-channel is punctured. Higher 16 bits are +* reserved. +* * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3280,6 +3286,8 @@ enum nl80211_attrs {NL80211_ATTR_RX_HW_TIMESTAMP ,NL80211_ATTR_TD_BITMAP , +NL80211_ATTR_PUNCT_BITMAP , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
@@ -6294,6 +6302,8 @@ enum nl80211_feature_flags {* might apply, e.g. no scans in progress, no offchannel operations * in progress, and no active connections. * +* @NL80211_EXT_FEATURE_PUNCT: Driver supports preamble puncturing in AP mode. +* * @NUM_NL80211_EXT_FEATURES: number of extended features. * @MAX_NL80211_EXT_FEATURES: highest extended feature index. */
@@ -6362,6 +6372,7 @@ enum nl80211_ext_feature_index {NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD ,NL80211_EXT_FEATURE_RADAR_BACKGROUND ,NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE , +NL80211_EXT_FEATURE_PUNCT ,/* add new features before the definition below */ NUM_NL80211_EXT_FEATURES,
net/wireless/nl80211.c +32 -0
@@ -810,6 +810,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [NL80211_ATTR_MLD_ADDR] = NLA_POLICY_EXACT_LEN(ETH_ALEN), [NL80211_ATTR_MLO_SUPPORT] = { .type = NLA_FLAG }, [NL80211_ATTR_MAX_NUM_AKM_SUITES] = { .type = NLA_REJECT }, + [NL80211_ATTR_PUNCT_BITMAP] = NLA_POLICY_RANGE(NLA_U8, 0, 0xffff), };/* policy for the key attributes */
@@ -3178,6 +3179,21 @@ static bool nl80211_can_set_dev_channel(struct wireless_dev *wdev) wdev->iftype ==NL80211_IFTYPE_P2P_GO ; } +static int nl80211_parse_punct_bitmap (struct cfg80211_registered_device *rdev, +struct genl_info *info, +const struct cfg80211_chan_def *chandef, +u16 *punct_bitmap) +{ +if (!wiphy_ext_feature_isset (&rdev->wiphy,NL80211_EXT_FEATURE_PUNCT )) +return -EINVAL ; + + *punct_bitmap =nla_get_u32 (info->attrs[NL80211_ATTR_PUNCT_BITMAP ]); +if (!cfg80211_valid_disable_subchannel_bitmap (punct_bitmap, chandef)) +return -EINVAL ; + +return 0 ; +} +int nl80211_parse_chandef (struct cfg80211_registered_device *rdev,struct genl_info *info,struct cfg80211_chan_def *chandef)
@@ -5955,6 +5971,14 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) goto out; } +if (info->attrs[NL80211_ATTR_PUNCT_BITMAP ]) { + err =nl80211_parse_punct_bitmap (rdev, info, + ¶ms->chandef, + ¶ms->punct_bitmap); +if (err) + goto out; + } +if (!cfg80211_reg_can_beacon_relax (&rdev->wiphy, ¶ms->chandef, wdev->iftype)) { err = -EINVAL ;
@@ -10107,6 +10131,14 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)if (info->attrs[NL80211_ATTR_CH_SWITCH_BLOCK_TX ]) params.block_tx = true; +if (info->attrs[NL80211_ATTR_PUNCT_BITMAP ]) { + err =nl80211_parse_punct_bitmap (rdev, info, + ¶ms.chandef, + ¶ms.punct_bitmap); +if (err) + goto free; + } +wdev_lock (wdev); err =rdev_channel_switch (rdev, dev, ¶ms);wdev_unlock (wdev);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 393/634 wifi: nl80211: add a command to enable/disable HW timestamping
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avraham Stern <[email protected]>
[ Upstream commit cbbaf2bb829b6c4ef911d4a725fc9b1fadc1e43f ]
Add a command to enable and disable HW timestamping of TM and FTM frames. HW timestamping can be enabled for a specific mac address or for all addresses.
The low level driver will indicate how many peers HW timestamping can be enabled concurrently, and this information will be passed to userspace.
Stable-dep-of: a519be2f5d95 ("wifi: mac80211: do not use old MBSSID elements")
--- include/net/cfg80211.h | 27 ++++++++++++++++++++++++++ include/uapi/linux/nl80211.h | 22 +++++++++++++++++++++ net/wireless/nl80211.c | 37 ++++++++++++++++++++++++++++++++++++ net/wireless/rdev-ops.h | 17 +++++++++++++++++ net/wireless/trace.h | 25 ++++++++++++++++++++++++ 5 files changed, 128 insertions(+)
include/net/cfg80211.h +27 -0
@@ -830,6 +830,18 @@ struct cfg80211_fils_aad {const u8 *anonce; }; +/** +* struct cfg80211_set_hw_timestamp - enable/disable HW timestamping +* @macaddr: peer MAC address. NULL to enable/disable HW timestamping for all +* addresses. +* @enable: if set, enable HW timestamping for the specified MAC address. +* Otherwise disable HW timestamping for the specified MAC address. +*/ +struct cfg80211_set_hw_timestamp { +const u8 *macaddr; +bool enable; +}; +/** * cfg80211_get_chandef_type - return old channel type from chandef * @chandef: the channel definition
@@ -4291,6 +4303,8 @@ struct mgmt_frame_regs {* @add_link_station: Add a link to a station. * @mod_link_station: Modify a link of a station. * @del_link_station: Remove a link of a station. +* +* @set_hw_timestamp: Enable/disable HW timestamping of TM/FTM frames. */ struct cfg80211_ops {int (*suspend)(struct wiphy *wiphy,struct cfg80211_wowlan *wow);
@@ -4644,6 +4658,8 @@ struct cfg80211_ops { struct link_station_parameters *params);int (*del_link_station)(struct wiphy *wiphy,struct net_device *dev,struct link_station_del_parameters *params); +int (*set_hw_timestamp)(struct wiphy *wiphy,struct net_device *dev, +struct cfg80211_set_hw_timestamp *hwts); };/*
@@ -5099,6 +5115,8 @@ struct wiphy_iftype_akm_suites {int n_akm_suites; }; +#define CFG80211_HW_TIMESTAMP_ALL_PEERS 0xffff +/** * struct wiphy - wireless hardware description * @mtx: mutex for the data (structures) of this device
@@ -5308,6 +5326,13 @@ struct wiphy_iftype_akm_suites {* NL80211_MAX_NR_AKM_SUITES in order to avoid compatibility issues with * legacy userspace and maximum allowed value is * CFG80211_MAX_NUM_AKM_SUITES. +* +* @hw_timestamp_max_peers: maximum number of peers that the driver supports +* enabling HW timestamping for concurrently. Setting this field to a +* non-zero value indicates that the driver supports HW timestamping. +* A value of %CFG80211_HW_TIMESTAMP_ALL_PEERS indicates the driver +* supports enabling HW timestamping for all peers (i.e. no need to +* specify a mac address). */ struct wiphy {struct mutex mtx;
@@ -5456,6 +5481,8 @@ struct wiphy {u8 ema_max_profile_periodicity;u16 max_num_akm_suites; +u16 hw_timestamp_max_peers; +char priv[]__aligned(NETDEV_ALIGN) ; };
include/uapi/linux/nl80211.h +22 -0
@@ -1281,6 +1281,16 @@* @NL80211_CMD_MODIFY_LINK_STA: Modify a link of an MLD station * @NL80211_CMD_REMOVE_LINK_STA: Remove a link of an MLD station * +* @NL80211_CMD_SET_HW_TIMESTAMP: Enable/disable HW timestamping of Timing +* measurement and Fine timing measurement frames. If %NL80211_ATTR_MAC +* is included, enable/disable HW timestamping only for frames to/from the +* specified MAC address. Otherwise enable/disable HW timestamping for +* all TM/FTM frames (including ones that were enabled with specific MAC +* address). If %NL80211_ATTR_HW_TIMESTAMP_ENABLED is not included, disable +* HW timestamping. +* The number of peers that HW timestamping can be enabled for concurrently +* is indicated by %NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS. +* * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */
@@ -1532,6 +1542,8 @@ enum nl80211_commands {NL80211_CMD_MODIFY_LINK_STA ,NL80211_CMD_REMOVE_LINK_STA , + NL80211_CMD_SET_HW_TIMESTAMP, +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
@@ -2757,6 +2769,13 @@ enum nl80211_commands {* indicates that the sub-channel is punctured. Higher 16 bits are * reserved. * +* @NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS: Maximum number of peers that HW +* timestamping can be enabled for concurrently (u16), a wiphy attribute. +* A value of 0xffff indicates setting for all peers (i.e. not specifying +* an address with %NL80211_CMD_SET_HW_TIMESTAMP) is supported. +* @NL80211_ATTR_HW_TIMESTAMP_ENABLED: Indicates whether HW timestamping should +* be enabled or not (flag attribute). +* * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3288,6 +3307,9 @@ enum nl80211_attrs {NL80211_ATTR_PUNCT_BITMAP , +NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS , +NL80211_ATTR_HW_TIMESTAMP_ENABLED , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
net/wireless/nl80211.c +37 -0
@@ -811,6 +811,9 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [NL80211_ATTR_MLO_SUPPORT] = { .type = NLA_FLAG }, [NL80211_ATTR_MAX_NUM_AKM_SUITES] = { .type = NLA_REJECT }, [NL80211_ATTR_PUNCT_BITMAP] = NLA_POLICY_RANGE(NLA_U8, 0, 0xffff), + + [NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS] = { .type = NLA_U16 }, + [NL80211_ATTR_HW_TIMESTAMP_ENABLED] = { .type = NLA_FLAG }, };/* policy for the key attributes */
@@ -2965,6 +2968,11 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,if (rdev->wiphy.flags &WIPHY_FLAG_SUPPORTS_MLO )nla_put_flag (msg,NL80211_ATTR_MLO_SUPPORT ); +if (rdev->wiphy.hw_timestamp_max_peers && +nla_put_u16 (msg,NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS , + rdev->wiphy.hw_timestamp_max_peers)) + goto nla_put_failure; +/* done */ state->split_start =0 ;break ;
@@ -16162,6 +16170,29 @@ nl80211_remove_link_station(struct sk_buff *skb, struct genl_info *info)return ret; } +static int nl80211_set_hw_timestamp (struct sk_buff *skb, +struct genl_info *info) +{ +struct cfg80211_registered_device *rdev = info->user_ptr[0 ]; +struct net_device *dev = info->user_ptr[1 ]; +struct cfg80211_set_hw_timestamp hwts = {}; + +if (!rdev->wiphy.hw_timestamp_max_peers) +return -EOPNOTSUPP ; + +if (!info->attrs[NL80211_ATTR_MAC ] && + rdev->wiphy.hw_timestamp_max_peers !=CFG80211_HW_TIMESTAMP_ALL_PEERS ) +return -EOPNOTSUPP ; + +if (info->attrs[NL80211_ATTR_MAC ]) + hwts.macaddr =nla_data (info->attrs[NL80211_ATTR_MAC ]); + + hwts.enable = +nla_get_flag (info->attrs[NL80211_ATTR_HW_TIMESTAMP_ENABLED ]); + +return rdev_set_hw_timestamp (rdev, dev, &hwts); +} +#define NL80211_FLAG_NEED_WIPHY 0x01#define NL80211_FLAG_NEED_NETDEV 0x02#define NL80211_FLAG_NEED_RTNL 0x04
@@ -17333,6 +17364,12 @@ static const struct genl_small_ops nl80211_small_ops[] = { .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP | NL80211_FLAG_MLO_VALID_LINK_ID), }, + { + .cmd = NL80211_CMD_SET_HW_TIMESTAMP, + .doit = nl80211_set_hw_timestamp, + .flags = GENL_UNS_ADMIN_PERM, + .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP), + }, };static struct genl_family nl80211_fam__ro_after_init = {
net/wireless/rdev-ops.h +17 -0
@@ -1498,4 +1498,21 @@ rdev_del_link_station(struct cfg80211_registered_device *rdev, return ret; } +static inline int +rdev_set_hw_timestamp (struct cfg80211_registered_device *rdev, +struct net_device *dev, +struct cfg80211_set_hw_timestamp *hwts) +{ +struct wiphy *wiphy = &rdev->wiphy; +int ret; + +if (!rdev->ops->set_hw_timestamp) +return -EOPNOTSUPP ; + +trace_rdev_set_hw_timestamp (wiphy, dev, hwts); + ret = rdev->ops->set_hw_timestamp (wiphy, dev, hwts); +trace_rdev_return_int (wiphy, ret); + +return ret; +}#endif /* __CFG80211_RDEV_OPS */
net/wireless/trace.h +25 -0
@@ -3901,6 +3901,31 @@ TRACE_EVENT(rdev_del_link_station, __entry->link_id) ); +TRACE_EVENT (rdev_set_hw_timestamp, + TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, + struct cfg80211_set_hw_timestamp *hwts), + +TP_ARGS (wiphy, netdev, hwts), + +TP_STRUCT__entry ( + WIPHY_ENTRY + NETDEV_ENTRY + MAC_ENTRY(macaddr) +__field (bool, enable) + ), + +TP_fast_assign ( + WIPHY_ASSIGN; + NETDEV_ASSIGN; + MAC_ASSIGN(macaddr, hwts->macaddr); + __entry->enable = hwts->enable; + ), + +TP_printk (WIPHY_PR_FMT ", " NETDEV_PR_FMT ", mac %pM, enable: %u" , +WIPHY_PR_ARG ,NETDEV_PR_ARG , __entry->macaddr, + __entry->enable) +); +#endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ #undef TRACE_INCLUDE_PATH
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 394/634 wifi: mac80211: generate EMA beacons in AP mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aloka Dixit <[email protected]>
[ Upstream commit bd54f3c29077f23dad92ef82a78061b40be30c65 ]
Add APIs to generate an array of beacons for an EMA AP (enhanced multiple BSSID advertisements), each including a single MBSSID element. EMA profile periodicity equals the count of elements.
- ieee80211_beacon_get_template_ema_list() - Generate and return all EMA beacon templates. Drivers must call ieee80211_beacon_free_ema_list() to free the memory. No change in the prototype for the existing API, ieee80211_beacon_get_template(), which should be used for non-EMA AP.
- ieee80211_beacon_get_template_ema_index() - Generate a beacon which includes the multiple BSSID element at the given index. Drivers can use this function in a loop until NULL is returned which indicates end of available MBSSID elements.
- ieee80211_beacon_free_ema_list() - free the memory allocated for the list of EMA beacon templates.
Modify existing functions ieee80211_beacon_get_ap(), ieee80211_get_mbssid_beacon_len() and ieee80211_beacon_add_mbssid() to accept a new parameter for EMA index.
Stable-dep-of: a519be2f5d95 ("wifi: mac80211: do not use old MBSSID elements")
--- include/net/mac80211.h | 68 +++++++++++++++++++ net/mac80211/cfg.c | 11 +-- net/mac80211/ieee80211_i.h | 10 ++- net/mac80211/tx.c | 134 ++++++++++++++++++++++++++++++++++--- 4 files changed, 205 insertions(+), 18 deletions(-)
include/net/mac80211.h +68 -0
@@ -5222,6 +5222,74 @@ ieee80211_beacon_get_template(struct ieee80211_hw *hw,struct ieee80211_mutable_offsets *offs, unsigned int link_id); +/** +* ieee80211_beacon_get_template_ema_index - EMA beacon template generation +* @hw: pointer obtained from ieee80211_alloc_hw(). +* @vif: &struct ieee80211_vif pointer from the add_interface callback. +* @offs: &struct ieee80211_mutable_offsets pointer to struct that will +* receive the offsets that may be updated by the driver. +* @link_id: the link id to which the beacon belongs (or 0 for a non-MLD AP). +* @ema_index: index of the beacon in the EMA set. +* +* This function follows the same rules as ieee80211_beacon_get_template() +* but returns a beacon template which includes multiple BSSID element at the +* requested index. +* +* Return: The beacon template. %NULL indicates the end of EMA templates. +*/ +struct sk_buff * +ieee80211_beacon_get_template_ema_index (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_mutable_offsets *offs, +unsigned int link_id,u8 ema_index); + +/** +* struct ieee80211_ema_beacons - List of EMA beacons +* @cnt: count of EMA beacons. +* +* @bcn: array of EMA beacons. +* @bcn.skb: the skb containing this specific beacon +* @bcn.offs: &struct ieee80211_mutable_offsets pointer to struct that will +* receive the offsets that may be updated by the driver. +*/ +struct ieee80211_ema_beacons { +u8 cnt; +struct { +struct sk_buff *skb; +struct ieee80211_mutable_offsets offs; + } bcn[]; +}; + +/** +* ieee80211_beacon_get_template_ema_list - EMA beacon template generation +* @hw: pointer obtained from ieee80211_alloc_hw(). +* @vif: &struct ieee80211_vif pointer from the add_interface callback. +* @link_id: the link id to which the beacon belongs (or 0 for a non-MLD AP) +* +* This function follows the same rules as ieee80211_beacon_get_template() +* but allocates and returns a pointer to list of all beacon templates required +* to cover all profiles in the multiple BSSID set. Each template includes only +* one multiple BSSID element. +* +* Driver must call ieee80211_beacon_free_ema_list() to free the memory. +* +* Return: EMA beacon templates of type struct ieee80211_ema_beacons *. +* %NULL on error. +*/ +struct ieee80211_ema_beacons * +ieee80211_beacon_get_template_ema_list (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +unsigned int link_id); + +/** +* ieee80211_beacon_free_ema_list - free an EMA beacon template list +* @ema_beacons: list of EMA beacons of type &struct ieee80211_ema_beacons pointers. +* +* This function will free a list previously acquired by calling +* ieee80211_beacon_get_template_ema_list() +*/ +void ieee80211_beacon_free_ema_list (struct ieee80211_ema_beacons *ema_beacons); +/** * ieee80211_beacon_get_tim - beacon generation function * @hw: pointer obtained from ieee80211_alloc_hw().
net/mac80211/cfg.c +7 -4
@@ -1125,11 +1125,11 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,if (params->mbssid_ies) { mbssid = params->mbssid_ies; size +=struct_size (new->mbssid_ies, elem, mbssid->cnt); - size +=ieee80211_get_mbssid_beacon_len (mbssid); + size +=ieee80211_get_mbssid_beacon_len (mbssid, mbssid->cnt); }else if (old && old->mbssid_ies) { mbssid = old->mbssid_ies; size +=struct_size (new->mbssid_ies, elem, mbssid->cnt); - size +=ieee80211_get_mbssid_beacon_len (mbssid); + size +=ieee80211_get_mbssid_beacon_len (mbssid, mbssid->cnt); } new =kzalloc (size,GFP_KERNEL );
@@ -3356,8 +3356,11 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon) len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len + beacon->proberesp_ies_len + beacon->assocresp_ies_len + - beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len + -ieee80211_get_mbssid_beacon_len (beacon->mbssid_ies); + beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len; + +if (beacon->mbssid_ies) + len +=ieee80211_get_mbssid_beacon_len (beacon->mbssid_ies, + beacon->mbssid_ies->cnt); new_beacon =kzalloc (sizeof (*new_beacon) + len,GFP_KERNEL );if (!new_beacon)
net/mac80211/ieee80211_i.h +7 -3
@@ -1165,13 +1165,17 @@ ieee80211_vif_get_shift(struct ieee80211_vif *vif) }static inline int -ieee80211_get_mbssid_beacon_len (struct cfg80211_mbssid_elems *elems) +ieee80211_get_mbssid_beacon_len (struct cfg80211_mbssid_elems *elems,u8 i) { -int i, len =0 ; +int len =0 ; -if (!elems) +if (!elems || !elems->cnt || i > elems->cnt)return 0 ; +if (i < elems->cnt) +return elems->elem[i].len; + +/* i == elems->cnt, calculate total length of all MBSSID elements */ for (i =0 ; i < elems->cnt; i++) len += elems->elem[i].len;
net/mac80211/tx.c +123 -11
194 lines not on this page · raw message
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 395/634 cfg80211: support RNR for EMA AP
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aloka Dixit <[email protected]>
[ Upstream commit dbbb27e183b1568d5a907ace1cd144b0709ea52a ]
As per IEEE Std 802.11ax-2021, 11.1.3.8.3 Discovery of a nontransmitted BSSID profile, an EMA AP that transmits a Beacon frame carrying a partial list of nontransmitted BSSID profiles should include in the frame a Reduced Neighbor Report element carrying information for at least the nontransmitted BSSIDs that are not present in the Multiple BSSID element carried in that frame.
Add new nested attribute NL80211_ATTR_EMA_RNR_ELEMS to support the above. Number of RNR elements must be more than or equal to the number of MBSSID elements. This attribute can be used only when EMA is enabled. Userspace is responsible for splitting the RNR into multiple elements such that each element excludes the non-transmitting profiles already included in the MBSSID element (%NL80211_ATTR_MBSSID_ELEMS) at the same index. Each EMA beacon will be generated by adding MBSSID and RNR elements at the same index. If the userspace provides more RNR elements than the number of MBSSID elements then these will be added in every EMA beacon.
Stable-dep-of: a519be2f5d95 ("wifi: mac80211: do not use old MBSSID elements")
--- include/net/cfg80211.h | 19 +++++++++ include/uapi/linux/nl80211.h | 13 ++++++ net/wireless/nl80211.c | 79 ++++++++++++++++++++++++++++++++---- 3 files changed, 104 insertions(+), 7 deletions(-)
include/net/cfg80211.h +19 -0
@@ -1187,6 +1187,23 @@ struct cfg80211_mbssid_elems { } elem[]; }; +/** +* struct cfg80211_rnr_elems - Reduced neighbor report (RNR) elements +* +* @cnt: Number of elements in array %elems. +* +* @elem: Array of RNR element(s) to be added into Beacon frames. +* @elem.data: Data for RNR elements. +* @elem.len: Length of data. +*/ +struct cfg80211_rnr_elems { +u8 cnt; +struct { +const u8 *data; +size_t len; + } elem[]; +}; +/** * struct cfg80211_beacon_data - beacon data * @link_id: the link ID for the AP MLD link sending this beacon
@@ -1207,6 +1224,7 @@ struct cfg80211_mbssid_elems {* @probe_resp_len: length of probe response template (@probe_resp) * @probe_resp: probe response template (AP mode only) * @mbssid_ies: multiple BSSID elements +* @rnr_ies: reduced neighbor report elements * @ftm_responder: enable FTM responder functionality; -1 for no change * (which also implies no change in LCI/civic location data) * @lci: Measurement Report element content, starting with Measurement Token
@@ -1230,6 +1248,7 @@ struct cfg80211_beacon_data {const u8 *lci;const u8 *civicloc;struct cfg80211_mbssid_elems *mbssid_ies; +struct cfg80211_rnr_elems *rnr_ies;s8 ftm_responder;size_t head_len, tail_len;
include/uapi/linux/nl80211.h +13 -0
@@ -2776,6 +2776,17 @@ enum nl80211_commands {* @NL80211_ATTR_HW_TIMESTAMP_ENABLED: Indicates whether HW timestamping should * be enabled or not (flag attribute). * +* @NL80211_ATTR_EMA_RNR_ELEMS: Optional nested attribute for +* reduced neighbor report (RNR) elements. This attribute can be used +* only when NL80211_MBSSID_CONFIG_ATTR_EMA is enabled. +* Userspace is responsible for splitting the RNR into multiple +* elements such that each element excludes the non-transmitting +* profiles already included in the MBSSID element +* (%NL80211_ATTR_MBSSID_ELEMS) at the same index. Each EMA beacon +* will be generated by adding MBSSID and RNR elements at the same +* index. If the userspace includes more RNR elements than number of +* MBSSID elements then these will be added in every EMA beacon. +* * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3310,6 +3321,8 @@ enum nl80211_attrs {NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS ,NL80211_ATTR_HW_TIMESTAMP_ENABLED , +NL80211_ATTR_EMA_RNR_ELEMS , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
net/wireless/nl80211.c +72 -7
169 lines not on this page · raw message
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 396/634 mac80211: support RNR for EMA AP
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aloka Dixit <[email protected]>
[ Upstream commit 68b9bea267bfc1259e195dcac1bf69db0c0c28da ]
Generate EMA beacons, each including MBSSID and RNR elements at a given index. If number of stored RNR elements is more than the number of MBSSID elements then add those in every EMA beacon.
Stable-dep-of: a519be2f5d95 ("wifi: mac80211: do not use old MBSSID elements")
--- net/mac80211/cfg.c | 63 +++++++++++++++++++++++++++++++++++--- net/mac80211/ieee80211_i.h | 21 +++++++++++-- net/mac80211/tx.c | 10 ++++++ 3 files changed, 86 insertions(+), 8 deletions(-)
net/mac80211/cfg.c +58 -5
@@ -1087,6 +1087,23 @@ ieee80211_copy_mbssid_beacon(u8 *pos, struct cfg80211_mbssid_elems *dst,return offset; } +static int +ieee80211_copy_rnr_beacon (u8 *pos,struct cfg80211_rnr_elems *dst, +struct cfg80211_rnr_elems *src) +{ +int i, offset =0 ; + +for (i =0 ; i < src->cnt; i++) { +memcpy (pos + offset, src->elem[i].data, src->elem[i].len); + dst->elem[i].len = src->elem[i].len; + dst->elem[i].data = pos + offset; + offset += dst->elem[i].len; + } + dst->cnt = src->cnt; + +return offset; +} + static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, struct ieee80211_link_data *link, struct cfg80211_beacon_data *params,
@@ -1094,6 +1111,7 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, const struct ieee80211_color_change_settings *cca) {struct cfg80211_mbssid_elems *mbssid =NULL ; +struct cfg80211_rnr_elems *rnr =NULL ;struct beacon_data *new, *old;int new_head_len, new_tail_len;int size, err;
@@ -1125,11 +1143,21 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,if (params->mbssid_ies) { mbssid = params->mbssid_ies; size +=struct_size (new->mbssid_ies, elem, mbssid->cnt); - size +=ieee80211_get_mbssid_beacon_len (mbssid, mbssid->cnt); +if (params->rnr_ies) { + rnr = params->rnr_ies; + size +=struct_size (new->rnr_ies, elem, rnr->cnt); + } + size +=ieee80211_get_mbssid_beacon_len (mbssid, rnr, + mbssid->cnt); }else if (old && old->mbssid_ies) { mbssid = old->mbssid_ies; size +=struct_size (new->mbssid_ies, elem, mbssid->cnt); - size +=ieee80211_get_mbssid_beacon_len (mbssid, mbssid->cnt); +if (old && old->rnr_ies) { + rnr = old->rnr_ies; + size +=struct_size (new->rnr_ies, elem, rnr->cnt); + } + size +=ieee80211_get_mbssid_beacon_len (mbssid, rnr, + mbssid->cnt); } new =kzalloc (size,GFP_KERNEL );
@@ -1140,7 +1168,7 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,/* * pointers go into the block we allocated, -* memory is | beacon_data | head | tail | mbssid_ies +* memory is | beacon_data | head | tail | mbssid_ies | rnr_ies */ new->head = ((u8 *) new) +sizeof (*new); new->tail = new->head + new_head_len;
@@ -1152,7 +1180,13 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, new->mbssid_ies = (void *)pos; pos +=struct_size (new->mbssid_ies, elem, mbssid->cnt); -ieee80211_copy_mbssid_beacon (pos, new->mbssid_ies, mbssid); + pos +=ieee80211_copy_mbssid_beacon (pos, new->mbssid_ies, + mbssid); +if (rnr) { + new->rnr_ies = (void *)pos; + pos +=struct_size (new->rnr_ies, elem, rnr->cnt); +ieee80211_copy_rnr_beacon (pos, new->rnr_ies, rnr); + }/* update bssid_indicator */ link_conf->bssid_indicator =ilog2 (__roundup_pow_of_two (mbssid->cnt +1 ));
@@ -1448,6 +1482,7 @@ static void ieee80211_free_next_beacon(struct ieee80211_link_data *link)return ;kfree (link->u.ap.next_beacon->mbssid_ies); +kfree (link->u.ap.next_beacon->rnr_ies);kfree (link->u.ap.next_beacon); link->u.ap.next_beacon =NULL ; }
@@ -3360,6 +3395,7 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)if (beacon->mbssid_ies) len +=ieee80211_get_mbssid_beacon_len (beacon->mbssid_ies, + beacon->rnr_ies, beacon->mbssid_ies->cnt); new_beacon =kzalloc (sizeof (*new_beacon) + len,GFP_KERNEL );
@@ -3375,6 +3411,18 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)kfree (new_beacon);return NULL ; } + +if (beacon->rnr_ies && beacon->rnr_ies->cnt) { + new_beacon->rnr_ies = +kzalloc (struct_size (new_beacon->rnr_ies, + elem, beacon->rnr_ies->cnt), +GFP_KERNEL ); +if (!new_beacon->rnr_ies) { +kfree (new_beacon->mbssid_ies); +kfree (new_beacon); +return NULL ; + } + } } pos = (u8 *)(new_beacon +1 );
@@ -3414,10 +3462,15 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)memcpy (pos, beacon->probe_resp, beacon->probe_resp_len); pos += beacon->probe_resp_len; } -if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) +if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) { pos +=ieee80211_copy_mbssid_beacon (pos, new_beacon->mbssid_ies, beacon->mbssid_ies); +if (beacon->rnr_ies && beacon->rnr_ies->cnt) + pos +=ieee80211_copy_rnr_beacon (pos, + new_beacon->rnr_ies, + beacon->rnr_ies); + }/* might copy -1, meaning no changes requested */ new_beacon->ftm_responder = beacon->ftm_responder;
net/mac80211/ieee80211_i.h +18 -3
@@ -269,6 +269,7 @@ struct beacon_data {u16 cntdwn_counter_offsets[IEEE80211_MAX_CNTDWN_COUNTERS_NUM ];u8 cntdwn_current_counter;struct cfg80211_mbssid_elems *mbssid_ies; +struct cfg80211_rnr_elems *rnr_ies;struct rcu_head rcu_head; };
@@ -1165,20 +1166,34 @@ ieee80211_vif_get_shift(struct ieee80211_vif *vif) }static inline int -ieee80211_get_mbssid_beacon_len (struct cfg80211_mbssid_elems *elems,u8 i) +ieee80211_get_mbssid_beacon_len (struct cfg80211_mbssid_elems *elems, +struct cfg80211_rnr_elems *rnr_elems, +u8 i) {int len =0 ;if (!elems || !elems->cnt || i > elems->cnt)return 0 ; -if (i < elems->cnt) -return elems->elem[i].len; +if (i < elems->cnt) { + len = elems->elem[i].len; +if (rnr_elems) { + len += rnr_elems->elem[i].len; +for (i = elems->cnt; i < rnr_elems->cnt; i++) + len += rnr_elems->elem[i].len; + } +return len; + }/* i == elems->cnt, calculate total length of all MBSSID elements */ for (i =0 ; i < elems->cnt; i++) len += elems->elem[i].len; +if (rnr_elems) { +for (i =0 ; i < rnr_elems->cnt; i++) + len += rnr_elems->elem[i].len; + } +return len; }
net/mac80211/tx.c +10 -0
@@ -5149,6 +5149,15 @@ ieee80211_beacon_add_mbssid(struct sk_buff *skb, struct beacon_data *beacon,if (i < beacon->mbssid_ies->cnt) {skb_put_data (skb, beacon->mbssid_ies->elem[i].data, beacon->mbssid_ies->elem[i].len); + +if (beacon->rnr_ies && beacon->rnr_ies->cnt) { +skb_put_data (skb, beacon->rnr_ies->elem[i].data, + beacon->rnr_ies->elem[i].len); + +for (i = beacon->mbssid_ies->cnt; i < beacon->rnr_ies->cnt; i++) +skb_put_data (skb, beacon->rnr_ies->elem[i].data, + beacon->rnr_ies->elem[i].len); + }return ; }
@@ -5186,6 +5195,7 @@ ieee80211_beacon_get_ap(struct ieee80211_hw *hw,* tail length, maximum TIM length and multiple BSSID length */ mbssid_len =ieee80211_get_mbssid_beacon_len (beacon->mbssid_ies, + beacon->rnr_ies, ema_index); skb = dev_alloc_skb(local->tx_headroom + beacon->head_len +
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 397/634 wifi: mac80211: do not use old MBSSID elements
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aloka Dixit <[email protected]>
[ Upstream commit a519be2f5d958c5804f2cfd68f1f384291271fab ]
When userspace brings down and deletes a non-transmitted profile, it is expected to send a new updated Beacon template for the transmitted profile of that multiple BSSID (MBSSID) group which does not include the removed profile in MBSSID element. This update comes via NL80211_CMD_SET_BEACON.
Such updates work well as long as the group continues to have at least one non-transmitted profile as NL80211_ATTR_MBSSID_ELEMS is included in the new Beacon template.
But when the last non-trasmitted profile is removed, it still gets included in Beacon templates sent to driver. This happens because when no MBSSID elements are sent by the userspace, ieee80211_assign_beacon() ends up using the element stored from earlier Beacon template.
Do not copy old MBSSID elements, instead userspace should always include these when applicable.
--- net/mac80211/cfg.c | 10 ---------- 1 file changed, 10 deletions(-)
net/mac80211/cfg.c +0 -10
@@ -1139,7 +1139,6 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, size =sizeof (*new) + new_head_len + new_tail_len; -/* new or old multiple BSSID elements? */ if (params->mbssid_ies) { mbssid = params->mbssid_ies; size +=struct_size (new->mbssid_ies, elem, mbssid->cnt);
@@ -1149,15 +1148,6 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, } size +=ieee80211_get_mbssid_beacon_len (mbssid, rnr, mbssid->cnt); - }else if (old && old->mbssid_ies) { - mbssid = old->mbssid_ies; - size +=struct_size (new->mbssid_ies, elem, mbssid->cnt); -if (old && old->rnr_ies) { - rnr = old->rnr_ies; - size +=struct_size (new->rnr_ies, elem, rnr->cnt); - } - size +=ieee80211_get_mbssid_beacon_len (mbssid, rnr, - mbssid->cnt); } new =kzalloc (size,GFP_KERNEL );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 398/634 i40e: fix scheduling in set_rx_mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Przemyslaw Korba <[email protected]>
[ Upstream commit be43abc5514167cc129a8d8e9727b89b8e1d9719 ]
Add service task schedule to set_rx_mode.
In some cases there are error messages printed out in PTP application (ptp4l):
ptp4l[13848.762]: port 1 (ens2f3np3): received SYNC without timestamp ptp4l[13848.825]: port 1 (ens2f3np3): received SYNC without timestamp ptp4l[13848.887]: port 1 (ens2f3np3): received SYNC without timestamp
This happens when service task would not run immediately after set_rx_mode, and we need it for setup tasks. This service task checks, if PTP RX packets are hung in firmware, and propagate correct settings such as multicast address for IEEE 1588 Precision Time Protocol. RX timestamping depends on some of these filters set. Bug happens only with high PTP packets frequency incoming, and not every run since sometimes service task is being ran from a different place immediately after starting ptp4l.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -0
@@ -2252,6 +2252,7 @@ static void i40e_set_rx_mode(struct net_device *netdev) vsi->flags |=I40E_VSI_FLAG_FILTER_CHANGED ;set_bit (__I40E_MACVLAN_SYNC_PENDING, vsi->back->state); } +i40e_service_event_schedule (vsi->back); }/**
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 399/634 i40e: Refactor argument of several client notification functions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Vecera <[email protected]>
[ Upstream commit 54c4664e48eea52f2b296c73ddb8f5629b958678 ]
Commit 0ef2d5afb12d ("i40e: KISS the client interface") simplified the client interface so in practice it supports only one client per i40e netdev. But we have still 2 notification functions that uses as parameter a pointer to VSI of netdevice associated with the client. After the mentioned commit only possible and used VSI is the main (LAN) VSI.
So refactor these functions so they are called with PF pointer argument and the associated VSI (LAN) is taken inside them.
Stable-dep-of: 699428342153 ("i40e: validate ring_len parameter against hardware-specific values")
--- drivers/net/ethernet/intel/i40e/i40e.h | 4 ++-- drivers/net/ethernet/intel/i40e/i40e_client.c | 20 +++++++++---------- drivers/net/ethernet/intel/i40e/i40e_main.c | 12 +++++------ 3 files changed, 17 insertions(+), 19 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +2 -2
@@ -1217,8 +1217,8 @@ static inline void i40e_dbg_exit(void) {}int i40e_lan_add_device (struct i40e_pf *pf);int i40e_lan_del_device (struct i40e_pf *pf);void i40e_client_subtask (struct i40e_pf *pf); -void i40e_notify_client_of_l2_param_changes (struct i40e_vsi *vsi); -void i40e_notify_client_of_netdev_close (struct i40e_vsi *vsi,bool reset); +void i40e_notify_client_of_l2_param_changes (struct i40e_pf *pf); +void i40e_notify_client_of_netdev_close (struct i40e_pf *pf,bool reset);void i40e_notify_client_of_vf_enable (struct i40e_pf *pf,u32 num_vfs);void i40e_notify_client_of_vf_reset (struct i40e_pf *pf,u32 vf_id);void i40e_client_update_msix_info (struct i40e_pf *pf);
drivers/net/ethernet/intel/i40e/i40e_client.c +10 -10
@@ -102,25 +102,26 @@ i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id, u8 *msg, u16 len)/** * i40e_notify_client_of_l2_param_changes - call the client notify callback -* @vsi: the VSI with l2 param changes +* @pf: PF device pointer * -* If there is a client to this VSI, call the client +* If there is a client, call its callback **/ -void i40e_notify_client_of_l2_param_changes (struct i40e_vsi *vsi) +void i40e_notify_client_of_l2_param_changes (struct i40e_pf *pf) { -struct i40e_pf *pf = vsi->back;struct i40e_client_instance *cdev = pf->cinst; +struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];struct i40e_params params;if (!cdev || !cdev->client)return ;if (!cdev->client->ops || !cdev->client->ops->l2_param_change) { -dev_dbg (&vsi->back->pdev->dev, +dev_dbg (&pf->pdev->dev,"Cannot locate client instance l2_param_change routine\n" );return ; }if (!test_bit (__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) { -dev_dbg (&vsi->back->pdev->dev,"Client is not open, abort l2 param change\n" ); +dev_dbg (&pf->pdev->dev, +"Client is not open, abort l2 param change\n" );return ; }memset (¶ms,0 ,sizeof (params));
@@ -160,20 +161,19 @@ static void i40e_client_release_qvlist(struct i40e_info *ldev)/** * i40e_notify_client_of_netdev_close - call the client close callback -* @vsi: the VSI with netdev closed +* @pf: PF device pointer * @reset: true when close called due to a reset pending * * If there is a client to this netdev, call the client with close **/ -void i40e_notify_client_of_netdev_close (struct i40e_vsi *vsi,bool reset) +void i40e_notify_client_of_netdev_close (struct i40e_pf *pf,bool reset) { -struct i40e_pf *pf = vsi->back;struct i40e_client_instance *cdev = pf->cinst;if (!cdev || !cdev->client)return ;if (!cdev->client->ops || !cdev->client->ops->close) { -dev_dbg (&vsi->back->pdev->dev, +dev_dbg (&pf->pdev->dev,"Cannot locate client instance close routine\n" );return ; }
drivers/net/ethernet/intel/i40e/i40e_main.c +5 -7
@@ -11313,14 +11313,12 @@ static void i40e_service_task(struct work_struct *work)i40e_fdir_reinit_subtask (pf);if (test_and_clear_bit (__I40E_CLIENT_RESET, pf->state)) {/* Client subtask will reopen next time through. */ -i40e_notify_client_of_netdev_close (pf->vsi[pf->lan_vsi], - true); +i40e_notify_client_of_netdev_close (pf, true); }else {i40e_client_subtask (pf);if (test_and_clear_bit (__I40E_CLIENT_L2_CHANGE, pf->state)) -i40e_notify_client_of_l2_param_changes ( - pf->vsi[pf->lan_vsi]); +i40e_notify_client_of_l2_param_changes (pf); }i40e_sync_filters_subtask (pf); }else {
@@ -16307,7 +16305,7 @@ static void i40e_remove(struct pci_dev *pdev)/* Client close must be called explicitly here because the timer * has been stopped. */ -i40e_notify_client_of_netdev_close (pf->vsi[pf->lan_vsi], false); +i40e_notify_client_of_netdev_close (pf, false);i40e_fdir_teardown (pf);
@@ -16573,7 +16571,7 @@ static void i40e_shutdown(struct pci_dev *pdev)/* Client close must be called explicitly here because the timer * has been stopped. */ -i40e_notify_client_of_netdev_close (pf->vsi[pf->lan_vsi], false); +i40e_notify_client_of_netdev_close (pf, false);if (pf->wol_en && (pf->hw_features &I40E_HW_WOL_MC_MAGIC_PKT_WAKE ))i40e_enable_mc_magic_wake (pf);
@@ -16626,7 +16624,7 @@ static int __maybe_unused i40e_suspend(struct device *dev)/* Client close must be called explicitly here because the timer * has been stopped. */ -i40e_notify_client_of_netdev_close (pf->vsi[pf->lan_vsi], false); +i40e_notify_client_of_netdev_close (pf, false);if (pf->wol_en && (pf->hw_features &I40E_HW_WOL_MC_MAGIC_PKT_WAKE ))i40e_enable_mc_magic_wake (pf);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 400/634 i40e: Refactor argument of i40e_detect_recover_hung()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Vecera <[email protected]>
[ Upstream commit 7033ada04e33048c8b33294fecbb0d73f3cd1088 ]
Commit 07d44190a389 ("i40e/i40evf: Detect and recover hung queue scenario") changes i40e_detect_recover_hung() argument type from i40e_pf* to i40e_vsi* to be shareable by both i40e and i40evf. Because the i40evf does not exist anymore and the function is exclusively used by i40e we can revert this change.
Stable-dep-of: 699428342153 ("i40e: validate ring_len parameter against hardware-specific values")
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 10 ++++++---- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
@@ -11304,7 +11304,7 @@ static void i40e_service_task(struct work_struct *work)return ;if (!test_bit (__I40E_RECOVERY_MODE, pf->state)) { -i40e_detect_recover_hung (pf->vsi[pf->lan_vsi]); +i40e_detect_recover_hung (pf);i40e_sync_filters_subtask (pf);i40e_reset_subtask (pf);i40e_handle_mdd_event (pf);
drivers/net/ethernet/intel/i40e/i40e_txrx.c +6 -4
@@ -867,13 +867,15 @@ u32 i40e_get_tx_pending(struct i40e_ring *ring, bool in_sw)/** * i40e_detect_recover_hung - Function to detect and recover hung_queues -* @vsi: pointer to vsi struct with tx queues +* @pf: pointer to PF struct * -* VSI has netdev and netdev has TX queues. This function is to check each of -* those TX queues if they are hung, trigger recovery by issuing SW interrupt. +* LAN VSI has netdev and netdev has TX queues. This function is to check +* each of those TX queues if they are hung, trigger recovery by issuing +* SW interrupt. **/ -void i40e_detect_recover_hung (struct i40e_vsi *vsi) +void i40e_detect_recover_hung (struct i40e_pf *pf) { +struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];struct i40e_ring *tx_ring =NULL ;struct net_device *netdev;unsigned int i;
drivers/net/ethernet/intel/i40e/i40e_txrx.h +1 -1
@@ -465,7 +465,7 @@ void i40e_free_rx_resources(struct i40e_ring *rx_ring);int i40e_napi_poll (struct napi_struct *napi,int budget);void i40e_force_wb (struct i40e_vsi *vsi,struct i40e_q_vector *q_vector);u32 i40e_get_tx_pending (struct i40e_ring *ring,bool in_sw); -void i40e_detect_recover_hung (struct i40e_vsi *vsi); +void i40e_detect_recover_hung (struct i40e_pf *pf);int __i40e_maybe_stop_tx (struct i40e_ring *tx_ring,int size);bool __i40e_chk_linearize (struct sk_buff *skb); int i40e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 401/634 i40e: validate ring_len parameter against hardware-specific values
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory Herrero <[email protected]>
[ Upstream commit 69942834215323cd9131db557091b4dec43f19c5 ]
The maximum number of descriptors supported by the hardware is hardware-dependent and can be retrieved using i40e_get_max_num_descriptors(). Move this function to a shared header and use it when checking for valid ring_len parameter rather than using hardcoded value.
By fixing an over-acceptance issue, behavior change could be seen where ring_len could now be rejected while configuring rx and tx queues if its size is larger than the hardware-dependent maximum number of descriptors.
--- drivers/net/ethernet/intel/i40e/i40e.h | 11 +++++++++++ drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ------------ drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +11 -0
@@ -1325,4 +1325,15 @@ static inline u32 i40e_is_tc_mqprio_enabled(struct i40e_pf *pf) return pf->flags & I40E_FLAG_TC_MQPRIO; } +static inline u32 i40e_get_max_num_descriptors (const struct i40e_pf *pf) +{ +const struct i40e_hw *hw = &pf->hw; + +switch (hw->mac.type) { +case I40E_MAC_XL710 : +return I40E_MAX_NUM_DESCRIPTORS_XL710 ; +default : +return I40E_MAX_NUM_DESCRIPTORS ; + } +}#endif /* _I40E_H_ */
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +0 -12
@@ -2012,18 +2012,6 @@ static void i40e_get_drvinfo(struct net_device *netdev, drvinfo->n_priv_flags +=I40E_GL_PRIV_FLAGS_STR_LEN ; } -static u32 i40e_get_max_num_descriptors (struct i40e_pf *pf) -{ -struct i40e_hw *hw = &pf->hw; - -switch (hw->mac.type) { -case I40E_MAC_XL710 : -return I40E_MAX_NUM_DESCRIPTORS_XL710 ; -default : -return I40E_MAX_NUM_DESCRIPTORS ; - } -} - static void i40e_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring, struct kernel_ethtool_ringparam *kernel_ring,
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +2 -2
@@ -656,7 +656,7 @@ static int i40e_config_vsi_tx_queue(struct i40e_vf *vf, u16 vsi_id,/* ring_len has to be multiple of 8 */ if (!IS_ALIGNED (info->ring_len,8 ) || - info->ring_len >I40E_MAX_NUM_DESCRIPTORS_XL710 ) { + info->ring_len >i40e_get_max_num_descriptors (pf)) { ret = -EINVAL ; goto error_context; }
@@ -728,7 +728,7 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_id,/* ring_len has to be multiple of 32 */ if (!IS_ALIGNED (info->ring_len,32 ) || - info->ring_len >I40E_MAX_NUM_DESCRIPTORS_XL710 ) { + info->ring_len >i40e_get_max_num_descriptors (pf)) { ret = -EINVAL ; goto error_param; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 402/634 iavf: fix off-by-one issues in iavf_config_rss_reg()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kohei Enju <[email protected]>
[ Upstream commit 6daa2893f323981c7894c68440823326e93a7d61 ]
There are off-by-one bugs when configuring RSS hash key and lookup table, causing out-of-bounds reads to memory [1] and out-of-bounds writes to device registers.
Before commit 43a3d9ba34c9 ("i40evf: Allow PF driver to configure RSS"), the loop upper bounds were:
i <= I40E_VFQF_{HKEY,HLUT}_MAX_INDEXwhich is safe since the value is the last valid index.
That commit changed the bounds to:
i <= adapter->rss_{key,lut}_size / 4where rss_{key,lut}_size / 4 is the number of dwords, so the last valid index is (rss_{key,lut}_size / 4) - 1. Therefore, using <= accesses one element past the end.
Fix the issues by using < instead of <=, ensuring we do not exceed the bounds.
[1] KASAN splat about rss_key_size off-by-one
BUG: KASAN: slab-out-of-bounds in iavf_config_rss+0x619/0x800
Read of size 4 at addr ffff888102c50134 by task kworker/u8:6/63
CPU: 0 UID: 0 PID: 63 Comm: kworker/u8:6 Not tainted 6.18.0-rc2-enjuk-tnguy-00378-g3005f5b77652-dirty #156 PREEMPT(voluntary)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: iavf iavf_watchdog_task
Call Trace:
<TASK>
dump_stack_lvl+0x6f/0xb0
print_report+0x170/0x4f3
kasan_report+0xe1/0x1a0
iavf_config_rss+0x619/0x800
iavf_watchdog_task+0x2be7/0x3230
process_one_work+0x7fd/0x1420
worker_thread+0x4d1/0xd40
kthread+0x344/0x660
ret_from_fork+0x249/0x320
ret_from_fork_asm+0x1a/0x30
</TASK>
Allocated by task 63:
kasan_save_stack+0x30/0x50
kasan_save_track+0x14/0x30
__kasan_kmalloc+0x7f/0x90
__kmalloc_noprof+0x246/0x6f0
iavf_watchdog_task+0x28fc/0x3230
process_one_work+0x7fd/0x1420
worker_thread+0x4d1/0xd40
kthread+0x344/0x660
ret_from_fork+0x249/0x320
ret_from_fork_asm+0x1a/0x30
The buggy address belongs to the object at ffff888102c50100
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes to the right of
allocated 52-byte region [ffff888102c50100, ffff888102c50134)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x102c50
flags: 0x200000000000000(node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000000 ffff8881000418c0 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080200020 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888102c50000: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
ffff888102c50080: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
>ffff888102c50100: 00 00 00 00 00 00 04 fc fc fc fc fc fc fc fc fc
^
ffff888102c50180: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff888102c50200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc--- drivers/net/ethernet/intel/iavf/iavf_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +2 -2
@@ -1783,11 +1783,11 @@ static int iavf_config_rss_reg(struct iavf_adapter *adapter)u16 i; dw = (u32 *)adapter->rss_key; -for (i =0 ; i <= adapter->rss_key_size /4 ; i++) +for (i =0 ; i < adapter->rss_key_size /4 ; i++)wr32 (hw,IAVF_VFQF_HKEY (i), dw[i]); dw = (u32 *)adapter->rss_lut; -for (i =0 ; i <= adapter->rss_lut_size /4 ; i++) +for (i =0 ; i < adapter->rss_lut_size /4 ; i++)wr32 (hw,IAVF_VFQF_HLUT (i), dw[i]);iavf_flush (hw);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 403/634 crypto: seqiv - Do not use req->iv after crypto_aead_encrypt
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 50fdb78b7c0bcc550910ef69c0984e751cac72fa ]
As soon as crypto_aead_encrypt is called, the underlying request may be freed by an asynchronous completion. Thus dereferencing req->iv after it returns is invalid.
Instead of checking req->iv against info, create a new variable unaligned_info and use it for that purpose instead.
--- crypto/seqiv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
crypto/seqiv.c +5 -3
@@ -51,6 +51,7 @@ static int seqiv_aead_encrypt(struct aead_request *req)struct aead_geniv_ctx *ctx =crypto_aead_ctx (geniv);struct aead_request *subreq =aead_request_ctx (req);crypto_completion_t compl; +bool unaligned_info;void *data;u8 *info;unsigned int ivsize =8 ;
@@ -80,8 +81,9 @@ static int seqiv_aead_encrypt(struct aead_request *req)return err; } -if (unlikely (!IS_ALIGNED ((unsigned long )info, -crypto_aead_alignmask (geniv) +1 ))) { + unaligned_info = !IS_ALIGNED ((unsigned long )info, +crypto_aead_alignmask (geniv) +1 ); +if (unlikely (unaligned_info)) { info =kmemdup (req->iv, ivsize, req->base.flags &CRYPTO_TFM_REQ_MAY_SLEEP ?GFP_KERNEL :GFP_ATOMIC );
@@ -101,7 +103,7 @@ static int seqiv_aead_encrypt(struct aead_request *req)scatterwalk_map_and_copy (info, req->dst, req->assoclen, ivsize,1 ); err =crypto_aead_encrypt (subreq); -if (unlikely (info != req->iv)) +if (unlikely (unaligned_info))seqiv_aead_encrypt_complete2 (req, err);return err; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 404/634 Bluetooth: btusb: revert use of devm_kzalloc in btusb
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Pinsonneault-Thibeault <[email protected]>
[ Upstream commit 252714f1e8bdd542025b16321c790458014d6880 ]
This reverts commit 98921dbd00c4e ("Bluetooth: Use devm_kzalloc in btusb.c file").
In btusb_probe(), we use devm_kzalloc() to allocate the btusb data. This ties the lifetime of all the btusb data to the binding of a driver to one interface, INTF. In a driver that binds to other interfaces, ISOC and DIAG, this is an accident waiting to happen.
The issue is revealed in btusb_disconnect(), where calling usb_driver_release_interface(&btusb_driver, data->intf) will have devm free the data that is also being used by the other interfaces of the driver that may not be released yet.
To fix this, revert the use of devm and go back to freeing memory explicitly.
--- drivers/bluetooth/btusb.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/bluetooth/btusb.c +9 -3
@@ -3849,7 +3849,7 @@ static int btusb_probe(struct usb_interface *intf,return -ENODEV ; } - data =devm_kzalloc (&intf->dev,sizeof (*data),GFP_KERNEL ); + data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data)return -ENOMEM ;
@@ -3872,8 +3872,10 @@ static int btusb_probe(struct usb_interface *intf, } } -if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) +if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) { +kfree (data);return -ENODEV ; + }if (id->driver_info &BTUSB_AMP ) { data->cmdreq_type =USB_TYPE_CLASS |0x01 ;
@@ -3920,8 +3922,10 @@ static int btusb_probe(struct usb_interface *intf, data->recv_acl = hci_recv_frame; hdev =hci_alloc_dev_priv (priv_size); -if (!hdev) +if (!hdev) { +kfree (data);return -ENOMEM ; + } hdev->bus =HCI_USB ;hci_set_drvdata (hdev, data);
@@ -4182,6 +4186,7 @@ static int btusb_probe(struct usb_interface *intf,if (data->reset_gpio)gpiod_put (data->reset_gpio);hci_free_dev (hdev); +kfree (data);return err; }
@@ -4227,6 +4232,7 @@ static void btusb_disconnect(struct usb_interface *intf) }hci_free_dev (hdev); +kfree (data); }#ifdef CONFIG_PM
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 405/634 net: mdio: aspeed: add dummy read to avoid read-after-write issue
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacky Chou <[email protected]>
[ Upstream commit d1a1a4bade4b20c0858d0b2f81d2611de055f675 ]
The Aspeed MDIO controller may return incorrect data when a read operation follows immediately after a write. Due to a controller bug, the subsequent read can latch stale data, causing the polling logic to terminate earlier than expected.
To work around this hardware issue, insert a dummy read after each write operation. This ensures that the next actual read returns the correct data and prevents premature polling exit.
This workaround has been verified to stabilize MDIO transactions on affected Aspeed platforms.
--- drivers/net/mdio/mdio-aspeed.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/mdio/mdio-aspeed.c +7 -0
@@ -63,6 +63,13 @@ static int aspeed_mdio_op(struct mii_bus *bus, u8 st, u8 op, u8 phyad, u8 regad,iowrite32 (ctrl, ctx->base +ASPEED_MDIO_CTRL ); +/* Workaround for read-after-write issue. +* The controller may return stale data if a read follows immediately +* after a write. A dummy read forces the hardware to update its +* internal state, ensuring that the next real read returns correct data. +*/ +ioread32 (ctx->base +ASPEED_MDIO_CTRL ); + return readl_poll_timeout(ctx->base + ASPEED_MDIO_CTRL, ctrl, !(ctrl & ASPEED_MDIO_CTRL_FIRE), ASPEED_MDIO_INTERVAL_US,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 406/634 net: openvswitch: Avoid needlessly taking the RTNL on vport destroy
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit 5498227676303e3ffa9a3a46214af96bc3e81314 ]
The openvswitch teardown code will immediately call ovs_netdev_detach_dev() in response to a NETDEV_UNREGISTER notification. It will then start the dp_notify_work workqueue, which will later end up calling the vport destroy() callback. This callback takes the RTNL to do another ovs_netdev_detach_port(), which in this case is unnecessary. This causes extra pressure on the RTNL, in some cases leading to "unregister_netdevice: waiting for XX to become free" warnings on teardown.
We can straight-forwardly avoid the extra RTNL lock acquisition by checking the device flags before taking the lock, and skip the locking altogether if the IFF_OVS_DATAPATH flag has already been unset.
--- net/openvswitch/vport-netdev.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
net/openvswitch/vport-netdev.c +13 -4
@@ -153,10 +153,19 @@ void ovs_netdev_detach_dev(struct vport *vport)static void netdev_destroy (struct vport *vport) { -rtnl_lock (); -if (netif_is_ovs_port (vport->dev)) -ovs_netdev_detach_dev (vport); -rtnl_unlock (); +/* When called from ovs_db_notify_wq() after a dp_device_event(), the +* port has already been detached, so we can avoid taking the RTNL by +* checking this first. +*/ +if (netif_is_ovs_port (vport->dev)) { +rtnl_lock (); +/* Check again while holding the lock to ensure we don't race +* with the netdev notifier and detach twice. +*/ +if (netif_is_ovs_port (vport->dev)) +ovs_netdev_detach_dev (vport); +rtnl_unlock (); + }call_rcu (&vport->rcu, vport_netdev_free); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 407/634 ip6_gre: make ip6gre_header() robust
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit db5b4e39c4e63700c68a7e65fc4e1f1375273476 ]
Over the years, syzbot found many ways to crash the kernel in ip6gre_header() [1].
This involves team or bonding drivers ability to dynamically change their dev->needed_headroom and/or dev->hard_header_len
In this particular crash mld_newpack() allocated an skb with a too small reserve/headroom, and by the time mld_sendpack() was called, syzbot managed to attach an ip6gre device.
[1]
skbuff: skb_under_panic: text:ffffffff8a1d69a8 len:136 put:40 head:ffff888059bc7000 data:ffff888059bc6fe8 tail:0x70 end:0x6c0 dev:team0
------------[ cut here ]------------ kernel BUG at net/core/skbuff.c:213 ! <TASK> skb_under_panic net/core/skbuff.c:223 [inline] skb_push+0xc3/0xe0 net/core/skbuff.c:2641 ip6gre_header+0xc8/0x790 net/ipv6/ip6_gre.c:1371 dev_hard_header include/linux/netdevice.h:3436 [inline] neigh_connected_output+0x286/0x460 net/core/neighbour.c:1618 neigh_output include/net/neighbour.h:556 [inline] ip6_finish_output2+0xfb3/0x1480 net/ipv6/ip6_output.c:136 __ip6_finish_output net/ipv6/ip6_output.c:-1 [inline] ip6_finish_output+0x234/0x7d0 net/ipv6/ip6_output.c:220 NF_HOOK_COND include/linux/netfilter.h:307 [inline] ip6_output+0x340/0x550 net/ipv6/ip6_output.c:247 NF_HOOK+0x9e/0x380 include/linux/netfilter.h:318 mld_sendpack+0x8d4/0xe60 net/ipv6/mcast.c:1855 mld_send_cr net/ipv6/mcast.c:2154 [inline] mld_ifc_work+0x83e/0xd60 net/ipv6/mcast.c:2693
--- net/ipv6/ip6_gre.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
net/ipv6/ip6_gre.c +8 -1
@@ -1405,9 +1405,16 @@ static int ip6gre_header(struct sk_buff *skb, struct net_device *dev, {struct ip6_tnl *t =netdev_priv (dev);struct ipv6hdr *ipv6h; +int needed;__be16 *p; - ipv6h =skb_push (skb, t->hlen +sizeof (*ipv6h)); + needed = t->hlen +sizeof (*ipv6h); +if (skb_headroom (skb) < needed && +pskb_expand_head (skb,HH_DATA_ALIGN (needed -skb_headroom (skb)), +0 ,GFP_ATOMIC )) +return -needed; + + ipv6h =skb_push (skb, needed);ip6_flow_hdr (ipv6h,0 ,ip6_make_flowlabel (dev_net (dev), skb, t->fl.u.ip6.flowlabel, true, &t->fl.u.ip6));
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 408/634 platform/x86: msi-laptop: add missing sysfs_remove_group()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 1461209cf813b6ee6d40f29b96b544587df6d2b1 ]
A sysfs group is created in msi_init() when old_ec_model is enabled, but never removed. Remove the msipf_old_attribute_group in that case.
--- drivers/platform/x86/msi-laptop.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/platform/x86/msi-laptop.c +3 -0
@@ -1130,6 +1130,9 @@ static void __exit msi_cleanup(void)sysfs_remove_group (&msipf_device->dev.kobj, &msipf_attribute_group);if (!quirks->old_ec_model && threeg_exists)device_remove_file (&msipf_device->dev, &dev_attr_threeg); +if (quirks->old_ec_model) +sysfs_remove_group (&msipf_device->dev.kobj, + &msipf_old_attribute_group);platform_device_unregister (msipf_device);platform_driver_unregister (&msipf_driver);backlight_device_unregister (msibl_device);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 409/634 platform/x86: ibm_rtl: fix EBDA signature search pointer arithmetic
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit 15dd100349b8526cbdf2de0ce3e72e700eb6c208 ]
The ibm_rtl_init() function searches for the signature but has a pointer arithmetic error. The loop counter suggests searching at 4-byte intervals but the implementation only advances by 1 byte per iteration.
Fix by properly advancing the pointer by sizeof(unsigned int) bytes each iteration.
--- drivers/platform/x86/ibm_rtl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/ibm_rtl.c +1 -1
@@ -262,7 +262,7 @@ static int __init ibm_rtl_init(void) {/* search for the _RTL_ signature at the start of the table */ for (i =0 ; i < ebda_size/sizeof (unsigned int ); i++) {struct ibm_rtl_table __iomem * tmp; - tmp = (struct ibm_rtl_table __iomem *) (ebda_map+i); + tmp = (struct ibm_rtl_table __iomem *) (ebda_map + i*sizeof (unsigned int ));if ((readq (&tmp->signature) &RTL_MASK ) ==RTL_SIGNATURE ) {phys_addr_t addr;unsigned int plen;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 410/634 team: fix check for port enabled in team_queue_override_port_prio_changed()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Pirko <[email protected]>
[ Upstream commit 932ac51d9953eaf77a1252f79b656d4ca86163c6 ]
There has been a syzkaller bug reported recently with the following trace:
list_del corruption, ffff888058bea080->prev is LIST_POISON2 (dead000000000122)
------------[ cut here ]------------ kernel BUG at lib/list_debug.c:59! Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI CPU: 3 UID: 0 PID: 21246 Comm: syz.0.2928 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 RIP: 0010:__list_del_entry_valid_or_report+0x13e/0x200 lib/list_debug.c:59 Code: 48 c7 c7 e0 71 f0 8b e8 30 08 ef fc 90 0f 0b 48 89 ef e8 a5 02 55 fd 48 89 ea 48 89 de 48 c7 c7 40 72 f0 8b e8 13 08 ef fc 90 <0f> 0b 48 89 ef e8 88 02 55 fd 48 89 ea 48 b8 00 00 00 00 00 fc ff RSP: 0018:ffffc9000d49f370 EFLAGS: 00010286 RAX: 000000000000004e RBX: ffff888058bea080 RCX: ffffc9002817d000 RDX: 0000000000000000 RSI: ffffffff819becc6 RDI: 0000000000000005 RBP: dead000000000122 R08: 0000000000000005 R09: 0000000000000000 R10: 0000000080000000 R11: 0000000000000001 R12: ffff888039e9c230 R13: ffff888058bea088 R14: ffff888058bea080 R15: ffff888055461480 FS: 00007fbbcfe6f6c0(0000) GS:ffff8880d6d0a000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000110c3afcb0 CR3: 00000000382c7000 CR4: 0000000000352ef0 Call Trace: <TASK> __list_del_entry_valid include/linux/list.h:132 [inline] __list_del_entry include/linux/list.h:223 [inline] list_del_rcu include/linux/rculist.h:178 [inline] __team_queue_override_port_del drivers/net/team/team_core.c:826 [inline] __team_queue_override_port_del drivers/net/team/team_core.c:821 [inline] team_queue_override_port_prio_changed drivers/net/team/team_core.c:883 [inline] team_priority_option_set+0x171/0x2f0 drivers/net/team/team_core.c:1534 team_option_set drivers/net/team/team_core.c:376 [inline] team_nl_options_set_doit+0x8ae/0xe60 drivers/net/team/team_core.c:2653 genl_family_rcv_msg_doit+0x209/0x2f0 net/netlink/genetlink.c:1115 genl_family_rcv_msg net/netlink/genetlink.c:1195 [inline] genl_rcv_msg+0x55c/0x800 net/netlink/genetlink.c:1210 netlink_rcv_skb+0x158/0x420 net/netlink/af_netlink.c:2552 genl_rcv+0x28/0x40 net/netlink/genetlink.c:1219 netlink_unicast_kernel net/netlink/af_netlink.c:1320 [inline] netlink_unicast+0x5aa/0x870 net/netlink/af_netlink.c:1346 netlink_sendmsg+0x8c8/0xdd0 net/netlink/af_netlink.c:1896 sock_sendmsg_nosec net/socket.c:727 [inline] __sock_sendmsg net/socket.c:742 [inline] ____sys_sendmsg+0xa98/0xc70 net/socket.c:2630 ___sys_sendmsg+0x134/0x1d0 net/socket.c:2684 __sys_sendmsg+0x16d/0x220 net/socket.c:2716 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xcd/0xfa0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
The problem is in this flow:
1) Port is enabled, queue_id != 0, in qom_list
2) Port gets disabled
-> team_port_disable()
-> team_queue_override_port_del()
-> del (removed from list)
3) Port is disabled, queue_id != 0, not in any list
4) Priority changes
-> team_queue_override_port_prio_changed()
-> checks: port disabled && queue_id != 0
-> calls del - hits the BUG as it is removed alreadyTo fix this, change the check in team_queue_override_port_prio_changed() so it returns early if port is not enabled.
--- drivers/net/team/team.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/team/team.c +1 -1
@@ -878,7 +878,7 @@ static void __team_queue_override_enabled_check(struct team *team)static void team_queue_override_port_prio_changed (struct team *team,struct team_port *port) { -if (!port->queue_id ||team_port_enabled (port)) +if (!port->queue_id || !team_port_enabled (port))return ;__team_queue_override_port_del (team, port);__team_queue_override_port_add (team, port);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 411/634 net: usb: rtl8150: fix memory leak on usb_submit_urb() failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepakkumar Karn <[email protected]>
[ Upstream commit 12cab1191d9890097171156d06bfa8d31f1e39c8 ]
In async_set_registers(), when usb_submit_urb() fails, the allocated
async_req structure and URB are not freed, causing a memory leak.
The completion callback async_set_reg_cb() is responsible for freeing these allocations, but it is only called after the URB is successfully submitted and completes (successfully or with error). If submission fails, the callback never runs and the memory is leaked.
Fix this by freeing both the URB and the request structure in the error path when usb_submit_urb() fails.
--- drivers/net/usb/rtl8150.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/usb/rtl8150.c +2 -0
@@ -211,6 +211,8 @@ static int async_set_registers(rtl8150_t *dev, u16 indx, u16 size, u16 reg)if (res == -ENODEV )netif_device_detach (dev->netdev);dev_err (&dev->udev->dev,"%s failed with %d\n" , __func__, res); +kfree (req); +usb_free_urb (async_urb); }return res; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 412/634 selftests: net: fix "buffer overflow detected" for tap.c
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alice C. Munduruca <[email protected]>
[ Upstream commit 472c5dd6b95c02b3e5d7395acf542150e91165e7 ]
When the selftest 'tap.c' is compiled with '-D_FORTIFY_SOURCE=3', the strcpy() in rtattr_add_strsz() is replaced with a checked version which causes the test to consistently fail when compiled with toolchains for which this option is enabled by default.
TAP version 13
1..3
# Starting 3 tests from 1 test cases.
# RUN tap.test_packet_valid_udp_gso ...
*** buffer overflow detected ***: terminated
# test_packet_valid_udp_gso: Test terminated by assertion
# FAIL tap.test_packet_valid_udp_gso
not ok 1 tap.test_packet_valid_udp_gso
# RUN tap.test_packet_valid_udp_csum ...
*** buffer overflow detected ***: terminated
# test_packet_valid_udp_csum: Test terminated by assertion
# FAIL tap.test_packet_valid_udp_csum
not ok 2 tap.test_packet_valid_udp_csum
# RUN tap.test_packet_crash_tap_invalid_eth_proto ...
*** buffer overflow detected ***: terminated
# test_packet_crash_tap_invalid_eth_proto: Test terminated by assertion
# FAIL tap.test_packet_crash_tap_invalid_eth_proto
not ok 3 tap.test_packet_crash_tap_invalid_eth_proto
# FAILED: 0 / 3 tests passed.
# Totals: pass:0 fail:3 xfail:0 xpass:0 skip:0 error:0
A buffer overflow is detected by the fortified glibc __strcpy_chk() since the __builtin_object_size() of RTA_DATA(rta) is incorrectly reported as 1, even though there is ample space in its bounding buffer req.
Additionally, given that IFLA_IFNAME also expects a null-terminated string, callers of rtaddr_add_str{,sz}() could simply use the rtaddr_add_strsz() variant. (which has been renamed to remove the trailing sz) memset() has been used for this function since it is unchecked and thus circumvents the issue discussed in the previous paragraph.
--- tools/testing/selftests/net/tap.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
tools/testing/selftests/net/tap.c +5 -11
@@ -56,18 +56,12 @@ static void rtattr_end(struct nlmsghdr *nh, struct rtattr *attr)static struct rtattr *rtattr_add_str (struct nlmsghdr *nh,unsigned short type,const char *s) { -struct rtattr *rta =rtattr_add (nh, type,strlen (s)); +unsigned int strsz =strlen (s) +1 ; +struct rtattr *rta; -memcpy (RTA_DATA (rta), s,strlen (s)); -return rta; -} - -static struct rtattr *rtattr_add_strsz (struct nlmsghdr *nh,unsigned short type, -const char *s) -{ -struct rtattr *rta =rtattr_add (nh, type,strlen (s) +1 ); + rta =rtattr_add (nh, type, strsz); -strcpy (RTA_DATA (rta), s); +memcpy (RTA_DATA (rta), s, strsz);return rta; }
@@ -119,7 +113,7 @@ static int dev_create(const char *dev, const char *link_type, link_info =rtattr_begin (&req.nh,IFLA_LINKINFO ); -rtattr_add_strsz (&req.nh,IFLA_INFO_KIND , link_type); +rtattr_add_str (&req.nh,IFLA_INFO_KIND , link_type);if (fill_info_data) { info_data =rtattr_begin (&req.nh,IFLA_INFO_DATA );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 413/634 smc91x: fix broken irq-context in PREEMPT_RT
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yeoreum Yun <[email protected]>
[ Upstream commit 6402078bd9d1ed46e79465e1faaa42e3458f8a33 ]
When smc91x.c is built with PREEMPT_RT, the following splat occurs in FVP_RevC:
[ 13.055000] smc91x LNRO0003:00 eth0: link up, 10Mbps, half-duplex, lpa 0x0000
[ 13.062137] BUG: workqueue leaked atomic, lock or RCU: kworker/2:1[106]
[ 13.062137] preempt=0x00000000 lock=0->0 RCU=0->1 workfn=mld_ifc_work
[ 13.062266] C
** replaying previous printk message **
[ 13.062266] CPU: 2 UID: 0 PID: 106 Comm: kworker/2:1 Not tainted 6.18.0-dirty #179 PREEMPT_{RT,(full)}
[ 13.062353] Hardware name: , BIOS
[ 13.062382] Workqueue: mld mld_ifc_work
[ 13.062469] Call trace:
[ 13.062494] show_stack+0x24/0x40 (C)
[ 13.062602] __dump_stack+0x28/0x48
[ 13.062710] dump_stack_lvl+0x7c/0xb0
[ 13.062818] dump_stack+0x18/0x34
[ 13.062926] process_scheduled_works+0x294/0x450
[ 13.063043] worker_thread+0x260/0x3d8
[ 13.063124] kthread+0x1c4/0x228
[ 13.063235] ret_from_fork+0x10/0x20This happens because smc_special_trylock() disables IRQs even on PREEMPT_RT,
but smc_special_unlock() does not restore IRQs on PREEMPT_RT.
The reason is that smc_special_unlock() calls spin_unlock_irqrestore(),
and rcu_read_unlock_bh() in __dev_queue_xmit() cannot invokercu_read_unlock() through __local_bh_enable_ip() when current->softirq_disable_cnt becomes zero.
To address this issue, replace smc_special_trylock() with spin_trylock_irqsave().
--- drivers/net/ethernet/smsc/smc91x.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/net/ethernet/smsc/smc91x.c +1 -9
@@ -515,15 +515,7 @@ static inline void smc_rcv(struct net_device *dev)* any other concurrent access and C would always interrupt B. But life * isn't that easy in a SMP world... */ -#define smc_special_trylock (lock, flags) \ -({ \ - int __ret; \ - local_irq_save(flags); \ - __ret = spin_trylock(lock); \ - if (!__ret) \ - local_irq_restore(flags); \ - __ret; \ -}) +#define smc_special_trylock (lock, flags) spin_trylock_irqsave(lock, flags)#define smc_special_lock (lock, flags) spin_lock_irqsave(lock, flags)#define smc_special_unlock (lock, flags) spin_unlock_irqrestore(lock, flags)#else
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 414/634 genalloc.h: fix htmldocs warning
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Morton <[email protected]>
[ Upstream commit 5393802c94e0ab1295c04c94c57bcb00222d4674 ]
WARNING: include/linux/genalloc.h:52 function parameter 'start_addr' not described in 'genpool_algo_t'
--- include/linux/genalloc.h | 1 + 1 file changed, 1 insertion(+)
include/linux/genalloc.h +1 -0
@@ -44,6 +44,7 @@ struct gen_pool;* @nr: The number of zeroed bits we're looking for * @data: optional additional data used by the callback * @pool: the pool being allocated from +* @start_addr: start address of memory chunk */ typedef unsigned long (*genpool_algo_t)(unsigned long *map, unsigned long size,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 415/634 firewire: nosy: Fix dma_free_coherent() size
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit c48c0fd0e19684b6ecdb4108a429e3a4e73f5e21 ]
It looks like the buffer allocated and mapped in add_card() is done with size RCV_BUFFER_SIZE which is 16 KB and 4KB.
--- drivers/firewire/nosy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/firewire/nosy.c +5 -5
@@ -36,6 +36,8 @@static char driver_name[] =KBUILD_MODNAME ; +#define RCV_BUFFER_SIZE (16 * 1024) +/* this is the physical layout of a PCL, its size is 128 bytes */ struct pcl {__le32 next;
@@ -517,16 +519,14 @@ remove_card(struct pci_dev *dev) lynx->rcv_start_pcl, lynx->rcv_start_pcl_bus);dma_free_coherent (&lynx->pci_device->dev,sizeof (struct pcl ), lynx->rcv_pcl, lynx->rcv_pcl_bus); -dma_free_coherent (&lynx->pci_device->dev,PAGE_SIZE , lynx->rcv_buffer, - lynx->rcv_buffer_bus); +dma_free_coherent (&lynx->pci_device->dev,RCV_BUFFER_SIZE , + lynx->rcv_buffer, lynx->rcv_buffer_bus);iounmap (lynx->registers);pci_disable_device (dev);lynx_put (lynx); } -#define RCV_BUFFER_SIZE (16 * 1024) -static int add_card (struct pci_dev *dev,const struct pci_device_id *unused) {
@@ -680,7 +680,7 @@ add_card(struct pci_dev *dev, const struct pci_device_id *unused)dma_free_coherent (&lynx->pci_device->dev,sizeof (struct pcl ), lynx->rcv_pcl, lynx->rcv_pcl_bus);if (lynx->rcv_buffer) -dma_free_coherent (&lynx->pci_device->dev,PAGE_SIZE , +dma_free_coherent (&lynx->pci_device->dev,RCV_BUFFER_SIZE , lynx->rcv_buffer, lynx->rcv_buffer_bus);iounmap (lynx->registers);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 416/634 net: dsa: b53: skip multicast entries for fdb_dump()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonas Gorski <[email protected]>
[ Upstream commit d42bce414d1c5c0b536758466a1f63ac358e613c ]
port_fdb_dump() is supposed to only add fdb entries, but we iterate over the full ARL table, which also includes multicast entries.
So check if the entry is a multicast entry before passing it on to the callback().
Additionally, the port of those entries is a bitmask, not a port number, so any included entries would have even be for the wrong port.
--- drivers/net/dsa/b53/b53_common.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/dsa/b53/b53_common.c +3 -0
@@ -1815,6 +1815,9 @@ static int b53_fdb_copy(int port, const struct b53_arl_entry *ent,if (!ent->is_valid)return 0 ; +if (is_multicast_ether_addr (ent->mac)) +return 0 ; +if (port != ent->port)return 0 ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 417/634 net: usb: asix: validate PHY address before use
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepanshu Kartikey <[email protected]>
[ Upstream commit a1e077a3f76eea0dc671ed6792e7d543946227e8 ]
The ASIX driver reads the PHY address from the USB device via asix_read_phy_addr(). A malicious or faulty device can return an invalid address (>= PHY_MAX_ADDR), which causes a warning in mdiobus_get_phy():
addr 207 out of range
WARNING: drivers/net/phy/mdio_bus.c:76
Validate the PHY address in asix_read_phy_addr() and remove the now-redundant check in ax88172a.c.
--- drivers/net/usb/asix_common.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/usb/asix_common.c +5 -0
@@ -335,6 +335,11 @@ int asix_read_phy_addr(struct usbnet *dev, bool internal) offset = (internal ?1 :0 ); ret = buf[offset]; +if (ret >=PHY_MAX_ADDR ) { +netdev_err (dev->net,"invalid PHY address: %d\n" , ret); +return -ENODEV ; + } +netdev_dbg (dev->net,"%s PHY address 0x%x\n" , internal ?"internal" :"external" , ret);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 418/634 net: bridge: Describe @tunnel_hash member in net_bridge_vlan_group struct
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bagas Sanjaya <[email protected]>
[ Upstream commit f79f9b7ace1713e4b83888c385f5f55519dfb687 ]
Sphinx reports kernel-doc warning:
WARNING: ./net/bridge/br_private.h:267 struct member 'tunnel_hash' not described in 'net_bridge_vlan_group'
Fix it by describing @tunnel_hash member.
--- net/bridge/br_private.h | 1 + 1 file changed, 1 insertion(+)
net/bridge/br_private.h +1 -0
@@ -224,6 +224,7 @@ struct net_bridge_vlan {* struct net_bridge_vlan_group * * @vlan_hash: VLAN entry rhashtable +* @tunnel_hash: Hash table to map from tunnel key ID (e.g. VXLAN VNI) to VLAN * @vlan_list: sorted VLAN entry list * @num_vlans: number of total VLAN entries * @pvid: PVID VLAN id
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 419/634 octeontx2-pf: fix "UBSAN: shift-out-of-bounds error"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anshumali Gaur <[email protected]>
[ Upstream commit 85f4b0c650d9f9db10bda8d3acfa1af83bf78cf7 ]
This patch ensures that the RX ring size (rx_pending) is not set below the permitted length. This avoids UBSAN shift-out-of-bounds errors when users passes small or zero ring sizes via ethtool -G.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +8 -0
@@ -422,6 +422,14 @@ static int otx2_set_ringparam(struct net_device *netdev,*/ if (rx_count < pfvf->hw.rq_skid) rx_count = pfvf->hw.rq_skid; + +if (ring->rx_pending <16 ) { +netdev_err (netdev, +"rx ring size %u invalid, min is 16\n" , + ring->rx_pending); +return -EINVAL ; + } + rx_count =Q_COUNT (Q_SIZE (rx_count,3 ));/* Due pipelining impact minimum 2000 unused SQ CQE's
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 420/634 net: stmmac: Power up SERDES after the PHY link
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Revanth Kumar Uppala <[email protected]>
[ Upstream commit a46e9010124256f5bf5fc2c241a45cf1944b768e ]
The Tegra MGBE ethernet controller requires that the SERDES link is powered-up after the PHY link is up, otherwise the link fails to become ready following a resume from suspend. Add a variable to indicate that the SERDES link must be powered-up after the PHY link.
Stable-dep-of: a48e23221000 ("net: stmmac: fix the crash issue for zero copy XDP_TX action")
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +++++-- include/linux/stmmac.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5 -2
@@ -994,6 +994,9 @@ static void stmmac_mac_link_up(struct phylink_config *config,struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev));u32 old_ctrl, ctrl; +if (priv->plat->serdes_up_after_phy_linkup && priv->plat->serdes_powerup) + priv->plat->serdes_powerup (priv->dev, priv->plat->bsp_priv); + old_ctrl =readl (priv->ioaddr +MAC_CTRL_REG ); ctrl = old_ctrl & ~priv->hw->link.speed_mask;
@@ -3839,7 +3842,7 @@ static int __stmmac_open(struct net_device *dev,stmmac_reset_queues_param (priv); -if (priv->plat->serdes_powerup) { +if (!priv->plat->serdes_up_after_phy_linkup && priv->plat->serdes_powerup) { ret = priv->plat->serdes_powerup (dev, priv->plat->bsp_priv);if (ret <0 ) { netdev_err(priv->dev, "%s: Serdes powerup failed\n",
@@ -7563,7 +7566,7 @@ int stmmac_resume(struct device *dev)stmmac_mdio_reset (priv->mii); } -if (priv->plat->serdes_powerup) { +if (!priv->plat->serdes_up_after_phy_linkup && priv->plat->serdes_powerup) { ret = priv->plat->serdes_powerup (ndev, priv->plat->bsp_priv);
include/linux/stmmac.h +1 -0
@@ -273,5 +273,6 @@ struct plat_stmmacenet_data {int msi_tx_base_vec;bool use_phy_wol;bool sph_disable; + bool serdes_up_after_phy_linkup; };#endif
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 421/634 net: stmmac: Remove some unnecessary void pointers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Halaney <[email protected]>
[ Upstream commit 0c3f3c4f4b15a2c105e1ca882d100048074a2865 ]
There's a few spots in the hardware interface where a void pointer is used, but what's passed in and later cast out is always the same type.
Just use the proper type directly.
Stable-dep-of: a48e23221000 ("net: stmmac: fix the crash issue for zero copy XDP_TX action")
--- .../net/ethernet/stmicro/stmmac/chain_mode.c | 10 +++---- .../ethernet/stmicro/stmmac/dwmac100_dma.c | 4 +-- .../ethernet/stmicro/stmmac/dwmac4_descs.c | 8 ++--- .../ethernet/stmicro/stmmac/dwxgmac2_descs.c | 6 ++-- .../net/ethernet/stmicro/stmmac/enh_desc.c | 11 +++---- drivers/net/ethernet/stmicro/stmmac/hwif.h | 30 ++++++++++++------- .../net/ethernet/stmicro/stmmac/norm_desc.c | 8 ++--- .../net/ethernet/stmicro/stmmac/ring_mode.c | 10 +++---- 8 files changed, 47 insertions(+), 40 deletions(-)
drivers/net/ethernet/stmicro/stmmac/chain_mode.c +4 -6
@@ -14,9 +14,9 @@#include "stmmac.h" -static int jumbo_frm (void *p,struct sk_buff *skb,int csum) +static int jumbo_frm (struct stmmac_tx_queue *tx_q,struct sk_buff *skb, +int csum) { -struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)p;unsigned int nopaged_len =skb_headlen (skb);struct stmmac_priv *priv = tx_q->priv_data;unsigned int entry = tx_q->cur_tx;
@@ -125,9 +125,8 @@ static void init_dma_chain(void *des, dma_addr_t phy_addr, } } -static void refill_desc3 (void *priv_ptr,struct dma_desc *p) +static void refill_desc3 (struct stmmac_rx_queue *rx_q,struct dma_desc *p) { -struct stmmac_rx_queue *rx_q = (struct stmmac_rx_queue *)priv_ptr;struct stmmac_priv *priv = rx_q->priv_data;if (priv->hwts_rx_en && !priv->extend_desc)
@@ -141,9 +140,8 @@ static void refill_desc3(void *priv_ptr, struct dma_desc *p) sizeof(struct dma_desc))); } -static void clean_desc3 (void *priv_ptr,struct dma_desc *p) +static void clean_desc3 (struct stmmac_tx_queue *tx_q,struct dma_desc *p) { -struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)priv_ptr;struct stmmac_priv *priv = tx_q->priv_data;unsigned int entry = tx_q->dirty_tx;
drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c +2 -2
@@ -80,10 +80,10 @@ static void dwmac100_dump_dma_regs(void __iomem *ioaddr, u32 *reg_space) }/* DMA controller has two counters to track the number of the missed frames. */ -static void dwmac100_dma_diagnostic_fr (void *data,struct stmmac_extra_stats *x, +static void dwmac100_dma_diagnostic_fr (struct net_device_stats *stats, +struct stmmac_extra_stats *x,void __iomem *ioaddr) { -struct net_device_stats *stats = (struct net_device_stats *)data;u32 csr8 =readl (ioaddr +DMA_MISSED_FRAME_CTR );if (unlikely (csr8)) {
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +4 -4
@@ -13,11 +13,11 @@#include "dwmac4.h" #include "dwmac4_descs.h" -static int dwmac4_wrback_get_tx_status (void *data,struct stmmac_extra_stats *x, +static int dwmac4_wrback_get_tx_status (struct net_device_stats *stats, +struct stmmac_extra_stats *x,struct dma_desc *p,void __iomem *ioaddr) { -struct net_device_stats *stats = (struct net_device_stats *)data;unsigned int tdes3;int ret = tx_done;
@@ -73,10 +73,10 @@ static int dwmac4_wrback_get_tx_status(void *data, struct stmmac_extra_stats *x,return ret; } -static int dwmac4_wrback_get_rx_status (void *data,struct stmmac_extra_stats *x, +static int dwmac4_wrback_get_rx_status (struct net_device_stats *stats, +struct stmmac_extra_stats *x,struct dma_desc *p) { -struct net_device_stats *stats = (struct net_device_stats *)data;unsigned int rdes1 =le32_to_cpu (p->des1);unsigned int rdes2 =le32_to_cpu (p->des2);unsigned int rdes3 =le32_to_cpu (p->des3);
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +4 -2
@@ -8,7 +8,8 @@#include "common.h" #include "dwxgmac2.h" -static int dwxgmac2_get_tx_status (void *data,struct stmmac_extra_stats *x, +static int dwxgmac2_get_tx_status (struct net_device_stats *stats, +struct stmmac_extra_stats *x,struct dma_desc *p,void __iomem *ioaddr) {unsigned int tdes3 =le32_to_cpu (p->des3);
@@ -22,7 +23,8 @@ static int dwxgmac2_get_tx_status(void *data, struct stmmac_extra_stats *x,return ret; } -static int dwxgmac2_get_rx_status (void *data,struct stmmac_extra_stats *x, +static int dwxgmac2_get_rx_status (struct net_device_stats *stats, +struct stmmac_extra_stats *x,struct dma_desc *p) {unsigned int rdes3 =le32_to_cpu (p->des3);
drivers/net/ethernet/stmicro/stmmac/enh_desc.c +6 -5
@@ -12,10 +12,10 @@#include "common.h" #include "descs_com.h" -static int enh_desc_get_tx_status (void *data,struct stmmac_extra_stats *x, +static int enh_desc_get_tx_status (struct net_device_stats *stats, +struct stmmac_extra_stats *x,struct dma_desc *p,void __iomem *ioaddr) { -struct net_device_stats *stats = (struct net_device_stats *)data;unsigned int tdes0 =le32_to_cpu (p->des0);int ret = tx_done;
@@ -117,7 +117,8 @@ static int enh_desc_coe_rdes0(int ipc_err, int type, int payload_err)return ret; } -static void enh_desc_get_ext_status (void *data,struct stmmac_extra_stats *x, +static void enh_desc_get_ext_status (struct net_device_stats *stats, +struct stmmac_extra_stats *x,struct dma_extended_desc *p) {unsigned int rdes0 =le32_to_cpu (p->basic.des0);
@@ -181,10 +182,10 @@ static void enh_desc_get_ext_status(void *data, struct stmmac_extra_stats *x, } } -static int enh_desc_get_rx_status (void *data,struct stmmac_extra_stats *x, +static int enh_desc_get_rx_status (struct net_device_stats *stats, +struct stmmac_extra_stats *x,struct dma_desc *p) { -struct net_device_stats *stats = (struct net_device_stats *)data;unsigned int rdes0 =le32_to_cpu (p->des0);int ret = good_frame;
drivers/net/ethernet/stmicro/stmmac/hwif.h +19 -11
@@ -56,8 +56,9 @@ struct stmmac_desc_ops {/* Last tx segment reports the transmit status */ int (*get_tx_ls)(struct dma_desc *p);/* Return the transmit status looking at the TDES1 */ -int (*tx_status)(void *data,struct stmmac_extra_stats *x, -struct dma_desc *p,void __iomem *ioaddr); +int (*tx_status)(struct net_device_stats *stats, +struct stmmac_extra_stats *x, +struct dma_desc *p,void __iomem *ioaddr);/* Get the buffer size from the descriptor */ int (*get_tx_len)(struct dma_desc *p);/* Handle extra events on specific interrupts hw dependent */
@@ -65,10 +66,12 @@ struct stmmac_desc_ops {/* Get the receive frame size */ int (*get_rx_frame_len)(struct dma_desc *p,int rx_coe_type);/* Return the reception status looking at the RDES1 */ -int (*rx_status)(void *data,struct stmmac_extra_stats *x, -struct dma_desc *p); -void (*rx_extended_status)(void *data,struct stmmac_extra_stats *x, -struct dma_extended_desc *p); +int (*rx_status)(struct net_device_stats *stats, +struct stmmac_extra_stats *x, +struct dma_desc *p); +void (*rx_extended_status)(struct net_device_stats *stats, +struct stmmac_extra_stats *x, +struct dma_extended_desc *p);/* Set tx timestamp enable bit */ void (*enable_tx_timestamp) (struct dma_desc *p);/* get tx timestamp status */
@@ -185,8 +188,9 @@ struct stmmac_dma_ops {void (*dma_tx_mode)(void __iomem *ioaddr,int mode,u32 channel,int fifosz,u8 qmode);/* To track extra statistic (if supported) */ -void (*dma_diagnostic_fr) (void *data,struct stmmac_extra_stats *x, -void __iomem *ioaddr); +void (*dma_diagnostic_fr)(struct net_device_stats *stats, +struct stmmac_extra_stats *x, +void __iomem *ioaddr);void (*enable_dma_transmission) (void __iomem *ioaddr);void (*enable_dma_irq)(void __iomem *ioaddr,u32 chan,bool rx,bool tx);
@@ -537,16 +541,20 @@ struct stmmac_hwtimestamp { #define stmmac_timestamp_interrupt(__priv, __args...) \ stmmac_do_void_callback(__priv, ptp, timestamp_interrupt, __args) +struct stmmac_tx_queue ; +struct stmmac_rx_queue ; +/* Helpers to manage the descriptors for chain and ring modes */ struct stmmac_mode_ops {void (*init) (void *des,dma_addr_t phy_addr,unsigned int size,unsigned int extend_desc);unsigned int (*is_jumbo_frm) (int len,int ehn_desc); -int (*jumbo_frm)(void *priv,struct sk_buff *skb,int csum); +int (*jumbo_frm)(struct stmmac_tx_queue *tx_q,struct sk_buff *skb, +int csum);int (*set_16kib_bfsize)(int mtu);void (*init_desc3)(struct dma_desc *p); -void (*refill_desc3) (void *priv,struct dma_desc *p); -void (*clean_desc3) (void *priv,struct dma_desc *p); +void (*refill_desc3)(struct stmmac_rx_queue *rx_q,struct dma_desc *p); +void (*clean_desc3)(struct stmmac_tx_queue *tx_q,struct dma_desc *p); }; #define stmmac_mode_init(__priv, __args...) \
drivers/net/ethernet/stmicro/stmmac/norm_desc.c +4 -4
@@ -12,10 +12,10 @@#include "common.h" #include "descs_com.h" -static int ndesc_get_tx_status (void *data,struct stmmac_extra_stats *x, +static int ndesc_get_tx_status (struct net_device_stats *stats, +struct stmmac_extra_stats *x,struct dma_desc *p,void __iomem *ioaddr) { -struct net_device_stats *stats = (struct net_device_stats *)data;unsigned int tdes0 =le32_to_cpu (p->des0);unsigned int tdes1 =le32_to_cpu (p->des1);int ret = tx_done;
@@ -70,12 +70,12 @@ static int ndesc_get_tx_len(struct dma_desc *p)* and, if required, updates the multicast statistics. * In case of success, it returns good_frame because the GMAC device * is supposed to be able to compute the csum in HW. */ -static int ndesc_get_rx_status (void *data,struct stmmac_extra_stats *x, +static int ndesc_get_rx_status (struct net_device_stats *stats, +struct stmmac_extra_stats *x,struct dma_desc *p) {int ret = good_frame;unsigned int rdes0 =le32_to_cpu (p->des0); -struct net_device_stats *stats = (struct net_device_stats *)data;if (unlikely (rdes0 &RDES0_OWN ))return dma_own;
drivers/net/ethernet/stmicro/stmmac/ring_mode.c +4 -6
@@ -14,9 +14,9 @@#include "stmmac.h" -static int jumbo_frm (void *p,struct sk_buff *skb,int csum) +static int jumbo_frm (struct stmmac_tx_queue *tx_q,struct sk_buff *skb, +int csum) { -struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)p;unsigned int nopaged_len =skb_headlen (skb);struct stmmac_priv *priv = tx_q->priv_data;unsigned int entry = tx_q->cur_tx;
@@ -101,9 +101,8 @@ static unsigned int is_jumbo_frm(int len, int enh_desc)return ret; } -static void refill_desc3 (void *priv_ptr,struct dma_desc *p) +static void refill_desc3 (struct stmmac_rx_queue *rx_q,struct dma_desc *p) { -struct stmmac_rx_queue *rx_q = priv_ptr;struct stmmac_priv *priv = rx_q->priv_data;/* Fill DES3 in case of RING mode */
@@ -117,9 +116,8 @@ static void init_desc3(struct dma_desc *p) p->des3 =cpu_to_le32 (le32_to_cpu (p->des2) + BUF_SIZE_8KiB); } -static void clean_desc3 (void *priv_ptr,struct dma_desc *p) +static void clean_desc3 (struct stmmac_tx_queue *tx_q,struct dma_desc *p) { -struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)priv_ptr;struct stmmac_priv *priv = tx_q->priv_data;unsigned int entry = tx_q->dirty_tx;
Signature · 1 line
2.51.0