7.2.6-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 335/1815 perf record: Fix teardown hang on system-wide multi-threaded sessions
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit fb4751e79c45cb48cff1c1d86b10a9cc6f6612fe ]
Under system-wide (-a) parallel streaming mode (--threads=cpu), background recording threads can be inundated by a continuous firehose of hardware samples generated by the OS. In this state, a background thread's local hit count remains unequal to its sample count, causing it to bypass the blocking fdarray__poll() call entirely on each iteration of its recording loop.
Because the termination check relies on the POLLHUP event status populated specifically by fdarray__poll(), bypassing it prevents the background thread from ever recognizing that its control pipe was closed by the main thread. This traps the background thread in an infinite recording loop, hanging the main thread indefinitely as it awaits a termination acknowledgment that never arrives.
Ensure teardown completion by adding explicit evlist__disable() calls in the main thread's cleanup paths at out_child: and out_child_no_flush:. Additionally, patch fdarray__filter() to respect the fdarray_flag__nonfilterable flag, preventing it from incorrectly setting the background thread's control pipe file descriptor to -1 and clearing its revents mask upon processing termination POLLHUP signals.
--- tools/lib/api/fd/array.c | 6 ++++-- tools/perf/builtin-record.c | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-)
tools/lib/api/fd/array.c +4 -2
@@ -115,6 +115,9 @@ int fdarray__filter(struct fdarray *fda, short revents,return 0 ;for (fd =0 ; fd < fda->nr; ++fd) { +if (fda->priv[fd].flags & fdarray_flag__nonfilterable) +continue ; +if (!fda->entries[fd].events)continue ;
@@ -132,8 +135,7 @@ int fdarray__filter(struct fdarray *fda, short revents,continue ; } -if (!(fda->priv[fd].flags & fdarray_flag__nonfilterable)) - ++nr; + ++nr; }return nr;
tools/perf/builtin-record.c +2 -0
@@ -2890,11 +2890,13 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)record__synthesize_workload (rec, true); out_child: +evlist__disable (rec->evlist);record__stop_threads (rec);record__mmap_read_all (rec, true); goto out_free_threads; out_child_no_flush:/* mmap read already failed — retrying would just fail again */ +evlist__disable (rec->evlist);record__stop_threads (rec); out_free_threads:record__free_thread_data (rec);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 336/1815 clk: spacemit: k3: fix parent clock of UFS aclk
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yixun Lan <[email protected]>
[ Upstream commit 7a588b62679c51abd08171d31df6e44589f0097d ]
According to SpacemiT updated clock docs, the previous UFS aclk parent clock was wrong, the correct one is illustrated below, so fix it.
--> pll1_d5_491p52 --\ --> pll1_d6_409p6 --| --> pll2_d6 --|--> div --> gate --> ufs_aclk --> pll2_d5 --/
--- drivers/clk/spacemit/ccu-k3.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/clk/spacemit/ccu-k3.c +3 -4
@@ -926,11 +926,10 @@ CCU_MUX_DIV_GATE_FC_DEFINE(dpu_aclk, dpu_aclk_parents, APMU_LCD_CLK_RES_CTRL5, 1 20, 3, BIT(16), 0);static const struct clk_parent_data ufs_aclk_parents[] = { -CCU_PARENT_HW (pll1_d6_409p6),CCU_PARENT_HW (pll1_d5_491p52), -CCU_PARENT_HW (pll1_d4_614p4), -CCU_PARENT_HW (pll1_d8_307p2), -CCU_PARENT_HW (pll2_d4), +CCU_PARENT_HW (pll1_d6_409p6), +CCU_PARENT_HW (pll2_d6), +CCU_PARENT_HW (pll2_d5), };CCU_MUX_DIV_GATE_FC_DEFINE (ufs_aclk, ufs_aclk_parents,APMU_UFS_CLK_RES_CTRL ,5 ,3 ,BIT (8 ),2 ,3 ,BIT (1 ),0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 337/1815 perf metricgroup: Fix metric expression copy leaks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Peng <[email protected]>
[ Upstream commit ef3af1df4f3372bd8ad47619452a283048b3bc8d ]
metricgroup__copy_metric_events() allocates a new metric expression and duplicates metric_name before linking the expression into the destination metric event.
Free new_expr when strdup() fails, and free the duplicated metric_name on the later error paths.
--- tools/perf/util/metricgroup.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/perf/util/metricgroup.c +6 -1
@@ -1693,8 +1693,10 @@ int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp, new_expr->metric_expr = old_expr->metric_expr; new_expr->metric_threshold = old_expr->metric_threshold; new_expr->metric_name =strdup (old_expr->metric_name); -if (!new_expr->metric_name) +if (!new_expr->metric_name) { +free (new_expr);return -ENOMEM ; + } new_expr->metric_unit = old_expr->metric_unit; new_expr->runtime = old_expr->runtime;
@@ -1707,6 +1709,7 @@ int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp, alloc_size =sizeof (*new_expr->metric_refs); new_expr->metric_refs =calloc (nr +1 , alloc_size);if (!new_expr->metric_refs) { +zfree (&new_expr->metric_name);free (new_expr);return -ENOMEM ; }
@@ -1723,6 +1726,7 @@ int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp, alloc_size =sizeof (*new_expr->metric_events); new_expr->metric_events =calloc (nr +1 , alloc_size);if (!new_expr->metric_events) { +zfree (&new_expr->metric_name);zfree (&new_expr->metric_refs);free (new_expr);return -ENOMEM ;
@@ -1733,6 +1737,7 @@ int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp, evsel = old_expr->metric_events[idx]; evsel =evlist__find_evsel (evlist, evsel->core.idx);if (evsel ==NULL ) { +zfree (&new_expr->metric_name);zfree (&new_expr->metric_events);zfree (&new_expr->metric_refs);free (new_expr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 338/1815 soc: qcom: rpmh-rsc: manage PM notifiers with devres
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 75e918aa876440d8ad559a11d6ab87bddb1ed79a ]
rpmh_rsc_probe() registers CPU PM or genpd notifiers before populating child devices. If child population fails, the CPU PM notifier path is not unwound and the genpd path needs open-coded cleanup.
Use devm_pm_runtime_enable() for the genpd path and devm_add_action_or_reset() for both notifier registrations. This makes probe failure and driver detach use the same cleanup model while keeping devm_of_platform_populate() responsible for child devices.
--- drivers/soc/qcom/rpmh-rsc.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-)
drivers/soc/qcom/rpmh-rsc.c +26 -11
@@ -944,17 +944,30 @@ static int rpmh_rsc_pd_callback(struct notifier_block *nfb,return NOTIFY_OK ; } +static void rpmh_rsc_pd_detach (void *data) +{ +dev_pm_genpd_remove_notifier (data); +} +static int rpmh_rsc_pd_attach (struct rsc_drv *drv,struct device *dev) {int ret; -pm_runtime_enable (dev); + ret =devm_pm_runtime_enable (dev); +if (ret) +return ret; + drv->genpd_nb.notifier_call = rpmh_rsc_pd_callback; ret =dev_pm_genpd_add_notifier (dev, &drv->genpd_nb);if (ret) -pm_runtime_disable (dev); +return ret; -return ret; +return devm_add_action_or_reset (dev, rpmh_rsc_pd_detach, dev); +} + +static void rpmh_rsc_cpu_pm_unregister (void *data) +{ +cpu_pm_unregister_notifier (data); }static int rpmh_probe_tcs_config (struct platform_device *pdev,struct rsc_drv *drv)
@@ -1107,7 +1120,15 @@ static int rpmh_rsc_probe(struct platform_device *pdev)return ret; }else { drv->rsc_pm.notifier_call = rpmh_rsc_cpu_pm_callback; -cpu_pm_register_notifier (&drv->rsc_pm); + ret =cpu_pm_register_notifier (&drv->rsc_pm); +if (ret) +return ret; + + ret =devm_add_action_or_reset (&pdev->dev, + rpmh_rsc_cpu_pm_unregister, + &drv->rsc_pm); +if (ret) +return ret; } }
@@ -1122,13 +1143,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev)dev_set_drvdata (&pdev->dev, drv); drv->dev = &pdev->dev; - ret =devm_of_platform_populate (&pdev->dev); -if (ret && pdev->dev.pm_domain) { -dev_pm_genpd_remove_notifier (&pdev->dev); -pm_runtime_disable (&pdev->dev); - } - -return ret; +return devm_of_platform_populate (&pdev->dev); }static const struct of_device_id rpmh_drv_match[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 339/1815 bus: qcom-ebi2: use managed resources for clocks and children
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit d19a46f7ed8eb54fea61e0eaf7db53ff7babb03c ]
qcom_ebi2_probe() enables the EBI2 clocks manually and populates child devices manually. Several later failure paths can then return without disabling the clocks or without relying on the driver core to undo child population.
Use devm_clk_get_enabled() for both clocks and devm_of_platform_populate() for children. This lets the driver core unwind the resources automatically and removes the hand-written error labels.
--- drivers/bus/qcom-ebi2.c | 50 +++++++++-------------------------------- 1 file changed, 11 insertions(+), 39 deletions(-)
drivers/bus/qcom-ebi2.c +11 -39
@@ -302,41 +302,23 @@ static int qcom_ebi2_probe(struct platform_device *pdev)u32 val;int ret; - ebi2xclk =devm_clk_get (dev,"ebi2x" ); + ebi2xclk =devm_clk_get_enabled (dev,"ebi2x" );if (IS_ERR (ebi2xclk))return PTR_ERR (ebi2xclk); - ret =clk_prepare_enable (ebi2xclk); -if (ret) { -dev_err (dev,"could not enable EBI2X clk (%d)\n" , ret); -return ret; - } - - ebi2clk =devm_clk_get (dev,"ebi2" ); -if (IS_ERR (ebi2clk)) { - ret =PTR_ERR (ebi2clk); - goto err_disable_2x_clk; - } - - ret =clk_prepare_enable (ebi2clk); -if (ret) { -dev_err (dev,"could not enable EBI2 clk\n" ); - goto err_disable_2x_clk; - } + ebi2clk =devm_clk_get_enabled (dev,"ebi2" ); +if (IS_ERR (ebi2clk)) +return PTR_ERR (ebi2clk); res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); ebi2_base =devm_ioremap_resource (dev, res); -if (IS_ERR (ebi2_base)) { - ret =PTR_ERR (ebi2_base); - goto err_disable_clk; - } +if (IS_ERR (ebi2_base)) +return PTR_ERR (ebi2_base); res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); ebi2_xmem =devm_ioremap_resource (dev, res); -if (IS_ERR (ebi2_xmem)) { - ret =PTR_ERR (ebi2_xmem); - goto err_disable_clk; - } +if (IS_ERR (ebi2_xmem)) +return PTR_ERR (ebi2_xmem);/* Allegedly this turns the power save mode off */ writel (0UL , ebi2_xmem +EBI2_XMEM_CFG );
@@ -353,7 +335,7 @@ static int qcom_ebi2_probe(struct platform_device *pdev)/* Figure out the chipselect */ ret =of_property_read_u32 (child,"reg" , &csindex);if (ret) - goto err_disable_clk; +return ret;if (csindex >5 ) { dev_err(dev,
@@ -372,20 +354,10 @@ static int qcom_ebi2_probe(struct platform_device *pdev) have_children = true; } -if (have_children) { - ret =of_platform_default_populate (np,NULL , dev); -if (ret) - goto err_disable_clk; - } +if (have_children) +return devm_of_platform_populate (dev);return 0 ; - -err_disable_clk: -clk_disable_unprepare (ebi2clk); -err_disable_2x_clk: -clk_disable_unprepare (ebi2xclk); - -return ret; }static const struct of_device_id qcom_ebi2_of_match[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 340/1815 clk: qcom: camcc-sc8280xp: unregister CAMCC_GDSC_CLK
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Masney <[email protected]>
[ Upstream commit 499b4cb6710f9a351d8b57a2132f9b4389d8464a ]
With the introduction of sync_state support in the clk and pmdomain subsystems, the following warning happens when the unused clocks are shutdown in camcc-sc8280xp:
[ 15.408367] titan_top_gdsc status stuck at 'on'
[ 15.408429] WARNING: drivers/clk/qcom/gdsc.c:178 at gdsc_toggle_logic+0x14c/0x160, CPU#2: kworker/u32:1/14
[ 15.408462] Modules linked in: bnep vfat fat ath11k_pci(+) ath11k mac80211 cfg80211 mhi libarc4 snd_soc_wcd938x snd_soc_wcd938x_sdw snd_soc_wcd_classh hci_uart snd_soc_wcd_common
snd_soc_sc8280xp soundwire_qcom snd_soc_wcd_mbhc snd_soc_qcom_sdw slimbus snd_soc_qcom_common regmap_sdw btqca btrtl qcom_camss soundwire_bus btbcm btintel snd_soc_sdca snd_soc_lpass_wsa_macro
bluetooth snd_soc_lpass_tx_macro snd_soc_lpass_va_macro snd_soc_lpass_rx_macro snd_soc_hdmi_codec snd_soc_lpass_macro_common videobuf2_dma_sg ov5675 v4l2_fwnode videobuf2_memops
qcom_spmi_adc5 snd_soc_core qcom_spmi_adc_tm5 videobuf2_v4l2 snd_seq snd_seq_device videobuf2_common v4l2_async qcom_vadc_common qcom_spmi_temp_alarm pm8941_pwrkey industrialio videodev
snd_compress rfkill ac97_bus snd_pcm_dmaengine qcom_tsens mc qcom_edac snd_pcm pci_pwrctrl_pwrseq qcom_cpufreq_hw snd_timer snd qcomtee soundcore tee leds_gpio joydev binfmt_misc zram
lz4hc_compress governor_simpleondemand panel_edp msm xhci_plat_hcd nvme nvme_core dwc3 qcom_pm8008_regulator
[ 15.408688] ucsi_glink nvme_keyring nvme_auth pmic_glink_altmode udc_core typec_ucsi aux_hpd_bridge qcom_battmgr ulpi ubwc_config socinfo ocmem drm_gpuvm qcom_q6v5_pas drm_exec
qcom_pil_info leds_qcom_lpg gpu_sched led_class_multicolor rtc_pm8xxx qcom_pbs qcom_common drm_display_helper qcom_pon qcom_glink_smem qcom_glink ghash_ce pwrseq_qcom_wcn gpio_sbu_mux
qcom_stats phy_qcom_qmp_combo qcom_q6v5 gf128mul cec dispcc_sc8280xp phy_qcom_edp camcc_sc8280xp i2c_qcom_cci qcom_sysmon drm_dp_aux_bus mdt_loader aux_bridge qcom_pm8008 i2c_hid_of_elan
dwc3_qcom_legacy llcc_qcom icc_bwmon gpi typec qcom_refgen_regulator phy_qcom_qmp_usb nvmem_qfprom qcom_ipcc phy_qcom_snps_femto_v2 gpucc_sc8280xp pinctrl_sc8280xp_lpass_lpi qcom_hwspinlock
pinctrl_lpass_lpi lpasscc_sc8280xp qrtr qcom_aoss pmic_glink pdr_interface phy_qcom_qmp_pcie qcom_smd qcom_pdr_msg icc_osm_l3 qcom_wdt qmi_helpers qcom_rng smp2p rpmsg_core gpio_keys pwm_bl
smem hid_multitouch fuse i2c_dev
[ 15.408928] CPU: 2 UID: 0 PID: 14 Comm: kworker/u32:1 Not tainted 7.1.0+ #2 PREEMPT(lazy)
[ 15.408937] Hardware name: LENOVO 21BX0016US/21BX0016US, BIOS N3HET88W (1.60 ) 03/14/2024
[ 15.408942] Workqueue: pm pm_runtime_work
[ 15.408959] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 15.408967] pc : gdsc_toggle_logic+0x14c/0x160
[ 15.408978] lr : gdsc_toggle_logic+0x14c/0x160
[ 15.408987] sp : ffff8000800f3b40
[ 15.408991] x29: ffff8000800f3b40 x28: 0000000000000000 x27: 0000000000000000
[ 15.409003] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000
[ 15.409014] x23: 0000000000000000 x22: 0000000000000001 x21: ffffa33f298fca88
[ 15.409024] x20: 0000000000000000 x19: ffffa33f298fc5b0 x18: 00cd15db75dacefd
[ 15.409035] x17: 000000040044ffff x16: ffffa33f3b1a3d88 x15: 726f776b80000002
[ 15.409045] x14: ffffffffffffffff x13: 0000000000000028 x12: 0101010101010101
[ 15.409056] x11: 7f7f7f7f7f7f7f7f x10: fefeff3039313274 x9 : ffffa33f3a5edafc
[ 15.409067] x8 : ffff8000800f3780 x7 : 0000000000000001 x6 : 0000000000000001
[ 15.409078] x5 : ffff000bf3ca1288 x4 : 0000000000000000 x3 : ffff5cccb6a3f000
[ 15.409088] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff000080ae0000
[ 15.409098] Call trace:
[ 15.409103] gdsc_toggle_logic+0x14c/0x160 (P)
[ 15.409115] gdsc_disable+0x4c/0x190
[ 15.409126] _genpd_power_off+0xa0/0x1a8
[ 15.409137] genpd_power_off.part.0+0x180/0x2a0
[ 15.409149] genpd_runtime_suspend+0x218/0x310
[ 15.409155] __rpm_callback+0x50/0x1f8
[ 15.409166] rpm_callback+0x7c/0x90
[ 15.409175] rpm_suspend+0xe8/0x690
[ 15.409185] pm_runtime_work+0xd0/0xe0
[ 15.409195] process_one_work+0x18c/0x518
[ 15.409208] worker_thread+0x190/0x320
[ 15.409218] kthread+0x110/0x130
[ 15.409227] ret_from_fork+0x10/0x20This clock is force enabled to be on in the probe, and registered with the Common Clk Framework, resulting in them being toggled off after unused clocks are shutdown. This clock is required for the GDSC transitions.
Similar to the fix in commit b60521eff227 ("clk: qcom: gcc-x1e80100:
Unregister GCC_GPU_CFG_AHB_CLK/GCC_DISP_XO_CLK"), let's just unregister this clock.
--- drivers/clk/qcom/camcc-sc8280xp.c | 19 ------------------- 1 file changed, 19 deletions(-)
drivers/clk/qcom/camcc-sc8280xp.c +0 -19
@@ -1753,24 +1753,6 @@ static struct clk_branch camcc_csiphy3_clk = { }, }; -static struct clk_branch camcc_gdsc_clk = { - .halt_reg =0xc1e4 , - .halt_check =BRANCH_HALT , - .clkr = { - .enable_reg =0xc1e4 , - .enable_mask =BIT (0 ), - .hw.init = &(struct clk_init_data ){ - .name ="camcc_gdsc_clk" , - .parent_hws = (const struct clk_hw *[]){ - &camcc_xo_clk_src.clkr.hw, - }, - .num_parents =1 , - .flags =CLK_SET_RATE_PARENT , - .ops = &clk_branch2_ops, - }, - }, -}; -static struct clk_branch camcc_icp_ahb_clk = { .halt_reg =0xc0d8 , .halt_check =BRANCH_HALT ,
@@ -2839,7 +2821,6 @@ static struct clk_regmap *camcc_sc8280xp_clocks[] = { [CAMCC_CSIPHY2_CLK] = &camcc_csiphy2_clk.clkr, [CAMCC_CSIPHY3_CLK] = &camcc_csiphy3_clk.clkr, [CAMCC_FAST_AHB_CLK_SRC] = &camcc_fast_ahb_clk_src.clkr, - [CAMCC_GDSC_CLK] = &camcc_gdsc_clk.clkr, [CAMCC_ICP_AHB_CLK] = &camcc_icp_ahb_clk.clkr, [CAMCC_ICP_CLK] = &camcc_icp_clk.clkr, [CAMCC_ICP_CLK_SRC] = &camcc_icp_clk_src.clkr,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 341/1815 bpf: Require a BPF cpumask for bpf_cpumask_populate()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Dudar <[email protected]>
[ Upstream commit 8740156ad33be5071b588b594c55f279457f667c ]
bpf_cpumask_populate() writes to its destination with bitmap_copy(), but the destination is typed as struct cpumask *. That allows the verifier to accept borrowed cpumask pointers returned by read-only kfuncs, such as scx_bpf_get_online_cpumask(), as a writable destination.
Make the destination a struct bpf_cpumask * so populate follows the same ownership rule as the other mutating cpumask kfuncs. Query kfuncs continue to accept const struct cpumask * inputs.
--- kernel/bpf/cpumask.c | 6 +++--- tools/sched_ext/include/scx/compat.bpf.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
kernel/bpf/cpumask.c +3 -3
@@ -449,12 +449,12 @@ __bpf_kfunc u32 bpf_cpumask_weight(const struct cpumask *cpumask)* @src__sz: Length of the BPF memory region in bytes. * * Return: -* * 0 if the struct cpumask * instance was populated successfully. +* * 0 if the struct bpf_cpumask * instance was populated successfully. * * -EACCES if the memory region is too small to populate the cpumask. * * -EINVAL if the memory region is not aligned to the size of a long * and the architecture does not support efficient unaligned accesses. */ -__bpf_kfunc int bpf_cpumask_populate(struct cpumask *cpumask, void *src, size_t src__sz) +__bpf_kfunc int bpf_cpumask_populate(struct bpf_cpumask *cpumask, void *src, size_t src__sz) {unsigned long source = (unsigned long )src;
@@ -467,7 +467,7 @@ __bpf_kfunc int bpf_cpumask_populate(struct cpumask *cpumask, void *src, size_t !IS_ALIGNED(source, sizeof(long)))return -EINVAL ; -bitmap_copy (cpumask_bits (cpumask), src, nr_cpu_ids); +bitmap_copy (cpumask_bits (&cpumask->cpumask), src, nr_cpu_ids);return 0 ; }
tools/sched_ext/include/scx/compat.bpf.h +1 -1
@@ -84,7 +84,7 @@ bool scx_bpf_dispatch_vtime_from_dsq___old(struct bpf_iter_scx_dsq *it__iter, st* * Compat macro will be dropped on v6.19 release. */ -int bpf_cpumask_populate(struct cpumask *dst, void *src, size_t src__sz) __ksym __weak; +int bpf_cpumask_populate(struct bpf_cpumask *dst, void *src, size_t src__sz) __ksym __weak;#define __COMPAT_bpf_cpumask_populate (cpumask, src, size__sz) \ (bpf_ksym_exists(bpf_cpumask_populate) ? \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 342/1815 bpf: Mark tracing_multi trampolines as ftrace managed
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit 30bdd6d1384d894931f113eb595636092d8e650c ]
Since tracing_multi link does not set ftrace_managed, it would fail to release the tracing_multi link when attaching tracing_multi link and then attaching fentry link.
[ 3.714215] WARNING: kernel/bpf/trampoline.c:1727 at bpf_trampoline_multi_detach+0x20b/0x240, CPU#1: test_progs/97 ... [ 3.733170] bpf_tracing_multi_link_release+0x14/0x30 [ 3.733890] bpf_link_free+0x58/0x130 [ 3.734414] bpf_link_release+0x23/0x30
Fix it by setting 'ftrace_managed = true' in register_fentry_multi().
--- kernel/bpf/trampoline.c | 1 + 1 file changed, 1 insertion(+)
kernel/bpf/trampoline.c +1 -0
@@ -1536,6 +1536,7 @@ static int register_fentry_multi(struct bpf_trampoline *tr, struct bpf_tramp_imaif (bpf_trampoline_use_jmp (tr->flags)) addr =ftrace_jmp_set (addr); + tr->func.ftrace_managed = true;ftrace_hash_add (data->reg, data->entry, ip, addr); tr->cur_image = im;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 343/1815 wifi: rtw89: 8852a: fix RSSI report when average beacon RSSI is not ready
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chih-Kang Chang <[email protected]>
[ Upstream commit 9bf6bd6ed5accb57544d04ded911a2ef1642d48f ]
8852A uses the average beacon RSSI to smooth the RSSI. However, before the average beacon RSSI is available, the RSSI should use the PPDU status RSSI of the received packet to avoid reporting the RSSI as -110 dBm.
--- drivers/net/wireless/realtek/rtw89/rtw8852a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw89/rtw8852a.c +1 -1
@@ -2212,7 +2212,7 @@ static void rtw8852a_query_ppdu(struct rtw89_dev *rtwdev,u8 raw;if (!status->signal) { -if (phy_ppdu->to_self) +if (phy_ppdu->to_self &&ewma_rssi_read (&bb->bcn_rssi)) raw =ewma_rssi_read (&bb->bcn_rssi);else raw =max (rx_power[RF_PATH_A ], rx_power[RF_PATH_B ]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 344/1815 iio: accel: dmard09: Implement IIO_CHAN_INFO_SCALE
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mert Seftali <[email protected]>
[ Upstream commit aa58ecc73466d0cb8c418de98e2225490bf600e3 ]
Reading the in_accel_scale attribute on the DMARD09 has always returned -EINVAL: the channels advertise scale via info_mask_shared_by_type so the IIO core exposes the attribute, but dmard09_read_raw() only handles IIO_CHAN_INFO_RAW, so a SCALE read falls through to 'default: return -EINVAL':
$ cat .../iio:deviceX/in_accel_scale
cat: in_accel_scale: Invalid argumentleaving userspace with raw counts it cannot convert to m/s^2.
The driver was written from a vendor source [1] without a datasheet, and the scale was declared but never implemented. The vendor source carries the sensitivity: its conversion is
acc = raw * GRAVITY_EARTH_1000 / sensitivity (then / 1000 -> m/s^2)
with sensitivity = 32 and GRAVITY_EARTH_1000 = 9807 ("about (9.80665)*1000"), i.e. 32 counts correspond to 1 g.
That sensitivity applies to the value this driver already reports as raw:
the vendor reduces each 16-bit sample to a signed 9-bit value, and the preparation in dmard09_read_raw() yields the same value. It is
self-consistent: 256 counts / 32 = 8 g full scale, matching the +/-8g range.
Implement the scale derived from that sensitivity using standard gravity:
scale = 9.80665 / 32 = 0.3064578125 m/s^2 per LSB
--- drivers/iio/accel/dmard09.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/iio/accel/dmard09.c +7 -0
@@ -8,6 +8,7 @@#include <linux/unaligned.h> #include <linux/module.h> #include <linux/i2c.h> +#include <linux/units.h> #include <linux/iio/iio.h> #define DMARD09_DRV_NAME "dmard09"
@@ -79,6 +80,12 @@ static int dmard09_read_raw(struct iio_dev *indio_dev, *val = accel;return IIO_VAL_INT ; +case IIO_CHAN_INFO_SCALE : + *val =0 ; +/* 1 g / 32 LSB, in m/s^2 */ + *val2 =IIO_G_TO_M_S_2 (NANO /32 ); + +return IIO_VAL_INT_PLUS_NANO ;default :return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 345/1815 RDMA/core: Wait for RCU callbacks before unloading ib_core
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 7d75592114d1664623c8cf191a12b38052c04483 ]
put_gid_ndev() is queued with call_rcu() and implemented in ib_core. Stopping the workqueues does not drain callbacks already queued, so RCU could invoke it after the module code has been unloaded.
synchronize_rcu() does not wait for callbacks. Wait for them after all producers have stopped.
--- drivers/infiniband/core/device.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/core/device.c +1 -0
@@ -3150,6 +3150,7 @@ static void __exit ib_core_cleanup(void)/* Make sure that any pending umem accounting work is done. */ destroy_workqueue (ib_wq);destroy_workqueue (ib_unreg_wq); +rcu_barrier ();WARN_ON (!xa_empty (&clients));WARN_ON (!xa_empty (&devices)); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 346/1815 RDMA/mlx5: Drain RCU callbacks during module teardown
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit e37cdd75f8d61c1123d324ae5667ac3da562290e ]
devx_free_subscription() can remain queued after the last DevX event file drops its module reference or an auxiliary driver detaches its devices. mlx5_ib can then unload before the callback runs.
Registration error unwind has the same risk because driver registration can attach existing devices before failing. Wait after all drivers have stopped.
--- drivers/infiniband/hw/mlx5/main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/mlx5/main.c +2 -0
@@ -5538,6 +5538,7 @@ static int __init mlx5_ib_init(void) dd_err:mlx5r_rep_cleanup (); rep_err: +rcu_barrier ();mlx5_ib_qp_event_cleanup (); qp_event_err:destroy_workqueue (mlx5_ib_event_wq);
@@ -5551,6 +5552,7 @@ static void __exit mlx5_ib_cleanup(void)auxiliary_driver_unregister (&mlx5r_driver);auxiliary_driver_unregister (&mlx5r_mp_driver);mlx5r_rep_cleanup (); +rcu_barrier ();mlx5_ib_qp_event_cleanup ();destroy_workqueue (mlx5_ib_event_wq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 347/1815 RDMA/ipoib: Drain RCU callbacks during module teardown
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 31b7c700670830a0e8a4cdcd451c88a13cc5dc48 ]
IPoIB reclamation completions can be signaled from inside an RCU callback. Teardown can wake before the callback returns and unload ib_ipoib while its code is still executing.
Client registration failure can also remove already-added devices and queue callbacks. Wait after client and workqueue teardown.
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/ulp/ipoib/ipoib_main.c +2 -0
@@ -2783,6 +2783,7 @@ static int __init ipoib_init_module(void) err_sa:ib_sa_unregister_client (&ipoib_sa_client);destroy_workqueue (ipoib_workqueue); +rcu_barrier (); err_fs:ipoib_unregister_debugfs ();
@@ -2800,6 +2801,7 @@ static void __exit ipoib_cleanup_module(void)ib_sa_unregister_client (&ipoib_sa_client);ipoib_unregister_debugfs ();destroy_workqueue (ipoib_workqueue); +rcu_barrier (); }module_init (ipoib_init_module);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 348/1815 RDMA/rxe: Avoid reprocessing the current packet after the QP enters the error state
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 15ae32c4a3551c4c9da457370bdfdd65d171e512 ]
When do_complete() finds the QP in the error state it returns RESPST_CHK_RESOURCE. Before commit 49dc9c1f0c7e ("RDMA/rxe: Cleanup reset state handling in rxe_resp.c") this was the flush loop:check_resource() had an error-state branch that fetched each remaining recv WQE and completed it with IB_WC_WR_FLUSH_ERR, without touching the current packet. That commit removed the error-state branch from check_resource() (draining is now done at rxe_receiver() entry) but kept the do_complete() error-state return.
As a result, when a QP moves to the error state while a packet is being completed - e.g. an rdma_cm disconnect racing with receive processing - the responder state machine loops back into the request processing chain with the already-completed packet still in hand:check_resource() fetches a fresh recv WQE, execute()/send_data_in() copies the same packet payload again, do_complete() posts another IB_WC_SUCCESS CQE (qp->resp.status is still 0), and control returns to the error-state check. The loop re-executes the same packet once per posted recv WQE (observed: ~1000 duplicate IB_WC_SUCCESS completions of one SEND, one per ~8us, matching the RQ occupancy) until the RQ is exhausted, after which qp->resp.wqe is NULL and send_data_in() dereferences it:
BUG: kernel NULL pointer dereference, address: 0000000000000014 Workqueue: rxe_wq do_work RIP: copy_data+0x29/0x1f0 Call Trace: send_data_in+0x25/0x50 rxe_receiver+0xf36/0x1dd0
The duplicate completions are indistinguishable from real receives to the ULP. During an rds stress test, the message was accepted as new and delivered the same datagram to user space hundreds of times, corrupting the stream; any ULP that relies on RC exactly-once delivery is affected.
A live packet reaching the error-state check in do_complete() has been executed and completed exactly once and must be consumed, not re-processed. Return RESPST_CLEANUP for it (dequeue and free); keep returning RESPST_CHK_RESOURCE for the pkt == NULL case.
--- drivers/infiniband/sw/rxe/rxe_resp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_resp.c +8 -1
@@ -1217,7 +1217,14 @@ static enum resp_states do_complete(struct rxe_qp *qp,spin_lock_irqsave (&qp->state_lock, flags);if (unlikely (qp_state (qp) ==IB_QPS_ERR )) {spin_unlock_irqrestore (&qp->state_lock, flags); -return RESPST_CHK_RESOURCE ; +/* The packet was executed and completed before the QP +* moved to ERROR; it must be consumed exactly once. +* Re-entering the request chain with the stale packet +* would copy it into every remaining recv WQE as a new +* completion. Remaining WQEs are flushed by the drain +* path at rxe_receiver() entry. +*/ +return pkt ?RESPST_CLEANUP :RESPST_CHK_RESOURCE ; }spin_unlock_irqrestore (&qp->state_lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 349/1815 drm/msm/dp: add missing drm_edid_connector_update() before add_modes on cached EDID
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Glathe <[email protected]>
[ Upstream commit b7088d58dccfba87fe8dd2ab7c493ee1d9d09277 ]
After the refactor to struct drm_edid, the fast path in msm_dp_panel_get_modes() that already held a cached EDID called drm_edid_connector_add_modes() directly without first calling drm_edid_connector_update().
The new API requires the update step to associate the EDID with the connector. Add the missing call. This restores correct behaviour for the cached-EDID path.
Patchwork: https://patchwork.freedesktop.org/patch/731125/
--- drivers/gpu/drm/msm/dp/dp_panel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/dp/dp_panel.c +3 -1
@@ -332,8 +332,10 @@ int msm_dp_panel_get_modes(struct msm_dp_panel *msm_dp_panel,return -EINVAL ; } -if (msm_dp_panel->drm_edid) +if (msm_dp_panel->drm_edid) { +drm_edid_connector_update (connector, msm_dp_panel->drm_edid);return drm_edid_connector_add_modes (connector); + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 350/1815 Revert "drm/msm: dsi: fix PLL init in bonded mode"
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 44784327815b2a1ad8bb56b9236770cb538c7c27 ]
Commit 93c97bc8d85d ("drm/msm: dsi: fix PLL init in bonded mode") fixed one of the issues with the DSI bonded mode, but broke non-bonded usecase for DSI as reported by Mohit Dsor. Clock divider is being programmed incorrectly, resultin in the wrong display mode being selected. Revert the offending commit, letting Neil to work on a better fix.
Patchwork: https://patchwork.freedesktop.org/patch/739459/
--- drivers/gpu/drm/msm/dsi/phy/dsi_phy.h | 1 + drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/dsi/phy/dsi_phy.h +1 -0
@@ -111,6 +111,7 @@ struct msm_dsi_phy {struct msm_dsi_dphy_timing timing;const struct msm_dsi_phy_cfg *cfg;void *tuning_cfg; +void *pll_data;enum msm_dsi_phy_usecase usecase;bool regulator_ldo_mode;
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +16 -2
@@ -426,8 +426,11 @@ static void dsi_pll_enable_pll_bias(struct dsi_pll_7nm *pll)u32 data;spin_lock_irqsave (&pll->pll_enable_lock, flags); - pll->pll_enable_cnt++; -WARN_ON (pll->pll_enable_cnt ==INT_MAX ); +if (pll->pll_enable_cnt++) { +spin_unlock_irqrestore (&pll->pll_enable_lock, flags); +WARN_ON (pll->pll_enable_cnt ==INT_MAX ); +return ; + } data =readl (pll->phy->base + REG_DSI_7nm_PHY_CMN_CTRL_0); data |= DSI_7nm_PHY_CMN_CTRL_0_PLL_SHUTDOWNB;
@@ -873,6 +876,7 @@ static int dsi_pll_7nm_init(struct msm_dsi_phy *phy)spin_lock_init (&pll_7nm->pll_enable_lock); pll_7nm->phy = phy; + phy->pll_data = pll_7nm; ret =pll_7nm_register (pll_7nm, phy->provided_clocks->hws);if (ret) {
@@ -961,8 +965,10 @@ static int dsi_7nm_phy_enable(struct msm_dsi_phy *phy,u32 const delay_us =5 ;u32 const timeout_us =1000 ;struct msm_dsi_dphy_timing *timing = &phy->timing; +struct dsi_pll_7nm *pll = phy->pll_data;void __iomem *base = phy->base;bool less_than_1500_mhz; +unsigned long flags;u32 vreg_ctrl_0, vreg_ctrl_1, lane_ctrl0;u32 glbl_pemph_ctrl_0;u32 glbl_str_swi_cal_sel_ctrl, glbl_hstx_str_ctrl_0;
@@ -1084,10 +1090,13 @@ static int dsi_7nm_phy_enable(struct msm_dsi_phy *phy, glbl_rescode_bot_ctrl =0x3c ; } +spin_lock_irqsave (&pll->pll_enable_lock, flags); + pll->pll_enable_cnt =1 ;/* de-assert digital and pll power down */ data = DSI_7nm_PHY_CMN_CTRL_0_DIGTOP_PWRDN_B | DSI_7nm_PHY_CMN_CTRL_0_PLL_SHUTDOWNB;writel (data, base + REG_DSI_7nm_PHY_CMN_CTRL_0); +spin_unlock_irqrestore (&pll->pll_enable_lock, flags);/* Assert PLL core reset */ writel (0x00 , base + REG_DSI_7nm_PHY_CMN_PLL_CNTRL);
@@ -1200,7 +1209,9 @@ static bool dsi_7nm_set_continuous_clock(struct msm_dsi_phy *phy, bool enable)static void dsi_7nm_phy_disable (struct msm_dsi_phy *phy) { +struct dsi_pll_7nm *pll = phy->pll_data;void __iomem *base = phy->base; +unsigned long flags;u32 data;DBG ("" );
@@ -1227,8 +1238,11 @@ static void dsi_7nm_phy_disable(struct msm_dsi_phy *phy)writel (data, base + REG_DSI_7nm_PHY_CMN_CTRL_0);writel (0 , base + REG_DSI_7nm_PHY_CMN_LANE_CTRL0); +spin_lock_irqsave (&pll->pll_enable_lock, flags); + pll->pll_enable_cnt =0 ;/* Turn off all PHY blocks */ writel (0x00 , base + REG_DSI_7nm_PHY_CMN_CTRL_0); +spin_unlock_irqrestore (&pll->pll_enable_lock, flags);/* make sure phy is turned off */ wmb ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 351/1815 crypto: ccp - Fix possible deadlock in SEV init failure path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Atish Patra <[email protected]>
[ Upstream commit b0e7ec0dab242c5e480121ba12400d0513e37ca2 ]
__sev_platform_init_handle_init_ex_path() calls rmp_mark_pages_firmware() with locked=false while the parent function of init_ex_path already acquired the sev_cmd_mutex.
In the case of an RMPUPDATE failure for any page after the first, the cleanup path would invoke reclaim pages which would result in a deadlock in sev_do_cmd.
Pass locked=true to honor the lock status of the parent function.
--- drivers/crypto/ccp/sev-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ccp/sev-dev.c +1 -1
@@ -1562,7 +1562,7 @@ static int __sev_platform_init_handle_init_ex_path(struct sev_device *sev)unsigned long npages; npages =1UL <<get_order (NV_LENGTH ); -if (rmp_mark_pages_firmware (__pa (sev_init_ex_buffer), npages, false)) { +if (rmp_mark_pages_firmware (__pa (sev_init_ex_buffer), npages, true)) {dev_err (sev->dev,"SEV: INIT_EX NV memory page state change failed.\n" );return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 352/1815 crypto: ccp - Fix memory leak in SEV INIT_EX path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Atish Patra <[email protected]>
[ Upstream commit c8e53ada20d352b0f1bdc3e58405a9edab897a2e ]
allocated pages in _init_ext_path are never freed and sev_init_ex_buffer is left pointing at the leaked memory in case of any failures during the function..
Fix by adding an error path that frees the pages and clears sev_init_ex_buffer. Make sure we only free the memory if the failure happens before the conversion. Otherwise, we may end up trying to free up converted pages in case of reclaim failure. rmp_mark_pages_firmware failures should be rare enough to avoid more code complexity to track down which pages were reclaimed/leaked vs which are not.
--- drivers/crypto/ccp/sev-dev.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/crypto/ccp/sev-dev.c +14 -3
@@ -1545,7 +1545,7 @@ static int __sev_platform_init_handle_init_ex_path(struct sev_device *sev)if (sev_init_ex_buffer)return 0 ; - page =alloc_pages (GFP_KERNEL ,get_order (NV_LENGTH )); + page =alloc_pages (GFP_KERNEL | __GFP_ZERO,get_order (NV_LENGTH ));if (!page) {dev_err (sev->dev,"SEV: INIT_EX NV memory allocation failed\n" );return -ENOMEM ;
@@ -1555,7 +1555,7 @@ static int __sev_platform_init_handle_init_ex_path(struct sev_device *sev) rc =sev_read_init_ex_file ();if (rc) -return rc; + goto err_free;/* If SEV-SNP is initialized, transition to firmware page. */ if (sev->snp_initialized) {
@@ -1564,11 +1564,22 @@ static int __sev_platform_init_handle_init_ex_path(struct sev_device *sev) npages =1UL <<get_order (NV_LENGTH );if (rmp_mark_pages_firmware (__pa (sev_init_ex_buffer), npages, true)) {dev_err (sev->dev,"SEV: INIT_EX NV memory page state change failed.\n" ); -return -ENOMEM ; + rc = -ENOMEM ; +/* +* Pages can be in an inconsistent state, don't release them back to the +* system. +*/ + goto err_reset; } }return 0 ; + +err_free: +__free_pages (page,get_order (NV_LENGTH )); +err_reset: + sev_init_ex_buffer =NULL ; +return rc; }static int __sev_platform_init_locked (int *error)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 353/1815 hwrng: ks-sa - Fix runtime PM cleanup on registration failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 1c17b601fafb09c9ec074fd097737d20eafe7d63 ]
ks_sa_rng_probe() enables runtime PM and resumes the device before registering the hwrng. If devm_hwrng_register() fails, probe returns without dropping the runtime PM usage count or disabling runtime PM.
Unwind the runtime PM state on the registration failure path, matching the cleanup done by remove().
--- drivers/char/hw_random/ks-sa-rng.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/char/hw_random/ks-sa-rng.c +8 -1
@@ -242,7 +242,14 @@ static int ks_sa_rng_probe(struct platform_device *pdev)return dev_err_probe (dev, ret,"Failed to enable SA power-domain\n" ); } -return devm_hwrng_register (&pdev->dev, &ks_sa_rng->rng); + ret =devm_hwrng_register (dev, &ks_sa_rng->rng); +if (ret) { +pm_runtime_put_sync (dev); +pm_runtime_disable (dev); +return ret; + } + +return 0 ; }static void ks_sa_rng_remove (struct platform_device *pdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 354/1815 crash_dump: release keyring reference at the correct time
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit ada2e5a44e99113e08ad9b7b71396c6c572204da ]
restore_dm_crypt_keys_to_thread_keyring() gets a reference to the user keyring before restoring the saved dm-crypt keys.
The same keyring reference is then passed to add_key_to_keyring() for each saved key, but add_key_to_keyring() drops that reference on every call. This is only balanced when exactly one key is restored. With multiple keys, the keyring reference is dropped too many times and may trigger a refcount underflow or use-after-free.
When more than five keys are restored, a refcount underflow/use-after-free warning can be triggered.
The early error paths after lookup_user_key() also return without dropping the keyring reference.
Keep ownership of the keyring reference in restore_dm_crypt_keys_to_thread_keyring(), drop it once on all exit paths, and make add_key_to_keyring() only use the reference without consuming it.
--- kernel/crash_dump_dm_crypt.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
kernel/crash_dump_dm_crypt.c +10 -5
@@ -81,7 +81,6 @@ static int add_key_to_keyring(struct dm_crypt_key *dm_key,kexec_dprintk ("Error when adding key" ); } -key_ref_put (keyring_ref);return r; }
@@ -104,6 +103,7 @@ static int restore_dm_crypt_keys_to_thread_keyring(void)struct dm_crypt_key *key;size_t keys_header_size;key_ref_t keyring_ref; +int ret =0 ;u64 addr;/* find the target keyring (which must be writable) */
@@ -118,7 +118,8 @@ static int restore_dm_crypt_keys_to_thread_keyring(void)dm_crypt_keys_read ((char *)&key_count,sizeof (key_count), &addr);if (key_count >KEY_NUM_MAX ) {kexec_dprintk ("Failed to read the number of dm-crypt keys\n" ); -return -1 ; + ret =-1 ; + goto out; }kexec_dprintk ("There are %u keys\n" , key_count);
@@ -126,8 +127,10 @@ static int restore_dm_crypt_keys_to_thread_keyring(void) keys_header_size =get_keys_header_size (key_count); keys_header =kzalloc (keys_header_size,GFP_KERNEL ); -if (!keys_header) -return -ENOMEM ; +if (!keys_header) { + ret = -ENOMEM ; + goto out; + }dm_crypt_keys_read ((char *)keys_header, keys_header_size, &addr);
@@ -137,7 +140,9 @@ static int restore_dm_crypt_keys_to_thread_keyring(void)add_key_to_keyring (key, keyring_ref); } -return 0 ; +out: +key_ref_put (keyring_ref); +return ret; }static int read_key_from_user_keyring (struct dm_crypt_key *dm_key)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 355/1815 xfrm6: fix out-of-bounds write in xfrm6_input_addr() when secpath is full
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 5d9e3bf34fec9a5d237e4b7cef4a707bc2e091bc ]
The depth check in xfrm6_input_addr() is off by one:
if (1 + sp->len == XFRM_MAX_DEPTH)
goto drop;
...
sp->xvec[sp->len++] = x;xfrm_input() can leave sp->len == XFRM_MAX_DEPTH, and the transport-mode receive path re-enters IPv6 input via xfrm_trans_reinject() with that secpath preserved. If the inner packet carries a destination-options HAO option or a type-2 routing header, xfrm6_input_addr() is called with sp->len == XFRM_MAX_DEPTH; the check (1 + 6 == 6) is false, so sp->xvec[sp->len++] writes one slot past the 6-element xvec[]. The write stays within the sec_path allocation (invisible to KASAN); UBSAN_BOUNDS flags it and panics under panic_on_warn.
Use "sp->len >= XFRM_MAX_DEPTH", matching xfrm_input(). This also restores one chain level the old check rejected at sp->len == 5.
UBSAN: array-index-out-of-bounds in net/ipv6/xfrm6_input.c:309:10 index 6 is out of range for type 'xfrm_state *[6]'
--- net/ipv6/xfrm6_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/xfrm6_input.c +1 -1
@@ -247,7 +247,7 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr, goto drop; } -if (1 + sp->len ==XFRM_MAX_DEPTH ) { +if (sp->len >=XFRM_MAX_DEPTH ) {XFRM_INC_STATS (net,LINUX_MIB_XFRMINBUFFERERROR ); goto drop; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 356/1815 esp: do not unref managed frag pages in esp_ssg_unref()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maher Azzouzi <[email protected]>
[ Upstream commit 21697720ff43b8dfa25b8e8d9ca7f56f4597fc80 ]
esp_ssg_unref() releases the page references held on the source scatterlist after the AEAD operation completes. It calls skb_page_unref() on every frag page for an out-of-place transform (req->src != req->dst), and in the error path of esp_output_tail() (already_unref == true) on the request's own scatterlist.
This is wrong when the skb carries managed frags (SKBFL_MANAGED_FRAG_REFS). Managed frags are owned by a zerocopy ubuf and the skb does not hold a per-frag page reference; io_uring SEND_ZC with a registered buffer attaches the bvec pages this way via io_sg_from_iter(). The rest of the stack honours this invariant:skb_release_data() skips the per-frag unref when SKBFL_MANAGED_FRAG_REFS is set, and skb_zcopy_managed() is the guard used at the other unref sites.
esp_ssg_unref() is missing that guard, so for a managed-frag skb it drops a page reference the skb never acquired. This can underflow the page reference count and free a page that is still in use.
Guard the function with skb_zcopy_managed() so both unref paths are skipped for managed-frag skbs, matching skb_release_data().
--- net/ipv4/esp4.c | 7 +++++++ net/ipv6/esp6.c | 7 +++++++ 2 files changed, 14 insertions(+)
net/ipv4/esp4.c +7 -0
@@ -104,6 +104,13 @@ static void esp_ssg_unref(struct xfrm_state *x, void *tmp, struct sk_buff *skb,struct aead_request *req;struct scatterlist *sg; +/* Managed frags are owned by the zerocopy ubuf; the skb holds no +* per-frag page reference, so we must not drop one here. Mirrors +* the SKBFL_MANAGED_FRAG_REFS handling in skb_release_data(). +*/ +if (skb_zcopy_managed (skb)) +return ; +if (x->props.flags &XFRM_STATE_ESN ) extralen +=sizeof (struct esp_output_extra );
net/ipv6/esp6.c +7 -0
@@ -121,6 +121,13 @@ static void esp_ssg_unref(struct xfrm_state *x, void *tmp, struct sk_buff *skb,struct aead_request *req;struct scatterlist *sg; +/* Managed frags are owned by the zerocopy ubuf; the skb holds no +* per-frag page reference, so we must not drop one here. Mirrors +* the SKBFL_MANAGED_FRAG_REFS handling in skb_release_data(). +*/ +if (skb_zcopy_managed (skb)) +return ; +if (x->props.flags &XFRM_STATE_ESN ) extralen +=sizeof (struct esp_output_extra );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 357/1815 ALSA: hpi: Check transport errors during HPI6000 adapter initialization
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Evgenii Burenchev <[email protected]>
[ Upstream commit cc15c329663e3ef1aeed0b68e49a5d5ce4ae0d5c ]
create_adapter_obj() retrieves adapter information by calling hpi6000_message_response_sequence(). This function reports transport-level errors through its return value and DSP-reported errors via hr0.error.
The current code only checks hr0.error, causing transport-level errors to be ignored. As a result, adapter initialization may continue with an invalid response.
Check the return value of hpi6000_message_response_sequence() before examining hr0.error.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- sound/pci/asihpi/hpi6000.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/pci/asihpi/hpi6000.c +5 -0
@@ -537,6 +537,11 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao, hr1.size =sizeof (hr1); error =hpi6000_message_response_sequence (pao,0 , &hm, &hr0); +if (error) { +HPI_DEBUG_LOG (ERROR ,"message transport error %d\n" , + error); +return error; + }if (hr0.error) {HPI_DEBUG_LOG (DEBUG ,"message error %d\n" , hr0.error);return hr0.error;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 358/1815 pmdomain: bcm: bcm2835: handle genpd provider registration errors
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit a1d9d3b958d69a13783613304f524f489fecdd1f ]
bcm2835_power_probe() initializes all power domains and then registers the onecell genpd provider, but ignores of_genpd_add_provider_onecell() failures. Probe can therefore return success even though no provider was published.
Check the provider registration return value and jump to the existing cleanup path on failure.
--- drivers/pmdomain/bcm/bcm2835-power.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/pmdomain/bcm/bcm2835-power.c +6 -1
@@ -677,7 +677,12 @@ static int bcm2835_power_probe(struct platform_device *pdev)if (ret) goto fail; -of_genpd_add_provider_onecell (dev->parent->of_node, &power->pd_xlate); + ret =of_genpd_add_provider_onecell (dev->parent->of_node, + &power->pd_xlate); +if (ret) { +dev_err_probe (dev, ret,"failed to add genpd provider\n" ); + goto fail; + }dev_info (dev,"Broadcom BCM2835 power domains driver" );return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 359/1815 misc: rtsx_usb: avoid USB I/O in runtime autosuspend
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Rhodes <[email protected]>
[ Upstream commit 483c948324a3823871c004560a92545759d3253c ]
The runtime autosuspend callback currently queries card status and clears OCP by issuing USB register accesses. This can run from the USB runtime-PM path itself, which is the wrong place to start more device I/O.
Keep a cached copy of the card-status bits from normal status reads instead. During runtime autosuspend, use that cached value only to preserve the existing Memory Stick autosuspend deferral.
Do not treat raw SD_CD as an autosuspend blocker, because tray-based SD readers can assert SD_CD with an empty tray. A real SD card is protected by the SD/MMC child runtime-PM usage once powered.
Also stop clearing OCP from the runtime autosuspend callback, so the callback does not issue USB commands.
--- drivers/misc/cardreader/rtsx_usb.c | 26 ++++++++++++++++++++------ include/linux/rtsx_usb.h | 3 +++ 2 files changed, 23 insertions(+), 6 deletions(-)
drivers/misc/cardreader/rtsx_usb.c +20 -6
@@ -312,6 +312,9 @@ int rtsx_usb_get_card_status(struct rtsx_ucr *ucr, u16 *status)if (ret <0 )return ret; + ucr->card_status_cache = *status; + ucr->card_status_valid = true; +return 0 ; }EXPORT_SYMBOL_GPL (rtsx_usb_get_card_status);
@@ -623,6 +626,7 @@ static int rtsx_usb_probe(struct usb_interface *intf, {struct usb_device *usb_dev =interface_to_usbdev (intf);struct rtsx_ucr *ucr; +u16 status;int ret; dev_dbg(&intf->dev,
@@ -659,6 +663,9 @@ static int rtsx_usb_probe(struct usb_interface *intf,if (ret) goto out_init_fail; +/* Prime cached status for runtime autosuspend decisions. */ +rtsx_usb_get_card_status (ucr, &status); +/* initialize USB SG transfer timer */ timer_setup (&ucr->sg_timer, rtsx_usb_sg_timed_out,0 );
@@ -713,22 +720,29 @@ static int rtsx_usb_suspend(struct usb_interface *intf, pm_message_t message)struct rtsx_ucr *ucr = (struct rtsx_ucr *)usb_get_intfdata (intf);u16 val =0 ; +bool valid = false;dev_dbg (&intf->dev,"%s called with pm message 0x%04x\n" , __func__, message.event);if (PMSG_IS_AUTO (message)) {if (mutex_trylock (&ucr->dev_mutex)) { -rtsx_usb_get_card_status (ucr, &val); + valid = ucr->card_status_valid; +if (valid) + val = ucr->card_status_cache;mutex_unlock (&ucr->dev_mutex); -/* Defer the autosuspend if card exists */ -if (val & (SD_CD |MS_CD )) { +/* +* Do not issue USB commands from runtime autosuspend. +* Raw SD_CD is not authoritative on tray-based readers, +* while a real SD card is protected by the SD/MMC child +* runtime-PM reference once the card is powered. Keep +* the historical Memory Stick autosuspend deferral when +* the cached status says MS media is present. +*/ +if (valid && (val &MS_CD )) {device_for_each_child (&intf->dev,NULL , rtsx_usb_resume_child);return -EAGAIN ; - }else { -/* if the card does not exists, clear OCP status */ -rtsx_usb_write_register (ucr,OCPCTL ,MS_OCP_CLEAR ,MS_OCP_CLEAR ); } }else {/* There is an ongoing operation*/
include/linux/rtsx_usb.h +3 -0
@@ -61,6 +61,9 @@ struct rtsx_ucr {struct timer_list sg_timer;struct mutex dev_mutex; + +u16 card_status_cache; +bool card_status_valid; };/* buffer size */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 360/1815 RDMA/rvt: Return NULL after port allocation failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 2982eaf3b9d2d953318c74cd6f1b7576ea6d7b1f ]
rvt_alloc_device() deallocates the IB device when its port array cannot be allocated but then returns the pointer to the released allocation. Callers treat any non-NULL value as valid and dereference it, resulting in a use-after-free.
Return NULL immediately after deallocation so callers can propagate the allocation failure.
--- drivers/infiniband/sw/rdmavt/vt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rdmavt/vt.c +3 -1
@@ -55,8 +55,10 @@ struct rvt_dev_info *rvt_alloc_device(size_t size, int nports)return rdi; rdi->ports =kzalloc_objs (*rdi->ports, nports); -if (!rdi->ports) +if (!rdi->ports) {ib_dealloc_device (&rdi->ibdev); +return NULL ; + }return rdi; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 361/1815 RDMA/hfi1: Preserve unit 0 on allocation failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 2e3809ad8911f5d5581b3f046bd628417bface76 ]
hfi1_free_devdata() assumes that the device was inserted into the unit table and unconditionally erases dd->unit. If xa_alloc_irq() fails, the zero-initialized unit remains zero, so full cleanup can remove an unrelated device from index 0.
Release only the rdmavt allocation and return immediately while the unit table has not acquired the device.
--- drivers/infiniband/hw/hfi1/init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/init.c +3 -2
@@ -1225,8 +1225,9 @@ static struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, GFP_KERNEL);if (ret <0 ) {dev_err (&pdev->dev, -"Could not allocate unit ID: error %d\n" , -ret); - goto bail; +"Could not allocate unit ID: error %pe\n" ,ERR_PTR (ret)); +rvt_dealloc_device (&dd->verbs_dev.rdi); +return ERR_PTR (ret); }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 362/1815 RDMA/hfi1: Free RX data on late probe failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 8e17e101e04a3dc062e2719da57ff78c1c060632 ]
hfi1_init_dd() allocates the shared AIP/VNIC RX support before returning. If hfi1_init() or hfi1_register_ib_device() later fails, init_one() tears down the device data without calling hfi1_free_rx(). This leaks netdev_rx and its dummy netdev.
Free the RX support after IB unregistration and before postinit_cleanup(), as done on normal device removal.
--- drivers/infiniband/hw/hfi1/init.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/hfi1/init.c +1 -0
@@ -1686,6 +1686,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)hfi1_device_remove (dd);if (!ret)hfi1_unregister_ib_device (dd); +hfi1_free_rx (dd);postinit_cleanup (dd);if (initfail) ret = initfail;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 363/1815 RDMA/hfi1: Stop flushing the global IB workqueue
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit d43b1c17f9e1b9d34a0d742f569c00d84147ebc0 ]
hfi1 does not queue work on ib_wq. QSFP and link work run on the per-port link_wq, while the remaining device work uses hfi1_wq or dedicated queues. The probe failure path destroys both per-port workqueues, and normal device removal flushes them in shutdown_device() before destroying them.
Remove the flushes of the core-owned global workqueue. Waiting for unrelated core or other device work is not part of hfi1 teardown.
--- drivers/infiniband/hw/hfi1/init.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/infiniband/hw/hfi1/init.c +0 -4
@@ -1669,7 +1669,6 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)if (initfail || ret) {msix_clean_up_interrupts (dd);stop_timers (dd); -flush_workqueue (ib_wq);for (pidx =0 ; pidx < dd->num_pports; ++pidx) {hfi1_quiet_serdes (dd->pport + pidx); ppd = dd->pport + pidx;
@@ -1743,9 +1742,6 @@ static void remove_one(struct pci_dev *pdev)stop_timers (dd); -/* wait until all of our (qsfp) queue_work() calls complete */ -flush_workqueue (ib_wq); -postinit_cleanup (dd); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 364/1815 RDMA/hfi1: Initialize debugfs after probe completes
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit bb18740b302f6f222ce3d5a7e5c45a52a90df805 ]
Commit ed6f653fe430 ("staging/rdma/hfi1: Fix debugfs access race") moved debugfs creation after device initialization and IB registration so users cannot access the files before the driver is ready. However, init_one() still creates them before character device creation and SDMA startup finish.
Move hfi1_dbg_ibdev_init() to the end of the successful probe path, matching hfi1_dbg_ibdev_exit() as the first action in remove_one().
--- drivers/infiniband/hw/hfi1/init.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/hfi1/init.c +2 -4
@@ -1656,11 +1656,8 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)* we still create devices, so diags, etc. can be used * to determine cause of problem. */ -if (!initfail && !ret) { +if (!initfail && !ret) dd->flags |=HFI1_INITTED ; -/* create debufs files after init and ib register */ -hfi1_dbg_ibdev_init (&dd->verbs_dev); - } j =hfi1_device_create (dd);if (j)
@@ -1693,6 +1690,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent) }sdma_start (dd); +hfi1_dbg_ibdev_init (&dd->verbs_dev);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 365/1815 ASoC: apple: mca: increase SERDES reset delay
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Calligeros <[email protected]>
[ Upstream commit cccd721e5aab03e92234faee72b363c9ba60611c ]
The SERDES clusters in this peripheral take a long time to warm up. We tried polling the reset bit until cleared, however this is not a reliable signal of readiness to be configured. Only waiting ~25 us to give the cluster a chance to settle makes it work reliably.
Increase the 2 us delay to 25 us and hope we never have to do this again.
--- sound/soc/apple/mca.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/apple/mca.c +3 -3
@@ -210,10 +210,10 @@ static void mca_fe_early_trigger(struct snd_pcm_substream *substream, int cmd,SERDES_STATUS_EN |SERDES_STATUS_RST , SERDES_STATUS_RST);/* -* Experiments suggest that it takes at most ~1 us -* for the bit to clear, so wait 2 us for good measure. +* The SERDES cluster needs a bit of time to reset itself +* and settle before we start poking it. This is... slow... */ -udelay (2 ); +udelay (25 );WARN_ON (readl_relaxed (cl->base + serdes_unit +REG_SERDES_STATUS ) &SERDES_STATUS_RST ); mca_modify(cl, serdes_conf, SERDES_CONF_SYNC_SEL,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 366/1815 isofs: fix out-of-bounds page array access on empty zisofs block
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 68d4d3e78150c7ed7d1195af63ad1e6ace30c661 ]
zisofs_uncompress_block()'s empty-block fast path returns pcount << PAGE_SHIFT, ignoring the incoming poffset, unlike the decompression path which returns bytes produced relative to poffset. zisofs_fill_pages() uses that return to advance its page cursor, so when the zisofs block size is below PAGE_SIZE and a sub-page block leaves poffset partway into a page, a following empty block over-counts and advances pages[] one element past its end, after which
"if (poffset && *pages)" reads pages[1] out of bounds. rock.c only rejects a block-size shift > 17, so a crafted "ZF" Rock Ridge record can set it below PAGE_SHIFT; the bug is reached by an ordinary read() of a compressed file on such a mounted ISO9660 image.
Return the byte count relative to poffset and zero only [poffset, PAGE_SIZE) of the first page, matching the decompression path. The page-aligned case (poffset == 0) is unaffected.
BUG: KASAN: slab-out-of-bounds in zisofs_read_folio (fs/isofs/compress.c:290) Read of size 8 at addr ffff88800f5eac48 by task exploit/142 zisofs_read_folio (fs/isofs/compress.c:290) read_pages (mm/readahead.c:184) ... filemap_read (mm/filemap.c:2814) vfs_read (fs/read_write.c:574) __x64_sys_pread64 (fs/read_write.c:769) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) The buggy address is located 0 bytes to the right of the allocated 8-byte region in the kmalloc-8 cache
--- fs/isofs/compress.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/isofs/compress.c +4 -2
@@ -65,12 +65,14 @@ static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start,/* Empty block? */ if (block_size ==0 ) {for ( i =0 ; i < pcount ; i++ ) { +unsigned int off = i ?0 : poffset; +if (!pages[i])continue ; -memzero_page (pages[i],0 ,PAGE_SIZE ); +memzero_page (pages[i], off,PAGE_SIZE - off);SetPageUptodate (pages[i]); } -return ((loff_t )pcount) <<PAGE_SHIFT ; +return (((loff_t )pcount) <<PAGE_SHIFT ) - poffset; }/* Because zlib is not thread-safe, do all the I/O at the top. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 367/1815 iommufd/selftest: Avoid selftest dirty bitmap size wrap
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit 4132ba2ae2cf14c289e3fabc1c95ac244d643356 ]
IOMMU_TEST_OP_DIRTY sizes its temporary dirty bitmap from length / page_size. Very large selftest ranges can make the DIV_ROUND_UP() additions wrap before allocation, producing a zero-length allocation while the later test_bit() loop still walks the original number of bits.
The selftest helper does not need to support unbounded dirty bitmap sizes. Reject requests that would allocate more than SZ_16M for the temporary buffer.
--- drivers/iommu/iommufd/selftest.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iommu/iommufd/selftest.c +4 -1
@@ -12,6 +12,7 @@#include <linux/iommu.h> #include <linux/platform_device.h> #include <linux/slab.h> +#include <linux/sizes.h> #include <linux/xarray.h> #include <uapi/linux/iommufd.h> #include <linux/generic_pt/iommu.h>
@@ -1705,6 +1706,9 @@ static int iommufd_test_dirty(struct iommufd_ucmd *ucmd, unsigned int mockpt_id,if (!page_size || !length || iova % page_size || length % page_size || !uptr)return -EINVAL ; + max = length / page_size; +if (max >SZ_16M *BITS_PER_BYTE ) +return -EOVERFLOW ; hwpt =get_md_pagetable (ucmd, mockpt_id, &mock);if (IS_ERR (hwpt))
@@ -1715,7 +1719,6 @@ static int iommufd_test_dirty(struct iommufd_ucmd *ucmd, unsigned int mockpt_id, goto out_put; } - max = length / page_size; tmp =kvzalloc (DIV_ROUND_UP (max,BITS_PER_LONG ) *sizeof (unsigned long ),GFP_KERNEL_ACCOUNT );if (!tmp) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 368/1815 iommufd/selftest: Fix dmabuf leak in iommufd_test_dmabuf_get()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: yeeli <[email protected]>
[ Upstream commit dba4254e216d7482d91d93e45faa3ccbefe79337 ]
When dma_buf_export() succeeds but dma_buf_fd() fails (e.g. -EMFILE from fd exhaustion), the dmabuf is leaked with no dma_buf_put() called.
Reproducer: exhaust fd table near RLIMIT_NOFILE, then repeatedly call IOMMU_TEST_OP_DMABUF_GET — htop shows unbounded memory growth.
Fix by calling dma_buf_put(dmabuf) on error and returning directly.
--- drivers/iommu/iommufd/selftest.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/iommu/iommufd/selftest.c +6 -1
@@ -2055,7 +2055,12 @@ static int iommufd_test_dmabuf_get(struct iommufd_ucmd *ucmd, goto err_free; } -return dma_buf_fd (dmabuf, open_flags); + rc =dma_buf_fd (dmabuf, open_flags); +if (rc <0 ) { +dma_buf_put (dmabuf); +return rc; + } +return 0 ; err_free:kfree (priv->memory);
Signature · 1 line
2.53.0
Re: [PATCH 7.2 0368/1815] iommufd/selftest: Fix dmabuf leak in iommufd_test_dmabuf_get()
Hi Greg,
Success path return rc was changed to return 0.
Please refer,
https://lore.kernel.org/linux-iommu/[email protected]/
Sasha Levin
maintainerRe: [PATCH 7.2 0368/1815] iommufd/selftest: Fix dmabuf leak in iommufd_test_dmabuf_get()
Quoted 1 line
Success path return rc was changed to return 0.
Dropped from the 7.2 queue. Will requeue together with the upstream fix ("iommufd/selftest: Return dmabuf fd from IOMMU_TEST_OP_DMABUF_GET again") once that lands in Linus's mainline tree.
Thanks for the report.
Signature · 2 lines
Thanks, Sasha
Greg Kroah-Hartman
maintainerPATCH 369/1815 rust: drm: gpuvm: require Send + Sync for the drivers associated data
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sami Tolvanen <[email protected]>
[ Upstream commit b59ec72fec247b90dc26f17c5b1ee9f1e0fe334c ]
DriverGpuVm permitted !Send/!Sync associated data on an abstraction whose handles are shared and dropped across threads: obtain() runs from many threads and the VA API performs deferred cross-thread drops. That is unsound.
Require Send + Sync on the trait and its associated data so the GpuVm and UniqueRefGpuVm handle impls need no per-impl bounds.
--- rust/kernel/drm/gpuvm/mod.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
rust/kernel/drm/gpuvm/mod.rs +15 -11
@@ -72,10 +72,12 @@ pub struct GpuVm<T: DriverGpuVm> { data: UnsafeCell<T>, } -// SAFETY: The GPUVM api does not assume that it is tied to a specific thread. The destructor will -// drop the `data` field, which is okay because it is guaranteed `Send` by the `DriverGpuVm` trait. +// SAFETY: It is safe to send a `GpuVm<T>` to another thread: all data reachable through it +// (`T`, `T::VmBoData`, and the GEM `T::Object`) is `Send` by the `DriverGpuVm` bounds. unsafe impl <T :DriverGpuVm >Send for GpuVm <T > {} -// SAFETY: The GPUVM api is designed to allow &self methods to be called in parallel. +// SAFETY: It is safe to share a `&GpuVm<T>` between threads: `&self` methods only alias data +// that is `Sync` by the `DriverGpuVm` bounds, and any thread may drop that data, or upgrade the +// reference and ultimately drop `T`, which the same bounds make `Send`. unsafe impl <T :DriverGpuVm >Sync for GpuVm <T > {}// SAFETY: By type invariants, the allocation is managed by the refcount in `self.vm`.
@@ -250,18 +252,22 @@ impl<T: DriverGpuVm> GpuVm<T> { }/// The manager for a GPUVM. -pub trait DriverGpuVm :Sized +Send { +pub trait DriverGpuVm :Sized +Send +Sync {/// Parent `Driver` for this object. type Driver : drm::Driver ;/// The kind of GEM object stored in this GPUVM. -type Object : drm::driver::AllocImpl <Driver =Self ::Driver >; +type Object : drm::driver::AllocImpl <Driver =Self ::Driver > +Send +Sync ;/// Data stored with each [`struct drm_gpuva`](struct@GpuVa). -type VaData ; +/// +/// Only `Send` is required: the data has a single owner at all times, moving +/// between threads by value (handed back as a [`GpuVaRemoved`]) but never +/// accessed by two threads concurrently. +type VaData :Send ;/// Data stored with each [`struct drm_gpuvm_bo`](struct@GpuVmBo). -type VmBoData ; +type VmBoData :Send +Sync ;/// The private data passed to callbacks. type SmContext <'ctx>;
@@ -296,12 +302,10 @@ pub trait DriverGpuVm: Sized + Send {/// # Invariants /// /// Each `GpuVm` instance has at most one `UniqueRefGpuVm` reference. +// `Send`/`Sync` derive from `ARef<GpuVm<T>>`; the trait bounds make them correct for the unique +// handle's `&mut T` access. pub struct UniqueRefGpuVm <T :DriverGpuVm >(ARef <GpuVm <T >>); -// SAFETY: The GPUVM api is designed to allow &self methods to be called in parallel, and -// concurrent access to `data` is safe due to the `T: Sync` requirement. -unsafe impl <T :DriverGpuVm +Sync >Sync for UniqueRefGpuVm <T > {} -impl <T :DriverGpuVm >UniqueRefGpuVm <T > {/// Access the data owned by this `UniqueRefGpuVm` immutably. #[inline]
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 370/1815 media: v4l2-async: Unregister sub-device if asc_list is empty
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
[ Upstream commit 4e72f13d58c4245c177a9d5f54579345554f354d ]
When my em28xx USB device that uses the i2c tvp5150 driver is disconnected, it crashes.
The cause is that the tvp5150 i2c module uses v4l2_async, but the em28xx driver does not since it predates v4l2_async.
In that corner case sd->asc_list is empty, so v4l2_async_unregister_subdev() never calls v4l2_device_unregister_subdev().
Modify the code so that, if sd->asc_list is empty, v4l2_device_unregister_subdev() is still called.
--- drivers/media/v4l2-core/v4l2-async.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/media/v4l2-core/v4l2-async.c +12 -3
@@ -897,9 +897,18 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) sd->subdev_notifier =NULL ;if (sd->asc_list.next) { -list_for_each_entry_safe (asc, asc_tmp, &sd->asc_list, - asc_subdev_entry) { -v4l2_async_unbind_subdev_one (asc->notifier, asc); +if (list_empty (&sd->asc_list)) { +/* +* If the sub-device was registered through other means +* than v4l2-async, there are no async connections but +* the sub-device may still well be registered. +* Unregister it now. +*/ +v4l2_device_unregister_subdev (sd); + }else { +list_for_each_entry_safe (asc, asc_tmp, &sd->asc_list, + asc_subdev_entry) +v4l2_async_unbind_subdev_one (asc->notifier, asc); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 371/1815 tools/sched_ext: scx_flatcg: Fix uninitialized stats on allocation failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liang Luo <[email protected]>
[ Upstream commit e07f6bb73efb484043e7fc2ec6d7d6220d1977f7 ]
In fcg_read_stats(), the memset() that zeroes the output @stats array sits after the calloc() failure check. When calloc() fails, the function returns without writing @stats.
The caller in main() declares acc_stats uninitialized, passes it as the @stats argument, and then reads it unconditionally:
__u64 acc_stats[FCG_NR_STATS];
fcg_read_stats(skel, acc_stats);
stats[i] = acc_stats[i] - last_stats[i]; // reads garbageBecause fcg_read_stats() returns void, the caller cannot detect the failure. Reading the uninitialized array is undefined behavior, and the garbage is further copied into last_stats via memcpy(), corrupting the baseline used by the next interval.
This regression was introduced by commit cabd76bbc036 ("tools/sched_ext:scx_flatcg: fix potential stack overflow from VLA in fcg_read_stats"), which replaced the VLA with calloc() and inserted the failure check before the existing memset().
Move the memset() above the calloc() failure check so @stats is always zeroed regardless of allocation outcome.
--- tools/sched_ext/scx_flatcg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/sched_ext/scx_flatcg.c +2 -2
@@ -105,12 +105,12 @@ static void fcg_read_stats(struct scx_flatcg *skel, __u64 *stats)__u64 *cnts;__u32 idx; +memset (stats,0 ,sizeof (stats[0 ]) *FCG_NR_STATS ); + cnts =calloc (skel->rodata->nr_cpus,sizeof (__u64));if (!cnts)return ; -memset (stats,0 ,sizeof (stats[0 ]) *FCG_NR_STATS ); -for (idx =0 ; idx <FCG_NR_STATS ; idx++) {int ret, cpu;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 372/1815 fs/resctrl: Prevent use-after-free in rdtgroup_kn_put()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Reinette Chatre <[email protected]>
[ Upstream commit f5bcf539484d2d604c2f2330e09487ea090b21c7 ]
A struct rdtgroup is reference counted via rdtgroup::waitcount. Callers that need the structure to remain valid across a sleep (while waiting on acquiring rdtgroup_mutex) take a reference with rdtgroup_kn_get() and release it with rdtgroup_kn_put().
The release path is intended to serve as the fallback freer: if the count drops to zero and the group has already been marked RDT_DELETED, rdtgroup_kn_put() frees the structure.
The bulk teardown paths free_all_child_rdtgrp() and rmdir_all_sub() resulting from a resctrl directory remove or resctrl fs unmount act as the primary
freer: they hold rdtgroup_mutex and free each rdtgroup whose waitcount is zero, otherwise they set RDT_DELETED and leave the freeing to the last waiter.
These two freers race. rdtgroup_kn_put() commits waitcount == 0 with atomic_dec_and_test() outside rdtgroup_mutex, then reads rdtgroup::flags. Between those two operations a concurrent caller of free_all_child_rdtgrp() or rmdir_all_sub() (which holds the mutex) can observe waitcount == 0 via atomic_read(), call rdtgroup_remove(), and kfree() the structure.
The subsequent read of rdtgroup::flags in rdtgroup_kn_put() is then a use-after-free, and the structure may even be freed twice if the freed memory happens to satisfy the RDT_DELETED flag check.
Replace the bare atomic_dec_and_test() with atomic_dec_and_mutex_lock() so that the decrement-to-zero takes rdtgroup_mutex before the count becomes globally visible. The inspection of rdtgroup::flags then runs under the same mutex held by the bulk freers, making the two paths mutually exclusive.
The common case where the count does not reach zero remains lock-free. Defer kernfs_unbreak_active_protection() until after the mutex is dropped since kernfs active protections functionally wrap rdtgroup_mutex. Remove resource group, which in turn drops its kernfs reference, after kernfs protection is restored.
[ bp: Split the commit messsages into smaller, easier-parseable paragraphs. ]
--- fs/resctrl/rdtgroup.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
fs/resctrl/rdtgroup.c +14 -5
@@ -2608,15 +2608,24 @@ static void rdtgroup_kn_get(struct rdtgroup *rdtgrp, struct kernfs_node *kn)static void rdtgroup_kn_put (struct rdtgroup *rdtgrp,struct kernfs_node *kn) { -if (atomic_dec_and_test (&rdtgrp->waitcount) && - (rdtgrp->flags &RDT_DELETED )) { +bool needs_free; + +if (!atomic_dec_and_mutex_lock (&rdtgrp->waitcount, &rdtgroup_mutex)) { +kernfs_unbreak_active_protection (kn); +return ; + } + + needs_free = rdtgrp->flags &RDT_DELETED ; + +mutex_unlock (&rdtgroup_mutex); + +kernfs_unbreak_active_protection (kn); + +if (needs_free) {if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP || rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKED )rdtgroup_pseudo_lock_remove (rdtgrp); -kernfs_unbreak_active_protection (kn);rdtgroup_remove (rdtgrp); - }else { -kernfs_unbreak_active_protection (kn); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 373/1815 perf record: Return the written size from process_comp_header()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Ilvokhin <[email protected]>
[ Upstream commit 757155c142f2bc9793e888ab101a5eea2d53f8f8 ]
process_comp_header() is called from zstd_compress_stream_to_records() twice per record: once with data_size == 0 to write the record header, and once with the payload size to finalize it. It returns the increment it was passed, and the loop separately decides whether a record still fits by comparing the remaining 'dst_size' against the header size.
With the fit check split from the code that writes the record, process_comp_header() cannot reject a record on its own, so any bytes it writes into 'dst' have to be bounds-checked by the caller instead of where they are produced.
Pass the space left in 'dst' to process_comp_header(), let it return the number of bytes written or -1 when the header does not fit, and account the compressed payload in the loop.
No functional change intended.
Stable-dep-of: ad40a000ea59 ("perf record: Fix multiple PERF_RECORD_COMPRESSED2 records per push")
--- tools/perf/builtin-record.c | 17 +++++++++++++---- tools/perf/util/compress.h | 6 ++++-- tools/perf/util/zstd.c | 25 ++++++++++++++----------- 3 files changed, 31 insertions(+), 17 deletions(-)
tools/perf/builtin-record.c +13 -4
@@ -1592,16 +1592,25 @@ static void record__adjust_affinity(struct record *rec, struct mmap *map) } } -static size_t process_comp_header (void *record,size_t increment) +/* +* Called once with data_size == 0 to start a record, then once with +* data_size == compressed payload size to finalize. +* Returns the bytes written, or -1 if it won't fit. +*/ +static ssize_t process_comp_header (void *record,size_t dst_size, +size_t data_size) {struct perf_record_compressed2 *event = record;size_t size =sizeof (*event); -if (increment) { - event->header.size += increment; -return increment; +if (data_size) { + event->header.size += data_size; +return 0 ; } +if (size > dst_size) +return -1 ; + event->header.type =PERF_RECORD_COMPRESSED2 ; event->header.size = size;
tools/perf/util/compress.h +4 -2
@@ -54,7 +54,8 @@ int zstd_fini(struct zstd_data *data);ssize_t zstd_compress_stream_to_records (struct zstd_data *data,void *dst,size_t dst_size,void *src,size_t src_size,size_t max_record_size, -size_t process_header (void *record,size_t increment)); +ssize_t process_header (void *record,size_t dst_size, +size_t data_size));size_t zstd_decompress_stream (struct zstd_data *data,void *src,size_t src_size,void *dst,size_t dst_size);
@@ -75,7 +76,8 @@ ssize_t zstd_compress_stream_to_records(struct zstd_data *data __maybe_unused, void *dst __maybe_unused, size_t dst_size __maybe_unused, void *src __maybe_unused, size_t src_size __maybe_unused, size_t max_record_size __maybe_unused, - size_t process_header(void *record, size_t increment) __maybe_unused) + ssize_t process_header(void *record, size_t dst_size, + size_t data_size) __maybe_unused) { return 0; }
tools/perf/util/zstd.c +14 -11
@@ -31,9 +31,11 @@ int zstd_fini(struct zstd_data *data)ssize_t zstd_compress_stream_to_records (struct zstd_data *data,void *dst,size_t dst_size,void *src,size_t src_size,size_t max_record_size, -size_t process_header (void *record,size_t increment)) +ssize_t process_header (void *record,size_t dst_size, +size_t data_size)) { -size_t ret, size, compressed =0 ; +size_t ret, compressed =0 ; +ssize_t size;ZSTD_inBuffer input = { src, src_size,0 };ZSTD_outBuffer output;void *record;
@@ -55,12 +57,9 @@ ssize_t zstd_compress_stream_to_records(struct zstd_data *data, void *dst, size_while (input.pos < input.size) { record = dst; -/* process_header writes the event header into record */ -if (dst_size <sizeof (struct perf_event_header )) - goto reset; - size =process_header (record,0 ); + size =process_header (record, dst_size,0 );/* Output buffer full — cannot fit even the record header */ -if (size > dst_size) +if (size <0 ) goto reset; compressed += size; dst += size;
@@ -74,17 +73,21 @@ ssize_t zstd_compress_stream_to_records(struct zstd_data *data, void *dst, size_ (long)src_size, ZSTD_getErrorName(ret)); goto reset; } - size = output.pos; + compressed += output.pos; + dst += output.pos; + dst_size -= output.pos;/* * No progress: ZSTD couldn't emit any bytes into the * remaining output buffer. Calling process_header -* with size=0 would re-trigger header initialization, +* with output.pos=0 would re-trigger header initialization, * double-subtracting the header size from dst_size and * underflowing the unsigned counter. */ -if (size ==0 ) +if (output.pos ==0 ) + goto reset; + size =process_header (record, dst_size, output.pos); +if (size <0 ) goto reset; - size =process_header (record, size); compressed += size; dst += size; dst_size -= size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 374/1815 perf record: Fix multiple PERF_RECORD_COMPRESSED2 records per push
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Ilvokhin <[email protected]>
[ Upstream commit ad40a000ea598f316ddc0e81e5acc77cc3b1fae0 ]
With Zstd compression enabled ('perf record -z'), a single mmap push whose compressed output exceeds the maximum record size makes zstd_compress_stream_to_records() emit several PERF_RECORD_COMPRESSED2 records back to back. record__pushfn() however rewrote only the first record's header to describe the whole blob as one record:
event->data_size = compressed - sizeof(struct perf_record_compressed2); event->header.size = PERF_ALIGN(compressed, sizeof(u64)); padding = event->header.size - compressed; ... record__write(rec, map, &pad, padding);
perf_event_header::size is a __u16, so once the compressed blob no longer fits in it the header.size assignment truncates and 'padding' (size_t) underflows. write() is then handed that bogus length and fails with EFAULT, aborting the recording:
failed to write perf data, error: Bad address
The bytes that did reach the file are mis-framed, so reading it back cannot be decompressed.
This is easy to hit with a high event rate and a large buffer, e.g.:
perf record -z -F max -m 32M --per-thread -- perf test -w thloop 5 1
The single-record fixup is wrong by construction: because header.size is 16 bits a compressed record cannot exceed 64KB, so the compressor must split a push into a chain of records, and the session reader already consumes them as such.
Frame each record where it is produced instead: make process_comp_header() set the per-record data_size, 8-byte-align header.size and zero the trailing padding, and let record__pushfn() write the resulting blob, as the AIO path already does. Reduce max_record_size by sizeof(u64) so the per-record alignment padding cannot push header.size past its u16 field. process_comp_header() returns -1 when that padding would not fit the space left in 'dst', so the compressor stops instead of overrunning the output buffer.
There is no on-disk format change; a perf.data written by the fixed tool is still read by existing perf.
--- tools/perf/builtin-record.c | 38 +++++------ .../record+zstd_comp_decomp_multi_record.sh | 63 +++++++++++++++++++ 2 files changed, 83 insertions(+), 18 deletions(-) create mode 100755 tools/perf/tests/shell/record+zstd_comp_decomp_multi_record.sh
tools/perf/builtin-record.c +20 -18
@@ -64,6 +64,7 @@#include <poll.h> #include <pthread.h> #include <unistd.h> +#include <string.h> #ifndef HAVE_GETTID #include <syscall.h> #endif
@@ -653,27 +654,14 @@ static int record__pushfn(struct mmap *map, void *to, void *bf, size_t size)struct record *rec = to;if (record__comp_enabled (rec)) { -struct perf_record_compressed2 *event = map->data; -size_t padding =0 ; -u8 pad[8 ] = {0 };ssize_t compressed =zstd_compress (rec->session, map, map->data,mmap__mmap_len (map), bf, size);if (compressed <0 )return (int )compressed; - bf = event; thread->samples++; - -/* -* The record from `zstd_compress` is not 8 bytes aligned, which would cause asan -* error. We make it aligned here. -*/ - event->data_size = compressed -sizeof (struct perf_record_compressed2 ); - event->header.size =PERF_ALIGN (compressed,sizeof (u64)); - padding = event->header.size - compressed; -return record__write (rec, map, bf, compressed) || -record__write (rec, map, &pad, padding); +return record__write (rec, map, map->data, compressed); } thread->samples++;
@@ -1594,7 +1582,8 @@ static void record__adjust_affinity(struct record *rec, struct mmap *map)/* * Called once with data_size == 0 to start a record, then once with -* data_size == compressed payload size to finalize. +* data_size == compressed payload size to finalize and 8-byte-pad it +* (unaligned records trip ASan in the reader). * Returns the bytes written, or -1 if it won't fit. */ static ssize_t process_comp_header(void *record, size_t dst_size,
@@ -1604,8 +1593,15 @@ static ssize_t process_comp_header(void *record, size_t dst_size,size_t size =sizeof (*event);if (data_size) { - event->header.size += data_size; -return 0 ; +size_t padding; + + event->data_size = data_size; + event->header.size =PERF_ALIGN (size + data_size,sizeof (u64)); + padding = event->header.size - size - data_size; +if (padding > dst_size) +return -1 ; +memset (record + size + data_size,0 , padding); +return padding; }if (size > dst_size)
@@ -1613,6 +1609,7 @@ static ssize_t process_comp_header(void *record, size_t dst_size, event->header.type =PERF_RECORD_COMPRESSED2 ; event->header.size = size; + event->data_size =0 ;return size; }
@@ -1621,7 +1618,12 @@ static ssize_t zstd_compress(struct perf_session *session, struct mmap *map, void *dst, size_t dst_size, void *src, size_t src_size) { ssize_t compressed; -size_t max_record_size =PERF_SAMPLE_MAX_SIZE -sizeof (struct perf_record_compressed2 ) -1 ; +/* +* Reserve space so per-record PERF_ALIGN() padding keeps header.size +* within u16. +*/ +size_t max_record_size =PERF_SAMPLE_MAX_SIZE + -sizeof (struct perf_record_compressed2 ) -sizeof (u64);struct zstd_data *zstd_data = &session->zstd_data;if (map && map->file)
tools/perf/tests/shell/record+zstd_comp_decomp_multi_record.sh new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 375/1815 fs/resctrl: Fix UAF from worker threads when domains are removed
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Reinette Chatre <[email protected]>
[ Upstream commit 2566b5cd6a275c124e8f154fef6e815f92ec8d5c ]
The mbm_handle_overflow() and cqm_handle_limbo() workers read event counters and may sleep while doing so. They are scheduled via delayed_work embedded in struct rdt_l3_mon_domain. Architecture allocates and frees these domains from CPU hotplug callbacks under cpus_write_lock(), and the workers acquire cpus_read_lock() to keep the domain alive across their access.
A use-after-free can occur when a worker is blocked waiting for cpus_read_lock() while the hotplug core holds cpus_write_lock(): the architecture frees the rdt_l3_mon_domain that contains the worker's work_struct. When the worker unblocks, the container_of() it performs on the embedded work pointer dereferences freed memory.
Drop cpus_read_lock() from the workers and instead drain pending and in-flight work synchronously before the architecture can free the domain. Since architecture offlines the domain under cpus_write_lock() after it has been unlinked from the RCU list and a grace period has elapsed, no new work can be scheduled. The cancel only needs to wait out existing work. Drop rdtgroup_mutex during CPU offline around cancel_delayed_work_sync() so that a worker waiting on the mutex can complete before re-pinning the work on a different CPU.
When offlining a CPU the architecture may iterate over resources in any order. For example, the MBA control domain may be offlined before or after a corresponding L3 monitor domain. Ensure that resctrl fs cancels the workers no matter what order the architecture offlines the domains.
--- fs/resctrl/monitor.c | 60 +++++++++++++++++++++++++++++++++++-------- fs/resctrl/rdtgroup.c | 52 +++++++++++++++++++++++++++++++++---- 2 files changed, 97 insertions(+), 15 deletions(-)
fs/resctrl/monitor.c +50 -10
@@ -628,14 +628,22 @@ void mon_event_count(void *info) rr->err =0 ; } -static struct rdt_ctrl_domain *get_ctrl_domain_from_cpu (int cpu, -struct rdt_resource *r) +/* +* Find the software controller's ctrl domain that contains @cpu on resource @r. +* +* Only called from the mbm_over worker via update_mba_bw() where the returned +* domain is kept alive by cancel_delayed_work_sync() in +* resctrl_offline_ctrl_domain(). This drains this worker and then waits on +* rdtgroup_mutex held here before the architecture can free the ctrl domain. +* +* Context: Call from RCU read-side critical section. +*/ +static struct rdt_ctrl_domain *get_sc_ctrl_domain_from_cpu (int cpu, +struct rdt_resource *r) {struct rdt_ctrl_domain *d; -lockdep_assert_cpus_held (); - -list_for_each_entry (d, &r->ctrl_domains, hdr.list) { +list_for_each_entry_rcu (d, &r->ctrl_domains, hdr.list) {/* Find the domain that contains this CPU */ if (cpumask_test_cpu (cpu, &d->hdr.cpu_mask))return d;
@@ -696,7 +704,8 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_l3_mon_domain *dom_mif (WARN_ON_ONCE (!pmbm_data))return ; - dom_mba =get_ctrl_domain_from_cpu (smp_processor_id (), r_mba); +guard (rcu)(); + dom_mba =get_sc_ctrl_domain_from_cpu (smp_processor_id (), r_mba);if (!dom_mba) {pr_warn_once ("Failure to get domain for MBA update\n" );return ;
@@ -799,11 +808,25 @@ void cqm_handle_limbo(struct work_struct *work)unsigned long delay =msecs_to_jiffies (CQM_LIMBOCHECK_INTERVAL );struct rdt_l3_mon_domain *d; -cpus_read_lock (); +/* +* Safe to run without CPU hotplug lock. Work is guaranteed to be +* canceled before the domain structure is removed. +*/ mutex_lock (&rdtgroup_mutex); +/* +* Ensure the worker is dedicated to a CPU as intended and not +* relocated by workqueue subsystem as part of CPU going offline. +*/ +if (!is_percpu_thread ()) + goto out_unlock; + d = container_of(work, struct rdt_l3_mon_domain, cqm_limbo.work); +/* Domain is going offline */ +if (cpumask_empty (&d->hdr.cpu_mask)) + goto out_unlock; +__check_limbo (d, false);if (has_busy_rmid (d)) {
@@ -813,8 +836,8 @@ void cqm_handle_limbo(struct work_struct *work) delay); } +out_unlock:mutex_unlock (&rdtgroup_mutex); -cpus_read_unlock (); }/**
@@ -846,7 +869,10 @@ void mbm_handle_overflow(struct work_struct *work)struct list_head *head;struct rdt_resource *r; -cpus_read_lock (); +/* +* Safe to run without CPU hotplug lock. Work is guaranteed to be +* canceled before the domain structure is removed. +*/ mutex_lock (&rdtgroup_mutex);/*
@@ -856,9 +882,24 @@ void mbm_handle_overflow(struct work_struct *work)if (!resctrl_mounted || !resctrl_arch_mon_capable ()) goto out_unlock; +/* +* Ensure the worker is dedicated to a CPU and not relocated by +* workqueue subsystem as part of CPU going offline since reading +* events depend on smp_processor_id(). After passing this check +* smp_processor_id() is valid for entire duration of this worker +* since it runs with rdtgroup_mutex held and the offline handler needs +* rdtgroup_mutex to offline the CPU being run on here. +*/ +if (!is_percpu_thread ()) + goto out_unlock; + r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); d = container_of(work, struct rdt_l3_mon_domain, mbm_over.work); +/* Domain is going offline */ +if (cpumask_empty (&d->hdr.cpu_mask)) + goto out_unlock; +list_for_each_entry (prgrp, &rdt_all_groups, rdtgroup_list) {mbm_update (r, d, prgrp);
@@ -880,7 +921,6 @@ void mbm_handle_overflow(struct work_struct *work) out_unlock:mutex_unlock (&rdtgroup_mutex); -cpus_read_unlock (); }/**
fs/resctrl/rdtgroup.c +47 -5
86 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 376/1815 rpmsg: glink: fix deadlock in endpoint destroy during driver detach
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Santhosh <[email protected]>
[ Upstream commit 5a5a48e788e02fd8a8eb7188ce440572d6c12418 ]
During driver detach, the device core holds the device mutex throughout the driver's remove callback chain. When the rpmsg endpoint is destroyed as part of that teardown, the GLINK endpoint destroy implementation attempts to unregister the underlying rpmsg device. That unregistration calls device_del(), which tries to re-acquire the same device mutex already held higher up the stack, causing rmmod to hang indefinitely.
The deadlock manifests with the following call chain:
[<0>] device_del+0x44/0x414 <- tries to acquire same mutex [<0>] device_unregister+0x18/0x34 [<0>] rpmsg_unregister_device+0x28/0x4c [<0>] qcom_glink_remove_rpmsg_device+0x70/0xc0 [<0>] qcom_glink_destroy_ept+0x58/0xbc [<0>] rpmsg_dev_remove+0x50/0x60 [<0>] device_remove+0x4c/0x80 [<0>] device_release_driver_internal+0x1cc/0x228 <- acquires device mutex [<0>] driver_detach+0x4c/0x98 [<0>] bus_remove_driver+0x6c/0xbc [<0>] driver_unregister+0x30/0x60 [<0>] unregister_rpmsg_driver+0x10/0x1c [<0>] fastrpc_exit+0x28/0x38 [fastrpc] [<0>] __arm64_sys_delete_module+0x1b8/0x294 [<0>] invoke_syscall+0x48/0x10c [<0>] el0_svc_common.constprop.0+0xc0/0xe0 [<0>] do_el0_svc+0x1c/0x28 [<0>] el0_svc+0x34/0x108 [<0>] el0t_64_sync_handler+0xa0/0xe4 [<0>] el0t_64_sync+0x198/0x19c
The rpmsg device unregistration inside endpoint destroy is redundant. In both contexts where endpoint destruction is triggered:
- Driver detach path: the driver core already tears down the rpmsg device.
- Channel close path: the rpmsg device is already unregistered before endpoint destruction is reached.
Remove the redundant unregistration to fix the deadlock.
--- drivers/rpmsg/qcom_glink_native.c | 3 --- 1 file changed, 3 deletions(-)
drivers/rpmsg/qcom_glink_native.c +0 -3
@@ -1418,9 +1418,6 @@ static void qcom_glink_destroy_ept(struct rpmsg_endpoint *ept) channel->ept.cb =NULL ;spin_unlock_irqrestore (&channel->recv_lock, flags); -/* Decouple the potential rpdev from the channel */ -qcom_glink_remove_rpmsg_device (glink, channel); -qcom_glink_send_close_req (glink, channel); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 377/1815 arm64: dts: renesas: rzt2h-n2h-evk: Remove unused MII/GMII pins
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lad Prabhakar <[email protected]>
[ Upstream commit c49ad13019771d5161290dc0eacb3ff6186c0953 ]
Remove the unused TXER, RXER, CRS, and COL pinmux configurations from the gmac1 (ETH3) and gmac2 (ETH2) pin groups.
The Ethernet interfaces on both the RZ/T2H and RZ/N2H EVK boards operate in RGMII mode, which does not utilize these extra MII/GMII sideband signal pins. Update the board switch configuration comments to accurately reflect the pin ranges that are actually in use.
--- .../boot/dts/renesas/r9a09g077m44-rzt2h-evk.dts | 14 ++------------ .../boot/dts/renesas/r9a09g087m44-rzn2h-evk.dts | 15 ++------------- 2 files changed, 4 insertions(+), 25 deletions(-)
arch/arm64/boot/dts/renesas/r9a09g077m44-rzt2h-evk.dts +2 -12
@@ -256,8 +256,7 @@ can0_pins: can0-pins { /* * GMAC1 Pin Configuration: * - * SW2[8] ON - use pins P33_2-P33_7, P34_0-P34_5, P34_7 and - * P35_0-P35_2 for Ethernet port 3 + * SW2[8] ON - use pins P33_2-P33_7 and P34_0-P34_5 for Ethernet port 3 */ gmac1_pins: gmac1-pins { pinmux = <RZT2H_PORT_PINMUX(33, 2, 0xf)>, /* ETH3_TXCLK */
@@ -272,10 +271,6 @@ gmac1_pins: gmac1-pins { <RZT2H_PORT_PINMUX(34, 3, 0xf)>, /* ETH3_RXD2 */ <RZT2H_PORT_PINMUX(34, 4, 0xf)>, /* ETH3_RXD3 */ <RZT2H_PORT_PINMUX(34, 5, 0xf)>, /* ETH3_RXDV */ - <RZT2H_PORT_PINMUX(34, 7, 0xf)>, /* ETH3_TXER */ - <RZT2H_PORT_PINMUX(35, 0, 0xf)>, /* ETH3_RXER */ - <RZT2H_PORT_PINMUX(35, 1, 0xf)>, /* ETH3_CRS */ - <RZT2H_PORT_PINMUX(35, 2, 0xf)>, /* ETH3_COL */ <RZT2H_PORT_PINMUX(26, 1, 0x10)>, /* GMAC1_MDC */ <RZT2H_PORT_PINMUX(26, 2, 0x10)>, /* GMAC1_MDIO */ <RZT2H_PORT_PINMUX(34, 6, 0x2)>, /* ETH3_REFCLK */
@@ -286,8 +281,7 @@ gmac1_pins: gmac1-pins { * GMAC2 Pin Configuration: * * SW2[6] OFF - connect MDC/MDIO of Ethernet port 2 to GMAC2 - * SW2[7] ON - use pins P29_1-P29_7, P30_0-P30_4, and P31_2-P31_5 - * for Ethernet port 2 + * SW2[7] ON - use pins P29_1-P29_7 and P30_0-P30_4 for Ethernet port 2 */ gmac2_pins: gmac2-pins { pinmux = <RZT2H_PORT_PINMUX(29, 1, 0xf)>, /* ETH2_TXCLK */
@@ -302,10 +296,6 @@ gmac2_pins: gmac2-pins { <RZT2H_PORT_PINMUX(30, 2, 0xf)>, /* ETH2_RXD2 */ <RZT2H_PORT_PINMUX(30, 3, 0xf)>, /* ETH2_RXD3 */ <RZT2H_PORT_PINMUX(30, 4, 0xf)>, /* ETH2_RXDV */ - <RZT2H_PORT_PINMUX(31, 2, 0xf)>, /* ETH2_TXER */ - <RZT2H_PORT_PINMUX(31, 3, 0xf)>, /* ETH2_RXER */ - <RZT2H_PORT_PINMUX(31, 4, 0xf)>, /* ETH2_CRS */ - <RZT2H_PORT_PINMUX(31, 5, 0xf)>, /* ETH2_COL */ <RZT2H_PORT_PINMUX(30, 5, 0x10)>, /* GMAC2_MDC */ <RZT2H_PORT_PINMUX(30, 6, 0x10)>, /* GMAC2_MDIO */ <RZT2H_PORT_PINMUX(31, 0, 0x2)>, /* ETH2_REFCLK */
arch/arm64/boot/dts/renesas/r9a09g087m44-rzn2h-evk.dts +2 -13
@@ -339,9 +339,7 @@ can1_pins: can1-pins { /* * GMAC1 Pin Configuration: * - * DSW5[8] ON - use pins P00_0-P00_2, P33_2-P33_7, P34_0-P34_6 - * for Ethernet port 3 - * DSW12[1] OFF; DSW12[2] ON - use pin P00_3 for Ethernet port 3 + * DSW5[8] ON - use pins P33_2-P33_7 and P34_0-P34_6 for Ethernet port 3 */ gmac1_pins: gmac1-pins { pinmux = <RZT2H_PORT_PINMUX(33, 2, 0xf)>, /* ETH3_TXCLK */
@@ -356,10 +354,6 @@ gmac1_pins: gmac1-pins { <RZT2H_PORT_PINMUX(34, 3, 0xf)>, /* ETH3_RXD2 */ <RZT2H_PORT_PINMUX(34, 4, 0xf)>, /* ETH3_RXD3 */ <RZT2H_PORT_PINMUX(34, 5, 0xf)>, /* ETH3_RXDV */ - <RZT2H_PORT_PINMUX(0, 0, 0xf)>, /* ETH3_TXER */ - <RZT2H_PORT_PINMUX(0, 1, 0xf)>, /* ETH3_RXER */ - <RZT2H_PORT_PINMUX(0, 2, 0xf)>, /* ETH3_CRS */ - <RZT2H_PORT_PINMUX(0, 3, 0xf)>, /* ETH3_COL */ <RZT2H_PORT_PINMUX(26, 1, 0x10)>, /* GMAC1_MDC */ <RZT2H_PORT_PINMUX(26, 2, 0x10)>, /* GMAC1_MDIO */ <RZT2H_PORT_PINMUX(34, 6, 0x2)>, /* ETH3_REFCLK */
@@ -370,8 +364,7 @@ gmac1_pins: gmac1-pins { * GMAC2 Pin Configuration: * * DSW5[6] OFF - connect MDC/MDIO of Ethernet port 2 to GMAC2 - * DSW5[7] ON - use pins P29_1-P29_7, P30_0-P30_4, P30_7, - * P31_2, P31_4 and P31_5 are used for Ethernet port 2 + * DSW5[7] ON - use pins P29_1-P29_7 and P30_0-P30_4 for Ethernet port 2 * DSW13[7] OFF; DSW13[8] ON - use pin P13_7 for IRQ14 */ gmac2_pins: gmac2-pins {
@@ -387,10 +380,6 @@ gmac2_pins: gmac2-pins { <RZT2H_PORT_PINMUX(30, 2, 0xf)>, /* ETH2_RXD2 */ <RZT2H_PORT_PINMUX(30, 3, 0xf)>, /* ETH2_RXD3 */ <RZT2H_PORT_PINMUX(30, 4, 0xf)>, /* ETH2_RXDV */ - <RZT2H_PORT_PINMUX(31, 2, 0xf)>, /* ETH2_TXER */ - <RZT2H_PORT_PINMUX(31, 1, 0xf)>, /* ETH2_RXER */ - <RZT2H_PORT_PINMUX(31, 4, 0xf)>, /* ETH2_CRS */ - <RZT2H_PORT_PINMUX(31, 5, 0xf)>, /* ETH2_COL */ <RZT2H_PORT_PINMUX(30, 5, 0x10)>, /* GMAC2_MDC */ <RZT2H_PORT_PINMUX(30, 6, 0x10)>, /* GMAC2_MDIO */ <RZT2H_PORT_PINMUX(31, 0, 0x2)>, /* ETH2_REFCLK */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 378/1815 arm64: dts: renesas: r9a09g056: Fix PCIe dma-ranges memory space code
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lad Prabhakar <[email protected]>
[ Upstream commit 3e7259fb8a31c8b784628cfc417998447b0e5629 ]
The RZ/V2N SoC supports up to 8 GiB of memory. Update the PCIe dma-ranges property to use the 64-bit prefetchable memory space code.
--- arch/arm64/boot/dts/renesas/r9a09g056.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/renesas/r9a09g056.dtsi +1 -1
@@ -1049,7 +1049,7 @@ pcie: pcie@13400000 { reg = <0 0x13400000 0 0x10000>; ranges = <0x02000000 0 0x30000000 0 0x30000000 0 0x8000000>, <0x43000000 4 0x40000000 4 0x40000000 6 0x00000000>; - dma-ranges = <0x42000000 0 0x40000000 0 0x40000000 2 0x00000000>; + dma-ranges = <0x43000000 0 0x40000000 0 0x40000000 2 0x00000000>; bus-range = <0x0 0xff>; interrupts = <GIC_SPI 800 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 801 IRQ_TYPE_LEVEL_HIGH>,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 379/1815 arm64: dts: renesas: r9a09g047: Fix PCIe dma-ranges memory space code
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lad Prabhakar <[email protected]>
[ Upstream commit 24afcb87e6aca1ff3face276223eeea0012f8e2b ]
The RZ/G3E SoC supports up to 8 GiB of memory. Update the PCIe dma-ranges property to use the 64-bit prefetchable memory space code.
--- arch/arm64/boot/dts/renesas/r9a09g047.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/renesas/r9a09g047.dtsi +1 -1
@@ -931,7 +931,7 @@ pcie: pcie@13400000 { reg = <0 0x13400000 0 0x10000>; ranges = <0x02000000 0 0x30000000 0 0x30000000 0 0x08000000>, <0x43000000 4 0x40000000 4 0x40000000 6 0x00000000>; - dma-ranges = <0x42000000 0 0x40000000 0 0x40000000 2 0x00000000>; + dma-ranges = <0x43000000 0 0x40000000 0 0x40000000 2 0x00000000>; bus-range = <0x0 0xff>; interrupts = <GIC_SPI 800 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 801 IRQ_TYPE_LEVEL_HIGH>,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 380/1815 iommufd: Simplify iommufd_device_remove_vdev()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit 8062148046e1a6417d44e2ed86c04e66c2f4f2a1 ]
Peiyang reports that this function indirectly includes a fault injection point through iommufd_get_object() that was intended to cover the uAPI use of object IDs, not in places like this that cannot fail.
On deeper inspection this can be written using a dedicated helper to obtain a users refcount relying entirely on the xa locking instead of going through the whole get/put scheme. The new helper doesn't need the fault injection point.
--- drivers/iommu/iommufd/device.c | 13 +++---------- drivers/iommu/iommufd/iommufd_private.h | 9 +-------- drivers/iommu/iommufd/main.c | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 18 deletions(-)
drivers/iommu/iommufd/device.c +3 -10
@@ -148,29 +148,22 @@ static void iommufd_device_remove_vdev(struct iommufd_device *idev)if (!idev->vdev) goto out_unlock; - vdev =iommufd_get_vdevice (idev->ictx, idev->vdev->obj.id); + vdev = idev->vdev; +/* * An ongoing vdev destroy ioctl has removed the vdev from the object * xarray, but has not finished iommufd_vdevice_destroy() yet as it * needs the same mutex. We exit the locking then wait on wait_cnt * reference for the vdev destruction. */ -if (IS_ERR (vdev)) - goto out_unlock; - -/* Should never happen */ -if (WARN_ON (vdev != idev->vdev)) { -iommufd_put_object (idev->ictx, &vdev->obj); +if (iommufd_try_inc_users (idev->ictx, &vdev->obj)) goto out_unlock; - }/* * vdev is still alive. Hold a users refcount to prevent racing with * userspace destruction, then use iommufd_object_tombstone_user() to * destroy it and leave a tombstone. */ -refcount_inc (&vdev->obj.users); -iommufd_put_object (idev->ictx, &vdev->obj);mutex_unlock (&idev->igroup->lock);iommufd_object_tombstone_user (idev->ictx, &vdev->obj);return ;
drivers/iommu/iommufd/iommufd_private.h +1 -8
@@ -182,6 +182,7 @@ static inline bool iommufd_lock_obj(struct iommufd_object *obj)return true; } +int iommufd_try_inc_users (struct iommufd_ctx *ictx,struct iommufd_object *obj);struct iommufd_object *iommufd_get_object (struct iommufd_ctx *ictx,u32 id,enum iommufd_object_type type); static inline void iommufd_put_object(struct iommufd_ctx *ictx,
@@ -698,14 +699,6 @@ void iommufd_vdevice_abort(struct iommufd_object *obj);int iommufd_hw_queue_alloc_ioctl (struct iommufd_ucmd *ucmd);void iommufd_hw_queue_destroy (struct iommufd_object *obj); -static inline struct iommufd_vdevice * -iommufd_get_vdevice (struct iommufd_ctx *ictx,u32 id) -{ -return container_of (iommufd_get_object (ictx, id, -IOMMUFD_OBJ_VDEVICE ), - struct iommufd_vdevice, obj); -} -#ifdef CONFIG_IOMMUFD_TEST int iommufd_test (struct iommufd_ucmd *ucmd);void iommufd_selftest_destroy (struct iommufd_object *obj);
drivers/iommu/iommufd/main.c +20 -0
@@ -180,6 +180,26 @@ struct iommufd_object *iommufd_get_object(struct iommufd_ctx *ictx, u32 id,return obj; } +/* +* Increment the users count of an object outside the context of an ioctl that +* has already locked it. The users refcount cannot be increased on an already +* created object unless the object is installed in the xarray, otherwise things +* are racing with a parallel destruction. +*/ +int iommufd_try_inc_users (struct iommufd_ctx *ictx,struct iommufd_object *obj) +{ +struct iommufd_object *cur; + +xa_lock (&ictx->objects); + cur =xa_load (&ictx->objects, obj->id); +if (cur == obj) +refcount_inc (&obj->users); +xa_unlock (&ictx->objects); +if (cur != obj) +return -EBUSY ; +return 0 ; +} +static int iommufd_object_dec_wait (struct iommufd_ctx *ictx,struct iommufd_object *to_destroy) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 381/1815 cxl/test: Rework cxl_type2_mem_init() to use cxl_mock_platform_device_add()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Ming <[email protected]>
[ Upstream commit 9515af581da976911aea820175afb05be803ae8c ]
cxl_type2_mem_init() is used to set up mock CXL type2 memory device for cxl testing, it introduces a known bug fixed by the following commit:
commit d90f236f8b9e ("cxl/test: Update mock dev array before calling platform_device_add()")
Mock CXL devices require updating the mock device array prior to platform_device_add(), otherwise, the CXL subsystem could fail to recognize the newly added mock device. Switch to cxl_mock_platform_device_add() helper to resolve this ordering issue.
Besides, this patch also includes two minor changes.
1. Preserve the original error code returned by cxl_mock_platform_device_add(), rather than unconditionally overriding it with -ENOMEM.
2. Drop redundant NULL check before platform_device_unregister(), as the function internally handles NULL pointer.
--- tools/testing/cxl/test/cxl.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
tools/testing/cxl/test/cxl.c +4 -13
@@ -1799,25 +1799,16 @@ static int cxl_type2_mem_init(void) pdev->dev.parent = &dport->dev;set_dev_node (&pdev->dev, i %2 ); - rc =platform_device_add (pdev); -if (rc) { - rc = -ENOMEM ; -platform_device_put (pdev); + rc =cxl_mock_platform_device_add (pdev, &cxl_mem[i]); +if (rc) goto err_mem; - } - cxl_mem[i] = pdev; }return 0 ; err_mem: -for (i =NR_CXL_TYPE2_ACCEL -1 ; i >=0 ; i--) { -struct platform_device *pdev = cxl_mem[i]; - -if (!pdev) -continue ; -platform_device_unregister (pdev); - } +for (i =NR_CXL_TYPE2_ACCEL -1 ; i >=0 ; i--) +platform_device_unregister (cxl_mem[i]);return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 382/1815 cxl/memdev: Fix firmware upload exact-fit handling
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guzebing <[email protected]>
[ Upstream commit af5035e1b3e400067bb003975936e5407377e7a3 ]
cxl_fw_prepare() classifies a firmware image as a one-shot transfer only when its Transfer FW input payload is smaller than the mailbox payload size. An image that exactly fills the payload is therefore treated as a multi-part transfer.
The firmware loader invokes cxl_fw_write() only once for that image. Since both offset == 0 and remaining == 0, the multi-part action selection sends INITIATE, never sends END, and then attempts to activate the target slot.
Include equality in the one-shot classification so exact-fit images use the FULL action.
--- drivers/cxl/core/memdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/core/memdev.c +1 -1
@@ -921,7 +921,7 @@ static enum fw_upload_err cxl_fw_prepare(struct fw_upload *fwl, const u8 *data,if (!size)return FW_UPLOAD_ERR_INVALID_SIZE ; - mds->fw.oneshot =struct_size (transfer, data, size) < + mds->fw.oneshot =struct_size (transfer, data, size) <= cxl_mbox->payload_size;if (cxl_mem_get_fw_info (mds))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 383/1815 cxl/mbox: Break poison list loop on an empty payload
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 8b301c4afbce4bc3f94528441d8d5ce1366504ad ]
A device that returns count == 0 with CXL_POISON_FLAG_MORE set on every iteration never advances nr_records, so the max_errors guard never trips and the do/while loops forever while holding poison.mutex. That hangs the sysfs-triggered scan thread and blocks all subsequent poison operations on the device. The existing "Protect against an uncleared _FLAG_MORE" guard was intended to bound a misbehaving device but does not cover the count == 0 case.
Stop the loop on an empty payload so a malfunctioning or malicious device cannot wedge the poison scan.
--- drivers/cxl/core/mbox.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/cxl/core/mbox.c +5 -0
@@ -1450,6 +1450,11 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,if (rc)break ; +if (!le16_to_cpu (po->count)) { +dev_dbg (&cxlmd->dev,"Poison empty payload!\n" ); +break ; + } +for (int i =0 ; i <le16_to_cpu (po->count); i++) trace_cxl_poison(cxlmd, cxlr, &po->record[i], po->flags, po->overflow_ts,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 384/1815 cxl/pci: Honor -EPROBE_DEFER from component register setup
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 430c502c80e542e77bcf97db13ec0e8cdf9addb0 ]
cxl_pci_setup_regs() for CXL_REGLOC_RBI_COMPONENT can return -EPROBE_DEFER on a Restricted CXL Host (RCD) when the upstream port has not yet been enumerated and the Component Registers must be extracted from the RCRB. cxl_pci_probe() treats every non-zero return from that call as the benign "component registers not found" case, logs a warning, and continues. The rc is then immediately overwritten by the subsequent cxl_pci_type3_init_mailbox() call, so the deferral is silently swallowed.
Return -EPROBE_DEFER instead of continuing so the probe is retried once the upstream port is available.
--- drivers/cxl/pci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/cxl/pci.c +5 -2
@@ -823,10 +823,13 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)*/ rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_COMPONENT , &cxlds->reg_map); -if (rc) +if (rc) { +if (rc == -EPROBE_DEFER ) +return rc;dev_warn (&pdev->dev,"No component registers (%d)\n" , rc); -else if (!cxlds->reg_map.component_map.ras.valid) + }else if (!cxlds->reg_map.component_map.ras.valid) {dev_dbg (&pdev->dev,"RAS registers not found\n" ); + } rc =cxl_pci_type3_init_mailbox (cxlds);if (rc)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 385/1815 cxl/features: Serialize multi-part Get/Set Feature transfers
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 77b814c1832fde018c30357b4ec3fcdaa91a1c10 ]
A Get or Set Feature payload larger than the mailbox payload size is split into several mailbox commands. mbox_mutex only serializes individual mailbox commands and is dropped between iterations of these loops. Nothing serializes the multi-part transfer as a whole. cxl_get_feature() and cxl_set_feature() are reachable concurrently from fwctl (per-fd RPCs run under a read-held registration lock) and from the EDAC scrub/ECS/repair paths, so two transfers to the same mailbox can interleave their parts and corrupt the device's transfer context.
Add a per-mailbox feat_mutex and hold it across the whole transfer in both functions. It nests outside mbox_mutex (which is taken inside cxl_internal_send_cmd()), and is taken nowhere else, so no lock-ordering inversion is introduced.
--- drivers/cxl/core/features.c | 3 +++ drivers/cxl/core/mbox.c | 1 + include/cxl/mailbox.h | 2 ++ 3 files changed, 6 insertions(+)
drivers/cxl/core/features.c +3 -0
@@ -240,6 +240,8 @@ size_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, size_out =min (feat_out_size, cxl_mbox->payload_size);uuid_copy (&pi.uuid, feat_uuid); pi.selection = selection; + +guard (mutex)(&cxl_mbox->feat_mutex); do { data_to_rd_size = min(feat_out_size - data_rcvd_size, cxl_mbox->payload_size);
@@ -314,6 +316,7 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox, data_in_size = cxl_mbox->payload_size - hdr_size; } +guard (mutex)(&cxl_mbox->feat_mutex); do { int rc;
drivers/cxl/core/mbox.c +1 -0
@@ -1516,6 +1516,7 @@ int cxl_mailbox_init(struct cxl_mailbox *cxl_mbox, struct device *host) cxl_mbox->host = host;mutex_init (&cxl_mbox->mbox_mutex); +mutex_init (&cxl_mbox->feat_mutex);rcuwait_init (&cxl_mbox->mbox_wait);return 0 ;
include/cxl/mailbox.h +2 -0
@@ -50,6 +50,7 @@ struct cxl_mbox_cmd {* @payload_size: Size of space for payload * (CXL 3.1 8.2.8.4.3 Mailbox Capabilities Register) * @mbox_mutex: mutex protects device mailbox and firmware +* @feat_mutex: serializes multi-part Get/Set Feature transfers * @mbox_wait: rcuwait for mailbox * @mbox_send: @dev specific transport for transmitting mailbox commands * @feat_cap: Features capability
@@ -60,6 +61,7 @@ struct cxl_mailbox {DECLARE_BITMAP (exclusive_cmds,CXL_MEM_COMMAND_ID_MAX );size_t payload_size;struct mutex mbox_mutex;/* lock to protect mailbox context */ +struct mutex feat_mutex;struct rcuwait mbox_wait;int (*mbox_send)(struct cxl_mailbox *cxl_mbox,struct cxl_mbox_cmd *cmd);enum cxl_features_capability feat_cap;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 386/1815 cxl/port: Restart port enumeration when a sibling adds the dport first
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
[ Upstream commit a623128bc2a1c257cbad97d0582f355fbe7be927 ]
Endpoint probes can race while enumerating a shared switch. If a sibling probe adds the dport first, the losing probe finds the dport already present, gets -EBUSY, and fails to enumerate the endpoint.
Treat this race the same as the existing port-created case by restarting the port walk, allowing it to find the existing dport and continue enumeration.
This race was discovered while testing a cxl_test mixed-granularity topology, where twelve endpoints behind shared switches are probed in parallel during module load.
--- drivers/cxl/core/port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cxl/core/port.c +2 -2
@@ -1749,8 +1749,8 @@ static int add_port_attach_ep(struct cxl_memdev *cxlmd, parent_dport, uport_dev, dport_dev);if (IS_ERR (dport)) { -/* Port already exists, restart iteration */ -if (PTR_ERR (dport) == -EAGAIN ) +/* Port or dport already exists, restart iteration */ +if (PTR_ERR (dport) == -EAGAIN ||PTR_ERR (dport) == -EBUSY )return 0 ;return PTR_ERR (dport); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 387/1815 hfsplus: validate thread record before delete key rebuild
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit e2ea5cac61acfc11dad22f1d2d4bc71d56c52a20 ]
hfsplus_delete_cat() is called with str == NULL when the last open reference to an unlinked HFS+ hardlink backing inode is closed. In that case, the function finds the catalog thread by CNID and rebuilds the catalog key from thread.nodeName.
That reconstruction path reads thread.nodeName.length directly from the catalog B-tree into fd.search_key and then copies length * 2 bytes into fd.search_key->cat.name.unicode. It does not first check that the found record is a thread record or that its size matches the thread name.
A corrupted image can therefore provide an oversized thread name length and make hfs_bnode_read() write past the catalog search-key allocation.
Read the CNID record through hfsplus_brec_read_cat(), which bounds the record read to sizeof(hfsplus_cat_entry) and verifies that a thread record's size exactly matches nodeName.length. Together, these checks ensure an accepted thread name fits HFSPLUS_MAX_STRLEN. Reject non-thread records before building the delete key from the validated thread name.
Share the thread-record-type helper between hfsplus_find_cat() and hfsplus_delete_cat().
--- fs/hfsplus/catalog.c | 25 ++++++++++++------------- fs/hfsplus/hfsplus_fs.h | 6 ++++++ 2 files changed, 18 insertions(+), 13 deletions(-)
fs/hfsplus/catalog.c +12 -13
@@ -204,7 +204,7 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid,return err; type =be16_to_cpu (tmp.type); -if (type !=HFSPLUS_FOLDER_THREAD && type !=HFSPLUS_FILE_THREAD ) { +if (!is_hfs_thread_record_type (type)) {pr_err ("found bad thread record in catalog\n" );return -EIO ; }
@@ -350,23 +350,22 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, const struct qstr *str) goto out;if (!str) { -int len; +hfsplus_cat_entry entry = {0 };hfsplus_cat_build_key_with_cnid (sb, fd.search_key, cnid); - err =hfs_brec_find (&fd, hfs_find_rec_by_key); + err =hfsplus_brec_read_cat (&fd, &entry);if (err) goto out; - off = fd.entryoffset + - offsetof(struct hfsplus_cat_thread , nodeName); - fd.search_key->cat.parent =cpu_to_be32 (dir->i_ino); -hfs_bnode_read (fd.bnode, - &fd.search_key->cat.name.length, off,2 ); - len =be16_to_cpu (fd.search_key->cat.name.length) *2 ; -hfs_bnode_read (fd.bnode, - &fd.search_key->cat.name.unicode, - off +2 , len); - fd.search_key->key_len =cpu_to_be16 (6 + len); + type =be16_to_cpu (entry.type); +if (!is_hfs_thread_record_type (type)) { +pr_err ("found bad thread record in catalog\n" ); + err = -EIO ; + goto out; + } + +hfsplus_cat_build_key_uni (fd.search_key, dir->i_ino, + &entry.thread.nodeName); }else { err =hfsplus_cat_build_key (sb, fd.search_key, dir->i_ino, str);if (unlikely (err))
fs/hfsplus/hfsplus_fs.h +6 -0
@@ -521,6 +521,12 @@ static inline u32 hfsplus_cat_thread_size(const struct hfsplus_cat_thread *threabe16_to_cpu (thread->nodeName.length) *sizeof (hfsplus_unichr); } +static inline +bool is_hfs_thread_record_type (u16 type) +{ +return type ==HFSPLUS_FOLDER_THREAD || type ==HFSPLUS_FILE_THREAD ; +} +int hfsplus_brec_read_cat (struct hfs_find_data *fd,hfsplus_cat_entry *entry);/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 388/1815 wifi: ath12k: fix dp_link_peer dangling references on AP vdev rollback
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baochen Qiang <[email protected]>
[ Upstream commit f066e1a93703c5be0fd905109d00587541711c97 ]
ath12k_mac_vdev_create() for an AP vdev creates the bss self-peer via ath12k_peer_create(), which finishes by calling ath12k_dp_link_peer_assign() to publish the dp_link_peer in the dp_hw->dp_peers[peerid_index] RCU table, in the dp_peer's link_peers[] array, and in the per-addr rhashtable.
If a step after ath12k_peer_create() fails the function jumps to err_peer_del, which open-codes a WMI peer_delete and waits for the unmap / delete_resp events. The wait_for_peer_delete_done() path relies on ath12k_dp_link_peer_unmap_event() freeing the dp_link_peer when the unmap arrives, but err_peer_del never calls ath12k_dp_link_peer_unassign() first. The published references in the dp_hw RCU table, dp_peer->link_peers[] and the rhashtable are left pointing at the dp_link_peer that unmap_event then frees, producing dangling pointers and use-after-free on subsequent lookups.
Replace the open-coded sequence with a call to ath12k_peer_delete(), which already does ath12k_dp_link_peer_unassign() before sending the WMI command. This drops the published references before the dp_link_peer is freed, in the same order as the normal teardown path in ath12k_mac_remove_link_interface().
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
--- drivers/net/wireless/ath/ath12k/mac.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
drivers/net/wireless/ath/ath12k/mac.c +2 -16
@@ -10616,22 +10616,8 @@ int ath12k_mac_vdev_create(struct ath12k *ar, struct ath12k_link_vif *arvif) err_peer_del:if (ahvif->vdev_type ==WMI_VDEV_TYPE_AP ) { -reinit_completion (&ar->peer_delete_done); - - ret =ath12k_wmi_send_peer_delete_cmd (ar, arvif->bssid, - arvif->vdev_id); -if (ret) { -ath12k_warn (ar->ab,"failed to delete peer vdev_id %d addr %pM\n" , - arvif->vdev_id, arvif->bssid); - goto err_dp_peer_del; - } - - ret =ath12k_wait_for_peer_delete_done (ar, arvif->vdev_id, - arvif->bssid); -if (ret) - goto err_dp_peer_del; - - ar->num_peers--; +/* ignore return value: propagate the original error */ +ath12k_peer_delete (ar, arvif->vdev_id, arvif->bssid); } err_dp_peer_del:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 389/1815 wifi: ath12k: fix MLO peer delete race
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baochen Qiang <[email protected]>
[ Upstream commit 01cc0f59aac3574b6a7b02493a76bc8ed0aa758f ]
ath12k_peer_mlo_link_peers_delete() sends WMI peer_delete for every link before waiting for any peer_unmap / peer_delete_resp event. The shared per-radio completion ar->peer_delete_done could not disambiguate which peer a response was for: every call to ath12k_peer_delete_send() did reinit_completion(&ar->peer_delete_done), so when an event for the first link arrived between two sends it raised the count to 1 and the second send promptly cleared it; the wait for the second link then timed out with
Timeout in receiving peer delete response
Replace the shared completion with a per-radio waiter list, with each pending ath12k_peer_delete() caller queueing an ath12k_peer_delete_wait carrying its (vdev_id, addr) and a private struct completion. ath12k_peer_delete_resp_event() matches the response against the list under ar->data_lock and signals the matching waiter.
Also correct the endian conversion in ath12k_peer_delete_resp_event() logging, and add the missing \n in some logging.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
--- drivers/net/wireless/ath/ath12k/core.c | 2 +- drivers/net/wireless/ath/ath12k/core.h | 5 +- drivers/net/wireless/ath/ath12k/mac.c | 2 +- drivers/net/wireless/ath/ath12k/peer.c | 130 ++++++++++++++++++++----- drivers/net/wireless/ath/ath12k/peer.h | 14 ++- drivers/net/wireless/ath/ath12k/wmi.c | 16 +-- 6 files changed, 131 insertions(+), 38 deletions(-)
drivers/net/wireless/ath/ath12k/core.c +1 -1
@@ -1524,7 +1524,7 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab)complete_all (&ar->scan.completed);complete (&ar->scan.on_channel);complete (&ar->peer_assoc_done); -complete (&ar->peer_delete_done); +ath12k_peer_delete_wait_flush (ar);complete (&ar->install_key_done);complete (&ar->vdev_setup_done);complete (&ar->vdev_delete_done);
drivers/net/wireless/ath/ath12k/core.h +3 -2
@@ -666,7 +666,8 @@ struct ath12k {/* protects the radio specific data like debug stats, ppdu_stats_info stats, * vdev_stop_status info, scan data, ath12k_sta info, ath12k_link_vif info, -* channel context data, survey info, test mode data, regd_channel_update_queue. +* channel context data, survey info, test mode data, regd_channel_update_queue, +* peer_delete_waits. */ spinlock_t data_lock;
@@ -688,7 +689,7 @@ struct ath12k {u8 radio_idx;struct completion peer_assoc_done; -struct completion peer_delete_done; +struct list_head peer_delete_waits;int install_key_status;struct completion install_key_done;
drivers/net/wireless/ath/ath12k/mac.c +1 -1
@@ -15092,11 +15092,11 @@ static void ath12k_mac_setup(struct ath12k *ar)spin_lock_init (&ar->dp.ppdu_list_lock);INIT_LIST_HEAD (&ar->arvifs);INIT_LIST_HEAD (&ar->dp.ppdu_stats_info); +INIT_LIST_HEAD (&ar->peer_delete_waits);init_completion (&ar->vdev_setup_done);init_completion (&ar->vdev_delete_done);init_completion (&ar->peer_assoc_done); -init_completion (&ar->peer_delete_done);init_completion (&ar->install_key_done);init_completion (&ar->bss_survey_done);init_completion (&ar->scan.started);
drivers/net/wireless/ath/ath12k/peer.c +104 -26
233 lines not on this page · raw message
drivers/net/wireless/ath/ath12k/peer.h +12 -2
@@ -9,13 +9,23 @@#include "dp_peer.h" +struct ath12k_peer_delete_wait { +struct list_head list; +u32 vdev_id; +u8 addr[ETH_ALEN ]; +struct completion done; +}; + +void ath12k_peer_delete_resp_signal (struct ath12k *ar,u32 vdev_id,const u8 *addr); +void ath12k_peer_delete_wait_flush (struct ath12k *ar); +void ath12k_peer_cleanup (struct ath12k *ar,u32 vdev_id);int ath12k_peer_delete (struct ath12k *ar,u32 vdev_id,u8 *addr);int ath12k_peer_create (struct ath12k *ar,struct ath12k_link_vif *arvif,struct ieee80211_sta *sta,struct ath12k_wmi_peer_create_arg *arg); -int ath12k_wait_for_peer_delete_done (struct ath12k *ar,u32 vdev_id, -const u8 *addr); +int ath12k_wait_for_peer_delete_done (struct ath12k *ar, +struct ath12k_peer_delete_wait *wait);int ath12k_peer_mlo_link_peers_delete (struct ath12k_vif *ahvif,struct ath12k_sta *ahsta);struct ath12k_ml_peer *ath12k_peer_ml_find (struct ath12k_hw *ah,const u8 *addr);
drivers/net/wireless/ath/ath12k/wmi.c +10 -6
@@ -7072,25 +7072,29 @@ static void ath12k_peer_delete_resp_event(struct ath12k_base *ab, struct sk_buff {struct wmi_peer_delete_resp_event peer_del_resp;struct ath12k *ar; +u32 vdev_id;if (ath12k_pull_peer_del_resp_ev (ab, skb, &peer_del_resp) !=0 ) { -ath12k_warn (ab,"failed to extract peer delete resp" ); +ath12k_warn (ab,"failed to extract peer delete resp\n" );return ; } + vdev_id =le32_to_cpu (peer_del_resp.vdev_id); +rcu_read_lock (); - ar =ath12k_mac_get_ar_by_vdev_id (ab,le32_to_cpu (peer_del_resp.vdev_id)); + ar =ath12k_mac_get_ar_by_vdev_id (ab, vdev_id);if (!ar) { -ath12k_warn (ab,"invalid vdev id in peer delete resp ev %d" , - peer_del_resp.vdev_id); +ath12k_warn (ab,"invalid vdev id in peer delete resp ev %d\n" , + vdev_id);rcu_read_unlock ();return ; } -complete (&ar->peer_delete_done); +ath12k_peer_delete_resp_signal (ar, vdev_id, + peer_del_resp.peer_macaddr.addr);rcu_read_unlock ();ath12k_dbg (ab,ATH12K_DBG_WMI ,"peer delete resp for vdev id %d addr %pM\n" , - peer_del_resp.vdev_id, peer_del_resp.peer_macaddr.addr); + vdev_id, peer_del_resp.peer_macaddr.addr); } static void ath12k_vdev_delete_resp_event(struct ath12k_base *ab,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 390/1815 wifi: ath12k: fix rx_mpdu_start layout for QCC2072
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Zhang <[email protected]>
[ Upstream commit 9eb29fd47595e8128775f8ac57ca671238cb798a ]
QCC2072's rx_mpdu_start TLV has a different field layout from QCN9274. Reusing struct rx_mpdu_start_qcn9274 in hal_rx_desc_qcc2072 causes the RX datapath to read the wrong offsets for info2, info4, pn[] and phy_ppdu_id, producing corrupted sequence number, PN, ppdu_id and mpdu-info flags (encrypted, fragment, addr2/addr4 valid).
Add a dedicated struct rx_mpdu_start_qcc2072 that matches the actual hardware descriptor layout, and use it in hal_rx_desc_qcc2072.
Tested-on: QCC2072 hw1.0 PCI WLAN.COL.1.0.c2-00188-QCACOLSWPL_V1_TO_SILICONZ-1
--- .../wireless/ath/ath12k/wifi7/hal_rx_desc.h | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/wifi7/hal_rx_desc.h +33 -1
@@ -140,6 +140,38 @@ struct rx_mpdu_start_qcn9274 {__le32 res1; } __packed; +struct rx_mpdu_start_qcc2072 { +__le32 info0; +__le32 info2; +__le32 reo_queue_desc_lo; +__le32 info1; +__le32 pn[4 ]; +__le32 info4; +__le32 peer_meta_data; +__le16 ast_index; +__le16 sw_peer_id; +__le16 info3; +__le16 phy_ppdu_id; +__le32 info5; +__le32 info6; +__le16 frame_ctrl; +__le16 duration; +u8 addr1[ETH_ALEN ]; +u8 addr2[ETH_ALEN ]; +u8 addr3[ETH_ALEN ]; +__le16 seq_ctrl; +u8 addr4[ETH_ALEN ]; +__le16 qos_ctrl; +__le32 ht_ctrl; +__le32 info7; +__le32 res0; +__le32 res1; +__le32 res2; +__le32 info8; +__le32 res3; +__le32 res4; +} __packed; +#define QCN9274_MPDU_START_SELECT_MPDU_START_TAG BIT(0)#define QCN9274_MPDU_START_SELECT_INFO0_REO_QUEUE_DESC_LO BIT(1)#define QCN9274_MPDU_START_SELECT_INFO1_PN_31_0 BIT(2)
@@ -1492,7 +1524,7 @@ struct hal_rx_desc_qcc2072 {struct rx_msdu_end_qcn9274 msdu_end;u8 rx_padding0[RX_BE_PADDING0_BYTES ];__le32 mpdu_start_tag; -struct rx_mpdu_start_qcn9274 mpdu_start; +struct rx_mpdu_start_qcc2072 mpdu_start;struct rx_pkt_hdr_tlv_qcc2072 pkt_hdr_tlv;u8 msdu_payload[]; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 391/1815 wifi: ath11k: cap out-of-range rx MCS instead of leaving bogus rate
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baochen Qiang <[email protected]>
[ Upstream commit 12b09e478aa7459b7893a695ef77682202f2da83 ]
ath11k can receive HT/VHT/HE frames whose reported MCS is above the maximum that can be expressed in the corresponding mac80211 rate space (e.g. an HE frame reported with MCS 12, while HE tops out at MCS 11).
The frame itself is valid and decodes correctly, but for such a frame ath11k_dp_rx_h_rate() leaves rx_status->rate_idx set to the out-of-range value and never assigns rx_status->encoding, so it stays RX_ENC_LEGACY from the ath11k_dp_rx_h_ppdu() initialization. Once that frame reaches mac80211 it trips the rate sanity check and the frame is dropped with a splat:
ath11k_pci 0000:03:00.0: Received with invalid mcs in HE mode 12
WARNING: CPU: 0 PID: 0 at net/mac80211/rx.c:5433 ieee80211_rx_list+0xb0a/0xe90 [mac80211]
Dropping the frame would discard otherwise valid data, so instead cap the reported MCS to the maximum the rate space can express and deliver the frame. Set rx_status->encoding before the range check and assign rate_idx from the capped value, so a frame with an out-of-range MCS no longer leaves partial or bogus rate metadata behind. Also downgrade the logging level since they are not treated as invalid frames now. The only loss is that such a frame is reported as the capped MCS in the rx rate statistics.
Tested-on: WCN6855 hw2.1 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.41
--- drivers/net/wireless/ath/ath11k/dp_rx.c | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/net/wireless/ath/ath11k/dp_rx.c +15 -15
@@ -2334,10 +2334,10 @@ static void ath11k_dp_rx_h_rate(struct ath11k *ar, struct hal_rx_desc *rx_desc,case RX_MSDU_START_PKT_TYPE_11N : rx_status->encoding =RX_ENC_HT ;if (rate_mcs >ATH11K_HT_MCS_MAX ) { -ath11k_warn (ar->ab, -"Received with invalid mcs in HT mode %d\n" , - rate_mcs); -break ; +ath11k_dbg (ar->ab,ATH11K_DBG_DP_RX , +"Received HT frame with out-of-range mcs %d, capping to %d\n" , + rate_mcs,ATH11K_HT_MCS_MAX ); + rate_mcs =ATH11K_HT_MCS_MAX ; } rx_status->rate_idx = rate_mcs + (8 * (nss -1 ));if (sgi)
@@ -2346,13 +2346,13 @@ static void ath11k_dp_rx_h_rate(struct ath11k *ar, struct hal_rx_desc *rx_desc,break ;case RX_MSDU_START_PKT_TYPE_11AC : rx_status->encoding =RX_ENC_VHT ; - rx_status->rate_idx = rate_mcs;if (rate_mcs >ATH11K_VHT_MCS_MAX ) { -ath11k_warn (ar->ab, -"Received with invalid mcs in VHT mode %d\n" , - rate_mcs); -break ; +ath11k_dbg (ar->ab,ATH11K_DBG_DP_RX , +"Received VHT frame with out-of-range mcs %d, capping to %d\n" , + rate_mcs,ATH11K_VHT_MCS_MAX ); + rate_mcs =ATH11K_VHT_MCS_MAX ; } + rx_status->rate_idx = rate_mcs; rx_status->nss = nss;if (sgi) rx_status->enc_flags |=RX_ENC_FLAG_SHORT_GI ;
@@ -2362,14 +2362,14 @@ static void ath11k_dp_rx_h_rate(struct ath11k *ar, struct hal_rx_desc *rx_desc, rx_status->enc_flags |=RX_ENC_FLAG_LDPC ;break ;case RX_MSDU_START_PKT_TYPE_11AX : - rx_status->rate_idx = rate_mcs; + rx_status->encoding =RX_ENC_HE ;if (rate_mcs >ATH11K_HE_MCS_MAX ) { -ath11k_warn (ar->ab, -"Received with invalid mcs in HE mode %d\n" , - rate_mcs); -break ; +ath11k_dbg (ar->ab,ATH11K_DBG_DP_RX , +"Received HE frame with out-of-range mcs %d, capping to %d\n" , + rate_mcs,ATH11K_HE_MCS_MAX ); + rate_mcs =ATH11K_HE_MCS_MAX ; } - rx_status->encoding =RX_ENC_HE ; + rx_status->rate_idx = rate_mcs; rx_status->nss = nss; rx_status->he_gi =ath11k_mac_he_gi_to_nl80211_he_gi (sgi); rx_status->bw =ath11k_mac_bw_to_mac80211_bw (bw);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 392/1815 x86/entry/fred: Encode frame pointer on entry
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Stevens <[email protected]>
[ Upstream commit dab01c597f6bd40e0efe7da967b8374ca1971b79 ]
Add missing ENCODE_FRAME_POINTER macro invocation into FRED_ENTER macro, to prevent the unwinder from encountering a NULL stack frame pointer when CONFIG_UNWINDER_FRAME_POINTER is enabled
--- arch/x86/entry/entry_64_fred.S | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/entry/entry_64_fred.S +2 -0
@@ -7,6 +7,7 @@ #include <linux/kvm_types.h> #include <asm/asm.h> +#include <asm/frame.h> #include <asm/fred.h> #include <asm/segment.h>
@@ -19,6 +20,7 @@ UNWIND_HINT_END_OF_STACK ANNOTATE_NOENDBR PUSH_AND_CLEAR_REGS + ENCODE_FRAME_POINTER movq %rsp, %rdi /* %rdi -> pt_regs */ .endm
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 393/1815 firmware: arm_scmi: Publish channel state before callbacks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit 0314900dcdde044af0208fed212035dbfaa55843 ]
Transport setup can enable callbacks before the setup routine returns. mailbox_chan_setup() registers the mailbox client with mbox_request_channel(), and the mailbox controller startup path can enable interrupt delivery before SCMI mailbox channel state has been published. Similarly, smc_chan_setup() requests the optional A2P completion IRQ before the SMC transport has made its cinfo pointer visible.
If a pending or spurious callback fires in those windows, the transport RX callback can dereference a NULL transport cinfo pointer. Publishing only the transport-private pointer is not sufficient either: an early callback can enter the SCMI core before scmi_chan_setup() has assigned cinfo->handle.
The core derives scmi_info from cinfo->handle in the RX path, so a NULL handle can still fault even when the transport-private cinfo is valid.
Assign cinfo->handle before invoking the transport setup callback. Publish the mailbox and SMC transport-private channel state before requesting the mailbox channels or IRQ, and clear the early-published pointers again on setup failure. Also unwind mailbox setup devres resources on failure so an optional RX setup error that is ignored by the core does not leave stale transport state behind.
--- drivers/firmware/arm_scmi/driver.c | 2 +- drivers/firmware/arm_scmi/transports/mailbox.c | 18 +++++++++++++----- drivers/firmware/arm_scmi/transports/smc.c | 15 +++++++++------ 3 files changed, 23 insertions(+), 12 deletions(-)
drivers/firmware/arm_scmi/driver.c +1 -1
@@ -2782,6 +2782,7 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node, cinfo->id = prot_id; cinfo->dev = &tdev->dev; + cinfo->handle = &info->handle; ret = info->desc->ops->chan_setup (cinfo, info->dev, tx);if (ret) {of_node_put (of_node);
@@ -2814,7 +2815,6 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node,return ret; } - cinfo->handle = &info->handle;return 0 ; }
drivers/firmware/arm_scmi/transports/mailbox.c +13 -5
@@ -211,13 +211,18 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, cl->tx_block = false; cl->knows_txdone = tx; + cinfo->transport_info = smbox; + smbox->cinfo = cinfo; +mutex_init (&smbox->chan_lock); + smbox->chan =mbox_request_channel (cl, tx ?0 : p2a_chan);if (IS_ERR (smbox->chan)) { ret =PTR_ERR (smbox->chan); + smbox->chan =NULL ;if (ret != -EPROBE_DEFER )dev_err (cdev,"failed to request SCMI %s mailbox\n" , desc); -return ret; + goto err_clear_cinfo; }/* Additional unidirectional channel for TX if needed */
@@ -241,11 +246,14 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, } } - cinfo->transport_info = smbox; - smbox->cinfo = cinfo; -mutex_init (&smbox->chan_lock); -return 0 ; + +err_clear_cinfo: + cinfo->transport_info =NULL ; + smbox->cinfo =NULL ; +devm_iounmap (dev, smbox->shmem); +devm_kfree (dev, smbox); +return ret; }static int mailbox_chan_free (int id,void *p,void *data)
drivers/firmware/arm_scmi/transports/smc.c +9 -6
@@ -172,6 +172,13 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, scmi_info->param_page =SHMEM_PAGE (res.start); scmi_info->param_offset =SHMEM_OFFSET (res.start); } + + scmi_info->func_id = func_id; + scmi_info->cap_id = cap_id; + scmi_info->cinfo = cinfo; +smc_channel_lock_init (scmi_info); + cinfo->transport_info = scmi_info; +/* * If there is an interrupt named "a2p", then the service and * completion of a message is signaled by an interrupt rather than by
@@ -183,18 +190,14 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, IRQF_NO_SUSPEND, dev_name(dev), scmi_info);if (ret) {dev_err (dev,"failed to setup SCMI smc irq\n" ); + cinfo->transport_info =NULL ; + scmi_info->cinfo =NULL ;return ret; } }else { cinfo->no_completion_irq = true; } - scmi_info->func_id = func_id; - scmi_info->cap_id = cap_id; - scmi_info->cinfo = cinfo; -smc_channel_lock_init (scmi_info); - cinfo->transport_info = scmi_info; -return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 394/1815 firmware: arm_scmi: Unregister device notifier before IDR teardown
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit 66a0bbf30cc14140fe13f63cd594a7c1ee352b75 ]
The requested-devices notifier looks up protocol fwnodes from the active_protocols IDR. During remove, unregister the notifier before releasing and destroying active_protocols so no notifier callback can race with the IDR teardown.
Keep the bus notifier registered until after the protocol state is torn down, matching the existing remove ordering for SCMI bus users.
--- drivers/firmware/arm_scmi/driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/firmware/arm_scmi/driver.c +3 -2
@@ -3401,6 +3401,9 @@ static void scmi_remove(struct platform_device *pdev)list_del (&info->node);mutex_unlock (&scmi_list_mutex); +blocking_notifier_chain_unregister (&scmi_requested_devices_nh, + &info->dev_req_nb); +scmi_notification_exit (&info->handle);mutex_lock (&info->protocols_mtx);
@@ -3411,8 +3414,6 @@ static void scmi_remove(struct platform_device *pdev)of_node_put (child);idr_destroy (&info->active_protocols); -blocking_notifier_chain_unregister (&scmi_requested_devices_nh, - &info->dev_req_nb);bus_unregister_notifier (&scmi_bus_type, &info->bus_nb);/* Safe to free channels since no more users */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 395/1815 firmware: arm_scmi: Quiesce notifications before teardown
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit 8e49055d0d495c9c07575ad8e111d9eaf0efb13f ]
scmi_notification_exit() clears and releases the notification instance, but transport callbacks can still deliver incoming notifications until the TX/RX channels are freed. During remove, an RX interrupt in that window can enter scmi_notify() while notification state is being torn down and then dereference freed memory. The same ordering exists on the probe error path after notification initialization.
The notification late-init worker has a separate lifetime issue: protocol event registration queues ni->init_work on the system workqueue, so destroying ni->notify_wq does not drain that work. If the devres group is released while init_work is still pending or running, the late-init worker can dereference the freed notification instance.
Quiesce the notification core before TX/RX channels are torn down, then clean up the channels before releasing the notification core resources. Use disable_work_sync() so future late-init queueing is rejected and any already queued or running late-init work has completed before channel teardown starts.
--- drivers/firmware/arm_scmi/driver.c | 13 +++++++------ drivers/firmware/arm_scmi/notify.c | 21 +++++++++++++++++++++ drivers/firmware/arm_scmi/notify.h | 1 + 3 files changed, 29 insertions(+), 6 deletions(-)
drivers/firmware/arm_scmi/driver.c +7 -6
@@ -3325,7 +3325,7 @@ static int scmi_probe(struct platform_device *pdev)dev_err (dev,"%s" , err_str);return 0 ; } - goto notification_exit; + goto raw_mode_cleanup; }mutex_lock (&scmi_list_mutex);
@@ -3367,17 +3367,18 @@ static int scmi_probe(struct platform_device *pdev)return 0 ; -notification_exit: +raw_mode_cleanup:if (IS_ENABLED (CONFIG_ARM_SCMI_RAW_MODE_SUPPORT ))scmi_raw_mode_cleanup (info->raw); -scmi_notification_exit (&info->handle); clear_dev_req_notifier:blocking_notifier_chain_unregister (&scmi_requested_devices_nh, &info->dev_req_nb); clear_bus_notifier:bus_unregister_notifier (&scmi_bus_type, &info->bus_nb); clear_txrx_setup: +scmi_notification_quiesce (&info->handle);scmi_cleanup_txrx_channels (info); +scmi_notification_exit (&info->handle); clear_ida:ida_free (&scmi_id, info->id);
@@ -3404,6 +3405,9 @@ static void scmi_remove(struct platform_device *pdev)blocking_notifier_chain_unregister (&scmi_requested_devices_nh, &info->dev_req_nb); +/* Stop transport callbacks before tearing down notifications. */ +scmi_notification_quiesce (&info->handle); +scmi_cleanup_txrx_channels (info);scmi_notification_exit (&info->handle);mutex_lock (&info->protocols_mtx);
@@ -3416,9 +3420,6 @@ static void scmi_remove(struct platform_device *pdev)bus_unregister_notifier (&scmi_bus_type, &info->bus_nb); -/* Safe to free channels since no more users */ -scmi_cleanup_txrx_channels (info); -ida_free (&scmi_id, info->id); }
drivers/firmware/arm_scmi/notify.c +21 -0
@@ -1706,6 +1706,25 @@ int scmi_notification_init(struct scmi_handle *handle)return -ENOMEM ; } +/** +* scmi_notification_quiesce() - Stop notification late initialization +* @handle: The handle identifying the platform instance to quiesce +* +* Prevent new late-init work from being queued and wait for any already queued +* or running late-init work to complete before transport channels are torn +* down. +*/ +void scmi_notification_quiesce (struct scmi_handle *handle) +{ +struct scmi_notify_instance *ni; + + ni =scmi_notification_instance_data_get (handle); +if (!ni) +return ; + +disable_work_sync (&ni->init_work); +} +/** * scmi_notification_exit() - Shutdown and clean Notification core * @handle: The handle identifying the platform instance to shutdown
@@ -1717,6 +1736,8 @@ void scmi_notification_exit(struct scmi_handle *handle) ni =scmi_notification_instance_data_get (handle);if (!ni)return ; + +scmi_notification_quiesce (handle);scmi_notification_instance_data_set (handle,NULL );/* Destroy while letting pending work complete */
drivers/firmware/arm_scmi/notify.h +1 -0
@@ -82,6 +82,7 @@ struct scmi_protocol_events { };int scmi_notification_init (struct scmi_handle *handle); +void scmi_notification_quiesce (struct scmi_handle *handle);void scmi_notification_exit (struct scmi_handle *handle); int scmi_register_protocol_events(const struct scmi_handle *handle, u8 proto_id, const struct scmi_protocol_handle *ph,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 396/1815 firmware: arm_scmi: Clean up channels on setup failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit 687d67be3d87894ef12e8a164434612e0b53cfae ]
scmi_channels_setup() can fail after the common BASE channel or earlier protocol channels have already been registered in the TX/RX IDRs.
Route this failure through the existing channel cleanup label so the transport channels, transport devices and IDR state created before the failure are released before the probe error path frees the SCMI instance ID.
--- drivers/firmware/arm_scmi/driver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/firmware/arm_scmi/driver.c +1 -2
@@ -3263,7 +3263,7 @@ static int scmi_probe(struct platform_device *pdev) ret =scmi_channels_setup (info);if (ret) { err_str ="failed to setup channels\n" ; - goto clear_ida; + goto clear_txrx_setup; } ret =bus_register_notifier (&scmi_bus_type, &info->bus_nb);
@@ -3379,7 +3379,6 @@ static int scmi_probe(struct platform_device *pdev)scmi_notification_quiesce (&info->handle);scmi_cleanup_txrx_channels (info);scmi_notification_exit (&info->handle); -clear_ida:ida_free (&scmi_id, info->id); out_err:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 397/1815 firmware: arm_scmi: Free transport channel on IDR failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit d72e7e5f24687c0490aabf317653caffe0447aeb ]
If transport channel setup succeeds but the following IDR insertion fails, the error path destroys the transport device and frees the channel info without invoking the transport cleanup callback.
Call chan_free() before destroying the device so transport specific resources such as IRQs, mailbox channels and mapped shared memory are released consistently with the normal teardown path.
--- drivers/firmware/arm_scmi/driver.c | 1 + 1 file changed, 1 insertion(+)
drivers/firmware/arm_scmi/driver.c +1 -0
@@ -2808,6 +2808,7 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node, "unable to allocate SCMI idr slot err %d\n", ret);/* Destroy channel and device only if created by this call. */ if (tdev) { + info->desc->ops->chan_free (prot_id, cinfo, idr);of_node_put (of_node);scmi_device_destroy (info->dev, prot_id, name);devm_kfree (info->dev, cinfo);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 398/1815 firmware: arm_scmi: Avoid IDR updates while cleaning channels
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit c38b1e19485aaa820e52cfe162525a8af67563da ]
scmi_cleanup_channels() walks the TX/RX channel IDRs with idr_for_each() to free transport resources and destroy the dedicated transport devices before calling idr_destroy().
The destroy callback removed each entry from the same IDR being walked. That is not needed for this cleanup path, and it is unsafe because idr_for_each() has not advanced its radix-tree iterator while the callback is running. Removing the current entry from the callback can invalidate the iterator state. The callback also cannot be protected by rcu_read_lock(), because scmi_device_destroy() may sleep.
Leave IDR teardown to the following idr_destroy() call and keep the callback limited to device destruction.
--- drivers/firmware/arm_scmi/driver.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/firmware/arm_scmi/driver.c +1 -3
@@ -2885,7 +2885,7 @@ static int scmi_channels_setup(struct scmi_info *info)return 0 ; } -static int scmi_chan_destroy (int id,void *p,void *idr) +static int scmi_chan_destroy (int id,void *p,void *data) {struct scmi_chan_info *cinfo = p;
@@ -2898,8 +2898,6 @@ static int scmi_chan_destroy(int id, void *p, void *idr) cinfo->dev =NULL ; } -idr_remove (idr, id); -return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 399/1815 firmware: arm_scmi: Reject out of range DT protocol IDs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit 59407ccb52130f2c81f4b3cbe4f14114afceb54f ]
SCMI protocol IDs carried in message headers are limited by MSG_PROTOCOL_ID_MASK. The DT parsing paths noticed protocol IDs outside that range, but only logged an error and then kept processing the invalid value.
That lets a malformed 32-bit DT reg value reach helpers which take a u8 protocol ID, where it can be truncated and/or treated as a different protocol.
For channel setup, two different out-of-range values can also be used as distinct IDR keys while aliasing the generated SCMI protocol identity.
Skip DT protocol nodes whose reg value does not fit the SCMI protocol ID field before setting up channels or creating protocol devices.
--- drivers/firmware/arm_scmi/driver.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/firmware/arm_scmi/driver.c +6 -2
@@ -2873,9 +2873,11 @@ static int scmi_channels_setup(struct scmi_info *info)if (of_property_read_u32 (child,"reg" , &prot_id))continue ; -if (!FIELD_FIT (MSG_PROTOCOL_ID_MASK , prot_id)) +if (!FIELD_FIT (MSG_PROTOCOL_ID_MASK , prot_id)) {dev_err (info->dev,"Out of range protocol %d\n" , prot_id); +continue ; + } ret =scmi_txrx_setup (info, child, prot_id);if (ret)
@@ -3339,8 +3341,10 @@ static int scmi_probe(struct platform_device *pdev)if (of_property_read_u32 (child,"reg" , &prot_id))continue ; -if (!FIELD_FIT (MSG_PROTOCOL_ID_MASK , prot_id)) +if (!FIELD_FIT (MSG_PROTOCOL_ID_MASK , prot_id)) {dev_err (dev,"Out of range protocol %d\n" , prot_id); +continue ; + }if (!scmi_is_protocol_implemented (handle, prot_id)) { dev_err(dev, "SCMI protocol %d not implemented\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 400/1815 firmware: arm_scmi: Use channel ID for transport teardown
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit a71a3d4d8a6e9e399fd988c0e6da47a6ee21c99e ]
SCMI protocols can share the BASE transport channel when firmware does not describe a dedicated channel for the protocol. In that case multiple IDR entries can point at the same scmi_chan_info, whose owning transport device was created with cinfo->id.
scmi_chan_destroy() used the IDR iterator key when destroying the transport device. If an alias entry is visited before the owning channel entry, the lookup can miss the device because the iterator key does not match the protocol ID used when the transport device was created. The code then clears cinfo->dev, so the later owning entry skips teardown and leaks the transport device.
Destroy the transport device using cinfo->id, which is the protocol ID that owns the channel and was used when creating the transport device.
--- drivers/firmware/arm_scmi/driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/arm_scmi/driver.c +1 -1
@@ -2896,7 +2896,7 @@ static int scmi_chan_destroy(int id, void *p, void *data)struct scmi_device *sdev =to_scmi_dev (cinfo->dev);of_node_put (cinfo->dev->of_node); -scmi_device_destroy (info->dev, id, sdev->name); +scmi_device_destroy (info->dev, cinfo->id, sdev->name); cinfo->dev =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 401/1815 firmware: arm_scmi: Protect device request lookup with RCU
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit e6a0e7a49d83e4fa4e1db68d74f99282eb97aa49 ]
The SCMI device request notifier looks up protocol OF nodes from the active_protocols IDR. The IDR lookup can run concurrently with protocol activation while probe is still registering protocols and creating their SCMI devices.
Wrap the lookup in an RCU read-side critical section as required by the IDR API for lockless readers.
--- drivers/firmware/arm_scmi/driver.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/firmware/arm_scmi/driver.c +3 -0
@@ -33,6 +33,7 @@#include <linux/of.h> #include <linux/platform_device.h> #include <linux/processor.h> +#include <linux/rcupdate.h> #include <linux/refcount.h> #include <linux/slab.h> #include <linux/xarray.h>
@@ -2958,7 +2959,9 @@ static int scmi_device_request_notifier(struct notifier_block *nb,struct scmi_device_id *id_table = data;struct scmi_info *info =req_nb_to_scmi_info (nb); +rcu_read_lock (); np =idr_find (&info->active_protocols, id_table->protocol_id); +rcu_read_unlock ();if (!np)return NOTIFY_DONE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 402/1815 firmware: arm_scmi: Drop handle on protocol bind failures
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit e3a5c30d233ca5d3e799a80da806554c703bda13 ]
The SCMI bus notifier acquires an SCMI handle when the driver core emits BUS_NOTIFY_BIND_DRIVER, before invoking the protocol driver probe callback. The protocol probe path only checks whether sdev->handle is set.
If device_link_add() fails after the handle has been acquired, the protocol device can still bind with a valid handle but without the dependency link to the SCMI parent. A concurrent parent unbind can then miss the child and tear down the SCMI instance while the child still holds a handle into it.
If the protocol driver probe later fails, for example with -EPROBE_DEFER, the driver core emits BUS_NOTIFY_DRIVER_NOT_BOUND rather than BUS_NOTIFY_UNBOUND_DRIVER. The SCMI notifier only released the handle on BUS_NOTIFY_UNBOUND_DRIVER, so each failed protocol-device bind leaked the SCMI instance users refcount and left sdev->handle set after the failed probe.
Make the link helper report failure and drop the acquired handle if the link cannot be created. Also handle BUS_NOTIFY_DRIVER_NOT_BOUND in the same cleanup path used for unbind so failed probes balance the earlier BUS_NOTIFY_BIND_DRIVER acquisition.
--- drivers/firmware/arm_scmi/driver.c | 31 ++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-)
drivers/firmware/arm_scmi/driver.c +23 -8
@@ -2629,21 +2629,31 @@ static int scmi_handle_put(const struct scmi_handle *handle)return 0 ; } -static void scmi_device_link_add (struct device *consumer, +static bool scmi_device_link_add (struct device *consumer,struct device *supplier) {struct device_link *link; link =device_link_add (consumer, supplier,DL_FLAG_AUTOREMOVE_CONSUMER ); -WARN_ON (!link); +return !WARN_ON (!link); +} + +static void scmi_clear_handle (struct scmi_device *scmi_dev) +{ +if (!scmi_dev->handle) +return ; + +scmi_handle_put (scmi_dev->handle); + scmi_dev->handle =NULL ; }static void scmi_set_handle (struct scmi_device *scmi_dev) { scmi_dev->handle =scmi_handle_get (&scmi_dev->dev); -if (scmi_dev->handle) -scmi_device_link_add (&scmi_dev->dev, scmi_dev->handle->dev); +if (scmi_dev->handle && + !scmi_device_link_add (&scmi_dev->dev, scmi_dev->handle->dev)) +scmi_clear_handle (scmi_dev); } static int __scmi_xfer_info_init(struct scmi_info *sinfo,
@@ -2927,6 +2937,7 @@ static int scmi_bus_notifier(struct notifier_block *nb, {struct scmi_info *info =bus_nb_to_scmi_info (nb);struct scmi_device *sdev =to_scmi_dev (data); +const char *status;/* Skip devices of different SCMI instances */ if (sdev->dev.parent != info->dev)
@@ -2936,18 +2947,22 @@ static int scmi_bus_notifier(struct notifier_block *nb,case BUS_NOTIFY_BIND_DRIVER :/* setup handle now as the transport is ready */ scmi_set_handle (sdev); + status ="about to be BOUND." ; +break ; +case BUS_NOTIFY_DRIVER_NOT_BOUND : +scmi_clear_handle (sdev); + status ="NOT BOUND." ;break ;case BUS_NOTIFY_UNBOUND_DRIVER : -scmi_handle_put (sdev->handle); - sdev->handle =NULL ; +scmi_clear_handle (sdev); + status ="UNBOUND." ;break ;default :return NOTIFY_DONE ; }dev_dbg (info->dev,"Device %s (%s) is now %s\n" ,dev_name (&sdev->dev), - sdev->name, action ==BUS_NOTIFY_BIND_DRIVER ? -"about to be BOUND." :"UNBOUND." ); + sdev->name, status);return NOTIFY_OK ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 403/1815 firmware: arm_scmi: Clear SystemPower flag on create failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit e4c16ae24ca027d7a72d645b42f976bb3e99b4b0 ]
__scmi_device_create() reserves the singleton SystemPower protocol device before registering the SCMI device. If any later step fails, a stale reservation can make a later retry reject SystemPower device creation permanently, for example after probe deferral.
A plain global boolean is not enough to track the reservation. A delayed final release of an older SystemPower device could clear the boolean after a newer device has already claimed it, breaking the singleton guarantee for the active device.
Track the reservation with the scmi_device pointer itself. Claim it with cmpxchg(NULL, scmi_dev) after allocating the device object, and release it with cmpxchg(scmi_dev, NULL) from the common cleanup helper. This lets the create-failure, explicit destroy and final release paths clear only the reservation owned by the device being cleaned up.
--- drivers/firmware/arm_scmi/bus.c | 59 ++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 27 deletions(-)
drivers/firmware/arm_scmi/bus.c +32 -27
@@ -7,7 +7,6 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt -#include <linux/atomic.h> #include <linux/types.h> #include <linux/module.h> #include <linux/of.h>
@@ -33,8 +32,8 @@ struct scmi_requested_dev {struct list_head node; }; -/* Track globally the creation of SCMI SystemPower related devices */ -static atomic_t scmi_syspower_registered =ATOMIC_INIT (0 ); +/* Track globally the SCMI SystemPower protocol device. */ +static struct scmi_device *scmi_syspower_registered;/** * scmi_protocol_device_request - Helper to request a device
@@ -391,10 +390,17 @@ void scmi_driver_unregister(struct scmi_driver *driver) }EXPORT_SYMBOL_GPL (scmi_driver_unregister); +static void scmi_device_release_syspower (struct scmi_device *scmi_dev) +{ +if (scmi_dev->protocol_id ==SCMI_PROTOCOL_SYSTEM ) +cmpxchg (&scmi_syspower_registered, scmi_dev,NULL ); +} +static void scmi_device_release (struct device *dev) {struct scmi_device *scmi_dev =to_scmi_dev (dev); +scmi_device_release_syspower (scmi_dev);kfree_const (scmi_dev->name);kfree (scmi_dev); }
@@ -406,9 +412,7 @@ static void __scmi_device_destroy(struct scmi_device *scmi_dev)dev_name (&scmi_dev->dev), scmi_dev->protocol_id, scmi_dev->name); -if (scmi_dev->protocol_id ==SCMI_PROTOCOL_SYSTEM ) -atomic_set (&scmi_syspower_registered,0 ); - +scmi_device_release_syspower (scmi_dev);ida_free (&scmi_bus_id, scmi_dev->id);device_unregister (&scmi_dev->dev); }
@@ -419,6 +423,7 @@ __scmi_device_create(struct device_node *np, struct device *parent, {int id, retval;struct scmi_device *scmi_dev; +bool syspower = (protocol ==SCMI_PROTOCOL_SYSTEM );/* * If the same protocol/name device already exist under the same parent
@@ -431,39 +436,33 @@ __scmi_device_create(struct device_node *np, struct device *parent,if (scmi_dev)return scmi_dev; + scmi_dev =kzalloc_obj (*scmi_dev); +if (!scmi_dev) +return NULL ; + + scmi_dev->protocol_id = protocol; +/* -* Ignore any possible subsequent failures while creating the device -* since we are doomed anyway at that point; not using a mutex which -* spans across this whole function to keep things simple and to avoid -* to serialize all the __scmi_device_create calls across possibly -* different SCMI server instances (parent) +* Reserve the singleton SystemPower protocol device using the device +* pointer itself, so delayed release of an older device cannot clear +* a reservation owned by a newer device. */ -if (protocol ==SCMI_PROTOCOL_SYSTEM && -atomic_cmpxchg (&scmi_syspower_registered,0 ,1 )) { +if (syspower &&cmpxchg (&scmi_syspower_registered,NULL , scmi_dev)) {dev_warn (parent,"SCMI SystemPower protocol device must be unique !\n" ); +kfree (scmi_dev);return NULL ; } - scmi_dev =kzalloc_obj (*scmi_dev); -if (!scmi_dev) -return NULL ; - scmi_dev->name =kstrdup_const (name ?:"unknown" ,GFP_KERNEL ); -if (!scmi_dev->name) { -kfree (scmi_dev); -return NULL ; - } +if (!scmi_dev->name) + goto free_dev; id =ida_alloc_min (&scmi_bus_id,1 ,GFP_KERNEL ); -if (id <0 ) { -kfree_const (scmi_dev->name); -kfree (scmi_dev); -return NULL ; - } +if (id <0 ) + goto free_name; scmi_dev->id = id; - scmi_dev->protocol_id = protocol; scmi_dev->dev.parent = parent;device_set_node (&scmi_dev->dev,of_fwnode_handle (np)); scmi_dev->dev.bus = &scmi_bus_type;
@@ -482,6 +481,12 @@ __scmi_device_create(struct device_node *np, struct device *parent,put_device (&scmi_dev->dev);ida_free (&scmi_bus_id, id);return NULL ; +free_name: +kfree_const (scmi_dev->name); +free_dev: +scmi_device_release_syspower (scmi_dev); +kfree (scmi_dev); +return NULL ; } static struct scmi_device *
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 404/1815 firmware: arm_scmi: Fix OF node reference handling
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit 659705f5eb378cea462214b74bdc6240cdab53fc ]
SCMI devices store the DT node in dev.of_node through device_set_node(), but that helper only assigns the fwnode and of_node pointers without taking an OF node reference.
Take a reference when assigning the node and release it from the SCMI device release path. With the device owning that reference, remove the separate channel-side get/put pair from the core driver.
--- drivers/firmware/arm_scmi/bus.c | 3 ++- drivers/firmware/arm_scmi/driver.c | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/firmware/arm_scmi/bus.c +2 -1
@@ -401,6 +401,7 @@ static void scmi_device_release(struct device *dev)struct scmi_device *scmi_dev =to_scmi_dev (dev);scmi_device_release_syspower (scmi_dev); +of_node_put (dev->of_node);kfree_const (scmi_dev->name);kfree (scmi_dev); }
@@ -464,7 +465,7 @@ __scmi_device_create(struct device_node *np, struct device *parent, scmi_dev->id = id; scmi_dev->dev.parent = parent; -device_set_node (&scmi_dev->dev,of_fwnode_handle (np)); +device_set_node (&scmi_dev->dev,of_fwnode_handle (of_node_get (np))); scmi_dev->dev.bus = &scmi_bus_type; scmi_dev->dev.release = scmi_device_release;dev_set_name (&scmi_dev->dev,"scmi_dev.%d" , id);
drivers/firmware/arm_scmi/driver.c +0 -4
@@ -2789,14 +2789,12 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node,devm_kfree (info->dev, cinfo);return -EINVAL ; } -of_node_get (of_node); cinfo->id = prot_id; cinfo->dev = &tdev->dev; cinfo->handle = &info->handle; ret = info->desc->ops->chan_setup (cinfo, info->dev, tx);if (ret) { -of_node_put (of_node);scmi_device_destroy (info->dev, prot_id, name);devm_kfree (info->dev, cinfo);return ret;
@@ -2820,7 +2818,6 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node,/* Destroy channel and device only if created by this call. */ if (tdev) { info->desc->ops->chan_free (prot_id, cinfo, idr); -of_node_put (of_node);scmi_device_destroy (info->dev, prot_id, name);devm_kfree (info->dev, cinfo); }
@@ -2906,7 +2903,6 @@ static int scmi_chan_destroy(int id, void *p, void *data)struct scmi_info *info =handle_to_scmi_info (cinfo->handle);struct scmi_device *sdev =to_scmi_dev (cinfo->dev); -of_node_put (cinfo->dev->of_node);scmi_device_destroy (info->dev, cinfo->id, sdev->name); cinfo->dev =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 405/1815 firmware: arm_scmi: Unwind TX receiver mailbox setup failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit 6f7c06744d53dc8e047725d411d7f915d9ec35ae ]
mailbox_chan_setup() can request an additional unidirectional TX receiver channel after successfully acquiring the primary channel. If that second request fails, the function returns immediately and leaves the primary channel allocated.
Unwind the primary mailbox channel before returning the error so probe deferral or other setup failures do not leave the channel busy for later probe attempts.
--- drivers/firmware/arm_scmi/transports/mailbox.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/firmware/arm_scmi/transports/mailbox.c +4 -1
@@ -230,9 +230,10 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, smbox->chan_receiver =mbox_request_channel (cl, a2p_rx_chan);if (IS_ERR (smbox->chan_receiver)) { ret =PTR_ERR (smbox->chan_receiver); + smbox->chan_receiver =NULL ;if (ret != -EPROBE_DEFER )dev_err (cdev,"failed to request SCMI Tx Receiver mailbox\n" ); -return ret; + goto err_free_chan; } }
@@ -248,6 +249,8 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,return 0 ; +err_free_chan: +mbox_free_channel (smbox->chan); err_clear_cinfo: cinfo->transport_info =NULL ; smbox->cinfo =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 406/1815 firmware: arm_scmi: Unwind P2A receiver mailbox setup failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit f3e3773c4e5e96549d7540d8ddeb4fcd534f6f1d ]
mailbox_chan_setup() can request an additional P2A receiver channel after successfully acquiring the primary P2A channel. If that later request fails, the function returns immediately and leaves the primary channel allocated.
Unwind the primary mailbox channel before returning the error so probe deferral or other setup failures do not leave the channel busy for later probe attempts.
--- drivers/firmware/arm_scmi/transports/mailbox.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/firmware/arm_scmi/transports/mailbox.c +2 -1
@@ -241,9 +241,10 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, smbox->chan_platform_receiver =mbox_request_channel (cl, p2a_rx_chan);if (IS_ERR (smbox->chan_platform_receiver)) { ret =PTR_ERR (smbox->chan_platform_receiver); + smbox->chan_platform_receiver =NULL ;if (ret != -EPROBE_DEFER )dev_err (cdev,"failed to request SCMI P2A Receiver mailbox\n" ); -return ret; + goto err_free_chan; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 407/1815 firmware: arm_scmi: Fix SCMI device destroy lifetimes
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit 6abe8fe36b29ff51d1a42c2f338972883f4751a5 ]
scmi_child_dev_find() drops the reference returned by device_find_child() before returning the scmi_device pointer. A concurrent unregister can then release the device while the destroy path is still using the returned pointer.
Make the lookup helper return the device_find_child() reference and keep it until scmi_device_destroy() has finished unregistering the child.
Also split device_unregister() in __scmi_device_destroy() so the SCMI bus ID is not made reusable until after device_del() has removed the old scmi_dev.N name from sysfs. This avoids a new SCMI device reusing the same ID while the old device is still registered.
The final device release callback is also a possible cleanup path when SCMI children are deleted by driver core recursion rather than __scmi_device_destroy(). Release the SCMI bus ID from a common helper used by destroy, register-failure and final-release paths, and clear scmi_dev->id after freeing it so the final release cannot free the same ID again.
--- drivers/firmware/arm_scmi/bus.c | 39 +++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 16 deletions(-)
drivers/firmware/arm_scmi/bus.c +23 -16
@@ -237,8 +237,9 @@ static int scmi_match_by_id_table(struct device *dev, const void *data)return scmi_dev_match_by_id_table (scmi_dev, id_table); } -static struct scmi_device *scmi_child_dev_find (struct device *parent, -int prot_id,const char *name) +/* Returns a device_find_child() reference which must be dropped by caller. */ +static struct scmi_device * +scmi_child_dev_find_get (struct device *parent,int prot_id,const char *name) {struct scmi_device_id id_table[2 ] = {0 };struct device *dev;
@@ -250,9 +251,6 @@ static struct scmi_device *scmi_child_dev_find(struct device *parent,if (!dev)return NULL ; -/* Drop the refcnt bumped implicitly by device_find_child */ -put_device (dev); -return to_scmi_dev (dev); }
@@ -390,17 +388,22 @@ void scmi_driver_unregister(struct scmi_driver *driver) }EXPORT_SYMBOL_GPL (scmi_driver_unregister); -static void scmi_device_release_syspower (struct scmi_device *scmi_dev) +static void scmi_device_release_resources (struct scmi_device *scmi_dev) {if (scmi_dev->protocol_id ==SCMI_PROTOCOL_SYSTEM )cmpxchg (&scmi_syspower_registered, scmi_dev,NULL ); + +if (scmi_dev->id) { +ida_free (&scmi_bus_id, scmi_dev->id); + scmi_dev->id =0 ; + } }static void scmi_device_release (struct device *dev) {struct scmi_device *scmi_dev =to_scmi_dev (dev); -scmi_device_release_syspower (scmi_dev); +scmi_device_release_resources (scmi_dev);of_node_put (dev->of_node);kfree_const (scmi_dev->name);kfree (scmi_dev);
@@ -413,9 +416,9 @@ static void __scmi_device_destroy(struct scmi_device *scmi_dev)dev_name (&scmi_dev->dev), scmi_dev->protocol_id, scmi_dev->name); -scmi_device_release_syspower (scmi_dev); -ida_free (&scmi_bus_id, scmi_dev->id); -device_unregister (&scmi_dev->dev); +device_del (&scmi_dev->dev); +scmi_device_release_resources (scmi_dev); +put_device (&scmi_dev->dev); } static struct scmi_device *
@@ -433,9 +436,11 @@ __scmi_device_create(struct device_node *np, struct device *parent,* each DT defined protocol at probe time, and the concurrent * registration of SCMI drivers. */ - scmi_dev =scmi_child_dev_find (parent, protocol, name); -if (scmi_dev) + scmi_dev =scmi_child_dev_find_get (parent, protocol, name); +if (scmi_dev) { +put_device (&scmi_dev->dev);return scmi_dev; + } scmi_dev =kzalloc_obj (*scmi_dev);if (!scmi_dev)
@@ -479,13 +484,13 @@ __scmi_device_create(struct device_node *np, struct device *parent,return scmi_dev; put_dev: +scmi_device_release_resources (scmi_dev);put_device (&scmi_dev->dev); -ida_free (&scmi_bus_id, id);return NULL ; free_name:kfree_const (scmi_dev->name); free_dev: -scmi_device_release_syspower (scmi_dev); +scmi_device_release_resources (scmi_dev);kfree (scmi_dev);return NULL ; }
@@ -567,9 +572,11 @@ void scmi_device_destroy(struct device *parent, int protocol, const char *name) {struct scmi_device *scmi_dev; - scmi_dev =scmi_child_dev_find (parent, protocol, name); -if (scmi_dev) + scmi_dev =scmi_child_dev_find_get (parent, protocol, name); +if (scmi_dev) {__scmi_device_destroy (scmi_dev); +put_device (&scmi_dev->dev); + } }EXPORT_SYMBOL_GPL (scmi_device_destroy);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 408/1815 firmware: arm_scmi: Fix transport device teardown lookup
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit a14dd8fe0a95db638c550ed984cfe2a7428c783d ]
SCMI transport devices are deliberately excluded from normal SCMI bus matching so protocol drivers cannot bind to the internal transport children. However, scmi_device_destroy() uses the same protocol/name lookup to find devices that must be unregistered during channel teardown.
Split the match helper so driver matching still skips transport devices, while explicit child lookup can find them for teardown. Use a shared transport-device name prefix macro for both matching and name generation.
Since transport-device names are derived from direction and protocol ID, reject duplicate protocol channel setup before creating or finding a transport device. This prevents malformed firmware with duplicate protocol child nodes from reusing an existing transport device and then destroying it when the duplicate IDR insertion fails.
--- drivers/firmware/arm_scmi/bus.c | 22 +++++++++++++++++----- drivers/firmware/arm_scmi/common.h | 2 ++ drivers/firmware/arm_scmi/driver.c | 5 ++++- 3 files changed, 23 insertions(+), 6 deletions(-)
drivers/firmware/arm_scmi/bus.c +17 -5
@@ -200,21 +200,33 @@ scmi_protocol_table_unregister(const struct scmi_device_id *id_table)scmi_protocol_device_unrequest (entry); } -static int scmi_dev_match_by_id_table (struct scmi_device *scmi_dev, -const struct scmi_device_id *id_table) +static bool scmi_device_is_transport (const struct scmi_device *scmi_dev) +{ +return !strncmp (scmi_dev->name,SCMI_TRANSPORT_DEVNAME_PREFIX , +strlen (SCMI_TRANSPORT_DEVNAME_PREFIX )); +} + +static int __scmi_dev_match_by_id_table (struct scmi_device *scmi_dev, +const struct scmi_device_id *id_table, +bool skip_transport) {if (!id_table || !id_table->name)return 0 ; -/* Always skip transport devices from matching */ for (; id_table->protocol_id && id_table->name; id_table++)if (id_table->protocol_id == scmi_dev->protocol_id && -strncmp (scmi_dev->name,"__scmi_transport_device" ,23 ) && + !(skip_transport &&scmi_device_is_transport (scmi_dev)) && !strcmp (id_table->name, scmi_dev->name))return 1 ;return 0 ; } +static int scmi_dev_match_by_id_table (struct scmi_device *scmi_dev, +const struct scmi_device_id *id_table) +{ +return __scmi_dev_match_by_id_table (scmi_dev, id_table, true); +} +static int scmi_dev_match_id (struct scmi_device *scmi_dev,const struct scmi_driver *scmi_drv) {
@@ -234,7 +246,7 @@ static int scmi_match_by_id_table(struct device *dev, const void *data)struct scmi_device *scmi_dev =to_scmi_dev (dev);const struct scmi_device_id *id_table = data; -return scmi_dev_match_by_id_table (scmi_dev, id_table); +return __scmi_dev_match_by_id_table (scmi_dev, id_table, false); }/* Returns a device_find_child() reference which must be dropped by caller. */
drivers/firmware/arm_scmi/common.h +2 -0
@@ -34,6 +34,8 @@#define SCMI_SHMEM_MAX_PAYLOAD_SIZE 104 +#define SCMI_TRANSPORT_DEVNAME_PREFIX "__scmi_transport_device" +enum scmi_error_codes {SCMI_SUCCESS =0 ,/* Success */ SCMI_ERR_SUPPORT =-1 ,/* Not supported */
drivers/firmware/arm_scmi/driver.c +4 -1
@@ -2762,6 +2762,9 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node, idx = tx ?0 :1 ; idr = tx ? &info->tx_idr : &info->rx_idr; +if (idr_find (idr, prot_id)) +return -EEXIST ; +if (!info->desc->ops->chan_available (of_node, idx)) { cinfo =idr_find (idr,SCMI_PROTOCOL_BASE );if (unlikely (!cinfo))/* Possible only if platform has no Rx */
@@ -2779,7 +2782,7 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node, cinfo->no_completion_irq = info->desc->no_completion_irq;/* Create a unique name for this transport device */ -snprintf (name,32 ,"__scmi_transport_device_%s_%02X" , +snprintf (name,sizeof (name),SCMI_TRANSPORT_DEVNAME_PREFIX "_%s_%02X" , idx ?"rx" :"tx" , prot_id);/* Create a uniquely named, dedicated transport device for this chan */ tdev =scmi_device_create (of_node, info->dev, prot_id, name);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 409/1815 cxl/features: Reject Get Feature count larger than the output buffer
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Cheng <[email protected]>
[ Upstream commit 4bf6bac375076ced2fa4b3fef8739bd985f93456 ]
cxlctl_get_feature() sizes its output buffer from the user's fwctl_rpc.out_len, but the device is told to write cxl_mbox_get_feat_in.count bytes into rpc_out->payload, which is a separate user-controlled value. Nothing bounds count against out_len, so a small out_len with a large count overflows the kvzalloc()'d buffer. A heap OOB write reachable from FWCTL_RPC.
Reject requests where count exceeds the available payload room, before allocating.
--- drivers/cxl/core/features.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/cxl/core/features.c +4 -0
@@ -474,6 +474,10 @@ static void *cxlctl_get_feature(struct cxl_features_state *cxlfs,if (!count)return ERR_PTR (-EINVAL ); +if (out_size < offsetof(struct fwctl_rpc_cxl_out , payload) || + count > out_size - offsetof(struct fwctl_rpc_cxl_out , payload)) +return ERR_PTR (-EINVAL ); + struct fwctl_rpc_cxl_out *rpc_out __free(kvfree) =kvzalloc (out_size,GFP_KERNEL );if (!rpc_out)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 410/1815 cxl/features: Reject Set Features output buffer smaller than the header
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Cheng <[email protected]>
[ Upstream commit cde18d6c1d913a67ab0afd3d9475ece4be79da50 ]
cxlctl_set_feature() sizes its output buffer from the user's fwctl_rpc.out_len but never checks it is large enough to hold even the fwctl_rpc_cxl_out header. With out_len == 0 , kvzalloc() returns ZERO_SIZE_PTR, which passes the !rpc_out check, the subsequent rpc_out->size = 0 then writes through the poison pointer.
Reject requests whose output buffer can't hold the response header, before allocating. The Set Feature reply carries no payload, so the header is all that is required.
--- drivers/cxl/core/features.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/cxl/core/features.c +3 -0
@@ -523,6 +523,9 @@ static void *cxlctl_set_feature(struct cxl_features_state *cxlfs, flags =le32_to_cpu (feat_in->flags); out_size = *out_len; +if (out_size < offsetof(struct fwctl_rpc_cxl_out , payload)) +return ERR_PTR (-EINVAL ); + struct fwctl_rpc_cxl_out *rpc_out __free(kvfree) =kvzalloc (out_size,GFP_KERNEL );if (!rpc_out)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 411/1815 cxl/features: Clamp Get Feature output size to the remaining buffer
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Cheng <[email protected]>
[ Upstream commit 2aeb21fe557ef154f0cdf4f9745ebd8d5b31ca83 ]
cxl_get_feature() reads a feature in a loop but passes a fixed size_out as the output capacity every iteration. On the last partial iteration the buffer has less room left, so a device that returns more than asked can overflow feat_out.
Use the per-iter size data_to_rd_size, which already tracks the remaining room, as the output capacity.
--- drivers/cxl/core/features.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/cxl/core/features.c +2 -3
@@ -225,7 +225,7 @@ size_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, void *feat_out, size_t feat_out_size, u16 offset, u16 *return_code) { - size_t data_to_rd_size, size_out; + size_t data_to_rd_size;struct cxl_mbox_get_feat_in pi;struct cxl_mbox_cmd mbox_cmd;size_t data_rcvd_size =0 ;
@@ -237,7 +237,6 @@ size_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,if (!feat_out || !feat_out_size)return 0 ; - size_out =min (feat_out_size, cxl_mbox->payload_size);uuid_copy (&pi.uuid, feat_uuid); pi.selection = selection;
@@ -252,7 +251,7 @@ size_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, .opcode = CXL_MBOX_OP_GET_FEATURE, .size_in = sizeof(pi), .payload_in = &pi, - .size_out = size_out, + .size_out = data_to_rd_size, .payload_out = feat_out + data_rcvd_size, .min_out = data_to_rd_size, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 412/1815 regulator: adp5055: Fix error code in adp5055_of_parse_cb()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 153bc959ce0f91b4446fb6fb805b8c1d2ca20c75 ]
This code accidentally returned the wrong variable instead of a negative error code. Return -EINVAL.
--- drivers/regulator/adp5055-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/adp5055-regulator.c +1 -1
@@ -224,7 +224,7 @@ static int adp5055_of_parse_cb(struct device_node *np, adp5055->dvs_limit_upper[id] = pval;if (adp5055->dvs_limit_upper[id] >192000 || adp5055->dvs_limit_upper[id] <12000 ) -return dev_err_probe (config->dev, adp5055->dvs_limit_upper[id], +return dev_err_probe (config->dev, -EINVAL ,"Out of range - dvs-limit-upper-microvolt value." ); ret =of_property_read_u32 (np,"adi,dvs-limit-lower-microvolt" , &pval);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 413/1815 tools/sched_ext: scx_qmap: Fix stale API name in comment
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liang Luo <[email protected]>
[ Upstream commit 35f9cbbacb671e587c84e992e7b0098c39e895a4 ]
The comment above dispatch_highpri() still references scx_bpf_dispatch[_vtime]_from_dsq(), which was renamed to scx_bpf_dsq_move[_vtime]() in v6.13 to unload the overloaded "dispatch" verb. The code below already uses the new names; only the comment was left behind during the rename.
--- tools/sched_ext/scx_qmap.bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/sched_ext/scx_qmap.bpf.c +1 -1
@@ -495,7 +495,7 @@ static void update_core_sched_head_seq(struct task_struct *p)* moving them to HIGHPRI_DSQ and then consuming them first. This makes minor * difference only when dsp_batch is larger than 1. * -* scx_bpf_dispatch[_vtime]_from_dsq() are allowed both from ops.dispatch() and +* scx_bpf_dsq_move[_vtime]() are allowed both from ops.dispatch() and * non-rq-lock holding BPF programs. As demonstration, this function is called * from qmap_dispatch() and monitor_timerfn(). */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 414/1815 libnvdimm/labels: Bound the on-media label size before the shift
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryam Vargas <[email protected]>
[ Upstream commit 18f9124248ed7a9da1c31973b629dceef76a9b0c ]
For a v1.2+ index, __nd_label_validate() computes the label size as 1 << (7 + nsindex[i]->labelsize), where labelsize is a u8 read from the label storage medium. A value of 25 or more makes the shift count reach or exceed the width of int -- undefined behavior -- and 24 already shifts into the sign bit. Only 0 (128-byte) and 1 (256-byte) are valid.
Reject a labelsize above 1 before the shift. The result was rejected by the following size comparison anyway, so this only removes the undefined shift on a crafted or corrupted medium; conforming labels are unaffected.
--- drivers/nvdimm/label.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/nvdimm/label.c +13 -2
@@ -145,10 +145,21 @@ static int __nd_label_validate(struct nvdimm_drvdata *ndd)/* label sizes larger than 128 arrived with v1.2 */ version =__le16_to_cpu (nsindex[i]->major) *100 +__le16_to_cpu (nsindex[i]->minor); -if (version >=102 ) +if (version >=102 ) { +/* +* labelsize feeds the shift below; only 0 (128-byte) +* and 1 (256-byte) are valid -- a larger value would +* overflow or exceed the width of int. +*/ +if (nsindex[i]->labelsize >1 ) { +dev_dbg (dev,"nsindex%d labelsize: %d invalid\n" , + i, nsindex[i]->labelsize); +continue ; + } labelsize =1 << (7 + nsindex[i]->labelsize); -else + }else { labelsize =128 ; + }if (labelsize !=sizeof_namespace_label (ndd)) { dev_dbg(dev, "nsindex%d labelsize %d invalid\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 415/1815 dax: fix misleading comment about share/index union in dax_folio_reset_order()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Groves <[email protected]>
[ Upstream commit 3fc3ebf40b5cf077829d8fc5c66ece5b4c6e66c7 ]
The comment in dax_folio_reset_order() claims that DAX maintains an invariant where folio->share != 0 only when folio->mapping == NULL, implying folio->share is zero whenever mapping is non-NULL. This is misleading because folio->share and folio->index are a union -- for non-shared folios with mapping != NULL, reading folio->share returns the file page offset (folio->index), which is typically non-zero.
Reword the comment to accurately describe the union aliasing: the assignment clears whichever interpretation of the union word is active (index for non-shared folios, share for shared folios), which is correct because the folio is being released in either case.
No functional change -- the code was already correct, only the justification was wrong.
--- fs/dax.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/dax.c +6 -6
@@ -392,12 +392,12 @@ int dax_folio_reset_order(struct folio *folio)int order =folio_order (folio);/* -* DAX maintains the invariant that folio->share != 0 only when -* folio->mapping == NULL (enforced by dax_folio_make_shared()). -* Equivalently: folio->mapping != NULL implies folio->share == 0. -* Callers ensure share has been decremented to zero before -* calling here, so unconditionally clearing both fields is -* correct. +* Clear the mapping and the index/share union word. folio->share +* and folio->index occupy the same union in struct folio. For +* non-shared folios (mapping != NULL), the union holds folio->index +* (file page offset); for shared folios (mapping == NULL), it holds +* folio->share (reference count). Either way, we are releasing the +* folio and both fields should be zeroed. */ folio->mapping =NULL ; folio->share =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 416/1815 dax/fsdev: fix multi-range offset in memory_failure handler
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Groves <[email protected]>
[ Upstream commit e0cb40c3c676786c92ddb7f891a928ce970d6244 ]
Fix memory_failure offset calculation for multi-range devices. The old code subtracted ranges[0].range.start from the faulting PFN's physical address, which produces an incorrect (inflated) logical offset when the PFN falls in ranges[1] or beyond due to physical gaps between ranges. Add fsdev_pfn_to_offset() to walk the range list and compute the correct device-linear byte offset relative to ranges[0].start (the device data start) -- the base the holder (xfs, famfs) maps from -- for both static and dynamic devices.
V5 walked the pagemap's immutable pgmap->ranges[] instead, to avoid reading the mutable dev_dax->ranges[] from this callback. That had a different problem: it regressed static devices, where pgmap->ranges[0].start can sit data_offset below the data start, so the reported offset came out data_offset too high and the holder would act on the wrong blocks. For dynamic devices the two arrays are identical, so pgmap->ranges[] only ever helped the dynamic case while breaking the static one. Walk dev_dax->ranges[] instead. (Richard Cheng spotted the static regression.)
Reading dev_dax->ranges[] here may race a concurrent krealloc() of the range array via sysfs (mapping_store(), under dax_region_rwsem, which this ->memory_failure callback does not hold). That exposure is pre-existing -- the original single-range code read dev_dax->ranges[0] locklessly as well -- so this patch does not make it worse; a proper fix (locking or snapshotting) belongs in a separate change.
--- drivers/dax/fsdev.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/dax/fsdev.c +16 -1
@@ -135,11 +135,26 @@ static void fsdev_clear_ops(void *data)* The core mm code in free_zone_device_folio() handles the wake_up_var() * directly for this memory type. */ +static u64 fsdev_pfn_to_offset (struct dev_dax *dev_dax,unsigned long pfn) +{ +phys_addr_t phys =PFN_PHYS (pfn); +u64 offset =0 ; + +for (int i =0 ; i < dev_dax->nr_range; i++) { +struct range *range = &dev_dax->ranges[i].range; + +if (phys >= range->start && phys <= range->end) +return offset + (phys - range->start); + offset +=range_len (range); + } +return -1ULL ; +} +static int fsdev_pagemap_memory_failure (struct dev_pagemap *pgmap,unsigned long pfn,unsigned long nr_pages,int mf_flags) {struct dev_dax *dev_dax = pgmap->owner; -u64 offset =PFN_PHYS (pfn) - dev_dax->ranges[0 ].range.start; +u64 offset =fsdev_pfn_to_offset (dev_dax, pfn);u64 len = nr_pages <<PAGE_SHIFT ; return dax_holder_notify_failure(dev_dax->dax_dev, offset,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 417/1815 dax/fsdev: clear vmemmap_shift when binding static pgmap
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Groves <[email protected]>
[ Upstream commit e0239229931faf9ca3367e3befcf16f77b2cd45b ]
Clear pgmap->vmemmap_shift for static DAX devices. When rebinding a static device from device_dax (which may set vmemmap_shift based on alignment) to fsdev_dax, the stale vmemmap_shift persists on the shared pgmap. Explicitly zero it before devm_memremap_pages() so the vmemmap is built for order-0 folios as fsdev requires.
--- drivers/dax/fsdev.c | 1 + 1 file changed, 1 insertion(+)
drivers/dax/fsdev.c +1 -0
@@ -237,6 +237,7 @@ static int fsdev_dax_probe(struct dev_dax *dev_dax) } pgmap = dev_dax->pgmap; + pgmap->vmemmap_shift =0 ; }else {size_t pgmap_size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 418/1815 dax/fsdev: dont leave a dangling dev_dax->pgmap on probe failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Groves <[email protected]>
[ Upstream commit caf906009d12cb21b934f1c4d17cedc6d469429f ]
After the dynamic path set dev_dax->pgmap, any later probe failure left dev_dax->pgmap dangling: devres frees the devm_kzalloc'd pgmap on probe failure, and subsequent probe attempts would hit the "dynamic-dax with pre-populated page map" check and fail permanently.
Factor pgmap acquisition out into fsdev_acquire_pgmap(), and defer the dev_dax->pgmap assignment until probe can no longer fail. A failed probe now never publishes the pointer at all, so there is nothing to unwind. This also matches kill_dev_dax(), which already clears the dynamic pgmap pointer on unbind: dev_dax->pgmap is now non-NULL only while the pgmap is actually valid.
Refactor suggested by Dave Jiang.
--- drivers/dax/fsdev.c | 77 ++++++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 28 deletions(-)
drivers/dax/fsdev.c +49 -28
@@ -219,47 +219,62 @@ static const struct file_operations fsdev_fops = { .release = fsdev_release, }; -static int fsdev_dax_probe (struct dev_dax *dev_dax) +/* +* Acquire the dev_pagemap for probe: the static (pre-populated) one if +* present, or a devm-allocated one for the dynamic case. Note that +* dev_dax->pgmap is not set here; fsdev_dax_probe() sets it only once +* probe succeeds, so a failed probe never leaves a dangling pointer +* to a devres-freed pgmap. +*/ +static struct dev_pagemap *fsdev_acquire_pgmap (struct dev_dax *dev_dax) { -struct dax_device *dax_dev = dev_dax->dax_dev;struct device *dev = &dev_dax->dev;struct dev_pagemap *pgmap; -struct inode *inode; -u64 data_offset =0 ; -struct cdev *cdev; -void *addr; -int rc, i; +size_t pgmap_size;if (static_dev_dax (dev_dax)) {if (dev_dax->nr_range >1 ) { -dev_warn (dev,"static pgmap / multi-range device conflict\n" ); -return -EINVAL ; +dev_warn (dev, +"static pgmap / multi-range device conflict\n" ); +return ERR_PTR (-EINVAL ); } pgmap = dev_dax->pgmap; pgmap->vmemmap_shift =0 ; - }else { -size_t pgmap_size; +return pgmap; + } -if (dev_dax->pgmap) { -dev_warn (dev,"dynamic-dax with pre-populated page map\n" ); -return -EINVAL ; - } +if (dev_dax->pgmap) { +dev_warn (dev,"dynamic-dax with pre-populated page map\n" ); +return ERR_PTR (-EINVAL ); + } - pgmap_size =struct_size (pgmap, ranges, dev_dax->nr_range -1 ); - pgmap =devm_kzalloc (dev, pgmap_size,GFP_KERNEL ); -if (!pgmap) -return -ENOMEM ; + pgmap_size =struct_size (pgmap, ranges, dev_dax->nr_range -1 ); + pgmap =devm_kzalloc (dev, pgmap_size,GFP_KERNEL ); +if (!pgmap) +return ERR_PTR (-ENOMEM ); - pgmap->nr_range = dev_dax->nr_range; - dev_dax->pgmap = pgmap; + pgmap->nr_range = dev_dax->nr_range; +for (int i =0 ; i < dev_dax->nr_range; i++) + pgmap->ranges[i] = dev_dax->ranges[i].range; -for (i =0 ; i < dev_dax->nr_range; i++) { -struct range *range = &dev_dax->ranges[i].range; +return pgmap; +} - pgmap->ranges[i] = *range; - } - } +static int fsdev_dax_probe (struct dev_dax *dev_dax) +{ +struct dax_device *dax_dev = dev_dax->dax_dev; +struct device *dev = &dev_dax->dev; +struct dev_pagemap *pgmap; +struct inode *inode; +u64 data_offset =0 ; +struct cdev *cdev; +void *addr; +int rc, i; + + pgmap =fsdev_acquire_pgmap (dev_dax); +if (IS_ERR (pgmap)) +return PTR_ERR (pgmap);for (i =0 ; i < dev_dax->nr_range; i++) {struct range *range = &dev_dax->ranges[i].range;
@@ -306,7 +321,7 @@ static int fsdev_dax_probe(struct dev_dax *dev_dax)/* Detect whether the data is at a non-zero offset into the memory */ if (pgmap->range.start != dev_dax->ranges[0 ].range.start) {u64 phys = dev_dax->ranges[0 ].range.start; -u64 pgmap_phys = dev_dax->pgmap[0 ].range.start; +u64 pgmap_phys = pgmap[0 ].range.start;if (!WARN_ON (pgmap_phys > phys)) data_offset = phys - pgmap_phys;
@@ -339,7 +354,13 @@ static int fsdev_dax_probe(struct dev_dax *dev_dax)return rc;run_dax (dax_dev); -return devm_add_action_or_reset (dev, fsdev_kill, dev_dax); + rc =devm_add_action_or_reset (dev, fsdev_kill, dev_dax); +if (rc) +return rc; + +/* Probe can no longer fail; expose the pgmap via dev_dax */ + dev_dax->pgmap = pgmap; +return 0 ; }static struct dax_device_driver fsdev_dax_driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 419/1815 dax/fsdev: clear pgmap ops and owner on unbind
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Groves <[email protected]>
[ Upstream commit f48884ac31b6bfc99f36b3f207b8c0cbe5d54bd7 ]
fsdev_dax_probe() sets pgmap->ops = &fsdev_pagemap_ops and pgmap->owner = dev_dax, but nothing ever clears them. For a dynamic device the pgmap is devm-allocated and freed on unbind, so this is harmless. For a static device the pgmap is the shared, long-lived one owned by the dax bus (kill_dev_dax() only NULLs dev_dax->pgmap for the non-static case), and device.c's probe sets only pgmap->type, never clearing ops/owner.
So after fsdev unbinds a static device the stale fsdev_pagemap_ops survives on the shared pgmap. If the device is then rebound to device_dax (MEMORY_DEVICE_GENERIC, which installs no ->memory_failure), or the fsdev_dax module is unloaded, a subsequent memory_failure on that pgmap dispatches through the stale -- and possibly freed -- handler.
Register a devm action that clears pgmap->ops and pgmap->owner on unbind, symmetric with setting them at probe, so the pgmap carries no fsdev state once fsdev is detached.
--- drivers/dax/fsdev.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/dax/fsdev.c +22 -0
@@ -127,6 +127,23 @@ static void fsdev_clear_ops(void *data)dax_set_ops (dev_dax->dax_dev,NULL ); } +static void fsdev_clear_pgmap_ops (void *data) +{ +struct dev_pagemap *pgmap = data; + +/* +* fsdev installs pgmap->ops and ->owner at probe. For a static device +* the pgmap is shared and long-lived (owned by the dax bus), so +* leaving fsdev's ops behind on unbind would let a later +* memory_failure -- after rebind to another driver, or after this +* module is unloaded -- dispatch through a stale or freed +* ->memory_failure handler. Clear them so the pgmap carries no fsdev +* state once we are unbound. +*/ + pgmap->ops =NULL ; + pgmap->owner =NULL ; +} +/* * Page map operations for FS-DAX mode * Similar to fsdax_pagemap_ops in drivers/nvdimm/pmem.c
@@ -306,6 +323,11 @@ static int fsdev_dax_probe(struct dev_dax *dev_dax)if (IS_ERR (addr))return PTR_ERR (addr); +/* Drop fsdev's pgmap->ops/owner on unbind so no stale ops survive. */ + rc =devm_add_action_or_reset (dev, fsdev_clear_pgmap_ops, pgmap); +if (rc) +return rc; +/* * Clear any stale compound folio state left over from a previous * driver (e.g., device_dax with vmemmap_shift). Also register this
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 420/1815 dax/fsdev: use __va(phys) for kaddr in direct_access
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Groves <[email protected]>
[ Upstream commit ff7c73fca793bd5c29a15ba735b0886f62f3a840 ]
Use __va(phys) instead of virt_addr + linear_offset for the kaddr return in __fsdev_dax_direct_access(). The previous code added a device-linear byte offset to virt_addr (which is __va of ranges[0]), but for multi-range devices with physical gaps between ranges, this linear arithmetic crosses the gap and produces a wrong kernel virtual address. Using __va(phys) where phys comes from dax_pgoff_to_phys() is correct for any range layout because the direct map translates each physical address independently.
This leaves dev_dax->virt_addr write-only, so remove the field (suggested by Dave Jiang).
--- drivers/dax/dax-private.h | 2 -- drivers/dax/fsdev.c | 8 ++------ 2 files changed, 2 insertions(+), 8 deletions(-)
drivers/dax/dax-private.h +0 -2
@@ -69,7 +69,6 @@ struct dev_dax_range {* data while the device is activated in the driver. * @region: parent region * @dax_dev: core dax functionality -* @virt_addr: kva from memremap; used by fsdev_dax * @cached_size: size of daxdev cached by fsdev_dax * @align: alignment of this instance * @target_node: effective numa node if dev_dax memory range is onlined
@@ -85,7 +84,6 @@ struct dev_dax_range {struct dev_dax {struct dax_region *region;struct dax_device *dax_dev; -void *virt_addr;u64 cached_size;unsigned int align;int target_node;
drivers/dax/fsdev.c +2 -6
@@ -51,9 +51,7 @@ static long __fsdev_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff,struct dev_dax *dev_dax =dax_get_private (dax_dev);size_t size = nr_pages <<PAGE_SHIFT ;size_t offset = pgoff <<PAGE_SHIFT ; -void *virt_addr = dev_dax->virt_addr + offset;phys_addr_t phys; -unsigned long local_pfn; phys =dax_pgoff_to_phys (dev_dax, pgoff, size);if (phys ==-1 ) {
@@ -63,11 +61,10 @@ static long __fsdev_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, }if (kaddr) - *kaddr = virt_addr; + *kaddr =__va (phys); - local_pfn =PHYS_PFN (phys);if (pfn) - *pfn = local_pfn; + *pfn =PHYS_PFN (phys);/* * Use cached_size which was computed at probe time. The size cannot
@@ -351,7 +348,6 @@ static int fsdev_dax_probe(struct dev_dax *dev_dax)pr_debug ("%s: offset detected phys=%llx pgmap_phys=%llx offset=%llx\n" , __func__, phys, pgmap_phys, data_offset); } - dev_dax->virt_addr = addr + data_offset; inode =dax_inode (dax_dev); cdev = inode->i_cdev;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 421/1815 dax/fsdev: fail probe on invalid pgmap offset
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Groves <[email protected]>
[ Upstream commit 755effecd6fc7d8ff18f09135cb5e3cf98c20d55 ]
Convert the WARN_ON to a fatal error when pgmap_phys > phys. This condition means the remapped region starts after the device's data region, which is an impossible state. Previously the probe continued with data_offset=0, leaving virt_addr silently misaligned. Now probe returns -EINVAL with a diagnostic message.
--- drivers/dax/fsdev.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/dax/fsdev.c +6 -2
@@ -342,8 +342,12 @@ static int fsdev_dax_probe(struct dev_dax *dev_dax)u64 phys = dev_dax->ranges[0 ].range.start;u64 pgmap_phys = pgmap[0 ].range.start; -if (!WARN_ON (pgmap_phys > phys)) - data_offset = phys - pgmap_phys; +if (pgmap_phys > phys) { +dev_err (dev,"pgmap start %#llx exceeds data start %#llx\n" , + pgmap_phys, phys); +return -EINVAL ; + } + data_offset = phys - pgmap_phys;pr_debug ("%s: offset detected phys=%llx pgmap_phys=%llx offset=%llx\n" , __func__, phys, pgmap_phys, data_offset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 422/1815 dax: read holder_ops once in dax_holder_notify_failure()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Groves <[email protected]>
[ Upstream commit 7ae9d15bdcde0f2955ae13b6a95587f9e23b2359 ]
dax_holder_notify_failure() reads dax_dev->holder_ops twice without READ_ONCE() -- once for the NULL check and once for the indirect notify_failure() call. A concurrent fs_put_dax() can clear holder_ops between the two reads, so the check can observe a non-NULL pointer while the call dereferences NULL. (kill_dax() also clears holder_ops, but only after synchronize_srcu(), so it cannot race a reader that is inside dax_read_lock(); fs_put_dax() does no such synchronization.)
Fetch holder_ops once into a local with READ_ONCE() so the NULL check and the indirect call observe the same value.
--- drivers/dax/super.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/dax/super.c +10 -2
@@ -303,6 +303,7 @@ EXPORT_SYMBOL_GPL(dax_recovery_write);int dax_holder_notify_failure (struct dax_device *dax_dev,u64 off,u64 len,int mf_flags) { +const struct dax_holder_operations *ops;int rc, id; id =dax_read_lock ();
@@ -311,12 +312,19 @@ int dax_holder_notify_failure(struct dax_device *dax_dev, u64 off, goto out; } -if (!dax_dev->holder_ops) { +/* +* Read holder_ops once: a concurrent fs_put_dax() can clear it without +* synchronizing against readers. Without the single fetch the compiler +* could reload between the NULL check and the call and dereference a +* NULL ops. +*/ + ops =READ_ONCE (dax_dev->holder_ops); +if (!ops) { rc = -EOPNOTSUPP ; goto out; } - rc = dax_dev->holder_ops->notify_failure (dax_dev, off, len, mf_flags); + rc = ops->notify_failure (dax_dev, off, len, mf_flags); out:dax_read_unlock (id);return rc;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 423/1815 dax: fix holder_ops race in fs_put_dax()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Groves <[email protected]>
[ Upstream commit 7a6db2eb6d5da9ade0d4802e25bbec3342ae0187 ]
Clear holder_ops before holder_data so that a concurrent fs_dax_get() cannot have its newly installed holder_ops overwritten. cmpxchg() provides release ordering on weakly-ordered architectures, ensuring the WRITE_ONCE(holder_ops, NULL) store is visible to any CPU that observes the holder_data release.
Add a WARN_ON() that fires only when the cmpxchg observes a non-NULL value that is not @holder, i.e. fs_put_dax() called by something that is not the current holder. That is an API contract violation; the WARN_ON() does not prevent the damage but makes the bug visible.
A NULL cmpxchg result is deliberately tolerated: kill_dax() clears holder_data while a holder is still attached when a device is removed out from under a mounted filesystem (after delivering MF_MEM_PRE_REMOVE). The holder's subsequent fs_put_dax() - e.g. xfs_free_buftarg() after a forced shutdown - then legitimately finds holder_data already NULL, so warning on that case would turn supported device removal into a splat (or a panic with panic_on_warn).
Also add a kerneldoc comment documenting that fs_put_dax() must only be called by the current holder.
--- drivers/dax/super.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-)
drivers/dax/super.c +39 -3
@@ -116,11 +116,47 @@ EXPORT_SYMBOL_GPL(fs_dax_get_by_bdev);#if IS_ENABLED (CONFIG_FS_DAX ) +/** +* fs_put_dax() - release holder ownership of a dax_device +* @dax_dev: dax device to release (may be NULL) +* @holder: the holder pointer previously passed to fs_dax_get() or +* fs_dax_get_by_bdev(); must match exactly, as it is used +* in a cmpxchg to atomically release ownership +* +* Must only be called by the current holder. Clears holder_ops before +* holder_data to avoid a race where a concurrent fs_dax_get() could have +* its newly installed holder_ops overwritten. +*/ void fs_put_dax (struct dax_device *dax_dev,void *holder) { -if (dax_dev && holder && -cmpxchg (&dax_dev->holder_data, holder,NULL ) == holder) - dax_dev->holder_ops =NULL ; +if (dax_dev && holder) { +void *prev; + +/* +* Clear holder_ops before releasing holder_data. A concurrent +* dax_holder_notify_failure() that sees NULL ops returns +* -EOPNOTSUPP cleanly. A concurrent fs_dax_get() that acquires +* holder_data after the cmpxchg below is guaranteed to observe +* holder_ops=NULL first (cmpxchg provides release ordering), so +* its subsequent store of new ops will not be overwritten. +*/ +WRITE_ONCE (dax_dev->holder_ops,NULL ); + prev =cmpxchg (&dax_dev->holder_data, holder,NULL ); + +/* +* prev == holder: normal release. +* prev == NULL: already released by kill_dax() when the +* device was removed under a live holder; +* not a bug. +* prev != holder (non-NULL): fs_put_dax() called by something +* that is not the current holder; an API +* contract violation. A lock would be needed +* to guard against this, but we WARN_ON() +* instead since violating the contract is +* a bug. +*/ +WARN_ON (prev && prev != holder); + }put_dax (dax_dev); }EXPORT_SYMBOL_GPL (fs_put_dax);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 424/1815 cpufreq: spear: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 6a9e0e0f7592313ace66303cf5eca68e04c10f30 ]
The clk_get_parent() function doesn't return error pointers, it returns NULL on error. Update the error checking to match.
--- drivers/cpufreq/spear-cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/spear-cpufreq.c +2 -2
@@ -79,9 +79,9 @@ static int spear1340_set_cpu_rate(struct clk *sys_pclk, unsigned long newfreq)int ret =0 ; sys_clk =clk_get_parent (spear_cpufreq.clk); -if (IS_ERR (sys_clk)) { +if (!sys_clk) {pr_err ("failed to get cpu's parent (sys) clock\n" ); -return PTR_ERR (sys_clk); +return -EINVAL ; }/* Set the rate of the source clock before changing the parent */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 425/1815 PCI: xgene: Drop unnecessary OF node reference
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 4869db344e76c9adfb1d9654df442db5371fac71 ]
xgene_pcie_probe() stores dev->of_node in port->node with of_node_get(), but the cached node is only used during probe by xgene_pcie_parse_map_dma_ranges(). The driver never releases the extra reference, so the node reference is leaked.
There is no need for private OF node ownership here. Use the device's existing of_node directly in xgene_pcie_parse_map_dma_ranges() and remove the cached port->node pointer.
--- drivers/pci/controller/pci-xgene.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/pci/controller/pci-xgene.c +1 -4
@@ -58,7 +58,6 @@#define XGENE_PCIE_IP_VER_2 2struct xgene_pcie { -struct device_node *node;struct device *dev;struct clk *clk;void __iomem *csr_base;
@@ -526,7 +525,7 @@ static void xgene_pcie_setup_ib_reg(struct xgene_pcie *port,static int xgene_pcie_parse_map_dma_ranges (struct xgene_pcie *port) { -struct device_node *np = port->node; +struct device_node *np = port->dev->of_node;struct of_pci_range range;struct of_pci_range_parser parser;struct device *dev = port->dev;
@@ -612,7 +611,6 @@ static bool xgene_check_pcie_msi_ready(void)static int xgene_pcie_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct device_node *dn = dev->of_node;struct xgene_pcie *port;struct pci_host_bridge *bridge;int ret;
@@ -627,7 +625,6 @@ static int xgene_pcie_probe(struct platform_device *pdev) port =pci_host_bridge_priv (bridge); - port->node =of_node_get (dn); port->dev = dev; port->version =XGENE_PCIE_IP_VER_1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 426/1815 PCI: keystone: Fix OF node reference leak in init
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 3260336defeb292a91de29e4d1d93469e3cec663 ]
of_find_matching_node() returns a device node with its reference count incremented. ks_pcie_init() only uses the returned node to decide whether to register the ARM external abort fault handler, but never drops the reference.
Store the lookup result in a temporary variable and release it with of_node_put() once the existence check has been made.
--- drivers/pci/controller/dwc/pci-keystone.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pci-keystone.c +5 -1
@@ -1389,13 +1389,17 @@ static int ks_pcie_fault(unsigned long addr, unsigned int fsr,static int __init ks_pcie_init (void ) { +struct device_node *np;/* * PCIe access errors that result into OCP errors are caught by ARM as * "External aborts" */ -if (of_find_matching_node (NULL , ks_pcie_of_match)) + np =of_find_matching_node (NULL , ks_pcie_of_match); +if (np) { +of_node_put (np);hook_fault_code (17 , ks_pcie_fault,SIGBUS ,0 ,"Asynchronous external abort" ); + }return platform_driver_register (&ks_pcie_driver); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 427/1815 irqchip/renesas-irqc: Fix generic interrupt chip leak on remove
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingshuang Fu <[email protected]>
[ Upstream commit 616dd89d81ad9a3cf1cfff4088a4c43e4e00d6ba ]
The driver allocates domain generic chips probe. However, on driver removal, the generic chips are not automatically freed when the interrupt domain is removed because the domain flags do not include IRQ_DOMAIN_FLAG_DESTROY_GC.
This causes both the domain generic chips structure and the associated generic chips to be leaked. Additionally, the generic chips remain on the global list and may later be accessed by generic interrupt chip suspend, resume, or shutdown callbacks after the driver has been removed, potentially resulting in a use-after-free and kernel crash.
Fix the resource leak by setting IRQ_DOMAIN_FLAG_DESTROY_GC on the interrupt domain; this lets the interrupt domain core automatically release all generic chips when irq_domain_remove() is invoked, removing the need for manual cleanup calls in error paths and remove callback.
--- drivers/irqchip/irq-renesas-irqc.c | 1 + 1 file changed, 1 insertion(+)
drivers/irqchip/irq-renesas-irqc.c +1 -0
@@ -176,6 +176,7 @@ static int irqc_probe(struct platform_device *pdev) goto err_runtime_pm_disable; } + p->irq_domain->flags |=IRQ_DOMAIN_FLAG_DESTROY_GC ; ret =irq_alloc_domain_generic_chips (p->irq_domain, p->number_of_irqs,1 ,"irqc" , handle_level_irq,0 ,0 ,IRQ_GC_INIT_NESTED_LOCK );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 428/1815 media: ti: vpe: Select V4L2_FWNODE for VIP
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yemike Abhilash Chandra <[email protected]>
[ Upstream commit 46f563185b23443894c4d6aa86942851bda6f5dc ]
The VIP driver uses v4l2_fwnode_endpoint_parse() and the v4l2_async_nf_*() notifier APIs, but its Kconfig entry does not select V4L2_FWNODE. Hence kernel test robot reports:
vip.c:3236: undefined reference to v4l2_async_nf_unregister' vip.c:3237: undefined reference to v4l2_async_nf_cleanup' vip.c:3339: undefined reference to v4l2_fwnode_endpoint_parse' vip.c:3346: undefined reference to v4l2_async_nf_init' vip.c:3348: undefined reference to __v4l2_async_nf_add_fwnode' vip.c:3357: undefined reference to v4l2_async_nf_register'
Select V4L2_FWNODE, which in turn selects V4L2_ASYNC, providing all the missing symbols.
--- drivers/media/platform/ti/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/ti/Kconfig +1 -0
@@ -50,6 +50,7 @@ config VIDEO_TI_VIP select VIDEO_TI_VPDMA select VIDEO_TI_SC select VIDEO_TI_CSC + select V4L2_FWNODE help Driver support for VIP module on certain TI SoC's VIP = Video Input Port.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 429/1815 media: i2c: rdacm21: Fix missing media_entity_cleanup()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biren Pandya <[email protected]>
[ Upstream commit 04c053379c3a33460b581953c4f5b36de39439ac ]
The driver misses calling media_entity_cleanup() on the probe error path and during remove, leaking resources if probe fails after entity initialization or when the driver is unloaded.
Fix this by adding media_entity_cleanup() to the rdacm21_probe() error handling path and to rdacm21_remove().
--- drivers/media/i2c/rdacm21.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/i2c/rdacm21.c +4 -1
@@ -588,10 +588,12 @@ static int rdacm21_probe(struct i2c_client *client) ret =v4l2_async_register_subdev (&dev->sd);if (ret) - goto error_free_ctrls; + goto error_entity_cleanup;return 0 ; +error_entity_cleanup: +media_entity_cleanup (&dev->sd.entity); error_free_ctrls:v4l2_ctrl_handler_free (&dev->ctrls); error:
@@ -606,6 +608,7 @@ static void rdacm21_remove(struct i2c_client *client)v4l2_async_unregister_subdev (&dev->sd);v4l2_ctrl_handler_free (&dev->ctrls); +media_entity_cleanup (&dev->sd.entity);i2c_unregister_device (dev->isp); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 430/1815 media: platform: amd: fix unmet dependency for VIDEO_V4L2_SUBDEV_API
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Braha <[email protected]>
[ Upstream commit 95a99456ff354a1bad4b4032ed1d044d608bd438 ]
Currently, VIDEO_AMD_ISP4_CAPTURE selects VIDEO_V4L2_SUBDEV_API without ensuring MEDIA_CONTROLLER is enabled, causing an unmet dependency:
WARNING: unmet direct dependencies detected for VIDEO_V4L2_SUBDEV_API
Depends on [n]: MEDIA_SUPPORT [=m] && VIDEO_DEV [=m] && MEDIA_CONTROLLER [=n]
Selected by [m]:
- VIDEO_AMD_ISP4_CAPTURE [=m] && MEDIA_SUPPORT [=m] && MEDIA_PLATFORM_SUPPORT [=y] && MEDIA_PLATFORM_DRIVERS [=y] && DRM_AMDGPU [=m] && DRM_AMD_ISP [=y] && HAS_DMA [=y] && VIDEO_DEV [=m]
Many other options in this subsystem select MEDIA_CONTROLLER, let's do the same here.
This unmet dependency bug was detected by kconfirm, a static analysis tool for Kconfig.
--- drivers/media/platform/amd/isp4/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/amd/isp4/Kconfig +1 -0
@@ -5,6 +5,7 @@ config VIDEO_AMD_ISP4_CAPTURE depends on DRM_AMDGPU && DRM_AMD_ISP depends on HAS_DMA depends on VIDEO_DEV + select MEDIA_CONTROLLER select VIDEOBUF2_CORE select VIDEOBUF2_MEMOPS select VIDEOBUF2_V4L2
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 431/1815 media: bcm2835-unicam: Fix asc leaked in error/remove path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eugen Hristev <[email protected]>
[ Upstream commit 253c9659e25131b0169f718e7d094ac1aa0d9279 ]
v4l2_async_nf_add_fwnode_remote() allocates the asc, which is freed when v4l2_async_nf_cleanup() is called.
Call v4l2_async_nf_cleanup() properly in the driver paths.
Discovered with kmemleak after rmmod:
unreferenced object 0xffff000084526b80 (size 64):
comm "modprobe", pid 185, jiffies 4295013512
hex dump (first 32 bytes):
01 00 00 00 00 00 00 00 e8 0d ff bf 00 00 ff ff ................
40 83 bc 84 00 00 ff ff 60 83 bc 84 00 00 ff ff @.......`.......
backtrace (crc ac584083):
[<00000000ffb081a7>] kmemleak_alloc+0x38/0x44
[<00000000d2fd9301>] __kmalloc+0x1b0/0x250
[<000000004dd5354d>] __v4l2_async_nf_add_fwnode+0x28/0x9c
[<0000000067587657>] __v4l2_async_nf_add_fwnode_remote+0x3c/0x64--- drivers/media/platform/broadcom/bcm2835-unicam.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/broadcom/bcm2835-unicam.c +2 -0
@@ -2614,6 +2614,7 @@ static int unicam_async_nf_init(struct unicam_device *unicam)return 0 ; error: +v4l2_async_nf_cleanup (&unicam->notifier);fwnode_handle_put (ep_handle);return ret; }
@@ -2746,6 +2747,7 @@ static void unicam_remove(struct platform_device *pdev)v4l2_device_unregister (&unicam->v4l2_dev);media_device_unregister (&unicam->mdev);v4l2_async_nf_unregister (&unicam->notifier); +v4l2_async_nf_cleanup (&unicam->notifier);unicam_subdev_cleanup (unicam);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 432/1815 media: ipu6: Do not free aux device pdata after init
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 9be07216af4cfc4813e1a46ce26407d31ea845de ]
ipu6_bus_initialize_device() stores the isys/psys pdata pointer in struct ipu6_bus_device and initializes the auxiliary device. After that point, error unwinding must drop the auxiliary device reference and let ipu6_bus_release() free both the bus device and adev->pdata.
The isys and psys init paths already call put_device() when MMU initialization fails, and ipu6_bus_add_device() calls auxiliary_device_uninit() on auxiliary_device_add() failure. Both paths therefore run the bus release callback. The extra kfree(pdata) in the callers can release the same object a second time.
Remove the manual pdata frees after the auxiliary device has been initialized.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/media/pci/intel/ipu6/ipu6.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/media/pci/intel/ipu6/ipu6.c +2 -8
@@ -400,7 +400,6 @@ ipu6_isys_init(struct pci_dev *pdev, struct device *parent, &ipdata->hw_variant);if (IS_ERR (isys_adev->mmu)) {put_device (&isys_adev->auxdev.dev); -kfree (pdata);return dev_err_cast_probe (dev, isys_adev->mmu,"ipu6_mmu_init(isys_adev->mmu) failed\n" ); }
@@ -408,10 +407,8 @@ ipu6_isys_init(struct pci_dev *pdev, struct device *parent, isys_adev->mmu->dev = &isys_adev->auxdev.dev; ret =ipu6_bus_add_device (isys_adev); -if (ret) { -kfree (pdata); +if (ret)return ERR_PTR (ret); - }return isys_adev; }
@@ -444,7 +441,6 @@ ipu6_psys_init(struct pci_dev *pdev, struct device *parent, &ipdata->hw_variant);if (IS_ERR (psys_adev->mmu)) {put_device (&psys_adev->auxdev.dev); -kfree (pdata);return dev_err_cast_probe (&pdev->dev, psys_adev->mmu,"ipu6_mmu_init(psys_adev->mmu) failed\n" ); }
@@ -452,10 +448,8 @@ ipu6_psys_init(struct pci_dev *pdev, struct device *parent, psys_adev->mmu->dev = &psys_adev->auxdev.dev; ret =ipu6_bus_add_device (psys_adev); -if (ret) { -kfree (pdata); +if (ret)return ERR_PTR (ret); - }return psys_adev; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 433/1815 OPP: Fix cleanup ordering
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregor Herburger <[email protected]>
[ Upstream commit ce46fede7792cedd247e34b48bc8a02eb90c7848 ]
Commit 173e02d67494 ("OPP: Initialize scope-based pointers inline") added initialization for all pointers. In some cases, the ordering was changed so that *opp_table was initialized after *opp. This also changes the order of the registered cleanup functions.
When the cleanup happens, this can cause use-after-free errors when the last reference is released and the release function _opp_kref_release tries to access the already freed opp->opp_table.
Initialize *opp_table before *opp again to fix this and ensure the correct cleanup order.
--- drivers/opp/core.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/opp/core.c +5 -8
@@ -1412,13 +1412,12 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table,*/ int dev_pm_opp_set_rate (struct device *dev,unsigned long target_freq) { + struct opp_table *opp_table __free(put_opp_table) = +_find_opp_table (dev); struct dev_pm_opp *opp __free(put_opp) = NULL;unsigned long freq =0 , temp_freq;bool forced = false; - struct opp_table *opp_table __free(put_opp_table) = -_find_opp_table (dev); -if (IS_ERR (opp_table)) {dev_err (dev,"%s: device's opp table doesn't exist\n" , __func__);return PTR_ERR (opp_table);
@@ -2870,11 +2869,10 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_add_dynamic);static int _opp_set_availability (struct device *dev,unsigned long freq,bool availability_req) { - struct dev_pm_opp *opp __free(put_opp) = ERR_PTR(-ENODEV), *tmp_opp; -/* Find the opp_table */ struct opp_table *opp_table __free(put_opp_table) =_find_opp_table (dev); + struct dev_pm_opp *opp __free(put_opp) = ERR_PTR(-ENODEV), *tmp_opp;if (IS_ERR (opp_table)) { dev_warn(dev, "%s: Device OPP not found (%ld)\n", __func__,
@@ -2932,12 +2930,11 @@ int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq, unsigned long u_volt_max) { - struct dev_pm_opp *opp __free(put_opp) = ERR_PTR(-ENODEV), *tmp_opp; -int r; -/* Find the opp_table */ struct opp_table *opp_table __free(put_opp_table) =_find_opp_table (dev); + struct dev_pm_opp *opp __free(put_opp) = ERR_PTR(-ENODEV), *tmp_opp; +int r;if (IS_ERR (opp_table)) { r =PTR_ERR (opp_table);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 434/1815 drm/amd/display: Fix DM I2C teardown race
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geoffrey McRae <[email protected]>
[ Upstream commit e4ae30a12aa95942814957d8bc1ce7366a7107d7 ]
DM I2C adapters can remain visible to userspace while DM teardown is already in progress. A concurrent i2c-dev transfer may then enter amdgpu_dm_i2c_xfer() after the backing DM state has been torn down, leading to a NULL pointer dereference.
Create a devres group around the DM I2C adapter lifetime and release it at the start of dm_hw_fini(), before HPD, IRQ, and DM state are torn down. This removes the I2C adapters first and waits for in-flight users to drain before the structures used by amdgpu_dm_i2c_xfer() disappear.
This fixes a teardown ordering race seen during device removal:
BUG: kernel NULL pointer dereference RIP: amdgpu_dm_i2c_xfer+0x122/0x1c0 [amdgpu] Call Trace:
__i2c_transferi2c_transferi2cdev_ioctl_rdwr
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 +++++++++++++- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 7 +++++++ 2 files changed, 20 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +13 -1
@@ -3284,17 +3284,26 @@ static int dm_hw_init(struct amdgpu_ip_block *ip_block)struct amdgpu_device *adev = ip_block->adev;int r; + adev->dm.i2c_devres_group =devres_open_group (adev->dev,NULL ,GFP_KERNEL ); +if (!adev->dm.i2c_devres_group) +return -ENOMEM ; +/* Create DAL display manager */ r =amdgpu_dm_init (adev);if (r) -return r; + goto err_release_i2c;amdgpu_dm_hpd_init (adev); r =dm_oem_i2c_hw_init (adev);if (r)drm_info (adev_to_drm (adev),"Failed to add OEM i2c bus\n" ); +devres_close_group (adev->dev, adev->dm.i2c_devres_group);return 0 ; + +err_release_i2c: +devres_release_group (adev->dev, adev->dm.i2c_devres_group); +return r; }/**
@@ -3309,6 +3318,9 @@ static int dm_hw_fini(struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev; +if (adev->dm.i2c_devres_group) +devres_release_group (adev->dev, adev->dm.i2c_devres_group); +amdgpu_dm_hpd_fini (adev);amdgpu_dm_irq_fini (adev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +7 -0
@@ -688,6 +688,13 @@ struct amdgpu_display_manager {*/ void *bb_from_dmub; +/** +* @i2c_devres_group: +* +* Devres group for DM i2c adapter lifetime management. +*/ +void *i2c_devres_group; +/** * @oem_i2c: *
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 435/1815 drm/amd/display: Remove unused-but-set variable hubp from
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gleb Markov <[email protected]>
[ Upstream commit b736792e5bd4a62f24e8d1e310bf4a75bfbeaaaa ]
The final check of hubp for NULL covers all remaining lines of code, since the value of hubp does not change until the end of the method.
This check is redundant because hubp1 is already dereferenced within the macro.
If it were NULL, the program would have already failed to proceed.
Remove the left part of the expression with the logical "&&".
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.c +1 -2
@@ -772,8 +772,7 @@ bool hubp1_is_flip_pending(struct hubp *hubp)if (flip_pending)return true; -if (hubp && - earliest_inuse_address.grph.addr.quad_part != hubp->request_address.grph.addr.quad_part) +if (earliest_inuse_address.grph.addr.quad_part != hubp->request_address.grph.addr.quad_part)return true;return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 436/1815 drm/amd/display: fix wrong register field in dccg35_set_hdmistreamclk_src_new
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dyllan Kobal <[email protected]>
[ Upstream commit db9c882f83d3f3e08069f52d0d2ebf9d131c9ae4 ]
dccg35_set_hdmistreamclk_src_new() updates HDMISTREAMCLK_CNTL but passes DPSTREAMCLK0_SRC_SEL as the field identifier in the second REG_UPDATE_2 slot.
The current behavior is harmless on DCN3.5 because both fields share the same bit layout, but it is still incorrect and could break on future hardware revisions.
--- drivers/gpu/drm/amd/display/dc/dccg/dcn35/dcn35_dccg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dccg/dcn35/dcn35_dccg.c +1 -1
@@ -572,7 +572,7 @@ static void dccg35_set_hdmistreamclk_src_new(case 0 :REG_UPDATE_2 (HDMISTREAMCLK_CNTL ,HDMISTREAMCLK0_EN , (src ==HDMI_STREAM_REFCLK ) ?0 :1 , -DPSTREAMCLK0_SRC_SEL , +HDMISTREAMCLK0_SRC_SEL , (src ==HDMI_STREAM_REFCLK ) ?0 : src);break ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 437/1815 drm/amd/display: remove duplicate link_dp_panel_replay.h include
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anas Khan <[email protected]>
[ Upstream commit dcda83715716ac828454094ed9c6e17150a0092f ]
link_dp_irq_handler.c includes "link_dp_panel_replay.h" twice. Drop the redundant second include; this is a non-functional cleanup flagged by scripts/checkincludes.pl.
--- .../gpu/drm/amd/display/dc/link/protocols/link_dp_irq_handler.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_irq_handler.c +0 -1
@@ -39,7 +39,6 @@#include "link/link_dpms.h" #include "dm_helpers.h" #include "link_dp_dpia_bw.h" -#include "link_dp_panel_replay.h" #define DC_LOGGER \ link->ctx->logger
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 438/1815 cpufreq: intel_pstate: Fix setting minimum P-state at init time
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit db53c573d31d07d5d782c5312d37cb33be788eba ]
If HWP is enabled, writes to MSR_IA32_PERF_CTL have no effect, so intel_pstate_get_cpu_pstates() should not attempt to call intel_pstate_set_min_pstate() to set the minimum P-state for the given CPU in that case.
Accordingly, remove the intel_pstate_set_min_pstate() call from intel_pstate_get_cpu_pstates() and make both intel_pstate_cpu_init() and intel_cpufreq_cpu_init() call that function in their non-HWP code paths.
The HWP code path in intel_pstate_cpu_init() does not need to update the current P-state of the CPU directly at all because it is taken care of the processor automatically, but the HWP code path of intel_cpufreq_cpu_init() should update it in principle to initialize the DESIRED_PERF field in MSR_HWP_REQUEST. For this purpose, make it call intel_cpufreq_hwp_update() and pass the minimum P-state limit to it as the current target value along with the current minimum and maximum limits.
--- drivers/cpufreq/intel_pstate.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/cpufreq/intel_pstate.c +11 -8
@@ -2356,8 +2356,6 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)if (pstate_funcs.get_vid) pstate_funcs.get_vid (cpu); - -intel_pstate_set_min_pstate (cpu); }/*
@@ -3063,6 +3061,7 @@ static int __intel_pstate_cpu_init(struct cpufreq_policy *policy)static int intel_pstate_cpu_init (struct cpufreq_policy *policy) {int ret =__intel_pstate_cpu_init (policy); +struct cpudata *cpu;if (ret)return ret;
@@ -3073,11 +3072,11 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy)*/ policy->policy =CPUFREQ_POLICY_POWERSAVE ; -if (hwp_active) { -struct cpudata *cpu = all_cpu_data[policy->cpu]; - + cpu = all_cpu_data[policy->cpu]; +if (hwp_active) cpu->epp_cached =intel_pstate_get_epp (cpu,0 ); - } +else +intel_pstate_set_min_pstate (cpu);return 0 ; }
@@ -3301,8 +3300,6 @@ static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy)return ret; policy->cpuinfo.transition_latency =INTEL_CPUFREQ_TRANSITION_LATENCY ; -/* This reflects the intel_pstate_get_cpu_pstates() setting. */ - policy->cur = policy->cpuinfo.min_freq; req =kzalloc_objs (*req,2 );if (!req) {
@@ -3323,9 +3320,15 @@ static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy)WRITE_ONCE (cpu->hwp_req_cached, value); cpu->epp_cached =intel_pstate_get_epp (cpu, value); + +intel_cpufreq_hwp_update (cpu, cpu->pstate.min_pstate, + cpu->pstate.max_pstate, + cpu->pstate.min_pstate, false); }else { policy->transition_delay_us =INTEL_CPUFREQ_TRANSITION_DELAY ; +intel_pstate_set_min_pstate (cpu); } + policy->cur = policy->cpuinfo.min_freq; freq =DIV_ROUND_UP (cpu->pstate.turbo_freq * global.min_perf_pct,100 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 439/1815 cpufreq: schedutil: Fix self-contradictory comment in sugov_iowait_apply()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhongqiu Han <[email protected]>
[ Upstream commit db6a017c91b774c15b1b890db45981eacfff540e ]
The kerneldoc of sugov_iowait_apply() says the IO boost value is increased in sugov_iowait_apply() and, in the same sentence, that it is decreased by the same function. That is self-contradictory, and the first part is wrong:sugov_iowait_apply() only decreases the boost.
The boost is actually increased in sugov_iowait_boost(). Fix the comment to name sugov_iowait_boost() as the place where the boost is increased, so it matches the code.
No functional change.
--- kernel/sched/cpufreq_schedutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/cpufreq_schedutil.c +1 -1
@@ -325,7 +325,7 @@ static void sugov_iowait_boost(struct sugov_cpu *sg_cpu, u64 time,* A CPU running a task which woken up after an IO operation can have its * utilization boosted to speed up the completion of those IO operations. * The IO boost value is increased each time a task wakes up from IO, in -* sugov_iowait_apply(), and it's instead decreased by this function, +* sugov_iowait_boost(), and it's instead decreased by this function, * each time an increase has not been requested (!iowait_boost_pending). * * A CPU which also appears to have been idle for at least one tick has also
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 440/1815 remoteproc: qcom_q6v5_mss: Make ssctl_id configurable per platform
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephan Gerhold <[email protected]>
[ Upstream commit 6aa64a4c89faec9daff36828df38f8f69498a870 ]
Currently, qcom_q6v5_mss hardcodes 0x12 as the instance ID for the subsystem control (ssctl) QMI service. However, some platforms (e.g. MDM9607) provide the service with a different instance ID (0x22).
Make it possible to override the ssctl_id per platform by adding it to the platform-specific rproc_hexagon_res struct. The same pattern also exists already inside qcom_q6v5_pas.
Stable-dep-of: 846baa5ab461 ("remoteproc: qcom_q6v5_mss: Fix MDM9607 subsystem control instance ID")
--- drivers/remoteproc/qcom_q6v5_mss.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/remoteproc/qcom_q6v5_mss.c +18 -1
@@ -162,6 +162,7 @@ struct rproc_hexagon_res {char **active_clk_names;char **proxy_pd_names;int version; +int ssctl_id;bool need_mem_protection;bool need_pas_mem_setup;bool has_alt_reset;
@@ -2191,7 +2192,7 @@ static int q6v5_probe(struct platform_device *pdev)qcom_add_smd_subdev (rproc, &qproc->smd_subdev);qcom_add_pdm_subdev (rproc, &qproc->pdm_subdev);qcom_add_ssr_subdev (rproc, &qproc->ssr_subdev,"mpss" ); - qproc->sysmon =qcom_add_sysmon_subdev (rproc,"modem" ,0x12 ); + qproc->sysmon =qcom_add_sysmon_subdev (rproc,"modem" , desc->ssctl_id);if (IS_ERR (qproc->sysmon)) { ret =PTR_ERR (qproc->sysmon); goto remove_subdevs;
@@ -2271,6 +2272,7 @@ static const struct rproc_hexagon_res sc7180_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_SC7180, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res sc7280_mss = {
@@ -2301,6 +2303,7 @@ static const struct rproc_hexagon_res sc7280_mss = { .has_ext_cntl_regs = true, .has_vq6 = true, .version = MSS_SC7280, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res sdm660_mss = {
@@ -2334,6 +2337,7 @@ static const struct rproc_hexagon_res sdm660_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_SDM660, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res sdm845_mss = {
@@ -2371,6 +2375,7 @@ static const struct rproc_hexagon_res sdm845_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_SDM845, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res msm8998_mss = {
@@ -2404,6 +2409,7 @@ static const struct rproc_hexagon_res msm8998_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_MSM8998, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res msm8996_mss = {
@@ -2444,6 +2450,7 @@ static const struct rproc_hexagon_res msm8996_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_MSM8996, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res mdm9607_mss = {
@@ -2479,6 +2486,7 @@ static const struct rproc_hexagon_res mdm9607_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_MDM9607, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res msm8909_mss = {
@@ -2515,6 +2523,7 @@ static const struct rproc_hexagon_res msm8909_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_MSM8909, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res msm8916_mss = {
@@ -2562,6 +2571,7 @@ static const struct rproc_hexagon_res msm8916_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_MSM8916, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res msm8917_mss = {
@@ -2606,6 +2616,7 @@ static const struct rproc_hexagon_res msm8917_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_MSM8917, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res msm8937_mss = {
@@ -2650,6 +2661,7 @@ static const struct rproc_hexagon_res msm8937_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_MSM8937, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res msm8940_mss = {
@@ -2694,6 +2706,7 @@ static const struct rproc_hexagon_res msm8940_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_MSM8940, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res msm8953_mss = {
@@ -2731,6 +2744,7 @@ static const struct rproc_hexagon_res msm8953_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_MSM8953, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res msm8974_mss = {
@@ -2785,6 +2799,7 @@ static const struct rproc_hexagon_res msm8974_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_MSM8974, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res msm8226_mss = {
@@ -2824,6 +2839,7 @@ static const struct rproc_hexagon_res msm8226_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_MSM8226, + .ssctl_id = 0x12, };static const struct rproc_hexagon_res msm8926_mss = {
@@ -2871,6 +2887,7 @@ static const struct rproc_hexagon_res msm8926_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_MSM8926, + .ssctl_id = 0x12, };static const struct of_device_id q6v5_of_match[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 441/1815 remoteproc: qcom_q6v5_mss: Fix MDM9607 subsystem control instance ID
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephan Gerhold <[email protected]>
[ Upstream commit 846baa5ab461e24d31f942dcdff1932e8516dd00 ]
On MDM9607, the modem firmware exposes the QMI subsystem control service with instance ID 0x22 (34), as visible e.g. with qrtr-lookup:
$ qrtr-lookup
Service Version Instance Node Port
43 2 34 3 1 Subsystem control serviceCurrently, qcom_q6v5_mss uses ssctl_id 0x12 for all platforms. The QMI service never shows up with this ID, leading to the following error when trying to shutdown the modem:
qcom-q6v5-mss 4080000.remoteproc: timeout waiting for ssctl service
Set the correct ssctl_id to allow clean shutdown of the modem firmware with the subsystem control service. ssctl_id 0x22 is also used by other modem-only Qualcomm platforms in qcom_q6v5_pas, such as SDX55.
--- drivers/remoteproc/qcom_q6v5_mss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/qcom_q6v5_mss.c +1 -1
@@ -2486,7 +2486,7 @@ static const struct rproc_hexagon_res mdm9607_mss = { .has_ext_cntl_regs = false, .has_vq6 = false, .version = MSS_MDM9607, - .ssctl_id = 0x12, + .ssctl_id = 0x22, };static const struct rproc_hexagon_res msm8909_mss = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 442/1815 remoteproc: qcom: Fix glink->node reference leak in qcom_add_glink_subdev
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uday Khare <[email protected]>
[ Upstream commit 44f4911ab8e6f4d69afad5f2571bbd2da421c918 ]
In qcom_add_glink_subdev(), the device node reference acquired via of_get_child_by_name() is stored in glink->node. If the subsequent kstrdup_const() allocation for glink->ssr_name fails, the function returns early without calling of_node_put() on glink->node, leaking the reference count.
Fix this by adding of_node_put(glink->node) on the error path before returning.
--- drivers/remoteproc/qcom_common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/remoteproc/qcom_common.c +3 -1
@@ -253,8 +253,10 @@ void qcom_add_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink,return ; glink->ssr_name =kstrdup_const (ssr_name,GFP_KERNEL ); -if (!glink->ssr_name) +if (!glink->ssr_name) { +of_node_put (glink->node);return ; + } glink->dev = dev; glink->subdev.start = glink_subdev_start;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 443/1815 perf: evsel: Fix error handling in tp_format lookup
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
[ Upstream commit 4968708beaad53940b67e4952e34a97d8768091d ]
In evsel__tp_format(), when trace_event__tp_format*() returns an error, IS_ERR() checks the local variable 'tp_format', but PTR_ERR() incorrectly uses 'evsel->tp_format' which hasn't been assigned yet.
Fix this by using PTR_ERR(tp_format) to extract the error code from the correct variable.
--- tools/perf/util/evsel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evsel.c +1 -1
@@ -706,7 +706,7 @@ struct tep_event *evsel__tp_format(struct evsel *evsel) tp_format =trace_event__tp_format (evsel->tp_sys, evsel->tp_name);if (IS_ERR (tp_format)) { -int err = -PTR_ERR (evsel->tp_format); +int err = -PTR_ERR (tp_format); errno = err; pr_err("Error getting tracepoint format '%s': %m\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 444/1815 drm/bridge: tc358767: clamp the reported AUX read size to the request
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maoyi Xie <[email protected]>
[ Upstream commit ec6444a00c49e6c2b5e9a507272a28126677f9ee ]
tc_aux_transfer() clamps an AUX read to the payload limit:
size_t size = min_t(size_t, DP_AUX_MAX_PAYLOAD_BYTES - 1, msg->size);
After the transfer it replaces size with the byte count the controller reports in AUX_BYTES:
if (size) size = FIELD_GET(AUX_BYTES, auxstatus);
AUX_BYTES is GENMASK(15, 8), so it can be up to 255. Nothing clamps it back to the request. tc_aux_read_data() reads that many bytes into the 16-byte auxrdata stack buffer, then copies them into the caller buffer. A reported count of 255 makes the read run to 256 bytes and overruns both.
The controller should never report more than it was asked to transfer, so this is defense in depth rather than a live hole. The reported count is only lightly trusted, and the check is cheap. Clamp it back to the request, the same way ti-sn65dsi86 does in commit aca58eac52b8 ("drm/bridge:
ti-sn65dsi86: Never store more than msg->size bytes in AUX xfer").
--- drivers/gpu/drm/bridge/tc358767.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/tc358767.c +1 -1
@@ -527,7 +527,7 @@ static ssize_t tc_aux_transfer(struct drm_dp_aux *aux,* address-only transfer */ if (size) - size =FIELD_GET (AUX_BYTES , auxstatus); + size =min_t (size_t, size,FIELD_GET (AUX_BYTES , auxstatus)); msg->reply =FIELD_GET (AUX_STATUS , auxstatus);switch (request) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 445/1815 x86/mm/pat: Take cpa_lock around large-page collapse
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis V. Lunev <[email protected]>
[ Upstream commit 1aac65f3e651334259ecb2a5f5ddb81c01f02599 ]
Loading and unloading modules concurrently on several CPUs on a KASAN build, with a short delay injected at the CPA page-table lookup to widen the window, faults within minutes:
BUG: KASAN: use-after-free in __change_page_attr+0x7cc/0x7e0 Write of size 8 at addr ffff888181139718 by task modprobe ... The buggy address belongs to the physical page: pfn:0x181139 ... page_type: f2(table)
cpa_collapse_large_pages() rebuilds a leaf PMD from its 4K PTEs and frees the old PTE-table pages, while __change_page_attr() fetches a PTE pointer from a lockless lookup_address_in_pgd_attr() and writes it with set_pte_atomic() only later. When module text is served from a shared large ROX mapping the two run on the same PMD:
CPU A (module load) CPU B (module finalize)
------------------- -----------------------
execmem_make_temp_rw
set_memory_nx
__change_page_attr
split 2M -> 4K table P
kpte = &P[i] (lockless)
execmem_restore_rox
set_memory_rox (CPA_COLLAPSE)
cpa_collapse_large_pages
rebuild leaf PMD
flush_tlb_all
pagetable_free(P)
set_pte_atomic(kpte, ...)
-> writes into freed PP is a page-table page (page_type: table), reused at once, so the write corrupts whatever got the page next: a bad-pte or bad-page splat, or a fatal fault once P has been turned into read-only text.
The flush_tlb_all() before the free does not close this: its IPI only serializes against page-table walkers that run with interrupts off (e.g. GUP-fast); the walk in __change_page_attr() runs with interrupts on, so nothing stops it from holding a stale pointer into P.
Serialize the collapse - the PMD rebuild, TLB flush and PTE-table free - under cpa_lock, the same lock __change_page_attr() now takes unconditionally since commit ("x86/mm/pat: stop gating cpa_lock on debug_pagealloc_enabled()"), so a concurrent walker can no longer hold a pointer into a table the collapse is about to free.
--- arch/x86/mm/pat/set_memory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/x86/mm/pat/set_memory.c +7 -1
@@ -418,6 +418,8 @@ static void cpa_collapse_large_pages(struct cpa_data *cpa)int collapsed =0 ;int i; +spin_lock (&cpa_lock); +if (cpa->flags & (CPA_PAGES_ARRAY |CPA_ARRAY )) {for (i =0 ; i < cpa->numpages; i++) collapsed += collapse_large_pages(__cpa_addr(cpa, i),
@@ -431,8 +433,10 @@ static void cpa_collapse_large_pages(struct cpa_data *cpa) collapsed +=collapse_large_pages (addr, &pgtables); } -if (!collapsed) +if (!collapsed) { +spin_unlock (&cpa_lock);return ; + }flush_tlb_all ();
@@ -440,6 +444,8 @@ static void cpa_collapse_large_pages(struct cpa_data *cpa)list_del (&ptdesc->pt_list);pagetable_free (ptdesc); } + +spin_unlock (&cpa_lock); }static void cpa_flush (struct cpa_data *cpa,int cache)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 446/1815 arm64: dts: qcom: msm8996-xiaomi-gemini: Fix up ti,drv2604 enable GPIO
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 569413a98a1761782a0770aa85d20a2c78893279 ]
Update the 'enable-gpio' property name to 'enable-gpios' to conform to the bindings for the TI DRV2604 haptics module. While at it, use the GPIO_ACTIVE_HIGH define instead of the raw literal.
--- arch/arm64/boot/dts/qcom/msm8996-xiaomi-gemini.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/msm8996-xiaomi-gemini.dts +1 -1
@@ -39,7 +39,7 @@ &blsp2_i2c3 { haptics: drv2604@5a { compatible = "ti,drv2604"; reg = <0x5a>; - enable-gpio = <&tlmm 93 0x00>; + enable-gpios = <&tlmm 93 GPIO_ACTIVE_HIGH>; mode = <DRV260X_LRA_MODE>; library-sel = <DRV260X_LIB_LRA>; pinctrl-names = "default","sleep";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 447/1815 arm64: dts: qcom: sc8280xp-x13s: Fix the drive-strength of mclk pin
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengyu Luo <[email protected]>
[ Upstream commit 09531bb8e0de5081fdbe215877dd7f2ec8b2f0e1 ]
The value can be retrieve via windbg on Windows.
lkd> !dd f111000 L8
ctl_reg => 0x284
in drivers/pinctrl/qcom/pinctrl-msm.c
function msm_gpio_dbg_show_one()
...
drive = (ctl_reg >> g->drv_bit) & 7; // (0x284 >> 6) & 7 == 2
...seq_printf(s, " %dmA", msm_regval_to_drive(drive)); // (drive + 1) * 2 == 6;
...
So the value is 6, not 16, it matches Windows now.
--- arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts +1 -1
@@ -1555,7 +1555,7 @@ cam_rgb_default: cam-rgb-default-state { mclk-pins { pins = "gpio17"; function = "cam_mclk"; - drive-strength = <16>; + drive-strength = <6>; bias-disable; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 448/1815 arm64: dts: qcom: eliza: Enable first QUPv3 wrapper by default
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit e78c2cf207c1ebf4558b709308199ee21de478ac ]
Since each serial engine will be enabled as needed in each board dts, there is no point of disabling the first QUPv3 wrapper in SoC dtsi.
So enable it by default. This is also now in line with the other SoCs, and also with the second QUPv3 wrapper.
--- arch/arm64/boot/dts/qcom/eliza.dtsi | 2 -- 1 file changed, 2 deletions(-)
arch/arm64/boot/dts/qcom/eliza.dtsi +0 -2
@@ -1232,8 +1232,6 @@ qupv3_1: geniqup@ac0000 { #size-cells = <2>; ranges; - status = "disabled"; - i2c0: i2c@a80000 { compatible = "qcom,geni-i2c"; reg = <0x0 0x00a80000 0x0 0x4000>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 449/1815 arm64: dts: qcom: glymur-crd: merge duplicate &pmh0101_gpios node extensions
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gopikrishna Garmidi <[email protected]>
[ Upstream commit 63b9c63716d452a71d4c5346e0dba4212b94c6a1 ]
The &pmh0101_gpios node is extended twice in glymur-crd.dtsi. The first extension defines the nvme_reg_en pinctrl state for the NVMe regulator enable GPIO (gpio14), and the second adds key_vol_up_default for the volume-up key (gpio6).
Merge both pinctrl states into a single &pmh0101_gpios block to avoid the duplicate node extension.
No functional change intended.
--- arch/arm64/boot/dts/qcom/glymur-crd.dtsi | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
arch/arm64/boot/dts/qcom/glymur-crd.dtsi +6 -8
@@ -781,14 +781,6 @@ &pcie6_port0 { wake-gpios = <&tlmm 151 GPIO_ACTIVE_LOW>; }; -&pmh0101_gpios { - nvme_reg_en: nvme-reg-en-state { - pins = "gpio14"; - function = "normal"; - bias-disable; - }; -}; - &pmh0110_f_e1_gpios { nvme_sec_reg_en: nvme-reg-en-state { pins = "gpio14";
@@ -804,6 +796,12 @@ key_vol_up_default: key-vol-up-default-state { output-disable; bias-pull-up; }; + + nvme_reg_en: nvme-reg-en-state { + pins = "gpio14"; + function = "normal"; + bias-disable; + }; }; &pmh0110_f_e0_gpios {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 450/1815 arm64: dts: qcom: ipq5018: Correct CMN PLL reference clock rate
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: George Moussalem <[email protected]>
[ Upstream commit 5e92312a1d7542be9a0e588467bfbb2ca123eaac ]
The correct CMN PLL reference clock rate for IPQ5018 is 4.8 GHz.
The CMN PLL driver did not account for the ref clock divider which is 2 for IPQ5018. Therefore, the computed rate was twice the actual output.
With the driver now accounting for the CMN PLL reference clock divider (commit: 88c543fff756), set the correct reference clock rate.
--- arch/arm64/boot/dts/qcom/ipq5018.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/ipq5018.dtsi +1 -1
@@ -256,7 +256,7 @@ cmn_pll: clock-controller@9b000 { "sys"; #clock-cells = <1>; assigned-clocks = <&cmn_pll IPQ5018_CMN_PLL_CLK>; - assigned-clock-rates-u64 = /bits/ 64 <9600000000>; + assigned-clock-rates-u64 = /bits/ 64 <4800000000>; }; qfprom: qfprom@a0000 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 451/1815 arm64: qcom: ipq5018: Add GEPHY RX and TX clocks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: George Moussalem <[email protected]>
[ Upstream commit 742dc058588bf1233647dcd95738c0afc621435d ]
Add RX and TX clocks for the IPQ5018 GEPHY to enable the datapath.
--- arch/arm64/boot/dts/qcom/ipq5018.dtsi | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/boot/dts/qcom/ipq5018.dtsi +3 -0
@@ -229,6 +229,9 @@ ge_phy: ethernet-phy@7 { compatible = "ethernet-phy-id004d.d0c0"; reg = <7>; + clocks = <&gcc GCC_GEPHY_RX_CLK>, + <&gcc GCC_GEPHY_TX_CLK>; + clock-names = "rx", "tx"; resets = <&gcc GCC_GEPHY_MISC_ARES>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 452/1815 arm64: dts: qcom: sm8250: sort out Iris power domains
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit d5c8efda722eb1f67cfe299b71f13dab93746934 ]
On SM8250 Iris core requires two power rails to function, MX (for PLLs) and MMCX (for everything else). The commit fa245b3f06cd ("arm64: dts:
qcom: sm8250: Add venus DT node") added only MX power rail, but omitted MMCX voltage levels.
Add MMCX domain to the Iris device node.
--- arch/arm64/boot/dts/qcom/sm8250.dtsi | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/qcom/sm8250.dtsi +14 -6
@@ -4326,8 +4326,12 @@ venus: video-codec@aa00000 { interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>; power-domains = <&videocc MVS0C_GDSC>, <&videocc MVS0_GDSC>, - <&rpmhpd RPMHPD_MX>; - power-domain-names = "venus", "vcodec0", "mx"; + <&rpmhpd RPMHPD_MX>, + <&rpmhpd RPMHPD_MMCX>; + power-domain-names = "venus", + "vcodec0", + "mx", + "mmcx"; operating-points-v2 = <&venus_opp_table>; clocks = <&gcc GCC_VIDEO_AXI0_CLK>,
@@ -4353,22 +4357,26 @@ venus_opp_table: opp-table { opp-720000000 { opp-hz = /bits/ 64 <720000000>; - required-opps = <&rpmhpd_opp_low_svs>; + required-opps = <&rpmhpd_opp_svs>, + <&rpmhpd_opp_low_svs>; }; opp-1014000000 { opp-hz = /bits/ 64 <1014000000>; - required-opps = <&rpmhpd_opp_svs>; + required-opps = <&rpmhpd_opp_svs>, + <&rpmhpd_opp_svs>; }; opp-1098000000 { opp-hz = /bits/ 64 <1098000000>; - required-opps = <&rpmhpd_opp_svs_l1>; + required-opps = <&rpmhpd_opp_svs_l1>, + <&rpmhpd_opp_svs_l1>; }; opp-1332000000 { opp-hz = /bits/ 64 <1332000000>; - required-opps = <&rpmhpd_opp_nom>; + required-opps = <&rpmhpd_opp_svs_l1>, + <&rpmhpd_opp_nom>; }; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 453/1815 arm64: dts: qcom: sm8250: correct frequencies in the Iris OPP table
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 68ea007df9293fcb29d38219d73094bbf4b59673 ]
The OPP table for the Iris core is wrong, it copies the VDD table from the downstream kernel, but that table is written for the video_cc_mvs0_clk_src, while the upstream uses video_cc_mvs0_clk for OPP rate setting (which is clk_src divided by 3). Specify correct frequencies in the OPP table.
--- arch/arm64/boot/dts/qcom/sm8250.dtsi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/arm64/boot/dts/qcom/sm8250.dtsi +8 -8
@@ -4355,26 +4355,26 @@ venus: video-codec@aa00000 { venus_opp_table: opp-table { compatible = "operating-points-v2"; - opp-720000000 { - opp-hz = /bits/ 64 <720000000>; + opp-240000000 { + opp-hz = /bits/ 64 <240000000>; required-opps = <&rpmhpd_opp_svs>, <&rpmhpd_opp_low_svs>; }; - opp-1014000000 { - opp-hz = /bits/ 64 <1014000000>; + opp-338000000 { + opp-hz = /bits/ 64 <338000000>; required-opps = <&rpmhpd_opp_svs>, <&rpmhpd_opp_svs>; }; - opp-1098000000 { - opp-hz = /bits/ 64 <1098000000>; + opp-366000000 { + opp-hz = /bits/ 64 <366000000>; required-opps = <&rpmhpd_opp_svs_l1>, <&rpmhpd_opp_svs_l1>; }; - opp-1332000000 { - opp-hz = /bits/ 64 <1332000000>; + opp-444000000 { + opp-hz = /bits/ 64 <444000000>; required-opps = <&rpmhpd_opp_svs_l1>, <&rpmhpd_opp_nom>; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 454/1815 arm64: dts: qcom: milos: Add reset for sdhc_2
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Weiss <[email protected]>
[ Upstream commit c3eceb0627605564f102dc0f5ca4a6060ca57fd4 ]
Add the missing reset (BCR) for sdhc_2.
--- arch/arm64/boot/dts/qcom/milos.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/qcom/milos.dtsi +2 -0
@@ -1724,6 +1724,8 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, iommus = <&apps_smmu 0x540 0>; + resets = <&gcc GCC_SDCC2_BCR>; + bus-width = <4>; qcom,dll-config = <0x0007442c>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 455/1815 perf sched: Add missing perf_session__delete()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit 2bd4ad6914ed73189ccc2fb2740e94dafd1a9a8f ]
The perf sched stats record missed to release the session and ASAN reported a leak.
--- tools/perf/builtin-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-sched.c +1 -1
@@ -4023,8 +4023,8 @@ static int perf_sched__schedstat_record(struct perf_sched *sched,else fprintf (stderr,"[ perf sched stats: Failed !! ]\n" ); +perf_session__delete (session);evlist__put (evlist); -close (fd);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 456/1815 perf sched: Fix memory leaks in perf sched stats report
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit 60de2c6561ae57b5f2c50efecc1fa1f0081f731a ]
The second pass data is not saved in the list and only used to calculate delta from the first pass. Let's free the data after use.
--- tools/perf/builtin-sched.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/perf/builtin-sched.c +4 -0
@@ -4627,6 +4627,8 @@ static int perf_sched__process_schedstat(const struct perf_tool *tool __maybe_un domain_second_pass =list_first_entry (&cpu_second_pass->domain_head, struct schedstat_domain, domain_list);store_schedstat_cpu_diff (temp); +free (temp->cpu_data); +free (temp); } }else if (event->header.type ==PERF_RECORD_SCHEDSTAT_DOMAIN ) {struct schedstat_cpu *cpu_tail;
@@ -4647,6 +4649,8 @@ static int perf_sched__process_schedstat(const struct perf_tool *tool __maybe_un }else {store_schedstat_domain_diff (temp); domain_second_pass =list_next_entry (domain_second_pass, domain_list); +free (temp->domain_data); +free (temp); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 457/1815 perf sched: Free subcommand string after perf sched stats
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit e1f522ac439f94d56cf0d9a3c82d1953646d377a ]
The first entry of the sched_usage is dynamically allocated in parse_options_subcommand() so it should be released at the end. Do not return from a subcommand directly.
--- tools/perf/builtin-sched.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tools/perf/builtin-sched.c +5 -4
@@ -5255,19 +5255,20 @@ int cmd_sched(int argc, const char **argv)if (argc) argc =parse_options (argc, argv, stats_options, stats_usage,0 ); -return perf_sched__schedstat_record (&sched, argc, argv); + ret =perf_sched__schedstat_record (&sched, argc, argv); }else if (argv[0 ] && !strcmp (argv[0 ],"report" )) {if (argc) argc =parse_options (argc, argv, stats_options, stats_usage,0 ); -return perf_sched__schedstat_report (&sched); + ret =perf_sched__schedstat_report (&sched); }else if (argv[0 ] && !strcmp (argv[0 ],"diff" )) {if (argc) argc =parse_options (argc, argv, stats_options, stats_usage,0 ); -return perf_sched__schedstat_diff (&sched, argc, argv); + ret =perf_sched__schedstat_diff (&sched, argc, argv); + }else { + ret =perf_sched__schedstat_live (&sched, argc, argv); } -return perf_sched__schedstat_live (&sched, argc, argv); }else {usage_with_options (sched_usage, sched_options); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 458/1815 perf jevents: Add more components to the metric sorting order
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 557f8b3ca8c8e58d5bc3084734bc7a470b043922 ]
Nazar Kazakov reported non-deterministic builds due to the metrics being reordered in the jevents.py output. The metrics were largely only being sorted by name, add in the expressions and descriptions.
--- tools/perf/pmu-events/jevents.py | 5 +++-- tools/perf/pmu-events/metric.py | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-)
tools/perf/pmu-events/jevents.py +3 -2
@@ -570,13 +570,14 @@ static const struct pmu_table_entry {_pending_events_tblname}[] = {{ def print_pending_metrics() -> None: """Optionally close metrics table.""" - def metric_cmp_key(j: JsonEvent) -> Tuple[bool, str, str]: + def metric_cmp_key(j: JsonEvent) -> Tuple[str, str, str, str]: def fix_none(s: Optional[str]) -> str: if s is None: return '' return s - return (j.desc is not None, fix_none(j.pmu), fix_none(j.metric_name)) + return (fix_none(j.pmu), fix_none(j.metric_name), j.metric_expr.ToPerfJson(), + fix_none(j.desc)) global _pending_metrics if not _pending_metrics:
tools/perf/pmu-events/metric.py +5 -1
@@ -623,7 +623,11 @@ class Metric: def __lt__(self, other): """Sort order.""" - return self.name < other.name + if self.name != other.name: + return self.name < other.name + if not self.expr.Equals(other.expr): + return self.expr.ToPerfJson() < other.expr.ToPerfJson() + return self.description < other.description def AddToMetricGroup(self, group): """Callback used when being added to a MetricGroup."""
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 459/1815 clk: qcom: gcc-glymur: Enable runtime PM
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit 8d4f342369d0d77f32a0211692442d3b6d455872 ]
Enable runtime PM for the controller so the common GCC probe path resumes the attached domain while registering clocks, resets and GDSCs.
This lets GDSC consumers propagate their votes through the GCC provider to the CX parent domain.
--- drivers/clk/qcom/gcc-glymur.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/qcom/gcc-glymur.c +1 -0
@@ -8548,6 +8548,7 @@ static const struct qcom_cc_desc gcc_glymur_desc = { .num_resets = ARRAY_SIZE(gcc_glymur_resets), .gdscs = gcc_glymur_gdscs, .num_gdscs = ARRAY_SIZE(gcc_glymur_gdscs), + .use_rpm = true, .driver_data = &gcc_glymur_driver_data, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 460/1815 soc: renesas: r8a78000: Drop duplicate "default ARCH_RENESAS"
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 07231087d5e24c4d9c578c824b96f8af913f7324 ]
The Kconfig entry for ARCH_R8A78000 contains both "default y if ARCH_RENESAS" and "default ARCH_RENESAS", which are sort-of duplicates.
Drop the latter, to restore consistency with the other ARM64 entries.
--- drivers/soc/renesas/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/soc/renesas/Kconfig +0 -1
@@ -356,7 +356,6 @@ config ARCH_R8A779H0 config ARCH_R8A78000 bool "ARM64 Platform support for R8A78000 (R-Car X5H)" default y if ARCH_RENESAS - default ARCH_RENESAS select ARCH_RCAR_GEN5 help This enables support for the Renesas R-Car X5H SoC.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 461/1815 drm/solomon: remove unneeded variables in blit functions
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Iker Pedrosa <[email protected]>
[ Upstream commit e5320be8a585a9286f231305d0d443d59c24e46c ]
Remove unneeded 'ret' variables in ssd130x_fb_blit_rect(), ssd132x_fb_blit_rect(), and ssd133x_fb_blit_rect() functions. These functions initialize ret to 0 and return it unchanged, so return 0 directly instead.
--- drivers/gpu/drm/solomon/ssd130x.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/solomon/ssd130x.c +3 -6
@@ -1008,7 +1008,6 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb,struct ssd130x_device *ssd130x =drm_to_ssd130x (fb->dev);struct iosys_map dst;unsigned int dst_pitch; -int ret =0 ;/* Align y to display page boundaries */ rect->y1 =round_down (rect->y1,SSD130X_PAGE_HEIGHT );
@@ -1021,7 +1020,7 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb,ssd130x_update_rect (ssd130x, rect, buf, data_array); -return ret; +return 0 ; } static int ssd132x_fb_blit_rect(struct drm_framebuffer *fb,
@@ -1033,7 +1032,6 @@ static int ssd132x_fb_blit_rect(struct drm_framebuffer *fb,struct ssd130x_device *ssd130x =drm_to_ssd130x (fb->dev);unsigned int dst_pitch;struct iosys_map dst; -int ret =0 ;/* Align x to display segment boundaries */ rect->x1 =round_down (rect->x1,SSD132X_SEGMENT_WIDTH );
@@ -1047,7 +1045,7 @@ static int ssd132x_fb_blit_rect(struct drm_framebuffer *fb,ssd132x_update_rect (ssd130x, rect, buf, data_array); -return ret; +return 0 ; } static int ssd133x_fb_blit_rect(struct drm_framebuffer *fb,
@@ -1059,7 +1057,6 @@ static int ssd133x_fb_blit_rect(struct drm_framebuffer *fb,const struct drm_format_info *fi =drm_format_info (DRM_FORMAT_RGB332 );unsigned int dst_pitch;struct iosys_map dst; -int ret =0 ;if (!fi)return -EINVAL ;
@@ -1071,7 +1068,7 @@ static int ssd133x_fb_blit_rect(struct drm_framebuffer *fb,ssd133x_update_rect (ssd130x, rect, data_array, dst_pitch); -return ret; +return 0 ; } static int ssd130x_primary_plane_atomic_check(struct drm_plane *plane,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 462/1815 spi: geni-qcom: Fix sticky ret causing wrong return value on invalid proto
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Praveen Talari <[email protected]>
[ Upstream commit 2c1c13da3a3a639d2ac7221e1a5e57945cbc7235 ]
spi_geni_init() reuses 'ret' after it has already been set by the runtime PM acquire check earlier in the function. When an invalid protocol is later detected, the function returns this stale 'ret' value instead of a proper error code, so it can end up returning 0 (or some other non-error value) even though the protocol check failed.
Fix this by returning -EINVAL directly on both invalid-proto paths.
--- drivers/spi/spi-geni-qcom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-geni-qcom.c +2 -2
@@ -625,7 +625,7 @@ static int spi_geni_init(struct spi_geni_master *mas)if (spi->target) {if (proto !=GENI_SE_SPI_SLAVE ) {dev_err (mas->dev,"Invalid proto %d\n" , proto); -return ret; +return -EINVAL ; }spi_slv_setup (mas); }else if (proto ==GENI_SE_INVALID_PROTO ) {
@@ -636,7 +636,7 @@ static int spi_geni_init(struct spi_geni_master *mas) } }else if (proto !=GENI_SE_SPI ) {dev_err (mas->dev,"Invalid proto %d\n" , proto); -return ret; +return -EINVAL ; } mas->tx_fifo_depth =geni_se_get_tx_fifo_depth (se);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 463/1815 perf stat: Fix duplicate output with --for-each-cgroup
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit c16af17927e0b9105f2964338f9341e0faf7edaa ]
Currently it produces following output with duplicate events when
--for-each-cgroup option is used. It seems perf stat adds them when
it handles default events but didn't copy some fields in evsel__clone().
$ sudo perf stat -a --for-each-cgroup / true
Performance counter stats for 'system wide':
8,440,165 duration_time /
8,439,895 duration_time /
8,440,015 duration_time /
8,440,024 duration_time /
8,440,075 duration_time /
8,440,095 duration_time /
330 context-switches / # 679.4 cs/sec cs_per_second
485.69 msec cpu-clock / # 57.5 CPUs CPUs_utilized
70 cpu-migrations / # 144.1 migrations/sec migrations_per_second
71 page-faults / # 146.2 faults/sec page_faults_per_second
12,183,711 branch-misses / # 10.9 % branch_miss_rate (5.15%)
111,981,297 branches / (5.15%)
95,844,809 branches / # 197.3 M/sec branch_frequency (35.49%)
65,611,429 cpu-cycles / # 0.1 GHz cycles_frequency (98.32%)
24,170,987 cpu-cycles / (95.12%)
18,552,509 instructions / # 0.8 instructions insn_per_cycle (95.12%)
22,405,293 cpu-cycles / (64.78%)
6,840,383 stalled-cycles-frontend / # 0.31 frontend_cycles_idle (64.78%)
<not counted> cpu-cycles /
<not supported> stalled-cycles-backend / # nan backend_cycles_idle
<not supported> stalled-cycles-backend / # nan stalled_cycles_per_instruction
<not supported> instructions /
<not supported> stalled-cycles-frontend /0.006546057 seconds time elapsed
Some events weren't counted. Try disabling the NMI watchdog:
echo 0 > /proc/sys/kernel/nmi_watchdog
perf stat ...
echo 1 > /proc/sys/kernel/nmi_watchdog
But I'm worrying about opening same events multiple times. Probably due to grouping, but I'm not sure if it's beneficial in the end. Without duplication, it seems it won't cause multiplexing (assuming no other users at the same time).
--- tools/perf/util/evsel.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
tools/perf/util/evsel.c +10 -0
@@ -612,7 +612,13 @@ struct evsel *evsel__clone(struct evsel *orig) evsel->sample_read = orig->sample_read; evsel->collect_stat = orig->collect_stat; evsel->weak_group = orig->weak_group; + evsel->bpf_counter = orig->bpf_counter; evsel->use_config_name = orig->use_config_name; + evsel->skippable = orig->skippable; + evsel->dont_regroup = orig->dont_regroup; + evsel->default_metricgroup = orig->default_metricgroup; + evsel->default_show_events = orig->default_show_events; + evsel->pmu = orig->pmu; evsel->first_wildcard_match = orig->first_wildcard_match;
@@ -621,6 +627,10 @@ struct evsel *evsel__clone(struct evsel *orig) evsel->alternate_hw_config = orig->alternate_hw_config; + evsel->retire_lat = orig->retire_lat; +if (evsel->retire_lat) + evsel->retirement_latency = orig->retirement_latency; +return evsel; out_err:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 464/1815 wifi: iwlwifi: fix counter type in iwl_fwrt_dump_error_logs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
[ Upstream commit 71e67b4b59337b2f9f4fef976a27de2dad7aabf2 ]
The loop counter 'count' was declared as u8 while num_pc is u32. If firmware advertises more than 255 PC entries the counter wraps back to zero and the loop never terminates potentially causing an infinite loop or reading past the allocated pc_data array.
Change the declaration to u32 to match num_pc.
--- drivers/net/wireless/intel/iwlwifi/fw/dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/fw/dump.c +1 -1
@@ -369,7 +369,7 @@ static void iwl_fwrt_dump_fseq_regs(struct iwl_fw_runtime *fwrt)void iwl_fwrt_dump_error_logs (struct iwl_fw_runtime *fwrt) {struct iwl_pc_data *pc_data; -u8 count; +u32 count;if (!iwl_trans_device_enabled (fwrt->trans)) { IWL_ERR(fwrt,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 465/1815 wifi: iwlwifi: mvm: fix off-by-one in TXF key sanitiser
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
[ Upstream commit f6a6c01cbc046f68e6916a7e047a1bc881c8c9ab ]
iwl_mvm_frob_txf_key_iter() tracks the last matched byte position in loop variable 'i'. When a full key match is found (match == keylen), 'i' points at the last byte of the matched key. The memset start offset should therefore be i + 1 - keylen, not i - keylen; the current code zeroes one byte before the match and leaves the final key byte un-sanitised.
--- drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/ops.c +1 -1
@@ -954,7 +954,7 @@ static void iwl_mvm_frob_txf_key_iter(struct ieee80211_hw *hw, } match++;if (match == keylen) { -memset (txf->buf + i - keylen,0xAA , keylen); +memset (txf->buf + i +1 - keylen,0xAA , keylen); match =0 ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 466/1815 wifi: iwlwifi: mei: check SAP message length before reading it
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avraham Stern <[email protected]>
[ Upstream commit 7d8cc301bcba233f31b589a45f4c1c97f2bb90d6 ]
Verify the SAP message size is not larger than the local buffer before reading the message to avoid buffer overflow.
--- drivers/net/wireless/intel/iwlwifi/mei/main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/intel/iwlwifi/mei/main.c +6 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (C) 2021-2024 Intel Corporation +* Copyright (C) 2026 Intel Corporation */ #include <linux/etherdevice.h>
@@ -1147,6 +1148,11 @@ static void iwl_mei_handle_sap_rx_cmd(struct mei_cl_device *cldev,iwl_mei_read_from_q (q_head, q_sz, &rd, wr, hdr,sizeof (*hdr)); valid_rx_sz -=sizeof (*hdr); len =le16_to_cpu (hdr->len); +if (len +sizeof (*hdr) >PAGE_SIZE ) { +dev_err (&cldev->dev, +"SAP message is too big: %u\n" , len); +break ; + }if (valid_rx_sz < len)break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 467/1815 wifi: iwlwifi: guard against division by zero in iwl_dbg_tlv_alloc_fragments
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
[ Upstream commit 9318bc0c41b24705690cf80d1596cf6b711e7027 ]
Make sure we don't end-up with a num_frags = 0 situation. For that, check that the required size is not 0 and put a checker on num_frags as well.
--- drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c +7 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* -* Copyright (C) 2018-2025 Intel Corporation +* Copyright (C) 2018-2026 Intel Corporation */ #include <linux/firmware.h> #include "iwl-drv.h"
@@ -611,6 +611,9 @@ static int iwl_dbg_tlv_alloc_fragments(struct iwl_fw_runtime *fwrt, cpu_to_le32(IWL_FW_INI_LOCATION_DRAM_PATH))return 0 ; +if (!fw_mon_cfg->req_size) +return -EIO ; + num_frags =le32_to_cpu (fw_mon_cfg->max_frags_num);if (fwrt->trans->mac_cfg->device_family <IWL_DEVICE_FAMILY_AX210 ) {if (alloc_id !=IWL_FW_INI_ALLOCATION_ID_DBGC1 )
@@ -621,6 +624,9 @@ static int iwl_dbg_tlv_alloc_fragments(struct iwl_fw_runtime *fwrt,return -EIO ; } +if (!num_frags) +return -EIO ; + remain_pages =DIV_ROUND_UP (le32_to_cpu (fw_mon_cfg->req_size),PAGE_SIZE ); num_frags =min_t (u32, num_frags,BUF_ALLOC_MAX_NUM_FRAGS );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 468/1815 wifi: iwlwifi: mei: pass correct argument to function
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avraham Stern <[email protected]>
[ Upstream commit 905f57aefde4f4092a411c8a55856182fb1c7598 ]
The first argument to iwl_mei_write_cyclic_buf() should be the cldev but the q_head pointer is passed instead. Fix it.
--- drivers/net/wireless/intel/iwlwifi/mei/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mei/main.c +1 -1
@@ -458,7 +458,7 @@ static int iwl_mei_send_sap_msg_payload(struct mei_cl_device *cldev, notif_q = &dir->q_ctrl_blk[SAP_QUEUE_IDX_NOTIF ]; q_head = mei->shared_mem.q_head[SAP_DIRECTION_HOST_TO_ME ][SAP_QUEUE_IDX_NOTIF ]; q_sz = mei->shared_mem.q_size[SAP_DIRECTION_HOST_TO_ME ][SAP_QUEUE_IDX_NOTIF ]; - ret =iwl_mei_write_cyclic_buf (q_head, notif_q, q_head, hdr, q_sz); + ret =iwl_mei_write_cyclic_buf (cldev, notif_q, q_head, hdr, q_sz);if (ret <0 )return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 469/1815 gpu: host1x: Avoid double device_add when clients already present
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Perttunen <[email protected]>
[ Upstream commit 254290869fd234b85119c48dbb98efa5fcd41a31 ]
host1x_device_add looks through the idle clients list to populate subdevs, and any matches entries are moved from the subdevs list to the active list. If all subdevs are populated, device_add will be called on the device. The secondary "subdevs list empty" check will then incorrectly again call device_add.
However, this would require a convoluted scenario since clients don't typically end up on the idle clients list.
Fix by checking whether the device was already added before adding again.
--- drivers/gpu/host1x/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/host1x/bus.c +1 -1
@@ -508,7 +508,7 @@ static int host1x_device_add(struct host1x *host1x,* Add device even if there are no subdevs to ensure syncpoint functionality * is available regardless of whether any engine subdevices are present */ -if (list_empty (&device->subdevs)) { +if (list_empty (&device->subdevs) && !device->registered) { err =device_add (&device->dev);if (err <0 )dev_err (&device->dev,"failed to add device: %d\n" , err);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 470/1815 gpu: host1x: Fix offset calculation in trace_write_gather
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Perttunen <[email protected]>
[ Upstream commit eb896850964d3dfce291b4fdff9c2d42d85e564b ]
When a gather longer than 2*TRACE_MAX_LENGTH (256) words is traced through host1x_cdma_push_gather, the reported BO offset drifts from the third iteration onward.
Fix the calculation by properly calculating the value on each loop rather than accumulating.
In reality, gathers tend to be pretty short so this is unlikely to ever have been observed.
--- drivers/gpu/host1x/hw/channel_hw.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/host1x/hw/channel_hw.c +2 -3
@@ -36,10 +36,9 @@ static void trace_write_gather(struct host1x_cdma *cdma, struct host1x_bo *bo,for (i =0 ; i < words; i +=TRACE_MAX_LENGTH ) {u32 num_words =min (words - i,TRACE_MAX_LENGTH ); - offset += i *sizeof (u32); -trace_host1x_cdma_push_gather (dev_name (dev), bo, - num_words, offset, + num_words, + offset + i *sizeof (u32), mem); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 471/1815 gpu: host1x: Avoid stack over-read in debug output helpers
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Perttunen <[email protected]>
[ Upstream commit bc17ac285fb708f22a8fa2c0ed32eceb1d37e6d6 ]
host1x_debug_output() and host1x_debug_cont() used vsnprintf(), which returns the length the formatted string would have reached with an unbounded buffer. That return value was passed straight to o->fn as the number of bytes to emit.
This could cause a read past end of the output buffer if a call to host1x_debug_* produced a string longer than 256 bytes. This only affected the debugfs files as the printk debug sink ignores the number of bytes. In practice, this is very unlikely to occur.
Fix by switching to vscnprintf(), which returns the number of bytes actually written.
--- drivers/gpu/host1x/debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/host1x/debug.c +2 -2
@@ -31,7 +31,7 @@ void host1x_debug_output(struct output *o, const char *fmt, ...)int len;va_start (args, fmt); - len =vsnprintf (o->buf,sizeof (o->buf), fmt, args); + len =vscnprintf (o->buf,sizeof (o->buf), fmt, args);va_end (args); o->fn (o->ctx, o->buf, len, false);
@@ -43,7 +43,7 @@ void host1x_debug_cont(struct output *o, const char *fmt, ...)int len;va_start (args, fmt); - len =vsnprintf (o->buf,sizeof (o->buf), fmt, args); + len =vscnprintf (o->buf,sizeof (o->buf), fmt, args);va_end (args); o->fn (o->ctx, o->buf, len, true);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 472/1815 drm/msm/adreno: fix use after free on error path in a6xx_gpu_init()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit b8a9c9c5787bed1243e5364c89ca66c26b4e4d83 ]
The a6xx_destroy() function frees "a6xx_gpu" and so "adreno_gpu" points to freed memory. Preserve the error code before freeing the memory to avoid a use after free.
Patchwork: https://patchwork.freedesktop.org/patch/732275/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +2 -1
@@ -2770,8 +2770,9 @@ static struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) adreno_gpu->ubwc_config =qcom_ubwc_config_get_data ();if (IS_ERR (adreno_gpu->ubwc_config)) { + ret =PTR_ERR (adreno_gpu->ubwc_config);a6xx_destroy (&(a6xx_gpu->base.base)); -return ERR_CAST (adreno_gpu->ubwc_config); +return ERR_PTR (ret); }/* Set up the preemption specific bits and pieces for each ringbuffer */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 473/1815 drm/msm/a6xx: Fix stale rpmh votes after suspend
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shivam Rawat <[email protected]>
[ Upstream commit d9108bfdb746edacdb05bd27959a4ae63c6c7f3f ]
There are stale RPMH votes (BCM votes) observed after GMU suspend. This is because the rpmh stop sequences are skipped during gmu suspend. Fix this and also move GMU to reset state to avoid any further activity.
Patchwork: https://patchwork.freedesktop.org/patch/730652/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +4 -1
@@ -642,7 +642,7 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)int ret;u32 val; -if (test_and_clear_bit (GMU_STATUS_FW_START , &gmu->status)) +if (!test_and_clear_bit (GMU_STATUS_FW_START , &gmu->status))return ;if (adreno_is_a840 (adreno_gpu))
@@ -1465,6 +1465,9 @@ static void a6xx_gmu_shutdown(struct a6xx_gmu *gmu)/* Stop the interrupts and mask the hardware */ a6xx_gmu_irq_disable (gmu); +/* Halt the gmu cm3 core */ +gmu_write (gmu,REG_A6XX_GMU_CM3_SYSRESET ,1 ); +/* Tell RPMh to power off the GPU */ a6xx_rpmh_stop (gmu);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 474/1815 drm/msm: Recover HW before retire hung submit
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jie Zhang <[email protected]>
[ Upstream commit b303e1d52811de7d1bcf793560754d4df68d4a1c ]
During recovery, it is not safe to retire the hung submit before we recover the GPU. Retiring the submit triggers BO free and that can result in GPU pagefaults since the GPU may be actively accessing those BOs.
To fix this, retire the submits after gpu recovery is complete in recover_worker().
Patchwork: https://patchwork.freedesktop.org/patch/730655/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/msm_gpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/msm_gpu.c +2 -2
@@ -552,11 +552,11 @@ static void recover_worker(struct kthread_work *work)msm_update_fence (ring->fctx, fence); } + gpu->funcs->recover (gpu); +/* retire completed submits, plus the one that hung: */ retire_submits (gpu); - gpu->funcs->recover (gpu); -/* * Replay all remaining submits starting with highest priority * ring
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 475/1815 drm/msm/a6xx: Fix A663 GPUCC register list for state capture
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jie Zhang <[email protected]>
[ Upstream commit fc7ccbc6174b79ffab5be5dca5b6e253df22f030 ]
The GPUCC register list for A663 is incorrect, which can cause out-of-bounds register access during GPU state capture.
Update it to use the correct register ranges.
Patchwork: https://patchwork.freedesktop.org/patch/730656/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +3 -1
@@ -1244,7 +1244,9 @@ static void a6xx_get_gmu_registers(struct msm_gpu *gpu,_a6xx_get_gmu_registers (gpu, a6xx_state, &a6xx_gmu_reglist[1 ], &a6xx_state->gmu_registers[1 ], true); -if (adreno_is_a621 (adreno_gpu) ||adreno_is_a623 (adreno_gpu)) +if (adreno_is_a621 (adreno_gpu) || +adreno_is_a623 (adreno_gpu) || +adreno_is_a663 (adreno_gpu))_a6xx_get_gmu_registers (gpu, a6xx_state, &a621_gpucc_reg, &a6xx_state->gmu_registers[2 ], false);else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 476/1815 drm/msm/a6xx: Fix A621 GPUCC register list for state capture
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jie Zhang <[email protected]>
[ Upstream commit d052d0358fb89b59718b9c24871d72006d4b89b0 ]
A621 uses an incorrect GPUCC register list during state capture.
The existing list matches A623/A663. Rename it accordingly and add a dedicated A621 GPUCC register list.
Patchwork: https://patchwork.freedesktop.org/patch/730659/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 7 ++++--- drivers/gpu/drm/msm/adreno/a6xx_gpu_state.h | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +4 -3
@@ -1244,11 +1244,12 @@ static void a6xx_get_gmu_registers(struct msm_gpu *gpu,_a6xx_get_gmu_registers (gpu, a6xx_state, &a6xx_gmu_reglist[1 ], &a6xx_state->gmu_registers[1 ], true); -if (adreno_is_a621 (adreno_gpu) || -adreno_is_a623 (adreno_gpu) || -adreno_is_a663 (adreno_gpu)) +if (adreno_is_a621 (adreno_gpu))_a6xx_get_gmu_registers (gpu, a6xx_state, &a621_gpucc_reg, &a6xx_state->gmu_registers[2 ], false); +else if (adreno_is_a623 (adreno_gpu) ||adreno_is_a663 (adreno_gpu)) +_a6xx_get_gmu_registers (gpu, a6xx_state, &a623_gpucc_reg, + &a6xx_state->gmu_registers[2 ], false);else _a6xx_get_gmu_registers (gpu, a6xx_state, &a6xx_gpucc_reg, &a6xx_state->gmu_registers[2 ], false);
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.h +12 -0
@@ -377,6 +377,17 @@ static const u32 a6xx_gmu_gpucc_registers[] = { };static const u32 a621_gmu_gpucc_registers[] = { +/* GPU CC */ +0x24000 ,0x2400e ,0x24400 ,0x2440e ,0x24800 ,0x24805 ,0x24c00 ,0x24cff , +0x25800 ,0x25804 ,0x25c00 ,0x25c04 ,0x26000 ,0x26004 ,0x26400 ,0x26405 , +0x26414 ,0x2641d ,0x2642a ,0x26430 ,0x26432 ,0x26432 ,0x26441 ,0x26455 , +0x26466 ,0x26468 ,0x26478 ,0x2647a ,0x26489 ,0x2648a ,0x2649c ,0x2649e , +0x264a0 ,0x264a3 ,0x264b3 ,0x264b5 ,0x264c5 ,0x264c7 ,0x264d6 ,0x264d8 , +0x264e8 ,0x264e9 ,0x264f9 ,0x264fc ,0x2650b ,0x2650c ,0x2651c ,0x2651e , +0x26540 ,0x26570 ,0x26600 ,0x26616 ,0x26620 ,0x2662d , +}; + +static const u32 a623_gmu_gpucc_registers[] = {/* GPU CC */ 0x24000 ,0x2400e ,0x24400 ,0x2440e ,0x25800 ,0x25804 ,0x25c00 ,0x25c04 ,0x26000 ,0x26004 ,0x26400 ,0x26405 ,0x26414 ,0x2641d ,0x2642a ,0x26430 ,
@@ -402,6 +413,7 @@ static const struct a6xx_registers a6xx_gmu_reglist[] = {static const struct a6xx_registers a6xx_gpucc_reg =REGS (a6xx_gmu_gpucc_registers,0 ,0 );static const struct a6xx_registers a621_gpucc_reg =REGS (a621_gmu_gpucc_registers,0 ,0 ); +static const struct a6xx_registers a623_gpucc_reg =REGS (a623_gmu_gpucc_registers,0 ,0 );static u32 a6xx_get_cp_roq_size (struct msm_gpu *gpu);static u32 a7xx_get_cp_roq_size (struct msm_gpu *gpu);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 477/1815 drm/msm/a6xx: Fix IRQ storm during msm_recovery test
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jie Zhang <[email protected]>
[ Upstream commit bc024d325e98b6b2806e00455e030622fb8e1820 ]
Once a hang is triggered by the msm_recovery test, the gpu error irq remains asserted and triggers an interrupt storm. In the worst case, this IRQ storm lands on the CPU core where the hangcheck timer is scheduled, blocking it from running. This eventually leads to CPU watchdog timeouts.
To fix this, mask the gpu error irqs during msm_recovery test and enable them back during the recovery.
Patchwork: https://patchwork.freedesktop.org/patch/730660/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 5 +++++ drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 5 ++++- drivers/gpu/drm/msm/adreno/a8xx_gpu.c | 5 ++++- drivers/gpu/drm/msm/msm_gpu.c | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +5 -0
@@ -1275,6 +1275,11 @@ static irqreturn_t a5xx_irq(struct msm_gpu *gpu) status & ~A5XX_RBBM_INT_0_MASK_RBBM_AHB_ERROR);if (priv->disable_err_irq) { +/* Turn off interrupts to avoid interrupt storm */ +gpu_write (gpu,REG_A5XX_RBBM_INT_0_MASK , +A5XX_RBBM_INT_0_MASK_CP_CACHE_FLUSH_TS | +A5XX_RBBM_INT_0_MASK_CP_SW ); + status &=A5XX_RBBM_INT_0_MASK_CP_CACHE_FLUSH_TS |A5XX_RBBM_INT_0_MASK_CP_SW ; }
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +4 -1
@@ -1911,8 +1911,11 @@ static irqreturn_t a6xx_irq(struct msm_gpu *gpu)gpu_write (gpu,REG_A6XX_RBBM_INT_CLEAR_CMD , status); -if (priv->disable_err_irq) +if (priv->disable_err_irq) { +/* Turn off interrupts to avoid interrupt storm */ +gpu_write (gpu,REG_A6XX_RBBM_INT_0_MASK ,A6XX_RBBM_INT_0_MASK_CP_CACHE_FLUSH_TS ); status &=A6XX_RBBM_INT_0_MASK_CP_CACHE_FLUSH_TS ; + }if (status &A6XX_RBBM_INT_0_MASK_RBBM_HANG_DETECT )a6xx_fault_detect_irq (gpu);
drivers/gpu/drm/msm/adreno/a8xx_gpu.c +4 -1
@@ -1211,8 +1211,11 @@ irqreturn_t a8xx_irq(struct msm_gpu *gpu)gpu_write (gpu,REG_A8XX_RBBM_INT_CLEAR_CMD , status); -if (priv->disable_err_irq) +if (priv->disable_err_irq) { +/* Turn off interrupts to avoid interrupt storm */ +gpu_write (gpu,REG_A8XX_RBBM_INT_0_MASK ,A6XX_RBBM_INT_0_MASK_CP_CACHE_FLUSH_TS ); status &=A6XX_RBBM_INT_0_MASK_CP_CACHE_FLUSH_TS ; + }if (status &A6XX_RBBM_INT_0_MASK_RBBM_HANG_DETECT )a8xx_fault_detect_irq (gpu);
drivers/gpu/drm/msm/msm_gpu.c +2 -0
@@ -552,6 +552,8 @@ static void recover_worker(struct kthread_work *work)msm_update_fence (ring->fctx, fence); } + priv->disable_err_irq = false; + gpu->funcs->recover (gpu);/* retire completed submits, plus the one that hung: */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 478/1815 drm/msm: Fix task_struct reference leak in recover_worker
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jie Zhang <[email protected]>
[ Upstream commit 40b793714ad8f393ab3d469f9d00b20ebda46257 ]
get_pid_task() increments the task reference count, but the corresponding put_task_struct() was missing in the else branch, leaking a reference on every GPU hang recovery.
Patchwork: https://patchwork.freedesktop.org/patch/730662/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/msm_gpu.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/msm_gpu.c +2 -0
@@ -505,6 +505,8 @@ static void recover_worker(struct kthread_work *work)*/ if (!vm->managed)msm_gem_vm_unusable (submit->vm); + +put_task_struct (task); } noreclaim_flag =memalloc_noreclaim_save ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 479/1815 drm/msm: Only fini scheduler after successful init
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit e2332abed2a4d3caa59052095dc16e4ce44791ea ]
msm_ringbuffer_new() destroys a partially initialized ring through msm_ringbuffer_destroy() when an allocation or scheduler setup step fails.
If drm_sched_init() fails before it finishes initializing the scheduler, the failure path still calls drm_sched_fini(). That teardown path assumes the scheduler work items, lists, and workqueue state were initialized.
Track successful scheduler initialization and call drm_sched_fini() only after drm_sched_init() returned 0.
This issue was found by a static analysis checker and confirmed by manual source review.
Patchwork: https://patchwork.freedesktop.org/patch/738905/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/msm_ringbuffer.c | 7 ++++--- drivers/gpu/drm/msm/msm_ringbuffer.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/msm_ringbuffer.c +4 -3
@@ -109,9 +109,9 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id, ring->memptrs_iova = memptrs_iova; ret =drm_sched_init (&ring->sched, &args); -if (ret) { +if (ret) goto fail; - } + ring->sched_initialized = true;INIT_LIST_HEAD (&ring->submits);spin_lock_init (&ring->submit_lock);
@@ -133,7 +133,8 @@ void msm_ringbuffer_destroy(struct msm_ringbuffer *ring)if (IS_ERR_OR_NULL (ring))return ; -drm_sched_fini (&ring->sched); +if (ring->sched_initialized) +drm_sched_fini (&ring->sched);msm_fence_context_free (ring->fctx);
drivers/gpu/drm/msm/msm_ringbuffer.h +1 -0
@@ -56,6 +56,7 @@ struct msm_ringbuffer {* The job scheduler for this ring. */ struct drm_gpu_scheduler sched; +bool sched_initialized;/* * List of in-flight submits on this ring. Protected by submit_lock.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 480/1815 bpf: Sync tail_call_reachable with callee state on entry
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pu Lehui <[email protected]>
[ Upstream commit 3513ea9dab6c1a3d2dc8e6160c41f690206948b6 ]
Currently in check_max_stack_depth_subprog, when the verifier enters a new callee branch, the local tail_call_reachable is not properly synchronized with the callee's state.
Consider a main prog branching into multiple subprogs:
subprog0 -> tailcall
main <
subprog1 -> subprog2When the verifier finishes checking subprog0 and backtracks to main prog, the local tail_call_reachable state is left as true. As it proceeds to subprog1, this uncleared state leaks into the new branch, falsely marking subprog1 and subprog2 as tailcall reachable.
Fix this by explicitly syncing tail_call_reachable with the callee's has_tail_call state on entry. The caller's state is safely preserved and restored via the existing backtracking logic.
--- kernel/bpf/verifier.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/verifier.c +2 -2
@@ -5211,8 +5211,8 @@ static int check_max_stack_depth_subprog(struct bpf_verifier_env *env, int idx,if (!priv_stack_supported) subprog[idx].priv_stack_mode =NO_PRIV_STACK ; -if (subprog[idx].has_tail_call) - tail_call_reachable = true; +/* sync tail_call_reachable with callee state on entry */ + tail_call_reachable = subprog[idx].has_tail_call; frame =bpf_subprog_is_global (env, idx) ?0 : frame +1 ;if (frame >=MAX_CALL_FRAMES ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 481/1815 scsi: ufs: core: Avoid possible memory reclaim deadlock in TX EQTR context
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Can Guo <[email protected]>
[ Upstream commit 760fc6f0e25a72832c2fcf37ecf5f1b770ec8374 ]
TX EQTR may run while devfreq gear scaling has quiesced the UFS tagset. In that context, functions ufshcd_tx_eqtr(), __ufshcd_tx_eqtr() and ufs_qcom_get_rx_fom() allocate memory with GFP_KERNEL. If direct reclaim is triggered, reclaim/writeback can depend on I/O to UFS device. Because the queue is quiesced, this can cause deadlock.
Use memalloc_noio_save/restore() in ufshcd_tx_eqtr() to cover all allocations in the TX EQTR call tree, including:
- params->eqtr_record in ufshcd_tx_eqtr()
- eqtr_data in __ufshcd_tx_eqtr()
- params in ufs_qcom_get_rx_fom()
This is preferred over tagging individual call sites with GFP_NOIO, as it automatically covers any future allocations added anywhere in the call tree without requiring each caller to be aware of this constraint.
[mkp: fix label as suggested by Bart]
--- drivers/ufs/core/ufs-txeq.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
drivers/ufs/core/ufs-txeq.c +21 -6
@@ -10,6 +10,7 @@#include <linux/delay.h> #include <linux/errno.h> #include <linux/kernel.h> +#include <linux/sched/mm.h> #include <ufs/ufshcd.h> #include <ufs/unipro.h> #include "ufshcd-priv.h"
@@ -1216,14 +1217,25 @@ static int ufshcd_tx_eqtr(struct ufs_hba *hba, struct ufs_pa_layer_attr *pwr_mode) {struct ufs_pa_layer_attr old_pwr_info; +unsigned int noio_flag;int ret; +/* +* ufshcd_tx_eqtr() is called from a power-mode-change context where +* I/O is suspended. Use memalloc_noio_save() to propagate GFP_NOIO +* to all allocations in the call tree instead of tagging each call +* site individually. +*/ + noio_flag =memalloc_noio_save (); +if (!params->eqtr_record) { params->eqtr_record =devm_kzalloc (hba->dev,sizeof (*params->eqtr_record),GFP_KERNEL ); -if (!params->eqtr_record) -return -ENOMEM ; +if (!params->eqtr_record) { + ret = -ENOMEM ; + goto out_noio_restore; + } }memcpy (&old_pwr_info, &hba->pwr_info,sizeof (struct ufs_pa_layer_attr ));
@@ -1231,23 +1243,26 @@ static int ufshcd_tx_eqtr(struct ufs_hba *hba, ret =ufshcd_tx_eqtr_prepare (hba, pwr_mode);if (ret) {dev_err (hba->dev,"Failed to prepare TX EQTR: %d\n" , ret); - goto out; + goto out_unprepare; } ret =ufshcd_vops_tx_eqtr_notify (hba,PRE_CHANGE , pwr_mode);if (ret) - goto out; + goto out_unprepare; ret =__ufshcd_tx_eqtr (hba, params, pwr_mode);if (ret) - goto out; + goto out_unprepare; ret =ufshcd_vops_tx_eqtr_notify (hba,POST_CHANGE , pwr_mode); -out: +out_unprepare:if (ret)ufshcd_tx_eqtr_unprepare (hba, &old_pwr_info); +out_noio_restore: +memalloc_noio_restore (noio_flag); +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 482/1815 wifi: rtw89: fw: use MAC source for IO offload delay command
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chia-Yuan Li <[email protected]>
[ Upstream commit 730dbda6dc70d29180eb2a7e9fa36823838bb042 ]
The udelay/mdelay helpers set the command source to RTW89_FW_CMD_OFLD_SRC_OTHER (4), which does not fit the two-bit field RTW89_H2C_CMD_OFLD_W0_SRC (GENMASK(1, 0)). The le32_encode_bits() masks it down to 0 (RTW89_FW_CMD_OFLD_SRC_BB), and compiler throws __field_overflow() error. Fortunately it still works because firmware ignores the source field for a delay command.
Use RTW89_FW_CMD_OFLD_SRC_MAC as the vendor driver does, and drop the unused RTW89_FW_CMD_OFLD_SRC_OTHER enumerator.
--- drivers/net/wireless/realtek/rtw89/fw.c | 4 ++-- drivers/net/wireless/realtek/rtw89/fw.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/realtek/rtw89/fw.c +2 -2
@@ -11780,7 +11780,7 @@ static void rtw89_fw_cmd_ofld_write_rf(struct rtw89_dev *rtwdev,static void rtw89_fw_cmd_ofld_udelay (struct rtw89_dev *rtwdev,u32 us) {struct rtw89_fw_cmd_ofld_arg cmd = { - .src =RTW89_FW_CMD_OFLD_SRC_OTHER , + .src =RTW89_FW_CMD_OFLD_SRC_MAC , .type =RTW89_FW_CMD_OFLD_DELAY , .value = us, };
@@ -11794,7 +11794,7 @@ static void rtw89_fw_cmd_ofld_udelay(struct rtw89_dev *rtwdev, u32 us)static void rtw89_fw_cmd_ofld_mdelay (struct rtw89_dev *rtwdev,u32 ms) {struct rtw89_fw_cmd_ofld_arg cmd = { - .src =RTW89_FW_CMD_OFLD_SRC_OTHER , + .src =RTW89_FW_CMD_OFLD_SRC_MAC , .type =RTW89_FW_CMD_OFLD_DELAY , .value = ms *1000 , };
drivers/net/wireless/realtek/rtw89/fw.h +0 -1
@@ -3144,7 +3144,6 @@ enum rtw89_fw_cmd_ofld_arg_src {RTW89_FW_CMD_OFLD_SRC_RF ,RTW89_FW_CMD_OFLD_SRC_MAC , RTW89_FW_CMD_OFLD_SRC_RF_DDIE, - RTW89_FW_CMD_OFLD_SRC_OTHER, }; enum rtw89_fw_cmd_ofld_arg_type {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 483/1815 crypto: sl3516 - drop invalid sg_dma_len checks before DMA mapping
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 3ae59a2eba64b3648f069aa52eeaaeefdfe4bb2f ]
sg_dma_len() is only valid after mapping the scatterlist with dma_map_sg(). However, sl3516_ce_need_fallback() checks it before the source and destination scatterlists are mapped. Thus, a stale DMA length that is not a multiple of 16 could incorrectly force a software fallback when CONFIG_NEED_SG_DMA_LENGTH=y.
Remove the invalid checks; the existing scatterlist length checks are sufficient.
--- drivers/crypto/gemini/sl3516-ce-cipher.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/crypto/gemini/sl3516-ce-cipher.c +0 -8
@@ -56,10 +56,6 @@ static bool sl3516_ce_need_fallback(struct skcipher_request *areq) ce->fallback_mod16++;return true; } -if ((sg_dma_len (sg) %16 ) !=0 ) { - ce->fallback_mod16++; -return true; - }if (!IS_ALIGNED (sg->offset,16 )) { ce->fallback_align16++;return true;
@@ -72,10 +68,6 @@ static bool sl3516_ce_need_fallback(struct skcipher_request *areq) ce->fallback_mod16++;return true; } -if ((sg_dma_len (sg) %16 ) !=0 ) { - ce->fallback_mod16++; -return true; - }if (!IS_ALIGNED (sg->offset,16 )) { ce->fallback_align16++;return true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 484/1815 crypto: aspeed - Propagate platform_get_irq() errors
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Narasimharao Vadlamudi <[email protected]>
[ Upstream commit eed5fde79651c66e0e24ba3d78a92afb63a76215 ]
platform_get_irq() returns a positive IRQ number on success and a negative error code on failure. aspeed_acry_probe() and aspeed_hace_probe() already detect negative returns, but both convert every failure to -ENXIO.
Return the original error code so callers can handle errors such as -EPROBE_DEFER correctly.
--- drivers/crypto/aspeed/aspeed-acry.c | 2 +- drivers/crypto/aspeed/aspeed-hace.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/aspeed/aspeed-acry.c +1 -1
@@ -728,7 +728,7 @@ static int aspeed_acry_probe(struct platform_device *pdev)/* Get irq number and register it */ acry_dev->irq =platform_get_irq (pdev,0 );if (acry_dev->irq <0 ) -return -ENXIO ; +return acry_dev->irq; rc =devm_request_irq (dev, acry_dev->irq, aspeed_acry_irq,0 ,dev_name (dev), acry_dev);
drivers/crypto/aspeed/aspeed-hace.c +1 -1
@@ -127,7 +127,7 @@ static int aspeed_hace_probe(struct platform_device *pdev)/* Get irq number and register it */ hace_dev->irq =platform_get_irq (pdev,0 );if (hace_dev->irq <0 ) -return -ENXIO ; +return hace_dev->irq; rc =devm_request_irq (&pdev->dev, hace_dev->irq, aspeed_hace_irq,0 ,dev_name (&pdev->dev), hace_dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 485/1815 ACPI: processor: idle: Expand _LPI package sanity checks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit d5c13047a132162d2649be876906ead691d12948 ]
The _LPI package sanity checks in acpi_processor_evaluate_lpi() miss a couple of things, so expand them by adding a buffer size check before retrieving a struct acpi_power_register from it (and skip the given state if the buffer is not large enough to hold a register structure) and making the function avoid copying the state description from the ACPI table if there are too few elements in the package supposed to hold it.
While at it, relocate and rephrase a comment about skipping _LPI state package elements [7-8].
--- drivers/acpi/processor_idle.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/acpi/processor_idle.c +21 -7
@@ -927,6 +927,13 @@ static int acpi_processor_evaluate_lpi(acpi_handle handle,if (obj->type ==ACPI_TYPE_BUFFER ) {struct acpi_power_register *reg; +if (obj->buffer.length <sizeof (*reg)) { +acpi_handle_debug (handle, +"Invalid register data for _LPI state %d\n" , + state_idx); +continue ; + } + reg = (struct acpi_power_register *)obj->buffer.pointer;if (reg->space_id !=ACPI_ADR_SPACE_SYSTEM_IO && reg->space_id !=ACPI_ADR_SPACE_FIXED_HARDWARE )
@@ -945,13 +952,6 @@ static int acpi_processor_evaluate_lpi(acpi_handle handle,continue ; } -/* elements[7,8] skipped for now i.e. Residency/Usage counter*/ - - obj = pkg_elem +9 ; -if (obj->type ==ACPI_TYPE_STRING ) -strscpy (lpi_state->desc, obj->string.pointer, -ACPI_CX_DESC_LEN ); - lpi_state->index = state_idx;if (obj_get_integer (pkg_elem +0 , &lpi_state->min_residency)) {pr_debug ("No min. residency found, assuming 10 us\n" );
@@ -974,6 +974,20 @@ static int acpi_processor_evaluate_lpi(acpi_handle handle,if (obj_get_integer (pkg_elem +5 , &lpi_state->enable_parent_state)) lpi_state->enable_parent_state =0 ; + +/* Skip elements [7-8] i.e. Residency/Usage counters. */ + +/* +* Avoid out-of-bounds access if the size of the package is less +* than expected. +*/ +if (element->package.count <10 ) +continue ; + + obj = pkg_elem +9 ; +if (obj->type ==ACPI_TYPE_STRING ) +strscpy (lpi_state->desc, obj->string.pointer, +ACPI_CX_DESC_LEN ); }acpi_handle_debug (handle,"Found %d power states\n" , state_idx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 486/1815 usb: gadget: f_uac1_legacy: remove broken string configfs attributes
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
[ Upstream commit 590d74ec8f488e06b9f1c0f8f0941f45531f3a55 ]
The UAC1_STR_ATTRIBUTE macro defines configfs show/store handlers for the fn_play, fn_cap, and fn_cntl string options. The store function contains an inverted null check on the kstrndup() return value.
This means every write attempt returns -ENOMEM on success and dereferences a NULL pointer on allocation failure. The attributes have been broken and unused for many years.
Remove the UAC1_STR_ATTRIBUTE macro and the three attributes it generated. The internal defaults (FILE_PCM_PLAYBACK, FILE_PCM_CAPTURE, FILE_CONTROL) set in f_audio_alloc_inst() are unaffected.
--- .../testing/configfs-usb-gadget-uac1_legacy | 3 - Documentation/usb/gadget-testing.rst | 3 - drivers/usb/gadget/function/f_uac1_legacy.c | 56 ------------------- drivers/usb/gadget/function/u_uac1_legacy.h | 3 - 4 files changed, 65 deletions(-)
Documentation/ABI/testing/configfs-usb-gadget-uac1_legacy +0 -3
@@ -5,8 +5,5 @@ Description: The attributes: audio_buf_size - audio buffer size - fn_cap - capture pcm device file name - fn_cntl - control device file name - fn_play - playback pcm device file name req_buf_size - ISO OUT endpoint request buffer size req_count - ISO OUT endpoint request count
Documentation/usb/gadget-testing.rst +0 -3
@@ -714,9 +714,6 @@ The uac1 function provides these attributes in its function directory: =============== ==================================== audio_buf_size audio buffer size - fn_cap capture pcm device file name - fn_cntl control device file name - fn_play playback pcm device file name req_buf_size ISO OUT endpoint request buffer size req_count ISO OUT endpoint request count =============== ====================================
drivers/usb/gadget/function/f_uac1_legacy.c +0 -56
72 lines not on this page · raw message
drivers/usb/gadget/function/u_uac1_legacy.h +0 -3
@@ -62,9 +62,6 @@ struct f_uac1_legacy_opts {char *fn_cap;char *fn_cntl; unsigned bound:1; - unsigned fn_play_alloc:1; - unsigned fn_cap_alloc:1; - unsigned fn_cntl_alloc:1;struct mutex lock;int refcnt; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 487/1815 tty: hvc: restrict HVC_DCC to ARMv6+ and ARM64
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 782f4dbd1794b4f30dc116a7ca42c5962c409be8 ]
hvc_dcc drives the JTAG DCC via the ARMv6/v7 CP14 debug registers (mrc/mcr p14, 0, rX, c0, c1/c5, 0 in asm/dcc.h). That encoding is undefined on older ARM cores, and also on ARMv7-M, but HVC_DCC only depends on ARM, so it can be enabled on e.g. ARM926 (ARCH_MULTI_V5), where hvc_dcc_console_init() runs __dcc_putchar() at boot and takes an undefined-instruction trap before the console is up:
Internal error: Oops - undefined instruction: 0 [#1] ARM PC is at hvc_dcc_check+0x50/0x8c hvc_dcc_check from hvc_dcc_console_init+0x18/0x48 hvc_dcc_console_init from console_init+0x58/0x170 Kernel panic - not syncing: Fatal exception
Restrict HVC_DCC to the CPUs where that encoding is valid: the CPU_V6 || CPU_V6K || CPU_V7 set that arch/arm/include/debug/icedcc.S guards it with, plus ARM64.
--- drivers/tty/hvc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/hvc/Kconfig +1 -1
@@ -79,7 +79,7 @@ config HVC_UDBG config HVC_DCC bool "ARM JTAG DCC console" - depends on ARM || ARM64 + depends on (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || ARM64 select HVC_DRIVER select SERIAL_CORE_CONSOLE help
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 488/1815 UDF symlink pathComponent header OOB read
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lee <[email protected]>
[ Upstream commit d23eb7380d1594cda31a5dc8487dd2a5c8def8c7 ]
udf_symlink_filler() can enter udf_pc_to_char() with a partial pathComponent header.
Validate that enough input remains for a complete pathComponent header before accessing it. Reject malformed symlink data that would otherwise make udf_pc_to_char() perform an out-of-bounds read.
--- fs/udf/symlink.c | 2 ++ 1 file changed, 2 insertions(+)
fs/udf/symlink.c +2 -0
@@ -36,6 +36,8 @@ static int udf_pc_to_char(struct super_block *sb, unsigned char *from,/* Reserve one byte for terminating \0 */ tolen--;while (elen < fromlen) { +if (fromlen - elen <sizeof (struct pathComponent )) +return -EIO ; pc = (struct pathComponent *)(from + elen); elen +=sizeof (struct pathComponent );switch (pc->componentType) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 489/1815 staging: rtl8723bs: fix xmit_frame/xmit_buf leaks on mgnt-frame error paths
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Nguyen <[email protected]>
[ Upstream commit 41b8209376dffbd7b0b85c8bc4697d9166ac62ef ]
issue_beacon(), issue_probersp() and issue_asocrsp() obtain a management xmit_frame together with its xmit_buf from the driver's fixed-size management-TX pools via alloc_mgtxmitframe(). On the normal path the frame is handed to dump_mgntframe(), which transfers ownership and eventually returns both objects to their pools (the frame and, for beacons, the buf in rtl8723bs_mgnt_xmit(); other bufs via the pending-xmitbuf/TX-completion path).
Several error/edge paths return early after a successful alloc_mgtxmitframe() but before dump_mgntframe(), so ownership is never transferred and neither object is freed:
- issue_beacon(): beacon larger than 512 bytes
- issue_probersp(): cur_network->ie_length > MAX_IE_SZ
- issue_probersp(): kzalloc() of the SSID scratch buffer fails
- issue_asocrsp(): pkt_type is neither ASSOCRSP nor REASSOCRSP
Because alloc_mgtxmitframe() removes the frame and buf from their free lists (list_del_init) without placing them on any pending list, an orphaned pair is on no list and referenced by nobody, so it is only reclaimed at driver teardown. Repeated hits progressively exhaust the management-TX pools until alloc_mgtxmitframe() returns NULL and the interface can no longer send beacons or probe/assoc responses.
Free the frame and buffer on these paths, matching the existing correct error handling in issue_assocreq().
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +17 -5
@@ -2181,8 +2181,11 @@ void issue_beacon(struct adapter *padapter, int timeout_ms)spin_unlock_bh (&pmlmepriv->bcn_update_lock); -if ((pattrib->pktlen +TXDESC_SIZE ) >512 ) +if ((pattrib->pktlen +TXDESC_SIZE ) >512 ) { +rtw_free_xmitbuf (pxmitpriv, pmgntframe->pxmitbuf); +rtw_free_xmitframe (pxmitpriv, pmgntframe);return ; + } pattrib->last_txcmdsz = pattrib->pktlen;
@@ -2243,8 +2246,11 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pattrib->pktlen = pattrib->hdrlen; pframe += pattrib->hdrlen; -if (cur_network->ie_length >MAX_IE_SZ ) +if (cur_network->ie_length >MAX_IE_SZ ) { +rtw_free_xmitbuf (pxmitpriv, pmgntframe->pxmitbuf); +rtw_free_xmitframe (pxmitpriv, pmgntframe);return ; + }if ((pmlmeinfo->state&0x03 ) ==WIFI_FW_AP_STATE ) { pwps_ie =rtw_get_wps_ie (cur_network->ies+_FIXED_IE_LENGTH_, cur_network->ie_length-_FIXED_IE_LENGTH_,NULL , &wps_ielen);
@@ -2291,8 +2297,11 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2pu8 *ies = pmgntframe->buf_addr+TXDESC_OFFSET +sizeof (struct ieee80211_hdr_3addr ); buf =kzalloc (MAX_IE_SZ ,GFP_ATOMIC ); -if (!buf) +if (!buf) { +rtw_free_xmitbuf (pxmitpriv, pmgntframe->pxmitbuf); +rtw_free_xmitframe (pxmitpriv, pmgntframe);return ; + } ssid_ie =rtw_get_ie (ies+_FIXED_IE_LENGTH_,WLAN_EID_SSID , &ssid_ielen, (pframe-ies)-_FIXED_IE_LENGTH_);
@@ -2670,10 +2679,13 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_iSetSeqNum (pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; -if ((pkt_type ==WIFI_ASSOCRSP ) || (pkt_type ==WIFI_REASSOCRSP )) +if ((pkt_type ==WIFI_ASSOCRSP ) || (pkt_type ==WIFI_REASSOCRSP )) {SetFrameSubType (pwlanhdr, pkt_type); -else + }else { +rtw_free_xmitbuf (pxmitpriv, pmgntframe->pxmitbuf); +rtw_free_xmitframe (pxmitpriv, pmgntframe);return ; + } pattrib->hdrlen =sizeof (struct ieee80211_hdr_3addr ); pattrib->pktlen += pattrib->hdrlen;
Signature · 1 line
2.53.0