6.0.16-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 815/1073 iommu/sun50i: Remove IOMMU_DOMAIN_IDENTITY
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit ef5bb8e7a7127218f826b9ccdf7508e7a339f4c2 ]
This driver treats IOMMU_DOMAIN_IDENTITY the same as UNMANAGED, which cannot possibly be correct.
UNMANAGED domains are required to start out blocking all DMAs. This seems to be what this driver does as it allocates a first level 'dt' for the IO page table that is 0 filled.
Thus UNMANAGED looks like a working IO page table, and so IDENTITY must be a mistake. Remove it.
--- drivers/iommu/sun50i-iommu.c | 1 - 1 file changed, 1 deletion(-)
drivers/iommu/sun50i-iommu.c +0 -1
@@ -672,7 +672,6 @@ static struct iommu_domain *sun50i_iommu_domain_alloc(unsigned type)struct sun50i_iommu_domain *sun50i_domain;if (type !=IOMMU_DOMAIN_DMA && - type !=IOMMU_DOMAIN_IDENTITY && type !=IOMMU_DOMAIN_UNMANAGED )return NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 816/1073 pwm: sifive: Call pwm_sifive_update_clock() while mutex is held
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 45558b3abb87eeb2cedb8a59cb2699c120b5102a ]
As was documented in commit 0f02f491b786 ("pwm: sifive: Reduce time the controller lock is held") a caller of pwm_sifive_update_clock() must hold the mutex. So fix pwm_sifive_clock_notifier() to grab the lock.
While this necessity was only documented later, the race exists since the driver was introduced.
--- drivers/pwm/pwm-sifive.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/pwm/pwm-sifive.c +4 -1
@@ -204,8 +204,11 @@ static int pwm_sifive_clock_notifier(struct notifier_block *nb,struct pwm_sifive_ddata *ddata = container_of(nb, struct pwm_sifive_ddata, notifier); -if (event ==POST_RATE_CHANGE ) +if (event ==POST_RATE_CHANGE ) { +mutex_lock (&ddata->lock);pwm_sifive_update_clock (ddata, ndata->new_rate); +mutex_unlock (&ddata->lock); + }return NOTIFY_OK ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 817/1073 pwm: mtk-disp: Fix the parameters calculated by the enabled flag of disp_pwm
In reply to Greg Kroah-HartmanFrom: xinlei lee <[email protected]>
[ Upstream commit 0b5ef3429d8f78427558ab0dcbfd862098ba2a63 ]
In the original mtk_disp_pwm_get_state() function wrongly uses bit 0 of CON0 to judge if the PWM is enabled.
However that is indicated by a bit (at a machine dependent position) in the DISP_PWM_EN register. Fix this accordingly.
--- drivers/pwm/pwm-mtk-disp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pwm/pwm-mtk-disp.c +3 -2
@@ -178,7 +178,7 @@ static void mtk_disp_pwm_get_state(struct pwm_chip *chip, {struct mtk_disp_pwm *mdp =to_mtk_disp_pwm (chip);u64 rate, period, high_width; -u32 clk_div, con0, con1; +u32 clk_div, pwm_en, con0, con1;int err; err =clk_prepare_enable (mdp->clk_main);
@@ -197,7 +197,8 @@ static void mtk_disp_pwm_get_state(struct pwm_chip *chip, rate =clk_get_rate (mdp->clk_main); con0 =readl (mdp->base + mdp->data->con0); con1 =readl (mdp->base + mdp->data->con1); - state->enabled = !!(con0 &BIT (0 )); + pwm_en =readl (mdp->base +DISP_PWM_EN ); + state->enabled = !!(pwm_en & mdp->data->enable_mask); clk_div =FIELD_GET (PWM_CLKDIV_MASK , con0); period =FIELD_GET (PWM_PERIOD_MASK , con1);/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 818/1073 pwm: mediatek: always use bus clock for PWM on MT7622
In reply to Greg Kroah-HartmanFrom: Daniel Golle <[email protected]>
[ Upstream commit aa3c668f2f98856af96e13f44da6ca4f26f0b98c ]
According to MT7622 Reference Manual for Development Board v1.0 the PWM unit found in the MT7622 SoC also comes with the PWM_CK_26M_SEL register at offset 0x210 just like other modern MediaTek ARM64 SoCs. And also MT7622 sets that register to 0x00000001 on reset which is described as 'Select 26M fix CLK as BCLK' in the datasheet. Hence set has_ck_26m_sel to true also for MT7622 which results in the driver writing 0 to the PWM_CK_26M_SEL register which is described as 'Select bus CLK as BCLK'.
--- drivers/pwm/pwm-mediatek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/pwm-mediatek.c +1 -1
@@ -296,7 +296,7 @@ static const struct pwm_mediatek_of_data mt6795_pwm_data = {static const struct pwm_mediatek_of_data mt7622_pwm_data = { .num_pwms =6 , .pwm45_fixup = false, - .has_ck_26m_sel = false, + .has_ck_26m_sel = true, };static const struct pwm_mediatek_of_data mt7623_pwm_data = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 819/1073 RISC-V: KVM: Fix reg_val check in kvm_riscv_vcpu_set_reg_config()
In reply to Greg Kroah-HartmanFrom: Anup Patel <[email protected]>
[ Upstream commit e482d9e33d5b0f222cbef7341dcd52cead6b9edc ]
The reg_val check in kvm_riscv_vcpu_set_reg_config() should only be done for isa config register.
--- arch/riscv/kvm/vcpu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
arch/riscv/kvm/vcpu.c +7 -4
@@ -286,12 +286,15 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu,if (copy_from_user (®_val, uaddr,KVM_REG_SIZE (reg->id)))return -EFAULT ; -/* This ONE REG interface is only defined for single letter extensions */ -if (fls (reg_val) >=RISCV_ISA_EXT_BASE ) -return -EINVAL ; -switch (reg_num) {case KVM_REG_RISCV_CONFIG_REG (isa): +/* +* This ONE REG interface is only defined for +* single letter extensions. +*/ +if (fls (reg_val) >=RISCV_ISA_EXT_BASE ) +return -EINVAL ; +if (!vcpu->arch.ran_atleast_once) {/* Ignore the enable/disable request for certain extensions */ for (i =0 ; i <RISCV_ISA_EXT_BASE ; i++) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 820/1073 remoteproc: sysmon: fix memory leak in qcom_add_sysmon_subdev()
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit e01ce676aaef3b13d02343d7e70f9637d93a3367 ]
The kfree() should be called when of_irq_get_byname() fails or devm_request_threaded_irq() fails in qcom_add_sysmon_subdev(), otherwise there will be a memory leak, so add kfree() to fix it.
--- drivers/remoteproc/qcom_sysmon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/remoteproc/qcom_sysmon.c +4 -1
@@ -652,7 +652,9 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,if (sysmon->shutdown_irq != -ENODATA ) {dev_err (sysmon->dev,"failed to retrieve shutdown-ack IRQ\n" ); -return ERR_PTR (sysmon->shutdown_irq); + ret = sysmon->shutdown_irq; +kfree (sysmon); +return ERR_PTR (ret); } }else { ret = devm_request_threaded_irq(sysmon->dev,
@@ -663,6 +665,7 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,if (ret) {dev_err (sysmon->dev,"failed to acquire shutdown-ack IRQ\n" ); +kfree (sysmon);return ERR_PTR (ret); } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 821/1073 remoteproc: qcom: q6v5: Fix potential null-ptr-deref in q6v5_wcss_init_mmio()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit f360e2b275efbb745ba0af8b47d9ef44221be586 ]
q6v5_wcss_init_mmio() will call platform_get_resource_byname() that may fail and return NULL. devm_ioremap() will use res->start as input, which may causes null-ptr-deref. Check the ret value of platform_get_resource_byname() to avoid the null-ptr-deref.
--- drivers/remoteproc/qcom_q6v5_wcss.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/remoteproc/qcom_q6v5_wcss.c +3 -0
@@ -827,6 +827,9 @@ static int q6v5_wcss_init_mmio(struct q6v5_wcss *wcss,int ret; res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"qdsp6" ); +if (!res) +return -EINVAL ; + wcss->reg_base =devm_ioremap (&pdev->dev, res->start,resource_size (res));if (!wcss->reg_base)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 822/1073 remoteproc: qcom_q6v5_pas: disable wakeup on probe fail or remove
In reply to Greg Kroah-HartmanFrom: Luca Weiss <[email protected]>
[ Upstream commit 9a70551996e699fda262e8d54bbd41739d7aad6d ]
Leaving wakeup enabled during probe fail (-EPROBE_DEFER) or remove makes the subsequent probe fail.
[ 3.749454] remoteproc remoteproc0: releasing 3000000.remoteproc [ 3.752949] qcom_q6v5_pas: probe of 3000000.remoteproc failed with error -17 [ 3.878935] remoteproc remoteproc0: releasing 4080000.remoteproc [ 3.887602] qcom_q6v5_pas: probe of 4080000.remoteproc failed with error -17 [ 4.319552] remoteproc remoteproc0: releasing 8300000.remoteproc [ 4.332716] qcom_q6v5_pas: probe of 8300000.remoteproc failed with error -17
Fix this by disabling wakeup in both cases so the driver can properly probe on the next try.
--- drivers/remoteproc/qcom_q6v5_pas.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/remoteproc/qcom_q6v5_pas.c +2 -0
@@ -556,6 +556,7 @@ static int adsp_probe(struct platform_device *pdev) detach_proxy_pds:adsp_pds_detach (adsp, adsp->proxy_pds, adsp->proxy_pd_count); free_rproc: +device_init_wakeup (adsp->dev, false);rproc_free (rproc);return ret;
@@ -572,6 +573,7 @@ static int adsp_remove(struct platform_device *pdev)qcom_remove_sysmon_subdev (adsp->sysmon);qcom_remove_smd_subdev (adsp->rproc, &adsp->smd_subdev);qcom_remove_ssr_subdev (adsp->rproc, &adsp->ssr_subdev); +device_init_wakeup (adsp->dev, false);rproc_free (adsp->rproc);return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 823/1073 remoteproc: qcom_q6v5_pas: detach power domains on remove
In reply to Greg Kroah-HartmanFrom: Luca Weiss <[email protected]>
[ Upstream commit 34d01df00b84127be04c914fc9f8e8be1fcdf851 ]
We need to detach from the power domains also on remove, not just on probe fail so a subsequent probe works as expected.
Otherwise the following error appears on re-probe:
[ 29.452005] sysfs: cannot create duplicate filename '/devices/genpd:0:3000000.remoteproc' [ 29.477121] CPU: 1 PID: 483 Comm: sh Tainted: G W 6.1.0-rc4-00075-g71a113770bda #78 [ 29.510319] Hardware name: Fairphone 4 (DT) [ 29.538335] Call trace: [ 29.564470] dump_backtrace.part.0+0xe0/0xf0 [ 29.592602] show_stack+0x18/0x30 [ 29.619616] dump_stack_lvl+0x64/0x80 [ 29.646834] dump_stack+0x18/0x34 [ 29.673541] sysfs_warn_dup+0x60/0x7c [ 29.700592] sysfs_create_dir_ns+0xec/0x110 [ 29.728057] kobject_add_internal+0xb8/0x374 [ 29.755530] kobject_add+0x9c/0x104 [ 29.782072] device_add+0xbc/0x8a0 [ 29.808445] device_register+0x20/0x30 [ 29.835175] genpd_dev_pm_attach_by_id+0xa4/0x190 [ 29.862851] genpd_dev_pm_attach_by_name+0x3c/0xb0 [ 29.890472] dev_pm_domain_attach_by_name+0x20/0x30 [ 29.918212] adsp_probe+0x278/0x580 [ 29.944384] platform_probe+0x68/0xc0 [ 29.970603] really_probe+0xbc/0x2dc [ 29.996662] __driver_probe_device+0x78/0xe0 [ 30.023491] device_driver_attach+0x48/0xac [ 30.050215] bind_store+0xb8/0x114 [ 30.075957] drv_attr_store+0x24/0x3c [ 30.101874] sysfs_kf_write+0x44/0x54 [ 30.127751] kernfs_fop_write_iter+0x120/0x1f0 [ 30.154448] vfs_write+0x1ac/0x380 [ 30.179937] ksys_write+0x70/0x104 [ 30.205274] __arm64_sys_write+0x1c/0x2c [ 30.231060] invoke_syscall+0x48/0x114 [ 30.256594] el0_svc_common.constprop.0+0x44/0xec [ 30.283183] do_el0_svc+0x2c/0xd0 [ 30.308320] el0_svc+0x2c/0x84 [ 30.333059] el0t_64_sync_handler+0xf4/0x120 [ 30.359001] el0t_64_sync+0x18c/0x190 [ 30.384385] kobject_add_internal failed for genpd:0:3000000.remoteproc with -EEXIST, don't try to register things with the same name in the same directory. [ 30.406029] remoteproc remoteproc0: releasing 3000000.remoteproc [ 30.416064] qcom_q6v5_pas: probe of 3000000.remoteproc failed with error -17
--- drivers/remoteproc/qcom_q6v5_pas.c | 1 + 1 file changed, 1 insertion(+)
drivers/remoteproc/qcom_q6v5_pas.c +1 -0
@@ -573,6 +573,7 @@ static int adsp_remove(struct platform_device *pdev)qcom_remove_sysmon_subdev (adsp->sysmon);qcom_remove_smd_subdev (adsp->rproc, &adsp->smd_subdev);qcom_remove_ssr_subdev (adsp->rproc, &adsp->ssr_subdev); +adsp_pds_detach (adsp, adsp->proxy_pds, adsp->proxy_pd_count);device_init_wakeup (adsp->dev, false);rproc_free (adsp->rproc);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 824/1073 remoteproc: qcom_q6v5_pas: Fix missing of_node_put() in adsp_alloc_memory_region()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 38e7d9c19276832ebb0277f415b9214bf7baeb37 ]
The pointer node is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done.
--- drivers/remoteproc/qcom_q6v5_pas.c | 1 + 1 file changed, 1 insertion(+)
drivers/remoteproc/qcom_q6v5_pas.c +1 -0
@@ -449,6 +449,7 @@ static int adsp_alloc_memory_region(struct qcom_adsp *adsp) } ret =of_address_to_resource (node,0 , &r); +of_node_put (node);if (ret)return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 825/1073 remoteproc: qcom: q6v5: Fix missing clk_disable_unprepare() in q6v5_wcss_qcs404_power_on()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 7ff5d60f18bba5cbaf17b2926aa9da44d5beca01 ]
q6v5_wcss_qcs404_power_on() have no fail path for readl_poll_timeout(). Add fail path for readl_poll_timeout().
--- drivers/remoteproc/qcom_q6v5_wcss.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/remoteproc/qcom_q6v5_wcss.c +2 -1
@@ -351,7 +351,7 @@ static int q6v5_wcss_qcs404_power_on(struct q6v5_wcss *wcss)if (ret) {dev_err (wcss->dev,"xo cbcr enabling timed out (rc:%d)\n" , ret); -return ret; + goto disable_xo_cbcr_clk; }writel (0 , wcss->reg_base +Q6SS_CGC_OVERRIDE );
@@ -417,6 +417,7 @@ static int q6v5_wcss_qcs404_power_on(struct q6v5_wcss *wcss) val =readl (wcss->reg_base +Q6SS_SLEEP_CBCR ); val &= ~Q6SS_CLK_ENABLE ;writel (val, wcss->reg_base +Q6SS_SLEEP_CBCR ); +disable_xo_cbcr_clk: val =readl (wcss->reg_base +Q6SS_XO_CBCR ); val &= ~Q6SS_CLK_ENABLE ;writel (val, wcss->reg_base +Q6SS_XO_CBCR );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 826/1073 powerpc/pseries/eeh: use correct API for error log size
In reply to Greg Kroah-HartmanFrom: Nathan Lynch <[email protected]>
[ Upstream commit 9aafbfa5f57a4b75bafd3bed0191e8429c5fa618 ]
rtas-error-log-max is not the name of an RTAS function, so rtas_token() is not the appropriate API for retrieving its value. We already have rtas_get_error_log_max() which returns a sensible value if the property is absent for any reason, so use that instead.
--- arch/powerpc/platforms/pseries/eeh_pseries.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
arch/powerpc/platforms/pseries/eeh_pseries.c +1 -10
@@ -848,16 +848,7 @@ static int __init eeh_pseries_init(void) }/* Initialize error log size */ - eeh_error_buf_size =rtas_token ("rtas-error-log-max" ); -if (eeh_error_buf_size ==RTAS_UNKNOWN_SERVICE ) { -pr_info ("%s: unknown EEH error log size\n" , - __func__); - eeh_error_buf_size =1024 ; - }else if (eeh_error_buf_size >RTAS_ERROR_LOG_MAX ) { -pr_info ("%s: EEH error log size %d exceeds the maximal %d\n" , - __func__, eeh_error_buf_size,RTAS_ERROR_LOG_MAX ); - eeh_error_buf_size =RTAS_ERROR_LOG_MAX ; - } + eeh_error_buf_size =rtas_get_error_log_max ();/* Set EEH probe mode */ eeh_add_flag (EEH_PROBE_MODE_DEVTREE |EEH_ENABLE_IO_FOR_LOG );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 827/1073 dt-bindings: mfd: qcom,spmi-pmic: Drop PWM reg dependency
In reply to Greg Kroah-HartmanFrom: Bryan O'Donoghue <[email protected]>
[ Upstream commit 763ab98687404d924b6612f7c9c8430333d31229 ]
The PWM node is not a separate device and is expected to be part of parent SPMI PMIC node, thus it obtains the address space from the parent. One IO address in "reg" is also not correct description because LPG block maps to several regions.
--- Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml +4 -4
@@ -92,6 +92,10 @@ properties: type: object $ref: /schemas/regulator/regulator.yaml# + pwm: + type: object + $ref: /schemas/leds/leds-qcom-lpg.yaml# + patternProperties: "^adc@[0-9a-f]+$": type: object
@@ -117,10 +121,6 @@ patternProperties: type: object $ref: /schemas/power/reset/qcom,pon.yaml# - "pwm@[0-9a-f]+$": - type: object - $ref: /schemas/leds/leds-qcom-lpg.yaml# - "^rtc@[0-9a-f]+$": type: object $ref: /schemas/rtc/qcom-pm8xxx-rtc.yaml#
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 828/1073 mfd: axp20x: Do not sleep in the power off handler
In reply to Greg Kroah-HartmanFrom: Samuel Holland <[email protected]>
[ Upstream commit 3f37d4f695cff180033254b9ed5adc8ab927cba9 ]
Since commit 856c288b0039 ("ARM: Use do_kernel_power_off()"), the function axp20x_power_off() now runs inside a RCU read-side critical section, so it is not allowed to call msleep(). Use mdelay() instead.
--- drivers/mfd/axp20x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/axp20x.c +1 -1
@@ -842,7 +842,7 @@ static void axp20x_power_off(void) AXP20X_OFF);/* Give capacitors etc. time to drain to avoid kernel panic msg. */ -msleep (500 ); +mdelay (500 ); }int axp20x_match_device (struct axp20x_dev *axp20x)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 829/1073 mfd: bd957x: Fix Kconfig dependency on REGMAP_IRQ
In reply to Greg Kroah-HartmanFrom: Matti Vaittinen <[email protected]>
[ Upstream commit 85842c46fd47fa6bd78681c154223bed27d5fd19 ]
The BD957x driver uses REGMAP_IRQ but does not 'select' to depend on it. This can cause build failures. Select REGMAP_IRQ for BD957X.
--- drivers/mfd/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/Kconfig +1 -0
@@ -1968,6 +1968,7 @@ config MFD_ROHM_BD957XMUF depends on I2C=y depends on OF select REGMAP_I2C + select REGMAP_IRQ select MFD_CORE help Select this option to get support for the ROHM BD9576MUF and
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 830/1073 mfd: qcom_rpm: Fix an error handling path in qcom_rpm_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 36579aca877a62f67ecd77eb3edefc4c86292406 ]
If an error occurs after the clk_prepare_enable() call, a corresponding clk_disable_unprepare() should be called.
Simplify code and switch to devm_clk_get_enabled() to fix it.
--- drivers/mfd/qcom_rpm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mfd/qcom_rpm.c +1 -3
@@ -547,7 +547,7 @@ static int qcom_rpm_probe(struct platform_device *pdev)init_completion (&rpm->ack);/* Enable message RAM clock */ - rpm->ramclk =devm_clk_get (&pdev->dev,"ram" ); + rpm->ramclk =devm_clk_get_enabled (&pdev->dev,"ram" );if (IS_ERR (rpm->ramclk)) { ret =PTR_ERR (rpm->ramclk);if (ret == -EPROBE_DEFER )
@@ -558,7 +558,6 @@ static int qcom_rpm_probe(struct platform_device *pdev)*/ rpm->ramclk =NULL ; } -clk_prepare_enable (rpm->ramclk);/* Accepts NULL */ irq_ack =platform_get_irq_byname (pdev,"ack" );if (irq_ack <0 )
@@ -681,7 +680,6 @@ static int qcom_rpm_remove(struct platform_device *pdev)struct qcom_rpm *rpm =dev_get_drvdata (&pdev->dev);of_platform_depopulate (&pdev->dev); -clk_disable_unprepare (rpm->ramclk);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 831/1073 mfd: pm8008: Fix return value check in pm8008_probe()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 14f8c55d48e02157519fbcb3a5de557abd8a06e2 ]
In case of error, the function devm_regmap_init_i2c() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().
--- drivers/mfd/qcom-pm8008.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/qcom-pm8008.c +2 -2
@@ -215,8 +215,8 @@ static int pm8008_probe(struct i2c_client *client) dev = &client->dev; regmap =devm_regmap_init_i2c (client, &qcom_mfd_regmap_cfg); -if (!regmap) -return -ENODEV ; +if (IS_ERR (regmap)) +return PTR_ERR (regmap);i2c_set_clientdata (client, regmap);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 832/1073 netfilter: flowtable: really fix NAT IPv6 offload
In reply to Greg Kroah-HartmanFrom: Qingfang DENG <[email protected]>
[ Upstream commit 5fb45f95eec682621748b7cb012c6a8f0f981e6a ]
The for-loop was broken from the start. It translates to:
for (i = 0; i < 4; i += 4)
which means the loop statement is run only once, so only the highest 32-bit of the IPv6 address gets mangled.
Fix the loop increment.
--- net/netfilter/nf_flow_table_offload.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nf_flow_table_offload.c +3 -3
@@ -383,12 +383,12 @@ static void flow_offload_ipv6_mangle(struct nf_flow_rule *flow_rule, const __be32 *addr, const __be32 *mask) { struct flow_action_entry *entry; -int i, j; +int i; -for (i =0 , j =0 ; i <sizeof (struct in6_addr ) /sizeof (u32); i +=sizeof (u32), j++) { +for (i =0 ; i <sizeof (struct in6_addr ) /sizeof (u32); i++) { entry =flow_action_entry_next (flow_rule);flow_offload_mangle (entry,FLOW_ACT_MANGLE_HDR_TYPE_IP6 , - offset + i, &addr[j], mask); + offset + i *sizeof (u32), &addr[i], mask); } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 833/1073 rtc: st-lpc: Add missing clk_disable_unprepare in st_rtc_probe()
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit 5fb733d7bd6949e90028efdce8bd528c6ab7cf1e ]
The clk_disable_unprepare() should be called in the error handling of clk_get_rate(), fix it.
--- drivers/rtc/rtc-st-lpc.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-st-lpc.c +1 -0
@@ -238,6 +238,7 @@ static int st_rtc_probe(struct platform_device *pdev) rtc->clkrate =clk_get_rate (rtc->clk);if (!rtc->clkrate) { +clk_disable_unprepare (rtc->clk);dev_err (&pdev->dev,"Unable to fetch clock rate\n" );return -EINVAL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 834/1073 rtc: pic32: Move devm_rtc_allocate_device earlier in pic32_rtc_probe()
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit 90cd5c88830140c9fade92a8027e0fb2c6e4cc49 ]
The pic32_rtc_enable(pdata, 0) and clk_disable_unprepare(pdata->clk) should be called in the error handling of devm_rtc_allocate_device(), so we should move devm_rtc_allocate_device earlier in pic32_rtc_probe() to fix it.
--- drivers/rtc/rtc-pic32.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/rtc/rtc-pic32.c +4 -4
@@ -324,16 +324,16 @@ static int pic32_rtc_probe(struct platform_device *pdev)spin_lock_init (&pdata->alarm_lock); + pdata->rtc =devm_rtc_allocate_device (&pdev->dev); +if (IS_ERR (pdata->rtc)) +return PTR_ERR (pdata->rtc); +clk_prepare_enable (pdata->clk);pic32_rtc_enable (pdata,1 );device_init_wakeup (&pdev->dev,1 ); - pdata->rtc =devm_rtc_allocate_device (&pdev->dev); -if (IS_ERR (pdata->rtc)) -return PTR_ERR (pdata->rtc); - pdata->rtc->ops = &pic32_rtcops; pdata->rtc->range_min =RTC_TIMESTAMP_BEGIN_2000 ; pdata->rtc->range_max =RTC_TIMESTAMP_END_2099 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 835/1073 rtc: pcf85063: fix pcf85063_clkout_control
In reply to Greg Kroah-HartmanFrom: Alexandre Belloni <[email protected]>
[ Upstream commit c2d12e85336f6d4172fb2bab5935027c446d7343 ]
pcf85063_clkout_control reads the wrong register but then update the correct one.
--- drivers/rtc/rtc-pcf85063.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-pcf85063.c +1 -1
@@ -424,7 +424,7 @@ static int pcf85063_clkout_control(struct clk_hw *hw, bool enable)unsigned int buf;int ret; - ret =regmap_read (pcf85063->regmap,PCF85063_REG_OFFSET , &buf); + ret =regmap_read (pcf85063->regmap,PCF85063_REG_CTRL2 , &buf);if (ret <0 )return ret; buf &=PCF85063_REG_CLKO_F_MASK ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 836/1073 iommu/mediatek: Fix forever loop in error handling
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 462e768b55a2331324ff72e74706261134369826 ]
There is a typo so this loop does i++ where i-- was intended. It will result in looping until the kernel crashes.
--- drivers/iommu/mtk_iommu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iommu/mtk_iommu.c +1 -2
@@ -1127,8 +1127,7 @@ static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **mreturn 0 ; err_larbdev_put: -/* id may be not linear mapping, loop whole the array */ -for (i =MTK_LARB_NR_MAX -1 ; i >=0 ; i++) { +for (i =MTK_LARB_NR_MAX -1 ; i >=0 ; i--) {if (!data->larb_imu[i].dev)continue ;put_device (data->larb_imu[i].dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 837/1073 nfsd: under NFSv4.1, fix double svc_xprt_put on rpc_create failure
In reply to Greg Kroah-HartmanFrom: Dan Aloni <[email protected]>
[ Upstream commit 3bc8edc98bd43540dbe648e4ef91f443d6d20a24 ]
On error situation clp->cl_cb_conn.cb_xprt should not be given a reference to the xprt otherwise both client cleanup and the error handling path of the caller call to put it. Better to delay handing over the reference to a later branch.
[ 72.530665] refcount_t: underflow; use-after-free. [ 72.531933] WARNING: CPU: 0 PID: 173 at lib/refcount.c:28 refcount_warn_saturate+0xcf/0x120 [ 72.533075] Modules linked in: nfsd(OE) nfsv4(OE) nfsv3(OE) nfs(OE) lockd(OE) compat_nfs_ssc(OE) nfs_acl(OE) rpcsec_gss_krb5(OE) auth_rpcgss(OE) rpcrdma(OE) dns_resolver fscache netfs grace rdma_cm iw_cm ib_cm sunrpc(OE) mlx5_ib mlx5_core mlxfw pci_hyperv_intf ib_uverbs ib_core xt_MASQUERADE nf_conntrack_netlink nft_counter xt_addrtype nft_compat br_netfilter bridge stp llc nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ip_set overlay nf_tables nfnetlink crct10dif_pclmul crc32_pclmul ghash_clmulni_intel xfs serio_raw virtio_net virtio_blk net_failover failover fuse [last unloaded: sunrpc] [ 72.540389] CPU: 0 PID: 173 Comm: kworker/u16:5 Tainted: G OE 5.15.82-dan #1 [ 72.541511] Hardware name: Red Hat KVM/RHEL-AV, BIOS 1.16.0-3.module+el8.7.0+1084+97b81f61 04/01/2014 [ 72.542717] Workqueue: nfsd4_callbacks nfsd4_run_cb_work [nfsd] [ 72.543575] RIP: 0010:refcount_warn_saturate+0xcf/0x120 [ 72.544299] Code: 55 00 0f 0b 5d e9 01 50 98 00 80 3d 75 9e 39 08 00 0f 85 74 ff ff ff 48 c7 c7 e8 d1 60 8e c6 05 61 9e 39 08 01 e8 f6 51 55 00 <0f> 0b 5d e9 d9 4f 98 00 80 3d 4b 9e 39 08 00 0f 85 4c ff ff ff 48 [ 72.546666] RSP: 0018:ffffb3f841157cf0 EFLAGS: 00010286 [ 72.547393] RAX: 0000000000000026 RBX: ffff89ac6231d478 RCX: 0000000000000000 [ 72.548324] RDX: ffff89adb7c2c2c0 RSI: ffff89adb7c205c0 RDI: ffff89adb7c205c0 [ 72.549271] RBP: ffffb3f841157cf0 R08: 0000000000000000 R09: c0000000ffefffff [ 72.550209] R10: 0000000000000001 R11: ffffb3f841157ad0 R12: ffff89ac6231d180 [ 72.551142] R13: ffff89ac6231d478 R14: ffff89ac40c06180 R15: ffff89ac6231d4b0 [ 72.552089] FS: 0000000000000000(0000) GS:ffff89adb7c00000(0000) knlGS:0000000000000000 [ 72.553175] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 72.553934] CR2: 0000563a310506a8 CR3: 0000000109a66000 CR4: 0000000000350ef0 [ 72.554874] Call Trace: [ 72.555278] <TASK> [ 72.555614] svc_xprt_put+0xaf/0xe0 [sunrpc] [ 72.556276] nfsd4_process_cb_update.isra.11+0xb7/0x410 [nfsd] [ 72.557087] ? update_load_avg+0x82/0x610 [ 72.557652] ? cpuacct_charge+0x60/0x70 [ 72.558212] ? dequeue_entity+0xdb/0x3e0 [ 72.558765] ? queued_spin_unlock+0x9/0x20 [ 72.559358] nfsd4_run_cb_work+0xfc/0x270 [nfsd] [ 72.560031] process_one_work+0x1df/0x390 [ 72.560600] worker_thread+0x37/0x3b0 [ 72.561644] ? process_one_work+0x390/0x390 [ 72.562247] kthread+0x12f/0x150 [ 72.562710] ? set_kthread_struct+0x50/0x50 [ 72.563309] ret_from_fork+0x22/0x30 [ 72.563818] </TASK> [ 72.564189] ---[ end trace 031117b1c72ec616 ]--- [ 72.566019] list_add corruption. next->prev should be prev (ffff89ac4977e538), but was ffff89ac4763e018. (next=ffff89ac4763e018). [ 72.567647] ------------[ cut here ]------------
--- fs/nfsd/nfs4callback.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfsd/nfs4callback.c +3 -1
@@ -916,7 +916,6 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c }else {if (!conn->cb_xprt)return -EINVAL ; - clp->cl_cb_conn.cb_xprt = conn->cb_xprt; clp->cl_cb_session = ses; args.bc_xprt = conn->cb_xprt; args.prognumber = clp->cl_cb_session->se_cb_prog;
@@ -936,6 +935,9 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *crpc_shutdown_client (client);return -ENOMEM ; } + +if (clp->cl_minorversion !=0 ) + clp->cl_cb_conn.cb_xprt = conn->cb_xprt; clp->cl_cb_client = client; clp->cl_cb_cred = cred;rcu_read_lock ();
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 838/1073 net: macsec: fix net device access prior to holding a lock
In reply to Greg Kroah-HartmanFrom: Emeel Hakim <[email protected]>
[ Upstream commit f3b4a00f0f62da252c598310698dfc82ef2f2e2e ]
Currently macsec offload selection update routine accesses the net device prior to holding the relevant lock. Fix by holding the lock prior to the device access.
--- drivers/net/macsec.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-)
drivers/net/macsec.c +21 -13
@@ -2621,7 +2621,7 @@ static int macsec_upd_offload(struct sk_buff *skb, struct genl_info *info)const struct macsec_ops *ops;struct macsec_context ctx;struct macsec_dev *macsec; -int ret; +int ret =0 ;if (!attrs[MACSEC_ATTR_IFINDEX ])return -EINVAL ;
@@ -2634,28 +2634,36 @@ static int macsec_upd_offload(struct sk_buff *skb, struct genl_info *info) macsec_genl_offload_policy, NULL))return -EINVAL ; +rtnl_lock (); + dev =get_dev_from_nl (genl_info_net (info), attrs); -if (IS_ERR (dev)) -return PTR_ERR (dev); +if (IS_ERR (dev)) { + ret =PTR_ERR (dev); + goto out; + } macsec =macsec_priv (dev); -if (!tb_offload[MACSEC_OFFLOAD_ATTR_TYPE ]) -return -EINVAL ; +if (!tb_offload[MACSEC_OFFLOAD_ATTR_TYPE ]) { + ret = -EINVAL ; + goto out; + } offload =nla_get_u8 (tb_offload[MACSEC_OFFLOAD_ATTR_TYPE ]);if (macsec->offload == offload) -return 0 ; + goto out;/* Check if the offloading mode is supported by the underlying layers */ if (offload !=MACSEC_OFFLOAD_OFF && - !macsec_check_offload (offload, macsec)) -return -EOPNOTSUPP ; + !macsec_check_offload (offload, macsec)) { + ret = -EOPNOTSUPP ; + goto out; + }/* Check if the net device is busy. */ -if (netif_running (dev)) -return -EBUSY ; - -rtnl_lock (); +if (netif_running (dev)) { + ret = -EBUSY ; + goto out; + } prev_offload = macsec->offload; macsec->offload = offload;
@@ -2690,7 +2698,7 @@ static int macsec_upd_offload(struct sk_buff *skb, struct genl_info *info) rollback: macsec->offload = prev_offload; - +out:rtnl_unlock ();return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 839/1073 bonding: add missed __rcu annotation for curr_active_slave
In reply to Greg Kroah-HartmanFrom: Hangbin Liu <[email protected]>
[ Upstream commit 3d0b738fc5adf9f380702ac1424672e4b32c3781 ]
There is one direct accesses to bond->curr_active_slave in bond_miimon_commit(). Protected it by rcu_access_pointer() since the later of this function also use this one.
Stable-dep-of: e95cc44763a4 ("bonding: do failover when high prio link up")
--- drivers/net/bonding/bond_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +1 -1
@@ -2698,7 +2698,7 @@ static void bond_miimon_commit(struct bonding *bond)bond_miimon_link_change (bond, slave,BOND_LINK_UP ); -if (!bond->curr_active_slave || slave == primary) +if (!rcu_access_pointer (bond->curr_active_slave) || slave == primary) goto do_failover;continue ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 840/1073 bonding: do failover when high prio link up
In reply to Greg Kroah-HartmanFrom: Hangbin Liu <[email protected]>
[ Upstream commit e95cc44763a41d5c715ef16742bcb1d8e6524a62 ]
Currently, when a high prio link enslaved, or when current link down, the high prio port could be selected. But when high prio link up, the new active slave reselection is not triggered. Fix it by checking link's prio when getting up. Making the do_failover after looping all slaves as there may be multi high prio slaves up.
--- drivers/net/bonding/bond_main.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/net/bonding/bond_main.c +15 -9
@@ -2653,8 +2653,9 @@ static void bond_miimon_link_change(struct bonding *bond,static void bond_miimon_commit (struct bonding *bond) { -struct list_head *iter;struct slave *slave, *primary; +bool do_failover = false; +struct list_head *iter;bond_for_each_slave (bond, slave, iter) {switch (slave->link_new_state) {
@@ -2698,8 +2699,9 @@ static void bond_miimon_commit(struct bonding *bond)bond_miimon_link_change (bond, slave,BOND_LINK_UP ); -if (!rcu_access_pointer (bond->curr_active_slave) || slave == primary) - goto do_failover; +if (!rcu_access_pointer (bond->curr_active_slave) || slave == primary || + slave->prio >rcu_dereference (bond->curr_active_slave)->prio) + do_failover = true;continue ;
@@ -2720,7 +2722,7 @@ static void bond_miimon_commit(struct bonding *bond)bond_miimon_link_change (bond, slave,BOND_LINK_DOWN );if (slave ==rcu_access_pointer (bond->curr_active_slave)) - goto do_failover; + do_failover = true;continue ;
@@ -2731,8 +2733,9 @@ static void bond_miimon_commit(struct bonding *bond)continue ; } + } -do_failover: +if (do_failover) {block_netpoll_tx ();bond_select_active_slave (bond);unblock_netpoll_tx ();
@@ -3530,6 +3533,7 @@ static int bond_ab_arp_inspect(struct bonding *bond)*/ static void bond_ab_arp_commit (struct bonding *bond) { +bool do_failover = false;struct list_head *iter;unsigned long last_tx;struct slave *slave;
@@ -3559,8 +3563,9 @@ static void bond_ab_arp_commit(struct bonding *bond)slave_info (bond->dev, slave->dev,"link status definitely up\n" );if (!rtnl_dereference (bond->curr_active_slave) || - slave ==rtnl_dereference (bond->primary_slave)) - goto do_failover; + slave ==rtnl_dereference (bond->primary_slave) || + slave->prio >rtnl_dereference (bond->curr_active_slave)->prio) + do_failover = true; }
@@ -3579,7 +3584,7 @@ static void bond_ab_arp_commit(struct bonding *bond)if (slave ==rtnl_dereference (bond->curr_active_slave)) {RCU_INIT_POINTER (bond->current_arp_slave,NULL ); - goto do_failover; + do_failover = true; }continue ;
@@ -3603,8 +3608,9 @@ static void bond_ab_arp_commit(struct bonding *bond) slave->link_new_state);continue ; } + } -do_failover: +if (do_failover) {block_netpoll_tx ();bond_select_active_slave (bond);unblock_netpoll_tx ();
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 841/1073 mISDN: hfcsusb: dont call dev_kfree_skb/kfree_skb() under spin_lock_irqsave()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit ddc9648db162eee556edd5222d2808fe33730203 ]
It is not allowed to call kfree_skb() or consume_skb() from hardware interrupt context or with hardware interrupts being disabled.
It should use dev_kfree_skb_irq() or dev_consume_skb_irq() instead. The difference between them is free reason, dev_kfree_skb_irq() means the SKB is dropped in error and dev_consume_skb_irq() means the SKB is consumed in normal.
skb_queue_purge() is called under spin_lock_irqsave() in hfcusb_l2l1D(), kfree_skb() is called in it, to fix this, use skb_queue_splice_init() to move the dch->squeue to a free queue, also enqueue the tx_skb and rx_skb, at last calling __skb_queue_purge() to free the SKBs afer unlock.
In tx_iso_complete(), dev_kfree_skb() is called to consume the transmitted SKB, so replace it with dev_consume_skb_irq().
--- drivers/isdn/hardware/mISDN/hfcsusb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/isdn/hardware/mISDN/hfcsusb.c +8 -4
@@ -326,20 +326,24 @@ hfcusb_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb)test_and_clear_bit (FLG_L2_ACTIVATED , &dch->Flags);if (hw->protocol ==ISDN_P_NT_S0 ) { +struct sk_buff_head free_queue; + +__skb_queue_head_init (&free_queue);hfcsusb_ph_command (hw,HFC_L1_DEACTIVATE_NT );spin_lock_irqsave (&hw->lock, flags); -skb_queue_purge (&dch->squeue); +skb_queue_splice_init (&dch->squeue, &free_queue);if (dch->tx_skb) { -dev_kfree_skb (dch->tx_skb); +__skb_queue_tail (&free_queue, dch->tx_skb); dch->tx_skb =NULL ; } dch->tx_idx =0 ;if (dch->rx_skb) { -dev_kfree_skb (dch->rx_skb); +__skb_queue_tail (&free_queue, dch->rx_skb); dch->rx_skb =NULL ; }test_and_clear_bit (FLG_TX_BUSY , &dch->Flags);spin_unlock_irqrestore (&hw->lock, flags); +__skb_queue_purge (&free_queue);#ifdef FIXME if (test_and_clear_bit (FLG_L1_BUSY , &dch->Flags))dchannel_sched_event (&hc->dch,D_CLEARBUSY );
@@ -1330,7 +1334,7 @@ tx_iso_complete(struct urb *urb)printk ("\n" ); } -dev_kfree_skb (tx_skb); +dev_consume_skb_irq (tx_skb); tx_skb =NULL ;if (fifo->dch &&get_next_dframe (fifo->dch)) tx_skb = fifo->dch->tx_skb;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 842/1073 mISDN: hfcpci: dont call dev_kfree_skb/kfree_skb() under spin_lock_irqsave()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit f0f596bd75a9d573ca9b587abb39cee0b916bb82 ]
It is not allowed to call kfree_skb() or consume_skb() from hardware interrupt context or with hardware interrupts being disabled.
skb_queue_purge() is called under spin_lock_irqsave() in hfcpci_l2l1D(), kfree_skb() is called in it, to fix this, use skb_queue_splice_init() to move the dch->squeue to a free queue, also enqueue the tx_skb and rx_skb, at last calling __skb_queue_purge() to free the SKBs afer unlock.
--- drivers/isdn/hardware/mISDN/hfcpci.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/isdn/hardware/mISDN/hfcpci.c +9 -4
@@ -1617,16 +1617,19 @@ hfcpci_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb)test_and_clear_bit (FLG_L2_ACTIVATED , &dch->Flags);spin_lock_irqsave (&hc->lock, flags);if (hc->hw.protocol ==ISDN_P_NT_S0 ) { +struct sk_buff_head free_queue; + +__skb_queue_head_init (&free_queue);/* prepare deactivation */ Write_hfc (hc,HFCPCI_STATES ,0x40 ); -skb_queue_purge (&dch->squeue); +skb_queue_splice_init (&dch->squeue, &free_queue);if (dch->tx_skb) { -dev_kfree_skb (dch->tx_skb); +__skb_queue_tail (&free_queue, dch->tx_skb); dch->tx_skb =NULL ; } dch->tx_idx =0 ;if (dch->rx_skb) { -dev_kfree_skb (dch->rx_skb); +__skb_queue_tail (&free_queue, dch->rx_skb); dch->rx_skb =NULL ; }test_and_clear_bit (FLG_TX_BUSY , &dch->Flags);
@@ -1639,10 +1642,12 @@ hfcpci_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb) hc->hw.mst_m &= ~HFCPCI_MASTER ;Write_hfc (hc,HFCPCI_MST_MODE , hc->hw.mst_m); ret =0 ; +spin_unlock_irqrestore (&hc->lock, flags); +__skb_queue_purge (&free_queue); }else { ret =l1_event (dch->l1, hh->prim); +spin_unlock_irqrestore (&hc->lock, flags); } -spin_unlock_irqrestore (&hc->lock, flags);break ; }if (!ret)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 843/1073 mISDN: hfcmulti: dont call dev_kfree_skb/kfree_skb() under spin_lock_irqsave()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 1232946cf522b8de9e398828bde325d7c41f29dd ]
It is not allowed to call kfree_skb() or consume_skb() from hardware interrupt context or with hardware interrupts being disabled.
skb_queue_purge() is called under spin_lock_irqsave() in handle_dmsg() and hfcm_l1callback(), kfree_skb() is called in them, to fix this, use skb_queue_splice_init() to move the dch->squeue to a free queue, also enqueue the tx_skb and rx_skb, at last calling __skb_queue_purge() to free the SKBs afer unlock.
--- drivers/isdn/hardware/mISDN/hfcmulti.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/isdn/hardware/mISDN/hfcmulti.c +13 -6
@@ -3217,6 +3217,7 @@ static int hfcm_l1callback(struct dchannel *dch, u_int cmd) {struct hfc_multi *hc = dch->hw; +struct sk_buff_head free_queue;u_long flags;switch (cmd) {
@@ -3245,6 +3246,7 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd)l1_event (dch->l1,HW_POWERUP_IND );break ;case HW_DEACT_REQ : +__skb_queue_head_init (&free_queue);/* start deactivation */ spin_lock_irqsave (&hc->lock, flags);if (hc->ctype ==HFC_TYPE_E1 ) {
@@ -3264,20 +3266,21 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd)plxsd_checksync (hc,0 ); } } -skb_queue_purge (&dch->squeue); +skb_queue_splice_init (&dch->squeue, &free_queue);if (dch->tx_skb) { -dev_kfree_skb (dch->tx_skb); +__skb_queue_tail (&free_queue, dch->tx_skb); dch->tx_skb =NULL ; } dch->tx_idx =0 ;if (dch->rx_skb) { -dev_kfree_skb (dch->rx_skb); +__skb_queue_tail (&free_queue, dch->rx_skb); dch->rx_skb =NULL ; }test_and_clear_bit (FLG_TX_BUSY , &dch->Flags);if (test_and_clear_bit (FLG_BUSY_TIMER , &dch->Flags))del_timer (&dch->timer);spin_unlock_irqrestore (&hc->lock, flags); +__skb_queue_purge (&free_queue);break ;case HW_POWERUP_REQ :spin_lock_irqsave (&hc->lock, flags);
@@ -3384,6 +3387,9 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb)case PH_DEACTIVATE_REQ :test_and_clear_bit (FLG_L2_ACTIVATED , &dch->Flags);if (dch->dev.D.protocol !=ISDN_P_TE_S0 ) { +struct sk_buff_head free_queue; + +__skb_queue_head_init (&free_queue);spin_lock_irqsave (&hc->lock, flags);if (debug &DEBUG_HFCMULTI_MSG ) printk(KERN_DEBUG
@@ -3405,14 +3411,14 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb)/* deactivate */ dch->state =1 ; } -skb_queue_purge (&dch->squeue); +skb_queue_splice_init (&dch->squeue, &free_queue);if (dch->tx_skb) { -dev_kfree_skb (dch->tx_skb); +__skb_queue_tail (&free_queue, dch->tx_skb); dch->tx_skb =NULL ; } dch->tx_idx =0 ;if (dch->rx_skb) { -dev_kfree_skb (dch->rx_skb); +__skb_queue_tail (&free_queue, dch->rx_skb); dch->rx_skb =NULL ; }test_and_clear_bit (FLG_TX_BUSY , &dch->Flags);
@@ -3424,6 +3430,7 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb)#endif ret =0 ;spin_unlock_irqrestore (&hc->lock, flags); +__skb_queue_purge (&free_queue); }else ret =l1_event (dch->l1, hh->prim);break ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 844/1073 block, bfq: fix possible uaf for bfqq->bic
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit 64dc8c732f5c2b406cc752e6aaa1bd5471159cab ]
Our test report a uaf for 'bfqq->bic' in 5.10:
==================================================================
BUG: KASAN: use-after-free in bfq_select_queue+0x378/0xa30 CPU: 6 PID: 2318352 Comm: fsstress Kdump: loaded Not tainted 5.10.0-60.18.0.50.h602.kasan.eulerosv2r11.x86_64 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58-20220320_160524-szxrtosci10000 04/01/2014 Call Trace: bfq_select_queue+0x378/0xa30 bfq_dispatch_request+0xe8/0x130 blk_mq_do_dispatch_sched+0x62/0xb0 __blk_mq_sched_dispatch_requests+0x215/0x2a0 blk_mq_sched_dispatch_requests+0x8f/0xd0 __blk_mq_run_hw_queue+0x98/0x180 __blk_mq_delay_run_hw_queue+0x22b/0x240 blk_mq_run_hw_queue+0xe3/0x190 blk_mq_sched_insert_requests+0x107/0x200 blk_mq_flush_plug_list+0x26e/0x3c0 blk_finish_plug+0x63/0x90 __iomap_dio_rw+0x7b5/0x910 iomap_dio_rw+0x36/0x80 ext4_dio_read_iter+0x146/0x190 [ext4] ext4_file_read_iter+0x1e2/0x230 [ext4] new_sync_read+0x29f/0x400 vfs_read+0x24e/0x2d0 ksys_read+0xd5/0x1b0 do_syscall_64+0x33/0x40 entry_SYSCALL_64_after_hwframe+0x61/0xc6
Commit 3bc5e683c67d ("bfq: Split shared queues on move between cgroups") changes that move process to a new cgroup will allocate a new bfqq to use, however, the old bfqq and new bfqq can point to the same bic:
1) Initial state, two process with io in the same cgroup.
Process 1 Process 2
(BIC1) (BIC2)
| Λ | Λ | | | | V | V | bfqq1 bfqq2
2) bfqq1 is merged to bfqq2.
Process 1 Process 2
(BIC1) (BIC2)
| | \-------------\|
V
bfqq1 bfqq2(coop)
3) Process 1 exit, then issue new io(denoce IOA) from Process 2.
(BIC2)
| Λ | | V |
bfqq2(coop)
4) Before IOA is completed, move Process 2 to another cgroup and issue io.
Process 2
(BIC2)
Λ
|\--------------\
| V
bfqq2 bfqq3
Now that BIC2 points to bfqq3, while bfqq2 and bfqq3 both point to BIC2. If all the requests are completed, and Process 2 exit, BIC2 will be freed while there is no guarantee that bfqq2 will be freed before BIC2.
Fix the problem by clearing bfqq->bic while bfqq is detached from bic.
--- block/bfq-iosched.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
block/bfq-iosched.c +6 -1
@@ -386,6 +386,12 @@ static void bfq_put_stable_ref(struct bfq_queue *bfqq);void bic_set_bfqq (struct bfq_io_cq *bic,struct bfq_queue *bfqq,bool is_sync) { +struct bfq_queue *old_bfqq = bic->bfqq[is_sync]; + +/* Clear bic pointer if bfqq is detached from this bic */ +if (old_bfqq && old_bfqq->bic == bic) + old_bfqq->bic =NULL ; +/* * If bfqq != NULL, then a non-stable queue merge between * bic->bfqq and bfqq is happening here. This causes troubles
@@ -5379,7 +5385,6 @@ static void bfq_exit_icq_bfqq(struct bfq_io_cq *bic, bool is_sync)unsigned long flags;spin_lock_irqsave (&bfqd->lock, flags); - bfqq->bic =NULL ;bfq_exit_bfqq (bfqd, bfqq);bic_set_bfqq (bic,NULL , is_sync);spin_unlock_irqrestore (&bfqd->lock, flags);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 845/1073 selftests/bpf: Select CONFIG_FUNCTION_ERROR_INJECTION
In reply to Greg Kroah-HartmanFrom: Song Liu <[email protected]>
[ Upstream commit a8dfde09c90109e3a98af54847e91bde7dc2d5c2 ]
BPF selftests require CONFIG_FUNCTION_ERROR_INJECTION to work. However, CONFIG_FUNCTION_ERROR_INJECTION is no longer 'y' by default after recent changes. As a result, we are seeing errors like the following from BPF CI:
bpf_testmod_test_read() is not modifiable
__x64_sys_setdomainname is not sleepable
__x64_sys_getpgid is not sleepable
Fix this by explicitly selecting CONFIG_FUNCTION_ERROR_INJECTION in the selftest config.
--- tools/testing/selftests/bpf/config | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/config +1 -0
@@ -13,6 +13,7 @@ CONFIG_CRYPTO_USER_API_HASH=m CONFIG_DYNAMIC_FTRACE=y CONFIG_FPROBE=y CONFIG_FTRACE_SYSCALLS=y +CONFIG_FUNCTION_ERROR_INJECTION=y CONFIG_FUNCTION_TRACER=y CONFIG_GENEVE=y CONFIG_IKCONFIG=y
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 846/1073 bpf: prevent leak of lsm program after failed attach
In reply to Greg Kroah-HartmanFrom: Milan Landaverde <[email protected]>
[ Upstream commit e89f3edffb860a0f54a9ed16deadb7a4a1fa3862 ]
In [0], we added the ability to bpf_prog_attach LSM programs to cgroups, but in our validation to make sure the prog is meant to be attached to BPF_LSM_CGROUP, we return too early if the check fails. This results in lack of decrementing prog's refcnt (through bpf_prog_put) leaving the LSM program alive past the point of the expected lifecycle. This fix allows for the decrement to take place.
[0] https://lore.kernel.org/all/[email protected]/
--- kernel/bpf/syscall.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/bpf/syscall.c +3 -3
@@ -3505,9 +3505,9 @@ static int bpf_prog_attach(const union bpf_attr *attr)case BPF_PROG_TYPE_LSM :if (ptype ==BPF_PROG_TYPE_LSM && prog->expected_attach_type !=BPF_LSM_CGROUP ) -return -EINVAL ; - - ret =cgroup_bpf_prog_attach (attr, ptype, prog); + ret = -EINVAL ; +else + ret =cgroup_bpf_prog_attach (attr, ptype, prog);break ;default : ret = -EINVAL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 847/1073 media: v4l2-ctrls-api.c: add back dropped ctrl->is_new = 1
In reply to Greg Kroah-HartmanFrom: Hans Verkuil <[email protected]>
[ Upstream commit 73278d483378cf850ade923a1107a70297b2602a ]
The patch adding support for dynamically allocated arrays accidentally dropped the line setting ctrl->is_new to 1, thus new string values were always ignored.
--- drivers/media/v4l2-core/v4l2-ctrls-api.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/v4l2-core/v4l2-ctrls-api.c +1 -0
@@ -155,6 +155,7 @@ static int user_to_new(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl)* then return an error. */ if (strlen (ctrl->p_new.p_char) == ctrl->maximum && last) + ctrl->is_new =1 ;return -ERANGE ; }return ret;
Signature · 1 line
2.35.1
Re: [PATCH 6.0 0847/1073] media: v4l2-ctrls-api.c: add back dropped ctrl->is_new = 1
Quoted 22 lines · Greg Kroah-Hartman
From: Hans Verkuil <[email protected]>
[ Upstream commit
73278d483378cf850ade923a1107a70297b2602a]The patch adding support for dynamically allocated arrays accidentally dropped the line setting
ctrl->is_newto 1, thus new string values were always ignored.Fixes fb582cba4492 ("media: v4l2-ctrls: add support for dynamically allocated arrays.")Reported-by Alice Yuan <[email protected]>Signed-off-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/media/v4l2-core/v4l2-ctrls-api.c | 1 + 1 file changed, 1 insertion(+)drivers/media/v4l2-core/v4l2-ctrls-api.c +0
-0
drivers/media/v4l2-core/v4l2-ctrls-api.c static int user_to_new(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) · line 159
Quoted 5 lines
drivers/media/v4l2-core/v4l2-ctrls-api.c +1
-0@@ -155,6 +155,7 @@ static int user_to_new(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl)* then return an error. */ if (strlen (ctrl->p_new.p_char) == ctrl->maximum && last) + ctrl->is_new =1 ;return -ERANGE ;
This is obviously wrong.
Something got messed up in mainline where my original patch:
got mangled to the version you have here.
I guess I'll have to post a new patch for mainline fixing the mangled fix.
I only now noticed that you posted the backport patch for review on Dec 25th :-(
Oh well, string control support was broken, and is now even more broken.
Regards,
Hans
Quoted 2 lines
drivers/media/v4l2-core/v4l2-ctrls-api.c +0
-0}return ret;
Greg Kroah-Hartman
maintainerPATCH 848/1073 net: enetc: avoid buffer leaks on xdp_do_redirect() failure
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 628050ec952d2e2e46ec9fb6aa07e41139e030c8 ]
Before enetc_clean_rx_ring_xdp() calls xdp_do_redirect(), each software BD in the RX ring between index orig_i and i can have one of 2 refcount values on its page.
We are the owner of the current buffer that is being processed, so the refcount will be at least 1.
If the current owner of the buffer at the diametrically opposed index in the RX ring (i.o.w, the other half of this page) has not yet called kfree(), this page's refcount could even be 2.
enetc_page_reusable() in enetc_flip_rx_buff() tests for the page refcount against 1, and [ if it's 2 ] does not attempt to reuse it.
But if enetc_flip_rx_buff() is put after the xdp_do_redirect() call, the page refcount can have one of 3 values. It can also be 0, if there is no owner of the other page half, and xdp_do_redirect() for this buffer ran so far that it triggered a flush of the devmap/cpumap bulk queue, and the consumers of those bulk queues also freed the buffer, all by the time xdp_do_redirect() returns the execution back to enetc.
This is the reason why enetc_flip_rx_buff() is called before xdp_do_redirect(), but there is a big flaw with that reasoning:enetc_flip_rx_buff() will set rx_swbd->page = NULL on both sides of the enetc_page_reusable() branch, and if xdp_do_redirect() returns an error, we call enetc_xdp_free(), which does not deal gracefully with that.
In fact, what happens is quite special. The page refcounts start as 1. enetc_flip_rx_buff() figures they're reusable, transfers these rx_swbd->page pointers to a different rx_swbd in enetc_reuse_page(), and bumps the refcount to 2. When xdp_do_redirect() later returns an error, we call the no-op enetc_xdp_free(), but we still haven't lost the reference to that page. A copy of it is still at rx_ring->next_to_alloc, but that has refcount 2 (and there are no concurrent owners of it in flight, to drop the refcount). What really kills the system is when we'll flip the rx_swbd->page the second time around. With an updated refcount of 2, the page will not be reusable and we'll really leak it. Then enetc_new_page() will have to allocate more pages, which will then eventually leak again on further errors from xdp_do_redirect().
The problem, summarized, is that we zeroize rx_swbd->page before we're completely done with it, and this makes it impossible for the error path to do something with it.
Since the packet is potentially multi-buffer and therefore the rx_swbd->page is potentially an array, manual passing of the old pointers between enetc_flip_rx_buff() and enetc_xdp_free() is a bit difficult.
For the sake of going with a simple solution, we accept the possibility of racing with xdp_do_redirect(), and we move the flip procedure to execute only on the redirect success path. By racing, I mean that the page may be deemed as not reusable by enetc (having a refcount of 0), but there will be no leak in that case, either.
Once we accept that, we have something better to do with buffers on XDP_REDIRECT failure. Since we haven't performed half-page flipping yet, we won't, either (and this way, we can avoid enetc_xdp_free() completely, which gives the entire page to the slab allocator). Instead, we'll call enetc_xdp_drop(), which will recycle this half of the buffer back to the RX ring.
--- drivers/net/ethernet/freescale/enetc/enetc.c | 35 +++++--------------- 1 file changed, 8 insertions(+), 27 deletions(-)
drivers/net/ethernet/freescale/enetc/enetc.c +8 -27
@@ -1489,23 +1489,6 @@ static void enetc_xdp_drop(struct enetc_bdr *rx_ring, int rx_ring_first, rx_ring->stats.xdp_drops++; } -static void enetc_xdp_free (struct enetc_bdr *rx_ring,int rx_ring_first, -int rx_ring_last) -{ -while (rx_ring_first != rx_ring_last) { -struct enetc_rx_swbd *rx_swbd = &rx_ring->rx_swbd[rx_ring_first]; - -if (rx_swbd->page) { -dma_unmap_page (rx_ring->dev, rx_swbd->dma,PAGE_SIZE , - rx_swbd->dir); -__free_page (rx_swbd->page); - rx_swbd->page =NULL ; - } -enetc_bdr_idx_inc (rx_ring, &rx_ring_first); - } - rx_ring->stats.xdp_redirect_failures++; -} -static int enetc_clean_rx_ring_xdp (struct enetc_bdr *rx_ring,struct napi_struct *napi,int work_limit,struct bpf_prog *prog)
@@ -1527,8 +1510,8 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring,int orig_i, orig_cleaned_cnt;struct xdp_buff xdp_buff;struct sk_buff *skb; -int tmp_orig_i, err;u32 bd_status; +int err; rxbd =enetc_rxbd (rx_ring, i); bd_status =le32_to_cpu (rxbd->r.lstatus);
@@ -1615,18 +1598,16 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring,break ; } - tmp_orig_i = orig_i; - -while (orig_i != i) { -enetc_flip_rx_buff (rx_ring, - &rx_ring->rx_swbd[orig_i]); -enetc_bdr_idx_inc (rx_ring, &orig_i); - } - err =xdp_do_redirect (rx_ring->ndev, &xdp_buff, prog);if (unlikely (err)) { -enetc_xdp_free (rx_ring, tmp_orig_i, i); +enetc_xdp_drop (rx_ring, orig_i, i); + rx_ring->stats.xdp_redirect_failures++; }else { +while (orig_i != i) { +enetc_flip_rx_buff (rx_ring, + &rx_ring->rx_swbd[orig_i]); +enetc_bdr_idx_inc (rx_ring, &orig_i); + } xdp_redirect_frm_cnt++; rx_ring->stats.xdp_redirect++; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 849/1073 nfc: pn533: Clear nfc_target before being used
In reply to Greg Kroah-HartmanFrom: Minsuk Kang <[email protected]>
[ Upstream commit 9f28157778ede0d4f183f7ab3b46995bb400abbe ]
Fix a slab-out-of-bounds read that occurs in nla_put() called from nfc_genl_send_target() when target->sensb_res_len, which is duplicated from an nfc_target in pn533, is too large as the nfc_target is not properly initialized and retains garbage values. Clear nfc_targets with memset() before they are used.
Found by a modified version of syzkaller.
BUG: KASAN: slab-out-of-bounds in nla_put Call Trace: memcpy nla_put nfc_genl_dump_targets genl_lock_dumpit netlink_dump __netlink_dump_start genl_family_rcv_msg_dumpit genl_rcv_msg netlink_rcv_skb genl_rcv netlink_unicast netlink_sendmsg sock_sendmsg ____sys_sendmsg ___sys_sendmsg __sys_sendmsg do_syscall_64
--- drivers/nfc/pn533/pn533.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/nfc/pn533/pn533.c +4 -0
@@ -1295,6 +1295,8 @@ static int pn533_poll_dep_complete(struct pn533 *dev, void *arg,if (IS_ERR (resp))return PTR_ERR (resp); +memset (&nfc_target,0 ,sizeof (struct nfc_target )); + rsp = (struct pn533_cmd_jump_dep_response *)resp->data; rc = rsp->status &PN533_CMD_RET_MASK ;
@@ -1926,6 +1928,8 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg,dev_dbg (dev->dev,"Creating new target\n" ); +memset (&nfc_target,0 ,sizeof (struct nfc_target )); + nfc_target.supported_protocols =NFC_PROTO_NFC_DEP_MASK ; nfc_target.nfcid1_len =10 ;memcpy (nfc_target.nfcid1, rsp->nfcid3t, nfc_target.nfcid1_len);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 850/1073 unix: Fix race in SOCK_SEQPACKETs unix_dgram_sendmsg()
In reply to Greg Kroah-HartmanFrom: Kirill Tkhai <[email protected]>
[ Upstream commit 3ff8bff704f4de125dca2262e5b5b963a3da1d87 ]
There is a race resulting in alive SOCK_SEQPACKET socket may change its state from TCP_ESTABLISHED to TCP_CLOSE:
unix_release_sock(peer) unix_dgram_sendmsg(sk)
sock_orphan(peer)
sock_set_flag(peer, SOCK_DEAD)
sock_alloc_send_pskb()
if !(sk->sk_shutdown & SEND_SHUTDOWN)
OK
if sock_flag(peer, SOCK_DEAD)
sk->sk_state = TCP_CLOSE sk->sk_shutdown = SHUTDOWN_MASK
After that socket sk remains almost normal: it is able to connect, listen, accept and recvmsg, while it can't sendmsg.
Since this is the only possibility for alive SOCK_SEQPACKET to change the state in such way, we should better fix this strange and potentially danger corner case.
Note, that we will return EPIPE here like this is normally done in sock_alloc_send_pskb(). Originally used ECONNREFUSED looks strange, since it's strange to return
a specific retval in dependence of race in kernel, when user can't affect on this.
Also, move TCP_CLOSE assignment for SOCK_DGRAM sockets under state lock to fix race with unix_dgram_connect():
unix_dgram_connect(other) unix_dgram_sendmsg(sk)
unix_peer(sk) = NULL unix_state_unlock(sk)
unix_state_double_lock(sk, other)
sk->sk_state = TCP_ESTABLISHED
unix_peer(sk) = other unix_state_double_unlock(sk, other)
sk->sk_state = TCP_CLOSED
This patch fixes both of these races.
--- net/unix/af_unix.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/unix/af_unix.c +9 -2
@@ -1969,13 +1969,20 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,unix_state_lock (sk); err =0 ; -if (unix_peer (sk) == other) { +if (sk->sk_type ==SOCK_SEQPACKET ) { +/* We are here only when racing with unix_release_sock() +* is clearing @other. Never change state to TCP_CLOSE +* unlike SOCK_DGRAM wants. +*/ +unix_state_unlock (sk); + err = -EPIPE ; + }else if (unix_peer (sk) == other) {unix_peer (sk) =NULL ;unix_dgram_peer_wake_disconnect_wakeup (sk, other); + sk->sk_state =TCP_CLOSE ;unix_state_unlock (sk); - sk->sk_state =TCP_CLOSE ;unix_dgram_disconnected (sk, other);sock_put (other); err = -ECONNREFUSED ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 851/1073 r6040: Fix kmemleak in probe and remove
In reply to Greg Kroah-HartmanFrom: Li Zetao <[email protected]>
[ Upstream commit 7e43039a49c2da45edc1d9d7c9ede4003ab45a5f ]
There is a memory leaks reported by kmemleak:
unreferenced object 0xffff888116111000 (size 2048):
comm "modprobe", pid 817, jiffies 4294759745 (age 76.502s)
hex dump (first 32 bytes):
00 c4 0a 04 81 88 ff ff 08 10 11 16 81 88 ff ff ................
08 10 11 16 81 88 ff ff 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff815bcd82>] kmalloc_trace+0x22/0x60
[<ffffffff827e20ee>] phy_device_create+0x4e/0x90
[<ffffffff827e6072>] get_phy_device+0xd2/0x220
[<ffffffff827e7844>] mdiobus_scan+0xa4/0x2e0
[<ffffffff827e8be2>] __mdiobus_register+0x482/0x8b0
[<ffffffffa01f5d24>] r6040_init_one+0x714/0xd2c [r6040]
...The problem occurs in probe process as follows:
r6040_init_one:
mdiobus_register
mdiobus_scan <- alloc and register phy_device,
the reference count of phy_device is 3
r6040_mii_probe
phy_connect <- connect to the first phy_device,
so the reference count of the first phy_device is 4, others are 3
register_netdev <- fault inject succeeded, goto error handling path
// error handling path
err_out_mdio_unregister:
mdiobus_unregister(lp->mii_bus);
err_out_mdio:
mdiobus_free(lp->mii_bus); <- the reference count of the first
phy_device is 1, it is not released and other phy_devices are released
// similarly, the remove process also has the same problem
The root cause is traced to the phy_device is not disconnected when removes one r6040 device in r6040_remove_one() or on error handling path after r6040_mii probed successfully. In r6040_mii_probe(), a net ethernet device is connected to the first PHY device of mii_bus, in order to notify the connected driver when the link status changes, which is the default behavior of the PHY infrastructure to handle everything. Therefore the phy_device should be disconnected when removes one r6040 device or on error handling path.
Fix it by adding phy_disconnect() when removes one r6040 device or on error handling path after r6040_mii probed successfully.
--- drivers/net/ethernet/rdc/r6040.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/rdc/r6040.c +4 -1
@@ -1159,10 +1159,12 @@ static int r6040_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) err =register_netdev (dev);if (err) {dev_err (&pdev->dev,"Failed to register net device\n" ); - goto err_out_mdio_unregister; + goto err_out_phy_disconnect; }return 0 ; +err_out_phy_disconnect: +phy_disconnect (dev->phydev); err_out_mdio_unregister:mdiobus_unregister (lp->mii_bus); err_out_mdio:
@@ -1186,6 +1188,7 @@ static void r6040_remove_one(struct pci_dev *pdev)struct r6040_private *lp =netdev_priv (dev);unregister_netdev (dev); +phy_disconnect (dev->phydev);mdiobus_unregister (lp->mii_bus);mdiobus_free (lp->mii_bus);netif_napi_del (&lp->napi);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 852/1073 blk-iocost: simplify ioc_name
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 9df3e65139b923dfe98f76b7057882c7afb2d3e4 ]
Just directly dereference the disk name instead of going through multiple hoops to find the same value.
Stable-dep-of: d36a9ea5e776 ("block: fix use-after-free of q->q_usage_counter")
--- block/blk-iocost.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
block/blk-iocost.c +5 -9
@@ -664,17 +664,13 @@ static struct ioc *q_to_ioc(struct request_queue *q)return rqos_to_ioc (rq_qos_id (q,RQ_QOS_COST )); } -static const char *q_name (struct request_queue *q) -{ -if (blk_queue_registered (q)) -return kobject_name (q->kobj.parent); -else -return "<unknown>" ; -} -static const char __maybe_unused *ioc_name (struct ioc *ioc) { -return q_name (ioc->rqos.q); +struct gendisk *disk = ioc->rqos.q->disk; + +if (!disk) +return "<unknown>" ; +return disk->disk_name; }static struct ioc_gq *pd_to_iocg (struct blkg_policy_data *pd)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 853/1073 blk-mq: move the srcu_struct used for quiescing to the tagset
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 80bd4a7aab4c9ce59bf5e35fdf52aa23d8a3c9f5 ]
All I/O submissions have fairly similar latencies, and a tagset-wide quiesce is a fairly common operation.
Stable-dep-of: d36a9ea5e776 ("block: fix use-after-free of q->q_usage_counter")
--- block/blk-core.c | 27 +++++---------------------- block/blk-mq.c | 33 +++++++++++++++++++++++++-------- block/blk-mq.h | 14 +++++++------- block/blk-sysfs.c | 9 ++------- block/blk.h | 9 +-------- block/genhd.c | 2 +- include/linux/blk-mq.h | 4 ++++ include/linux/blkdev.h | 9 --------- 8 files changed, 45 insertions(+), 62 deletions(-)
block/blk-core.c +5 -22
@@ -66,7 +66,6 @@ DEFINE_IDA(blk_queue_ida);* For queue allocation */ struct kmem_cache *blk_requestq_cachep; -struct kmem_cache *blk_requestq_srcu_cachep;/* * Controlling structure to kblockd
@@ -374,26 +373,20 @@ static void blk_timeout_work(struct work_struct *work) { } -struct request_queue *blk_alloc_queue (int node_id,bool alloc_srcu) +struct request_queue *blk_alloc_queue (int node_id) {struct request_queue *q; - q =kmem_cache_alloc_node (blk_get_queue_kmem_cache (alloc_srcu), -GFP_KERNEL | __GFP_ZERO, node_id); + q =kmem_cache_alloc_node (blk_requestq_cachep,GFP_KERNEL | __GFP_ZERO, + node_id);if (!q)return NULL ; -if (alloc_srcu) { -blk_queue_flag_set (QUEUE_FLAG_HAS_SRCU , q); -if (init_srcu_struct (q->srcu) !=0 ) - goto fail_q; - } - q->last_merge =NULL ; q->id =ida_alloc (&blk_queue_ida,GFP_KERNEL );if (q->id <0 ) - goto fail_srcu; + goto fail_q; q->stats =blk_alloc_queue_stats ();if (!q->stats)
@@ -435,11 +428,8 @@ struct request_queue *blk_alloc_queue(int node_id, bool alloc_srcu)blk_free_queue_stats (q->stats); fail_id:ida_free (&blk_queue_ida, q->id); -fail_srcu: -if (alloc_srcu) -cleanup_srcu_struct (q->srcu); fail_q: -kmem_cache_free (blk_get_queue_kmem_cache (alloc_srcu), q); +kmem_cache_free (blk_requestq_cachep, q);return NULL ; }
@@ -1198,9 +1188,6 @@ int __init blk_dev_init(void) sizeof_field(struct request, cmd_flags));BUILD_BUG_ON (REQ_OP_BITS +REQ_FLAG_BITS >8 * sizeof_field(struct bio, bi_opf)); -BUILD_BUG_ON (ALIGN (offsetof(struct request_queue , srcu), - __alignof__(struct request_queue )) != -sizeof (struct request_queue ));/* used for unplugging and affects IO latency/throughput - HIGHPRI */ kblockd_workqueue = alloc_workqueue("kblockd",
@@ -1211,10 +1198,6 @@ int __init blk_dev_init(void) blk_requestq_cachep =kmem_cache_create ("request_queue" ,sizeof (struct request_queue ),0 ,SLAB_PANIC ,NULL ); - blk_requestq_srcu_cachep =kmem_cache_create ("request_queue_srcu" , -sizeof (struct request_queue ) + -sizeof (struct srcu_struct ),0 ,SLAB_PANIC ,NULL ); - blk_debugfs_root =debugfs_create_dir ("block" ,NULL );return 0 ;
block/blk-mq.c +25 -8
@@ -261,8 +261,8 @@ EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue_nowait);*/ void blk_mq_wait_quiesce_done (struct request_queue *q) { -if (blk_queue_has_srcu (q)) -synchronize_srcu (q->srcu); +if (q->tag_set->flags &BLK_MQ_F_BLOCKING ) +synchronize_srcu (q->tag_set->srcu);else synchronize_rcu (); }
@@ -3886,7 +3886,7 @@ static struct request_queue *blk_mq_init_queue_data(struct blk_mq_tag_set *set,struct request_queue *q;int ret; - q =blk_alloc_queue (set->numa_node, set->flags &BLK_MQ_F_BLOCKING ); + q =blk_alloc_queue (set->numa_node);if (!q)return ERR_PTR (-ENOMEM ); q->queuedata = queuedata;
@@ -4058,9 +4058,6 @@ static void blk_mq_update_poll_flag(struct request_queue *q)int blk_mq_init_allocated_queue (struct blk_mq_tag_set *set,struct request_queue *q) { -WARN_ON_ONCE (blk_queue_has_srcu (q) != - !!(set->flags &BLK_MQ_F_BLOCKING )); -/* mark the queue as mq asap */ q->mq_ops = set->ops;
@@ -4317,8 +4314,18 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)if (set->nr_maps ==1 && set->nr_hw_queues > nr_cpu_ids) set->nr_hw_queues = nr_cpu_ids; -if (blk_mq_alloc_tag_set_tags (set, set->nr_hw_queues) <0 ) -return -ENOMEM ; +if (set->flags &BLK_MQ_F_BLOCKING ) { + set->srcu =kmalloc (sizeof (*set->srcu),GFP_KERNEL ); +if (!set->srcu) +return -ENOMEM ; + ret =init_srcu_struct (set->srcu); +if (ret) + goto out_free_srcu; + } + + ret =blk_mq_alloc_tag_set_tags (set, set->nr_hw_queues); +if (ret) + goto out_cleanup_srcu; ret = -ENOMEM ;for (i =0 ; i < set->nr_maps; i++) {
@@ -4350,6 +4357,12 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set) }kfree (set->tags); set->tags =NULL ; +out_cleanup_srcu: +if (set->flags &BLK_MQ_F_BLOCKING ) +cleanup_srcu_struct (set->srcu); +out_free_srcu: +if (set->flags &BLK_MQ_F_BLOCKING ) +kfree (set->srcu);return ret; }EXPORT_SYMBOL (blk_mq_alloc_tag_set);
@@ -4389,6 +4402,10 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set)kfree (set->tags); set->tags =NULL ; +if (set->flags &BLK_MQ_F_BLOCKING ) { +cleanup_srcu_struct (set->srcu); +kfree (set->srcu); + } }EXPORT_SYMBOL (blk_mq_free_tag_set);
block/blk-mq.h +7 -7
@@ -376,17 +376,17 @@ static inline bool hctx_may_queue(struct blk_mq_hw_ctx *hctx,/* run the code block in @dispatch_ops with rcu/srcu read lock held */ #define __blk_mq_run_dispatch_ops (q, check_sleep, dispatch_ops) \ do { \ - if (!blk_queue_has_srcu(q)) { \ - rcu_read_lock(); \ - (dispatch_ops); \ - rcu_read_unlock(); \ - } else { \ + if ((q)->tag_set->flags & BLK_MQ_F_BLOCKING) { \ int srcu_idx; \ \ might_sleep_if(check_sleep); \ - srcu_idx = srcu_read_lock((q)->srcu); \ + srcu_idx = srcu_read_lock((q)->tag_set->srcu); \ (dispatch_ops); \ - srcu_read_unlock((q)->srcu, srcu_idx); \ + srcu_read_unlock((q)->tag_set->srcu, srcu_idx); \ + } else { \ + rcu_read_lock(); \ + (dispatch_ops); \ + rcu_read_unlock(); \ } \ } while (0)
block/blk-sysfs.c +2 -7
@@ -739,10 +739,8 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr,static void blk_free_queue_rcu (struct rcu_head *rcu_head) { - struct request_queue *q = container_of(rcu_head, struct request_queue, - rcu_head); - -kmem_cache_free (blk_get_queue_kmem_cache (blk_queue_has_srcu (q)), q); +kmem_cache_free (blk_requestq_cachep, + container_of(rcu_head, struct request_queue, rcu_head)); }/**
@@ -779,9 +777,6 @@ static void blk_release_queue(struct kobject *kobj)if (queue_is_mq (q))blk_mq_release (q); -if (blk_queue_has_srcu (q)) -cleanup_srcu_struct (q->srcu); -ida_free (&blk_queue_ida, q->id);call_rcu (&q->rcu_head, blk_free_queue_rcu); }
block/blk.h +1 -8
@@ -27,7 +27,6 @@ struct blk_flush_queue { };extern struct kmem_cache *blk_requestq_cachep; -extern struct kmem_cache *blk_requestq_srcu_cachep;extern struct kobj_type blk_queue_ktype;extern struct ida blk_queue_ida;
@@ -421,13 +420,7 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio, struct page *page, unsigned int len, unsigned int offset, unsigned int max_sectors, bool *same_page); -static inline struct kmem_cache *blk_get_queue_kmem_cache (bool srcu) -{ -if (srcu) -return blk_requestq_srcu_cachep; -return blk_requestq_cachep; -} -struct request_queue *blk_alloc_queue (int node_id,bool alloc_srcu); +struct request_queue *blk_alloc_queue (int node_id);int disk_scan_partitions (struct gendisk *disk,fmode_t mode);
block/genhd.c +1 -1
@@ -1402,7 +1402,7 @@ struct gendisk *__blk_alloc_disk(int node, struct lock_class_key *lkclass)struct request_queue *q;struct gendisk *disk; - q =blk_alloc_queue (node, false); + q =blk_alloc_queue (node);if (!q)return NULL ;
include/linux/blk-mq.h +4 -0
@@ -7,6 +7,7 @@#include <linux/lockdep.h> #include <linux/scatterlist.h> #include <linux/prefetch.h> +#include <linux/srcu.h> struct blk_mq_tags ;struct blk_flush_queue ;
@@ -496,6 +497,8 @@ enum hctx_type {* @tag_list_lock: Serializes tag_list accesses. * @tag_list: List of the request queues that use this tag set. See also * request_queue.tag_set_list. +* @srcu: Use as lock when type of the request queue is blocking +* (BLK_MQ_F_BLOCKING). */ struct blk_mq_tag_set {struct blk_mq_queue_map map[HCTX_MAX_TYPES ];
@@ -516,6 +519,7 @@ struct blk_mq_tag_set {struct mutex tag_list_lock;struct list_head tag_list; +struct srcu_struct *srcu; };/**
include/linux/blkdev.h +0 -9
@@ -22,7 +22,6 @@#include <linux/blkzoned.h> #include <linux/sched.h> #include <linux/sbitmap.h> -#include <linux/srcu.h> #include <linux/uuid.h> #include <linux/xarray.h>
@@ -544,18 +543,11 @@ struct request_queue {struct mutex debugfs_mutex;bool mq_sysfs_init_done; - -/** -* @srcu: Sleepable RCU. Use as lock when type of the request queue -* is blocking (BLK_MQ_F_BLOCKING). Must be the last member -*/ -struct srcu_struct srcu[]; };/* Keep blk_queue_flag_name[] in sync with the definitions below */ #define QUEUE_FLAG_STOPPED 0/* queue is stopped */ #define QUEUE_FLAG_DYING 1/* queue being torn down */ -#define QUEUE_FLAG_HAS_SRCU 2/* SRCU is allocated */ #define QUEUE_FLAG_NOMERGES 3/* disable merge attempts */ #define QUEUE_FLAG_SAME_COMP 4/* complete on same CPU-group */ #define QUEUE_FLAG_FAIL_IO 5/* fake timeout */
@@ -591,7 +583,6 @@ bool blk_queue_flag_test_and_set(unsigned int flag, struct request_queue *q);#define blk_queue_stopped (q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags)#define blk_queue_dying (q) test_bit(QUEUE_FLAG_DYING, &(q)->queue_flags) -#define blk_queue_has_srcu (q) test_bit(QUEUE_FLAG_HAS_SRCU, &(q)->queue_flags)#define blk_queue_init_done (q) test_bit(QUEUE_FLAG_INIT_DONE, &(q)->queue_flags)#define blk_queue_nomerges (q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags)#define blk_queue_noxmerges (q) \
Signature · 1 line
2.35.1
Re: [PATCH 6.0 0853/1073] blk-mq: move the srcu_struct used for quiescing to the tagset
Quoted 17 lines · Greg Kroah-Hartman
From: Christoph Hellwig <[email protected]>
[ Upstream commit
80bd4a7aab4c9ce59bf5e35fdf52aa23d8a3c9f5]All I/O submissions have fairly similar latencies, and a tagset-wide quiesce is a fairly common operation.
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Keith Busch <[email protected]>Reviewed-by Ming Lei <[email protected]>Reviewed-by Chao Leng <[email protected]>Reviewed-by Sagi Grimberg <[email protected]>Reviewed-by Hannes Reinecke <[email protected]>Reviewed-by Chaitanya Kulkarni <[email protected]>[axboe: fix whitespace]Signed-off-by Jens Axboe <[email protected]>
Quoted 2 lines
Stable-dep-of:
d36a9ea5e776("block: fix use-after-free ofq->q_usage_counter")Signed-off-by Sasha Levin <[email protected]>
commit 8537380bb988 ("blk-mq: skip non-mq queues in blk_mq_quiesce_queue") is required for backporting this patch, otherwise kernel panic can be triggered.
Thanks,
Ming
Greg Kroah-Hartman
maintainerRe: [PATCH 6.0 0853/1073] blk-mq: move the srcu_struct used for quiescing to the tagset
Quoted 21 lines · Ming Lei
Quoted 17 lines · Greg Kroah-Hartman
From: Christoph Hellwig <[email protected]>
[ Upstream commit
80bd4a7aab4c9ce59bf5e35fdf52aa23d8a3c9f5]All I/O submissions have fairly similar latencies, and a tagset-wide quiesce is a fairly common operation.
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Keith Busch <[email protected]>Reviewed-by Ming Lei <[email protected]>Reviewed-by Chao Leng <[email protected]>Reviewed-by Sagi Grimberg <[email protected]>Reviewed-by Hannes Reinecke <[email protected]>Reviewed-by Chaitanya Kulkarni <[email protected]>[axboe: fix whitespace]Signed-off-by Jens Axboe <[email protected]>Quoted 2 lines
Stable-dep-of:
d36a9ea5e776("block: fix use-after-free ofq->q_usage_counter")Signed-off-by Sasha Levin <[email protected]>
Quoted 3 lines
commit
8537380bb988("blk-mq: skip non-mq queues inblk_mq_quiesce_queue") is required for backporting this patch, otherwise kernel panic can be triggered.
I've dropped this commit from the queues for now until they can be brought all back in in a clean way.
thanks,
greg k-h
Greg Kroah-Hartman
maintainerPATCH 854/1073 blk-crypto: pass a gendisk to blk_crypto_sysfs_{,un}register
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 450deb93df7d457cdd93594a1987f9650c749b96 ]
Prepare for changes to the block layer sysfs handling by passing the readily available gendisk to blk_crypto_sysfs_{,un}register.
Stable-dep-of: d36a9ea5e776 ("block: fix use-after-free of q->q_usage_counter")
--- block/blk-crypto-internal.h | 10 ++++++---- block/blk-crypto-sysfs.c | 7 ++++--- block/blk-sysfs.c | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-)
block/blk-crypto-internal.h +6 -4
@@ -21,9 +21,9 @@ extern const struct blk_crypto_mode blk_crypto_modes[];#ifdef CONFIG_BLK_INLINE_ENCRYPTION -int blk_crypto_sysfs_register (struct request_queue *q); +int blk_crypto_sysfs_register (struct gendisk *disk); -void blk_crypto_sysfs_unregister (struct request_queue *q); +void blk_crypto_sysfs_unregister (struct gendisk *disk);void bio_crypt_dun_increment (u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE ],unsigned int inc);
@@ -67,12 +67,14 @@ static inline bool blk_crypto_rq_is_encrypted(struct request *rq)#else /* CONFIG_BLK_INLINE_ENCRYPTION */ -static inline int blk_crypto_sysfs_register (struct request_queue *q) +static inline int blk_crypto_sysfs_register (struct gendisk *disk) {return 0 ; } -static inline void blk_crypto_sysfs_unregister (struct request_queue *q) { } +static inline void blk_crypto_sysfs_unregister (struct gendisk *disk) +{ +}static inline bool bio_crypt_rq_ctx_compatible (struct request *rq,struct bio *bio)
block/blk-crypto-sysfs.c +4 -3
@@ -126,8 +126,9 @@ static struct kobj_type blk_crypto_ktype = {* If the request_queue has a blk_crypto_profile, create the "crypto" * subdirectory in sysfs (/sys/block/$disk/queue/crypto/). */ -int blk_crypto_sysfs_register (struct request_queue *q) +int blk_crypto_sysfs_register (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct blk_crypto_kobj *obj;int err;
@@ -149,9 +150,9 @@ int blk_crypto_sysfs_register(struct request_queue *q)return 0 ; } -void blk_crypto_sysfs_unregister (struct request_queue *q) +void blk_crypto_sysfs_unregister (struct gendisk *disk) { -kobject_put (q->crypto_kobject); +kobject_put (disk->queue->crypto_kobject); }static int __init blk_crypto_sysfs_init (void )
block/blk-sysfs.c +2 -2
@@ -833,7 +833,7 @@ int blk_register_queue(struct gendisk *disk) goto put_dev; } - ret =blk_crypto_sysfs_register (q); + ret =blk_crypto_sysfs_register (disk);if (ret) goto put_dev;
@@ -910,7 +910,7 @@ void blk_unregister_queue(struct gendisk *disk)*/ if (queue_is_mq (q))blk_mq_sysfs_unregister (disk); -blk_crypto_sysfs_unregister (q); +blk_crypto_sysfs_unregister (disk);mutex_lock (&q->sysfs_lock);elv_unregister_queue (q);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 855/1073 block: factor out a blk_debugfs_remove helper
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 6fc75f309d291d328b4ea2f91bef0ff56e4bc7c2 ]
Split the debugfs removal from blk_unregister_queue into a helper so that the it can be reused for blk_register_queue error handling.
Stable-dep-of: d36a9ea5e776 ("block: fix use-after-free of q->q_usage_counter")
--- block/blk-sysfs.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
block/blk-sysfs.c +14 -7
@@ -797,6 +797,19 @@ struct kobj_type blk_queue_ktype = { .release = blk_release_queue, }; +static void blk_debugfs_remove (struct gendisk *disk) +{ +struct request_queue *q = disk->queue; + +mutex_lock (&q->debugfs_mutex); +blk_trace_shutdown (q); +debugfs_remove_recursive (q->debugfs_dir); + q->debugfs_dir =NULL ; + q->sched_debugfs_dir =NULL ; + q->rqos_debugfs_dir =NULL ; +mutex_unlock (&q->debugfs_mutex); +} +/** * blk_register_queue - register a block layer queue with sysfs * @disk: Disk of which the request queue should be registered with sysfs.
@@ -922,11 +935,5 @@ void blk_unregister_queue(struct gendisk *disk)kobject_del (&q->kobj);mutex_unlock (&q->sysfs_dir_lock); -mutex_lock (&q->debugfs_mutex); -blk_trace_shutdown (q); -debugfs_remove_recursive (q->debugfs_dir); - q->debugfs_dir =NULL ; - q->sched_debugfs_dir =NULL ; - q->rqos_debugfs_dir =NULL ; -mutex_unlock (&q->debugfs_mutex); +blk_debugfs_remove (disk); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 856/1073 block: fix error unwinding in blk_register_queue
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 40602997be26887bdfa3d58659c3acb4579099e9 ]
blk_register_queue fails to handle errors from blk_mq_sysfs_register, leaks various resources on errors and accidentally sets queue refs percpu refcount to percpu mode on kobject_add failure. Fix all that by properly unwinding on errors.
Stable-dep-of: d36a9ea5e776 ("block: fix use-after-free of q->q_usage_counter")
--- block/blk-sysfs.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
block/blk-sysfs.c +16 -12
@@ -820,13 +820,15 @@ int blk_register_queue(struct gendisk *disk)int ret;mutex_lock (&q->sysfs_dir_lock); - ret =kobject_add (&q->kobj, &disk_to_dev (disk)->kobj,"queue" );if (ret <0 ) - goto unlock; + goto out_unlock_dir; -if (queue_is_mq (q)) -blk_mq_sysfs_register (disk); +if (queue_is_mq (q)) { + ret =blk_mq_sysfs_register (disk); +if (ret) + goto out_del_queue_kobj; + }mutex_lock (&q->sysfs_lock);mutex_lock (&q->debugfs_mutex);
@@ -838,17 +840,17 @@ int blk_register_queue(struct gendisk *disk) ret =disk_register_independent_access_ranges (disk);if (ret) - goto put_dev; + goto out_debugfs_remove;if (q->elevator) { ret =elv_register_queue (q, false);if (ret) - goto put_dev; + goto out_unregister_ia_ranges; } ret =blk_crypto_sysfs_register (disk);if (ret) - goto put_dev; + goto out_elv_unregister;blk_queue_flag_set (QUEUE_FLAG_REGISTERED , q);wbt_enable_default (q);
@@ -859,8 +861,6 @@ int blk_register_queue(struct gendisk *disk)if (q->elevator)kobject_uevent (&q->elevator->kobj,KOBJ_ADD );mutex_unlock (&q->sysfs_lock); - -unlock:mutex_unlock (&q->sysfs_dir_lock);/*
@@ -879,13 +879,17 @@ int blk_register_queue(struct gendisk *disk)return ret; -put_dev: +out_elv_unregister:elv_unregister_queue (q); +out_unregister_ia_ranges:disk_unregister_independent_access_ranges (disk); +out_debugfs_remove: +blk_debugfs_remove (disk);mutex_unlock (&q->sysfs_lock); -mutex_unlock (&q->sysfs_dir_lock); +out_del_queue_kobj:kobject_del (&q->kobj); - +out_unlock_dir: +mutex_unlock (&q->sysfs_dir_lock);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 857/1073 block: untangle request_queue refcounting from sysfs
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 2bd85221a625b316114bafaab527770b607095d3 ]
The kobject embedded into the request_queue is used for the queue directory in sysfs, but that is a child of the gendisks directory and is intimately tied to it. Move this kobject to the gendisk and use a refcount_t in the request_queue for the actual request_queue refcounting that is completely unrelated to the device model.
Stable-dep-of: d36a9ea5e776 ("block: fix use-after-free of q->q_usage_counter")
--- block/blk-core.c | 42 ++++++++++++++++---- block/blk-crypto-sysfs.c | 4 +- block/blk-ia-ranges.c | 3 +- block/blk-sysfs.c | 86 +++++++++++----------------------------- block/blk.h | 4 -- block/bsg.c | 11 +++-- block/elevator.c | 2 +- include/linux/blkdev.h | 6 +-- 8 files changed, 71 insertions(+), 87 deletions(-)
block/blk-core.c +34 -8
@@ -60,12 +60,12 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(block_split);EXPORT_TRACEPOINT_SYMBOL_GPL (block_unplug);EXPORT_TRACEPOINT_SYMBOL_GPL (block_rq_insert); -DEFINE_IDA (blk_queue_ida); +static DEFINE_IDA (blk_queue_ida);/* * For queue allocation */ -struct kmem_cache *blk_requestq_cachep; +static struct kmem_cache *blk_requestq_cachep;/* * Controlling structure to kblockd
@@ -253,19 +253,46 @@ void blk_clear_pm_only(struct request_queue *q) }EXPORT_SYMBOL_GPL (blk_clear_pm_only); +static void blk_free_queue_rcu (struct rcu_head *rcu_head) +{ +kmem_cache_free (blk_requestq_cachep, + container_of(rcu_head, struct request_queue, rcu_head)); +} + +static void blk_free_queue (struct request_queue *q) +{ +might_sleep (); + +percpu_ref_exit (&q->q_usage_counter); + +if (q->poll_stat) +blk_stat_remove_callback (q, q->poll_cb); +blk_stat_free_callback (q->poll_cb); + +blk_free_queue_stats (q->stats); +kfree (q->poll_stat); + +if (queue_is_mq (q)) +blk_mq_release (q); + +ida_free (&blk_queue_ida, q->id); +call_rcu (&q->rcu_head, blk_free_queue_rcu); +} +/** * blk_put_queue - decrement the request_queue refcount * @q: the request_queue structure to decrement the refcount for * -* Decrements the refcount of the request_queue kobject. When this reaches 0 -* we'll have blk_release_queue() called. +* Decrements the refcount of the request_queue and free it when the refcount +* reaches 0. * * Context: Any context, but the last reference must not be dropped from * atomic context. */ void blk_put_queue (struct request_queue *q) { -kobject_put (&q->kobj); +if (refcount_dec_and_test (&q->refs)) +blk_free_queue (q); }EXPORT_SYMBOL (blk_put_queue);
@@ -400,8 +427,7 @@ struct request_queue *blk_alloc_queue(int node_id)INIT_WORK (&q->timeout_work, blk_timeout_work);INIT_LIST_HEAD (&q->icq_list); -kobject_init (&q->kobj, &blk_queue_ktype); - +refcount_set (&q->refs,1 );mutex_init (&q->debugfs_mutex);mutex_init (&q->sysfs_lock);mutex_init (&q->sysfs_dir_lock);
@@ -445,7 +471,7 @@ bool blk_get_queue(struct request_queue *q) {if (unlikely (blk_queue_dying (q)))return false; -kobject_get (&q->kobj); +refcount_inc (&q->refs);return true; }EXPORT_SYMBOL (blk_get_queue);
block/blk-crypto-sysfs.c +2 -2
@@ -140,8 +140,8 @@ int blk_crypto_sysfs_register(struct gendisk *disk)return -ENOMEM ; obj->profile = q->crypto_profile; - err =kobject_init_and_add (&obj->kobj, &blk_crypto_ktype, &q->kobj, -"crypto" ); + err =kobject_init_and_add (&obj->kobj, &blk_crypto_ktype, + &disk->queue_kobj,"crypto" );if (err) {kobject_put (&obj->kobj);return err;
block/blk-ia-ranges.c +2 -1
@@ -123,7 +123,8 @@ int disk_register_independent_access_ranges(struct gendisk *disk)*/ WARN_ON (iars->sysfs_registered); ret =kobject_init_and_add (&iars->kobj, &blk_ia_ranges_ktype, - &q->kobj,"%s" ,"independent_access_ranges" ); + &disk->queue_kobj,"%s" , +"independent_access_ranges" );if (ret) { disk->ia_ranges =NULL ;kobject_put (&iars->kobj);
block/blk-sysfs.c +23 -63
156 lines not on this page · raw message
block/blk.h +0 -4
@@ -26,10 +26,6 @@ struct blk_flush_queue {spinlock_t mq_flush_lock; }; -extern struct kmem_cache *blk_requestq_cachep; -extern struct kobj_type blk_queue_ktype; -extern struct ida blk_queue_ida; -bool is_flush_rq (struct request *req); struct blk_flush_queue *blk_alloc_flush_queue(int node, int cmd_size,
block/bsg.c +7 -4
@@ -175,8 +175,10 @@ static void bsg_device_release(struct device *dev)void bsg_unregister_queue (struct bsg_device *bd) { -if (bd->queue->kobj.sd) -sysfs_remove_link (&bd->queue->kobj,"bsg" ); +struct gendisk *disk = bd->queue->disk; + +if (disk && disk->queue_kobj.sd) +sysfs_remove_link (&disk->queue_kobj,"bsg" );cdev_device_del (&bd->cdev, &bd->device);put_device (&bd->device); }
@@ -216,8 +218,9 @@ struct bsg_device *bsg_register_queue(struct request_queue *q,if (ret) goto out_put_device; -if (q->kobj.sd) { - ret =sysfs_create_link (&q->kobj, &bd->device.kobj,"bsg" ); +if (q->disk && q->disk->queue_kobj.sd) { + ret =sysfs_create_link (&q->disk->queue_kobj, &bd->device.kobj, +"bsg" );if (ret) goto out_device_del; }
block/elevator.c +1 -1
@@ -499,7 +499,7 @@ int elv_register_queue(struct request_queue *q, bool uevent)lockdep_assert_held (&q->sysfs_lock); - error =kobject_add (&e->kobj, &q->kobj,"%s" ,"iosched" ); + error =kobject_add (&e->kobj, &q->disk->queue_kobj,"iosched" );if (!error) {struct elv_fs_entry *attr = e->type->elevator_attrs;if (attr) {
include/linux/blkdev.h +2 -4
@@ -155,6 +155,7 @@ struct gendisk {unsigned open_partitions;/* number of open partitions */ struct backing_dev_info *bdi; +struct kobject queue_kobj;/* the queue/ directory */ struct kobject *slave_dir;#ifdef CONFIG_BLOCK_HOLDER_DEPRECATED struct list_head slave_bdevs;
@@ -437,10 +438,7 @@ struct request_queue {struct gendisk *disk; -/* -* queue kobject -*/ -struct kobject kobj; +refcount_t refs;/* * mq queue kobject
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 858/1073 block: mark blk_put_queue as potentially blocking
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 63f93fd6fa5717769a78d6d7bea6f7f9a1ccca8e ]
We can't just say that the last reference release may block, as any reference dropped could be the last one. So move the might_sleep() from blk_free_queue to blk_put_queue and update the documentation.
Stable-dep-of: d36a9ea5e776 ("block: fix use-after-free of q->q_usage_counter")
--- block/blk-core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
block/blk-core.c +2 -4
@@ -261,8 +261,6 @@ static void blk_free_queue_rcu(struct rcu_head *rcu_head)static void blk_free_queue (struct request_queue *q) { -might_sleep (); -percpu_ref_exit (&q->q_usage_counter);if (q->poll_stat)
@@ -286,11 +284,11 @@ static void blk_free_queue(struct request_queue *q)* Decrements the refcount of the request_queue and free it when the refcount * reaches 0. * -* Context: Any context, but the last reference must not be dropped from -* atomic context. +* Context: Can sleep. */ void blk_put_queue (struct request_queue *q) { +might_sleep ();if (refcount_dec_and_test (&q->refs))blk_free_queue (q); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 859/1073 block: fix use-after-free of q->q_usage_counter
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit d36a9ea5e7766961e753ee38d4c331bbe6ef659b ]
For blk-mq, queue release handler is usually called after blk_mq_freeze_queue_wait() returns. However, the q_usage_counter->release() handler may not be run yet at that time, so this can cause a use-after-free.
Fix the issue by moving percpu_ref_exit() into blk_free_queue_rcu(). Since ->release() is called with rcu read lock held, it is agreed that the race should be covered in caller per discussion from the two links.
--- block/blk-core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
block/blk-core.c +5 -4
@@ -255,14 +255,15 @@ EXPORT_SYMBOL_GPL(blk_clear_pm_only);static void blk_free_queue_rcu (struct rcu_head *rcu_head) { -kmem_cache_free (blk_requestq_cachep, - container_of(rcu_head, struct request_queue, rcu_head)); +struct request_queue *q =container_of (rcu_head, + struct request_queue, rcu_head); + +percpu_ref_exit (&q->q_usage_counter); +kmem_cache_free (blk_requestq_cachep, q); }static void blk_free_queue (struct request_queue *q) { -percpu_ref_exit (&q->q_usage_counter); -if (q->poll_stat)blk_stat_remove_callback (q, q->poll_cb);blk_stat_free_callback (q->poll_cb);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 860/1073 net: dsa: mv88e6xxx: avoid reg_lock deadlock in mv88e6xxx_setup_port()
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit a7d82367daa6baa5e8399e6327e7f2f463534505 ]
In the blamed commit, it was not noticed that one implementation of chip->info->ops->phylink_get_caps(), called by mv88e6xxx_get_caps(), may access hardware registers, and in doing so, it takes the mv88e6xxx_reg_lock(). Namely, this is mv88e6352_phylink_get_caps().
This is a problem because mv88e6xxx_get_caps(), apart from being a top-level function (method invoked by dsa_switch_ops), is now also directly called from mv88e6xxx_setup_port(), which runs under the mv88e6xxx_reg_lock() taken by mv88e6xxx_setup(). Therefore, when running on mv88e6352, the reg_lock would be acquired a second time and the system would deadlock on driver probe.
The things that mv88e6xxx_setup() can compete with in terms of register access with are the IRQ handlers and MDIO bus operations registered by mv88e6xxx_probe(). So there is a real need to acquire the register lock.
The register lock can, in principle, be dropped and re-acquired pretty much at will within the driver, as long as no operations that involve waiting for indirect access to complete (essentially, callers of mv88e6xxx_smi_direct_wait() and mv88e6xxx_wait_mask()) are interrupted with the lock released. However, I would guess that in mv88e6xxx_setup(), the critical section is kept open for such a long time just in order to optimize away multiple lock/unlock operations on the registers.
We could, in principle, drop the reg_lock right before the mv88e6xxx_setup_port() -> mv88e6xxx_get_caps() call, and re-acquire it immediately afterwards. But this would look ugly, because mv88e6xxx_setup_port() would release a lock which it didn't acquire, but the caller did.
A cleaner solution to this issue comes from the observation that struct mv88e6xxxx_ops methods generally assume they are called with the reg_lock already acquired. Whereas mv88e6352_phylink_get_caps() is more the exception rather than the norm, in that it acquires the lock itself.
Let's enforce the same locking pattern/convention for chip->info->ops->phylink_get_caps() as well, and make mv88e6xxx_get_caps(), the top-level function, acquire the register lock explicitly, for this one implementation that will access registers for port 4 to work properly.
This means that mv88e6xxx_setup_port() will no longer call the top-level function, but the low-level mv88e6xxx_ops method which expects the correct calling context (register lock held).
Compared to chip->info->ops->phylink_get_caps(), mv88e6xxx_get_caps() also fixes up the supported_interfaces bitmap for internal ports, since that can be done generically and does not require per-switch knowledge. That's code which will no longer execute, however mv88e6xxx_setup_port() doesn't need that. It just needs to look at the mac_capabilities bitmap.
--- drivers/net/dsa/mv88e6xxx/chip.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +4 -5
@@ -689,13 +689,12 @@ static void mv88e6352_phylink_get_caps(struct mv88e6xxx_chip *chip, int port,/* Port 4 supports automedia if the serdes is associated with it. */ if (port ==4 ) { -mv88e6xxx_reg_lock (chip); err =mv88e6352_g2_scratch_port_has_serdes (chip, port);if (err <0 )dev_err (chip->dev,"p%d: failed to read scratch\n" , port);if (err <=0 ) - goto unlock; +return ; cmode =mv88e6352_get_port4_serdes_cmode (chip);if (cmode <0 )
@@ -703,8 +702,6 @@ static void mv88e6352_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, port); elsemv88e6xxx_translate_cmode (cmode ,supported ); -unlock: -mv88e6xxx_reg_unlock (chip); } }
@@ -823,7 +820,9 @@ static void mv88e6xxx_get_caps(struct dsa_switch *ds, int port, {struct mv88e6xxx_chip *chip = ds->priv; +mv88e6xxx_reg_lock (chip); chip->info->ops->phylink_get_caps (chip, port, config); +mv88e6xxx_reg_unlock (chip);if (mv88e6xxx_phy_is_internal (ds, port)) { __set_bit(PHY_INTERFACE_MODE_INTERNAL,
@@ -3299,7 +3298,7 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)struct phylink_config pl_config = {};unsigned long caps; -mv88e6xxx_get_caps (ds, port, &pl_config); + chip->info->ops->phylink_get_caps (chip, port, &pl_config); caps = pl_config.mac_capabilities;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 861/1073 igc: Enhance Qbv scheduling by using first flag bit
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit db0b124f02ba68de6517ac303d431af220ccfe9f ]
The I225 hardware has a limitation that packets can only be scheduled in the [0, cycle-time] interval. So, scheduling a packet to the start of the next cycle doesn't usually work.
To overcome this, we use the Transmit Descriptor first flag to indicates that a packet should be the first packet (from a queue) in a cycle according to the section 7.5.2.9.3.4 The First Packet on Each QBV Cycle in Intel Discrete I225/6 User Manual.
But this only works if there was any packet from that queue during the current cycle, to avoid this issue, we issue an empty packet if that's not the case. Also require one more descriptor to be available, to take into account the empty packet that might be issued.
Test Setup:
Talker: Use l2_tai to generate the launchtime into packet load.
Listener: Use timedump.c to compute the delta between packet arrival and LaunchTime packet payload.
Test Result:
Before:
1666000610127300000,1666000610127300096,96,621273 1666000610127400000,1666000610127400192,192,621274 1666000610127500000,1666000610127500032,32,621275 1666000610127600000,1666000610127600128,128,621276 1666000610127700000,1666000610127700224,224,621277 1666000610127800000,1666000610127800064,64,621278 1666000610127900000,1666000610127900160,160,621279 1666000610128000000,1666000610128000000,0,621280 1666000610128100000,1666000610128100096,96,621281 1666000610128200000,1666000610128200192,192,621282 1666000610128300000,1666000610128300032,32,621283 1666000610128400000,1666000610128301056,-98944,621284 1666000610128500000,1666000610128302080,-197920,621285 1666000610128600000,1666000610128302848,-297152,621286 1666000610128700000,1666000610128303872,-396128,621287 1666000610128800000,1666000610128304896,-495104,621288 1666000610128900000,1666000610128305664,-594336,621289 1666000610129000000,1666000610128306688,-693312,621290 1666000610129100000,1666000610128307712,-792288,621291 1666000610129200000,1666000610128308480,-891520,621292 1666000610129300000,1666000610128309504,-990496,621293 1666000610129400000,1666000610128310528,-1089472,621294 1666000610129500000,1666000610128311296,-1188704,621295 1666000610129600000,1666000610128312320,-1287680,621296 1666000610129700000,1666000610128313344,-1386656,621297 1666000610129800000,1666000610128314112,-1485888,621298 1666000610129900000,1666000610128315136,-1584864,621299 1666000610130000000,1666000610128316160,-1683840,621300 1666000610130100000,1666000610128316928,-1783072,621301 1666000610130200000,1666000610128317952,-1882048,621302 1666000610130300000,1666000610128318976,-1981024,621303 1666000610130400000,1666000610128319744,-2080256,621304 1666000610130500000,1666000610128320768,-2179232,621305 1666000610130600000,1666000610128321792,-2278208,621306 1666000610130700000,1666000610128322816,-2377184,621307 1666000610130800000,1666000610128323584,-2476416,621308 1666000610130900000,1666000610128324608,-2575392,621309 1666000610131000000,1666000610128325632,-2674368,621310 1666000610131100000,1666000610128326400,-2773600,621311 1666000610131200000,1666000610128327424,-2872576,621312 1666000610131300000,1666000610128328448,-2971552,621313 1666000610131400000,1666000610128329216,-3070784,621314 1666000610131500000,1666000610131500032,32,621315 1666000610131600000,1666000610131600128,128,621316 1666000610131700000,1666000610131700224,224,621317
After:
1666073510646200000,1666073510646200064,64,2676462 1666073510646300000,1666073510646300160,160,2676463 1666073510646400000,1666073510646400256,256,2676464 1666073510646500000,1666073510646500096,96,2676465 1666073510646600000,1666073510646600192,192,2676466 1666073510646700000,1666073510646700032,32,2676467 1666073510646800000,1666073510646800128,128,2676468 1666073510646900000,1666073510646900224,224,2676469 1666073510647000000,1666073510647000064,64,2676470 1666073510647100000,1666073510647100160,160,2676471 1666073510647200000,1666073510647200256,256,2676472 1666073510647300000,1666073510647300096,96,2676473 1666073510647400000,1666073510647400192,192,2676474 1666073510647500000,1666073510647500032,32,2676475 1666073510647600000,1666073510647600128,128,2676476 1666073510647700000,1666073510647700224,224,2676477 1666073510647800000,1666073510647800064,64,2676478 1666073510647900000,1666073510647900160,160,2676479 1666073510648000000,1666073510648000000,0,2676480 1666073510648100000,1666073510648100096,96,2676481 1666073510648200000,1666073510648200192,192,2676482 1666073510648300000,1666073510648300032,32,2676483 1666073510648400000,1666073510648400128,128,2676484 1666073510648500000,1666073510648500224,224,2676485 1666073510648600000,1666073510648600064,64,2676486 1666073510648700000,1666073510648700160,160,2676487 1666073510648800000,1666073510648800000,0,2676488 1666073510648900000,1666073510648900096,96,2676489 1666073510649000000,1666073510649000192,192,2676490 1666073510649100000,1666073510649100032,32,2676491 1666073510649200000,1666073510649200128,128,2676492 1666073510649300000,1666073510649300224,224,2676493 1666073510649400000,1666073510649400064,64,2676494 1666073510649500000,1666073510649500160,160,2676495 1666073510649600000,1666073510649600000,0,2676496 1666073510649700000,1666073510649700096,96,2676497 1666073510649800000,1666073510649800192,192,2676498 1666073510649900000,1666073510649900032,32,2676499 1666073510650000000,1666073510650000128,128,2676500
--- drivers/net/ethernet/intel/igc/igc.h | 2 + drivers/net/ethernet/intel/igc/igc_defines.h | 2 + drivers/net/ethernet/intel/igc/igc_main.c | 176 ++++++++++++++++--- 3 files changed, 151 insertions(+), 29 deletions(-)
drivers/net/ethernet/intel/igc/igc.h +2 -0
@@ -94,6 +94,8 @@ struct igc_ring {u8 queue_index;/* logical index of the ring*/ u8 reg_idx;/* physical index of the ring */ bool launchtime_enable;/* true if LaunchTime is enabled */ +ktime_t last_tx_cycle;/* end of the cycle with a launchtime transmission */ +ktime_t last_ff_cycle;/* Last cycle with an active first flag */ u32 start_time;u32 end_time;
drivers/net/ethernet/intel/igc/igc_defines.h +2 -0
@@ -321,6 +321,8 @@#define IGC_ADVTXD_L4LEN_SHIFT 8/* Adv ctxt L4LEN shift */ #define IGC_ADVTXD_MSS_SHIFT 16/* Adv ctxt MSS shift */ +#define IGC_ADVTXD_TSN_CNTX_FIRST 0x00000080 +/* Transmit Control */ #define IGC_TCTL_EN 0x00000002/* enable Tx */ #define IGC_TCTL_PSP 0x00000008/* pad short packets */
drivers/net/ethernet/intel/igc/igc_main.c +147 -29
252 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 862/1073 igc: Use strict cycles for Qbv scheduling
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit d8f45be01dd9381065a3778a579385249ed011dc ]
Configuring strict cycle mode in the controller forces more well behaved transmissions when taprio is offloaded.
When set this strict_cycle and strict_end, transmission is not enabled if the whole packet cannot be completed before end of the Qbv cycle.
--- drivers/net/ethernet/intel/igc/igc_tsn.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/igc/igc_tsn.c +2 -9
@@ -110,15 +110,8 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)wr32 (IGC_STQT (i), ring->start_time);wr32 (IGC_ENDQT (i), ring->end_time); -if (adapter->base_time) { -/* If we have a base_time we are in "taprio" -* mode and we need to be strict about the -* cycles: only transmit a packet if it can be -* completed during that cycle. -*/ - txqctl |=IGC_TXQCTL_STRICT_CYCLE | -IGC_TXQCTL_STRICT_END ; - } + txqctl |=IGC_TXQCTL_STRICT_CYCLE | +IGC_TXQCTL_STRICT_END ;if (ring->launchtime_enable) txqctl |=IGC_TXQCTL_QUEUE_MODE_LAUNCHT ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 863/1073 igc: Add checking for basetime less than zero
In reply to Greg Kroah-HartmanFrom: Muhammad Husaini Zulkifli <[email protected]>
[ Upstream commit 3b61764fb49a6e147ac90d71dccdddc9d5508ba1 ]
Using the tc qdisc command, the user can set basetime to any value. Checking should be done on the driver's side to prevent registering basetime values that are less than zero.
--- drivers/net/ethernet/intel/igc/igc_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/igc/igc_main.c +3 -0
@@ -6003,6 +6003,9 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter,if (!qopt->enable)return igc_tsn_clear_schedule (adapter); +if (qopt->base_time <0 ) +return -ERANGE ; +if (adapter->base_time)return -EALREADY ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 864/1073 igc: allow BaseTime 0 enrollment for Qbv
In reply to Greg Kroah-HartmanFrom: Tan Tee Min <[email protected]>
[ Upstream commit e17090eb24944fbbe1f24d9f336d7bad4fbe47e8 ]
Introduce qbv_enable flag in igc_adapter struct to store the Qbv on/off. So this allow the BaseTime to enroll with zero value.
--- drivers/net/ethernet/intel/igc/igc.h | 1 + drivers/net/ethernet/intel/igc/igc_main.c | 2 ++ drivers/net/ethernet/intel/igc/igc_tsn.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc.h +1 -0
@@ -184,6 +184,7 @@ struct igc_adapter {ktime_t base_time;ktime_t cycle_time; +bool qbv_enable;/* OS defined structs */ struct pci_dev *pdev;
drivers/net/ethernet/intel/igc/igc_main.c +2 -0
@@ -6000,6 +6000,8 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter,u32 start_time =0 , end_time =0 ;size_t n; + adapter->qbv_enable = qopt->enable; +if (!qopt->enable)return igc_tsn_clear_schedule (adapter);
drivers/net/ethernet/intel/igc/igc_tsn.c +1 -1
@@ -36,7 +36,7 @@ static unsigned int igc_tsn_new_flags(struct igc_adapter *adapter) {unsigned int new_flags = adapter->flags & ~IGC_FLAG_TSN_ANY_ENABLED ; -if (adapter->base_time) +if (adapter->qbv_enable) new_flags |=IGC_FLAG_TSN_QBV_ENABLED ;if (is_any_launchtime (adapter))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 865/1073 igc: recalculate Qbv end_time by considering cycle time
In reply to Greg Kroah-HartmanFrom: Tan Tee Min <[email protected]>
[ Upstream commit 6d05251d537a4d3835959a8cdd8cbbbdcdc0c904 ]
Qbv users can specify a cycle time that is not equal to the total GCL intervals. Hence, recalculation is necessary here to exclude the time interval that exceeds the cycle time. As those GCL which exceeds the cycle time will be truncated.
According to IEEE Std. 802.1Q-2018 section 8.6.9.2, once the end of the list is reached, it will switch to the END_OF_CYCLE state and leave the gates in the same state until the next cycle is started.
--- drivers/net/ethernet/intel/igc/igc_main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/net/ethernet/intel/igc/igc_main.c +15 -0
@@ -6023,6 +6023,21 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter, end_time += e->interval; +/* If any of the conditions below are true, we need to manually +* control the end time of the cycle. +* 1. Qbv users can specify a cycle time that is not equal +* to the total GCL intervals. Hence, recalculation is +* necessary here to exclude the time interval that +* exceeds the cycle time. +* 2. According to IEEE Std. 802.1Q-2018 section 8.6.9.2, +* once the end of the list is reached, it will switch +* to the END_OF_CYCLE state and leave the gates in the +* same state until the next cycle is started. +*/ +if (end_time > adapter->cycle_time || + n +1 == qopt->num_entries) + end_time = adapter->cycle_time; +for (i =0 ; i < adapter->num_tx_queues; i++) {struct igc_ring *ring = adapter->tx_ring[i];
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 866/1073 igc: Set Qbv start_time and end_time to end_time if not being configured in GCL
In reply to Greg Kroah-HartmanFrom: Tan Tee Min <[email protected]>
[ Upstream commit 72abeedd83982c1bc6023f631e412db78374d9b4 ]
The default setting of end_time minus start_time is whole 1 second. Thus, if it's not being configured in any GCL entry then it will be staying at original 1 second.
This patch is changing the start_time and end_time to be end_time as if setting zero will be having weird HW behavior where the gate will not be fully closed.
--- drivers/net/ethernet/intel/igc/igc_main.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc_main.c +13 -1
@@ -5999,6 +5999,7 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter,bool queue_configured[IGC_MAX_TX_QUEUES ] = { };u32 start_time =0 , end_time =0 ;size_t n; +int i; adapter->qbv_enable = qopt->enable;
@@ -6019,7 +6020,6 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter,for (n =0 ; n < qopt->num_entries; n++) {struct tc_taprio_sched_entry *e = &qopt->entries[n]; -int i; end_time += e->interval;
@@ -6058,6 +6058,18 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter, start_time += e->interval; } +/* Check whether a queue gets configured. +* If not, set the start and end time to be end time. +*/ +for (i =0 ; i < adapter->num_tx_queues; i++) { +if (!queue_configured[i]) { +struct igc_ring *ring = adapter->tx_ring[i]; + + ring->start_time = end_time; + ring->end_time = end_time; + } + } +return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 867/1073 rtc: mxc_v2: Add missing clk_disable_unprepare()
In reply to Greg Kroah-HartmanFrom: GUO Zihua <[email protected]>
[ Upstream commit 55d5a86618d3b1a768bce01882b74cbbd2651975 ]
The call to clk_disable_unprepare() is left out in the error handling of devm_rtc_allocate_device. Add it back.
--- drivers/rtc/rtc-mxc_v2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/rtc/rtc-mxc_v2.c +3 -1
@@ -336,8 +336,10 @@ static int mxc_rtc_probe(struct platform_device *pdev) } pdata->rtc =devm_rtc_allocate_device (&pdev->dev); -if (IS_ERR (pdata->rtc)) +if (IS_ERR (pdata->rtc)) { +clk_disable_unprepare (pdata->clk);return PTR_ERR (pdata->rtc); + } pdata->rtc->ops = &mxc_rtc_ops; pdata->rtc->range_max =U32_MAX ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 868/1073 devlink: hold region lock when flushing snapshots
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
[ Upstream commit b4cafb3d2c740f8d1b1234b43ac4a60e5291c960 ]
Netdevsim triggers a splat on reload, when it destroys regions with snapshots pending:
WARNING: CPU: 1 PID: 787 at net/core/devlink.c:6291 devlink_region_snapshot_del+0x12e/0x140 CPU: 1 PID: 787 Comm: devlink Not tainted 6.1.0-07460-g7ae9888d6e1c #580 RIP: 0010:devlink_region_snapshot_del+0x12e/0x140 Call Trace: <TASK> devl_region_destroy+0x70/0x140 nsim_dev_reload_down+0x2f/0x60 [netdevsim] devlink_reload+0x1f7/0x360 devlink_nl_cmd_reload+0x6ce/0x860 genl_family_rcv_msg_doit.isra.0+0x145/0x1c0
This is the locking assert in devlink_region_snapshot_del(), we're supposed to be holding the region->snapshot_lock here.
--- net/core/devlink.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/devlink.c +2 -0
@@ -11358,8 +11358,10 @@ void devl_region_destroy(struct devlink_region *region)devl_assert_locked (devlink);/* Free all snapshots of region */ +mutex_lock (®ion->snapshot_lock);list_for_each_entry_safe (snapshot, ts, ®ion->snapshot_list, list)devlink_region_snapshot_del (region, snapshot); +mutex_unlock (®ion->snapshot_lock);list_del (®ion->list);mutex_destroy (®ion->snapshot_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 869/1073 selftests: devlink: fix the fd redirect in dummy_reporter_test
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 2fc60e2ff972d3dca836bff0b08cbe503c4ca1ce ]
$number + > bash means redirect FD $number, e.g. commonly used 2> redirects stderr (fd 2). The test uses 8192> to write the number 8192 to a file, this results in:
./devlink.sh: line 499: 8192: Bad file descriptor
Oddly the test also papers over this issue by checking for failure (expecting an error rather than success) so it passes, anyway.
--- tools/testing/selftests/drivers/net/netdevsim/devlink.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/drivers/net/netdevsim/devlink.sh +2 -2
@@ -496,8 +496,8 @@ dummy_reporter_test() check_reporter_info dummy healthy 3 3 10 true - echo 8192> $DEBUGFS_DIR/health/binary_len - check_fail $? "Failed set dummy reporter binary len to 8192" + echo 8192 > $DEBUGFS_DIR/health/binary_len + check_err $? "Failed set dummy reporter binary len to 8192" local dump=$(devlink health dump show $DL_HANDLE reporter dummy -j) check_err $? "Failed show dump of dummy reporter"
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 870/1073 openvswitch: Fix flow lookup to use unmasked key
In reply to Greg Kroah-HartmanFrom: Eelco Chaudron <[email protected]>
[ Upstream commit 68bb10101e6b0a6bb44e9c908ef795fc4af99eae ]
The commit mentioned below causes the ovs_flow_tbl_lookup() function to be called with the masked key. However, it's supposed to be called with the unmasked key. This due to the fact that the datapath supports installing wider flows, and OVS relies on this behavior. For example if ipv4(src=1.1.1.1/192.0.0.0, dst=1.1.1.2/192.0.0.0) exists, a wider flow (smaller mask) of ipv4(src=192.1.1.1/128.0.0.0,dst=192.1.1.2/ 128.0.0.0) is allowed to be added.
However, if we try to add a wildcard rule, the installation fails:
$ ovs-appctl dpctl/add-flow system@myDP "in_port(1),eth_type(0x0800), \ ipv4(src=1.1.1.1/192.0.0.0,dst=1.1.1.2/192.0.0.0,frag=no)" 2 $ ovs-appctl dpctl/add-flow system@myDP "in_port(1),eth_type(0x0800), \ ipv4(src=192.1.1.1/0.0.0.0,dst=49.1.1.2/0.0.0.0,frag=no)" 2 ovs-vswitchd: updating flow table (File exists)
The reason is that the key used to determine if the flow is already present in the system uses the original key ANDed with the mask. This results in the IP address not being part of the (miniflow) key, i.e., being substituted with an all-zero value. When doing the actual lookup, this results in the key wrongfully matching the first flow, and therefore the flow does not get installed.
This change reverses the commit below, but rather than having the key on the stack, it's allocated.
--- net/openvswitch/datapath.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
net/openvswitch/datapath.c +16 -9
@@ -947,6 +947,7 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)struct sw_flow_mask mask;struct sk_buff *reply;struct datapath *dp; +struct sw_flow_key *key;struct sw_flow_actions *acts;struct sw_flow_match match;u32 ufid_flags =ovs_nla_get_ufid_flags (a[OVS_FLOW_ATTR_UFID_FLAGS ]);
@@ -974,24 +975,26 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info) }/* Extract key. */ -ovs_match_init (&match, &new_flow->key, false, &mask); + key =kzalloc (sizeof (*key),GFP_KERNEL ); +if (!key) { + error = -ENOMEM ; + goto err_kfree_key; + } + +ovs_match_init (&match, key, false, &mask); error =ovs_nla_get_match (net, &match, a[OVS_FLOW_ATTR_KEY ], a[OVS_FLOW_ATTR_MASK ], log);if (error) goto err_kfree_flow; +ovs_flow_mask_key (&new_flow->key, key, true, &mask); +/* Extract flow identifier. */ error =ovs_nla_get_identifier (&new_flow->id, a[OVS_FLOW_ATTR_UFID ], - &new_flow->key, log); + key, log);if (error) goto err_kfree_flow; -/* unmasked key is needed to match when ufid is not used. */ -if (ovs_identifier_is_key (&new_flow->id)) - match.key = new_flow->id.unmasked_key; - -ovs_flow_mask_key (&new_flow->key, &new_flow->key, true, &mask); -/* Validate actions. */ error =ovs_nla_copy_actions (net, a[OVS_FLOW_ATTR_ACTIONS ], &new_flow->key, &acts, log);
@@ -1018,7 +1021,7 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)if (ovs_identifier_is_ufid (&new_flow->id)) flow =ovs_flow_tbl_lookup_ufid (&dp->table, &new_flow->id);if (!flow) - flow =ovs_flow_tbl_lookup (&dp->table, &new_flow->key); + flow =ovs_flow_tbl_lookup (&dp->table, key);if (likely (!flow)) {rcu_assign_pointer (new_flow->sf_acts, acts);
@@ -1088,6 +1091,8 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)if (reply)ovs_notify (&dp_flow_genl_family, reply, info); + +kfree (key);return 0 ; err_unlock_ovs:
@@ -1097,6 +1102,8 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)ovs_nla_free_flow_actions (acts); err_kfree_flow:ovs_flow_free (new_flow, false); +err_kfree_key: +kfree (key); error:return error; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 871/1073 soc: mediatek: pm-domains: Fix the power glitch issue
In reply to Greg Kroah-HartmanFrom: Chun-Jie Chen <[email protected]>
[ Upstream commit dba8eb83af9dd757ef645b52200775e86883d858 ]
Power reset maybe generate unexpected signal. In order to avoid the glitch issue, we need to enable isolation first to guarantee the stable signal when power reset is triggered.
--- drivers/soc/mediatek/mtk-pm-domains.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/mediatek/mtk-pm-domains.c +1 -1
@@ -275,9 +275,9 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)clk_bulk_disable_unprepare (pd->num_subsys_clks, pd->subsys_clks);/* subsys power off */ -regmap_clear_bits (scpsys->base, pd->data->ctl_offs,PWR_RST_B_BIT );regmap_set_bits (scpsys->base, pd->data->ctl_offs,PWR_ISO_BIT );regmap_set_bits (scpsys->base, pd->data->ctl_offs,PWR_CLK_DIS_BIT ); +regmap_clear_bits (scpsys->base, pd->data->ctl_offs,PWR_RST_B_BIT );regmap_clear_bits (scpsys->base, pd->data->ctl_offs,PWR_ON_2ND_BIT );regmap_clear_bits (scpsys->base, pd->data->ctl_offs,PWR_ON_BIT );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 872/1073 arm64: dts: mt8183: Fix Mali GPU clock
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
[ Upstream commit ad2631b5645a1d0ca9bf6fecf71f77e3b0071ee5 ]
The actual clock feeding into the Mali GPU on the MT8183 is from the clock gate in the MFGCFG block, not CLK_TOP_MFGPLL_CK from the TOPCKGEN block, which itself is simply a pass-through placeholder for the MFGPLL in the APMIXEDSYS block.
Fix the hardware description with the correct clock reference.
--- arch/arm64/boot/dts/mediatek/mt8183.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -1
@@ -1670,7 +1670,7 @@ gpu: gpu@13040000 { <GIC_SPI 278 IRQ_TYPE_LEVEL_LOW>; interrupt-names = "job", "mmu", "gpu"; - clocks = <&topckgen CLK_TOP_MFGPLL_CK>; + clocks = <&mfgcfg CLK_MFG_BG3D>; power-domains = <&spm MT8183_POWER_DOMAIN_MFG_CORE0>,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 873/1073 devlink: protect devlink dump by the instance lock
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 214964a13ab56a9757d146b79b468a7ca190fbfb ]
Take the instance lock around devlink_nl_fill() when dumping, doit takes it already.
We are only dumping basic info so in the worst case we were risking data races around the reload statistics. Until the big devlink mutex was removed all relevant code was protected by it, so the missing instance lock was not exposed.
--- net/core/devlink.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/devlink.c +3 -0
@@ -1498,10 +1498,13 @@ static int devlink_nl_cmd_get_dumpit(struct sk_buff *msg,continue ; } +devl_lock (devlink); err =devlink_nl_fill (msg, devlink,DEVLINK_CMD_NEW ,NETLINK_CB (cb->skb).portid, cb->nlh->nlmsg_seq,NLM_F_MULTI ); +devl_unlock (devlink);devlink_put (devlink); +if (err) goto out; idx++;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 874/1073 skbuff: Account for tail adjustment during pull operations
In reply to Greg Kroah-HartmanFrom: Subash Abhinov Kasiviswanathan <[email protected]>
[ Upstream commit 2d7afdcbc9d32423f177ee12b7c93783aea338fb ]
Extending the tail can have some unexpected side effects if a program uses a helper like BPF_FUNC_skb_pull_data to read partial content beyond the head skb headlen when all the skbs in the gso frag_list are linear with no head_frag -
kernel BUG at net/core/skbuff.c:4219!
pc : skb_segment+0xcf4/0xd2c lr : skb_segment+0x63c/0xd2c Call trace: skb_segment+0xcf4/0xd2c __udp_gso_segment+0xa4/0x544 udp4_ufo_fragment+0x184/0x1c0 inet_gso_segment+0x16c/0x3a4 skb_mac_gso_segment+0xd4/0x1b0 __skb_gso_segment+0xcc/0x12c udp_rcv_segment+0x54/0x16c udp_queue_rcv_skb+0x78/0x144 udp_unicast_rcv_skb+0x8c/0xa4 __udp4_lib_rcv+0x490/0x68c udp_rcv+0x20/0x30 ip_protocol_deliver_rcu+0x1b0/0x33c ip_local_deliver+0xd8/0x1f0 ip_rcv+0x98/0x1a4 deliver_ptype_list_skb+0x98/0x1ec __netif_receive_skb_core+0x978/0xc60
Fix this by marking these skbs as GSO_DODGY so segmentation can handle the tail updates accordingly.
--- net/core/skbuff.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/skbuff.c +3 -0
@@ -2313,6 +2313,9 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta) insp = list; }else {/* Eaten partially. */ +if (skb_is_gso (skb) && !list->head_frag && +skb_headlen (list)) +skb_shinfo (skb)->gso_type |=SKB_GSO_DODGY ;if (skb_shared (list)) {/* Sucks! We need to fork list. :-( */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 875/1073 mailbox: mpfs: read the system controllers status
In reply to Greg Kroah-HartmanFrom: Conor Dooley <[email protected]>
[ Upstream commit ab47d0bfdf88faac0eb02749e5bfaa306e004300 ]
Some services explicitly return an error code in their response, but others rely on the system controller to set a status in its status register. The meaning of the bits varies based on what service is requested, so pass it back up to the driver that requested the service in the first place. The field in the message struct already existed, but was unused until now.
If the system controller is busy, in which case we should never actually be in the interrupt handler, or if the service fails the mailbox itself should not be read. Callers should check the status before operating on the response.
There's an existing, but unused, #define for the mailbox mask - but it was incorrect. It was doing a GENMASK_ULL(32, 16) which should've just been a GENMASK(31, 16), so fix that up and start using it.
--- drivers/mailbox/mailbox-mpfs.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-)
drivers/mailbox/mailbox-mpfs.c +28 -3
@@ -2,7 +2,7 @@/* * Microchip PolarFire SoC (MPFS) system controller/mailbox controller driver * -* Copyright (c) 2020 Microchip Corporation. All rights reserved. +* Copyright (c) 2020-2022 Microchip Corporation. All rights reserved. * * Author: Conor Dooley <[email protected]> *
@@ -56,7 +56,7 @@#define SCB_STATUS_NOTIFY_MASK BIT(SCB_STATUS_NOTIFY)#define SCB_STATUS_POS (16) -#define SCB_STATUS_MASK GENMASK_ULL(SCB_STATUS_POS + SCB_MASK_WIDTH, SCB_STATUS_POS) +#define SCB_STATUS_MASK GENMASK(SCB_STATUS_POS + SCB_MASK_WIDTH - 1, SCB_STATUS_POS)struct mpfs_mbox {struct mbox_controller controller;
@@ -130,13 +130,38 @@ static void mpfs_mbox_rx_data(struct mbox_chan *chan)struct mpfs_mbox *mbox = (struct mpfs_mbox *)chan->con_priv;struct mpfs_mss_response *response = mbox->response;u16 num_words =ALIGN ((response->resp_size), (4 )) /4U ; -u32 i; +u32 i, status;if (!response->resp_msg) {dev_err (mbox->dev,"failed to assign memory for response %d\n" , -ENOMEM );return ; } +/* +* The status is stored in bits 31:16 of the SERVICES_SR register. +* It is only valid when BUSY == 0. +* We should *never* get an interrupt while the controller is +* still in the busy state. If we do, something has gone badly +* wrong & the content of the mailbox would not be valid. +*/ +if (mpfs_mbox_busy (mbox)) { +dev_err (mbox->dev,"got an interrupt but system controller is busy\n" ); + response->resp_status =0xDEAD ; +return ; + } + + status =readl_relaxed (mbox->ctrl_base +SERVICES_SR_OFFSET ); + +/* +* If the status of the individual servers is non-zero, the service has +* failed. The contents of the mailbox at this point are not be valid, +* so don't bother reading them. Set the status so that the driver +* implementing the service can handle the result. +*/ + response->resp_status = (status &SCB_STATUS_MASK ) >>SCB_STATUS_POS ; +if (response->resp_status) +return ; +if (!mpfs_mbox_busy (mbox)) {for (i =0 ; i < num_words; i++) { response->resp_msg[i] =
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 876/1073 mailbox: arm_mhuv2: Fix return value check in mhuv2_probe()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 165b7643f2df890066b1b4e8a387888a600ca9bf ]
If devm_of_iomap() fails, it returns ERR_PTR() and never return NULL, so replace NULL pointer check with IS_ERR() to fix this problem.
--- drivers/mailbox/arm_mhuv2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mailbox/arm_mhuv2.c +2 -2
@@ -1062,8 +1062,8 @@ static int mhuv2_probe(struct amba_device *adev, const struct amba_id *id)int ret = -EINVAL ; reg =devm_of_iomap (dev, dev->of_node,0 ,NULL ); -if (!reg) -return -ENOMEM ; +if (IS_ERR (reg)) +return PTR_ERR (reg); mhu =devm_kzalloc (dev,sizeof (*mhu),GFP_KERNEL );if (!mhu)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 877/1073 mailbox: zynq-ipi: fix error handling while device_register() fails
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit a6792a0cdef0b1c2d77920246283a72537e60e94 ]
If device_register() fails, it has two issues:
1. The name allocated by dev_set_name() is leaked.
2. The parent of device is not NULL, device_unregister() is called in zynqmp_ipi_free_mboxes(), it will lead a kernel crash because of removing not added device.
Call put_device() to give up the reference, so the name is freed in kobject_cleanup(). Add device registered check in zynqmp_ipi_free_mboxes() to avoid null-ptr-deref.
--- drivers/mailbox/zynqmp-ipi-mailbox.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mailbox/zynqmp-ipi-mailbox.c +3 -1
@@ -493,6 +493,7 @@ static int zynqmp_ipi_mbox_probe(struct zynqmp_ipi_mbox *ipi_mbox, ret =device_register (&ipi_mbox->dev);if (ret) {dev_err (dev,"Failed to register ipi mbox dev.\n" ); +put_device (&ipi_mbox->dev);return ret; } mdev = &ipi_mbox->dev;
@@ -619,7 +620,8 @@ static void zynqmp_ipi_free_mboxes(struct zynqmp_ipi_pdata *pdata) ipi_mbox = &pdata->ipi_mboxes[i];if (ipi_mbox->dev.parent) {mbox_controller_unregister (&ipi_mbox->mbox); -device_unregister (&ipi_mbox->dev); +if (device_is_registered (&ipi_mbox->dev)) +device_unregister (&ipi_mbox->dev); } } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 878/1073 net_sched: reject TCF_EM_SIMPLE case for complex ematch module
In reply to Greg Kroah-HartmanFrom: Cong Wang <[email protected]>
[ Upstream commit 9cd3fd2054c3b3055163accbf2f31a4426f10317 ]
When TCF_EM_SIMPLE was introduced, it is supposed to be convenient for ematch implementation:
https://lore.kernel.org/all/[email protected]/
"You don't have to, providing a 32bit data chunk without TCF_EM_SIMPLE set will simply result in allocating & copy. It's an optimization, nothing more."
So if an ematch module provides ops->datalen that means it wants a complex data structure (saved in its em->data) instead of a simple u32 value. We should simply reject such a combination, otherwise this u32 could be misinterpreted as a pointer.
--- net/sched/ematch.c | 2 ++ 1 file changed, 2 insertions(+)
net/sched/ematch.c +2 -0
@@ -255,6 +255,8 @@ static int tcf_em_validate(struct tcf_proto *tp,* the value carried. */ if (em_hdr->flags &TCF_EM_SIMPLE ) { +if (em->ops->datalen >0 ) + goto errout;if (data_len <sizeof (u32)) goto errout; em->data = *(u32 *) data;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 879/1073 rxrpc: Fix missing unlock in rxrpc_do_sendmsg()
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 4feb2c44629e6f9b459b41a5a60491069d346a95 ]
One of the error paths in rxrpc_do_sendmsg() doesn't unlock the call mutex before returning. Fix it to do this.
Note that this still doesn't get rid of the checker warning:
../net/rxrpc/sendmsg.c:617:5: warning: context imbalance in 'rxrpc_do_sendmsg' - wrong count at exit
I think the interplay between the socket lock and the call's user_mutex may be too complicated for checker to analyse, especially as rxrpc_new_client_call_for_sendmsg(), which it calls, returns with the call's user_mutex if successful but unconditionally drops the socket lock.
--- net/rxrpc/sendmsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rxrpc/sendmsg.c +1 -1
@@ -716,7 +716,7 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)if (call->tx_total_len !=-1 || call->tx_pending || call->tx_top !=0 ) - goto error_put; + goto out_put_unlock; call->tx_total_len = p.call.tx_total_len; } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 880/1073 myri10ge: Fix an error handling path in myri10ge_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit d83b950d44d2982c0e62e3d81b0f35ab09431008 ]
Some memory allocated in myri10ge_probe_slices() is not released in the error handling path of myri10ge_probe().
Add the corresponding kfree(), as already done in the remove function.
--- drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/myricom/myri10ge/myri10ge.c +1 -0
@@ -3913,6 +3913,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)myri10ge_free_slices (mgp); abort_with_firmware: +kfree (mgp->msix_vectors);myri10ge_dummy_rdma (mgp,0 ); abort_with_ioremap:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 881/1073 net: stream: purge sk_error_queue in sk_stream_kill_queues()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit e0c8bccd40fc1c19e1d246c39bcf79e357e1ada3 ]
Changheon Lee reported TCP socket leaks, with a nice repro.
It seems we leak TCP sockets with the following sequence:
1) SOF_TIMESTAMPING_TX_ACK is enabled on the socket.
Each ACK will cook an skb put in error queue, from __skb_tstamp_tx(). __skb_tstamp_tx() is using skb_clone(), unless SOF_TIMESTAMPING_OPT_TSONLY was also requested.
2) If the application is also using MSG_ZEROCOPY, then we put in the error queue cloned skbs that had a struct ubuf_info attached to them.
Whenever an struct ubuf_info is allocated, sock_zerocopy_alloc() does a sock_hold().
As long as the cloned skbs are still in sk_error_queue, socket refcount is kept elevated.
3) Application closes the socket, while error queue is not empty.
Since tcp_close() no longer purges the socket error queue, we might end up with a TCP socket with at least one skb in error queue keeping the socket alive forever.
This bug can be (ab)used to consume all kernel memory and freeze the host.
We need to purge the error queue, with proper synchronization against concurrent writers.
--- net/core/stream.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/core/stream.c +6 -0
@@ -196,6 +196,12 @@ void sk_stream_kill_queues(struct sock *sk)/* First the read buffer. */ __skb_queue_purge (&sk->sk_receive_queue); +/* Next, the error queue. +* We need to use queue lock, because other threads might +* add packets to the queue without socket lock being held. +*/ +skb_queue_purge (&sk->sk_error_queue); +/* Next, the write queue. */ WARN_ON_ONCE (!skb_queue_empty (&sk->sk_write_queue));
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 882/1073 mctp: serial: Fix starting value for frame check sequence
In reply to Greg Kroah-HartmanFrom: Jeremy Kerr <[email protected]>
[ Upstream commit 2856a62762c8409e360d4fd452194c8e57ba1058 ]
RFC1662 defines the start state for the crc16 FCS to be 0xffff, but we're currently starting at zero.
This change uses the correct start state. We're only early in the adoption for the serial binding, so there aren't yet any other users to interface to.
--- drivers/net/mctp/mctp-serial.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/mctp/mctp-serial.c +4 -2
@@ -35,6 +35,8 @@#define BYTE_FRAME 0x7e#define BYTE_ESC 0x7d +#define FCS_INIT 0xffff +static DEFINE_IDA (mctp_serial_ida);enum mctp_serial_state {
@@ -123,7 +125,7 @@ static void mctp_serial_tx_work(struct work_struct *work) buf[2 ] = dev->txlen;if (!dev->txpos) - dev->txfcs =crc_ccitt (0 , buf +1 ,2 ); + dev->txfcs =crc_ccitt (FCS_INIT , buf +1 ,2 ); txlen =write_chunk (dev, buf + dev->txpos,3 - dev->txpos);if (txlen <=0 ) {
@@ -303,7 +305,7 @@ static void mctp_serial_push_header(struct mctp_serial *dev, unsigned char c)case 1 :if (c ==MCTP_SERIAL_VERSION ) { dev->rxpos++; - dev->rxfcs =crc_ccitt_byte (0 , c); + dev->rxfcs =crc_ccitt_byte (FCS_INIT , c); }else { dev->rxstate =STATE_ERR ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 883/1073 mctp: Remove device type check at unregister
In reply to Greg Kroah-HartmanFrom: Matt Johnston <[email protected]>
[ Upstream commit b389a902dd5be4ece505a2e0463b9b034de04bf5 ]
The unregister check could be incorrectly triggered if a netdev changes its type after register. That is possible for a tun device using TUNSETLINK ioctl, resulting in mctp unregister failing and the netdev unregister waiting forever.
This was encountered by https://github.com/openthread/openthread/issues/8523
Neither check at register or unregister is required. They were added in an attempt to track down mctp_ptr being set unexpectedly, which should not happen in normal operation.
--- net/mctp/device.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
net/mctp/device.c +1 -13
@@ -429,12 +429,6 @@ static void mctp_unregister(struct net_device *dev)struct mctp_dev *mdev; mdev =mctp_dev_get_rtnl (dev); -if (mdev && !mctp_known (dev)) { -// Sanity check, should match what was set in mctp_register -netdev_warn (dev,"%s: BUG mctp_ptr set for unknown type %d" , - __func__, dev->type); -return ; - }if (!mdev)return ;
@@ -451,14 +445,8 @@ static int mctp_register(struct net_device *dev)struct mctp_dev *mdev;/* Already registered? */ - mdev =rtnl_dereference (dev->mctp_ptr); - -if (mdev) { -if (!mctp_known (dev)) -netdev_warn (dev,"%s: BUG mctp_ptr set for unknown type %d" , - __func__, dev->type); +if (rtnl_dereference (dev->mctp_ptr))return 0 ; - }/* only register specific types */ if (!mctp_known (dev))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 884/1073 HID: amd_sfh: Add missing check for dma_alloc_coherent
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 53ffa6a9f83b2170c60591da1ead8791d5a42e81 ]
Add check for the return value of the dma_alloc_coherent since it may return NULL pointer if allocation fails.
--- drivers/hid/amd-sfh-hid/amd_sfh_client.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/hid/amd-sfh-hid/amd_sfh_client.c +4 -0
@@ -237,6 +237,10 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) in_data->sensor_virt_addr[i] =dma_alloc_coherent (dev,sizeof (int ) *8 , &cl_data->sensor_dma_addr[i],GFP_KERNEL ); +if (!in_data->sensor_virt_addr[i]) { + rc = -ENOMEM ; + goto cleanup; + } cl_data->sensor_sts[i] =SENSOR_DISABLED ; cl_data->sensor_requested_cnt[i] =0 ; cl_data->cur_hid_dev = i;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 885/1073 rcu: Fix __this_cpu_read() lockdep warning in rcu_force_quiescent_state()
In reply to Greg Kroah-HartmanFrom: Zqiang <[email protected]>
[ Upstream commit ceb1c8c9b8aa9199da46a0f29d2d5f08d9b44c15 ]
Running rcutorture with non-zero fqs_duration module parameter in a kernel built with CONFIG_PREEMPTION=y results in the following splat:
BUG: using __this_cpu_read() in preemptible [00000000] code: rcu_torture_fqs/398 caller is __this_cpu_preempt_check+0x13/0x20 CPU: 3 PID: 398 Comm: rcu_torture_fqs Not tainted 6.0.0-rc1-yoctodev-standard+ Call Trace: <TASK> dump_stack_lvl+0x5b/0x86 dump_stack+0x10/0x16 check_preemption_disabled+0xe5/0xf0 __this_cpu_preempt_check+0x13/0x20 rcu_force_quiescent_state.part.0+0x1c/0x170 rcu_force_quiescent_state+0x1e/0x30 rcu_torture_fqs+0xca/0x160 ? rcu_torture_boost+0x430/0x430 kthread+0x192/0x1d0 ? kthread_complete_and_exit+0x30/0x30 ret_from_fork+0x22/0x30 </TASK>
The problem is that rcu_force_quiescent_state() uses __this_cpu_read() in preemptible code instead of the proper raw_cpu_read(). This commit therefore changes __this_cpu_read() to raw_cpu_read().
--- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +1 -1
@@ -2415,7 +2415,7 @@ void rcu_force_quiescent_state(void)struct rcu_node *rnp_old =NULL ;/* Funnel through hierarchy to reduce memory contention. */ - rnp =__this_cpu_read (rcu_data.mynode); + rnp =raw_cpu_read (rcu_data.mynode);for (; rnp !=NULL ; rnp = rnp->parent) { ret = (READ_ONCE (rcu_state.gp_flags) &RCU_GP_FLAG_FQS ) || !raw_spin_trylock (&rnp->fqslock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 886/1073 arm64: make is_ttbrX_addr() noinstr-safe
In reply to Greg Kroah-HartmanFrom: Mark Rutland <[email protected]>
[ Upstream commit d8c1d798a2e5091128c391c6dadcc9be334af3f5 ]
We use is_ttbr0_addr() in noinstr code, but as it's only marked as inline, it's theoretically possible for the compiler to place it out-of-line and instrument it, which would be problematic.
Mark is_ttbr0_addr() as __always_inline such that that can safely be used from noinstr code. For consistency, do the same to is_ttbr1_addr(). Note that while is_ttbr1_addr() calls arch_kasan_reset_tag(), this is a macro (and its callees are either macros or __always_inline), so there is not a risk of transient instrumentation.
--- arch/arm64/include/asm/processor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/processor.h +2 -2
@@ -308,13 +308,13 @@ static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc, }#endif -static inline bool is_ttbr0_addr (unsigned long addr) +static __always_inline bool is_ttbr0_addr(unsigned long addr) {/* entry assembly clears tags for TTBR0 addrs */ return addr <TASK_SIZE ; } -static inline bool is_ttbr1_addr (unsigned long addr) +static __always_inline bool is_ttbr1_addr(unsigned long addr) {/* TTBR1 addresses may have a tag if KASAN_SW_TAGS is in use */ return arch_kasan_reset_tag (addr) >=PAGE_OFFSET ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 887/1073 ARM: dts: aspeed: rainier,everest: Move reserved memory regions
In reply to Greg Kroah-HartmanFrom: Adriana Kobylak <[email protected]>
[ Upstream commit e184d42a6e085f95f5c4f1a4fbabebab2984cb68 ]
Move the reserved regions to account for a decrease in DRAM when ECC is enabled. ECC takes 1/9th of memory.
Running on HW with ECC off, u-boot prints:
DRAM: already initialized, 1008 MiB (capacity:1024 MiB, VGA:16 MiB, ECC:off)
And with ECC on, u-boot prints:
DRAM: already initialized, 896 MiB (capacity:1024 MiB, VGA:16 MiB, ECC:on, ECC size:896 MiB)
This implies that MCR54 is configured for ECC to be bounded at the bottom of a 16MiB VGA memory region:
1024MiB - 16MiB (VGA) = 1008MiB
1008MiB / 9 (for ECC) = 112MiB
1008MiB - 112MiB = 896MiB (available DRAM)
The flash_memory region currently starts at offset 896MiB:0xb8000000 (flash_memory offset) - 0x80000000 (base memory address) = 0x38000000 = 896MiB
This is the end of the available DRAM with ECC enabled and therefore it needs to be moved.
Since the flash_memory is 64MiB in size and needs to be 64MiB aligned, it can just be moved up by 64MiB and would sit right at the end of the available DRAM buffer.
The ramoops region currently follows the flash_memory, but it can be moved to sit above flash_memory which would minimize the address-space fragmentation.
--- arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts | 17 ++++++++--------- arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts | 16 +++++++++------- 2 files changed, 17 insertions(+), 16 deletions(-)
arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts +8 -9
@@ -162,16 +162,9 @@ reserved-memory { #size-cells = <1>; ranges; - /* LPC FW cycle bridge region requires natural alignment */ - flash_memory: region@b8000000 { - no-map; - reg = <0xb8000000 0x04000000>; /* 64M */ - }; - - /* 48MB region from the end of flash to start of vga memory */ - ramoops@bc000000 { + ramoops@b3e00000 { compatible = "ramoops"; - reg = <0xbc000000 0x200000>; /* 16 * (4 * 0x8000) */ + reg = <0xb3e00000 0x200000>; /* 16 * (4 * 0x8000) */ record-size = <0x8000>; console-size = <0x8000>; ftrace-size = <0x8000>;
@@ -179,6 +172,12 @@ ramoops@bc000000 { max-reason = <3>; /* KMSG_DUMP_EMERG */ }; + /* LPC FW cycle bridge region requires natural alignment */ + flash_memory: region@b4000000 { + no-map; + reg = <0xb4000000 0x04000000>; /* 64M */ + }; + /* VGA region is dictated by hardware strapping */ vga_memory: region@bf000000 { no-map;
arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts +9 -7
@@ -95,14 +95,9 @@ reserved-memory { #size-cells = <1>; ranges; - flash_memory: region@b8000000 { - no-map; - reg = <0xb8000000 0x04000000>; /* 64M */ - }; - - ramoops@bc000000 { + ramoops@b3e00000 { compatible = "ramoops"; - reg = <0xbc000000 0x200000>; /* 16 * (4 * 0x8000) */ + reg = <0xb3e00000 0x200000>; /* 16 * (4 * 0x8000) */ record-size = <0x8000>; console-size = <0x8000>; ftrace-size = <0x8000>;
@@ -110,6 +105,13 @@ ramoops@bc000000 { max-reason = <3>; /* KMSG_DUMP_EMERG */ }; + /* LPC FW cycle bridge region requires natural alignment */ + flash_memory: region@b4000000 { + no-map; + reg = <0xb4000000 0x04000000>; /* 64M */ + }; + + /* VGA region is dictated by hardware strapping */ vga_memory: region@bf000000 { no-map; compatible = "shared-dma-pool";
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 888/1073 video: hyperv_fb: Avoid taking busy spinlock on panic path
In reply to Greg Kroah-HartmanFrom: Guilherme G. Piccoli <[email protected]>
[ Upstream commit 1d044ca035dc22df0d3b39e56f2881071d9118bd ]
The Hyper-V framebuffer code registers a panic notifier in order to try updating its fbdev if the kernel crashed. The notifier callback is straightforward, but it calls the vmbus_sendpacket() routine eventually, and such function takes a spinlock for the ring buffer operations.
Panic path runs in atomic context, with local interrupts and preemption disabled, and all secondary CPUs shutdown. That said, taking a spinlock might cause a lockup if a secondary CPU was disabled with such lock taken. Fix it here by checking if the ring buffer spinlock is busy on Hyper-V framebuffer panic notifier; if so, bail-out avoiding the potential lockup scenario.
--- drivers/hv/ring_buffer.c | 13 +++++++++++++ drivers/video/fbdev/hyperv_fb.c | 8 +++++++- include/linux/hyperv.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-)
drivers/hv/ring_buffer.c +13 -0
@@ -280,6 +280,19 @@ void hv_ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info) ring_info->pkt_buffer_size =0 ; } +/* +* Check if the ring buffer spinlock is available to take or not; used on +* atomic contexts, like panic path (see the Hyper-V framebuffer driver). +*/ + +bool hv_ringbuffer_spinlock_busy (struct vmbus_channel *channel) +{ +struct hv_ring_buffer_info *rinfo = &channel->outbound; + +return spin_is_locked (&rinfo->ring_lock); +} +EXPORT_SYMBOL_GPL (hv_ringbuffer_spinlock_busy); +/* Write to the ring buffer. */ int hv_ringbuffer_write(struct vmbus_channel *channel, const struct kvec *kv_list, u32 kv_count,
drivers/video/fbdev/hyperv_fb.c +7 -1
@@ -779,12 +779,18 @@ static void hvfb_ondemand_refresh_throttle(struct hvfb_par *par,static int hvfb_on_panic (struct notifier_block *nb,unsigned long e,void *p) { +struct hv_device *hdev;struct hvfb_par *par;struct fb_info *info; par = container_of(nb, struct hvfb_par, hvfb_panic_nb); - par->synchronous_fb = true; info = par->info; + hdev =device_to_hv_device (info->device); + +if (hv_ringbuffer_spinlock_busy (hdev->channel)) +return NOTIFY_DONE ; + + par->synchronous_fb = true;if (par->need_docopy)hvfb_docopy (par,0 , dio_fb_size);synthvid_update (info,0 ,0 ,INT_MAX ,INT_MAX );
include/linux/hyperv.h +2 -0
@@ -1341,6 +1341,8 @@ struct hv_ring_buffer_debug_info {int hv_ringbuffer_get_debuginfo (struct hv_ring_buffer_info *ring_info,struct hv_ring_buffer_debug_info *debug_info); +bool hv_ringbuffer_spinlock_busy (struct vmbus_channel *channel); +/* Vmbus interface */ #define vmbus_driver_register (driver) \ __vmbus_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 889/1073 x86/hyperv: Remove unregister syscore call from Hyper-V cleanup
In reply to Greg Kroah-HartmanFrom: Gaurav Kohli <[email protected]>
[ Upstream commit 32c97d980e2eef25465d453f2956a9ca68926a3c ]
Hyper-V cleanup code comes under panic path where preemption and irq is already disabled. So calling of unregister_syscore_ops might schedule out the thread even for the case where mutex lock is free. hyperv_cleanup
unregister_syscore_ops
mutex_lock(&syscore_ops_lock)
might_sleep
Here might_sleep might schedule out this thread, where voluntary preemption config is on and this thread will never comes back. And also this was added earlier to maintain the symmetry which is not required as this can comes during crash shutdown path only.
To prevent the same, removing unregister_syscore_ops function call.
--- arch/x86/hyperv/hv_init.c | 2 -- 1 file changed, 2 deletions(-)
arch/x86/hyperv/hv_init.c +0 -2
@@ -536,8 +536,6 @@ void hyperv_cleanup(void) {union hv_x64_msr_hypercall_contents hypercall_msr; -unregister_syscore_ops (&hv_syscore_ops); -/* Reset our OS id */ wrmsrl (HV_X64_MSR_GUEST_OS_ID ,0 );hv_ghcb_msr_write (HV_X64_MSR_GUEST_OS_ID ,0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 890/1073 binfmt_misc: fix shift-out-of-bounds in check_special_flags
In reply to Greg Kroah-HartmanFrom: Liu Shixin <[email protected]>
[ Upstream commit 6a46bf558803dd2b959ca7435a5c143efe837217 ]
UBSAN reported a shift-out-of-bounds warning:
left shift of 1 by 31 places cannot be represented in type 'int'
Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x8d/0xcf lib/dump_stack.c:106 ubsan_epilogue+0xa/0x44 lib/ubsan.c:151 __ubsan_handle_shift_out_of_bounds+0x1e7/0x208 lib/ubsan.c:322 check_special_flags fs/binfmt_misc.c:241 [inline] create_entry fs/binfmt_misc.c:456 [inline] bm_register_write+0x9d3/0xa20 fs/binfmt_misc.c:654 vfs_write+0x11e/0x580 fs/read_write.c:582 ksys_write+0xcf/0x120 fs/read_write.c:637 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x34/0x80 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x4194e1
Since the type of Node's flags is unsigned long, we should define these macros with same type too.
--- fs/binfmt_misc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/binfmt_misc.c +4 -4
@@ -44,10 +44,10 @@ static LIST_HEAD(entries);static int enabled =1 ;enum {Enabled, Magic}; -#define MISC_FMT_PRESERVE_ARGV0 (1 << 31) -#define MISC_FMT_OPEN_BINARY (1 << 30) -#define MISC_FMT_CREDENTIALS (1 << 29) -#define MISC_FMT_OPEN_FILE (1 << 28) +#define MISC_FMT_PRESERVE_ARGV0 (1UL << 31) +#define MISC_FMT_OPEN_BINARY (1UL << 30) +#define MISC_FMT_CREDENTIALS (1UL << 29) +#define MISC_FMT_OPEN_FILE (1UL << 28) typedef struct { struct list_head list;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 891/1073 arm64: dts: qcom: sm6350: Add apps_smmu with streamID to SDHCI 1/2 nodes
In reply to Greg Kroah-HartmanFrom: Marijn Suijten <[email protected]>
[ Upstream commit 7372b944a6ba5ac86628eaacc89ed4f103435cb9 ]
When enabling the APPS SMMU the mainline driver reconfigures the SMMU from its bootloader configuration, losing the stream mapping for (among which) the SDHCI hardware and breaking its ADMA feature. This feature can be disabled with:
sdhci.debug_quirks=0x40
But it is of course desired to have this feature enabled and working through the SMMU.
--- arch/arm64/boot/dts/qcom/sm6350.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/qcom/sm6350.dtsi +2 -0
@@ -482,6 +482,7 @@ sdhc_1: mmc@7c4000 { interrupts = <GIC_SPI 641 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 644 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "hc_irq", "pwr_irq"; + iommus = <&apps_smmu 0x60 0x0>; clocks = <&gcc GCC_SDCC1_AHB_CLK>, <&gcc GCC_SDCC1_APPS_CLK>,
@@ -928,6 +929,7 @@ sdhc_2: mmc@8804000 { interrupts = <GIC_SPI 204 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 222 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "hc_irq", "pwr_irq"; + iommus = <&apps_smmu 0x560 0x0>; clocks = <&gcc GCC_SDCC2_AHB_CLK>, <&gcc GCC_SDCC2_APPS_CLK>,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 892/1073 fs: jfs: fix shift-out-of-bounds in dbAllocAG
In reply to Greg Kroah-HartmanFrom: Dongliang Mu <[email protected]>
[ Upstream commit 898f706695682b9954f280d95e49fa86ffa55d08 ]
Syzbot found a crash : UBSAN: shift-out-of-bounds in dbAllocAG. The underlying bug is the missing check of bmp->db_agl2size. The field can be greater than 64 and trigger the shift-out-of-bounds.
Fix this bug by adding a check of bmp->db_agl2size in dbMount since this field is used in many following functions. The upper bound for this field is L2MAXL2SIZE - L2MAXAG, thanks for the help of Dave Kleikamp. Note that, for maintenance, I reorganized error handling code of dbMount.
--- fs/jfs/jfs_dmap.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
fs/jfs/jfs_dmap.c +16 -6
@@ -155,7 +155,7 @@ int dbMount(struct inode *ipbmap)struct bmap *bmp;struct dbmap_disk *dbmp_le;struct metapage *mp; -int i; +int i, err;/* * allocate/initialize the in-memory bmap descriptor
@@ -170,8 +170,8 @@ int dbMount(struct inode *ipbmap)BMAPBLKNO <<JFS_SBI (ipbmap->i_sb)->l2nbperpage, PSIZE, 0);if (mp ==NULL ) { -kfree (bmp); -return -EIO ; + err = -EIO ; + goto err_kfree_bmp; }/* copy the on-disk bmap descriptor to its in-memory version. */
@@ -181,9 +181,8 @@ int dbMount(struct inode *ipbmap) bmp->db_l2nbperpage =le32_to_cpu (dbmp_le->dn_l2nbperpage); bmp->db_numag =le32_to_cpu (dbmp_le->dn_numag);if (!bmp->db_numag) { -release_metapage (mp); -kfree (bmp); -return -EINVAL ; + err = -EINVAL ; + goto err_release_metapage; } bmp->db_maxlevel =le32_to_cpu (dbmp_le->dn_maxlevel);
@@ -194,6 +193,11 @@ int dbMount(struct inode *ipbmap) bmp->db_agwidth =le32_to_cpu (dbmp_le->dn_agwidth); bmp->db_agstart =le32_to_cpu (dbmp_le->dn_agstart); bmp->db_agl2size =le32_to_cpu (dbmp_le->dn_agl2size); +if (bmp->db_agl2size >L2MAXL2SIZE -L2MAXAG ) { + err = -EINVAL ; + goto err_release_metapage; + } +for (i =0 ; i <MAXAG ; i++) bmp->db_agfree[i] =le64_to_cpu (dbmp_le->dn_agfree[i]); bmp->db_agsize =le64_to_cpu (dbmp_le->dn_agsize);
@@ -214,6 +218,12 @@ int dbMount(struct inode *ipbmap)BMAP_LOCK_INIT (bmp);return (0 ); + +err_release_metapage: +release_metapage (mp); +err_kfree_bmp: +kfree (bmp); +return err; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 893/1073 udf: Avoid double brelse() in udf_rename()
In reply to Greg Kroah-HartmanFrom: Shigeru Yoshida <[email protected]>
[ Upstream commit c791730f2554a9ebb8f18df9368dc27d4ebc38c2 ]
syzbot reported a warning like below [1]:
VFS: brelse: Trying to free free buffer
WARNING: CPU: 2 PID: 7301 at fs/buffer.c:1145 __brelse+0x67/0xa0 ... Call Trace: <TASK> invalidate_bh_lru+0x99/0x150 smp_call_function_many_cond+0xe2a/0x10c0 ? generic_remap_file_range_prep+0x50/0x50 ? __brelse+0xa0/0xa0 ? __mutex_lock+0x21c/0x12d0 ? smp_call_on_cpu+0x250/0x250 ? rcu_read_lock_sched_held+0xb/0x60 ? lock_release+0x587/0x810 ? __brelse+0xa0/0xa0 ? generic_remap_file_range_prep+0x50/0x50 on_each_cpu_cond_mask+0x3c/0x80 blkdev_flush_mapping+0x13a/0x2f0 blkdev_put_whole+0xd3/0xf0 blkdev_put+0x222/0x760 deactivate_locked_super+0x96/0x160 deactivate_super+0xda/0x100 cleanup_mnt+0x222/0x3d0 task_work_run+0x149/0x240 ? task_work_cancel+0x30/0x30 do_exit+0xb29/0x2a40 ? reacquire_held_locks+0x4a0/0x4a0 ? do_raw_spin_lock+0x12a/0x2b0 ? mm_update_next_owner+0x7c0/0x7c0 ? rwlock_bug.part.0+0x90/0x90 ? zap_other_threads+0x234/0x2d0 do_group_exit+0xd0/0x2a0 __x64_sys_exit_group+0x3a/0x50 do_syscall_64+0x34/0xb0 entry_SYSCALL_64_after_hwframe+0x63/0xcd
The cause of the issue is that brelse() is called on both ofibh.sbh and ofibh.ebh by udf_find_entry() when it returns NULL. However, brelse() is called by udf_rename(), too. So, b_count on buffer_head becomes unbalanced.
This patch fixes the issue by not calling brelse() by udf_rename() when udf_find_entry() returns NULL.
--- fs/udf/namei.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/udf/namei.c +4 -4
@@ -1091,8 +1091,9 @@ static int udf_rename(struct user_namespace *mnt_userns, struct inode *old_dir,return -EINVAL ; ofi =udf_find_entry (old_dir, &old_dentry->d_name, &ofibh, &ocfi); -if (IS_ERR (ofi)) { - retval =PTR_ERR (ofi); +if (!ofi ||IS_ERR (ofi)) { +if (IS_ERR (ofi)) + retval =PTR_ERR (ofi); goto end_rename; }
@@ -1101,8 +1102,7 @@ static int udf_rename(struct user_namespace *mnt_userns, struct inode *old_dir,brelse (ofibh.sbh); tloc =lelb_to_cpu (ocfi.icb.extLocation); -if (!ofi ||udf_get_lb_pblock (old_dir->i_sb, &tloc,0 ) - != old_inode->i_ino) +if (udf_get_lb_pblock (old_dir->i_sb, &tloc,0 ) != old_inode->i_ino) goto end_rename; nfi =udf_find_entry (new_dir, &new_dentry->d_name, &nfibh, &ncfi);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 894/1073 jfs: Fix fortify moan in symlink
In reply to Greg Kroah-HartmanFrom: Dr. David Alan Gilbert <[email protected]>
[ Upstream commit ebe060369f8d6e4588b115f252bebf5ba4d64350 ]
JFS has in jfs_incore.h:
/* _inline may overflow into _inline_ea when needed */
/* _inline_ea may overlay the last part of
* file._xtroot if maxentry = XTROOTINITSLOT
*/
union {
struct {
/* 128: inline symlink */
unchar _inline[128];
/* 128: inline extended attr */
unchar _inline_ea[128];
};
unchar _inline_all[256];and currently the symlink code copies into _inline;
if this is larger than 128 bytes it triggers a fortify warning of the form:
memcpy: detected field-spanning write (size 132) of single field
"ip->i_link" at fs/jfs/namei.c:950 (size 18446744073709551615)
when it's actually OK.
Copy it into _inline_all instead.
--- fs/jfs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jfs/namei.c +1 -1
@@ -946,7 +946,7 @@ static int jfs_symlink(struct user_namespace *mnt_userns, struct inode *dip,if (ssize <=IDATASIZE ) { ip->i_op = &jfs_fast_symlink_inode_operations; - ip->i_link =JFS_IP (ip)->i_inline; + ip->i_link =JFS_IP (ip)->i_inline_all;memcpy (ip->i_link, name, ssize); ip->i_size = ssize -1 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 895/1073 fs: jfs: fix shift-out-of-bounds in dbDiscardAG
In reply to Greg Kroah-HartmanFrom: Hoi Pok Wu <[email protected]>
[ Upstream commit 25e70c6162f207828dd405b432d8f2a98dbf7082 ]
This should be applied to most URSAN bugs found recently by syzbot, by guarding the dbMount. As syzbot feeding rubbish into the bmap descriptor.
--- fs/jfs/jfs_dmap.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/jfs/jfs_dmap.c +5 -0
@@ -198,6 +198,11 @@ int dbMount(struct inode *ipbmap) goto err_release_metapage; } +if (((bmp->db_mapsize -1 ) >> bmp->db_agl2size) >MAXAG ) { + err = -EINVAL ; + goto err_release_metapage; + } +for (i =0 ; i <MAXAG ; i++) bmp->db_agfree[i] =le64_to_cpu (dbmp_le->dn_agfree[i]); bmp->db_agsize =le64_to_cpu (dbmp_le->dn_agsize);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 896/1073 ACPI: processor: idle: Check acpi_fetch_acpi_dev() return value
In reply to Greg Kroah-HartmanFrom: Li Zhong <[email protected]>
[ Upstream commit 2437513a814b3e93bd02879740a8a06e52e2cf7d ]
The return value of acpi_fetch_acpi_dev() could be NULL, which would cause a NULL pointer dereference to occur in acpi_device_hid().
--- drivers/acpi/processor_idle.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/acpi/processor_idle.c +3 -0
@@ -1134,6 +1134,9 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr) status =acpi_get_parent (handle, &pr_ahandle);while (ACPI_SUCCESS (status)) { d =acpi_fetch_acpi_dev (pr_ahandle); +if (!d) +break ; + handle = pr_ahandle;if (strcmp (acpi_device_hid (d),ACPI_PROCESSOR_CONTAINER_HID ))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 897/1073 ACPI: EC: Add quirk for the HP Pavilion Gaming 15-cx0041ur
In reply to Greg Kroah-HartmanFrom: Mia Kanashi <[email protected]>
[ Upstream commit b423f240a66ad928c4cb5ec6055dfc90ce8d894e ]
Added GPE quirk entry for the HP Pavilion Gaming 15-cx0041ur. There is a quirk entry for the 15-cx0xxx laptops, but this one has different DMI_PRODUCT_NAME.
Notably backlight keys and other ACPI events now function correctly.
--- drivers/acpi/ec.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/acpi/ec.c +10 -0
@@ -1879,6 +1879,16 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Gaming Laptop 15-cx0xxx"), }, }, + { +/* +* HP Pavilion Gaming Laptop 15-cx0041ur +*/ + .callback = ec_honor_dsdt_gpe, + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"HP" ), + DMI_MATCH(DMI_PRODUCT_NAME, "HP 15-cx0041ur"), + }, + }, {/* * Samsung hardware
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 898/1073 ACPICA: Fix error code path in acpi_ds_call_control_method()
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit 404ec60438add1afadaffaed34bb5fe4ddcadd40 ]
A use-after-free in acpi_ps_parse_aml() after a failing invocaion of acpi_ds_call_control_method() is reported by KASAN [1] and code inspection reveals that next_walk_state pushed to the thread by acpi_ds_create_walk_state() is freed on errors, but it is not popped from the thread beforehand. Thus acpi_ds_get_current_walk_state() called by acpi_ps_parse_aml() subsequently returns it as the new walk state which is incorrect.
To address this, make acpi_ds_call_control_method() call acpi_ds_pop_walk_state() to pop next_walk_state from the thread before returning an error.
--- drivers/acpi/acpica/dsmethod.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/acpi/acpica/dsmethod.c +8 -2
@@ -517,7 +517,7 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread, info =ACPI_ALLOCATE_ZEROED (sizeof (struct acpi_evaluate_info ));if (!info) { status =AE_NO_MEMORY ; - goto cleanup; + goto pop_walk_state; } info->parameters = &this_walk_state->operands[0 ];
@@ -529,7 +529,7 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,ACPI_FREE (info);if (ACPI_FAILURE (status)) { - goto cleanup; + goto pop_walk_state; } next_walk_state->method_nesting_depth =
@@ -575,6 +575,12 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,return_ACPI_STATUS (status); +pop_walk_state: + +/* On error, pop the walk state to be deleted from thread */ + +acpi_ds_pop_walk_state (thread); + cleanup:/* On error, we must terminate the method properly */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 899/1073 nilfs2: fix shift-out-of-bounds/overflow in nilfs_sb2_bad_offset()
In reply to Greg Kroah-HartmanFrom: Ryusuke Konishi <[email protected]>
[ Upstream commit 610a2a3d7d8be3537458a378ec69396a76c385b6 ]
Patch series "nilfs2: fix UBSAN shift-out-of-bounds warnings on mount time".
The first patch fixes a bug reported by syzbot, and the second one fixes the remaining bug of the same kind. Although they are triggered by the same super block data anomaly, I divided it into the above two because the details of the issues and how to fix it are different.
Both are required to eliminate the shift-out-of-bounds issues at mount time.
This patch (of 2):
If the block size exponent information written in an on-disk superblock is corrupted, nilfs_sb2_bad_offset helper function can trigger shift-out-of-bounds warning followed by a kernel panic (if panic_on_warn is set):
shift exponent 38983 is too large for 64-bit type 'unsigned long long'
Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106 ubsan_epilogue lib/ubsan.c:151 [inline] __ubsan_handle_shift_out_of_bounds+0x33d/0x3b0 lib/ubsan.c:322 nilfs_sb2_bad_offset fs/nilfs2/the_nilfs.c:449 [inline] nilfs_load_super_block+0xdf5/0xe00 fs/nilfs2/the_nilfs.c:523 init_nilfs+0xb7/0x7d0 fs/nilfs2/the_nilfs.c:577 nilfs_fill_super+0xb1/0x5d0 fs/nilfs2/super.c:1047 nilfs_mount+0x613/0x9b0 fs/nilfs2/super.c:1317 ...
In addition, since nilfs_sb2_bad_offset() performs multiplication without considering the upper bound, the computation may overflow if the disk layout parameters are not normal.
This fixes these issues by inserting preliminary sanity checks for those parameters and by converting the comparison from one involving multiplication and left bit-shifting to one using division and right bit-shifting.
--- fs/nilfs2/the_nilfs.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)
fs/nilfs2/the_nilfs.c +27 -4
@@ -13,6 +13,7 @@#include <linux/blkdev.h> #include <linux/backing-dev.h> #include <linux/random.h> +#include <linux/log2.h> #include <linux/crc32.h> #include "nilfs.h" #include "segment.h"
@@ -443,11 +444,33 @@ static int nilfs_valid_sb(struct nilfs_super_block *sbp)return crc ==le32_to_cpu (sbp->s_sum); } -static int nilfs_sb2_bad_offset (struct nilfs_super_block *sbp,u64 offset) +/** +* nilfs_sb2_bad_offset - check the location of the second superblock +* @sbp: superblock raw data buffer +* @offset: byte offset of second superblock calculated from device size +* +* nilfs_sb2_bad_offset() checks if the position on the second +* superblock is valid or not based on the filesystem parameters +* stored in @sbp. If @offset points to a location within the segment +* area, or if the parameters themselves are not normal, it is +* determined to be invalid. +* +* Return Value: true if invalid, false if valid. +*/ +static bool nilfs_sb2_bad_offset (struct nilfs_super_block *sbp,u64 offset) { -return offset < ((le64_to_cpu (sbp->s_nsegments) * -le32_to_cpu (sbp->s_blocks_per_segment)) << - (le32_to_cpu (sbp->s_log_block_size) +10 )); +unsigned int shift_bits =le32_to_cpu (sbp->s_log_block_size); +u32 blocks_per_segment =le32_to_cpu (sbp->s_blocks_per_segment); +u64 nsegments =le64_to_cpu (sbp->s_nsegments); +u64 index; + +if (blocks_per_segment <NILFS_SEG_MIN_BLOCKS || + shift_bits >ilog2 (NILFS_MAX_BLOCK_SIZE ) -BLOCK_SIZE_BITS ) +return true; + + index = offset >> (shift_bits +BLOCK_SIZE_BITS ); +do_div (index, blocks_per_segment); +return index < nsegments; }static void nilfs_release_super_block (struct the_nilfs *nilfs)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 900/1073 nilfs2: fix shift-out-of-bounds due to too large exponent of block size
In reply to Greg Kroah-HartmanFrom: Ryusuke Konishi <[email protected]>
[ Upstream commit ebeccaaef67a4895d2496ab8d9c2fb8d89201211 ]
If field s_log_block_size of superblock data is corrupted and too large, init_nilfs() and load_nilfs() still can trigger a shift-out-of-bounds warning followed by a kernel panic (if panic_on_warn is set):
shift exponent 38973 is too large for 32-bit type 'int'
Call Trace: <TASK> dump_stack_lvl+0xcd/0x134 ubsan_epilogue+0xb/0x50 __ubsan_handle_shift_out_of_bounds.cold.12+0x17b/0x1f5 init_nilfs.cold.11+0x18/0x1d [nilfs2] nilfs_mount+0x9b5/0x12b0 [nilfs2] ...
This fixes the issue by adding and using a new helper function for getting block size with sanity check.
--- fs/nilfs2/the_nilfs.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-)
fs/nilfs2/the_nilfs.c +38 -4
@@ -193,6 +193,34 @@ static int nilfs_store_log_cursor(struct the_nilfs *nilfs,return ret; } +/** +* nilfs_get_blocksize - get block size from raw superblock data +* @sb: super block instance +* @sbp: superblock raw data buffer +* @blocksize: place to store block size +* +* nilfs_get_blocksize() calculates the block size from the block size +* exponent information written in @sbp and stores it in @blocksize, +* or aborts with an error message if it's too large. +* +* Return Value: On success, 0 is returned. If the block size is too +* large, -EINVAL is returned. +*/ +static int nilfs_get_blocksize (struct super_block *sb, +struct nilfs_super_block *sbp,int *blocksize) +{ +unsigned int shift_bits =le32_to_cpu (sbp->s_log_block_size); + +if (unlikely (shift_bits > +ilog2 (NILFS_MAX_BLOCK_SIZE ) -BLOCK_SIZE_BITS )) { +nilfs_err (sb,"too large filesystem blocksize: 2 ^ %u KiB" , + shift_bits); +return -EINVAL ; + } + *blocksize =BLOCK_SIZE << shift_bits; +return 0 ; +} +/** * load_nilfs - load and recover the nilfs * @nilfs: the_nilfs structure to be released
@@ -246,11 +274,15 @@ int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb) nilfs->ns_sbwtime =le64_to_cpu (sbp[0 ]->s_wtime);/* verify consistency between two super blocks */ - blocksize =BLOCK_SIZE <<le32_to_cpu (sbp[0 ]->s_log_block_size); + err =nilfs_get_blocksize (sb, sbp[0 ], &blocksize); +if (err) + goto scan_error; +if (blocksize != nilfs->ns_blocksize) {nilfs_warn (sb,"blocksize differs between two super blocks (%d != %d)" , blocksize, nilfs->ns_blocksize); + err = -EINVAL ; goto scan_error; }
@@ -609,9 +641,11 @@ int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data)if (err) goto failed_sbh; - blocksize =BLOCK_SIZE <<le32_to_cpu (sbp->s_log_block_size); -if (blocksize <NILFS_MIN_BLOCK_SIZE || - blocksize >NILFS_MAX_BLOCK_SIZE ) { + err =nilfs_get_blocksize (sb, sbp, &blocksize); +if (err) + goto failed_sbh; + +if (blocksize <NILFS_MIN_BLOCK_SIZE ) {nilfs_err (sb,"couldn't mount because of unsupported filesystem blocksize %d" , blocksize);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 901/1073 acct: fix potential integer overflow in encode_comp_t()
In reply to Greg Kroah-HartmanFrom: Zheng Yejian <[email protected]>
[ Upstream commit c5f31c655bcc01b6da53b836ac951c1556245305 ]
The integer overflow is descripted with following codes:
Quoted 3 lines
317 static
comp_tencode_comp_t(u64 value)
318 {
319 int exp, rnd;
......
Quoted 4 lines
341 exp <<= MANTSIZE; 342 exp += value; 343 return exp;344 }
Currently comp_t is defined as type of '__u16', but the variable 'exp' is type of 'int', so overflow would happen when variable 'exp' in line 343 is greater than 65535.
--- kernel/acct.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/acct.c +2 -0
@@ -350,6 +350,8 @@ static comp_t encode_comp_t(unsigned long value) exp++; } +if (exp > (((comp_t ) ~0U ) >>MANTSIZE )) +return (comp_t ) ~0U ;/* * Clean it up and polish it off. */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 902/1073 x86/apic: Handle no CONFIG_X86_X2APIC on systems with x2APIC enabled by BIOS
In reply to Greg Kroah-HartmanFrom: Mateusz Jończyk <[email protected]>
[ Upstream commit e3998434da4f5b1f57f8d6a8a9f8502ee3723bae ]
A kernel that was compiled without CONFIG_X86_X2APIC was unable to boot on platforms that have x2APIC already enabled in the BIOS before starting the kernel.
The kernel was supposed to panic with an approprite error message in validate_x2apic() due to the missing X2APIC support.
However, validate_x2apic() was run too late in the boot cycle, and the kernel tried to initialize the APIC nonetheless. This resulted in an earlier panic in setup_local_APIC() because the APIC was not registered.
In my experiments, a panic message in setup_local_APIC() was not visible in the graphical console, which resulted in a hang with no indication what has gone wrong.
Instead of calling panic(), disable the APIC, which results in a somewhat working system with the PIC only (and no SMP). This way the user is able to diagnose the problem more easily.
Disabling X2APIC mode is not an option because it's impossible on systems with locked x2APIC.
The proper place to disable the APIC in this case is in check_x2apic(), which is called early from setup_arch(). Doing this in __apic_intr_mode_select() is too late.
Make check_x2apic() unconditionally available and remove the empty stub.
--- arch/x86/Kconfig | 4 ++-- arch/x86/include/asm/apic.h | 3 +-- arch/x86/kernel/apic/apic.c | 13 ++++++++----- 3 files changed, 11 insertions(+), 9 deletions(-)
arch/x86/Kconfig +2 -2
@@ -450,8 +450,8 @@ config X86_X2APIC Some Intel systems circa 2022 and later are locked into x2APIC mode and can not fall back to the legacy APIC modes if SGX or TDX are - enabled in the BIOS. They will be unable to boot without enabling - this option. + enabled in the BIOS. They will boot with very reduced functionality + without enabling this option. If you don't know what to do here, say N.
arch/x86/include/asm/apic.h +1 -2
@@ -249,7 +249,6 @@ static inline u64 native_x2apic_icr_read(void)extern int x2apic_mode;extern int x2apic_phys;extern void __init x2apic_set_max_apicid (u32 apicid); -extern void __init check_x2apic (void );extern void x2apic_setup (void );static inline int x2apic_enabled (void ) {
@@ -258,13 +257,13 @@ static inline int x2apic_enabled(void)#define x2apic_supported () (boot_cpu_has(X86_FEATURE_X2APIC))#else /* !CONFIG_X86_X2APIC */ -static inline void check_x2apic (void ) { }static inline void x2apic_setup (void ) { }static inline int x2apic_enabled (void ) {return 0 ; }#define x2apic_mode (0)#define x2apic_supported () (0)#endif /* !CONFIG_X86_X2APIC */ +extern void __init check_x2apic (void );struct irq_data ;
arch/x86/kernel/apic/apic.c +8 -5
@@ -1931,16 +1931,19 @@ void __init check_x2apic(void) } }#else /* CONFIG_X86_X2APIC */ -static int __init validate_x2apic (void ) +void __init check_x2apic (void ) {if (!apic_is_x2apic_enabled ()) -return 0 ; +return ;/* -* Checkme: Can we simply turn off x2apic here instead of panic? +* Checkme: Can we simply turn off x2APIC here instead of disabling the APIC? */ -panic ("BIOS has enabled x2apic but kernel doesn't support x2apic, please disable x2apic in BIOS.\n" ); +pr_err ("Kernel does not support x2APIC, please recompile with CONFIG_X86_X2APIC.\n" ); +pr_err ("Disabling APIC, expect reduced performance and functionality.\n" ); + + disable_apic =1 ; +setup_clear_cpu_cap (X86_FEATURE_APIC ); } -early_initcall (validate_x2apic);static inline void try_to_enable_x2apic (int remap_mode) { }static inline void __x2apic_enable (void ) { }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 903/1073 ACPI: x86: Add skip i2c clients quirk for Lenovo Yoga Tab 3 Pro (YT3-X90F)
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit fe820db35275561d8bf86ad19044d40ffc95bc04 ]
The Lenovo Yoga Tab 3 Pro (YT3-X90F) is a x86 (Cherry Trail) tablet which ships with Android x86 as factory OS. The Android x86 kernel fork ignores I2C devices described in the DSDT, except for the PMIC and Audio codecs.
As usual the Lenovo Yoga Tab 3 Pro's DSDT contains a bunch of extra I2C devices which are not actually there, causing various resource conflicts. Add an ACPI_QUIRK_SKIP_I2C_CLIENTS quirk for the Lenovo Yoga Tab 3 Pro to the acpi_quirk_skip_dmi_ids table to woraround this.
ACPI_QUIRK_SKIP_I2C_CLIENTS handling uses i2c_acpi_known_good_ids[], so that PMICs and Audio codecs will still be enumerated properly. The Lenovo Yoga Tab 3 Pro uses a Whiskey Cove PMIC, add the INT34D3 HID for this PMIC to the i2c_acpi_known_good_ids[] list.
--- drivers/acpi/x86/utils.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/acpi/x86/utils.c +12 -1
@@ -308,7 +308,7 @@ static const struct dmi_system_id acpi_quirk_skip_dmi_ids[] = { ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), }, { -/* Lenovo Yoga Tablet 1050F/L */ +/* Lenovo Yoga Tablet 2 1050F/L */ .matches = {DMI_MATCH (DMI_SYS_VENDOR ,"Intel Corp." ), DMI_MATCH(DMI_PRODUCT_NAME, "VALLEYVIEW C0 PLATFORM"),
@@ -319,6 +319,16 @@ static const struct dmi_system_id acpi_quirk_skip_dmi_ids[] = { .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), }, + { +/* Lenovo Yoga Tab 3 Pro X90F */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Intel Corporation" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"CHERRYVIEW D1 PLATFORM" ), + DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"), + }, + .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | + ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), + }, {/* Nextbook Ares 8 */ .matches = {
@@ -348,6 +358,7 @@ static const struct acpi_device_id i2c_acpi_known_good_ids[] = { { "10EC5640", 0 }, /* RealTek ALC5640 audio codec */ { "INT33F4", 0 }, /* X-Powers AXP288 PMIC */ { "INT33FD", 0 }, /* Intel Crystal Cove PMIC */ + { "INT34D3", 0 }, /* Intel Whiskey Cove PMIC */ { "NPCE69A", 0 }, /* Asus Transformer keyboard dock */ {} };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 904/1073 ACPI: x86: Add skip i2c clients quirk for Medion Lifetab S10346
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit ecc6aaabcedc276128315f57755364106017c606 ]
The Medion Lifetab S10346 is a x86 tablet which ships with Android x86 as factory OS. The Android x86 kernel fork ignores I2C devices described in the DSDT, except for the PMIC and Audio codecs.
As usual the Medion Lifetab S10346's DSDT contains a bunch of extra I2C devices which are not actually there, causing various resource conflicts. Add an ACPI_QUIRK_SKIP_I2C_CLIENTS quirk for the Medion Lifetab S10346 to the acpi_quirk_skip_dmi_ids table to woraround this.
--- drivers/acpi/x86/utils.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/acpi/x86/utils.c +11 -0
@@ -329,6 +329,17 @@ static const struct dmi_system_id acpi_quirk_skip_dmi_ids[] = { .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), }, + { +/* Medion Lifetab S10346 */ + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"AMI Corporation" ), +DMI_MATCH (DMI_BOARD_NAME ,"Aptio CRB" ), +/* Way too generic, also match on BIOS data */ + DMI_MATCH(DMI_BIOS_DATE, "10/22/2015"), + }, + .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | + ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), + }, {/* Nextbook Ares 8 */ .matches = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 905/1073 hfs: fix OOB Read in __hfs_brec_find
In reply to Greg Kroah-HartmanFrom: ZhangPeng <[email protected]>
[ Upstream commit 8d824e69d9f3fa3121b2dda25053bae71e2460d2 ]
Syzbot reported a OOB read bug:
==================================================================
BUG: KASAN: slab-out-of-bounds in hfs_strcmp+0x117/0x190 fs/hfs/string.c:84 Read of size 1 at addr ffff88807eb62c4e by task kworker/u4:1/11 CPU: 1 PID: 11 Comm: kworker/u4:1 Not tainted 6.1.0-rc6-syzkaller-00308-g644e9524388a #0 Workqueue: writeback wb_workfn (flush-7:0) Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106 print_address_description+0x74/0x340 mm/kasan/report.c:284 print_report+0x107/0x1f0 mm/kasan/report.c:395 kasan_report+0xcd/0x100 mm/kasan/report.c:495 hfs_strcmp+0x117/0x190 fs/hfs/string.c:84 __hfs_brec_find+0x213/0x5c0 fs/hfs/bfind.c:75 hfs_brec_find+0x276/0x520 fs/hfs/bfind.c:138 hfs_write_inode+0x34c/0xb40 fs/hfs/inode.c:462 write_inode fs/fs-writeback.c:1440 [inline]
If the input inode of hfs_write_inode() is incorrect:
struct inode
struct hfs_inode_info
struct hfs_cat_key
struct hfs_name
u8 len # len is greater than HFS_NAMELEN(31) which is the
maximum length of an HFS filename
OOB read occurred:hfs_write_inode()
hfs_brec_find()
__hfs_brec_find()
hfs_cat_keycmp()
hfs_strcmp() # OOB read occurred due to len is too large
Fix this by adding a Check on len in hfs_write_inode() before calling hfs_brec_find().
--- fs/hfs/inode.c | 2 ++ 1 file changed, 2 insertions(+)
fs/hfs/inode.c +2 -0
@@ -458,6 +458,8 @@ int hfs_write_inode(struct inode *inode, struct writeback_control *wbc)/* panic? */ return -EIO ; +if (HFS_I (main_inode)->cat_key.CName.len >HFS_NAMELEN ) +return -EIO ; fd.search_key->cat =HFS_I (main_inode)->cat_key;if (hfs_brec_find (&fd))/* panic? */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 906/1073 drm/etnaviv: add missing quirks for GC300
In reply to Greg Kroah-HartmanFrom: Doug Brown <[email protected]>
[ Upstream commit cc7d3fb446a91f24978a6aa59cbb578f92e22242 ]
The GC300's features register doesn't specify that a 2D pipe is available, and like the GC600, its idle register reports zero bits where modules aren't present.
--- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +9 -2
@@ -416,6 +416,12 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)if (gpu->identity.model == chipModel_GC700) gpu->identity.features &= ~chipFeatures_FAST_CLEAR; +/* These models/revisions don't have the 2D pipe bit */ +if ((gpu->identity.model == chipModel_GC500 && + gpu->identity.revision <=2 ) || + gpu->identity.model == chipModel_GC300) + gpu->identity.features |= chipFeatures_PIPE_2D; + if ((gpu->identity.model == chipModel_GC500 && gpu->identity.revision < 2) || (gpu->identity.model == chipModel_GC300 &&
@@ -449,8 +455,9 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)gpu_read (gpu,VIVS_HI_CHIP_MINOR_FEATURE_5 ); } -/* GC600 idle register reports zero bits where modules aren't present */ -if (gpu->identity.model == chipModel_GC600) +/* GC600/300 idle register reports zero bits where modules aren't present */ +if (gpu->identity.model == chipModel_GC600 || + gpu->identity.model == chipModel_GC300) gpu->idle_mask =VIVS_HI_IDLE_STATE_TX |VIVS_HI_IDLE_STATE_RA | VIVS_HI_IDLE_STATE_SE |
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 907/1073 media: imx-jpeg: Disable useless interrupt to avoid kernel panic
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit c3720e65c9013a7b2a5dbb63e6bf6d74a35dd894 ]
There is a hardware bug that the interrupt STMBUF_HALF may be triggered after or when disable interrupt.
It may led to unexpected kernel panic.
And interrupt STMBUF_HALF and STMBUF_RTND have no other effect. So disable them and the unused interrupts.
meanwhile clear the interrupt status when disable interrupt.
--- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +3 -1
@@ -76,12 +76,14 @@ void print_wrapper_info(struct device *dev, void __iomem *reg)void mxc_jpeg_enable_irq (void __iomem *reg,int slot) { -writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); +writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_STATUS )); +writel (0xF0C , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); }void mxc_jpeg_disable_irq (void __iomem *reg,int slot) {writel (0x0 , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); +writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_STATUS )); }void mxc_jpeg_sw_reset (void __iomem *reg)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 908/1073 brcmfmac: return error when getting invalid max_flowrings from dongle
In reply to Greg Kroah-HartmanFrom: Wright Feng <[email protected]>
[ Upstream commit 2aca4f3734bd717e04943ddf340d49ab62299a00 ]
When firmware hit trap at initialization, host will read abnormal max_flowrings number from dongle, and it will cause kernel panic when doing iowrite to initialize dongle ring.
To detect this error at early stage, we directly return error when getting invalid max_flowrings(>256).
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +4 -0
@@ -1120,6 +1120,10 @@ static int brcmf_pcie_init_ringbuffers(struct brcmf_pciedev_info *devinfo)BRCMF_NROF_H2D_COMMON_MSGRINGS ; max_completionrings =BRCMF_NROF_D2H_COMMON_MSGRINGS ; } +if (max_flowrings >256 ) { +brcmf_err (bus,"invalid max_flowrings(%d)\n" , max_flowrings); +return -EIO ; + }if (devinfo->dma_idx_sz !=0 ) { bufsz = (max_submissionrings + max_completionrings) *
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 909/1073 wifi: ath9k: verify the expected usb_endpoints are present
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
[ Upstream commit 16ef02bad239f11f322df8425d302be62f0443ce ]
The bug arises when a USB device claims to be an ATH9K but doesn't have the expected endpoints. (In this case there was an interrupt endpoint where the driver expected a bulk endpoint.) The kernel needs to be able to handle such devices without getting an internal error.
usb 1-1: BOGUS urb xfer, pipe 3 != type 1
WARNING: CPU: 3 PID: 500 at drivers/usb/core/urb.c:493 usb_submit_urb+0xce2/0x1430 drivers/usb/core/urb.c:493 Modules linked in: CPU: 3 PID: 500 Comm: kworker/3:2 Not tainted 5.10.135-syzkaller #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 Workqueue: events request_firmware_work_func RIP: 0010:usb_submit_urb+0xce2/0x1430 drivers/usb/core/urb.c:493 Call Trace: ath9k_hif_usb_alloc_rx_urbs drivers/net/wireless/ath/ath9k/hif_usb.c:908 [inline] ath9k_hif_usb_alloc_urbs+0x75e/0x1010 drivers/net/wireless/ath/ath9k/hif_usb.c:1019 ath9k_hif_usb_dev_init drivers/net/wireless/ath/ath9k/hif_usb.c:1109 [inline] ath9k_hif_usb_firmware_cb+0x142/0x530 drivers/net/wireless/ath/ath9k/hif_usb.c:1242 request_firmware_work_func+0x12e/0x240 drivers/base/firmware_loader/main.c:1097 process_one_work+0x9af/0x1600 kernel/workqueue.c:2279 worker_thread+0x61d/0x12f0 kernel/workqueue.c:2425 kthread+0x3b4/0x4a0 kernel/kthread.c:313 ret_from_fork+0x22/0x30 arch/x86/entry/entry_64.S:299
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/net/wireless/ath/ath9k/hif_usb.c +14 -0
@@ -1327,10 +1327,24 @@ static int send_eject_command(struct usb_interface *interface)static int ath9k_hif_usb_probe (struct usb_interface *interface,const struct usb_device_id *id) { +struct usb_endpoint_descriptor *bulk_in, *bulk_out, *int_in, *int_out;struct usb_device *udev =interface_to_usbdev (interface); +struct usb_host_interface *alt;struct hif_device_usb *hif_dev;int ret =0 ; +/* Verify the expected endpoints are present */ + alt = interface->cur_altsetting; +if (usb_find_common_endpoints (alt, &bulk_in, &bulk_out, &int_in, &int_out) <0 || +usb_endpoint_num (bulk_in) !=USB_WLAN_RX_PIPE || +usb_endpoint_num (bulk_out) !=USB_WLAN_TX_PIPE || +usb_endpoint_num (int_in) !=USB_REG_IN_PIPE || +usb_endpoint_num (int_out) !=USB_REG_OUT_PIPE ) { +dev_err (&udev->dev, +"ath9k_htc: Device endpoint numbers are not the expected ones\n" ); +return -ENODEV ; + } +if (id->driver_info ==STORAGE_DEVICE )return send_eject_command (interface);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 910/1073 wifi: ar5523: Fix use-after-free on ar5523_cmd() timed out
In reply to Greg Kroah-HartmanFrom: Shigeru Yoshida <[email protected]>
[ Upstream commit b6702a942a069c2a975478d719e98d83cdae1797 ]
syzkaller reported use-after-free with the stack trace like below [1]:
[ 38.960489][ C3] ================================================================== [ 38.963216][ C3] BUG: KASAN: use-after-free in ar5523_cmd_tx_cb+0x220/0x240 [ 38.964950][ C3] Read of size 8 at addr ffff888048e03450 by task swapper/3/0 [ 38.966363][ C3] [ 38.967053][ C3] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 6.0.0-09039-ga6afa4199d3d-dirty #18 [ 38.968464][ C3] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.0-1.fc36 04/01/2014 [ 38.969959][ C3] Call Trace: [ 38.970841][ C3] <IRQ> [ 38.971663][ C3] dump_stack_lvl+0xfc/0x174 [ 38.972620][ C3] print_report.cold+0x2c3/0x752 [ 38.973626][ C3] ? ar5523_cmd_tx_cb+0x220/0x240 [ 38.974644][ C3] kasan_report+0xb1/0x1d0 [ 38.975720][ C3] ? ar5523_cmd_tx_cb+0x220/0x240 [ 38.976831][ C3] ar5523_cmd_tx_cb+0x220/0x240 [ 38.978412][ C3] __usb_hcd_giveback_urb+0x353/0x5b0 [ 38.979755][ C3] usb_hcd_giveback_urb+0x385/0x430 [ 38.981266][ C3] dummy_timer+0x140c/0x34e0 [ 38.982925][ C3] ? notifier_call_chain+0xb5/0x1e0 [ 38.984761][ C3] ? rcu_read_lock_sched_held+0xb/0x60 [ 38.986242][ C3] ? lock_release+0x51c/0x790 [ 38.987323][ C3] ? _raw_read_unlock_irqrestore+0x37/0x70 [ 38.988483][ C3] ? __wake_up_common_lock+0xde/0x130 [ 38.989621][ C3] ? reacquire_held_locks+0x4a0/0x4a0 [ 38.990777][ C3] ? lock_acquire+0x472/0x550 [ 38.991919][ C3] ? rcu_read_lock_sched_held+0xb/0x60 [ 38.993138][ C3] ? lock_acquire+0x472/0x550 [ 38.994890][ C3] ? dummy_urb_enqueue+0x860/0x860 [ 38.996266][ C3] ? do_raw_spin_unlock+0x16f/0x230 [ 38.997670][ C3] ? dummy_urb_enqueue+0x860/0x860 [ 38.999116][ C3] call_timer_fn+0x1a0/0x6a0 [ 39.000668][ C3] ? add_timer_on+0x4a0/0x4a0 [ 39.002137][ C3] ? reacquire_held_locks+0x4a0/0x4a0 [ 39.003809][ C3] ? __next_timer_interrupt+0x226/0x2a0 [ 39.005509][ C3] __run_timers.part.0+0x69a/0xac0 [ 39.007025][ C3] ? dummy_urb_enqueue+0x860/0x860 [ 39.008716][ C3] ? call_timer_fn+0x6a0/0x6a0 [ 39.010254][ C3] ? cpuacct_percpu_seq_show+0x10/0x10 [ 39.011795][ C3] ? kvm_sched_clock_read+0x14/0x40 [ 39.013277][ C3] ? sched_clock_cpu+0x69/0x2b0 [ 39.014724][ C3] run_timer_softirq+0xb6/0x1d0 [ 39.016196][ C3] __do_softirq+0x1d2/0x9be [ 39.017616][ C3] __irq_exit_rcu+0xeb/0x190 [ 39.019004][ C3] irq_exit_rcu+0x5/0x20 [ 39.020361][ C3] sysvec_apic_timer_interrupt+0x8f/0xb0 [ 39.021965][ C3] </IRQ> [ 39.023237][ C3] <TASK>
In ar5523_probe(), ar5523_host_available() calls ar5523_cmd() as below (there are other functions which finally call ar5523_cmd()):
ar5523_probe()
-> ar5523_host_available()
-> ar5523_cmd_read()
-> ar5523_cmd()
If ar5523_cmd() timed out, then ar5523_host_available() failed and ar5523_probe() freed the device structure. So, ar5523_cmd_tx_cb() might touch the freed structure.
This patch fixes this issue by canceling in-flight tx cmd if submitted urb timed out.
--- drivers/net/wireless/ath/ar5523/ar5523.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/ath/ar5523/ar5523.c +6 -0
@@ -241,6 +241,11 @@ static void ar5523_cmd_tx_cb(struct urb *urb) } } +static void ar5523_cancel_tx_cmd (struct ar5523 *ar) +{ +usb_kill_urb (ar->tx_cmd.urb_tx); +} +static int ar5523_cmd (struct ar5523 *ar,u32 code,const void *idata,int ilen,void *odata,int olen,int flags) {
@@ -280,6 +285,7 @@ static int ar5523_cmd(struct ar5523 *ar, u32 code, const void *idata, }if (!wait_for_completion_timeout (&cmd->done,2 *HZ )) { +ar5523_cancel_tx_cmd (ar); cmd->odata =NULL ;ar5523_err (ar,"timeout waiting for command %02x reply\n" , code);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 911/1073 ASoC: codecs: rt298: Add quirk for KBL-R RVP platform
In reply to Greg Kroah-HartmanFrom: Amadeusz Sławiński <[email protected]>
[ Upstream commit 953dbd1cef18ce9ac0d69c1bd735b929fe52a17e ]
KBL-R RVP platforms also use combojack, so we need to enable that configuration for them.
--- sound/soc/codecs/rt298.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/codecs/rt298.c +7 -0
@@ -1166,6 +1166,13 @@ static const struct dmi_system_id force_combo_jack_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Geminilake") } }, + { + .ident = "Intel Kabylake R RVP", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Intel Corporation" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Kabylake Client platform") + } + }, { } };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 912/1073 ASoC: Intel: avs: Add quirk for KBL-R RVP platform
In reply to Greg Kroah-HartmanFrom: Amadeusz Sławiński <[email protected]>
[ Upstream commit 9d0737fa0e7530313634c0ecd75f09a95ba8d44a ]
KBL-R RVPs contain built-in rt298 codec which requires different PLL clock and .dai_fmt configuration than seen on other boards.
--- sound/soc/intel/avs/boards/rt298.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
sound/soc/intel/avs/boards/rt298.c +22 -2
@@ -6,6 +6,7 @@// Amadeusz Slawinski <[email protected]> // +#include <linux/dmi.h> #include <linux/module.h> #include <sound/jack.h> #include <sound/pcm.h>
@@ -14,6 +15,16 @@#include <sound/soc-acpi.h> #include "../../../codecs/rt298.h" +static const struct dmi_system_id kblr_dmi_table[] = { + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Intel Corporation" ), +DMI_MATCH (DMI_BOARD_NAME ,"Kabylake R DDR4 RVP" ), + }, + }, + {} +}; +static const struct snd_kcontrol_new card_controls[] = {SOC_DAPM_PIN_SWITCH ("Headphone Jack" ),SOC_DAPM_PIN_SWITCH ("Mic Jack" ),
@@ -96,9 +107,15 @@ avs_rt298_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_param {struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_dai *codec_dai =asoc_rtd_to_codec (rtd,0 ); +unsigned int clk_freq;int ret; - ret =snd_soc_dai_set_sysclk (codec_dai,RT298_SCLK_S_PLL ,19200000 ,SND_SOC_CLOCK_IN ); +if (dmi_first_match (kblr_dmi_table)) + clk_freq =24000000 ; +else + clk_freq =19200000 ; + + ret =snd_soc_dai_set_sysclk (codec_dai,RT298_SCLK_S_PLL , clk_freq,SND_SOC_CLOCK_IN );if (ret <0 )dev_err (rtd->dev,"Set codec sysclk failed: %d\n" , ret);
@@ -139,7 +156,10 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in dl->platforms = platform; dl->num_platforms =1 ; dl->id =0 ; - dl->dai_fmt =SND_SOC_DAIFMT_DSP_A |SND_SOC_DAIFMT_NB_NF |SND_SOC_DAIFMT_CBS_CFS ; +if (dmi_first_match (kblr_dmi_table)) + dl->dai_fmt =SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_NB_NF |SND_SOC_DAIFMT_CBS_CFS ; +else + dl->dai_fmt =SND_SOC_DAIFMT_DSP_A |SND_SOC_DAIFMT_NB_NF |SND_SOC_DAIFMT_CBS_CFS ; dl->init = avs_rt298_codec_init; dl->be_hw_params_fixup = avs_rt298_be_fixup; dl->ops = &avs_rt298_ops;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 913/1073 ipmi: fix memleak when unload ipmi driver
In reply to Greg Kroah-HartmanFrom: Zhang Yuchen <[email protected]>
[ Upstream commit 36992eb6b9b83f7f9cdc8e74fb5799d7b52e83e9 ]
After the IPMI disconnect problem, the memory kept rising and we tried to unload the driver to free the memory. However, only part of the free memory is recovered after the driver is uninstalled. Using ebpf to hook free functions, we find that neither ipmi_user nor ipmi_smi_msg is free, only ipmi_recv_msg is free.
We find that the deliver_smi_err_response call in clean_smi_msgs does the destroy processing on each message from the xmit_msg queue without checking the return value and free ipmi_smi_msg.
deliver_smi_err_response is called only at this location. Adding the free handling has no effect.
To verify, try using ebpf to trace the free function.
$ bpftrace -e 'kretprobe:ipmi_alloc_recv_msg {printf("alloc rcv
%p\n",retval);} kprobe:free_recv_msg {printf("free recv %p\n",
arg0)} kretprobe:ipmi_alloc_smi_msg {printf("alloc smi %p\n",
retval);} kprobe:free_smi_msg {printf("free smi %p\n",arg0)}'Message-Id: <[email protected]>
--- drivers/char/ipmi/ipmi_msghandler.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/char/ipmi/ipmi_msghandler.c +6 -2
@@ -3710,12 +3710,16 @@ static void deliver_smi_err_response(struct ipmi_smi *intf,struct ipmi_smi_msg *msg, unsigned char err) { + int rv; msg->rsp[0 ] = msg->data[0 ] |4 ; msg->rsp[1 ] = msg->data[1 ]; msg->rsp[2 ] = err; msg->rsp_size =3 ; -/* It's an error, so it will never requeue, no need to check return. */ -handle_one_recv_msg (intf, msg); + +/* This will never requeue, but it may ask us to free the message. */ + rv =handle_one_recv_msg (intf, msg); +if (rv ==0 ) +ipmi_free_smi_msg (msg); }static void cleanup_smi_msgs (struct ipmi_smi *intf)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 914/1073 wifi: ath10k: Delay the unmapping of the buffer
In reply to Greg Kroah-HartmanFrom: Youghandhar Chintala <[email protected]>
[ Upstream commit acd4324e5f1f11351630234297f95076f0ac9a2f ]
On WCN3990, we are seeing a rare scenario where copy engine hardware is sending a copy complete interrupt to the host driver while still processing the buffer that the driver has sent, this is leading into an SMMU fault triggering kernel panic. This is happening on copy engine channel 3 (CE3) where the driver normally enqueues WMI commands to the firmware. Upon receiving a copy complete interrupt, host driver will immediately unmap and frees the buffer presuming that hardware has processed the buffer. In the issue case, upon receiving copy complete interrupt, host driver will unmap and free the buffer but since hardware is still accessing the buffer (which in this case got unmapped in parallel), SMMU hardware will trigger an SMMU fault resulting in a kernel panic.
In order to avoid this, as a work around, add a delay before unmapping the copy engine source DMA buffer. This is conditionally done for WCN3990 and only for the CE3 channel where issue is seen.
Below is the crash signature:
wifi smmu error: kernel: [ 10.120965] arm-smmu 15000000.iommu: Unhandled context fault: fsr=0x402, iova=0x7fdfd8ac0, fsynr=0x500003,cbfrsynra=0xc1, cb=6 arm-smmu 15000000.iommu: Unhandled context fault:fsr=0x402, iova=0x7fe06fdc0, fsynr=0x710003, cbfrsynra=0xc1, cb=6 qcom-q6v5-mss 4080000.remoteproc: fatal error
received: err_qdi.c:1040:EF:wlan_process:0x1:WLAN RT:0x2091:
cmnos_thread.c:3998:Asserted in copy_engine.c:AXI_ERROR_DETECTED:2149 remoteproc remoteproc0: crash detected in 4080000.remoteproc: type fatal error <3> remoteproc remoteproc0:
handling crash #1 in 4080000.remoteproc
pc : __arm_lpae_unmap+0x500/0x514 lr : __arm_lpae_unmap+0x4bc/0x514
sp : ffffffc011ffb530
x29: ffffffc011ffb590 x28: 0000000000000000
x27: 0000000000000000 x26: 0000000000000004
x25: 0000000000000003 x24: ffffffc011ffb890
x23: ffffffa762ef9be0 x22: ffffffa77244ef00
x21: 0000000000000009 x20: 00000007fff7c000
x19: 0000000000000003 x18: 0000000000000000
x17: 0000000000000004 x16: ffffffd7a357d9f0
x15: 0000000000000000 x14: 00fd5d4fa7ffffff
x13: 000000000000000e x12: 0000000000000000
x11: 00000000ffffffff x10: 00000000fffffe00
x9 : 000000000000017c x8 : 000000000000000c
x7 : 0000000000000000 x6 : ffffffa762ef9000
x5 : 0000000000000003 x4 : 0000000000000004
x3 : 0000000000001000 x2 : 00000007fff7c000
x1 : ffffffc011ffb890 x0 : 0000000000000000 Call trace:
__arm_lpae_unmap+0x500/0x514 __arm_lpae_unmap+0x4bc/0x514 __arm_lpae_unmap+0x4bc/0x514 arm_lpae_unmap_pages+0x78/0xa4 arm_smmu_unmap_pages+0x78/0x104 __iommu_unmap+0xc8/0x1e4 iommu_unmap_fast+0x38/0x48 __iommu_dma_unmap+0x84/0x104 iommu_dma_free+0x34/0x50 dma_free_attrs+0xa4/0xd0 ath10k_htt_rx_free+0xc4/0xf4 [ath10k_core] ath10k_core_stop+0x64/0x7c [ath10k_core] ath10k_halt+0x11c/0x180 [ath10k_core] ath10k_stop+0x54/0x94 [ath10k_core] drv_stop+0x48/0x1c8 [mac80211] ieee80211_do_open+0x638/0x77c [mac80211] ieee80211_open+0x48/0x5c [mac80211] __dev_open+0xb4/0x174 __dev_change_flags+0xc4/0x1dc dev_change_flags+0x3c/0x7c devinet_ioctl+0x2b4/0x580 inet_ioctl+0xb0/0x1b4 sock_do_ioctl+0x4c/0x16c compat_ifreq_ioctl+0x1cc/0x35c compat_sock_ioctl+0x110/0x2ac __arm64_compat_sys_ioctl+0xf4/0x3e0 el0_svc_common+0xb4/0x17c el0_svc_compat_handler+0x2c/0x58 el0_svc_compat+0x8/0x2c
Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.2.0-01387-QCAHLSWMTPLZ-1
--- drivers/net/wireless/ath/ath10k/core.c | 16 ++++++++++++++++ drivers/net/wireless/ath/ath10k/htc.c | 9 +++++++++ drivers/net/wireless/ath/ath10k/hw.h | 2 ++ 3 files changed, 27 insertions(+)
drivers/net/wireless/ath/ath10k/core.c +16 -0
@@ -99,6 +99,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA988X_HW_2_0_VERSION,
@@ -138,6 +139,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA9887_HW_1_0_VERSION,
@@ -178,6 +180,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA6174_HW_3_2_VERSION,
@@ -213,6 +216,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = true, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA6174_HW_2_1_VERSION,
@@ -252,6 +256,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA6174_HW_2_1_VERSION,
@@ -291,6 +296,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA6174_HW_3_0_VERSION,
@@ -330,6 +336,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA6174_HW_3_2_VERSION,
@@ -373,6 +380,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = true, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA99X0_HW_2_0_DEV_VERSION,
@@ -418,6 +426,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA9984_HW_1_0_DEV_VERSION,
@@ -470,6 +479,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA9888_HW_2_0_DEV_VERSION,
@@ -519,6 +529,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA9377_HW_1_0_DEV_VERSION,
@@ -558,6 +569,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA9377_HW_1_1_DEV_VERSION,
@@ -599,6 +611,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA9377_HW_1_1_DEV_VERSION,
@@ -631,6 +644,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA4019_HW_1_0_DEV_VERSION,
@@ -677,6 +691,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = WCN3990_HW_1_0_DEV_VERSION,
@@ -709,6 +724,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = true, .hw_restart_disconnect = true, .use_fw_tx_credits = false, + .delay_unmap_buffer = true, }, };
drivers/net/wireless/ath/ath10k/htc.c +9 -0
@@ -56,6 +56,15 @@ void ath10k_htc_notify_tx_completion(struct ath10k_htc_ep *ep,ath10k_dbg (ar,ATH10K_DBG_HTC ,"%s: ep %d skb %pK\n" , __func__, ep->eid, skb); +/* A corner case where the copy completion is reaching to host but still +* copy engine is processing it due to which host unmaps corresponding +* memory and causes SMMU fault, hence as workaround adding delay +* the unmapping memory to avoid SMMU faults. +*/ +if (ar->hw_params.delay_unmap_buffer && + ep->ul_pipe_id ==3 ) +mdelay (2 ); + hdr = (struct ath10k_htc_hdr *)skb->data;ath10k_htc_restore_tx_skb (ep->htc, skb);
drivers/net/wireless/ath/ath10k/hw.h +2 -0
@@ -637,6 +637,8 @@ struct ath10k_hw_params {bool hw_restart_disconnect;bool use_fw_tx_credits; + +bool delay_unmap_buffer; };struct htt_resp ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 915/1073 drm/amd/display: prevent memory leak
In reply to Greg Kroah-HartmanFrom: gehao <[email protected]>
[ Upstream commit d232afb1f3417ae8194ccf19ad3a8360e70e104e ]
In dce6(0,1,4)_create_resource_pool and dce80_create_resource_pool the allocated memory should be released if construct pool fails.
--- drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c | 3 +++ drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c | 2 ++ 2 files changed, 5 insertions(+)
drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c +3 -0
@@ -1128,6 +1128,7 @@ struct resource_pool *dce60_create_resource_pool(if (dce60_construct (num_virtual_links, dc, pool))return &pool->base; +kfree (pool);BREAK_TO_DEBUGGER ();return NULL ; }
@@ -1325,6 +1326,7 @@ struct resource_pool *dce61_create_resource_pool(if (dce61_construct (num_virtual_links, dc, pool))return &pool->base; +kfree (pool);BREAK_TO_DEBUGGER ();return NULL ; }
@@ -1518,6 +1520,7 @@ struct resource_pool *dce64_create_resource_pool(if (dce64_construct (num_virtual_links, dc, pool))return &pool->base; +kfree (pool);BREAK_TO_DEBUGGER ();return NULL ; }
drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c +2 -0
@@ -1137,6 +1137,7 @@ struct resource_pool *dce80_create_resource_pool(if (dce80_construct (num_virtual_links, dc, pool))return &pool->base; +kfree (pool);BREAK_TO_DEBUGGER ();return NULL ; }
@@ -1336,6 +1337,7 @@ struct resource_pool *dce81_create_resource_pool(if (dce81_construct (num_virtual_links, dc, pool))return &pool->base; +kfree (pool);BREAK_TO_DEBUGGER ();return NULL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 916/1073 drm/edid: add a quirk for two LG monitors to get them to work on 10bpc
In reply to Greg Kroah-HartmanFrom: Hamza Mahfooz <[email protected]>
[ Upstream commit aa193f7eff8ff753577351140b8af13b76cdc7c2 ]
The LG 27GP950 and LG 27GN950 have visible display corruption when trying to use 10bpc modes. So, to fix this, cap their maximum DSC target bitrate to 15bpp.
--- drivers/gpu/drm/drm_edid.c | 12 ++++++++++++ include/drm/drm_connector.h | 6 ++++++ 2 files changed, 18 insertions(+)
drivers/gpu/drm/drm_edid.c +12 -0
@@ -87,6 +87,8 @@ static int oui(u8 first, u8 second, u8 third)#define EDID_QUIRK_FORCE_10BPC (1 << 11)/* Non desktop display (i.e. HMD) */ #define EDID_QUIRK_NON_DESKTOP (1 << 12) +/* Cap the DSC target bitrate to 15bpp */ +#define EDID_QUIRK_CAP_DSC_15BPP (1 << 13)#define MICROSOFT_IEEE_OUI 0xca125c
@@ -147,6 +149,12 @@ static const struct edid_quirk {EDID_QUIRK ('F' ,'C' ,'M' ,13600 ,EDID_QUIRK_PREFER_LARGE_75 |EDID_QUIRK_DETAILED_IN_CM ), +/* LG 27GP950 */ +EDID_QUIRK ('G' ,'S' ,'M' ,0x5bbf ,EDID_QUIRK_CAP_DSC_15BPP ), + +/* LG 27GN950 */ +EDID_QUIRK ('G' ,'S' ,'M' ,0x5b9a ,EDID_QUIRK_CAP_DSC_15BPP ), +/* LGD panel of HP zBook 17 G2, eDP 10 bpc, but reports unknown bpc */ EDID_QUIRK('L', 'G', 'D', 764, EDID_QUIRK_FORCE_10BPC),
@@ -6116,6 +6124,7 @@ static void drm_reset_display_info(struct drm_connector *connector) info->mso_stream_count =0 ; info->mso_pixel_overlap =0 ; + info->max_dsc_bpp =0 ; } static u32 update_display_info(struct drm_connector *connector,
@@ -6202,6 +6211,9 @@ static u32 update_display_info(struct drm_connector *connector, info->non_desktop = true; } +if (quirks &EDID_QUIRK_CAP_DSC_15BPP ) + info->max_dsc_bpp =15 ; +return quirks; }
include/drm/drm_connector.h +6 -0
@@ -635,6 +635,12 @@ struct drm_display_info {* @mso_pixel_overlap: eDP MSO segment pixel overlap, 0-8 pixels. */ u8 mso_pixel_overlap; + +/** +* @max_dsc_bpp: Maximum DSC target bitrate, if it is set to 0 the +* monitor's default value is used instead. +*/ +u32 max_dsc_bpp; }; int drm_display_info_set_bus_formats(struct drm_display_info *info,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 917/1073 Revert "drm/amd/display: Limit max DSC target bpp for specific monitors"
In reply to Greg Kroah-HartmanFrom: Hamza Mahfooz <[email protected]>
[ Upstream commit 6803dfd3a69ccb318772463a86e40929fd4fbac7 ]
This reverts commit 55eea8ef98641f6e1e1c202bd3a49a57c1dd4059.
This quirk is now handled in the DRM core, so we can drop all of the internal code that was added to handle it.
--- .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 35 ------------------- 1 file changed, 35 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +0 -35
@@ -41,39 +41,6 @@#include "dm_helpers.h" #include "ddc_service_types.h" -struct monitor_patch_info { -unsigned int manufacturer_id; -unsigned int product_id; -void (*patch_func)(struct dc_edid_caps *edid_caps,unsigned int param); -unsigned int patch_param; -}; -static void set_max_dsc_bpp_limit (struct dc_edid_caps *edid_caps,unsigned int param); - -static const struct monitor_patch_info monitor_patch_table[] = { -{0x6D1E ,0x5BBF , set_max_dsc_bpp_limit,15 }, -{0x6D1E ,0x5B9A , set_max_dsc_bpp_limit,15 }, -}; - -static void set_max_dsc_bpp_limit (struct dc_edid_caps *edid_caps,unsigned int param) -{ -if (edid_caps) - edid_caps->panel_patch.max_dsc_target_bpp_limit = param; -} - -static int amdgpu_dm_patch_edid_caps (struct dc_edid_caps *edid_caps) -{ -int i, ret =0 ; - -for (i =0 ; i <ARRAY_SIZE (monitor_patch_table); i++) -if ((edid_caps->manufacturer_id == monitor_patch_table[i].manufacturer_id) - && (edid_caps->product_id == monitor_patch_table[i].product_id)) { - monitor_patch_table[i].patch_func (edid_caps, monitor_patch_table[i].patch_param); - ret++; - } - -return ret; -} -/* dm_helpers_parse_edid_caps * * Parse edid caps
@@ -148,8 +115,6 @@ enum dc_edid_status dm_helpers_parse_edid_caps(kfree (sads);kfree (sadb); -amdgpu_dm_patch_edid_caps (edid_caps); -return result; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 918/1073 drm/rockchip: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit e3558747ebe15306e6d0b75bd6d211436be4a7d5 ]
Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() to avoid device usage counter leak.
--- drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 ++-- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +1 -1
@@ -1201,7 +1201,7 @@ static int dw_mipi_dsi_dphy_power_on(struct phy *phy)return i; } - ret =pm_runtime_get_sync (dsi->dev); + ret =pm_runtime_resume_and_get (dsi->dev);if (ret <0 ) {DRM_DEV_ERROR (dsi->dev,"failed to enable device: %d\n" , ret);return ret;
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2 -2
@@ -605,7 +605,7 @@ static int vop_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state)struct vop *vop =to_vop (crtc);int ret, i; - ret =pm_runtime_get_sync (vop->dev); + ret =pm_runtime_resume_and_get (vop->dev);if (ret <0 ) {DRM_DEV_ERROR (vop->dev,"failed to get pm runtime: %d\n" , ret);return ret;
@@ -1953,7 +1953,7 @@ static int vop_initial(struct vop *vop)return PTR_ERR (vop->dclk); } - ret =pm_runtime_get_sync (vop->dev); + ret =pm_runtime_resume_and_get (vop->dev);if (ret <0 ) {DRM_DEV_ERROR (vop->dev,"failed to get pm runtime: %d\n" , ret);return ret;
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +1 -1
@@ -823,7 +823,7 @@ static void vop2_enable(struct vop2 *vop2) {int ret; - ret =pm_runtime_get_sync (vop2->dev); + ret =pm_runtime_resume_and_get (vop2->dev);if (ret <0 ) {drm_err (vop2->drm,"failed to get pm runtime: %d\n" , ret);return ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 919/1073 blk-mq: avoid double ->queue_rq() because of early timeout
In reply to Greg Kroah-HartmanFrom: David Jeffery <[email protected]>
[ Upstream commit 82c229476b8f6afd7e09bc4dc77d89dc19ff7688 ]
David Jeffery found one double ->queue_rq() issue, so far it can be triggered in VM use case because of long vmexit latency or preempt latency of vCPU pthread or long page fault in vCPU pthread, then block IO req could be timed out before queuing the request to hardware but after calling blk_mq_start_request() during ->queue_rq(), then timeout handler may handle it by requeue, then double ->queue_rq() is caused, and kernel panic.
So far, it is driver's responsibility to cover the race between timeout and completion, so it seems supposed to be solved in driver in theory, given driver has enough knowledge.
But it is really one common problem, lots of driver could have similar issue, and could be hard to fix all affected drivers, even it isn't easy for driver to handle the race. So David suggests this patch by draining in-progress ->queue_rq() for solving this issue.
--- block/blk-mq.c | 56 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 12 deletions(-)
block/blk-mq.c +44 -12
@@ -1442,7 +1442,13 @@ static void blk_mq_rq_timed_out(struct request *req)blk_add_timer (req); } -static bool blk_mq_req_expired (struct request *rq,unsigned long *next) +struct blk_expired_data { +bool has_timedout_rq; +unsigned long next; +unsigned long timeout_start; +}; + +static bool blk_mq_req_expired (struct request *rq,struct blk_expired_data *expired) {unsigned long deadline;
@@ -1452,13 +1458,13 @@ static bool blk_mq_req_expired(struct request *rq, unsigned long *next)return false; deadline =READ_ONCE (rq->deadline); -if (time_after_eq (jiffies, deadline)) +if (time_after_eq (expired->timeout_start, deadline))return true; -if (*next ==0 ) - *next = deadline; -else if (time_after (*next, deadline)) - *next = deadline; +if (expired->next ==0 ) + expired->next = deadline; +else if (time_after (expired->next, deadline)) + expired->next = deadline;return false; }
@@ -1472,7 +1478,7 @@ void blk_mq_put_rq_ref(struct request *rq)static bool blk_mq_check_expired (struct request *rq,void *priv) { -unsigned long *next = priv; +struct blk_expired_data *expired = priv;/* * blk_mq_queue_tag_busy_iter() has locked the request, so it cannot
@@ -1481,7 +1487,18 @@ static bool blk_mq_check_expired(struct request *rq, void *priv)* it was completed and reallocated as a new request after returning * from blk_mq_check_expired(). */ -if (blk_mq_req_expired (rq, next)) +if (blk_mq_req_expired (rq, expired)) { + expired->has_timedout_rq = true; +return false; + } +return true; +} + +static bool blk_mq_handle_expired (struct request *rq,void *priv) +{ +struct blk_expired_data *expired = priv; + +if (blk_mq_req_expired (rq, expired))blk_mq_rq_timed_out (rq);return true; }
@@ -1490,7 +1507,9 @@ static void blk_mq_timeout_work(struct work_struct *work) {struct request_queue *q = container_of(work, struct request_queue, timeout_work); -unsigned long next =0 ; +struct blk_expired_data expired = { + .timeout_start = jiffies, + };struct blk_mq_hw_ctx *hctx;unsigned long i;
@@ -1510,10 +1529,23 @@ static void blk_mq_timeout_work(struct work_struct *work)if (!percpu_ref_tryget (&q->q_usage_counter))return ; -blk_mq_queue_tag_busy_iter (q, blk_mq_check_expired, &next); +/* check if there is any timed-out request */ +blk_mq_queue_tag_busy_iter (q, blk_mq_check_expired, &expired); +if (expired.has_timedout_rq) { +/* +* Before walking tags, we must ensure any submit started +* before the current time has finished. Since the submit +* uses srcu or rcu, wait for a synchronization point to +* ensure all running submits have finished +*/ +blk_mq_wait_quiesce_done (q); + + expired.next =0 ; +blk_mq_queue_tag_busy_iter (q, blk_mq_handle_expired, &expired); + } -if (next !=0 ) { -mod_timer (&q->timeout, next); +if (expired.next !=0 ) { +mod_timer (&q->timeout, expired.next); }else {/* * Request timeouts are handled as a forward rolling timer. If
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 920/1073 HID: apple: fix key translations where multiple quirks attempt to translate the same key
In reply to Greg Kroah-HartmanFrom: Kerem Karabay <[email protected]>
[ Upstream commit 5476fcf7f7b901db1cea92acb1abdd12609e30e1 ]
The hid-apple driver does not support chaining translations or dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this problem. The quirk is not set for the Macs where these bugs happen yet (see the 2nd patch for that), but this can be forced by setting the iso_layout parameter. Unfortunately, this only partially works. KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get translated to KEY_102ND, so both of them end up functioning as KEY_GRAVE. This is because the driver translates the keys as if Fn was pressed and the original is sent if it is not pressed, without any further translations happening on the key[#463]. KEY_GRAVE is present at macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by making the translations continue and not return immediately after translating a key so that chained translations work and translations can depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl option a little bit, as it makes it simply use a normal translation instead adding extra code to translate a key to KEY_FN[#381]. This change wasn't put in another patch as the code that translates the Fn key needs to be changed because of the changes in the patch, and those changes would be discarded with the next patch anyway (the part that originally translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit 20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no dedicated escape key and a non-English layout.
--- drivers/hid/hid-apple.c | 102 +++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 58 deletions(-)
drivers/hid/hid-apple.c +44 -58
@@ -314,6 +314,7 @@ static const struct apple_key_translation swapped_option_cmd_keys[] = {static const struct apple_key_translation swapped_fn_leftctrl_keys[] = { {KEY_FN ,KEY_LEFTCTRL }, + {KEY_LEFTCTRL ,KEY_FN }, { } };
@@ -375,24 +376,40 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,struct apple_sc *asc =hid_get_drvdata (hid);const struct apple_key_translation *trans, *table;bool do_translate; -u16 code =0 ; +u16 code = usage->code;unsigned int real_fnmode; -u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL ) : (KEY_FN ); - -if (usage->code == fn_keycode) { - asc->fn_on = !!value; -input_event_with_scancode (input, usage->type,KEY_FN , - usage->hid, value); -return 1 ; - } -if (fnmode ==3 ) { real_fnmode = (asc->quirks &APPLE_IS_NON_APPLE ) ?2 :1 ; }else { real_fnmode = fnmode; } +if (swap_fn_leftctrl) { + trans =apple_find_translation (swapped_fn_leftctrl_keys, code); + +if (trans) + code = trans->to; + } + +if (iso_layout >0 || (iso_layout <0 && (asc->quirks &APPLE_ISO_TILDE_QUIRK ) && + hid->country ==HID_COUNTRY_INTERNATIONAL_ISO )) { + trans =apple_find_translation (apple_iso_keyboard, code); + +if (trans) + code = trans->to; + } + +if (swap_opt_cmd) { + trans =apple_find_translation (swapped_option_cmd_keys, code); + +if (trans) + code = trans->to; + } + +if (code ==KEY_FN ) + asc->fn_on = !!value; +if (real_fnmode) { if (hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI || hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO ||
@@ -430,15 +447,18 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,else table = apple_fn_keys; - trans =apple_find_translation (table, usage->code); + trans =apple_find_translation (table, code);if (trans) { -if (test_bit (trans->from, input->key)) +bool from_is_set =test_bit (trans->from, input->key); +bool to_is_set =test_bit (trans->to, input->key); + +if (from_is_set) code = trans->from; -else if (test_bit (trans->to, input->key)) +else if (to_is_set) code = trans->to; -if (!code) { +if (!(from_is_set || to_is_set)) {if (trans->flags &APPLE_FLAG_FKEY ) {switch (real_fnmode) {case 1 :
@@ -455,62 +475,31 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, do_translate = asc->fn_on; } - code = do_translate ? trans->to : trans->from; +if (do_translate) + code = trans->to; } - -input_event_with_scancode (input, usage->type, code, - usage->hid, value); -return 1 ; }if (asc->quirks &APPLE_NUMLOCK_EMULATION && - (test_bit (usage->code, asc->pressed_numlock) || + (test_bit (code, asc->pressed_numlock) ||test_bit (LED_NUML , input->led))) { - trans =apple_find_translation (powerbook_numlock_keys, - usage->code); + trans =apple_find_translation (powerbook_numlock_keys, code);if (trans) {if (value) -set_bit (usage->code, - asc->pressed_numlock); +set_bit (code, asc->pressed_numlock);else -clear_bit (usage->code, - asc->pressed_numlock); +clear_bit (code, asc->pressed_numlock); -input_event_with_scancode (input, usage->type, - trans->to, usage->hid, value); + code = trans->to; } - -return 1 ; } } -if (iso_layout >0 || (iso_layout <0 && (asc->quirks &APPLE_ISO_TILDE_QUIRK ) && - hid->country ==HID_COUNTRY_INTERNATIONAL_ISO )) { - trans =apple_find_translation (apple_iso_keyboard, usage->code); -if (trans) { -input_event_with_scancode (input, usage->type, - trans->to, usage->hid, value); -return 1 ; - } - } +if (usage->code != code) { +input_event_with_scancode (input, usage->type, code, usage->hid, value); -if (swap_opt_cmd) { - trans =apple_find_translation (swapped_option_cmd_keys, usage->code); -if (trans) { -input_event_with_scancode (input, usage->type, - trans->to, usage->hid, value); -return 1 ; - } - } - -if (swap_fn_leftctrl) { - trans =apple_find_translation (swapped_fn_leftctrl_keys, usage->code); -if (trans) { -input_event_with_scancode (input, usage->type, - trans->to, usage->hid, value); -return 1 ; - } +return 1 ; }return 0 ;
@@ -640,9 +629,6 @@ static void apple_setup_input(struct input_dev *input)apple_setup_key_translation (input, apple2021_fn_keys);apple_setup_key_translation (input, macbookpro_no_esc_fn_keys);apple_setup_key_translation (input, macbookpro_dedicated_esc_fn_keys); - -if (swap_fn_leftctrl) -apple_setup_key_translation (input, swapped_fn_leftctrl_keys); } static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 921/1073 HID: apple: enable APPLE_ISO_TILDE_QUIRK for the keyboards of Macs with the T2 chip
In reply to Greg Kroah-HartmanFrom: Kerem Karabay <[email protected]>
[ Upstream commit 084bc074c231e716cbcb9e8f9db05b17fd3563cf ]
The iso_layout parameter must be manually set to get the driver to swap KEY_102ND and KEY_GRAVE. This patch eliminates the need to do that.
This is safe to do, as Macs with keyboards that do not need the quirk will keep working the same way as the value of hid->country will be different than HID_COUNTRY_INTERNATIONAL_ISO. This was tested by one person with a Mac with the WELLSPRINGT2_J152F keyboard with a layout that does not require the quirk to be set.
--- drivers/hid/hid-apple.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/hid/hid-apple.c +8 -8
@@ -997,21 +997,21 @@ static const struct hid_device_id apple_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS), .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K), - .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL }, + .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132), - .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL }, + .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680), - .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL }, + .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213), - .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL }, + .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 922/1073 wifi: ath11k: Fix qmi_msg_handler data structure initialization
In reply to Greg Kroah-HartmanFrom: Rahul Bhattacharjee <[email protected]>
[ Upstream commit ed3725e15a154ebebf44e0c34806c57525483f92 ]
qmi_msg_handler is required to be null terminated by QMI module. There might be a case where a handler for a msg id is not present in the handlers array which can lead to infinite loop while searching the handler and therefore out of bound access in qmi_invoke_handler(). Hence update the initialization in qmi_msg_handler data structure.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-01100-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/qmi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath11k/qmi.c +3 -0
@@ -3083,6 +3083,9 @@ static const struct qmi_msg_handler ath11k_qmi_msg_handlers[] = { sizeof(struct qmi_wlfw_fw_init_done_ind_msg_v01), .fn = ath11k_qmi_msg_fw_init_done_cb, }, + +/* end of list */ + {}, }; static int ath11k_qmi_ops_new_server(struct qmi_handle *qmi_hdl,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 923/1073 qed (gcc13): use u16 for fid to be big enough
In reply to Greg Kroah-HartmanFrom: Jiri Slaby (SUSE) <[email protected]>
[ Upstream commit 7d84118229bf7f7290438c85caa8e49de52d50c1 ]
gcc 13 correctly reports overflow in qed_grc_dump_addr_range():
In file included from drivers/net/ethernet/qlogic/qed/qed.h:23,
from drivers/net/ethernet/qlogic/qed/qed_debug.c:10:drivers/net/ethernet/qlogic/qed/qed_debug.c: In function 'qed_grc_dump_addr_range':include/linux/qed/qed_if.h:1217:9: error: overflow in conversion from 'int' to 'u8' {aka 'unsigned char'} changes value from '(int)vf_id << 8 | 128' to '128' [-Werror=overflow]
We do:
u8 fid;
...
fid = vf_id << 8 | 128;
Since fid is 16bit (and the stored value above too), fid should be u16, not u8. Fix that.
--- drivers/net/ethernet/qlogic/qed/qed_debug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qed/qed_debug.c +2 -1
@@ -1972,9 +1972,10 @@ static u32 qed_grc_dump_addr_range(struct qed_hwfn *p_hwfn, u8 split_id) {struct dbg_tools_data *dev_data = &p_hwfn->dbg_info; -u8 port_id =0 , pf_id =0 , vf_id =0 , fid =0 ; +u8 port_id =0 , pf_id =0 , vf_id =0 ;bool read_using_dmae = false;u32 thresh; +u16 fid;if (!dump)return len;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 924/1073 drm/meson: Fix return type of meson_encoder_cvbs_mode_valid()
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 6c4e4d35203301906afb53c6d1e1302d4c793c05 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/gpu/drm/meson/meson_encoder_cvbs.c:211:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' with an expression of type 'int (struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.mode_valid = meson_encoder_cvbs_mode_valid,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
->mode_valid() in 'struct drm_bridge_funcs' expects a return type of 'enum drm_mode_status', not 'int'. Adjust the return type of meson_encoder_cvbs_mode_valid() to match the prototype's to resolve the warning and CFI failure.
--- drivers/gpu/drm/meson/meson_encoder_cvbs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/meson/meson_encoder_cvbs.c +4 -3
@@ -116,9 +116,10 @@ static int meson_encoder_cvbs_get_modes(struct drm_bridge *bridge,return i; } -static int meson_encoder_cvbs_mode_valid (struct drm_bridge *bridge, -const struct drm_display_info *display_info, -const struct drm_display_mode *mode) +static enum drm_mode_status +meson_encoder_cvbs_mode_valid (struct drm_bridge *bridge, +const struct drm_display_info *display_info, +const struct drm_display_mode *mode) {if (meson_cvbs_get_mode (mode))return MODE_OK ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 925/1073 bpf: make sure skb->len != 0 when redirecting to a tunneling device
In reply to Greg Kroah-HartmanFrom: Stanislav Fomichev <[email protected]>
[ Upstream commit 07ec7b502800ba9f7b8b15cb01dd6556bb41aaca ]
syzkaller managed to trigger another case where skb->len == 0 when we enter __dev_queue_xmit:
WARNING: CPU: 0 PID: 2470 at include/linux/skbuff.h:2576 skb_assert_len include/linux/skbuff.h:2576 [inline] WARNING: CPU: 0 PID: 2470 at include/linux/skbuff.h:2576 __dev_queue_xmit+0x2069/0x35e0 net/core/dev.c:4295 Call Trace: dev_queue_xmit+0x17/0x20 net/core/dev.c:4406 __bpf_tx_skb net/core/filter.c:2115 [inline] __bpf_redirect_no_mac net/core/filter.c:2140 [inline] __bpf_redirect+0x5fb/0xda0 net/core/filter.c:2163 ____bpf_clone_redirect net/core/filter.c:2447 [inline] bpf_clone_redirect+0x247/0x390 net/core/filter.c:2419 bpf_prog_48159a89cb4a9a16+0x59/0x5e bpf_dispatcher_nop_func include/linux/bpf.h:897 [inline] __bpf_prog_run include/linux/filter.h:596 [inline] bpf_prog_run include/linux/filter.h:603 [inline] bpf_test_run+0x46c/0x890 net/bpf/test_run.c:402 bpf_prog_test_run_skb+0xbdc/0x14c0 net/bpf/test_run.c:1170 bpf_prog_test_run+0x345/0x3c0 kernel/bpf/syscall.c:3648 __sys_bpf+0x43a/0x6c0 kernel/bpf/syscall.c:5005 __do_sys_bpf kernel/bpf/syscall.c:5091 [inline] __se_sys_bpf kernel/bpf/syscall.c:5089 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5089 do_syscall_64+0x54/0x70 arch/x86/entry/common.c:48 entry_SYSCALL_64_after_hwframe+0x61/0xc6
The reproducer doesn't really reproduce outside of syzkaller environment, so I'm taking a guess here. It looks like we do generate correct ETH_HLEN-sized packet, but we redirect the packet to the tunneling device. Before we do so, we __skb_pull l2 header and arrive again at skb->len == 0. Doesn't seem like we can do anything better than having an explicit check after __skb_pull?
--- net/core/filter.c | 4 ++++ 1 file changed, 4 insertions(+)
net/core/filter.c +4 -0
@@ -2130,6 +2130,10 @@ static int __bpf_redirect_no_mac(struct sk_buff *skb, struct net_device *dev,if (mlen) {__skb_pull (skb, mlen); +if (unlikely (!skb->len)) { +kfree_skb (skb); +return -ERANGE ; + }/* At ingress, the mac header has already been pulled once. * At egress, skb_pospull_rcsum has to be done in case that
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 926/1073 net: ethernet: ti: Fix return type of netcp_ndo_start_xmit()
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 63fe6ff674a96cfcfc0fa8df1051a27aa31c70b4 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/net/ethernet/ti/netcp_core.c:1944:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = netcp_ndo_start_xmit,
^~~~~~~~~~~~~~~~~~~~
1 error generated.
->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of netcp_ndo_start_xmit() to match the prototype's to resolve the warning and CFI failure.
--- drivers/net/ethernet/ti/netcp_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ti/netcp_core.c +1 -1
@@ -1261,7 +1261,7 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp, }/* Submit the packet */ -static int netcp_ndo_start_xmit (struct sk_buff *skb,struct net_device *ndev) +static netdev_tx_t netcp_ndo_start_xmit (struct sk_buff *skb,struct net_device *ndev) {struct netcp_intf *netcp =netdev_priv (ndev);struct netcp_stats *tx_stats = &netcp->stats;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 927/1073 hamradio: baycom_epp: Fix return type of baycom_send_packet()
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit c5733e5b15d91ab679646ec3149e192996a27d5d ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/net/hamradio/baycom_epp.c:1119:25: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = baycom_send_packet,
^~~~~~~~~~~~~~~~~~
1 error generated.
->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of baycom_send_packet() to match the prototype's to resolve the warning and CFI failure.
--- drivers/net/hamradio/baycom_epp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/hamradio/baycom_epp.c +1 -1
@@ -758,7 +758,7 @@ static void epp_bh(struct work_struct *work)* ===================== network driver interface ========================= */ -static int baycom_send_packet (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t baycom_send_packet (struct sk_buff *skb,struct net_device *dev) {struct baycom_state *bc =netdev_priv (dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 928/1073 wifi: brcmfmac: Fix potential shift-out-of-bounds in brcmf_fw_alloc_request()
In reply to Greg Kroah-HartmanFrom: Minsuk Kang <[email protected]>
[ Upstream commit 81d17f6f3331f03c8eafdacea68ab773426c1e3c ]
This patch fixes a shift-out-of-bounds in brcmfmac that occurs in BIT(chiprev) when a 'chiprev' provided by the device is too large. It should also not be equal to or greater than BITS_PER_TYPE(u32) as we do bitwise AND with a u32 variable and BIT(chiprev). The patch adds a check that makes the function return NULL if that is the case. Note that the NULL case is later handled by the bus-specific caller, brcmf_usb_probe_cb() or brcmf_usb_reset_resume(), for example.
Found by a modified version of syzkaller.
UBSAN: shift-out-of-bounds in drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c shift exponent 151055786 is too large for 64-bit type 'long unsigned int' CPU: 0 PID: 1885 Comm: kworker/0:2 Tainted: G O 5.14.0+ #132 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 Workqueue: usb_hub_wq hub_event Call Trace: dump_stack_lvl+0x57/0x7d ubsan_epilogue+0x5/0x40 __ubsan_handle_shift_out_of_bounds.cold+0x53/0xdb ? lock_chain_count+0x20/0x20 brcmf_fw_alloc_request.cold+0x19/0x3ea ? brcmf_fw_get_firmwares+0x250/0x250 ? brcmf_usb_ioctl_resp_wait+0x1a7/0x1f0 brcmf_usb_get_fwname+0x114/0x1a0 ? brcmf_usb_reset_resume+0x120/0x120 ? number+0x6c4/0x9a0 brcmf_c_process_clm_blob+0x168/0x590 ? put_dec+0x90/0x90 ? enable_ptr_key_workfn+0x20/0x20 ? brcmf_common_pd_remove+0x50/0x50 ? rcu_read_lock_sched_held+0xa1/0xd0 brcmf_c_preinit_dcmds+0x673/0xc40 ? brcmf_c_set_joinpref_default+0x100/0x100 ? rcu_read_lock_sched_held+0xa1/0xd0 ? rcu_read_lock_bh_held+0xb0/0xb0 ? lock_acquire+0x19d/0x4e0 ? find_held_lock+0x2d/0x110 ? brcmf_usb_deq+0x1cc/0x260 ? mark_held_locks+0x9f/0xe0 ? lockdep_hardirqs_on_prepare+0x273/0x3e0 ? _raw_spin_unlock_irqrestore+0x47/0x50 ? trace_hardirqs_on+0x1c/0x120 ? brcmf_usb_deq+0x1a7/0x260 ? brcmf_usb_rx_fill_all+0x5a/0xf0 brcmf_attach+0x246/0xd40 ? wiphy_new_nm+0x1476/0x1d50 ? kmemdup+0x30/0x40 brcmf_usb_probe+0x12de/0x1690 ? brcmf_usbdev_qinit.constprop.0+0x470/0x470 usb_probe_interface+0x25f/0x710 really_probe+0x1be/0xa90 __driver_probe_device+0x2ab/0x460 ? usb_match_id.part.0+0x88/0xc0 driver_probe_device+0x49/0x120 __device_attach_driver+0x18a/0x250 ? driver_allows_async_probing+0x120/0x120 bus_for_each_drv+0x123/0x1a0 ? bus_rescan_devices+0x20/0x20 ? lockdep_hardirqs_on_prepare+0x273/0x3e0 ? trace_hardirqs_on+0x1c/0x120 __device_attach+0x207/0x330 ? device_bind_driver+0xb0/0xb0 ? kobject_uevent_env+0x230/0x12c0 bus_probe_device+0x1a2/0x260 device_add+0xa61/0x1ce0 ? __mutex_unlock_slowpath+0xe7/0x660 ? __fw_devlink_link_to_suppliers+0x550/0x550 usb_set_configuration+0x984/0x1770 ? kernfs_create_link+0x175/0x230 usb_generic_driver_probe+0x69/0x90 usb_probe_device+0x9c/0x220 really_probe+0x1be/0xa90 __driver_probe_device+0x2ab/0x460 driver_probe_device+0x49/0x120 __device_attach_driver+0x18a/0x250 ? driver_allows_async_probing+0x120/0x120 bus_for_each_drv+0x123/0x1a0 ? bus_rescan_devices+0x20/0x20 ? lockdep_hardirqs_on_prepare+0x273/0x3e0 ? trace_hardirqs_on+0x1c/0x120 __device_attach+0x207/0x330 ? device_bind_driver+0xb0/0xb0 ? kobject_uevent_env+0x230/0x12c0 bus_probe_device+0x1a2/0x260 device_add+0xa61/0x1ce0 ? __fw_devlink_link_to_suppliers+0x550/0x550 usb_new_device.cold+0x463/0xf66 ? hub_disconnect+0x400/0x400 ? _raw_spin_unlock_irq+0x24/0x30 hub_event+0x10d5/0x3330 ? hub_port_debounce+0x280/0x280 ? __lock_acquire+0x1671/0x5790 ? wq_calc_node_cpumask+0x170/0x2a0 ? lock_release+0x640/0x640 ? rcu_read_lock_sched_held+0xa1/0xd0 ? rcu_read_lock_bh_held+0xb0/0xb0 ? lockdep_hardirqs_on_prepare+0x273/0x3e0 process_one_work+0x873/0x13e0 ? lock_release+0x640/0x640 ? pwq_dec_nr_in_flight+0x320/0x320 ? rwlock_bug.part.0+0x90/0x90 worker_thread+0x8b/0xd10 ? __kthread_parkme+0xd9/0x1d0 ? process_one_work+0x13e0/0x13e0 kthread+0x379/0x450 ? _raw_spin_unlock_irq+0x24/0x30 ? set_kthread_struct+0x100/0x100 ret_from_fork+0x1f/0x30
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +5 -0
@@ -737,6 +737,11 @@ brcmf_fw_alloc_request(u32 chip, u32 chiprev,u32 i, j;char end ='\0' ; +if (chiprev >=BITS_PER_TYPE (u32)) { +brcmf_err ("Invalid chip revision %u\n" , chiprev); +return NULL ; + } +for (i =0 ; i < table_size; i++) {if (mapping_table[i].chipid == chip && mapping_table[i].revmask &BIT (chiprev))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 929/1073 HID: input: do not query XP-PEN Deco LW battery
In reply to Greg Kroah-HartmanFrom: José Expósito <[email protected]>
[ Upstream commit 037c1aaeb96fe5f778026f4c1ef28b26cf600bfa ]
The XP-PEN Deco LW drawing tablet can be connected by USB cable or using a USB Bluetooth dongle. When it is connected using the dongle, there might be a small delay until the tablet is paired with the dongle.
Fetching the device battery during this delay results in random battery percentage values.
Add a quirk to avoid actively querying the battery percentage and wait for the device to report it on its own.
--- drivers/hid/hid-input.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/hid/hid-input.c +6 -0
@@ -340,6 +340,7 @@ static enum power_supply_property hidinput_battery_props[] = {#define HID_BATTERY_QUIRK_PERCENT (1 << 0)/* always reports percent */ #define HID_BATTERY_QUIRK_FEATURE (1 << 1)/* ask for feature report */ #define HID_BATTERY_QUIRK_IGNORE (1 << 2)/* completely ignore the battery */ +#define HID_BATTERY_QUIRK_AVOID_QUERY (1 << 3)/* do not query the battery */ static const struct hid_device_id hid_battery_quirks[] = { { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
@@ -373,6 +374,8 @@ static const struct hid_device_id hid_battery_quirks[] = { HID_BATTERY_QUIRK_IGNORE }, {HID_USB_DEVICE (USB_VENDOR_ID_ELAN ,USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN ), HID_BATTERY_QUIRK_IGNORE }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_L), + HID_BATTERY_QUIRK_AVOID_QUERY }, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15), HID_BATTERY_QUIRK_IGNORE }, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15T_DR100),
@@ -554,6 +557,9 @@ static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type, dev->battery_avoid_query = report_type ==HID_INPUT_REPORT && field->physical ==HID_DG_STYLUS ; +if (quirks &HID_BATTERY_QUIRK_AVOID_QUERY ) + dev->battery_avoid_query = true; + dev->battery =power_supply_register (&dev->dev, psy_desc, &psy_cfg);if (IS_ERR (dev->battery)) { error =PTR_ERR (dev->battery);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 930/1073 igb: Do not free q_vector unless new one was allocated
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit 0668716506ca66f90d395f36ccdaebc3e0e84801 ]
Avoid potential use-after-free condition under memory pressure. If the kzalloc() fails, q_vector will be freed but left in the original adapter->q_vector[v_idx] array position.
--- drivers/net/ethernet/intel/igb/igb_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +6 -2
@@ -1202,8 +1202,12 @@ static int igb_alloc_q_vector(struct igb_adapter *adapter,if (!q_vector) { q_vector =kzalloc (size,GFP_KERNEL ); }else if (size >ksize (q_vector)) { -kfree_rcu (q_vector, rcu); - q_vector =kzalloc (size,GFP_KERNEL ); +struct igb_q_vector *new_q_vector; + + new_q_vector =kzalloc (size,GFP_KERNEL ); +if (new_q_vector) +kfree_rcu (q_vector, rcu); + q_vector = new_q_vector; }else {memset (q_vector,0 , size); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 931/1073 drm/amdgpu: Fix type of second parameter in trans_msg() callback
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit f0d0f1087333714ee683cc134a95afe331d7ddd9 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c:412:15: error: incompatible function pointer types initializing 'void (*)(struct amdgpu_device *, u32, u32, u32, u32)' (aka 'void (*)(struct amdgpu_device *, unsigned int, unsigned int, unsigned int, unsigned int)') with an expression of type 'void (struct amdgpu_device *, enum idh_request, u32, u32, u32)' (aka 'void (struct amdgpu_device *, enum idh_request, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
.trans_msg = xgpu_ai_mailbox_trans_msg,
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c:435:15: error: incompatible function pointer types initializing 'void (*)(struct amdgpu_device *, u32, u32, u32, u32)' (aka 'void (*)(struct amdgpu_device *, unsigned int, unsigned int, unsigned int, unsigned int)') with an expression of type 'void (struct amdgpu_device *, enum idh_request, u32, u32, u32)' (aka 'void (struct amdgpu_device *, enum idh_request, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
.trans_msg = xgpu_nv_mailbox_trans_msg,
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
The type of the second parameter in the prototype should be 'enum idh_request' instead of 'u32'. Update it to clear up the warnings.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +4 -1
@@ -75,6 +75,8 @@ struct amdgpu_vf_error_buffer {uint64_t data[AMDGPU_VF_ERROR_ENTRY_SIZE ]; }; +enum idh_request ; +/** * struct amdgpu_virt_ops - amdgpu device virt operations */
@@ -84,7 +86,8 @@ struct amdgpu_virt_ops {int (*req_init_data)(struct amdgpu_device *adev);int (*reset_gpu)(struct amdgpu_device *adev);int (*wait_reset)(struct amdgpu_device *adev); -void (*trans_msg)(struct amdgpu_device *adev,u32 req,u32 data1,u32 data2,u32 data3); +void (*trans_msg)(struct amdgpu_device *adev,enum idh_request req, +u32 data1,u32 data2,u32 data3); };/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 932/1073 drm/amdgpu: Fix type of second parameter in odn_edit_dpm_table() callback
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit e4d0ef752081e7aa6ffb7ccac11c499c732a2e05 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/amdgpu_smu.c:3008:29: error: incompatible function pointer types initializing 'int (*)(void *, uint32_t, long *, uint32_t)' (aka 'int (*)(void *, unsigned int, long *, unsigned int)') with an expression of type 'int (void *, enum PP_OD_DPM_TABLE_COMMAND, long *, uint32_t)' (aka 'int (void *, enum PP_OD_DPM_TABLE_COMMAND, long *, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
.odn_edit_dpm_table = smu_od_edit_dpm_table,
^~~~~~~~~~~~~~~~~~~~~
1 error generated.
There are only two implementations of ->odn_edit_dpm_table() in 'struct amd_pm_funcs': smu_od_edit_dpm_table() and pp_odn_edit_dpm_table(). One has a second parameter type of 'enum PP_OD_DPM_TABLE_COMMAND' and the other uses 'u32'. Ultimately, smu_od_edit_dpm_table() calls ->od_edit_dpm_table() from 'struct pptable_funcs' and pp_odn_edit_dpm_table() calls ->odn_edit_dpm_table() from 'struct pp_hwmgr_func', which both have a second parameter type of 'enum PP_OD_DPM_TABLE_COMMAND'.
Update the type parameter in both the prototype in 'struct amd_pm_funcs' and pp_odn_edit_dpm_table() to 'enum PP_OD_DPM_TABLE_COMMAND', which cleans up the warning.
--- drivers/gpu/drm/amd/include/kgd_pp_interface.h | 3 ++- drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +2 -1
@@ -354,7 +354,8 @@ struct amd_pm_funcs {int (*get_power_profile_mode)(void *handle,char *buf);int (*set_power_profile_mode)(void *handle,long *input,uint32_t size);int (*set_fine_grain_clk_vol)(void *handle,uint32_t type,long *input,uint32_t size); -int (*odn_edit_dpm_table)(void *handle,uint32_t type,long *input,uint32_t size); +int (*odn_edit_dpm_table)(void *handle,enum PP_OD_DPM_TABLE_COMMAND type, +long *input,uint32_t size);int (*set_mp1_state)(void *handle,enum pp_mp1_state mp1_state);int (*smu_i2c_bus_access)(void *handle,bool acquire);int (*gfx_state_change_set)(void *handle,uint32_t state);
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2 -1
@@ -838,7 +838,8 @@ static int pp_set_fine_grain_clk_vol(void *handle, uint32_t type, long *input, ureturn hwmgr->hwmgr_func->set_fine_grain_clk_vol (hwmgr, type, input, size); } -static int pp_odn_edit_dpm_table (void *handle,uint32_t type,long *input,uint32_t size) +static int pp_odn_edit_dpm_table (void *handle,enum PP_OD_DPM_TABLE_COMMAND type, +long *input,uint32_t size) {struct pp_hwmgr *hwmgr = handle;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 933/1073 s390/ctcm: Fix return type of ctc{mp,}m_tx()
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit aa5bf80c3c067b82b4362cd6e8e2194623bcaca6 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/s390/net/ctcm_main.c:1064:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = ctcm_tx,
^~~~~~~
drivers/s390/net/ctcm_main.c:1072:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = ctcmpc_tx,
^~~~~~~~~
->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of ctc{mp,}m_tx() to match the prototype's to resolve the warning and potential CFI failure, should s390 select ARCH_SUPPORTS_CFI_CLANG in the future.
Additionally, while in the area, remove a comment block that is no longer relevant.
--- drivers/s390/net/ctcm_main.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/s390/net/ctcm_main.c +2 -9
@@ -825,16 +825,9 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb)/* * Start transmission of a packet. * Called from generic network device layer. -* -* skb Pointer to buffer containing the packet. -* dev Pointer to interface struct. -* -* returns 0 if packet consumed, !0 if packet rejected. -* Note: If we return !0, then the packet is free'd by -* the generic network layer. */ /* first merge version - leaving both functions separated */ -static int ctcm_tx (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t ctcm_tx (struct sk_buff *skb,struct net_device *dev) {struct ctcm_priv *priv = dev->ml_priv;
@@ -877,7 +870,7 @@ static int ctcm_tx(struct sk_buff *skb, struct net_device *dev) }/* unmerged MPC variant of ctcm_tx */ -static int ctcmpc_tx (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t ctcmpc_tx (struct sk_buff *skb,struct net_device *dev) {int len =0 ;struct ctcm_priv *priv = dev->ml_priv;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 934/1073 s390/netiucv: Fix return type of netiucv_tx()
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 88d86d18d7cf7e9137c95f9d212bb9fff8a1b4be ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/s390/net/netiucv.c:1854:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = netiucv_tx,
^~~~~~~~~~
->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of netiucv_tx() to match the prototype's to resolve the warning and potential CFI failure, should s390 select ARCH_SUPPORTS_CFI_CLANG in the future.
Additionally, while in the area, remove a comment block that is no longer relevant.
--- drivers/s390/net/netiucv.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/s390/net/netiucv.c +1 -8
@@ -1248,15 +1248,8 @@ static int netiucv_close(struct net_device *dev)/* * Start transmission of a packet. * Called from generic network device layer. -* -* @param skb Pointer to buffer containing the packet. -* @param dev Pointer to interface struct. -* -* @return 0 if packet consumed, !0 if packet rejected. -* Note: If we return !0, then the packet is free'd by -* the generic network layer. */ -static int netiucv_tx (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t netiucv_tx (struct sk_buff *skb,struct net_device *dev) {struct netiucv_priv *privptr =netdev_priv (dev);int rc;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 935/1073 s390/lcs: Fix return type of lcs_start_xmit()
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit bb16db8393658e0978c3f0d30ae069e878264fa3 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/s390/net/lcs.c:2090:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = lcs_start_xmit,
^~~~~~~~~~~~~~
drivers/s390/net/lcs.c:2097:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = lcs_start_xmit,
^~~~~~~~~~~~~~
->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of lcs_start_xmit() to match the prototype's to resolve the warning and potential CFI failure, should s390 select ARCH_SUPPORTS_CFI_CLANG in the future.
--- drivers/s390/net/lcs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/s390/net/lcs.c +3 -5
@@ -1519,9 +1519,8 @@ lcs_txbuffer_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)/* * Packet transmit function called by network stack */ -static int -__lcs_start_xmit (struct lcs_card *card,struct sk_buff *skb, -struct net_device *dev) +static netdev_tx_t __lcs_start_xmit (struct lcs_card *card,struct sk_buff *skb, +struct net_device *dev) {struct lcs_header *header;int rc =NETDEV_TX_OK ;
@@ -1582,8 +1581,7 @@ __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb,return rc; } -static int -lcs_start_xmit (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t lcs_start_xmit (struct sk_buff *skb,struct net_device *dev) {struct lcs_card *card;int rc;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 936/1073 drm/amd/display: Disable DRR actions during state commit
In reply to Greg Kroah-HartmanFrom: Wesley Chalmers <[email protected]>
[ Upstream commit de020e5fa9ebc6fc32e82ae6ccb0282451ed937c ]
[WHY]
Committing a state while performing DRR actions can cause underflow.
[HOW]
Disabled features performing DRR actions during state commit. Need to follow-up on why DRR actions affect state commit.
--- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +0 -3
@@ -973,8 +973,5 @@ void dcn30_prepare_bandwidth(struct dc *dc, dc->clk_mgr->funcs->set_max_memclk (dc->clk_mgr, dc->clk_mgr->bw_params->clk_table.entries[dc->clk_mgr->bw_params->clk_table.num_entries -1 ].memclk_mhz);dcn20_prepare_bandwidth (dc, context); - -dc_dmub_srv_p_state_delegate (dc, - context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching, context); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 937/1073 drm/msm: Use drm_mode_copy()
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
[ Upstream commit b2a1c5ca50db22b3677676dd5bad5f6092429acf ]
struct drm_display_mode embeds a list head, so overwriting the full struct with another one will corrupt the list (if the destination mode is on a list). Use drm_mode_copy() instead which explicitly preserves the list head of the destination mode.
Even if we know the destination mode is not on any list using drm_mode_copy() seems decent as it sets a good example. Bad examples of not using it might eventually get copied into code where preserving the list head actually matters.
Obviously one case not covered here is when the mode itself is embedded in a larger structure and the whole structure is copied. But if we are careful when copying into modes embedded in structures I think we can be a little more reassured that bogus list heads haven't been propagated in.
@is_mode_copy@
@@drm_mode_copy(...)
{
...
}
@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)
@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)
@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode
--- drivers/gpu/drm/msm/dp/dp_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/dp/dp_display.c +1 -1
@@ -857,7 +857,7 @@ static int dp_display_set_mode(struct msm_dp *dp_display, dp = container_of(dp_display, struct dp_display_private, dp_display); - dp->panel->dp_mode.drm_mode = mode->drm_mode; +drm_mode_copy (&dp->panel->dp_mode.drm_mode, &mode->drm_mode); dp->panel->dp_mode.bpp = mode->bpp; dp->panel->dp_mode.capabilities = mode->capabilities;dp_panel_init_panel_info (dp->panel);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 938/1073 drm/rockchip: Use drm_mode_copy()
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
[ Upstream commit 2bfaa28000d2830d3209161a4541cce0660e1b84 ]
struct drm_display_mode embeds a list head, so overwriting the full struct with another one will corrupt the list (if the destination mode is on a list). Use drm_mode_copy() instead which explicitly preserves the list head of the destination mode.
Even if we know the destination mode is not on any list using drm_mode_copy() seems decent as it sets a good example. Bad examples of not using it might eventually get copied into code where preserving the list head actually matters.
Obviously one case not covered here is when the mode itself is embedded in a larger structure and the whole structure is copied. But if we are careful when copying into modes embedded in structures I think we can be a little more reassured that bogus list heads haven't been propagated in.
@is_mode_copy@
@@drm_mode_copy(...)
{
...
}
@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)
@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)
@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode
--- drivers/gpu/drm/rockchip/cdn-dp-core.c | 2 +- drivers/gpu/drm/rockchip/inno_hdmi.c | 2 +- drivers/gpu/drm/rockchip/rk3066_hdmi.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/rockchip/cdn-dp-core.c +1 -1
@@ -571,7 +571,7 @@ static void cdn_dp_encoder_mode_set(struct drm_encoder *encoder, video->v_sync_polarity = !!(mode->flags &DRM_MODE_FLAG_NVSYNC ); video->h_sync_polarity = !!(mode->flags &DRM_MODE_FLAG_NHSYNC ); -memcpy (&dp->mode, adjusted,sizeof (*mode)); +drm_mode_copy (&dp->mode, adjusted); }static bool cdn_dp_check_link_status (struct cdn_dp_device *dp)
drivers/gpu/drm/rockchip/inno_hdmi.c +1 -1
@@ -499,7 +499,7 @@ static void inno_hdmi_encoder_mode_set(struct drm_encoder *encoder,inno_hdmi_setup (hdmi, adj_mode);/* Store the display mode for plugin/DPMS poweron events */ -memcpy (&hdmi->previous_mode, adj_mode,sizeof (hdmi->previous_mode)); +drm_mode_copy (&hdmi->previous_mode, adj_mode); }static void inno_hdmi_encoder_enable (struct drm_encoder *encoder)
drivers/gpu/drm/rockchip/rk3066_hdmi.c +1 -1
@@ -395,7 +395,7 @@ rk3066_hdmi_encoder_mode_set(struct drm_encoder *encoder,struct rk3066_hdmi *hdmi =encoder_to_rk3066_hdmi (encoder);/* Store the display mode for plugin/DPMS poweron events. */ -memcpy (&hdmi->previous_mode, adj_mode,sizeof (hdmi->previous_mode)); +drm_mode_copy (&hdmi->previous_mode, adj_mode); }static void rk3066_hdmi_encoder_enable (struct drm_encoder *encoder)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 939/1073 drm/sti: Use drm_mode_copy()
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
[ Upstream commit 442cf8e22ba25a77cb9092d78733fdbac9844e50 ]
struct drm_display_mode embeds a list head, so overwriting the full struct with another one will corrupt the list (if the destination mode is on a list). Use drm_mode_copy() instead which explicitly preserves the list head of the destination mode.
Even if we know the destination mode is not on any list using drm_mode_copy() seems decent as it sets a good example. Bad examples of not using it might eventually get copied into code where preserving the list head actually matters.
Obviously one case not covered here is when the mode itself is embedded in a larger structure and the whole structure is copied. But if we are careful when copying into modes embedded in structures I think we can be a little more reassured that bogus list heads haven't been propagated in.
@is_mode_copy@
@@drm_mode_copy(...)
{
...
}
@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)
@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)
@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode
--- drivers/gpu/drm/sti/sti_dvo.c | 2 +- drivers/gpu/drm/sti/sti_hda.c | 2 +- drivers/gpu/drm/sti/sti_hdmi.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/sti/sti_dvo.c +1 -1
@@ -288,7 +288,7 @@ static void sti_dvo_set_mode(struct drm_bridge *bridge,DRM_DEBUG_DRIVER ("\n" ); -memcpy (&dvo->mode, mode,sizeof (struct drm_display_mode )); +drm_mode_copy (&dvo->mode, mode);/* According to the path used (main or aux), the dvo clocks should * have a different parent clock. */
drivers/gpu/drm/sti/sti_hda.c +1 -1
@@ -524,7 +524,7 @@ static void sti_hda_set_mode(struct drm_bridge *bridge,DRM_DEBUG_DRIVER ("\n" ); -memcpy (&hda->mode, mode,sizeof (struct drm_display_mode )); +drm_mode_copy (&hda->mode, mode);if (!hda_get_mode_idx (hda->mode, &mode_idx)) {DRM_ERROR ("Undefined mode\n" );
drivers/gpu/drm/sti/sti_hdmi.c +1 -1
@@ -941,7 +941,7 @@ static void sti_hdmi_set_mode(struct drm_bridge *bridge,DRM_DEBUG_DRIVER ("\n" );/* Copy the drm display mode in the connector local structure */ -memcpy (&hdmi->mode, mode,sizeof (struct drm_display_mode )); +drm_mode_copy (&hdmi->mode, mode);/* Update clock framerate according to the selected mode */ ret =clk_set_rate (hdmi->clk_pix, mode->clock *1000 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 940/1073 drm/mediatek: Fix return type of mtk_hdmi_bridge_mode_valid()
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 890d637523eec9d730e3885532fa1228ba678880 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/gpu/drm/mediatek/mtk_hdmi.c:1407:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' with an expression of type 'int (struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.mode_valid = mtk_hdmi_bridge_mode_valid,
^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
->mode_valid() in 'struct drm_bridge_funcs' expects a return type of 'enum drm_mode_status', not 'int'. Adjust the return type of mtk_hdmi_bridge_mode_valid() to match the prototype's to resolve the warning and CFI failure.
--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_hdmi.c +4 -3
@@ -1203,9 +1203,10 @@ static enum drm_connector_status mtk_hdmi_detect(struct mtk_hdmi *hdmi)return mtk_hdmi_update_plugged_status (hdmi); } -static int mtk_hdmi_bridge_mode_valid (struct drm_bridge *bridge, -const struct drm_display_info *info, -const struct drm_display_mode *mode) +static enum drm_mode_status +mtk_hdmi_bridge_mode_valid (struct drm_bridge *bridge, +const struct drm_display_info *info, +const struct drm_display_mode *mode) {struct mtk_hdmi *hdmi =hdmi_ctx_from_bridge (bridge);struct drm_bridge *next_bridge;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 941/1073 drivers/md/md-bitmap: check the return value of md_bitmap_get_counter()
In reply to Greg Kroah-HartmanFrom: Li Zhong <[email protected]>
[ Upstream commit 3bd548e5b819b8c0f2c9085de775c5c7bff9052f ]
Check the return value of md_bitmap_get_counter() in case it returns NULL pointer, which will result in a null pointer dereference.
v2: update the check to include other dereference
--- drivers/md/md-bitmap.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
drivers/md/md-bitmap.c +15 -12
@@ -2195,20 +2195,23 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,if (set) { bmc_new =md_bitmap_get_counter (&bitmap->counts, block, &new_blocks,1 ); -if (*bmc_new ==0 ) { -/* need to set on-disk bits too. */ -sector_t end = block + new_blocks; -sector_t start = block >> chunkshift; - start <<= chunkshift; -while (start < end) { -md_bitmap_file_set_bit (bitmap, block); - start +=1 << chunkshift; +if (bmc_new) { +if (*bmc_new ==0 ) { +/* need to set on-disk bits too. */ +sector_t end = block + new_blocks; +sector_t start = block >> chunkshift; + + start <<= chunkshift; +while (start < end) { +md_bitmap_file_set_bit (bitmap, block); + start +=1 << chunkshift; + } + *bmc_new =2 ; +md_bitmap_count_page (&bitmap->counts, block,1 ); +md_bitmap_set_pending (&bitmap->counts, block); } - *bmc_new =2 ; -md_bitmap_count_page (&bitmap->counts, block,1 ); -md_bitmap_set_pending (&bitmap->counts, block); + *bmc_new |=NEEDED_MASK ; } - *bmc_new |=NEEDED_MASK ;if (new_blocks < old_blocks) old_blocks = new_blocks; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 942/1073 md/raid0, raid10: Dont set discard sectors for request queue
In reply to Greg Kroah-HartmanFrom: Xiao Ni <[email protected]>
[ Upstream commit 8e1a2279ca2b0485cc379a153d02a9793f74a48f ]
It should use disk_stack_limits to get a proper max_discard_sectors rather than setting a value by stack drivers.
And there is a bug. If all member disks are rotational devices, raid0/raid10 set max_discard_sectors. So the member devices are not ssd/nvme, but raid0/raid10 export the wrong value. It reports warning messages in function __blkdev_issue_discard when mkfs.xfs like this:
[ 4616.022599] ------------[ cut here ]------------ [ 4616.027779] WARNING: CPU: 4 PID: 99634 at block/blk-lib.c:50 __blkdev_issue_discard+0x16a/0x1a0 [ 4616.140663] RIP: 0010:__blkdev_issue_discard+0x16a/0x1a0 [ 4616.146601] Code: 24 4c 89 20 31 c0 e9 fe fe ff ff c1 e8 09 8d 48 ff 4c 89 f0 4c 09 e8 48 85 c1 0f 84 55 ff ff ff b8 ea ff ff ff e9 df fe ff ff <0f> 0b 48 8d 74 24 08 e8 ea d6 00 00 48 c7 c6 20 1e 89 ab 48 c7 c7 [ 4616.167567] RSP: 0018:ffffaab88cbffca8 EFLAGS: 00010246 [ 4616.173406] RAX: ffff9ba1f9e44678 RBX: 0000000000000000 RCX: ffff9ba1c9792080 [ 4616.181376] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff9ba1c9792080 [ 4616.189345] RBP: 0000000000000cc0 R08: ffffaab88cbffd10 R09: 0000000000000000 [ 4616.197317] R10: 0000000000000012 R11: 0000000000000000 R12: 0000000000000000 [ 4616.205288] R13: 0000000000400000 R14: 0000000000000cc0 R15: ffff9ba1c9792080 [ 4616.213259] FS: 00007f9a5534e980(0000) GS:ffff9ba1b7c80000(0000) knlGS:0000000000000000 [ 4616.222298] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 4616.228719] CR2: 000055a390a4c518 CR3: 0000000123e40006 CR4: 00000000001706e0 [ 4616.236689] Call Trace: [ 4616.239428] blkdev_issue_discard+0x52/0xb0 [ 4616.244108] blkdev_common_ioctl+0x43c/0xa00 [ 4616.248883] blkdev_ioctl+0x116/0x280 [ 4616.252977] __x64_sys_ioctl+0x8a/0xc0 [ 4616.257163] do_syscall_64+0x5c/0x90 [ 4616.261164] ? handle_mm_fault+0xc5/0x2a0 [ 4616.265652] ? do_user_addr_fault+0x1d8/0x690 [ 4616.270527] ? do_syscall_64+0x69/0x90 [ 4616.274717] ? exc_page_fault+0x62/0x150 [ 4616.279097] entry_SYSCALL_64_after_hwframe+0x63/0xcd [ 4616.284748] RIP: 0033:0x7f9a55398c6b
--- drivers/md/raid0.c | 1 - drivers/md/raid10.c | 2 -- 2 files changed, 3 deletions(-)
drivers/md/raid0.c +0 -1
@@ -398,7 +398,6 @@ static int raid0_run(struct mddev *mddev)blk_queue_max_hw_sectors (mddev->queue, mddev->chunk_sectors);blk_queue_max_write_zeroes_sectors (mddev->queue, mddev->chunk_sectors); -blk_queue_max_discard_sectors (mddev->queue,UINT_MAX );blk_queue_io_min (mddev->queue, mddev->chunk_sectors <<9 ); blk_queue_io_opt(mddev->queue,
drivers/md/raid10.c +0 -2
@@ -4104,8 +4104,6 @@ static int raid10_run(struct mddev *mddev) conf->thread =NULL ;if (mddev->queue) { -blk_queue_max_discard_sectors (mddev->queue, -UINT_MAX );blk_queue_max_write_zeroes_sectors (mddev->queue,0 );blk_queue_io_min (mddev->queue, mddev->chunk_sectors <<9 );raid10_set_io_opt (conf);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 943/1073 md/raid1: stop mdx_raid1 thread when raid1 array run failed
In reply to Greg Kroah-HartmanFrom: Jiang Li <[email protected]>
[ Upstream commit b611ad14006e5be2170d9e8e611bf49dff288911 ]
fail run raid1 array when we assemble array with the inactive disk only, but the mdx_raid1 thread were not stop, Even if the associated resources have been released. it will caused a NULL dereference when we do poweroff.
This causes the following Oops:
[ 287.587787] BUG: kernel NULL pointer dereference, address: 0000000000000070
[ 287.594762] #PF: supervisor read access in kernel mode
[ 287.599912] #PF: error_code(0x0000) - not-present page
[ 287.605061] PGD 0 P4D 0
[ 287.607612] Oops: 0000 [#1] SMP NOPTI
[ 287.611287] CPU: 3 PID: 5265 Comm: md0_raid1 Tainted: G U 5.10.146 #0
[ 287.619029] Hardware name: xxxxxxx/To be filled by O.E.M, BIOS 5.19 06/16/2022
[ 287.626775] RIP: 0010:md_check_recovery+0x57/0x500 [md_mod]
[ 287.632357] Code: fe 01 00 00 48 83 bb 10 03 00 00 00 74 08 48 89 ......
[ 287.651118] RSP: 0018:ffffc90000433d78 EFLAGS: 00010202
[ 287.656347] RAX: 0000000000000000 RBX: ffff888105986800 RCX: 0000000000000000
[ 287.663491] RDX: ffffc90000433bb0 RSI: 00000000ffffefff RDI: ffff888105986800
[ 287.670634] RBP: ffffc90000433da0 R08: 0000000000000000 R09: c0000000ffffefff
[ 287.677771] R10: 0000000000000001 R11: ffffc90000433ba8 R12: ffff888105986800
[ 287.684907] R13: 0000000000000000 R14: fffffffffffffe00 R15: ffff888100b6b500
[ 287.692052] FS: 0000000000000000(0000) GS:ffff888277f80000(0000) knlGS:0000000000000000
[ 287.700149] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 287.705897] CR2: 0000000000000070 CR3: 000000000320a000 CR4: 0000000000350ee0
[ 287.713033] Call Trace:
[ 287.715498] raid1d+0x6c/0xbbb [raid1]
[ 287.719256] ? __schedule+0x1ff/0x760
[ 287.722930] ? schedule+0x3b/0xb0
[ 287.726260] ? schedule_timeout+0x1ed/0x290
[ 287.730456] ? __switch_to+0x11f/0x400
[ 287.734219] md_thread+0xe9/0x140 [md_mod]
[ 287.738328] ? md_thread+0xe9/0x140 [md_mod]
[ 287.742601] ? wait_woken+0x80/0x80
[ 287.746097] ? md_register_thread+0xe0/0xe0 [md_mod]
[ 287.751064] kthread+0x11a/0x140
[ 287.754300] ? kthread_park+0x90/0x90
[ 287.757974] ret_from_fork+0x1f/0x30In fact, when raid1 array run fail, we need to domd_unregister_thread() before raid1_free().
--- drivers/md/raid1.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/raid1.c +1 -0
@@ -3159,6 +3159,7 @@ static int raid1_run(struct mddev *mddev)* RAID1 needs at least one disk in active */ if (conf->raid_disks - mddev->degraded <1 ) { +md_unregister_thread (&conf->thread); ret = -EINVAL ; goto abort; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 944/1073 drm/amd/display: Workaround to increase phantom pipe vactive in pipesplit
In reply to Greg Kroah-HartmanFrom: George Shen <[email protected]>
[ Upstream commit 5b8f9deaf3b6badfc0da968e6e07ceabd19700b6 ]
[Why]
Certain high resolution displays exhibit DCC line corruption with SubVP enabled. This is likely due to insufficient DCC meta data buffered immediately after the mclk switch.
[How]
Add workaround to increase phantom pipe vactive height by meta_row_height number of lines, thus increasing the amount of meta data buffered immediately after mclk switch finishes.
--- drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c +7 -0
@@ -485,9 +485,11 @@ void dcn32_set_phantom_stream_timing(struct dc *dc,unsigned int i, pipe_idx;struct pipe_ctx *pipe;uint32_t phantom_vactive, phantom_bp, pstate_width_fw_delay_lines; +unsigned int num_dpp;unsigned int vlevel = context->bw_ctx.dml.vba.VoltageLevel;unsigned int dcfclk = context->bw_ctx.dml.vba.DCFCLKState[vlevel][context->bw_ctx.dml.vba.maxMpcComb];unsigned int socclk = context->bw_ctx.dml.vba.SOCCLKPerState[vlevel]; +struct vba_vars_st *vba = &context->bw_ctx.dml.vba;dc_assert_fp_enabled ();
@@ -523,6 +525,11 @@ void dcn32_set_phantom_stream_timing(struct dc *dc, phantom_vactive =get_subviewport_lines_needed_in_mall (&context->bw_ctx.dml, pipes, pipe_cnt, pipe_idx) + pstate_width_fw_delay_lines + dc->caps.subvp_swath_height_margin_lines; +// W/A for DCC corruption with certain high resolution timings. +// Determing if pipesplit is used. If so, add meta_row_height to the phantom vactive. + num_dpp = vba->NoOfDPP[vba->VoltageLevel][vba->maxMpcComb][vba->pipe_plane[pipe_idx]]; + phantom_vactive += num_dpp >1 ? vba->meta_row_height[vba->pipe_plane[pipe_idx]] :0 ; +// For backporch of phantom pipe, use vstartup of the main pipe phantom_bp =get_vstartup (&context->bw_ctx.dml, pipes, pipe_cnt, pipe_idx);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 945/1073 drm/amd/display: fix array index out of bound error in bios parser
In reply to Greg Kroah-HartmanFrom: Aurabindo Pillai <[email protected]>
[ Upstream commit 4fc1ba4aa589ca267468ad23fedef37562227d32 ]
[Why&How]
Firmware headers dictate that gpio_pin array only has a size of 8. The count returned from vbios however is greater than 8.
Fix this by not using array indexing but incrementing the pointer since gpio_pin definition in atomfirmware.h is hardcoded to size 8
--- .../gpu/drm/amd/display/dc/bios/bios_parser2.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +7 -9
@@ -487,6 +487,7 @@ static enum bp_result get_gpio_i2c_info(uint32_t count =0 ;unsigned int table_index =0 ;bool find_valid = false; +struct atom_gpio_pin_assignment *pin;if (!info)return BP_RESULT_BADINPUT ;
@@ -514,20 +515,17 @@ static enum bp_result get_gpio_i2c_info( - sizeof(struct atom_common_table_header)) /sizeof (struct atom_gpio_pin_assignment ); + pin = (struct atom_gpio_pin_assignment *) header->gpio_pin; +for (table_index =0 ; table_index < count; table_index++) { -if (((record->i2c_id &I2C_HW_CAP ) == ( - header->gpio_pin[table_index].gpio_id & -I2C_HW_CAP )) && - ((record->i2c_id &I2C_HW_ENGINE_ID_MASK ) == - (header->gpio_pin[table_index].gpio_id & -I2C_HW_ENGINE_ID_MASK )) && - ((record->i2c_id &I2C_HW_LANE_MUX ) == - (header->gpio_pin[table_index].gpio_id & -I2C_HW_LANE_MUX ))) { +if (((record->i2c_id &I2C_HW_CAP ) == (pin->gpio_id &I2C_HW_CAP )) && + ((record->i2c_id &I2C_HW_ENGINE_ID_MASK ) == (pin->gpio_id &I2C_HW_ENGINE_ID_MASK )) && + ((record->i2c_id &I2C_HW_LANE_MUX ) == (pin->gpio_id &I2C_HW_LANE_MUX ))) {/* still valid */ find_valid = true;break ; } + pin = (struct atom_gpio_pin_assignment *)((uint8_t *)pin +sizeof (struct atom_gpio_pin_assignment )); }/* If we don't find the entry that we are looking for then
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 946/1073 nvme-auth: dont override ctrl keys before validation
In reply to Greg Kroah-HartmanFrom: Sagi Grimberg <[email protected]>
[ Upstream commit 01604350e14560d4d69323eb1ba12a257a643ea8 ]
Replace ctrl ctrl_key/host_key only after nvme_auth_generate_key is successful. Also, this fixes a bug where the keys are leaked.
--- drivers/nvme/host/core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +10 -2
@@ -3739,13 +3739,17 @@ static ssize_t nvme_ctrl_dhchap_secret_store(struct device *dev,memcpy (dhchap_secret, buf, count);nvme_auth_stop (ctrl);if (strcmp (dhchap_secret, opts->dhchap_secret)) { +struct nvme_dhchap_key *key, *host_key;int ret; - ret =nvme_auth_generate_key (dhchap_secret, &ctrl->host_key); + ret =nvme_auth_generate_key (dhchap_secret, &key);if (ret)return ret;kfree (opts->dhchap_secret); opts->dhchap_secret = dhchap_secret; + host_key = ctrl->host_key; + ctrl->host_key = key; +nvme_auth_free_key (host_key);/* Key has changed; re-authentication with new key */ nvme_auth_reset (ctrl); }
@@ -3789,13 +3793,17 @@ static ssize_t nvme_ctrl_dhchap_ctrl_secret_store(struct device *dev,memcpy (dhchap_secret, buf, count);nvme_auth_stop (ctrl);if (strcmp (dhchap_secret, opts->dhchap_ctrl_secret)) { +struct nvme_dhchap_key *key, *ctrl_key;int ret; - ret =nvme_auth_generate_key (dhchap_secret, &ctrl->ctrl_key); + ret =nvme_auth_generate_key (dhchap_secret, &key);if (ret)return ret;kfree (opts->dhchap_ctrl_secret); opts->dhchap_ctrl_secret = dhchap_secret; + ctrl_key = ctrl->ctrl_key; + ctrl->ctrl_key = key; +nvme_auth_free_key (ctrl_key);/* Key has changed; re-authentication with new key */ nvme_auth_reset (ctrl); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 947/1073 net: add atomic_long_t to net_device_stats fields
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 6c1c5097781f563b70a81683ea6fdac21637573b ]
Long standing KCSAN issues are caused by data-race around some dev->stats changes.
Most performance critical paths already use per-cpu variables, or per-queue ones.
It is reasonable (and more correct) to use atomic operations for the slow paths.
This patch adds an union for each field of net_device_stats, so that we can convert paths that are not yet protected by a spinlock or a mutex.
netdev_stats_to_stats64() no longer has an #if BITS_PER_LONG==64
Note that the memcpy() we were using on 64bit arches had no provision to avoid load-tearing,
while atomic_long_read() is providing the needed protection at no cost.
--- include/linux/netdevice.h | 58 +++++++++++++++++++++++---------------- include/net/dst.h | 5 ++-- net/core/dev.c | 14 ++-------- 3 files changed, 40 insertions(+), 37 deletions(-)
include/linux/netdevice.h +35 -23
@@ -171,31 +171,38 @@ static inline bool dev_xmit_complete(int rc)* (unsigned long) so they can be read and written atomically. */ +#define NET_DEV_STAT (FIELD ) \ + union { \ + unsigned long FIELD; \ + atomic_long_t __##FIELD; \ + } +struct net_device_stats { -unsigned long rx_packets; -unsigned long tx_packets; -unsigned long rx_bytes; -unsigned long tx_bytes; -unsigned long rx_errors; -unsigned long tx_errors; -unsigned long rx_dropped; -unsigned long tx_dropped; -unsigned long multicast; -unsigned long collisions; -unsigned long rx_length_errors; -unsigned long rx_over_errors; -unsigned long rx_crc_errors; -unsigned long rx_frame_errors; -unsigned long rx_fifo_errors; -unsigned long rx_missed_errors; -unsigned long tx_aborted_errors; -unsigned long tx_carrier_errors; -unsigned long tx_fifo_errors; -unsigned long tx_heartbeat_errors; -unsigned long tx_window_errors; -unsigned long rx_compressed; -unsigned long tx_compressed; +NET_DEV_STAT (rx_packets); +NET_DEV_STAT (tx_packets); +NET_DEV_STAT (rx_bytes); +NET_DEV_STAT (tx_bytes); +NET_DEV_STAT (rx_errors); +NET_DEV_STAT (tx_errors); +NET_DEV_STAT (rx_dropped); +NET_DEV_STAT (tx_dropped); +NET_DEV_STAT (multicast); +NET_DEV_STAT (collisions); +NET_DEV_STAT (rx_length_errors); +NET_DEV_STAT (rx_over_errors); +NET_DEV_STAT (rx_crc_errors); +NET_DEV_STAT (rx_frame_errors); +NET_DEV_STAT (rx_fifo_errors); +NET_DEV_STAT (rx_missed_errors); +NET_DEV_STAT (tx_aborted_errors); +NET_DEV_STAT (tx_carrier_errors); +NET_DEV_STAT (tx_fifo_errors); +NET_DEV_STAT (tx_heartbeat_errors); +NET_DEV_STAT (tx_window_errors); +NET_DEV_STAT (rx_compressed); +NET_DEV_STAT (tx_compressed); }; +#undef NET_DEV_STAT/* per-cpu stats, allocated on demand. * Try to fit them in a single cache line, for dev_get_stats() sake.
@@ -5143,4 +5150,9 @@ extern struct list_head ptype_base[PTYPE_HASH_SIZE] __read_mostly;extern struct net_device *blackhole_netdev; +/* Note: Avoid these macros in fast path, prefer per-cpu or per-queue counters. */ +#define DEV_STATS_INC (DEV ,FIELD ) atomic_long_inc(&(DEV)->stats.__##FIELD) +#define DEV_STATS_ADD (DEV ,FIELD ,VAL ) \ + atomic_long_add((VAL), &(DEV)->stats.__##FIELD) +#endif /* _LINUX_NETDEVICE_H */
include/net/dst.h +2 -3
@@ -362,9 +362,8 @@ static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev,static inline void skb_tunnel_rx (struct sk_buff *skb,struct net_device *dev,struct net *net) { -/* TODO : stats should be SMP safe */ - dev->stats.rx_packets++; - dev->stats.rx_bytes += skb->len; +DEV_STATS_INC (dev, rx_packets); +DEV_STATS_ADD (dev, rx_bytes, skb->len);__skb_tunnel_rx (skb, dev, net); }
net/core/dev.c +3 -11
@@ -10398,24 +10398,16 @@ void netdev_run_todo(void)void netdev_stats_to_stats64 (struct rtnl_link_stats64 *stats64,const struct net_device_stats *netdev_stats) { -#if BITS_PER_LONG ==64 -BUILD_BUG_ON (sizeof (*stats64) <sizeof (*netdev_stats)); -memcpy (stats64, netdev_stats,sizeof (*netdev_stats)); -/* zero out counters that only exist in rtnl_link_stats64 */ -memset ((char *)stats64 +sizeof (*netdev_stats),0 , -sizeof (*stats64) -sizeof (*netdev_stats)); -#else -size_t i, n =sizeof (*netdev_stats) /sizeof (unsigned long ); -const unsigned long *src = (const unsigned long *)netdev_stats; +size_t i, n =sizeof (*netdev_stats) /sizeof (atomic_long_t); +const atomic_long_t *src = (atomic_long_t *)netdev_stats;u64 *dst = (u64 *)stats64;BUILD_BUG_ON (n >sizeof (*stats64) /sizeof (u64));for (i =0 ; i < n; i++) - dst[i] = src[i]; + dst[i] =atomic_long_read (&src[i]);/* zero out counters that only exist in rtnl_link_stats64 */ memset ((char *)stats64 + n *sizeof (u64),0 ,sizeof (*stats64) - n *sizeof (u64)); -#endif }EXPORT_SYMBOL (netdev_stats_to_stats64);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 948/1073 ipv6/sit: use DEV_STATS_INC() to avoid data-races
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit cb34b7cf17ecf33499c9298943f85af247abc1e9 ]
syzbot/KCSAN reported that multiple cpus are updating dev->stats.tx_error concurrently.
This is because sit tunnels are NETIF_F_LLTX, meaning their ndo_start_xmit() is not protected by a spinlock.
While original KCSAN report was about tx path, rx path has the same issue.
--- net/ipv6/sit.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
net/ipv6/sit.c +11 -11
@@ -694,7 +694,7 @@ static int ipip6_rcv(struct sk_buff *skb) skb->dev = tunnel->dev;if (packet_is_spoofed (skb, iph, tunnel)) { - tunnel->dev->stats.rx_errors++; +DEV_STATS_INC (tunnel->dev, rx_errors); goto out; }
@@ -714,8 +714,8 @@ static int ipip6_rcv(struct sk_buff *skb)net_info_ratelimited ("non-ECT from %pI4 with TOS=%#x\n" , &iph->saddr, iph->tos);if (err >1 ) { - ++tunnel->dev->stats.rx_frame_errors; - ++tunnel->dev->stats.rx_errors; +DEV_STATS_INC (tunnel->dev, rx_frame_errors); +DEV_STATS_INC (tunnel->dev, rx_errors); goto out; } }
@@ -942,7 +942,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,if (!rt) { rt =ip_route_output_flow (tunnel->net, &fl4,NULL );if (IS_ERR (rt)) { - dev->stats.tx_carrier_errors++; +DEV_STATS_INC (dev, tx_carrier_errors); goto tx_error_icmp; }dst_cache_set_ip4 (&tunnel->dst_cache, &rt->dst, fl4.saddr);
@@ -950,14 +950,14 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,if (rt->rt_type !=RTN_UNICAST && rt->rt_type !=RTN_LOCAL ) {ip_rt_put (rt); - dev->stats.tx_carrier_errors++; +DEV_STATS_INC (dev, tx_carrier_errors); goto tx_error_icmp; } tdev = rt->dst.dev;if (tdev == dev) {ip_rt_put (rt); - dev->stats.collisions++; +DEV_STATS_INC (dev, collisions); goto tx_error; }
@@ -970,7 +970,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, mtu =dst_mtu (&rt->dst) - t_hlen;if (mtu <IPV4_MIN_MTU ) { - dev->stats.collisions++; +DEV_STATS_INC (dev, collisions);ip_rt_put (rt); goto tx_error; }
@@ -1009,7 +1009,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,struct sk_buff *new_skb =skb_realloc_headroom (skb, max_headroom);if (!new_skb) {ip_rt_put (rt); - dev->stats.tx_dropped++; +DEV_STATS_INC (dev, tx_dropped);kfree_skb (skb);return NETDEV_TX_OK ; }
@@ -1039,7 +1039,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,dst_link_failure (skb); tx_error:kfree_skb (skb); - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);return NETDEV_TX_OK ; }
@@ -1058,7 +1058,7 @@ static netdev_tx_t sit_tunnel_xmit__(struct sk_buff *skb,return NETDEV_TX_OK ; tx_error:kfree_skb (skb); - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);return NETDEV_TX_OK ; }
@@ -1087,7 +1087,7 @@ static netdev_tx_t sit_tunnel_xmit(struct sk_buff *skb,return NETDEV_TX_OK ; tx_err: - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);kfree_skb (skb);return NETDEV_TX_OK ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 949/1073 mrp: introduce active flags to prevent UAF when applicant uninit
In reply to Greg Kroah-HartmanFrom: Schspa Shi <[email protected]>
[ Upstream commit ab0377803dafc58f1e22296708c1c28e309414d6 ]
The caller of del_timer_sync must prevent restarting of the timer, If we have no this synchronization, there is a small probability that the cancellation will not be successful.
And syzbot report the fellowing crash:
==================================================================
BUG: KASAN: use-after-free in hlist_add_head include/linux/list.h:929 [inline] BUG: KASAN: use-after-free in enqueue_timer+0x18/0xa4 kernel/time/timer.c:605
Write at addr f9ff000024df6058 by task syz-fuzzer/2256 Pointer tag: [f9], memory tag: [fe]
CPU: 1 PID: 2256 Comm: syz-fuzzer Not tainted 6.1.0-rc5-syzkaller-00008- ge01d50cbd6ee #0 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace.part.0+0xe0/0xf0 arch/arm64/kernel/stacktrace.c:156 dump_backtrace arch/arm64/kernel/stacktrace.c:162 [inline] show_stack+0x18/0x40 arch/arm64/kernel/stacktrace.c:163 __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x68/0x84 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:284 [inline] print_report+0x1a8/0x4a0 mm/kasan/report.c:395 kasan_report+0x94/0xb4 mm/kasan/report.c:495 __do_kernel_fault+0x164/0x1e0 arch/arm64/mm/fault.c:320 do_bad_area arch/arm64/mm/fault.c:473 [inline] do_tag_check_fault+0x78/0x8c arch/arm64/mm/fault.c:749 do_mem_abort+0x44/0x94 arch/arm64/mm/fault.c:825 el1_abort+0x40/0x60 arch/arm64/kernel/entry-common.c:367 el1h_64_sync_handler+0xd8/0xe4 arch/arm64/kernel/entry-common.c:427 el1h_64_sync+0x64/0x68 arch/arm64/kernel/entry.S:576 hlist_add_head include/linux/list.h:929 [inline] enqueue_timer+0x18/0xa4 kernel/time/timer.c:605 mod_timer+0x14/0x20 kernel/time/timer.c:1161 mrp_periodic_timer_arm net/802/mrp.c:614 [inline] mrp_periodic_timer+0xa0/0xc0 net/802/mrp.c:627 call_timer_fn.constprop.0+0x24/0x80 kernel/time/timer.c:1474 expire_timers+0x98/0xc4 kernel/time/timer.c:1519
To fix it, we can introduce a new active flags to make sure the timer will not restart.
--- include/net/mrp.h | 1 + net/802/mrp.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-)
include/net/mrp.h +1 -0
@@ -124,6 +124,7 @@ struct mrp_applicant {struct sk_buff *pdu;struct rb_root mad;struct rcu_head rcu; +bool active; };struct mrp_port {
net/802/mrp.c +13 -5
@@ -606,7 +606,10 @@ static void mrp_join_timer(struct timer_list *t)spin_unlock (&app->lock);mrp_queue_xmit (app); -mrp_join_timer_arm (app); +spin_lock (&app->lock); +if (likely (app->active)) +mrp_join_timer_arm (app); +spin_unlock (&app->lock); }static void mrp_periodic_timer_arm (struct mrp_applicant *app)
@@ -620,11 +623,12 @@ static void mrp_periodic_timer(struct timer_list *t)struct mrp_applicant *app =from_timer (app, t, periodic_timer);spin_lock (&app->lock); -mrp_mad_event (app,MRP_EVENT_PERIODIC ); -mrp_pdu_queue (app); +if (likely (app->active)) { +mrp_mad_event (app,MRP_EVENT_PERIODIC ); +mrp_pdu_queue (app); +mrp_periodic_timer_arm (app); + }spin_unlock (&app->lock); - -mrp_periodic_timer_arm (app); }static int mrp_pdu_parse_end_mark (struct sk_buff *skb,int *offset)
@@ -872,6 +876,7 @@ int mrp_init_applicant(struct net_device *dev, struct mrp_application *appl) app->dev = dev; app->app = appl; app->mad =RB_ROOT ; + app->active = true;spin_lock_init (&app->lock);skb_queue_head_init (&app->queue);rcu_assign_pointer (dev->mrp_port->applicants[appl->type], app);
@@ -900,6 +905,9 @@ void mrp_uninit_applicant(struct net_device *dev, struct mrp_application *appl)RCU_INIT_POINTER (port->applicants[appl->type],NULL ); +spin_lock_bh (&app->lock); + app->active = false; +spin_unlock_bh (&app->lock);/* Delete timer and generate a final TX event to flush out * all pending messages before the applicant is gone. */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 950/1073 net: ethernet: mtk_eth_soc: drop packets to WDMA if the ring is full
In reply to Greg Kroah-HartmanFrom: Felix Fietkau <[email protected]>
[ Upstream commit f4b2fa2c25e1ade78f766aa82e733a0b5198d484 ]
Improves handling of DMA ring overflow.
Clarify other WDMA drop related comment.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 5 ++++- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +4 -1
@@ -3344,9 +3344,12 @@ static int mtk_hw_init(struct mtk_eth *eth)mtk_w32 (eth,0x21021000 ,MTK_FE_INT_GRP );if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) { -/* PSE should not drop port8 and port9 packets */ +/* PSE should not drop port8 and port9 packets from WDMA Tx */ mtk_w32 (eth,0x00000300 ,PSE_DROP_CFG ); +/* PSE should drop packets to port 8/9 on WDMA Rx ring full */ +mtk_w32 (eth,0x00000300 ,PSE_PPE0_DROP ); +/* PSE Free Queue Flow Control */ mtk_w32 (eth,0x01fa01f4 ,PSE_FQFC_CFG2 );
drivers/net/ethernet/mediatek/mtk_eth_soc.h +1 -0
@@ -121,6 +121,7 @@#define PSE_FQFC_CFG1 0x100#define PSE_FQFC_CFG2 0x104#define PSE_DROP_CFG 0x108 +#define PSE_PPE0_DROP 0x110/* PSE Input Queue Reservation Register*/ #define PSE_IQ_REV (x) (0x140 + (((x) - 1) << 2))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 951/1073 ppp: associate skb with a device at tx
In reply to Greg Kroah-HartmanFrom: Stanislav Fomichev <[email protected]>
[ Upstream commit 9f225444467b98579cf28d94f4ad053460dfdb84 ]
Syzkaller triggered flow dissector warning with the following:
r0 = openat$ppp(0xffffffffffffff9c, &(0x7f0000000000), 0xc0802, 0x0)
ioctl$PPPIOCNEWUNIT(r0, 0xc004743e, &(0x7f00000000c0))
ioctl$PPPIOCSACTIVE(r0, 0x40107446, &(0x7f0000000240)={0x2, &(0x7f0000000180)=[{0x20, 0x0, 0x0, 0xfffff034}, {0x6}]}) pwritev(r0, &(0x7f0000000040)=[{&(0x7f0000000140)='\x00!', 0x2}], 0x1, 0x0, 0x0)
[ 9.485814] WARNING: CPU: 3 PID: 329 at net/core/flow_dissector.c:1016 __skb_flow_dissect+0x1ee0/0x1fa0 [ 9.485929] skb_get_poff+0x53/0xa0 [ 9.485937] bpf_skb_get_pay_offset+0xe/0x20 [ 9.485944] ? ppp_send_frame+0xc2/0x5b0 [ 9.485949] ? _raw_spin_unlock_irqrestore+0x40/0x60 [ 9.485958] ? __ppp_xmit_process+0x7a/0xe0 [ 9.485968] ? ppp_xmit_process+0x5b/0xb0 [ 9.485974] ? ppp_write+0x12a/0x190 [ 9.485981] ? do_iter_write+0x18e/0x2d0 [ 9.485987] ? __import_iovec+0x30/0x130 [ 9.485997] ? do_pwritev+0x1b6/0x240 [ 9.486016] ? trace_hardirqs_on+0x47/0x50 [ 9.486023] ? __x64_sys_pwritev+0x24/0x30 [ 9.486026] ? do_syscall_64+0x3d/0x80 [ 9.486031] ? entry_SYSCALL_64_after_hwframe+0x63/0xcd
Flow dissector tries to find skb net namespace either via device or via socket. Neigher is set in ppp_send_frame, so let's manually use ppp->dev.
--- drivers/net/ppp/ppp_generic.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ppp/ppp_generic.c +2 -0
@@ -1743,6 +1743,8 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)int len;unsigned char *cp; + skb->dev = ppp->dev; +if (proto <0x8000 ) {#ifdef CONFIG_PPP_FILTER /* check if we should pass this packet */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 952/1073 bpf: Fix a BTF_ID_LIST bug with CONFIG_DEBUG_INFO_BTF not set
In reply to Greg Kroah-HartmanFrom: Yonghong Song <[email protected]>
[ Upstream commit beb3d47d1d3d7185bb401af628ad32ee204a9526 ]
With CONFIG_DEBUG_INFO_BTF not set, we hit the following compilation error,
/.../kernel/bpf/verifier.c:8196:23: error: array index 6 is past the end of the array (that has type 'u32[5]' (aka 'unsigned int[5]')) [-Werror,-Warray-bounds]
if (meta->func_id == special_kfunc_list[KF_bpf_cast_to_kern_ctx])
^ ~~~~~~~~~~~~~~~~~~~~~~~
/.../kernel/bpf/verifier.c:8174:1: note: array 'special_kfunc_list' declared here
BTF_ID_LIST(special_kfunc_list)
^
/.../include/linux/btf_ids.h:207:27: note: expanded from macro 'BTF_ID_LIST'
#define BTF_ID_LIST(name) static u32 __maybe_unused name[5];
^
/.../kernel/bpf/verifier.c:8443:19: error: array index 5 is past the end of the array
(that has type 'u32[5]' (aka 'unsigned int[5]')) [-Werror,-Warray-bounds]
btf_id == special_kfunc_list[KF_bpf_list_pop_back];
^ ~~~~~~~~~~~~~~~~~~~~ /.../kernel/bpf/verifier.c:8174:1: note: array 'special_kfunc_list' declared here BTF_ID_LIST(special_kfunc_list)
^
/.../include/linux/btf_ids.h:207:27: note: expanded from macro 'BTF_ID_LIST' #define BTF_ID_LIST(name) static u32 __maybe_unused name[5];
...
Fix the problem by increase the size of BTF_ID_LIST to 16 to avoid compilation error and also prevent potentially unintended issue due to out-of-bound access.
--- include/linux/btf_ids.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/btf_ids.h +1 -1
@@ -204,7 +204,7 @@ extern struct btf_id_set8 name;#else -#define BTF_ID_LIST (name) static u32 __maybe_unused name[5]; +#define BTF_ID_LIST (name) static u32 __maybe_unused name[16];#define BTF_ID (prefix, name)#define BTF_ID_FLAGS (prefix, name, ...)#define BTF_ID_UNUSED
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 953/1073 bpf: Prevent decl_tag from being referenced in func_proto arg
In reply to Greg Kroah-HartmanFrom: Stanislav Fomichev <[email protected]>
[ Upstream commit f17472d4599697d701aa239b4c475a506bccfd19 ]
Syzkaller managed to hit another decl_tag issue:
btf_func_proto_check kernel/bpf/btf.c:4506 [inline] btf_check_all_types kernel/bpf/btf.c:4734 [inline] btf_parse_type_sec+0x1175/0x1980 kernel/bpf/btf.c:4763 btf_parse kernel/bpf/btf.c:5042 [inline] btf_new_fd+0x65a/0xb00 kernel/bpf/btf.c:6709 bpf_btf_load+0x6f/0x90 kernel/bpf/syscall.c:4342 __sys_bpf+0x50a/0x6c0 kernel/bpf/syscall.c:5034 __do_sys_bpf kernel/bpf/syscall.c:5093 [inline] __se_sys_bpf kernel/bpf/syscall.c:5091 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5091 do_syscall_64+0x54/0x70 arch/x86/entry/common.c:48
This seems similar to commit ea68376c8bed ("bpf: prevent decl_tag from being referenced in func_proto") but for the argument.
--- kernel/bpf/btf.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/bpf/btf.c +5 -0
@@ -4481,6 +4481,11 @@ static int btf_func_proto_check(struct btf_verifier_env *env,break ; } +if (btf_type_is_resolve_source_only (arg_type)) { +btf_verifier_log_type (env, t,"Invalid arg#%u" , i +1 ); +return -EINVAL ; + } +if (args[i].name_off && (!btf_name_offset_valid (btf, args[i].name_off) || !btf_name_valid_identifier (btf, args[i].name_off))) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 954/1073 ethtool: avoiding integer overflow in ethtool_phys_id()
In reply to Greg Kroah-HartmanFrom: Maxim Korotkov <[email protected]>
[ Upstream commit 64a8f8f7127da228d59a39e2c5e75f86590f90b4 ]
The value of an arithmetic expression "n * id.data" is subject to possible overflow due to a failure to cast operands to a larger data type before performing arithmetic. Used macro for multiplication instead operator for avoiding overflow.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- net/ethtool/ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ethtool/ioctl.c +2 -1
@@ -2007,7 +2007,8 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) }else {/* Driver expects to be called at twice the frequency in rc */ int n = rc *2 , interval =HZ / n; -u64 count = n * id.data, i =0 ; +u64 count =mul_u32_u32 (n, id.data); +u64 i =0 ; do { rtnl_lock();
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 955/1073 media: dvb-frontends: fix leak of memory fw
In reply to Greg Kroah-HartmanFrom: Yan Lei <[email protected]>
[ Upstream commit a15fe8d9f1bf460a804bcf18a890bfd2cf0d5caa ]
--- drivers/media/dvb-frontends/bcm3510.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/dvb-frontends/bcm3510.c +1 -0
@@ -649,6 +649,7 @@ static int bcm3510_download_firmware(struct dvb_frontend* fe)deb_info ("firmware chunk, addr: 0x%04x, len: 0x%04x, total length: 0x%04zx\n" ,addr,len,fw->size);if ((ret =bcm3510_write_ram (st,addr,&b[i+4 ],len)) <0 ) {err ("firmware download failed: %d\n" ,ret); +release_firmware (fw);return ret; } i +=4 + len;
Signature · 1 line
2.35.1