7.2.6-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 1328/1815 selftests: drv-net: so_txtime: only send test traffic to sch_etf
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
[ Upstream commit ef3d6cca02c8a7b6465fb1691823524b86d1cb99 ]
The ETF qdiscs drops traffic without a socket or txtime. Even with parameter skip_sock_check regular traffic is affected by ETF.
This test ran fine when run manually in a pure software environment. But with drv-net across two hosts tests fail as early as when calling cfg.remote.deploy due to effectively losing connectivity.
Isolate the intended test traffic:
- mark that with SO_MARK 100
- install a regular permissive root prio qdisc for background traffic
- install the ETF qdisc as leaf
- install a filter that only directs SO_MARK 100 traffic to this leaf
Technically other high prio traffic will map onto this leaf based on ToS band mapping too. But that is immaterial in practice.
--- tools/testing/selftests/drivers/net/config | 2 ++ tools/testing/selftests/drivers/net/so_txtime.py | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-)
tools/testing/selftests/drivers/net/config +2 -0
@@ -8,6 +8,7 @@ CONFIG_NET_ACT_SKBEDIT=m CONFIG_NET_CLS_ACT=y CONFIG_NET_CLS_BPF=y CONFIG_NET_CLS_FLOWER=m +CONFIG_NET_CLS_FW=m CONFIG_NET_CLS_MATCHALL=m CONFIG_NETCONSOLE=m CONFIG_NETCONSOLE_DYNAMIC=y
@@ -17,6 +18,7 @@ CONFIG_NETKIT=y CONFIG_NET_SCH_ETF=m CONFIG_NET_SCH_FQ=m CONFIG_NET_SCH_INGRESS=y +CONFIG_NET_SCH_PRIO=m CONFIG_PPP=y CONFIG_PPPOE=y CONFIG_VLAN_8021Q=m
tools/testing/selftests/drivers/net/so_txtime.py +13 -3
@@ -27,7 +27,7 @@ def test_so_txtime(cfg, clockid, ipver, args_tx, args_rx, expect_success): cmd_addr = f"-S {cfg.addr_v[ipver]} -D {cfg.remote_addr_v[ipver]}" cmd_args = f"-{ipver} -c {clockid} -t {tstart} {cmd_addr}" cmd_rx = f"{cfg.bin_remote} {cmd_args} {args_rx} -r" - cmd_tx = f"{cfg.bin_local} {cmd_args} {args_tx}" + cmd_tx = f"{cfg.bin_local} -m 100 {cmd_args} {args_tx}" expect_fail = not expect_success if slow_machine:
@@ -45,7 +45,7 @@ def _qdisc_setup(ifname, qdisc, optargs=""): """ orig = tc(f"qdisc show dev {ifname} root", json=True)[0].get("kind", None) defer(tc, f"qdisc replace dev {ifname} root {orig}") - tc(f"qdisc replace dev {ifname} root {qdisc} {optargs}") + tc(f"qdisc replace dev {ifname} root handle 1: {qdisc} {optargs}") def _test_variants_fq():
@@ -96,11 +96,21 @@ def _test_variants_etf(): def test_so_txtime_etf(cfg, ipver, args_tx, args_rx, expect_fail): """Run all variants of etf tests.""" cfg.require_ipver(ipver) + + # root qdisc for background traffic (e.g., bkg()) + _qdisc_setup(cfg.ifname, "prio") + + # leaf ETF qdisc only for intended packets try: - _qdisc_setup(cfg.ifname, "etf", "clockid CLOCK_TAI delta 400000") + etf_args = "clockid CLOCK_TAI delta 400000" + tc(f"qdisc add dev {cfg.ifname} parent 1:1 handle 10: etf {etf_args}") except Exception as e: raise KsftSkipEx("tc does not support qdisc etf. skipping") from e + # redirect mark 100 to leaf + filter_args = "protocol all handle 100 fw flowid 1:1" + tc(f"filter add dev {cfg.ifname} parent 1: {filter_args}") + test_so_txtime(cfg, "tai", ipver, args_tx, args_rx, expect_fail)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1329/1815 powerpc/configs: enable CONFIG_RAS to fix EDAC support
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Walle <[email protected]>
[ Upstream commit 3921cfc2e8155a767235801be88cbd0e4c73508d ]
Before commit e3c4ff6d8c94 ("EDAC: Remove EDAC_MM_EDAC") EDAC_MM_EDAC selected RAS, after that commit, EDAC depends on RAS, but nobody enables it. Enable it in the config again.
--- arch/powerpc/configs/85xx-hw.config | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/configs/85xx-hw.config +1 -0
@@ -90,6 +90,7 @@ CONFIG_PPC_EPAPR_HV_BYTECHAN=y CONFIG_QE_GPIO=y CONFIG_QUICC_ENGINE=y CONFIG_RAPIDIO=y +CONFIG_RAS=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_CMOS=y CONFIG_RTC_DRV_DS1307=y
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1330/1815 apparmor: fix unconfined user namespace restriction forced stack
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Johansen <[email protected]>
[ Upstream commit 08c2f7c8d4b1434cfae006f3daf4d1bce330b57b ]
If a task is already confined by a stack the unprivileged transition restriction on unconfined is not correctly, applied. This results in an escape if two transitions through an unconfined profile can be executed.
Fix this by pushing the check into the per profile label build. The check will always be done against unconfined and result in a stack of just the unconfined component when necessary.
--- security/apparmor/domain.c | 80 +++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 26 deletions(-)
security/apparmor/domain.c +54 -26
@@ -874,6 +874,52 @@ static struct aa_label *label_merge_wrap(struct aa_label *a, struct aa_label *b,return label; } +static bool is_profile_priv_restricted_to_stack (const struct cred *subj_cred, +struct aa_profile *profile) +{ +if (profile_unconfined (profile) && profile == profile->ns->unconfined && + aa_unprivileged_unconfined_restricted && +/* cap_capable returns false (0) if true, hence true here means +* doesn't have capability and the stack will be restricted +*/ +cap_capable (current_cred (), &init_user_ns,CAP_MAC_OVERRIDE , +CAP_OPT_NOAUDIT )) +return true; +return false; +} + +static const char *stack_msg ="change_profile unprivileged unconfined converted to stacking" ; + +static struct aa_label *priv_restricted_transition (const struct cred *subj_cred, +struct aa_profile *profile, +const char *op,u32 request, +const char *name, +struct aa_label *transition, +gfp_t gfp) +{ +if (!is_profile_priv_restricted_to_stack (subj_cred, profile)) +return aa_get_newest_label (transition); + +/* transition allowed but only via stack */ +struct aa_label *target =label_merge_wrap (&profile->label, + transition, gfp); +if (IS_ERR_OR_NULL (target)) +return target; + +/* doing this here is less than optimal but good enough until the +* fs mediation rework lands +*/ +struct aa_perms perms = { + .allow = request, + .audit = request, + }; +aa_audit_file (subj_cred, profile, &perms, op, + request, name,NULL , target, + subj_cred->euid, stack_msg,0 ); + +return target; +} + static struct aa_label *handle_onexec(const struct cred *subj_cred, struct aa_label *label, struct aa_label *onexec, bool stack,
@@ -902,7 +948,10 @@ static struct aa_label *handle_onexec(const struct cred *subj_cred, new =fn_label_build_in_scope (label, profile,GFP_KERNEL , stack ?label_merge_wrap (&profile->label, onexec,GFP_KERNEL ) - :aa_get_newest_label (onexec), + :priv_restricted_transition (subj_cred, profile, +OP_CHANGE_ONEXEC ,AA_MAY_ONEXEC , + bprm->filename, onexec, +GFP_KERNEL ),profile_transition (subj_cred, profile, bprm, buffer, cond, unsafe));AA_BUG (!new);
@@ -1406,8 +1455,6 @@ static int change_profile_perms_wrapper(const char *op, const char *name,return error; } -static const char *stack_msg ="change_profile unprivileged unconfined converted to stacking" ; -/** * aa_change_profile - perform a one-way profile transition * @fqname: name of profile may include namespace (NOT NULL)
@@ -1467,28 +1514,6 @@ int aa_change_profile(const char *fqname, int flags) op =OP_CHANGE_PROFILE ; } -/* This should move to a per profile test. Requires pushing build -* into callback -*/ -if (!stack &&unconfined (label) && - label == &labels_ns (label)->unconfined->label && - aa_unprivileged_unconfined_restricted && -/* TODO: refactor so this check is a fn */ -cap_capable (current_cred (), &init_user_ns,CAP_MAC_OVERRIDE , -CAP_OPT_NOAUDIT )) { -/* regardless of the request in this case apparmor -* stacks against unconfined so admin set policy can't be -* by-passed -*/ - stack = true; - perms.audit = request; - (void )fn_for_each_in_scope (label, profile, -aa_audit_file (subj_cred, profile, &perms, op, - request, auditname,NULL , target, -GLOBAL_ROOT_UID , stack_msg,0 )); - perms.audit =0 ; - } -if (*fqname =='&' ) { stack = true;/* don't have label_parse() do stacking */
@@ -1559,7 +1584,10 @@ int aa_change_profile(const char *fqname, int flags)/* stacking is always a subset, so only check the nonstack case */ if (!stack) { new =fn_label_build_in_scope (label, profile,GFP_KERNEL , -aa_get_label (target), +priv_restricted_transition (subj_cred, profile, + op, request, + auditname, target, +GFP_KERNEL ),aa_get_label (&profile->label));AA_BUG (!new);if (IS_ERR (new))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1331/1815 iommu/amd: Fix incorrect device ID in invalid PASID error message
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasant Hegde <[email protected]>
[ Upstream commit 5322e19fc5acf013784207bc38191cd418a8bb48 ]
The IO page fault notifier handler logs pdev->dev.id when reporting an invalid PASID, but pdev->dev.id is the kernel-internal device ID and not the IOMMU device ID (BDF). Use dev_data->devid instead, which reflects actual devid.
--- drivers/iommu/amd/ppr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd/ppr.c +1 -1
@@ -140,7 +140,7 @@ static void iommu_call_iopf_notifier(struct amd_iommu *iommu, u64 *raw)if (event.fault.prm.pasid ==0 || event.fault.prm.pasid >= dev_data->max_pasids) {pr_info_ratelimited ("Invalid PASID : 0x%x, device : 0x%x\n" , - event.fault.prm.pasid, pdev->dev.id); + event.fault.prm.pasid, dev_data->devid); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1332/1815 rust: uapi: replace direct asm-generic/ioctl.h include with linux/ioctl.h
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Kumar Chaurasiya (IBM) <[email protected]>
[ Upstream commit cdfcaa36ac93aa96df8310d7e57860f7600b2861 ]
rust/uapi/uapi_helper.h was directly including <uapi/asm-generic/ioctl.h> instead of the proper <uapi/linux/ioctl.h>.
On powerpc, <uapi/linux/ioctl.h> pulls in <uapi/asm/ioctl.h> first, which defines _IOC_SIZEBITS, _IOC_DIRBITS, _IOC_NONE, and _IOC_WRITE with the arch-specific values, before falling through to <asm-generic/ioctl.h>. By bypassing that chain and including <asm-generic/ioctl.h> directly, the arch-specific overrides never ran first, so when other headers in the compilation later brought in the full arch-aware chain, Clang saw those four macros being defined a second time and emitted:
clang diag: arch/powerpc/include/uapi/asm/ioctl.h:5:9: warning: '_IOC_SIZEBITS' macro redefined [-Wmacro-redefined] clang diag: arch/powerpc/include/uapi/asm/ioctl.h:6:9: warning: '_IOC_DIRBITS' macro redefined [-Wmacro-redefined] clang diag: arch/powerpc/include/uapi/asm/ioctl.h:8:9: warning: '_IOC_NONE' macro redefined [-Wmacro-redefined] clang diag: arch/powerpc/include/uapi/asm/ioctl.h:10:9: warning: '_IOC_WRITE' macro redefined [-Wmacro-redefined]
Fix this by replacing the direct include of <uapi/asm-generic/ioctl.h> with <uapi/linux/ioctl.h>, which is the correct arch-aware entry point and already maintains the intended include order.
--- rust/uapi/uapi_helper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rust/uapi/uapi_helper.h +1 -1
@@ -6,11 +6,11 @@* Sorted alphabetically. */ -#include <uapi/asm-generic/ioctl.h> #include <uapi/drm/drm.h> #include <uapi/drm/nova_drm.h> #include <uapi/drm/panthor_drm.h> #include <uapi/linux/android/binder.h> +#include <uapi/linux/ioctl.h> #include <uapi/linux/mdio.h> #include <uapi/linux/mii.h> #include <uapi/linux/ethtool.h>
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1333/1815 phy: renesas: rcar-gen3-usb2: Ignore missing VBUS regulator
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 9ea8d49c6cc6e217f5f5818369f659dc25bf89bf ]
Commit b6d7dd157763 ("phy: renesas: rcar-gen3-usb2: Add regulator for OTG VBUS control") introduced support for controlling OTG VBUS through the regulator framework.
As part of this change, the driver started requesting an exclusive "vbus" regulator for OTG-capable PHYs with no_adp_ctrl set. The lookup failure was propagated unconditionally, causing probe to fail on platforms where no VBUS regulator is described.
On RZ/V2H and RZ/V2N, which do not use a VBUS regulator, this results in the following error:
phy_rcar_gen3_usb2 15800200.usb-phy:
dummy supplies not allowed for exclusive requests (id=vbus)
This failure completely prevents the USB 2.0 interface from initializing.
Fix this by allowing the probe to continue if an external VBUS regulator is missing. Only propagate the error if the internal vbus-regulator node is explicitly present, or if the lookup returns -EPROBE_DEFER. For all other missing regulator errors, gracefully assume no external VBUS regulator is available and return 0.
--- drivers/phy/renesas/phy-rcar-gen3-usb2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/phy/renesas/phy-rcar-gen3-usb2.c +11 -2
@@ -898,8 +898,17 @@ static int rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(struct rcar_geint ret; channel->vbus =devm_regulator_get_exclusive (dev,"vbus" ); -if (IS_ERR (channel->vbus)) -return PTR_ERR (channel->vbus); +if (IS_ERR (channel->vbus)) { + ret =PTR_ERR (channel->vbus); +/* If vbus-regulator node was present vbus regulator should be available */ +if (channel->otg_internal_reg) +return ret; + +if (ret == -EPROBE_DEFER ) +return ret; + +return 0 ; + }if (enable) { ret =regulator_enable (channel->vbus);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1334/1815 phy: qcom: qmp-combo: Correct pre-emphasis table for QMP v4 DP PHYs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Esteban Urrutia <[email protected]>
[ Upstream commit 481807f939077059db278edd0467e7e609b6c9a7 ]
Comparing sm8350 and sm8450 tables, this seems to be a typo.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +1 -1
@@ -2108,7 +2108,7 @@ static const u8 qmp_dp_v4_pre_emphasis_hbr3_hbr2[4][4] = {static const u8 qmp_dp_v4_pre_emphasis_hbr_rbr[4 ][4 ] = { {0x00 ,0x0d ,0x14 ,0x1a }, {0x00 ,0x0e ,0x15 ,0xff }, - {0x00 ,0x0d ,0xff ,0xff }, + {0x00 ,0x0e ,0xff ,0xff }, {0x03 ,0xff ,0xff ,0xff } };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1335/1815 phy: qcom: qmp-combo: Drop qmp_v4_calibrate_dp_phy
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Esteban Urrutia <[email protected]>
[ Upstream commit 8fd2b30d187fa33e5dd30699d3e3a3662c1610c9 ]
There are no downstream device trees that specify five values in the qcom,aux-cfg1-settings array.
Plus, after cross referencing both downstream device trees and entries which refer this function, only 0x13 is specified.
Since 0x13 is written at initialization time, drop this function as a whole, and remove now unused variable assignations.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 31 ----------------------- 1 file changed, 31 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +0 -31
@@ -2325,7 +2325,6 @@ static int qmp_v3_calibrate_dp_phy(struct qmp_combo *qmp);static void qmp_v4_dp_aux_init (struct qmp_combo *qmp);static void qmp_v4_configure_dp_tx (struct qmp_combo *qmp);static int qmp_v4_configure_dp_phy (struct qmp_combo *qmp); -static int qmp_v4_calibrate_dp_phy (struct qmp_combo *qmp);static void qmp_v8_dp_aux_init (struct qmp_combo *qmp);static int qmp_v8_configure_dp_clocks (struct qmp_combo *qmp);
@@ -2466,7 +2465,6 @@ static const struct qmp_phy_cfg sar2130p_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v6_usb3phy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -2603,7 +2601,6 @@ static const struct qmp_phy_cfg sc8180x_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2650,7 +2647,6 @@ static const struct qmp_phy_cfg sc8280xp_usb43dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2696,7 +2692,6 @@ static const struct qmp_phy_cfg x1e80100_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2785,7 +2780,6 @@ static const struct qmp_phy_cfg sm8250_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2834,7 +2828,6 @@ static const struct qmp_phy_cfg sm8350_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2882,7 +2875,6 @@ static const struct qmp_phy_cfg sm8550_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v6_usb3phy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -2928,7 +2920,6 @@ static const struct qmp_phy_cfg sm8650_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v6_usb3phy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -2974,7 +2965,6 @@ static const struct qmp_phy_cfg sm8750_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v8_usb3phy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -3020,7 +3010,6 @@ static const struct qmp_phy_cfg glymur_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v8_configure_dp_clocks, .configure_dp_phy = qmp_v8_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v8_n3_usb43dpphy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -3316,7 +3305,6 @@ static void qmp_v4_dp_aux_init(struct qmp_combo *qmp)writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG7 );writel (0xb7 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG8 );writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG9 ); - qmp->dp_aux_cfg =0 ; writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK | PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK |
@@ -3345,7 +3333,6 @@ static void qmp_v8_dp_aux_init(struct qmp_combo *qmp)writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG7 );writel (0xb7 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG8 );writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG9 ); - qmp->dp_aux_cfg =0 ; writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK | PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK |
@@ -3605,24 +3592,6 @@ static int qmp_v8_configure_dp_phy(struct qmp_combo *qmp)return 0 ; } -/* -* We need to calibrate the aux setting here as many times -* as the caller tries -*/ -static int qmp_v4_calibrate_dp_phy (struct qmp_combo *qmp) -{ -static const u8 cfg1_settings[] = {0x20 ,0x13 ,0x23 ,0x1d }; -u8 val; - - qmp->dp_aux_cfg++; - qmp->dp_aux_cfg %=ARRAY_SIZE (cfg1_settings); - val = cfg1_settings[qmp->dp_aux_cfg]; - -writel (val, qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG1 ); - -return 0 ; -} -static int qmp_combo_dp_configure (struct phy *phy,union phy_configure_opts *opts) {const struct phy_configure_opts_dp *dp_opts = &opts->dp;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1336/1815 arm64: entry: Avoid unnecessary local_irq_disable() on kernel exit
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Murzin <[email protected]>
[ Upstream commit 39aebe0e89469c2904e60b1e977e0d4dbf33326b ]
Currently, when exiting to kernel mode, we attempt involuntary preemption. The preemption logic expects IRQs to be disabled, which is why we call local_irq_disable() before attempting preemption.
However, depending on the context, local_irq_disable() may be unnecessary:
- __el1_irq(), the non-NMI EL1 IRQ path, already has IRQs disabled, so local_irq_disable() is redundant.
- irqentry_exit_to_kernel_mode_preempt() immediately returns when exiting from an NMI-like context, so calling local_irq_disable() beforehand is unnecessary work.
Furthermore, it confuses the pNMI state tracking when we are in a context with interrupts disabled and the GIC_PRIO_PSR_I_SET bit is set in the PMR, leading to a warning when CONFIG_ARM64_DEBUG_PRIORITY_MASKING=y:
WARNING: ./arch/arm64/include/asm/irqflags.h:63 at arm64_exit_to_kernel_mode+0xb8/0xc0, CPU#40: retsnoop/31805
CPU: 40 UID: 0 PID: 31805 Comm: retsnoop Not tainted 7.2.0-rc6-next-20260805 #7 PREEMPTLAZY
pstate: 234013c9 (nzCv DAIF +PAN -UAO +TCO +DIT +SSBS BTYPE=--)
pc : arm64_exit_to_kernel_mode (arch/arm64/kernel/entry-common.c:63)
lr : el1_abort (arch/arm64/kernel/entry-common.c:323)
pmr: 000000f0
Call trace:
arm64_exit_to_kernel_mode (arch/arm64/kernel/entry-common.c:63) (P)
el1_abort (arch/arm64/kernel/entry-common.c:323)
el1h_64_sync_handler (arch/arm64/kernel/entry-common.c:449)
el1h_64_sync (arch/arm64/kernel/entry.S:589)
[...]Split arm64_exit_to_kernel_mode() into preempt, non-preempt, and dispatch parts so that we can avoid this extra work where it is not needed and avoid breaking the pNMI tracking logic.
--- arch/arm64/kernel/entry-common.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
arch/arm64/kernel/entry-common.c +25 -5
@@ -52,16 +52,36 @@ static noinstr irqentry_state_t arm64_enter_from_kernel_mode(struct pt_regs *reg* After this function returns it is not safe to call regular kernel code, * instrumentable code, or any code which may trigger an exception. */ -static void noinstr arm64_exit_to_kernel_mode(struct pt_regs *regs, -irqentry_state_t state) +static void noinstr __arm64_exit_to_kernel_mode(struct pt_regs *regs, +irqentry_state_t state) { -local_irq_disable (); -irqentry_exit_to_kernel_mode_preempt (regs, state);local_daif_mask ();mte_check_tfsr_exit ();irqentry_exit_to_kernel_mode_after_preempt (regs, state); } +/* +* We are returning from the context which allows involuntary kernel preemption +*/ +static void noinstr arm64_exit_to_kernel_mode_preempt(struct pt_regs *regs, +irqentry_state_t state) +{ +irqentry_exit_to_kernel_mode_preempt (regs, state); +__arm64_exit_to_kernel_mode (regs, state); +} + +static void noinstr arm64_exit_to_kernel_mode(struct pt_regs *regs, +irqentry_state_t state) +{ +if (!regs_irqs_disabled (regs)) { +local_irq_disable (); +arm64_exit_to_kernel_mode_preempt (regs, state); +return ; + } + +__arm64_exit_to_kernel_mode (regs, state); +} + static __always_inline void arm64_syscall_enter_from_user_mode(struct pt_regs *regs) {enter_from_user_mode (regs);
@@ -509,7 +529,7 @@ static __always_inline void __el1_irq(struct pt_regs *regs,do_interrupt_handler (regs, handler);irq_exit_rcu (); -arm64_exit_to_kernel_mode (regs, state); +arm64_exit_to_kernel_mode_preempt (regs, state); } static void noinstr el1_interrupt(struct pt_regs *regs,void (*handler)(struct pt_regs *))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1337/1815 spi: sprd-adi: Fix probe succeeding without registering the controller
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Babanpreet Singh <[email protected]>
[ Upstream commit f092e1c935015ee0a0fea1a0374f4cab7b71953c ]
With CONFIG_HWSPINLOCK=n the of_hwspin_lock_get_id() stub returns 0 unconditionally. In sprd_adi_probe() the guard
if (ret > 0 || (IS_ENABLED(CONFIG_HWSPINLOCK) && ret == 0))
is false for that 0, so it takes the else branch, where the switch has no case for 0 and lands in
default: return dev_err_probe(&pdev->dev, ret, "failed to find hwlock id\n");
dev_err_probe() returns its err argument unchanged, so probe logs "failed to find hwlock id" and then returns 0, reporting success. sprd_adi_hw_init(), the restart handler and devm_spi_register_controller() are all skipped: the device binds but no SPI controller is ever registered.
The hardware spinlock is optional for this controller and the -ENOENT arm already covers "no hardware spinlock supplied". Treat the stub's 0 the same way and continue without a lock; all four users of sadi->hwlock already test it for NULL.
This is not reachable on production kernels. Kconfig has
depends on HWSPINLOCK || (COMPILE_TEST && !HWSPINLOCK)
so the affected configuration exists only under COMPILE_TEST, where no real hardware is present.
Found by smatch:drivers/spi/spi-sprd-adi.c:560 sprd_adi_probe() warn: passing zero to 'dev_err_probe'
--- drivers/spi/spi-sprd-adi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/spi/spi-sprd-adi.c +6 -0
@@ -553,6 +553,12 @@ static int sprd_adi_probe(struct platform_device *pdev)return -ENXIO ; }else {switch (ret) { +case 0 : +/* +* Only reachable with CONFIG_HWSPINLOCK=n, where the +* of_hwspin_lock_get_id() stub returns 0. +*/ + fallthrough;case -ENOENT :dev_info (&pdev->dev,"no hardware spinlock supplied\n" );break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1338/1815 ASoC: qcom: q6apm: keep the graph start count in sync with the DSP
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jorijn van der Graaf <[email protected]>
[ Upstream commit daa7ffd765ae67a83e77dae32c66ce2d6d995d19 ]
q6apm_graph_start() increments start_count even when APM_CMD_GRAPH_START fails, leaving the graph counted as running while the DSP never started it. A later start - a retried prepare, or a resume after a failed start - then finds a non-zero count, skips the command and returns success with no data flowing.
Count the graph only once the DSP has accepted the start. The count then stays at zero for a graph that never started, so also stop decrementing below zero in q6apm_graph_stop(): the compressed free path stops unconditionally, and a negative count would make the next start skip the command in the same way.
--- sound/soc/qcom/qdsp6/q6apm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
sound/soc/qcom/qdsp6/q6apm.c +9 -3
@@ -802,14 +802,17 @@ EXPORT_SYMBOL_GPL(q6apm_graph_prepare);int q6apm_graph_start (struct q6apm_graph *graph) {struct audioreach_graph *ar_graph = graph->ar_graph; -int ret =0 ; +int ret; -if (ar_graph->start_count ==0 ) +if (ar_graph->start_count ==0 ) { ret =audioreach_graph_mgmt_cmd (ar_graph,APM_CMD_GRAPH_START ); +if (ret) +return ret; + } ar_graph->start_count++; -return ret; +return 0 ; }EXPORT_SYMBOL_GPL (q6apm_graph_start);
@@ -817,6 +820,9 @@ int q6apm_graph_stop(struct q6apm_graph *graph) {struct audioreach_graph *ar_graph = graph->ar_graph; +if (ar_graph->start_count ==0 ) +return 0 ; +if (--ar_graph->start_count >0 )return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1339/1815 arm64: bti: Disable in-kernel BTI with recent versions of Clang
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit d3359af21fc9e7a47577ff90e821b6510ec34dee ]
The following BTI exception was seen when loading a livepatch module:
Internal error: Oops - BTI: 0000000036000001 [#1] SMP pstate: 634004c9 (nZCv daIF +PAN -UAO +TCO +DIT -SSBS BTYPE=jc) pc : kill_orphaned_pgrp+0x0/0x150 lr : do_exit+0x498/0xaf0 [livepatch_combined]
The problem is that the patch module's do_exit() is branching to a static function in vmlinux using a module PLT veneer (indirect branch), but the target function doesn't have a BTI landing pad.
Clang 21+ omits the landing pad for static functions which can only be reached by a direct branch. That's normally fine for ordinary modules which only branch to global exported functions, but Mark Brown points out [1] that this isn't guaranteed if the module branches between sections. Futhermore, livepatch modules use klp relocations to reference arbitrary kernel symbols, so with CONFIG_RANDOMIZE_MODULE_REGION_FULL the module is far enough from the kernel that every R_AARCH64_CALL26 needs a PLT.
Put Clang 21+ in the naughty corner alongside GCC, which suffers from the same issue, by disabling CONFIG_ARM64_BTI_KERNEL until we have a version of the toolchain with the problem resolved.
--- arch/arm64/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/Kconfig +2 -0
@@ -2116,6 +2116,8 @@ config ARM64_BTI_KERNEL depends on !CC_IS_GCC || GCC_VERSION >= 100100 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106671 depends on !CC_IS_GCC + # https://github.com/llvm/llvm-project/issues/215547 + depends on !CC_IS_CLANG || CLANG_VERSION < 210000 depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_ARGS) help Build the kernel with Branch Target Identification annotations
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1340/1815 s390/irqflags: Add out-of-line definitions of arch_local_irq_*() for KMSAN
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Leoshkevich <[email protected]>
[ Upstream commit 3f7c9f9c36b47a2a5cdbc56597eddf32662ef7fa ]
Inline KMSAN arch_local_irq_*() definitions run afoul of -Wstatic-in-inline. Move them out-of-line. Make sure decompressor and non-GPL modules see the out-of-line definitions.
--- arch/s390/include/asm/irqflags.h | 20 +++++++++++++------- arch/s390/kernel/Makefile | 1 + arch/s390/kernel/irqflags.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 arch/s390/kernel/irqflags.c
arch/s390/include/asm/irqflags.h +13 -7
@@ -37,18 +37,24 @@ static __always_inline void __arch_local_irq_ssm(unsigned long flags) asmvolatile ("ssm %0" : :"Q" (flags) :"memory" ); } -#ifdef CONFIG_KMSAN -#define arch_local_irq_attributes noinline notrace __no_sanitize_memory __maybe_unused +#if defined(CONFIG_KMSAN ) && !defined(__DECOMPRESSOR) +unsigned long arch_local_save_flags (void ); +unsigned long arch_local_irq_save (void ); +void arch_local_irq_enable_external (void ); +void arch_local_irq_enable (void );#else -#define arch_local_irq_attributes __always_inline +#define arch_local_save_flags __arch_local_save_flags +#define arch_local_irq_save __arch_local_irq_save +#define arch_local_irq_enable_external __arch_local_irq_enable_external +#define arch_local_irq_enable __arch_local_irq_enable#endif -static arch_local_irq_attributes unsigned long arch_local_save_flags (void ) +static __always_inline unsigned long __arch_local_save_flags (void ) {return __arch_local_irq_stnsm (0xff ); } -static arch_local_irq_attributes unsigned long arch_local_irq_save (void ) +static __always_inline unsigned long __arch_local_irq_save (void ) {return __arch_local_irq_stnsm (0xfc ); }
@@ -58,12 +64,12 @@ static __always_inline void arch_local_irq_disable(void)arch_local_irq_save (); } -static arch_local_irq_attributes void arch_local_irq_enable_external(void) +static __always_inline void __arch_local_irq_enable_external(void) {__arch_local_irq_stosm (0x01 ); } -static arch_local_irq_attributes void arch_local_irq_enable(void) +static __always_inline void __arch_local_irq_enable(void) {__arch_local_irq_stosm (0x03 ); }
arch/s390/kernel/Makefile +1 -0
@@ -72,6 +72,7 @@ obj-$(CONFIG_STACKPROTECTOR) += stackprotector.o obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o obj-$(CONFIG_KEXEC_FILE) += kexec_elf.o obj-$(CONFIG_CERT_STORE) += cert_store.o +obj-$(CONFIG_KMSAN) += irqflags.o obj-$(CONFIG_PERF_EVENTS) += perf_event.o obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf.o perf_cpum_sf.o
arch/s390/kernel/irqflags.c new file +28 -0
@@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/export.h> +#include <asm/irqflags.h> + +noinstr unsigned long arch_local_save_flags (void ) +{ +return __arch_local_save_flags (); +} +EXPORT_SYMBOL (arch_local_save_flags); + +noinstr unsigned long arch_local_irq_save (void ) +{ +return __arch_local_irq_save (); +} +EXPORT_SYMBOL (arch_local_irq_save); + +noinstr void arch_local_irq_enable_external(void) +{ +__arch_local_irq_enable_external (); +} +EXPORT_SYMBOL (arch_local_irq_enable_external); + +noinstr void arch_local_irq_enable(void) +{ +__arch_local_irq_enable (); +} +EXPORT_SYMBOL (arch_local_irq_enable);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1341/1815 nvmet: fix heap out-of-bounds read in nvmet_auth_negotiate()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit 5bb96cc218835769ab74ec7f3ea2bf81fbffe955 ]
nvmet_execute_auth_send() allocates the DH-HMAC-CHAP message buffer with the host-supplied transfer length (tl) and hands it to nvmet_auth_negotiate() without passing tl along. nvmet_auth_negotiate() then reads the negotiate header and, for each of the halen hash identifiers and dhlen DH group identifiers, indexes into the fixed idlist[60] array (hashes at idlist[0..halen), groups at idlist[30..]).
Neither the transfer length nor halen/dhlen is validated. A malicious or non-conformant host can report a tl smaller than the negotiate structure, or a halen/dhlen larger than the array (both are u8, up to 255), making the loops read past the end of the allocated buffer (heap out-of-bounds read). The sibling nvmet_auth_reply() already validates tl against the structure size; the negotiate path did not.
Pass tl into nvmet_auth_negotiate(), reject a tl that does not cover the negotiate data plus one full protocol descriptor, and reject halen/dhlen larger than NVME_AUTH_DHCHAP_MAX_DH_IDS.
--- drivers/nvme/target/fabrics-cmd-auth.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/nvme/target/fabrics-cmd-auth.c +10 -2
@@ -30,12 +30,16 @@ void nvmet_auth_sq_init(struct nvmet_sq *sq) sq->dhchap_step =NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE ; } -static u8 nvmet_auth_negotiate (struct nvmet_req *req,void *d) +static u8 nvmet_auth_negotiate (struct nvmet_req *req,void *d,u32 tl) {struct nvmet_ctrl *ctrl = req->sq->ctrl;struct nvmf_auth_dhchap_negotiate_data *data = d;int i, hash_id =0 , fallback_hash_id =0 , dhgid, fallback_dhgid; +if (tl <sizeof (*data) + +sizeof (struct nvmf_auth_dhchap_protocol_descriptor )) +return NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD ; + pr_debug("%s: ctrl %d qid %d: data sc_d %d napd %d authid %d halen %d dhlen %d\n", __func__, ctrl->cntlid, req->sq->qid, data->sc_c, data->napd, data->auth_protocol[0].dhchap.authid,
@@ -71,6 +75,10 @@ static u8 nvmet_auth_negotiate(struct nvmet_req *req, void *d) NVME_AUTH_DHCHAP_AUTH_ID)return NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD ; +if (data->auth_protocol[0 ].dhchap.dhlen >NVME_AUTH_DHCHAP_MAX_DH_IDS || + data->auth_protocol[0 ].dhchap.halen >NVME_AUTH_DHCHAP_MAX_HASH_IDS ) +return NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD ; +for (i =0 ; i < data->auth_protocol[0 ].dhchap.halen; i++) {u8 host_hmac_id = data->auth_protocol[0 ].dhchap.idlist[i];
@@ -316,7 +324,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req) }else if (data->auth_id != req->sq->dhchap_step) goto done_failure1;/* Validate negotiation parameters */ - dhchap_status =nvmet_auth_negotiate (req, d); + dhchap_status =nvmet_auth_negotiate (req, d, tl);if (dhchap_status ==0 ) req->sq->dhchap_step =NVME_AUTH_DHCHAP_MESSAGE_CHALLENGE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1342/1815 nvme-apple: Destroy the admin queue on removal
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Peter <[email protected]>
[ Upstream commit 87d5b9864c8118d26f54de4b66d2bddf2c659272 ]
The admin queue is allocated with blk_mq_alloc_queue() but never destroyed. nvme_free_ctrl() only drops the last reference and blk_mq_exit_queue() and blk_sync_queue() never run: the hctx is never moved to q->unused_hctx_list and the timeout timer and work stay armed on a queue that is about to be freed which will eventually oops inside blk_mq_timeout_work().
This can only be triggered when the controller fails to come up and is then immediately torn down again which is why no one ever ran into this before.
Let's just copy what the pcie driver does: unquiesce and destroy the admin queue before nvme_uninit_ctrl().
With this the following WARN followed by a panic no longer happens:
WARNING: block/blk-mq.c:4390 at blk_mq_release+0x194/0x238, CPU#4: kworker/u34:4/119
CPU: 4 UID: 0 PID: 119 Comm: kworker/u34:4 Not tainted 7.2.0-rc1-dirty #248 PREEMPT
Hardware name: Apple Mac mini (M1, 2020) (DT)
Workqueue: nvme-wq apple_nvme_remove_dead_ctrl_work
pstate: 61400005 (nZCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
pc : blk_mq_release+0x194/0x238
lr : blk_mq_release+0x58/0x238
sp : ffffc000833a3b50
x29: ffffc000833a3b50 x28: ffff80001d0450f8 x27: ffff800020c95200
x26: 0000000000000088 x25: 0000000000000000 x24: ffff800020f36805
x23: 0000000000000000 x22: ffffc00081a86878 x21: ffff800020be9c60
x20: 0000000000000000 x19: ffff800022501698 x18: 000000000000000a
x17: 7365757165722066 x16: 666f7265776f7020 x15: 0000000000000000
x14: 0000000000000028 x13: 0000000000004def x12: 0000000000000003
x11: 0000000000000000 x10: 0000000000000000 x9 : ffffc000805b4fc8
x8 : ffffc00081915820 x7 : ffffc00081c4f3c8 x6 : 0000000000000001
x5 : 0000000000000004 x4 : ffff800022498d80 x3 : ffffc000833a3b14
x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff800022501698
Call trace:
blk_mq_release+0x194/0x238 (P)
blk_put_queue+0x8c/0xf0
nvme_free_ctrl+0x4c/0x260
device_release+0x44/0x128
kobject_put+0xa0/0x120
put_device+0x1c/0x40
nvme_uninit_ctrl+0x48/0x60
apple_nvme_remove+0x54/0xb0
platform_remove+0x28/0x40
device_remove+0x54/0x98
device_release_driver_internal+
device_release_driver+0x20/0x38
apple_nvme_remove_dead_ctrl_wor
process_one_work+0x1f4/0x770
worker_thread+0x1b8/0x360
kthread+0x140/0x160
ret_from_fork+0x10/0x20
irq event stamp: 448
hardirqs last enabled at (447):in_unlock_irqrestore+0x74/0x80
hardirqs last disabled at (448): [<ffffc000811cf5c0>] el1_brk64+0x20/0x60
softirqs last enabled at (0): [ess+0xb28/0x2698
softirqs last disabled at (0): [<0000000000000000>] 0x0
---[ end trace 0000000000000000
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
Mem abort info:
ESR = 0x0000000096000005
EC = 0x25: DABT (current EL),
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x05: level 1 translation fault
Data abort info:
ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000
CM = 0, WnR = 0, TnD = 0, TagA
GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[0000000000000000] user address
Internal error: Oops: 0000000096000005 [#1] SMP
CPU: 7 UID: 0 PID: 54 Comm: kwor 7.2.0-rc1-dirty #248PREEMPT
Tainted: [W]=WARN
Hardware name: Apple Mac mini (M1, 2020) (DT)
Workqueue: kblockd blk_mq_timeou
pstate: 01400005 (nzcv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
pc : percpu_ref_tryget_many.cons
lr : percpu_ref_tryget_many.constprop.0+0xc0/0x168
sp : ffffc000829cbce0
x29: ffffc000829cbce0 x28: ffff800020be9f48 x27: ffff800013e503c0
x26: 0000000000000108 x25: 000009c05
x23: 0000000000000000 x22: ffffc000819f5000 x21: ffff800020be9f48
x20: ffff8001deda4808 x19: ffff8000a
x17: 00000000580e1fac x16: ffffc00082bbbb7c x15: 0000000000000000
x14: 0000000000000028 x13: 000000001
x11: 0000000000000000 x10: 0000000000000000 x9 : ffffc000829cbc20
x8 : ffffc00081915820 x7 : ffffc0001
x5 : ffff80001ca77d08 x4 : 0000000000000000 x3 : ffff80001ca77cb8
x2 : 0000000000000000 x1 : 000000007
Call trace:
percpu_ref_tryget_many.constpro
blk_mq_timeout_work+0x48/0x298
process_one_work+0x1f4/0x770
worker_thread+0x1b8/0x360
kthread+0x140/0x160
ret_from_fork+0x10/0x20
Code: 91282000 97ed44b2 17ffffd2
---[ end trace 0000000000000000 ]------ drivers/nvme/host/apple.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/nvme/host/apple.c +9 -0
@@ -1652,6 +1652,15 @@ static void apple_nvme_remove(struct platform_device *pdev)nvme_stop_ctrl (&anv->ctrl);nvme_remove_namespaces (&anv->ctrl);apple_nvme_disable (anv, true); +if (anv->ctrl.admin_q && !blk_queue_dying (anv->ctrl.admin_q)) { +/* +* If the controller was reset during removal, it's possible +* user requests may be waiting on a stopped queue. Start the +* queue to flush these to completion. +*/ +nvme_unquiesce_admin_queue (&anv->ctrl); +blk_mq_destroy_queue (anv->ctrl.admin_q); + }nvme_uninit_ctrl (&anv->ctrl);if (apple_rtkit_is_running (anv->rtk)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1343/1815 nvme-apple: Dont set a DMA direction for commands without a data transfer
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Peter <[email protected]>
[ Upstream commit 94dd5804938d6681dbf26f023b1356d511f4fc48 ]
Setting the DMA direction for commands that don't do any transfer likely triggered the PRP NULL check for which we needed a chicken bit. That bit has disappeared starting with macOS 15 so let's just do this correctly instead.
--- drivers/nvme/host/apple.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/host/apple.c +3 -1
@@ -341,7 +341,9 @@ static void apple_nvme_submit_cmd_t8103(struct apple_nvme_queue *q, tcb->length = cmd->rw.length; tcb->command_id = tag; -if (nvme_is_write (cmd)) +if (!cmd->common.dptr.prp1) + tcb->dma_flags =0 ; +else if (nvme_is_write (cmd)) tcb->dma_flags =APPLE_ANS_TCB_DMA_TO_DEVICE ;else tcb->dma_flags =APPLE_ANS_TCB_DMA_FROM_DEVICE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1344/1815 nvme-apple: Never set the opcode in the NVMMU TCB
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Peter <[email protected]>
[ Upstream commit cc0fec9b42cfbc69d70cb4c4b616408a7037b445 ]
macOS always sets this to zero and the firmware starting with macOS 15 has started to complain about what we're doing here.
--- drivers/nvme/host/apple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/apple.c +1 -1
@@ -335,7 +335,7 @@ static void apple_nvme_submit_cmd_t8103(struct apple_nvme_queue *q,u32 tag =nvme_tag_from_cid (cmd->common.command_id);struct apple_nvmmu_tcb *tcb = &q->tcbs[tag]; - tcb->opcode = cmd->common.opcode; + tcb->opcode =0 ; tcb->prp1 = cmd->common.dptr.prp1; tcb->prp2 = cmd->common.dptr.prp2; tcb->length = cmd->rw.length;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1345/1815 nvme: Add a quirk for page aligned admin queue buffers
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Peter <[email protected]>
[ Upstream commit 69d22a6b2f6984200d92dac689f8b00cc3d7d736 ]
Apple controllers seem to require any queue buffers on the admin queue to be aligned to the NVMe controller page size. Weirdly, this constraint does not apply to the i/o queue where any alignment is fine. This has always been required on pre-M1 controllers and is required starting with macOS 15 firmware or post-M4 controllers again. On M1/M2/M3 we only got away with this because there was a chicken bit to disable this requirement. Let's add a quirk that enforces this alignment.
Stable-dep-of: ea2160c7b781 ("nvme-apple: Require page aligned buffers on the admin queue")
--- drivers/nvme/host/core.c | 5 ++++- drivers/nvme/host/nvme.h | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +4 -1
@@ -2071,7 +2071,10 @@ static void nvme_set_ctrl_limits(struct nvme_ctrl *ctrl, lim->max_integrity_segments = ctrl->max_integrity_segments; lim->virt_boundary_mask = ctrl->ops->get_virt_boundary (ctrl, is_admin); lim->max_segment_size =UINT_MAX ; - lim->dma_alignment =3 ; +if (is_admin && (ctrl->quirks &NVME_QUIRK_ADMIN_PAGE_ALIGN )) + lim->dma_alignment =NVME_CTRL_PAGE_SIZE -1 ; +else + lim->dma_alignment =3 ; } static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id,
drivers/nvme/host/nvme.h +7 -0
@@ -178,6 +178,11 @@ enum nvme_quirks {* Align dma pool segment size to 512 bytes */ NVME_QUIRK_DMAPOOL_ALIGN_512 = (1 <<22 ), + +/* +* Admin queue DMA buffers must be page aligned +*/ + NVME_QUIRK_ADMIN_PAGE_ALIGN = (1 << 23), };static inline char *nvme_quirk_name (enum nvme_quirks q)
@@ -229,6 +234,8 @@ static inline char *nvme_quirk_name(enum nvme_quirks q)return "broken_msi" ;case NVME_QUIRK_DMAPOOL_ALIGN_512 :return "dmapool_align_512" ; +case NVME_QUIRK_ADMIN_PAGE_ALIGN : +return "admin_page_align" ; }return "unknown" ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1346/1815 nvme-apple: Require page aligned buffers on the admin queue
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Peter <[email protected]>
[ Upstream commit ea2160c7b78187ea9ab08c3190eef237c4ee99a7 ]
Now that we have a quick to align buffers on the admin queue to the NVMe controller page size use it for Apple controllers. This fixes pre-M1 controllers, which always rejected unaligned requests, and also makes this driver work for M4 SoCs and for M1/M2/M3 SoCs that have been updated to the firmware shipped with macOS 15.
--- drivers/nvme/host/apple.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/apple.c +2 -1
@@ -1599,7 +1599,8 @@ static struct apple_nvme *apple_nvme_alloc(struct platform_device *pdev) } ret =nvme_init_ctrl (&anv->ctrl, anv->dev, &nvme_ctrl_ops, -NVME_QUIRK_SKIP_CID_GEN |NVME_QUIRK_IDENTIFY_CNS ); +NVME_QUIRK_SKIP_CID_GEN |NVME_QUIRK_IDENTIFY_CNS | +NVME_QUIRK_ADMIN_PAGE_ALIGN );if (ret) {dev_err_probe (dev, ret,"Failed to initialize nvme_ctrl" ); goto put_dev;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1347/1815 nvme-apple: Drop the PRP null check chicken bit
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Peter <[email protected]>
[ Upstream commit 8ce883fd068b7ba9ab493cd3ecca3a7ea868c375 ]
Now that we program the DMA direction correctly the NULL check that used to make commands fail passes. Another side effect of this bit was that non-align buffers on the admin queue were silently allowed and that's been fixed now as well and we this don't need this chicken bit anymore. More importantly, starting with the firmware installed with macOS 15, which is required for M4 but can also be installed on the previous SoCs, the controller no longer exposes this control register and any access SErrors instead. Just drop the write entirely.
--- drivers/nvme/host/apple.c | 14 -------------- 1 file changed, 14 deletions(-)
drivers/nvme/host/apple.c +0 -14
@@ -47,9 +47,6 @@#define APPLE_ANS_BOOT_STATUS 0x1300#define APPLE_ANS_BOOT_STATUS_OK 0xde71ce55 -#define APPLE_ANS_UNKNOWN_CTRL 0x24008 -#define APPLE_ANS_PRP_NULL_CHECK BIT(11) -#define APPLE_ANS_LINEAR_SQ_CTRL 0x24908#define APPLE_ANS_LINEAR_SQ_EN BIT(0)
@@ -1143,17 +1140,6 @@ static void apple_nvme_reset_work(struct work_struct *work)/* Setup the NVMMU for the maximum admin and IO queue depth */ writel (anv->hw->max_queue_depth -1 , anv->mmio_nvme +APPLE_NVMMU_NUM_TCBS ); - -/* -* This is probably a chicken bit: without it all commands -* where any PRP is set to zero (including those that don't use -* that field) fail and the co-processor complains about -* "completed with err BAD_CMD-" or a "NULL_PRP_PTR_ERR" in the -* syslog -*/ -writel (readl (anv->mmio_nvme +APPLE_ANS_UNKNOWN_CTRL ) & - ~APPLE_ANS_PRP_NULL_CHECK , - anv->mmio_nvme +APPLE_ANS_UNKNOWN_CTRL ); }/* Setup the admin queue */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1348/1815 nvmet: fix NULL pointer dereference in nvmet_execute_identify_ns_zns()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit f594863967d87b7fcbff6e724d51135fd701a13d ]
When a host issues an Identify command with CNS 05h (I/O Command Set specific Identify Namespace) and CSI 02h (ZNS) targeting a file-backed namespace, nvmet_execute_identify_ns_zns() calls bdev_is_zoned() on req->ns->bdev. A file-backed namespace has no block device, so req->ns->bdev is NULL and bdev_is_zoned() dereferences it, oopsing.
The I/O command set is selected by the host-supplied CSI field and the command is routed here whenever CONFIG_BLK_DEV_ZONED is enabled, independent of the namespace backing type, so any file-backed namespace is exposed.
Reject the command with Invalid Field when the namespace is not backed by a block device.
--- drivers/nvme/target/zns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/zns.c +1 -1
@@ -116,7 +116,7 @@ void nvmet_execute_identify_ns_zns(struct nvmet_req *req)mutex_unlock (&req->ns->subsys->lock); } -if (!bdev_is_zoned (req->ns->bdev)) { +if (!req->ns->bdev || !bdev_is_zoned (req->ns->bdev)) { status =NVME_SC_INVALID_FIELD |NVME_STATUS_DNR ; req->error_loc = offsetof(struct nvme_identify , nsid); goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1349/1815 nvme/ioctl: check SUBMIT_IO with nvme_cmd_allowed()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Xiuwei <[email protected]>
[ Upstream commit b53d495c7f0db46b6748b5ade48371a10dd5d3bc ]
Unlike IO_CMD / IO64_CMD, NVME_IOCTL_SUBMIT_IO never calls nvme_cmd_allowed(). Unprivileged callers can thus issue I/O on a partition device or write through a read-only file descriptor.
Pass flags and open_for_write through and reject disallowed commands with -EACCES.
Stable-dep-of: 1161be71d1ec ("nvme: reject passthrough of driver-managed Set Features")
--- drivers/nvme/host/ioctl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/nvme/host/ioctl.c +6 -2
@@ -202,7 +202,8 @@ static int nvme_submit_user_cmd(struct request_queue *q,return ret; } -static int nvme_submit_io (struct nvme_ns *ns,struct nvme_user_io __user *uio) +static int nvme_submit_io (struct nvme_ns *ns,struct nvme_user_io __user *uio, +unsigned int flags,bool open_for_write) {struct nvme_user_io io;struct nvme_command c;
@@ -260,6 +261,9 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) c.rw.lbat =cpu_to_le16 (io.apptag); c.rw.lbatm =cpu_to_le16 (io.appmask); +if (!nvme_cmd_allowed (ns, &c, flags, open_for_write)) +return -EACCES ; +return nvme_submit_user_cmd (ns->queue, &c, io.addr, length, metadata, meta_len,NULL ,0 ,0 ); }
@@ -595,7 +599,7 @@ static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd,case NVME_IOCTL_SUBMIT_IO32 :#endif case NVME_IOCTL_SUBMIT_IO : -return nvme_submit_io (ns, argp); +return nvme_submit_io (ns, argp, flags, open_for_write);case NVME_IOCTL_IO64_CMD_VEC : flags |=NVME_IOCTL_VEC ; fallthrough;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1350/1815 nvme: reject passthrough of driver-managed Set Features
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Shi <[email protected]>
[ Upstream commit 1161be71d1ecf7dc785382114c71afed0349531e ]
Since commit b58da2d270db ("nvme: update keep alive interval when kato is modified"), a Set Features (KATO) passthrough command lets userspace start keep-alive on any transport. nvme_keep_alive_work() allocates with BLK_MQ_REQ_RESERVED, but nvme_alloc_admin_tag_set() reserves admin tags only for fabrics, so on other transports the allocation trips WARN_ON_ONCE() in blk_mq_get_tag() and fails:
nvme nvme0: keep-alive failed: -11
Several Set Features change controller state the driver manages itself and cannot react to when set behind its back. Reject these in nvme_admin_cmd_allowed():
- KATO on non-fabrics (keep-alive is only armed for fabrics; on PCIe it has no reserved tag and harms idle power states)
- Host Behavior Support, Host Memory Buffer, Number of Queues, and Autonomous Power State Transition (all driver-managed)
Keep Alive on fabrics is unchanged; I/O commands are unaffected as the check is confined to the admin path (ns == NULL).
Found by FuzzNvme.
--- drivers/nvme/host/ioctl.c | 111 ++++++++++++++++++++++++-------------- 1 file changed, 72 insertions(+), 39 deletions(-)
drivers/nvme/host/ioctl.c +72 -39
@@ -14,45 +14,54 @@ enum { NVME_IOCTL_PARTITION = (1 << 1), }; -static bool nvme_cmd_allowed (struct nvme_ns *ns,struct nvme_command *c, -unsigned int flags,bool open_for_write) +static bool nvme_admin_cmd_allowed (struct nvme_ctrl *ctrl, +struct nvme_command *c) { -u32 effects; - -/* -* Do not allow unprivileged passthrough on partitions, as that allows an -* escape from the containment of the partition. -*/ -if (flags &NVME_IOCTL_PARTITION ) - goto admin; - -/* -* Do not allow unprivileged processes to send vendor specific or fabrics -* commands as we can't be sure about their effects. -*/ -if (c->common.opcode >= nvme_cmd_vendor_start || - c->common.opcode == nvme_fabrics_command) - goto admin; -/* * Do not allow unprivileged passthrough of admin commands except * for a subset of identify commands that contain information required * to form proper I/O commands in userspace and do not expose any * potentially sensitive information. */ -if (!ns) { -if (c->common.opcode == nvme_admin_identify) { -switch (c->identify.cns) { -case NVME_ID_CNS_NS : -case NVME_ID_CNS_CS_NS : -case NVME_ID_CNS_NS_CS_INDEP : -case NVME_ID_CNS_CS_CTRL : -case NVME_ID_CNS_CTRL : -return true; - } +switch (c->common.opcode) { +case nvme_admin_identify: +switch (c->identify.cns) { +case NVME_ID_CNS_NS : +case NVME_ID_CNS_CS_NS : +case NVME_ID_CNS_NS_CS_INDEP : +case NVME_ID_CNS_CS_CTRL : +case NVME_ID_CNS_CTRL : +return true; } - goto admin; +break ; +case nvme_admin_set_features: +/* +* Reject Set Features that change controller state the driver +* manages itself; setting them behind the driver's back from +* userspace leaves it unable to react correctly. Keep Alive is +* only armed for fabrics - on other transports it has no +* reserved tag and harms idle power states. +*/ +switch (le32_to_cpu (c->features.fid) &0xff ) { +case NVME_FEAT_KATO : +if (ctrl->ops->flags &NVME_F_FABRICS ) +break ; + fallthrough; +case NVME_FEAT_HOST_BEHAVIOR : +case NVME_FEAT_HOST_MEM_BUF : +case NVME_FEAT_NUM_QUEUES : +case NVME_FEAT_AUTO_PST : +return false; + } +break ; } +return capable (CAP_SYS_ADMIN ); +} + +static bool nvme_ns_cmd_allowed (struct nvme_ns *ns,struct nvme_command *c, +bool open_for_write) +{ +u32 effects;/* * Check if the controller provides a Commands Supported and Effects log
@@ -61,7 +70,7 @@ static bool nvme_cmd_allowed(struct nvme_ns *ns, struct nvme_command *c,*/ effects =nvme_command_effects (ns->ctrl, ns, c->common.opcode);if (!(effects &NVME_CMD_EFFECTS_CSUPP )) - goto admin; +return capable (CAP_SYS_ADMIN );/* * Don't allow passthrough for command that have intrusive (or unknown)
@@ -70,7 +79,7 @@ static bool nvme_cmd_allowed(struct nvme_ns *ns, struct nvme_command *c,if (effects & ~(NVME_CMD_EFFECTS_CSUPP |NVME_CMD_EFFECTS_LBCC |NVME_CMD_EFFECTS_UUID_SEL |NVME_CMD_EFFECTS_SCOPE_MASK )) - goto admin; +return capable (CAP_SYS_ADMIN );/* * Only allow I/O commands that transfer data to the controller or that
@@ -79,11 +88,34 @@ static bool nvme_cmd_allowed(struct nvme_ns *ns, struct nvme_command *c,*/ if ((nvme_is_write (c) || (effects &NVME_CMD_EFFECTS_LBCC )) && !open_for_write) - goto admin; +return capable (CAP_SYS_ADMIN );return true; -admin: -return capable (CAP_SYS_ADMIN ); +} + +static bool nvme_cmd_allowed (struct nvme_ctrl *ctrl,struct nvme_ns *ns, +struct nvme_command *c,unsigned int flags, +bool open_for_write) +{ +/* +* Do not allow unprivileged passthrough on partitions, as that +* allows an escape from the containment of the partition. +*/ +if (flags &NVME_IOCTL_PARTITION ) +return capable (CAP_SYS_ADMIN ); + +/* +* Do not allow unprivileged processes to send vendor specific or +* fabrics commands as we can't be sure about their effects. +*/ +if (c->common.opcode >= nvme_cmd_vendor_start || + c->common.opcode == nvme_fabrics_command) +return capable (CAP_SYS_ADMIN ); + +if (!ns) +return nvme_admin_cmd_allowed (ctrl, c); + +return nvme_ns_cmd_allowed (ns, c, open_for_write); }/*
@@ -261,7 +293,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio, c.rw.lbat =cpu_to_le16 (io.apptag); c.rw.lbatm =cpu_to_le16 (io.appmask); -if (!nvme_cmd_allowed (ns, &c, flags, open_for_write)) +if (!nvme_cmd_allowed (ns->ctrl, ns, &c, flags, open_for_write))return -EACCES ; return nvme_submit_user_cmd(ns->queue, &c, io.addr, length, metadata,
@@ -311,7 +343,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns, c.common.cdw14 =cpu_to_le32 (cmd.cdw14); c.common.cdw15 =cpu_to_le32 (cmd.cdw15); -if (!nvme_cmd_allowed (ns, &c,0 , open_for_write)) +if (!nvme_cmd_allowed (ctrl, ns, &c,0 , open_for_write))return -EACCES ;if (cmd.timeout_ms)
@@ -358,7 +390,7 @@ static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct nvme_ns *ns, c.common.cdw14 =cpu_to_le32 (cmd.cdw14); c.common.cdw15 =cpu_to_le32 (cmd.cdw15); -if (!nvme_cmd_allowed (ns, &c, flags, open_for_write)) +if (!nvme_cmd_allowed (ctrl, ns, &c, flags, open_for_write))return -EACCES ;if (cmd.timeout_ms)
@@ -453,6 +485,7 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,const struct nvme_uring_cmd *cmd =io_uring_sqe128_cmd (ioucmd->sqe, struct nvme_uring_cmd);struct request_queue *q = ns ? ns->queue : ctrl->admin_q; +bool open_for_write = ioucmd->file->f_mode &FMODE_WRITE ;struct nvme_uring_data d;struct nvme_command c;struct iov_iter iter;
@@ -483,7 +516,7 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns, c.common.cdw14 =cpu_to_le32 (READ_ONCE (cmd->cdw14)); c.common.cdw15 =cpu_to_le32 (READ_ONCE (cmd->cdw15)); -if (!nvme_cmd_allowed (ns, &c,0 , ioucmd->file->f_mode &FMODE_WRITE )) +if (!nvme_cmd_allowed (ctrl, ns, &c,0 , open_for_write))return -EACCES ; d.metadata =READ_ONCE (cmd->metadata);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1351/1815 hrtimer: Account nr_retries on recovered interrupt retries
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liang Hao <[email protected]>
[ Upstream commit 32a05ba399fc52661f59f38efd2e606f45eb2c8f ]
Re-arranging hrtimer_interrupt() switched the retry path to a local counter and dropped the update of cpu_base->nr_retries, leaving the field exported via /proc/timer_list stuck at zero.
Increment nr_retries only when another pass through the expiry loop is started; the third attempt that falls through to hang handling is still accounted by nr_hangs alone.
--- kernel/time/hrtimer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/time/hrtimer.c +3 -1
@@ -2228,8 +2228,10 @@ void hrtimer_interrupt(struct clock_event_device *dev) expires_next =hrtimer_update_next_event (cpu_base); cpu_base->hang_detected = false;if (expires_next < now) { -if (++retries <3 ) +if (++retries <3 ) { + cpu_base->nr_retries++; goto retry; + } delta =ktime_sub (now, entry_time); cpu_base->max_hang_time = max_t(unsigned int, cpu_base->max_hang_time, delta);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1352/1815 nfc: llcp: avoid userspace overflow on invalid optlen
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 99985bfa8336fadcc69190ba2dcbd5386af3d661 ]
nfc_llcp_getsockopt() casts optval to (u32 __user *) for put_user(), so the kernel always stores 4 bytes regardless of the caller-supplied optlen. The existing min_t(u32, len, sizeof(u32)) only clamps the length reported back to userspace; it does not constrain the store. A call with optlen < 4 therefore writes past the user buffer, violating the getsockopt(2) contract for all five supported optnames.
Reject any call with optlen < sizeof(u32) up front. 'len' is int, so a plain size comparison would promote a negative optlen to size_t and slip past the check; an explicit 'len < 0' test is added first to catch negative values before the size compare.
--- net/nfc/llcp_sock.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/nfc/llcp_sock.c +6 -0
@@ -319,6 +319,12 @@ static int nfc_llcp_getsockopt(struct socket *sock, int level, int optname,if (get_user (len, optlen))return -EFAULT ; +if (len <0 ) +return -EINVAL ; + +if (len <sizeof (u32)) +return -EINVAL ; + local = llcp_sock->local;if (!local)return -ENODEV ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1353/1815 nfc: llcp: read llcp_sock->local under the socket lock in getsockopt
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 36812527052c5bfb1ec6c1e292d67a5bf76b750f ]
nfc_llcp_getsockopt() read llcp_sock->local before lock_sock(sk) and then dereferenced the cached pointer inside the locked region. llcp_sock_bind() assigns and clears llcp_sock->local under the same socket lock, dropping the last reference on its error path. A getsockopt() racing an in-flight bind() can observe the pointer, block on lock_sock(), and then dereference a freed nfc_llcp_local once bind() has unwound.
Move the llcp_sock->local read and the NULL check inside the lock_sock(sk) region so bind() cannot mutate or free the pointer between the load and the use.
--- net/nfc/llcp_sock.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/nfc/llcp_sock.c +6 -4
@@ -325,14 +325,16 @@ static int nfc_llcp_getsockopt(struct socket *sock, int level, int optname,if (len <sizeof (u32))return -EINVAL ; - local = llcp_sock->local; -if (!local) -return -ENODEV ; - len =min_t (u32, len,sizeof (u32));lock_sock (sk); + local = llcp_sock->local; +if (!local) { +release_sock (sk); +return -ENODEV ; + } +switch (optname) {case NFC_LLCP_RW : rw = llcp_sock->rw >LLCP_MAX_RW ? local->rw : llcp_sock->rw;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1354/1815 nfc: nci: fix double completion race in nci_data_exchange_complete
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhenghang Xiao <[email protected]>
[ Upstream commit 8265a626cc14a48e46e6dc8c47667e72b4232ac2 ]
nci_close_device() and nci_rx_work can both call nci_data_exchange_complete() concurrently. After commit 4527025d440ce8 ("nfc: nci: fix circular locking dependency in nci_close_device") moved flush_workqueue(ndev->rx_wq) after mutex_unlock(&ndev->req_lock), rx_work is no longer serialized with the explicit completion call in the close path. Both callers read the non-NULL callback pointer and invoke rawsock_data_exchange_complete(), which calls sock_put() -- but only one sock_hold() was taken, so the second sock_put() underflows the refcount and frees the socket while it is still in use.
Replace the bare clear_bit(NCI_DATA_EXCHANGE) with test_and_clear_bit() so that only the first caller proceeds to invoke the callback.
--- net/nfc/nci/data.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/nfc/nci/data.c +5 -5
@@ -46,11 +46,11 @@ void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb,timer_delete_sync (&ndev->data_timer);clear_bit (NCI_DATA_EXCHANGE_TO , &ndev->flags); -/* Mark the exchange as done before calling the callback. -* The callback (e.g. rawsock_data_exchange_complete) may -* want to immediately queue another data exchange. -*/ -clear_bit (NCI_DATA_EXCHANGE , &ndev->flags); +/* Claim completion atomically -- both close and rx_work may race here */ +if (!test_and_clear_bit (NCI_DATA_EXCHANGE , &ndev->flags)) { +kfree_skb (skb); +return ; + }if (cb) {/* forward skb to nfc core */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1355/1815 nfc: llcp: bound SNL TLV parsing to the skb and add length checks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Doruk Tan Ozturk <[email protected]>
[ Upstream commit f4c7f37f0ab990952539dc68d931d65c3657600a ]
nfc_llcp_recv_snl() walked the SNL TLV list using a u16 offset/length pair derived from skb->len, without bounding reads to the actual skb data. Three problems followed:
- For a short frame (skb->len < LLCP_HEADER_SIZE), tlv_len underflowed.
- The per-TLV header (type, length) was read without checking that two bytes remained.
- A declared TLV length could run past the end of the buffer, and an SDREQ with length == 0 made "service_name_len = length - 1" underflow (size_t), driving an out-of-bounds read in the following strncmp() / nfc_llcp_sock_from_sn(). The SDRES case likewise read tlv[2]/tlv[3] without a length check.
A nearby NFC device can reach this without authentication; LLCP link activation happens automatically after NFC-DEP.
Walk the TLV list by pointer, bounded by skb_tail_pointer() over the linear skb data, and validate each TLV declared length before use. Add explicit length checks for SDREQ (>= 1) and SDRES (exactly 2).
Found by 0sec automated security-research tooling (https://0sec.ai).
--- net/nfc/llcp_core.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-)
net/nfc/llcp_core.c +21 -8
@@ -1288,10 +1288,9 @@ static void nfc_llcp_recv_snl(struct nfc_llcp_local *local, {struct nfc_llcp_sock *llcp_sock;u8 dsap, ssap, type, length, tid, sap; -const u8 *tlv; -u16 tlv_len, offset; +const u8 *tlv, *tlv_end;const char *service_name; -size_t service_name_len; +int service_name_len;struct nfc_llcp_sdp_tlv *sdp;HLIST_HEAD (llc_sdres_list);size_t sdres_tlvs_len;
@@ -1307,22 +1306,34 @@ static void nfc_llcp_recv_snl(struct nfc_llcp_local *local, return; } + /* + * Walk the SNL TLV list in the linear part of the skb only, + * bounded by skb_tail_pointer(). Each TLV needs a two-byte + * header (type, length) and its declared length must fit before + * the end; this also keeps the walk safe for very short frames. + */ tlv = &skb->data[LLCP_HEADER_SIZE]; - tlv_len = skb->len - LLCP_HEADER_SIZE; - offset = 0; + tlv_end = skb_tail_pointer(skb); sdres_tlvs_len = 0; - while (offset < tlv_len) { + while (tlv + 2 < tlv_end) { type = tlv[0]; length = tlv[1]; + if (tlv + 2 + length > tlv_end) + break; + switch (type) { case LLCP_TLV_SDREQ: + if (length < 1) + break; + tid = tlv[2]; service_name = (char *) &tlv[3]; service_name_len = length - 1; - pr_debug("Looking for %.16s\n", service_name); + pr_debug("Looking for %.*s\n", service_name_len, + service_name); if (service_name_len == strlen("urn:nfc:sn:sdp") && !strncmp(service_name, "urn:nfc:sn:sdp",
@@ -1382,6 +1393,9 @@ static void nfc_llcp_recv_snl(struct nfc_llcp_local *local,break ;case LLCP_TLV_SDRES : +if (length !=2 ) +break ; +mutex_lock (&local->sdreq_lock);pr_debug ("LLCP_TLV_SDRES: searching tid %d\n" , tlv[2 ]);
@@ -1410,7 +1424,6 @@ static void nfc_llcp_recv_snl(struct nfc_llcp_local *local,break ; } - offset += length +2 ; tlv += length +2 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1356/1815 nfc: pn533: hold a reference to the request skb during send_frame
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yinhao Hu <[email protected]>
[ Upstream commit 47792358a624ea066455ef86b744159928cd7716 ]
__pn533_send_async() publishes the command and then calls dev->phy_ops->send_frame(). Once dev->cmd is set, an incoming frame can be matched to this command: the I2C threaded IRQ runs pn533_recv_frame(), which queues cmd_complete_work, and pn533_send_async_complete() frees cmd->req with consume_skb().
On the I2C transport, pn533_i2c_send_frame() still dereferences the same skb after i2c_master_send() returns, so a completion that races the send can free the skb while the transport is still using it.
The request skb is owned by the command object and may be freed by command completion at any time after dev->cmd is published, so the transport send path must not assume it stays alive. Hold a temporary reference to the request skb across the send_frame() call so the transport always sees a live skb even if completion races the send. Add a pn533_send_cmd_frame() helper and use it from all three send paths.
--- drivers/nfc/pn533/pn533.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/nfc/pn533/pn533.c +15 -6
@@ -434,6 +434,18 @@ static int pn533_send_async_complete(struct pn533 *dev)return rc; } +static int pn533_send_cmd_frame (struct pn533 *dev,struct pn533_cmd *cmd) +{ +struct sk_buff *req = cmd->req; +int rc; + +skb_get (req); + dev->cmd = cmd; + rc = dev->phy_ops->send_frame (dev, req); +dev_kfree_skb (req); +return rc; +} + static int __pn533_send_async(struct pn533 *dev, u8 cmd_code, struct sk_buff *req, pn533_send_async_complete_t complete_cb,
@@ -458,8 +470,7 @@ static int __pn533_send_async(struct pn533 *dev, u8 cmd_code,mutex_lock (&dev->cmd_lock);if (!dev->cmd_pending) { - dev->cmd = cmd; - rc = dev->phy_ops->send_frame (dev, req); + rc =pn533_send_cmd_frame (dev, cmd);if (rc) { dev->cmd =NULL ; goto error;
@@ -529,8 +540,7 @@ static int pn533_send_cmd_direct_async(struct pn533 *dev, u8 cmd_code,pn533_build_cmd_frame (dev, cmd_code, req); - dev->cmd = cmd; - rc = dev->phy_ops->send_frame (dev, req); + rc =pn533_send_cmd_frame (dev, cmd);if (rc <0 ) { dev->cmd =NULL ;kfree (cmd);
@@ -569,8 +579,7 @@ static void pn533_wq_cmd(struct work_struct *work)mutex_unlock (&dev->cmd_lock); - dev->cmd = cmd; - rc = dev->phy_ops->send_frame (dev, cmd->req); + rc =pn533_send_cmd_frame (dev, cmd);if (rc <0 ) { dev->cmd =NULL ;dev_kfree_skb (cmd->req);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1357/1815 nfc: digital: Do not dump a NULL response in command completion
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 1c7dd70c0adfa58fd66b5cbd03efb747ad6d8d8d ]
digital_wq_cmd_complete() dumps the response data whenever cmd->resp is not an error pointer. However, a driver can legitimately complete a command with no response skb at all.
digital_tg_send_psl_res() is the only caller that passes timeout=0, meaning no response is expected once the command has been transmitted. On that path trf7970a completes the command with
trf->rx_skb = ERR_PTR(0);
which evaluates to NULL. IS_ERR(NULL) is false, so the NULL response passes the !IS_ERR() check and cmd->resp->data and cmd->resp->len are dereferenced whenever the debug print site is enabled. The driver guards its own dump with "trf->rx_skb && !IS_ERR(trf->rx_skb)"; the digital layer is missing the NULL half of that test.
Use IS_ERR_OR_NULL() so that NULL responses are skipped as well. The callback on that path, digital_tg_send_psl_res_complete(), never dereferences resp and dev_kfree_skb() accepts NULL, so only the debug dump needs fixing.
--- net/nfc/digital_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/nfc/digital_core.c +1 -1
@@ -127,7 +127,7 @@ static void digital_wq_cmd_complete(struct work_struct *work)mutex_unlock (&ddev->cmd_lock); -if (!IS_ERR (cmd->resp)) +if (!IS_ERR_OR_NULL (cmd->resp))print_hex_dump_debug ("DIGITAL RX: " ,DUMP_PREFIX_NONE ,16 ,1 , cmd->resp->data, cmd->resp->len, false);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1358/1815 nfc: nci: fix use of uninitialized memory in CORE_INIT_RSP parsing
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yun Zhou <[email protected]>
[ Upstream commit d56575a2595ee1f597f39e8a1cfb67ed3501678d ]
nci_core_init_rsp_packet_v1() and nci_core_init_rsp_packet_v2() parse the CORE_INIT_RSP packet without validating that the skb contains enough data. A malformed response (e.g. injected via virtual_ncidev) can declare a large num_supported_rf_interfaces while providing insufficient data, causing reads of uninitialized slab memory. This is later used in nci_init_complete_req(), triggering a KMSAN uninit-value warning.
Add skb length checks before accessing packet fields:
- Validate the skb has at least 1 byte for the status field.
- Validate the skb can hold the fixed-size header before parsing.
- In v2, bounds-check each variable-length rf_interface entry and its extension parameters within the parsing loop.
- In v1, verify the skb is large enough for both the variable-length rf_interfaces array and the trailing rsp_2 structure.
--- net/nfc/nci/rsp.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-)
net/nfc/nci/rsp.c +38 -3
@@ -50,11 +50,27 @@ static u8 nci_core_init_rsp_packet_v1(struct nci_dev *ndev,const struct nci_core_init_rsp_1 *rsp_1 = (void *)skb->data;const struct nci_core_init_rsp_2 *rsp_2; +/* Ensure that the status field can be accessed. */ +if (skb_headlen (skb) <1 ) +return NCI_STATUS_SYNTAX_ERROR ; +pr_debug ("status 0x%x\n" , rsp_1->status);if (rsp_1->status !=NCI_STATUS_OK )return rsp_1->status; +/* Success response must contain the full fixed-size header */ +if (skb_headlen (skb) <sizeof (*rsp_1)) +return NCI_STATUS_SYNTAX_ERROR ; + +/* Ensure the variable-length rf_interfaces array and trailing +* rsp_2 structure are fully contained within the skb. +*/ +if (skb_headlen (skb) <sizeof (*rsp_1) + + rsp_1->num_supported_rf_interfaces + +sizeof (*rsp_2)) +return NCI_STATUS_SYNTAX_ERROR ; + ndev->nfcc_features =__le32_to_cpu (rsp_1->nfcc_features); ndev->num_supported_rf_interfaces = rsp_1->num_supported_rf_interfaces;
@@ -87,15 +103,25 @@ static u8 nci_core_init_rsp_packet_v2(struct nci_dev *ndev, const struct sk_buff *skb) {const struct nci_core_init_rsp_nci_ver2 *rsp = (void *)skb->data; -const u8 *supported_rf_interface = rsp->supported_rf_interfaces; +const u8 *supported_rf_interface;u8 rf_interface_idx =0 ;u8 rf_extension_cnt =0 ; +/* Ensure that the status field can be accessed. */ +if (skb_headlen (skb) <1 ) +return NCI_STATUS_SYNTAX_ERROR ; +pr_debug ("status %x\n" , rsp->status);if (rsp->status !=NCI_STATUS_OK )return rsp->status; +/* Success response must contain the full fixed-size header */ +if (skb_headlen (skb) <sizeof (*rsp)) +return NCI_STATUS_SYNTAX_ERROR ; + + supported_rf_interface = rsp->supported_rf_interfaces; + ndev->nfcc_features =__le32_to_cpu (rsp->nfcc_features); ndev->num_supported_rf_interfaces = rsp->num_supported_rf_interfaces;
@@ -104,13 +130,22 @@ static u8 nci_core_init_rsp_packet_v2(struct nci_dev *ndev, NCI_MAX_SUPPORTED_RF_INTERFACES);while (rf_interface_idx < ndev->num_supported_rf_interfaces) { - ndev->supported_rf_interfaces[rf_interface_idx++] = *supported_rf_interface++; +/* Each entry: [rf_interface_type (1B)] [ext_count (1B)] [ext...] */ +if (supported_rf_interface +2 >skb_tail_pointer (skb)) +break ; + ndev->supported_rf_interfaces[rf_interface_idx] = *supported_rf_interface++; -/* skip rf extension parameters */ rf_extension_cnt = *supported_rf_interface++; +if (supported_rf_interface + rf_extension_cnt >skb_tail_pointer (skb)) +break ; + +/* Only count the entry after full validation */ + rf_interface_idx++; supported_rf_interface += rf_extension_cnt; } + ndev->num_supported_rf_interfaces = rf_interface_idx; + ndev->max_logical_connections = rsp->max_logical_connections; ndev->max_routing_table_size =__le16_to_cpu (rsp->max_routing_table_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1359/1815 ALSA: seq: Dont leak the extension cell pointer in the bounce payload
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 59e1592d3c270ff4642d5d6dc55c545306eb0693 ]
The bounce_error_event() embeds the failed event in the bounce payload by pointing data.ext.ptr at it. When that event is a queued variable-length event, its own data.ext.ptr holds the address of its first extension cell, put there by snd_seq_event_dup(). The payload goes out verbatim through snd_seq_expand_var_event(), so the address reaches userspace.
That is the same address commit 705dd6dcbc0e ("ALSA: seq: Clear variable event pointer on read") removed from the event header. The read path still clears it there, just above the call that expands the payload.
Embed a sanitised copy instead, treated exactly as snd_seq_read() treats the header. A stack copy is enough because delivery is synchronous and snd_seq_event_dup() copies before returning.
An unprivileged client reaches this by setting SNDRV_SEQ_FILTER_BOUNCE, queueing a variable-length event to a port that does not exist and reading the bounce back. Eight bytes on 64-bit, from its own pool.
--- sound/core/seq/seq_clientmgr.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
sound/core/seq/seq_clientmgr.c +10 -6
@@ -528,7 +528,7 @@ static int bounce_error_event(struct snd_seq_client *client,struct snd_seq_event *event, int err, int atomic, int hop) { - struct snd_seq_event bounce_ev; + struct snd_seq_event bounce_ev, quoted;int result; if (client == NULL ||
@@ -548,15 +548,19 @@ static int bounce_error_event(struct snd_seq_client *client,* For user clients, send SNDRV_SEQ_EVENT_BOUNCE with the * original event embedded as variable-length data. This * avoids exposing data.quote.event (a kernel pointer) to -* userspace. The variable-length path in snd_seq_event_dup() -* copies the event data from data.ext.ptr into chained cells, -* and snd_seq_expand_var_event() copies only the data content -* -- never the pointer -- to userspace. +* userspace. Sanitise the embedded copy too - a queued +* variable-length event carries the address of its own +* extension cell, and the payload goes out verbatim. */ + quoted = *event; +if (snd_seq_ev_is_variable ("ed)) { + quoted.data.ext.len &= ~SNDRV_SEQ_EXT_MASK ; + quoted.data.ext.ptr =NULL ; + } bounce_ev.type =SNDRV_SEQ_EVENT_BOUNCE ; bounce_ev.flags =SNDRV_SEQ_EVENT_LENGTH_VARIABLE ; bounce_ev.data.ext.len =sizeof (struct snd_seq_event ); - bounce_ev.data.ext.ptr = (char *)event; + bounce_ev.data.ext.ptr = (char *)"ed; }else {/* * For kernel clients, quote the event pointer directly.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1360/1815 phy: rockchip: samsung-hdptx: Fix rate recalculation for high bpc
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cristian Ciocaltea <[email protected]>
[ Upstream commit f0c2c9c58a48b621b1cb90f0821da422b31af814 ]
The PHY PLL can be programmed by an external component, e.g. the bootloader, just before the recalc_rate() callback is invoked during devm_clk_hw_register() in the probe path.
Therefore rk_hdptx_phy_clk_recalc_rate() finds the PLL enabled and attempts to compute the clock rate, while making use of the bpc value from the HDMI PHY configuration, which always defaults to 8 because phy_configure() was not run at that point. As a consequence, the (re)calculated rate is incorrect when the actual bpc was higher than 8.
Do not rely on any of the hdmi_cfg members when computing the clock rate and, instead, read the required input data (i.e. bpc), directly from the hardware registers.
--- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +4 -9
@@ -2168,7 +2168,7 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(struct rk_hdptx_phy *hdptx)struct lcpll_config lcpll_hw;struct ropll_config ropll_hw;u64 fout, sdm; -u32 mode, val; +u32 mode, bpc, val;int ret, i; ret =regmap_read (hdptx->regmap,CMN_REG (0008 ), &mode);
@@ -2266,6 +2266,7 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(struct rk_hdptx_phy *hdptx)if (ret)return 0 ; ropll_hw.pms_sdiv = ((val &PLL_PCG_POSTDIV_SEL_MASK ) >>4 ) +1 ; + bpc = (FIELD_GET (PLL_PCG_CLK_SEL_MASK , val) <<1 ) +8 ; fout =PLL_REF_CLK * ropll_hw.pms_mdiv;if (ropll_hw.sdm_en) {
@@ -2280,7 +2281,7 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(struct rk_hdptx_phy *hdptx) fout = fout + sdm; } -return div_u64 (fout *2 , ropll_hw.pms_sdiv *10 ); +return DIV_ROUND_CLOSEST_ULL (fout *2 *8 , ropll_hw.pms_sdiv *10 * bpc); } static unsigned long rk_hdptx_phy_clk_recalc_rate(struct clk_hw *hw,
@@ -2288,19 +2289,13 @@ static unsigned long rk_hdptx_phy_clk_recalc_rate(struct clk_hw *hw, {struct rk_hdptx_phy *hdptx =to_rk_hdptx_phy (hw);u32 status; -u64 rate;int ret; ret =regmap_read (hdptx->grf,GRF_HDPTX_CON0 , &status);if (ret || !(status &HDPTX_I_PLL_EN ))return 0 ; - rate =rk_hdptx_phy_clk_calc_rate_from_pll_cfg (hdptx); - -if (hdptx->hdmi_cfg.mode ==PHY_HDMI_MODE_FRL ) -return rate; - -return DIV_ROUND_CLOSEST_ULL (rate *8 , hdptx->hdmi_cfg.bpc); +return rk_hdptx_phy_clk_calc_rate_from_pll_cfg (hdptx); } static int rk_hdptx_phy_clk_determine_rate(struct clk_hw *hw,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1361/1815 phy: rockchip: samsung-hdptx: Prevent divide-by-zero when computing clk rate
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cristian Ciocaltea <[email protected]>
[ Upstream commit c4fe5a9f379055ce0ec930f6495ae62aad237b89 ]
Calculating 'sdm' fraction in rk_hdptx_phy_clk_calc_rate_from_pll_cfg() could trigger a divide-by-zero, as it uses div_u64() with a denominator read directly from hardware: the values ropll_hw.sdm_deno, ropll_hw.sdc_deno, ropll_hw.sdc_n, and ropll_hw.sdc_num are populated from PLL registers which, in theory, could be left by the bootloader uninitialized/misconfigured.
Provide the necessary sanitization to avoid trusting the hardware state.
--- .../phy/rockchip/phy-rockchip-samsung-hdptx.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +13 -3
@@ -2270,10 +2270,20 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(struct rk_hdptx_phy *hdptx) fout =PLL_REF_CLK * ropll_hw.pms_mdiv;if (ropll_hw.sdm_en) { + val =16U * ropll_hw.sdm_deno * + (ropll_hw.sdc_deno * ropll_hw.sdc_n - ropll_hw.sdc_num); +if (!val) { +/* +* The PLL config currently stored in hardware can't be +* translated into a rate. The next .set_rate() should +* program a valid configuration and help with recovery. +*/ +dev_dbg (hdptx->dev,"Invalid ROPLL hw state: deno == 0\n" ); +return 0 ; + } + sdm =div_u64 (PLL_REF_CLK * ropll_hw.sdc_deno * - ropll_hw.pms_mdiv * ropll_hw.sdm_num, -16 * ropll_hw.sdm_deno * - (ropll_hw.sdc_deno * ropll_hw.sdc_n - ropll_hw.sdc_num)); + ropll_hw.pms_mdiv * ropll_hw.sdm_num, val);if (ropll_hw.sdm_num_sign) fout = fout - sdm;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1362/1815 phy: rockchip: samsung-hdptx: Guard against clk rate integer underflow
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cristian Ciocaltea <[email protected]>
[ Upstream commit 229788526ff24e0607726e93b74dd2ef157a99cd ]
The 'fout' subtraction in rk_hdptx_phy_clk_calc_rate_from_pll_cfg() could result in an integer underflow, if the hardware registers are misconfigured or contain uninitialized values, such that the computed sigma-delta modulator offset sdm exceeds the base frequency fout.
This might lead to an absurdly high clock rate being returned to the Common Clock Framework, with unpredictable effects on downstream clk consumers.
Provide the necessary sanitization to avoid trusting the hardware state.
--- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +12 -2
@@ -2285,10 +2285,20 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(struct rk_hdptx_phy *hdptx) sdm =div_u64 (PLL_REF_CLK * ropll_hw.sdc_deno * ropll_hw.pms_mdiv * ropll_hw.sdm_num, val); -if (ropll_hw.sdm_num_sign) +if (ropll_hw.sdm_num_sign) { +if (sdm > fout) { +/* +* Similarly to the case above, it is expected +* the next .set_rate() will help with recovery. +*/ +dev_dbg (hdptx->dev,"Invalid ROPLL hw state: sdm > fout\n" ); +return 0 ; + } + fout = fout - sdm; -else + }else { fout = fout + sdm; + } }return DIV_ROUND_CLOSEST_ULL (fout *2 *8 , ropll_hw.pms_sdiv *10 * bpc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1363/1815 phy: rockchip: samsung-hdptx: Fix rate recalculation for 3.2GHz FRL
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cristian Ciocaltea <[email protected]>
[ Upstream commit 9ac3daadb9060360e937a5993a5fd88360d6fdad ]
rk_hdptx_phy_clk_calc_rate_from_pll_cfg() is currently unable to handle cascade mode for the 3.2GHz FRL operating mode, as it relies solely on LCPLL_LCVCO_MODE_EN_MASK to determinate the rate from the rk_hdptx_frl_lcpll_cfg array. Since there is no entry for this particular rate, the function returns 0.
This is the only rate which requires LC_REF_CLK_SEL to be set in GRF_HDPTX_CON0, hence extend the FRL matching accordingly.
--- .../phy/rockchip/phy-rockchip-samsung-hdptx.c | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-)
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +25 -10
@@ -2206,16 +2206,31 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(struct rk_hdptx_phy *hdptx)return 0 ; lcpll_hw.sdc_n = (val &LCPLL_SDC_N_MASK ) >>1 ; -for (i =0 ; i <ARRAY_SIZE (rk_hdptx_frl_lcpll_cfg); i++) { -const struct lcpll_config *cfg = &rk_hdptx_frl_lcpll_cfg[i]; - -if (cfg->pms_mdiv == lcpll_hw.pms_mdiv && - cfg->pms_sdiv == lcpll_hw.pms_sdiv && - cfg->sdm_num_sign == lcpll_hw.sdm_num_sign && - cfg->sdm_num == lcpll_hw.sdm_num && - cfg->sdm_deno == lcpll_hw.sdm_deno && - cfg->sdc_n == lcpll_hw.sdc_n) -return cfg->rate; + ret =regmap_read (hdptx->grf,GRF_HDPTX_CON0 , &val); +if (ret) +return 0 ; + +if (val &LC_REF_CLK_SEL ) { +if (lcpll_hw.pms_mdiv ==0x6b && + lcpll_hw.sdm_num_sign ==0x01 && + lcpll_hw.sdm_num ==0x02 && + lcpll_hw.sdm_deno ==0x09 && + lcpll_hw.sdc_n ==FIELD_GET (LCPLL_SDC_N_MASK ,0x02 )) +return FRL_8G4L_RATE ; + }else { +const struct lcpll_config *cfg; + +for (i =0 ; i <ARRAY_SIZE (rk_hdptx_frl_lcpll_cfg); i++) { + cfg = &rk_hdptx_frl_lcpll_cfg[i]; + +if (cfg->pms_mdiv == lcpll_hw.pms_mdiv && + cfg->pms_sdiv == lcpll_hw.pms_sdiv && + cfg->sdm_num_sign == lcpll_hw.sdm_num_sign && + cfg->sdm_num == lcpll_hw.sdm_num && + cfg->sdm_deno == lcpll_hw.sdm_deno && + cfg->sdc_n == lcpll_hw.sdc_n) +return cfg->rate; + } }dev_dbg (hdptx->dev,"%s no FRL match found\n" , __func__);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1364/1815 phy: rockchip: samsung-hdptx: Handle uncommitted PHY config changes
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cristian Ciocaltea <[email protected]>
[ Upstream commit aec3e4ce25da4ed37bbbfedcbb7107ae9428b183 ]
Any changes to the PHY link rate and/or color depth done via the HDMI PHY configuration API are not immediately programmed into the hardware, but are delayed until the PHY usage count gets incremented from 0 to 1, that is when it is powered on or when the PLL clock exposed through the CCF API is prepared, whichever comes first.
Since the clock might remain in prepared state after subsequent PHY config changes, the programming can also be triggered via clk_ops.set_rate(). However, from the clock consumer perspective (i.e. VOP2 display controller), the (pixel) clock rate doesn't vary with bpc, as that is handled internally by the PHY and reflected in the TDMS character rate only.
As a consequence, changing the bpc while preserving the modeline may lead to out-of-sync issues between CCF and HDMI PHY config state, because the .set_rate() callback is not invoked when clock rate remains constant. This may also happen when the PHY PLL has been pre-programmed by an external entity, e.g. the bootloader, which is actually a regression introduced by the recent FRL-related changes.
Introduce a pll_config_dirty flag to keep track of uncommitted PHY config changes and use it in clk_ops.determine_rate() to invalidate the current clock rate (as known by CCF) and, consequently, ensure those changes are programmed into hardware via clk_ops.set_rate().
Moreover, proceed with a similar fix in phy_ops.power_on() callback, to handle the scenario where the CCF API is not used due to operating in FRL mode, while the clock is still in a prepared state and thus preventing rk_hdptx_phy_consumer_get() to apply the updated PHY configuration.
--- .../phy/rockchip/phy-rockchip-samsung-hdptx.c | 84 +++++++++++-------- 1 file changed, 48 insertions(+), 36 deletions(-)
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +48 -36
@@ -413,6 +413,7 @@ struct rk_hdptx_phy {/* clk provider */ struct clk_hw hw; +bool pll_config_dirty;bool restrict_rate_change;atomic_t usage_count;
@@ -1260,13 +1261,19 @@ static int rk_hdptx_tmds_ropll_cmn_config(struct rk_hdptx_phy *hdptx)static int rk_hdptx_pll_cmn_config (struct rk_hdptx_phy *hdptx) { +int ret; +if (hdptx->hdmi_cfg.rate <=HDMI20_MAX_RATE ) -return rk_hdptx_tmds_ropll_cmn_config (hdptx); + ret =rk_hdptx_tmds_ropll_cmn_config (hdptx); +else if (hdptx->hdmi_cfg.rate ==FRL_8G4L_RATE ) + ret =rk_hdptx_frl_lcpll_ropll_cmn_config (hdptx); +else + ret =rk_hdptx_frl_lcpll_cmn_config (hdptx); -if (hdptx->hdmi_cfg.rate ==FRL_8G4L_RATE ) -return rk_hdptx_frl_lcpll_ropll_cmn_config (hdptx); +if (!ret) + hdptx->pll_config_dirty = false; -return rk_hdptx_frl_lcpll_cmn_config (hdptx); +return ret; }static int rk_hdptx_frl_lcpll_mode_config (struct rk_hdptx_phy *hdptx)
@@ -1347,25 +1354,22 @@ static int rk_hdptx_phy_consumer_get(struct rk_hdptx_phy *hdptx)return 0 ; ret =regmap_read (hdptx->grf,GRF_HDPTX_STATUS , &status); -if (ret) - goto dec_usage; - -if (status &HDPTX_O_PLL_LOCK_DONE ) -dev_warn (hdptx->dev,"PLL locked by unknown consumer!\n" ); +if (ret) { +atomic_dec (&hdptx->usage_count); +return ret; + }if (mode ==PHY_MODE_DP ) {rk_hdptx_dp_reset (hdptx); }else { - ret =rk_hdptx_pll_cmn_config (hdptx); -if (ret) - goto dec_usage; +/* +* Ignore PLL config errors at this point as pll_config_dirty +* was not reset and, therefore, operation will be retried. +*/ +rk_hdptx_pll_cmn_config (hdptx); }return 0 ; - -dec_usage: -atomic_dec (&hdptx->usage_count); -return ret; }static int rk_hdptx_phy_consumer_put (struct rk_hdptx_phy *hdptx,bool force)
@@ -1700,13 +1704,18 @@ static int rk_hdptx_phy_power_on(struct phy *phy)if (ret)rk_hdptx_phy_consumer_put (hdptx, true); }else { -regmap_write (hdptx->grf,GRF_HDPTX_CON0 , -HDPTX_MODE_SEL <<16 |FIELD_PREP (HDPTX_MODE_SEL ,0x0 )); +if (hdptx->pll_config_dirty) + ret =rk_hdptx_pll_cmn_config (hdptx); + +if (!ret) { +regmap_write (hdptx->grf,GRF_HDPTX_CON0 , +HDPTX_MODE_SEL <<16 |FIELD_PREP (HDPTX_MODE_SEL ,0x0 )); -if (hdptx->hdmi_cfg.mode ==PHY_HDMI_MODE_FRL ) - ret =rk_hdptx_frl_lcpll_mode_config (hdptx); -else - ret =rk_hdptx_tmds_ropll_mode_config (hdptx); +if (hdptx->hdmi_cfg.mode ==PHY_HDMI_MODE_FRL ) + ret =rk_hdptx_frl_lcpll_mode_config (hdptx); +else + ret =rk_hdptx_tmds_ropll_mode_config (hdptx); + }if (ret)rk_hdptx_phy_consumer_put (hdptx, true);
@@ -2081,7 +2090,10 @@ static int rk_hdptx_phy_configure(struct phy *phy, union phy_configure_opts *optdev_err (hdptx->dev,"invalid hdmi params for phy configure\n" ); }else { hdptx->restrict_rate_change = true; -dev_dbg (hdptx->dev,"%s rate=%llu bpc=%u\n" , __func__, + hdptx->pll_config_dirty = true; + +dev_dbg (hdptx->dev,"%s %s rate=%llu bpc=%u\n" , __func__, + hdptx->hdmi_cfg.mode ?"FRL" :"TMDS" , hdptx->hdmi_cfg.rate, hdptx->hdmi_cfg.bpc); }
@@ -2338,8 +2350,19 @@ static int rk_hdptx_phy_clk_determine_rate(struct clk_hw *hw, {struct rk_hdptx_phy *hdptx =to_rk_hdptx_phy (hw); -if (hdptx->hdmi_cfg.mode ==PHY_HDMI_MODE_FRL ) -return hdptx->hdmi_cfg.rate; +/* +* Invalidate current clock rate to ensure rk_hdptx_phy_clk_set_rate() +* will be invoked to commit PLL configuration. +*/ +if (hdptx->pll_config_dirty) { + req->rate =0 ; +return 0 ; + } + +if (hdptx->hdmi_cfg.mode ==PHY_HDMI_MODE_FRL ) { + req->rate = hdptx->hdmi_cfg.rate; +return 0 ; + }/* * FIXME: Temporarily allow altering TMDS char rate via CCF.
@@ -2371,17 +2394,6 @@ static int rk_hdptx_phy_clk_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) {struct rk_hdptx_phy *hdptx =to_rk_hdptx_phy (hw); -unsigned long long link_rate = rate; - -if (hdptx->hdmi_cfg.mode !=PHY_HDMI_MODE_FRL ) - link_rate =DIV_ROUND_CLOSEST_ULL (rate * hdptx->hdmi_cfg.bpc,8 ); - -/* Revert any unlikely link rate change since determine_rate() */ -if (hdptx->hdmi_cfg.rate != link_rate) { -dev_warn (hdptx->dev,"Reverting unexpected rate change from %llu to %llu\n" , - link_rate, hdptx->hdmi_cfg.rate); - hdptx->hdmi_cfg.rate = link_rate; - }/* * The link rate would be normally programmed in HW during
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1365/1815 dmaengine: qcom-bam-dma: fix autosuspend cleanup during removal
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 a50184171235045d96104811414b25cf5338cf86 ]
bam_dma_probe() calls pm_runtime_use_autosuspend(), but bam_dma_remove() does not call the matching pm_runtime_dont_use_autosuspend() when removing the device.
If the autosuspend delay is set to a negative value while autosuspend is enabled, the runtime PM core increments usage_count to prevent runtime suspend. Without calling pm_runtime_dont_use_autosuspend() during teardown, this reference is not dropped and usage_count remains unbalanced.
Add the missing pm_runtime_dont_use_autosuspend() call before forcing the device into runtime suspend during removal.
This issue was found by manual code inspection.
--- drivers/dma/qcom/bam_dma.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma/qcom/bam_dma.c +1 -0
@@ -1401,6 +1401,7 @@ static void bam_dma_remove(struct platform_device *pdev)struct bam_device *bdev =platform_get_drvdata (pdev);u32 i; +pm_runtime_dont_use_autosuspend (&pdev->dev);pm_runtime_force_suspend (&pdev->dev);of_dma_controller_free (pdev->dev.of_node);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1366/1815 RDMA/cxgb4: Free debugfs on registration failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit fe5c16bb6252dea6025b748257ddc3b2665495b0 ]
c4iw_alloc() creates the per-device debugfs tree (dev->debugfs_root via setup_debugfs()), but it is removed only in c4iw_remove(), not in c4iw_dealloc(). When RDMA device registration fails, the registration worker's err_dealloc_ctx path calls c4iw_dealloc() directly, bypassing c4iw_remove(), so the debugfs dentries leak and outlive the freed c4iw_dev.
Move debugfs_remove_recursive() into c4iw_dealloc() so every path that frees ctx->dev also removes its debugfs tree.
--- drivers/infiniband/hw/cxgb4/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/cxgb4/device.c +1 -1
@@ -933,6 +933,7 @@ static void c4iw_rdev_close(struct c4iw_rdev *rdev)void c4iw_dealloc (struct uld_ctx *ctx) { +debugfs_remove_recursive (ctx->dev->debugfs_root);c4iw_rdev_close (&ctx->dev->rdev);WARN_ON (!xa_empty (&ctx->dev->cqs));WARN_ON (!xa_empty (&ctx->dev->qps));
@@ -957,7 +958,6 @@ static void c4iw_remove(struct uld_ctx *ctx)if (!ctx->dev)return ; -debugfs_remove_recursive (ctx->dev->debugfs_root);c4iw_unregister_device (ctx->dev);c4iw_dealloc (ctx); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1367/1815 RDMA/cma: Fix WARNING in res_to_rt
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Yanjun <[email protected]>
[ Upstream commit c6d1ec4fbe56492bb88987d577f04a5fb6955f26 ]
syzbot reported a WARN_ON(!res->dev) in res_to_rt() triggered via addr_handler() during asynchronous address resolution:
"
WARNING: drivers/infiniband/core/restrack.c:138 at res_to_rt+0x1c4/0x230 CPU#1: kworker/u8:4/59 Modules linked in: CPU: 1 UID: 0 PID: 59 Comm: kworker/u8:4 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Compute Engine, BIOS Google 07/24/2026 Workqueue: ib_addr process_one_req RIP: 0010:res_to_rt+0x1c4/0x230 drivers/infiniband/core/restrack.c:138 RSP: 0018:ffffc9000201f850 EFLAGS: 00010293 RAX: ffffffff88d00ce5 RBX: ffff88807f0fd4f8 RCX: ffff88801e6e0000 RDX: 0000000000000000 RSI: ffffffff8fd996f0 RDI: 0000000000000003 RBP: 0000000000000000 R08: ffff88801e6e0000 R09: 000000000000000a R10: 0000000000000009 R11: 0000000000000000 R12: dffffc0000000000 R13: 1ffff1100fe1fa9f R14: 0000000000000000 R15: 0000000000000003 FS: 0000000000000000(0000) GS:ffff888125012000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00001d559c3d2000 CR3: 0000000077c4c000 CR4: 00000000003526f0 Call Trace: <TASK> rdma_restrack_add+0x5a/0x8a0 drivers/infiniband/core/restrack.c:236 addr_handler+0x41a/0x5a0 drivers/infiniband/core/cma.c:3534 process_one_req+0x2eb/0x540 drivers/infiniband/core/addr.c:624 process_one_work kernel/workqueue.c:3375 [inline] process_scheduled_works+0xc4e/0x1630 kernel/workqueue.c:3458 worker_thread+0xa47/0xfb0 kernel/workqueue.c:3539 kthread+0x388/0x470 kernel/kthread.c:436 ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK>
"
In addr_handler(), cma_acquire_dev_by_src_ip() is called to populate id_priv->cma_dev and bind the associated ib_device to id_priv->id.device. If cma_acquire_dev_by_src_ip() returns an error (non-zero status), the ID remains unassociated with any RDMA device.
Previously, rdma_restrack_add(&id_priv->res) was invoked unconditionally even when cma_acquire_dev_by_src_ip() failed, passing a resource with a NULL dev pointer and triggering the WARN_ON assertion in res_to_rt().
Fix this by only adding the resource to restrack when acquiring the device succeeds.
--- drivers/infiniband/core/cma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/core/cma.c +4 -2
@@ -3528,10 +3528,12 @@ static void addr_handler(int status, struct sockaddr *src_addr,memcpy (addr, src_addr,rdma_addr_size (src_addr));if (!status && !id_priv->cma_dev) { status =cma_acquire_dev_by_src_ip (id_priv); -if (status) +if (status) {pr_debug_ratelimited ("RDMA CM: ADDR_ERROR: failed to acquire device. status %d\n" , status); -rdma_restrack_add (&id_priv->res); + }else { +rdma_restrack_add (&id_priv->res); + } }else if (status) {pr_debug_ratelimited ("RDMA CM: ADDR_ERROR: failed to resolve IP. status %d\n" , status); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1368/1815 ice: fall back to SBQ when LL PHY timer interface times out
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Przemyslaw Korba <[email protected]>
[ Upstream commit 6959fbdc940f62d8eef2a171d3a3342d7c248855 ]
The low-latency (LL) PHY timer interface relies on a tight, atomic poll of the PF_SB_ATQBAL register with a 2ms timeout. After an NVM update / EMPR, FW may need significantly longer than 2ms to start responding to ATQBAL commands. The first PHY adjust or incval write issued by ice_ptp_rebuild_owner() fails with -ETIMEDOUT.
Fix this by falling back to the existing SBQ-based PHY register write path when LL times out. This makes sure PTP is initialized when FW takes longer than expected to come back online.
Steps to reproduce:
./nvmupdate64e -if devlink -f
Update E810 card with nvmupdate64e, and observe dmesg errors:
Failed to write PHC increment value, status -110 PTP reset failed, error: -110 (-ETIMEDOUT)
--- drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 38 +++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +20 -18
@@ -4808,15 +4808,12 @@ static int ice_ptp_prep_phy_adj_ll_e810(struct ice_hw *hw, s32 adj) !FIELD_GET (REG_LL_PROXY_H_EXEC , val),10 ,REG_LL_PROXY_H_TIMEOUT_US , false, hw, REG_LL_PROXY_H); -if (err) { -ice_debug (hw,ICE_DBG_PTP ,"Failed to prepare PHY timer adjustment using low latency interface\n" ); -spin_unlock_irq (¶ms->atqbal_wq.lock); -return err; - } -spin_unlock_irq (¶ms->atqbal_wq.lock); -return 0 ; +if (err) +ice_debug (hw,ICE_DBG_PTP ,"Failed to prepare PHY timer adjustment using low latency interface\n" ); + +return err; }/**
@@ -4837,8 +4834,12 @@ static int ice_ptp_prep_phy_adj_e810(struct ice_hw *hw, s32 adj)u8 tmr_idx;int err; -if (hw->dev_caps.ts_dev_info.ll_phy_tmr_update) -return ice_ptp_prep_phy_adj_ll_e810 (hw, adj); +if (hw->dev_caps.ts_dev_info.ll_phy_tmr_update) { + err =ice_ptp_prep_phy_adj_ll_e810 (hw, adj); +if (err != -ETIMEDOUT ) +return err; +ice_debug (hw,ICE_DBG_PTP ,"LL adj timed out, falling back to SBQ\n" ); + } tmr_idx = hw->func_caps.ts_func_info.tmr_index_owned;
@@ -4901,15 +4902,12 @@ static int ice_ptp_prep_phy_incval_ll_e810(struct ice_hw *hw, u64 incval) !FIELD_GET (REG_LL_PROXY_H_EXEC , val),10 ,REG_LL_PROXY_H_TIMEOUT_US , false, hw, REG_LL_PROXY_H); -if (err) { -ice_debug (hw,ICE_DBG_PTP ,"Failed to prepare PHY timer increment using low latency interface\n" ); -spin_unlock_irq (¶ms->atqbal_wq.lock); -return err; - } -spin_unlock_irq (¶ms->atqbal_wq.lock); -return 0 ; +if (err) +ice_debug (hw,ICE_DBG_PTP ,"Failed to prepare PHY timer increment using low latency interface\n" ); + +return err; }/**
@@ -4927,8 +4925,12 @@ static int ice_ptp_prep_phy_incval_e810(struct ice_hw *hw, u64 incval)u8 tmr_idx;int err; -if (hw->dev_caps.ts_dev_info.ll_phy_tmr_update) -return ice_ptp_prep_phy_incval_ll_e810 (hw, incval); +if (hw->dev_caps.ts_dev_info.ll_phy_tmr_update) { + err =ice_ptp_prep_phy_incval_ll_e810 (hw, incval); +if (err != -ETIMEDOUT ) +return err; +ice_debug (hw,ICE_DBG_PTP ,"LL incval timed out, falling back to SBQ\n" ); + } tmr_idx = hw->func_caps.ts_func_info.tmr_index_owned; low =lower_32_bits (incval);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1369/1815 ice: clear the default forwarding VSI rule when releasing a VSI
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Oros <[email protected]>
[ Upstream commit d04287e27bf1c0b879a10d929c163f2da69715b6 ]
When a VSI is configured as the switch's default forwarding VSI (ICE_SW_LKUP_DFLT) and is then torn down, the rule is left behind in the switch. ice_vsi_release() no longer removes it, and the SR-IOV VF free path (ice_free_vfs() -> ice_free_vf_res() -> ice_vf_vsi_release() -> ice_vsi_release()) does not disable promiscuous mode either, which only happens on VF reset in ice_vf_clear_all_promisc_modes().
A trusted VF that enters unicast promiscuous mode becomes the default forwarding VSI (this is the default mode, when the PF does not have VF true-promiscuous mode enabled). If the VFs are then destroyed without the VF first leaving promiscuous mode, the ICE_SW_LKUP_DFLT rule for the now-freed VSI is leaked. When VFs are recreated, a VSI reuses the freed hw_vsi_id. If it is assigned a different VSI handle than the leaked rule holds, ice_set_dflt_vsi() does not recognize it as already-default, and ice_add_update_vsi_list() folds the dangling (freed) handle into a VSI list, which the firmware rejects. The VSI handle assigned on re-creation varies, so the failure is intermittent rather than every cycle.
Reproduce by repeatedly running the cycle below on the two ports of the same card, where $VF0 and $VF1 are the netdevs of vf 15 once they appear. The VF must be brought up so iavf actually pushes the unicast promiscuous request, and the rule must settle before the VFs are torn down again:
echo 16 > /sys/class/net/$PF0/device/sriov_numvfs echo 16 > /sys/class/net/$PF1/device/sriov_numvfs ip link set $PF0 vf 15 trust on
ip link set $PF1 vf 15 trust on
ip link set $VF0 up
ip link set $VF1 up
ip link set $VF0 promisc on
ip link set $VF1 promisc on
sleep 1
echo 0 > /sys/class/net/$PF0/device/sriov_numvfs echo 0 > /sys/class/net/$PF1/device/sriov_numvfs
Within a few cycles the ice PF and iavf VF log:
Failed to set VSI 25 as the default forwarding VSI, error -22 Turning on/off promiscuous mode for VF 63 failed, error: -22 PF returned error -53 (IAVF_ERR_ADMIN_QUEUE_ERROR) to our request 14
This cleanup used to live in ice_vsi_release() but was dropped by the referenced refactor. Restore it. Clear the default forwarding VSI rule in ice_vsi_release() when this VSI owns it, which covers every teardown path.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ice/ice_lib.c +3 -0
@@ -2871,6 +2871,9 @@ int ice_vsi_release(struct ice_vsi *vsi)return -ENODEV ; pf = vsi->back; +if (ice_is_vsi_dflt_vsi (vsi)) +ice_clear_dflt_vsi (vsi); +if (test_bit (ICE_FLAG_RSS_ENA , pf->flags))ice_rss_clean (vsi);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1370/1815 ice: acquire NVM lock around each flash read
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Malz <[email protected]>
[ Upstream commit df88d6f1ed653993bd5c8647aef0e6498f4b1647 ]
FW caps the NVM read lock at a maximum of 3000ms regardless of the timeout requested via ice_acquire_nvm(). ice_read_flat_nvm() splits a read into multiple ice_aq_read_nvm() commands, one per 4KB sector, all issued under a single lock taken by the caller. Reading a large region can exceed 3000ms, so FW reclaims the lock mid-read and the remaining commands might fail.
Move the lock acquire/release into ice_read_flat_nvm() so it brackets each individual ice_aq_read_nvm() command, ensuring the lock is never held across more than one FW read.
ice_release_nvm() issues its own AQ command and overwrites hw->adminq.sq_last_status, which some callers inspect after a failed read. Add an optional read_aq_err output parameter to ice_read_flat_nvm() to capture the failing read's AQ error before the release; callers that need it (ice_discover_flash_size() and the ethtool/devlink log paths) use it instead of sq_last_status, others pass NULL.
Callers that previously took the lock around ice_read_flat_nvm(), ice_read_sr_word() or ice_read_flash_module() now call them without it. The now-redundant per-block locking in ice_devlink_nvm_snapshot() is dropped. ice_read_sr_word() is now a thin wrapper, so ice_read_sr_word_aq() is folded into it.
--- .../net/ethernet/intel/ice/devlink/devlink.c | 32 ++----- drivers/net/ethernet/intel/ice/ice_ethtool.c | 16 +--- drivers/net/ethernet/intel/ice/ice_nvm.c | 90 ++++++++++--------- drivers/net/ethernet/intel/ice/ice_nvm.h | 2 +- 4 files changed, 58 insertions(+), 82 deletions(-)
drivers/net/ethernet/intel/ice/devlink/devlink.c +7 -25
@@ -1890,27 +1890,18 @@ static int ice_devlink_nvm_snapshot(struct devlink *devlink,*/ for (i =0 ; i < num_blks; i++) {u32 read_sz =min_t (u32,ICE_DEVLINK_READ_BLK_SIZE , left); - - status =ice_acquire_nvm (hw,ICE_RES_READ ); -if (status) { -dev_dbg (dev,"ice_acquire_nvm failed, err %d aq_err %d\n" , - status, hw->adminq.sq_last_status); -NL_SET_ERR_MSG_MOD (extack,"Failed to acquire NVM semaphore" ); -vfree (nvm_data); -return -EIO ; - } +enum libie_aq_err read_aq_err =LIBIE_AQ_RC_OK ; status =ice_read_flat_nvm (hw, i *ICE_DEVLINK_READ_BLK_SIZE , - &read_sz, tmp, read_shadow_ram); + &read_sz, tmp, read_shadow_ram, + &read_aq_err);if (status) {dev_dbg (dev,"ice_read_flat_nvm failed after reading %u bytes, err %d aq_err %d\n" , - read_sz, status, hw->adminq.sq_last_status); + read_sz, status, read_aq_err);NL_SET_ERR_MSG_MOD (extack,"Failed to read NVM contents" ); -ice_release_nvm (hw);vfree (nvm_data);return -EIO ; } -ice_release_nvm (hw); tmp += read_sz; left -= read_sz;
@@ -1943,6 +1934,7 @@ static int ice_devlink_nvm_read(struct devlink *devlink,struct netlink_ext_ack *extack, u64 offset, u32 size, u8 *data) { + enum libie_aq_err read_aq_err = LIBIE_AQ_RC_OK;struct ice_pf *pf =devlink_priv (devlink);struct device *dev =ice_pf_to_dev (pf);struct ice_hw *hw = &pf->hw;
@@ -1966,24 +1958,14 @@ static int ice_devlink_nvm_read(struct devlink *devlink,return -ERANGE ; } - status =ice_acquire_nvm (hw,ICE_RES_READ ); -if (status) { -dev_dbg (dev,"ice_acquire_nvm failed, err %d aq_err %d\n" , - status, hw->adminq.sq_last_status); -NL_SET_ERR_MSG_MOD (extack,"Failed to acquire NVM semaphore" ); -return -EIO ; - } - status =ice_read_flat_nvm (hw, (u32 )offset, &size, data, - read_shadow_ram); + read_shadow_ram, &read_aq_err);if (status) {dev_dbg (dev,"ice_read_flat_nvm failed after reading %u bytes, err %d aq_err %d\n" , - size, status, hw->adminq.sq_last_status); + size, status, read_aq_err);NL_SET_ERR_MSG_MOD (extack,"Failed to read NVM contents" ); -ice_release_nvm (hw);return -EIO ; } -ice_release_nvm (hw);return 0 ; }
drivers/net/ethernet/intel/ice/ice_ethtool.c +4 -12
@@ -853,6 +853,7 @@ static int ice_get_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom, u8 *bytes) { + enum libie_aq_err read_aq_err = LIBIE_AQ_RC_OK;struct ice_pf *pf =ice_netdev_to_pf (netdev);struct ice_hw *hw = &pf->hw;struct device *dev;
@@ -869,24 +870,15 @@ ice_get_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom,if (!buf)return -ENOMEM ; - ret =ice_acquire_nvm (hw,ICE_RES_READ ); -if (ret) { -dev_err (dev,"ice_acquire_nvm failed, err %d aq_err %s\n" , - ret,libie_aq_str (hw->adminq.sq_last_status)); - goto out; - } - ret =ice_read_flat_nvm (hw, eeprom->offset, &eeprom->len, buf, - false); + false, &read_aq_err);if (ret) {dev_err (dev,"ice_read_flat_nvm failed, err %d aq_err %s\n" , - ret,libie_aq_str (hw->adminq.sq_last_status)); - goto release; + ret,libie_aq_str (read_aq_err)); + goto out; }memcpy (bytes, buf, eeprom->len); -release: -ice_release_nvm (hw); out:kfree (buf);return ret;
drivers/net/ethernet/intel/ice/ice_nvm.c +46 -44
172 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_nvm.h +1 -1
@@ -19,7 +19,7 @@ int ice_aq_read_nvm(struct ice_hw *hw, u16 module_typeid, u32 offset, bool read_shadow_ram, struct ice_sq_cd *cd);int ice_read_flat_nvm (struct ice_hw *hw,u32 offset,u32 *length,u8 *data, -bool read_shadow_ram); +bool read_shadow_ram,enum libie_aq_err *read_aq_err);int ice_get_pfa_module_tlv (struct ice_hw *hw,u16 *module_tlv,u16 *module_tlv_len,u16 module_type);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1371/1815 idpf: add missing cpu_to_le32 in idpf_tx_splitq_build_flow_desc
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
[ Upstream commit b802a8c1ca16f9490fa0cb3110c00c10d52b392d ]
idpf_tx_splitq_build_flow_desc performs a 32-bit store to &cmd_dtype to set the 8-bit cmd_dtype and zero the adjacent 3-byte timestamp field in a single operation.
Descriptors are in little endian. Add missing cpu_to_le32 and cast to __le32 to ensure the fields are written correctly also on big endian platforms.
--- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +1 -1
@@ -2408,7 +2408,7 @@ void idpf_tx_splitq_build_flow_desc(union idpf_tx_flex_desc *desc,struct idpf_tx_splitq_params *params, u16 td_cmd, u16 size) { - *(u32 *)&desc->flow.qw1.cmd_dtype = (u8)(params->dtype | td_cmd); + *(__le32 *)&desc->flow.qw1.cmd_dtype = cpu_to_le32((u8)(params->dtype | td_cmd)); desc->flow.qw1.rxr_bufsize =cpu_to_le16 ((u16 )size); desc->flow.qw1.compl_tag =cpu_to_le16 (params->compl_tag); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1372/1815 ASoC: pxa: Use devm_clk_get_optional() for extclk clock
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 6ec64d757af9b75a3c64f9f7dad76bdc1efc06ca ]
The Device Tree binding defines the extclk clock as an optional property, but the driver currently uses devm_clk_get() and manually handles the absence of the clock.
Use devm_clk_get_optional() to match the binding and simplify the optional clock handling. This also propagates errors other than the absence of the optional clock, including -EPROBE_DEFER.
This changes the existing behavior for errors other than -EPROBE_DEFER. RFC to discuss whether these errors should cause probe to fail rather than being treated as an unavailable optional clock.
--- sound/soc/pxa/pxa-ssp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
sound/soc/pxa/pxa-ssp.c +2 -5
@@ -769,13 +769,10 @@ static int pxa_ssp_probe(struct snd_soc_dai *dai) goto err_priv; } - priv->extclk =devm_clk_get (dev,"extclk" ); + priv->extclk =devm_clk_get_optional (dev,"extclk" );if (IS_ERR (priv->extclk)) { ret =PTR_ERR (priv->extclk); -if (ret == -EPROBE_DEFER ) - goto err_priv; - - priv->extclk =NULL ; + goto err_priv; } }else { priv->ssp =pxa_ssp_request (dai->id +1 ,"SoC audio" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1373/1815 ASoC: fsl-asoc-card: defer probe when the CPU DAI device is not ready
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: LiangCheng Wang <[email protected]>
[ Upstream commit 0286324da660875dc504fd65b3be87e9c8b9a547 ]
fsl_asoc_card_probe() hard-fails with -EINVAL when the CPU DAI (SAI) platform device is not found. Like the codec, the CPU DAI may just be probed later than the machine driver; the order is not guaranteed and varies across kernel versions, so a permanent -EINVAL leaves the card unregistered with no analog playback or capture.
Defer probe instead, mirroring commit e396dec46c56 ("ASoC:
fsl-asoc-card: Defer probe when fail to find codec device").
Tested on i.MX8MP with an ALC5672 on SAI3: the card that failed to register on v6.18 now comes up during boot.
--- sound/soc/fsl/fsl-asoc-card.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/fsl/fsl-asoc-card.c +2 -2
@@ -728,8 +728,8 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) cpu_pdev =of_find_device_by_node (cpu_np);if (!cpu_pdev) { -dev_err (&pdev->dev,"failed to find CPU DAI device\n" ); - ret = -EINVAL ; + ret =dev_err_probe (&pdev->dev, -EPROBE_DEFER , +"failed to find CPU DAI device\n" ); goto fail; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1374/1815 UBI: Preserve torture flag when rescheduling failed erasures
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit 420477a84f1e52babfe60a43dbdd0988ed956845 ]
In __erase_worker(), when ubi_sync_erase() returns -EINTR, -ENOMEM, -EAGAIN, or -EBUSY, the physical eraseblock is rescheduled for erasure via schedule_erase() with the torture flag hardcoded to 0. This unconditionally drops the torture request.
If the error occurred before torture_peb() completed (e.g., -ENOMEM from the ec_hdr allocation in ubi_sync_erase(), errors from self_check_not_bad()/nor_erase_prepare() in ubi_io_sync_erase(), or torture_peb() failing mid-test because its internal do_sync_erase()/ ubi_io_read()/ubi_io_write() returned one of the above error codes), the torture test was never finished. Such a PEB may reach the free pool without being tortured, defeating the purpose of the torture test for detecting marginally-bad eraseblocks.
If the error occurred after torture_peb() succeeded (the final do_sync_erase() in ubi_io_sync_erase() or ubi_io_write_ec_hdr() in ubi_sync_erase() failed), the torture has already been done and need not be repeated.
Pass the torture flag by pointer to ubi_sync_erase() and ubi_io_sync_erase(), and clear it to zero once torture_peb() has completed successfully. __erase_worker() then forwards the updated wl_wrk->torture to schedule_erase(): torture already done is dropped, torture not completed is preserved across the reschedule.
--- drivers/mtd/ubi/attach.c | 4 ++-- drivers/mtd/ubi/fastmap.c | 6 +++--- drivers/mtd/ubi/io.c | 11 +++++++---- drivers/mtd/ubi/ubi.h | 4 ++-- drivers/mtd/ubi/wl.c | 15 +++++++++------ 5 files changed, 23 insertions(+), 17 deletions(-)
drivers/mtd/ubi/attach.c +2 -2
@@ -771,7 +771,7 @@ void ubi_remove_av(struct ubi_attach_info *ai, struct ubi_ainf_volume *av)static int early_erase_peb (struct ubi_device *ubi,const struct ubi_attach_info *ai,int pnum,int ec) { -int err; +int err, torture =0 ;struct ubi_ec_hdr *ec_hdr;if ((long long )ec >=UBI_MAX_ERASECOUNTER ) {
@@ -790,7 +790,7 @@ static int early_erase_peb(struct ubi_device *ubi, ec_hdr->ec =cpu_to_be64 (ec); - err =ubi_io_sync_erase (ubi, pnum,0 ); + err =ubi_io_sync_erase (ubi, pnum, &torture);if (err <0 ) goto out_free;
drivers/mtd/ubi/fastmap.c +3 -3
@@ -1488,7 +1488,7 @@ static void return_fm_pebs(struct ubi_device *ubi,*/ int ubi_update_fastmap (struct ubi_device *ubi) { -int ret, i, j; +int ret, i, j, torture =0 ;struct ubi_fastmap_layout *new_fm, *old_fm;struct ubi_wl_entry *tmp_e;
@@ -1526,7 +1526,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)if (!tmp_e) {if (old_fm && old_fm->e[i]) { - ret =ubi_sync_erase (ubi, old_fm->e[i],0 ); + ret =ubi_sync_erase (ubi, old_fm->e[i], &torture);if (ret <0 ) {ubi_err (ubi,"could not erase old fastmap PEB" );
@@ -1578,7 +1578,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)if (old_fm) {/* no fresh anchor PEB was found, reuse the old one */ if (!tmp_e) { - ret =ubi_sync_erase (ubi, old_fm->e[0 ],0 ); + ret =ubi_sync_erase (ubi, old_fm->e[0 ], &torture);if (ret <0 ) {ubi_err (ubi,"could not erase old anchor PEB" );
drivers/mtd/ubi/io.c +7 -4
@@ -519,8 +519,10 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum)/** * ubi_io_sync_erase - synchronously erase a physical eraseblock. * @ubi: UBI device description object -* @pnum: physical eraseblock number to erase -* @torture: if this physical eraseblock has to be tortured +* @pnum: the physical eraseblock number to erase +* @torture: if this physical eraseblock has to be tortured; cleared to zero +* once the torture test has completed successfully so that a retry +* of the erase does not torture the physical eraseblock again * * This function synchronously erases physical eraseblock @pnum. If @torture * flag is not zero, the physical eraseblock is checked by means of writing
@@ -532,7 +534,7 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum)* codes in case of other errors. Note, %-EIO means that the physical * eraseblock is bad. */ -int ubi_io_sync_erase (struct ubi_device *ubi,int pnum,int torture) +int ubi_io_sync_erase (struct ubi_device *ubi,int pnum,int *torture) {int err, ret =0 ;
@@ -560,10 +562,11 @@ int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture)return err; } -if (torture) { +if (*torture) { ret =torture_peb (ubi, pnum);if (ret <0 )return ret; + *torture =0 ; } err =do_sync_erase (ubi, pnum);
drivers/mtd/ubi/ubi.h +2 -2
@@ -901,7 +901,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap, struct ubi_attach_info *ai_scan);/* wl.c */ -int ubi_sync_erase (struct ubi_device *ubi,struct ubi_wl_entry *e,int torture); +int ubi_sync_erase (struct ubi_device *ubi,struct ubi_wl_entry *e,int *torture);int ubi_wl_get_peb (struct ubi_device *ubi);int ubi_wl_put_peb (struct ubi_device *ubi,int vol_id,int lnum,int pnum,int torture);
@@ -923,7 +923,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, int len);int ubi_io_write (struct ubi_device *ubi,const void *buf,int pnum,int offset,int len); -int ubi_io_sync_erase (struct ubi_device *ubi,int pnum,int torture); +int ubi_io_sync_erase (struct ubi_device *ubi,int pnum,int *torture);int ubi_io_is_bad (const struct ubi_device *ubi,int pnum);int ubi_io_mark_bad (const struct ubi_device *ubi,int pnum); int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
drivers/mtd/ubi/wl.c +9 -6
@@ -443,12 +443,14 @@ static int prot_queue_del(struct ubi_device *ubi, int pnum)* ubi_sync_erase - synchronously erase a physical eraseblock. * @ubi: UBI device description object * @e: the physical eraseblock to erase -* @torture: if the physical eraseblock has to be tortured +* @torture: if the physical eraseblock has to be tortured; cleared to zero +* once the torture test has completed successfully so that a retry +* of the erase does not torture the physical eraseblock again * * This function returns zero in case of success and a negative error code in * case of failure. */ -int ubi_sync_erase (struct ubi_device *ubi,struct ubi_wl_entry *e,int torture) +int ubi_sync_erase (struct ubi_device *ubi,struct ubi_wl_entry *e,int *torture) {int err;struct ubi_ec_hdr *ec_hdr;
@@ -1113,7 +1115,7 @@ static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk)dbg_wl ("erase PEB %d EC %d LEB %d:%d" , pnum, e->ec, wl_wrk->vol_id, wl_wrk->lnum); - err =ubi_sync_erase (ubi, e, wl_wrk->torture); + err =ubi_sync_erase (ubi, e, &wl_wrk->torture);if (!err) {spin_lock (&ubi->wl_lock);
@@ -1150,7 +1152,8 @@ static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk)int err1;/* Re-schedule the LEB for erasure */ - err1 =schedule_erase (ubi, e, vol_id, lnum,0 , true); + err1 =schedule_erase (ubi, e, vol_id, lnum, wl_wrk->torture, + true);if (err1) {spin_lock (&ubi->wl_lock);wl_entry_destroy (ubi, e);
@@ -1757,7 +1760,7 @@ static void shutdown_work(struct ubi_device *ubi)static int erase_aeb (struct ubi_device *ubi,struct ubi_ainf_peb *aeb,bool sync) {struct ubi_wl_entry *e; -int err; +int err, torture =0 ; e =kmem_cache_alloc (ubi_wl_entry_slab,GFP_KERNEL );if (!e)
@@ -1768,7 +1771,7 @@ static int erase_aeb(struct ubi_device *ubi, struct ubi_ainf_peb *aeb, bool sync ubi->lookuptbl[e->pnum] = e;if (sync) { - err =ubi_sync_erase (ubi, e, false); + err =ubi_sync_erase (ubi, e, &torture);if (err) goto out_free;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1375/1815 UBI: fastmap: Pass to_be_tortured when reusing old fastmap PEBs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit be04fce9945aac2a843f5d16725391eb80d948ef ]
In ubi_update_fastmap(), when no fresh PEB is available to replace an old fastmap PEB, the old PEB is reused by erasing it synchronously via ubi_sync_erase() with the torture flag hardcoded to zero.
However, old_fm->to_be_tortured[] may be non-zero: it is set during fastmap scanning when ubi_io_read_data()/ubi_io_read_ec_hdr() reports UBI_IO_BITFLIPS, meaning the PEB showed signs of bit decay and should be tortured to verify it is still reliable.
When the old PEB is instead returned to the WL sub-system via ubi_wl_put_fm_peb(), the to_be_tortured flag is honored. The synchronous reuse path is inconsistent: it silently skips the torture test for PEBs that exhibited bit-flips.
Fix it by passing &old_fm->to_be_tortured[i] to ubi_sync_erase().
--- drivers/mtd/ubi/fastmap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/mtd/ubi/fastmap.c +5 -3
@@ -1488,7 +1488,7 @@ static void return_fm_pebs(struct ubi_device *ubi,*/ int ubi_update_fastmap (struct ubi_device *ubi) { -int ret, i, j, torture =0 ; +int ret, i, j;struct ubi_fastmap_layout *new_fm, *old_fm;struct ubi_wl_entry *tmp_e;
@@ -1526,7 +1526,8 @@ int ubi_update_fastmap(struct ubi_device *ubi)if (!tmp_e) {if (old_fm && old_fm->e[i]) { - ret =ubi_sync_erase (ubi, old_fm->e[i], &torture); + ret =ubi_sync_erase (ubi, old_fm->e[i], + &old_fm->to_be_tortured[i]);if (ret <0 ) {ubi_err (ubi,"could not erase old fastmap PEB" );
@@ -1578,7 +1579,8 @@ int ubi_update_fastmap(struct ubi_device *ubi)if (old_fm) {/* no fresh anchor PEB was found, reuse the old one */ if (!tmp_e) { - ret =ubi_sync_erase (ubi, old_fm->e[0 ], &torture); + ret =ubi_sync_erase (ubi, old_fm->e[0 ], + &old_fm->to_be_tortured[0 ]);if (ret <0 ) {ubi_err (ubi,"could not erase old anchor PEB" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1376/1815 bpf: Compare iterator types during state pruning
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ning Ding <[email protected]>
[ Upstream commit 83608e303b95d07afba1c15da0b5d9e513c2f15a ]
An iterator stack slot can be MEM_RCU or PTR_UNTRUSTED. These states must not be equal, or the verifier can prune an unsafe path.
Compare the pointer type for STACK_ITER slots.
--- kernel/bpf/states.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/bpf/states.c +2 -1
@@ -812,7 +812,8 @@ static bool stacksafe(struct bpf_verifier_env *env, struct bpf_func_state *old,* infinite loop check triggering, see * iter_active_depths_differ() */ - if (old_reg->iter.btf != cur_reg->iter.btf || + if (old_reg->type != cur_reg->type || + old_reg->iter.btf != cur_reg->iter.btf || old_reg->iter.btf_id != cur_reg->iter.btf_id || old_reg->iter.state != cur_reg->iter.state ||/* ignore {old_reg,cur_reg}->iter.depth, see above */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1377/1815 ubi: Fix rollback for explicit UBI device numbers
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 5b0a6b554e12a97f9771a9a9f4ea1f5457373c73 ]
ubi_init_attach() rolls back module initialization failures by scanning ubi_devices[0..i-1], where i is the mtd= parameter index. That assumes the parameter index matches the UBI device number.
That assumption is not true when mtd= specifies an explicit ubi_num. A successfully attached device can be stored at a higher ubi_devices[] slot, and a later failure can miss it during rollback.
Scan the full ubi_devices[] array and detach by the actual array index, matching the way UBI devices are stored.
--- drivers/mtd/ubi/build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/ubi/build.c +2 -2
@@ -1317,10 +1317,10 @@ static int __init ubi_init_attach(void)return 0 ; out_detach: -for (k =0 ; k < i; k++) +for (k =0 ; k <UBI_MAX_DEVICES ; k++)if (ubi_devices[k]) {mutex_lock (&ubi_devices_mutex); -ubi_detach_mtd_dev (ubi_devices[k]->ubi_num,1 ); +ubi_detach_mtd_dev (k,1 );mutex_unlock (&ubi_devices_mutex); }return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1378/1815 objtool/klp: Fix vmlinux .klp.symid link error for .no_trim_symbol symbols
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit 3a83d9cd3d0e66c0ef99ce84f972ed26f50c990f ]
Testing klp-build with arm64 produced the following linker error during the original kernel build:
__notrim.1' referenced in section .klp.symid' of vmlinux.o: defined in discarded section `.no_trim_symbol' of vmlinux.o
symbol_get() puts a static __notrim[] in .no_trim_symbol, which GCC names __notrim.1, __notrim.2, etc. Two or more built-in translation units calling symbol_get() thus produce duplicate names, resulting in corresponding .klp.symid references which trigger the above error.
Add .no_trim_symbol to the discarded section list so its symbols don't get symids.
Note this issue is not specific to arm64: it just needs two built-in symbol_get() callers. arm64 trips over it easily because it has KVM always compiled in vmlinux, whereas on x86 it's typically a module.
--- tools/objtool/klp-symid.c | 1 + 1 file changed, 1 insertion(+)
tools/objtool/klp-symid.c +1 -0
@@ -31,6 +31,7 @@static const char *const discarded_secs[] = {".discard" ,".modinfo" , +".no_trim_symbol" ,"__tracepoint_check" , };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1379/1815 objtool/klp: Fix size of empty special section entries
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit 1ea786097cd79522b76cbd41beeb8f84ef3a76f4 ]
create_fake_symbols() sizes each ANNOTATE_DATA_SPECIAL entry from the offset of the next annotation, falling back to the end of the section for the last entry. But the last entry is detected by a zero size, which also happens for an *empty* entry: ALTERNATIVE(oldinstr, "", ft) still annotates its zero-length replacement, at the same offset as the next entry's annotation.
So every empty replacement gets a fake symbol spanning the entire rest of .altinstr_replacement. That's harmless today only because find_symbol_containing() picks the smaller of two overlapping symbols.
Track whether a next annotation was found rather than inferring it from the size. A zero-length fake symbol is fine: find_symbol_containing() skips those, so the properly sized symbol at the same offset still wins.
--- tools/objtool/klp-diff.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
tools/objtool/klp-diff.c +11 -2
@@ -1628,13 +1628,17 @@ static int create_fake_symbols(struct elf *elf)for_each_reloc (sec->rsec, reloc) {unsigned long offset, size;struct reloc *next_reloc; +bool last = true;if (annotype (elf, sec, reloc) !=ANNOTYPE_DATA_SPECIAL )continue ; offset =reloc_addend (reloc); - size =0 ; +/* +* Find the start of the next entry so the fake symbol size can +* be calculated. +*/ next_reloc = reloc;for_each_reloc_continue (sec->rsec, next_reloc) { if (annotype(elf, sec, next_reloc) != ANNOTYPE_DATA_SPECIAL ||
@@ -1642,10 +1646,15 @@ static int create_fake_symbols(struct elf *elf)continue ; size =reloc_addend (next_reloc) - offset; + last = false;break ; } -if (!size) +/* +* If no next entry found, this is the last entry, so its size +* is from the current offset to the end of the section. +*/ +if (last) size =sec_size (reloc->sym->sec) - offset;if (create_fake_symbol (elf, reloc->sym->sec, offset, size))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1380/1815 objtool/klp: Ignore replacement offset of empty x86 alternatives
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit 636f230ce21e2730072c58280f1fa0bed4a00eed ]
An x86 alternative with an empty replacement, e.g. the second entry of
ALTERNATIVE_2("orig", "repl", ft1, "", ft2)
has a replacementlen of zero. Its replacement offset still gets a relocation, but the label it points at is the end of the previous replacement, which is also the beginning of the *next* alternative's replacement. The value is meaningless; get_alt_entry() already ignores it for that reason.
klp diff doesn't ignore it. When such an alternative belongs to a changed function, cloning its relocations drags in the unrelated neighboring replacement, along with everything that replacement references. On an x86 clang/lto build an empty alternative in meminfo_proc_show() pulled in the replacement of an alternative in proc_kcore_init(), silently emitting a klp relocation against init text which has long since been freed by the time the patch is applied.
Add arch_alt_ignore_new_reloc() and skip such relocations when cloning. This has to be arch specific: on arm64 a zero-length replacement instead identifies an alternative callback, whose replacement offset points at the callback function and must be preserved.
--- tools/objtool/arch/x86/special.c | 27 +++++++++++++++++++++++++ tools/objtool/include/objtool/special.h | 7 +++++++ tools/objtool/klp-diff.c | 6 +++++- 3 files changed, 39 insertions(+), 1 deletion(-)
tools/objtool/arch/x86/special.c +27 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-or-later #include <string.h> +#include <arch/special.h> #include <objtool/special.h> #include <objtool/builtin.h> #include <objtool/warn.h>
@@ -9,6 +10,32 @@/* cpu feature name array generated from cpufeatures.h */ #include "cpu-feature-names.c" +/* +* An alternative with an empty replacement, e.g. the second entry of +* +* ALTERNATIVE_2("orig", "repl", ft1, "", ft2) +* +* still gets a relocation for its replacement offset. But the label it points +* at is the end of the previous entry's replacement, which is also the +* beginning of the *next* entry's replacement. The value is meaningless: it's +* only ever used with a length of zero. +*/ +bool arch_alt_ignore_new_reloc (struct section *sec,unsigned long offset) +{ +unsigned long entry_off; + +if (strcmp (sec->name,".altinstructions" )) +return false; + + entry_off = offset - (offset %ALT_ENTRY_SIZE ); + +if (offset - entry_off !=ALT_NEW_OFFSET ) +return false; + +return !*(unsigned char *)(sec->data->d_buf + entry_off + +ALT_NEW_LEN_OFFSET ); +} +void arch_handle_alternative (struct special_alt *alt) {static struct special_alt *group, *prev;
tools/objtool/include/objtool/special.h +7 -0
@@ -32,6 +32,13 @@ int special_get_alts(struct elf *elf, struct list_head *alts);void arch_handle_alternative (struct special_alt *alt); +/* +* Should the reloc at @offset -- the "new" (replacement) field of a special +* section group entry -- be ignored? The meaning of a zero-length replacement +* is arch specific, so the arch decides. +*/ +bool arch_alt_ignore_new_reloc (struct section *sec,unsigned long offset); +bool arch_support_alt_relocation (struct special_alt *special_alt,struct instruction *insn,struct reloc *reloc);
tools/objtool/klp-diff.c +5 -1
@@ -12,7 +12,7 @@#include <objtool/arch.h> #include <objtool/klp.h> #include <objtool/util.h> -#include <arch/special.h> +#include <objtool/special.h> #include <linux/align.h> #include <linux/objtool_types.h>
@@ -1538,6 +1538,10 @@ static int clone_sym_relocs(struct elfs *e, struct symbol *patched_sym) !strcmp(patched_reloc->sym->sec->name, ".altinstr_aux")) continue; +if (arch_alt_ignore_new_reloc (patched_sym->sec, +reloc_offset (patched_reloc))) +continue ; + ret =convert_reloc_sym (e->patched, patched_reloc);if (ret <0 ) { ERROR_FUNC(patched_rsec->base, reloc_offset(patched_reloc),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1381/1815 mtd: ubi: Release device reference on busy detach
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 31dd710cd84d5dd63c49f640d3a9f36c9699ca95 ]
ubi_detach_mtd_dev() obtains a device reference through ubi_get_device() before checking whether the UBI device is busy. The busy return path drops ubi->ref_count but leaves the device reference held, so the device object cannot be released after a later detach.
Drop the device reference before returning -EBUSY.
--- drivers/mtd/ubi/build.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/ubi/build.c +1 -0
@@ -1105,6 +1105,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway) ubi->ref_count -=1 ;if (ubi->ref_count) {if (!anyway) { +put_device (&ubi->dev);spin_unlock (&ubi_devices_lock);return -EBUSY ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1382/1815 ASoC: xilinx: formatter_pcm: fix stream_data leak on open error
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit b992511180e126150c6ad3580a6fd568c385f4c6 ]
In xlnx_formatter_pcm_open(), stream_data is allocated and adata->play_stream or adata->capture_stream is assigned early. If a later step, such as snd_pcm_hw_constraint_step() or snd_pcm_hw_constraint_integer(), fails, the function returns the error immediately. ALSA does not call the close callback when open fails, so stream_data is leaked and the stream pointer is left dangling, pointing to a substream that ALSA frees. A later interrupt would then call snd_pcm_period_elapsed() on the freed substream.
Free stream_data and clear the stream pointer on the error paths.
--- sound/soc/xilinx/xlnx_formatter_pcm.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
sound/soc/xilinx/xlnx_formatter_pcm.c +11 -3
@@ -384,7 +384,7 @@ static int xlnx_formatter_pcm_open(struct snd_soc_component *component,if (err) {dev_err (component->dev,"Unable to set constraint on period bytes\n" ); -return err; + goto error; }/* Resize the buffer bytes as divisible by 64 */
@@ -394,7 +394,7 @@ static int xlnx_formatter_pcm_open(struct snd_soc_component *component,if (err) {dev_err (component->dev,"Unable to set constraint on buffer bytes\n" ); -return err; + goto error; }/* Set periods as integer multiple */
@@ -403,7 +403,7 @@ static int xlnx_formatter_pcm_open(struct snd_soc_component *component,if (err <0 ) {dev_err (component->dev,"Unable to set constraint on periods to be integer\n" ); -return err; + goto error; }/* enable DMA IOC irq */
@@ -412,6 +412,14 @@ static int xlnx_formatter_pcm_open(struct snd_soc_component *component,writel (val, stream_data->mmio +XLNX_AUD_CTRL );return 0 ; + +error: +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + adata->play_stream =NULL ; +else + adata->capture_stream =NULL ; +kfree (stream_data); +return err; } static int xlnx_formatter_pcm_close(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1383/1815 UBI: fix two issues in the ubi.mtd MODULE_PARM_DESC
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ran Hongyun <[email protected]>
[ Upstream commit ff7937d14f5333ec7e6fb50d00a152d7974f4105 ]
Fix two issues introduced before:
- The parameter format string was missing the enable_fm and need_resv_pool tokens introduced in an earlier commit.
- The bad-block reservation note was misplaced after Example 5 instead of after Example 3. It was misplaced due to an earlier patch.
--- drivers/mtd/ubi/build.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/ubi/build.c +3 -3
@@ -1575,7 +1575,7 @@ static int ubi_mtd_param_parse(const char *val, const struct kernel_param *kp) }module_param_call (mtd, ubi_mtd_param_parse,NULL ,NULL ,0400 ); -MODULE_PARM_DESC (mtd,"MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024[,ubi_num]]].\n" +MODULE_PARM_DESC (mtd,"MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024[,ubi_num[,enable_fm[,need_resv_pool]]]]].\n" "Multiple \"mtd\" parameters may be specified.\n" "MTD devices may be specified by their number, name, or path to the MTD character device node.\n" "Optional \"vid_hdr_offs\" parameter specifies UBI VID header position to be used by UBI. (default value if 0)\n"
@@ -1588,9 +1588,9 @@ MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|pa"Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n" "Example 2: mtd=content,1984 mtd=4 - attach MTD device with name \"content\" using VID header offset 1984, and MTD device number 4 with default VID header offset.\n" "Example 3: mtd=/dev/mtd1,0,25 - attach MTD device /dev/mtd1 using default VID header offset and reserve 25*nand_size_in_blocks/1024 erase blocks for bad block handling.\n" +"\t(e.g. if the NAND *chipset* has 4096 PEB, 100 will be reserved for this UBI device).\n" "Example 4: mtd=/dev/mtd1,0,0,5 - attach MTD device /dev/mtd1 to UBI 5 and using default values for the other fields.\n" -"example 5: mtd=1,0,0,5 mtd=2,0,0,6,1 - attach MTD device /dev/mtd1 to UBI 5 and disable fastmap; attach MTD device /dev/mtd2 to UBI 6 and enable fastmap.(only works when fastmap is enabled and fm_autoconvert=Y).\n" - "\t(e.g. if the NAND *chipset* has 4096 PEB, 100 will be reserved for this UBI device)."); + "example 5: mtd=1,0,0,5 mtd=2,0,0,6,1 - attach MTD device /dev/mtd1 to UBI 5 and disable fastmap; attach MTD device /dev/mtd2 to UBI 6 and enable fastmap.(only works when fastmap is enabled and fm_autoconvert=Y).\n");#ifdef CONFIG_MTD_UBI_FASTMAP module_param (fm_autoconvert, bool,0644 );MODULE_PARM_DESC (fm_autoconvert,"Set this parameter to enable fastmap automatically on images without a fastmap." );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1384/1815 firewire: core: add KUnit test skeleton for node tree
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Sakamoto <[email protected]>
[ Upstream commit 1f9b65cf57081035547b4d3ca1805df20892e9db ]
Some issues have been reported in node tree management. Refactoring the topology-related code in the core is required. Adding unit tests would help ensure that the refactoring does not introduce regressions.
This commit adds a KUnit test skeleton for this purpose.
Stable-dep-of: 05bfb1327dc5 ("firewire: core: fix memory leak in error path of build_tree()")
--- drivers/firewire/.kunitconfig | 1 + drivers/firewire/Kconfig | 15 +++++++++++++++ drivers/firewire/core-topology.c | 4 ++++ drivers/firewire/node-tree-test.c | 19 +++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 drivers/firewire/node-tree-test.c
drivers/firewire/.kunitconfig +1 -0
@@ -6,3 +6,4 @@ CONFIG_FIREWIRE_KUNIT_DEVICE_ATTRIBUTE_TEST=y CONFIG_FIREWIRE_KUNIT_PACKET_SERDES_TEST=y CONFIG_FIREWIRE_KUNIT_SELF_ID_SEQUENCE_HELPER_TEST=y CONFIG_FIREWIRE_KUNIT_OHCI_SERDES_TEST=y +CONFIG_FIREWIRE_KUNIT_NODE_TREE_TEST=y
drivers/firewire/Kconfig +15 -0
@@ -81,6 +81,21 @@ config FIREWIRE_KUNIT_SELF_ID_SEQUENCE_HELPER_TEST For more information on KUnit and unit tests in general, refer to the KUnit documentation in Documentation/dev-tools/kunit/. +config FIREWIRE_KUNIT_NODE_TREE_TEST + tristate "KUnit tests for node tree" if !KUNIT_ALL_TESTS + depends on FIREWIRE && KUNIT + default KUNIT_ALL_TESTS + help + This builds the KUnit tests for node tree. + + KUnit tests run during boot and output the results to the debug + log in TAP format (https://testanything.org/). Only useful for + kernel devs running KUnit test harness and are not for inclusion + into a production build. + + For more information on KUnit and unit tests in general, refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + config FIREWIRE_OHCI tristate "OHCI-1394 controllers" depends on PCI && FIREWIRE
drivers/firewire/core-topology.c +4 -0
@@ -507,3 +507,7 @@ void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation, } }EXPORT_SYMBOL (fw_core_handle_bus_reset); + +#ifdef CONFIG_FIREWIRE_KUNIT_NODE_TREE_TEST +#include "node-tree-test.c" +#endif
drivers/firewire/node-tree-test.c new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// node-tree-test.c - An application of Kunit to test node tree. +// +// Copyright (c) 2026 Takashi Sakamoto +// +// This file can not be built independently since it is intentionally included in core-topology.c. + +#include <kunit/test.h> + +static struct kunit_case node_tree_test_cases[] = { + {} +}; + +static struct kunit_suite node_tree_test_suite = { + .name ="firewire-node-tree" , + .test_cases = node_tree_test_cases, +}; +kunit_test_suite (node_tree_test_suite);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1385/1815 firewire: core: add KUnit tests for successful tree building
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Sakamoto <[email protected]>
[ Upstream commit 7b763ea17152cf61ede5289c3c66bf133c8aafa7 ]
After a bus reset, self ID sequence is captured by 1394 OHCI hardware and passed to software through SelfID DMA context. The core parses the sequence to build an internal cache of the node tree for the current generation of the bus. This is the first step in managing resources on the bus.
The tree is build by the build_tree() function. This commit adds KUnit tests for the function, covering several successful scenarios.
Stable-dep-of: 05bfb1327dc5 ("firewire: core: fix memory leak in error path of build_tree()")
--- drivers/firewire/node-tree-test.c | 508 ++++++++++++++++++++++++++++++ 1 file changed, 508 insertions(+)
drivers/firewire/node-tree-test.c +508 -0
@@ -7,13 +7,521 @@// This file can not be built independently since it is intentionally included in core-topology.c. #include <kunit/test.h> +#include <kunit/test-bug.h> +#include <kunit/device.h> + +struct private_data { +struct fw_card *card; +unsigned int release_count; +}; + +static int node_tree_test_init (struct kunit *test) +{ +struct private_data *data; + + data =kunit_kzalloc (test,sizeof (*data),GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, data); + + data->card =kunit_kzalloc (test,sizeof (struct fw_card ),GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, data->card); + + data->card->device =kunit_device_register (test,"dummy-device" ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, data->card->device); + + test->priv = data; + +return 0 ; +} + +static void node_tree_test_exit (struct kunit *test) +{ +struct private_data *data = test->priv; + +kunit_device_unregister (test, data->card->device); +kunit_kfree (test, data->card); +kunit_kfree (test, data); +} + +static void release_fw_node (struct fw_card *card,struct fw_node *node,struct fw_node *parent) +{ +struct private_data *data =kunit_get_current_test ()->priv; + +fw_node_put (node); + ++data->release_count; +} + +static void node_tree_test_two_nodes (struct kunit *test) +{ +// root +// ++============++ +// || phy 1 || +// || P0 P1 P2 || +// ++===|==|==|==++ +// | +// +-----+ +// | +// ++===|==x==x==++ +// || P0 P1 P2 || +// || phy 0 || +// ++============++ +// +static const u32 self_id_sequence[] = { +0x80000080 , +0x8100005e , + }; +struct private_data *data = test->priv; +struct fw_card *card = data->card; + + card->node_id =LOCAL_BUS |0x01 ; + + card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 ); +KUNIT_EXPECT_NOT_NULL (test, card->local_node); +KUNIT_EXPECT_PTR_EQ (test, card->local_node, card->root_node); + +struct fw_node *node = card->root_node; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x01 ); +KUNIT_EXPECT_EQ (test, node->port_count,3 ); +KUNIT_EXPECT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_NULL (test, node->ports[1 ]); +KUNIT_EXPECT_NOT_NULL (test, node->ports[2 ]); + +struct fw_node *parent = node; + node = parent->ports[2 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x00 ); +KUNIT_EXPECT_EQ (test, node->port_count,1 ); +KUNIT_EXPECT_PTR_EQ (test, node->ports[0 ], parent); + + ++card->color; +for_each_fw_node (card, card->root_node, release_fw_node); +KUNIT_EXPECT_EQ (test, data->release_count,2 ); +} + +static void node_tree_test_two_nodes_1394a (struct kunit *test) +{ +// root +// ++===============++ +// || phy 0 || +// || P0 P1 P2 P3 || +// ++===|==|==|==|==++ +// | +// +--+ +// | +// ++===|==|==|==|==|==++ +// || P0 P1 P2 P3 P4 || +// || phy 1 || +// ++==================++ +// +// NOTE: Just for Self-ID Packets Zero and One. +static const u32 self_id_sequence[] = { +0x80000065 ,0x80814000 , +0x8100005d ,0x81810000 , + }; +struct private_data *data = test->priv; +struct fw_card *card = data->card; + + card->node_id =LOCAL_BUS |0x01 ; + + card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 ); +KUNIT_EXPECT_NOT_NULL (test, card->local_node); +KUNIT_EXPECT_PTR_EQ (test, card->local_node, card->root_node); + +struct fw_node *node = card->root_node; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x01 ); +KUNIT_EXPECT_EQ (test, node->port_count,4 ); +KUNIT_EXPECT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_NULL (test, node->ports[1 ]); +KUNIT_EXPECT_NOT_NULL (test, node->ports[2 ]); +KUNIT_EXPECT_NULL (test, node->ports[3 ]); + +struct fw_node *parent = node; + node = parent->ports[2 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x00 ); +KUNIT_EXPECT_EQ (test, node->port_count,5 ); +KUNIT_EXPECT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_PTR_EQ (test, node->ports[1 ], parent); +KUNIT_EXPECT_NULL (test, node->ports[2 ]); +KUNIT_EXPECT_NULL (test, node->ports[3 ]); +KUNIT_EXPECT_NULL (test, node->ports[4 ]); + + ++card->color; +for_each_fw_node (card, card->root_node, release_fw_node); +KUNIT_EXPECT_EQ (test, data->release_count,2 ); +} + +static void node_tree_test_three_nodes_case0 (struct kunit *test) +{ +// root +// ++============++ +// || phy 2 || +// || P0 P1 P2 || +// ++===|==|==|==++ +// | | +// +--+ +-----------------+ +// | | +// ++===|==|==x==++ ++===|==|==|==++ +// || P0 P1 P2 || || P0 P1 P2 || +// || phy 0 || || phy 1 || +// ++============++ ++============++ +// +static const u32 self_id_sequence[] = { +0x80000060 , +0x81000058 , +0x820000dc , + }; +struct private_data *data = test->priv; +struct fw_card *card = data->card; + + card->node_id =LOCAL_BUS |0x02 ; + + card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 ); +KUNIT_EXPECT_NOT_NULL (test, card->local_node); +KUNIT_EXPECT_PTR_EQ (test, card->local_node, card->root_node); + +struct fw_node *node = card->root_node; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x02 ); +KUNIT_EXPECT_EQ (test, node->port_count,3 ); +KUNIT_EXPECT_NOT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_NULL (test, node->ports[1 ]); +KUNIT_EXPECT_NOT_NULL (test, node->ports[2 ]); + +struct fw_node *parent = node; + node = parent->ports[0 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x00 ); +KUNIT_EXPECT_EQ (test, node->port_count,2 ); +KUNIT_EXPECT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_PTR_EQ (test, node->ports[1 ], parent); + + node = parent->ports[2 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x01 ); +KUNIT_EXPECT_EQ (test, node->port_count,3 ); +KUNIT_EXPECT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_NULL (test, node->ports[1 ]); +KUNIT_EXPECT_PTR_EQ (test, node->ports[2 ], parent); + + ++card->color; +for_each_fw_node (card, card->root_node, release_fw_node); +KUNIT_EXPECT_EQ (test, data->release_count,3 ); +} + +static void node_tree_test_three_nodes_case1 (struct kunit *test) +{ +// root +// ++============++ +// || phy 2 || +// || P0 P1 P2 || +// ++===|==|==x==++ +// | +// | +-----------+ +// | | | +// ++===|==|==|==++ ++===|==x==x==++ +// || P0 P1 P2 || || P0 P1 P2 || +// || phy 1 || || phy 0 || +// ++============++ ++============++ +// +static const u32 self_id_sequence[] = { +0x80000080 , +0x8100006c , +0x82000070 , + }; +struct private_data *data = test->priv; +struct fw_card *card = data->card; + + card->node_id =LOCAL_BUS |0x02 ; + + card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 ); +KUNIT_EXPECT_NOT_NULL (test, card->local_node); +KUNIT_EXPECT_PTR_EQ (test, card->local_node, card->root_node); + +struct fw_node *node = card->root_node; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x02 ); +KUNIT_EXPECT_EQ (test, node->port_count,2 ); +KUNIT_EXPECT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_NOT_NULL (test, node->ports[1 ]); + +struct fw_node *parent = node; + node = parent->ports[1 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x01 ); +KUNIT_EXPECT_EQ (test, node->port_count,3 ); +KUNIT_EXPECT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_PTR_EQ (test, node->ports[1 ], parent); +KUNIT_EXPECT_NOT_NULL (test, node->ports[2 ]); + + parent = node; + node = parent->ports[2 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x00 ); +KUNIT_EXPECT_EQ (test, node->port_count,1 ); +KUNIT_EXPECT_PTR_EQ (test, node->ports[0 ], parent); + + ++card->color; +for_each_fw_node (card, card->root_node, release_fw_node); +KUNIT_EXPECT_EQ (test, data->release_count,3 ); +} + +static void node_tree_test_four_nodes_case0 (struct kunit *test) +{ +// root +// ++============++ +// || phy 3 || +// || P0 P1 P2 || +// ++===|==|==|==++ +// | +// | +-----------+ +--------------+ +// | | | | | +// ++===|==|==|==++ ++===|==|==x==++ ++===|==x==x==++ +// || P0 P1 P2 || || P0 P1 P2 || || P0 P1 P2 || +// || phy 2 || || phy 1 || || phy 0 || +// ++============++ ++============++ ++============++ +// +static const u32 self_id_sequence[] = { +0x80000080 , +0x810000b0 , +0x8200006c , +0x83000074 , + }; +struct private_data *data = test->priv; +struct fw_card *card = data->card; + + card->node_id =LOCAL_BUS |0x03 ; + + card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 ); +KUNIT_EXPECT_NOT_NULL (test, card->local_node); +KUNIT_EXPECT_PTR_EQ (test, card->local_node, card->root_node); + +struct fw_node *node = card->root_node; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x03 ); +KUNIT_EXPECT_EQ (test, node->port_count,3 ); +KUNIT_EXPECT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_NOT_NULL (test, node->ports[1 ]); +KUNIT_EXPECT_NULL (test, node->ports[2 ]); + +struct fw_node *parent = node; + node = parent->ports[1 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x02 ); +KUNIT_EXPECT_EQ (test, node->port_count,3 ); +KUNIT_EXPECT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_PTR_EQ (test, node->ports[1 ], parent); +KUNIT_EXPECT_NOT_NULL (test, node->ports[2 ]); + + parent = node; + node = parent->ports[2 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x01 ); +KUNIT_EXPECT_EQ (test, node->port_count,2 ); +KUNIT_EXPECT_PTR_EQ (test, node->ports[0 ], parent); +KUNIT_EXPECT_NOT_NULL (test, node->ports[1 ]); + + parent = node; + node = parent->ports[1 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x00 ); +KUNIT_EXPECT_EQ (test, node->port_count,1 ); +KUNIT_EXPECT_PTR_EQ (test, node->ports[0 ], parent); + + ++card->color; +for_each_fw_node (card, card->root_node, release_fw_node); +KUNIT_EXPECT_EQ (test, data->release_count,4 ); +} + +static void node_tree_test_four_nodes_case1 (struct kunit *test) +{ +// root +// ++============++ +// || phy 3 || +// || P0 P1 P2 || +// ++===|==|==x==++ +// | +// | +--------------------------------+ +// | | +-----------+ | +// ++===|==|==|==++ ++===|==x==x==++ ++===|==|==|==++ +// || P0 P1 P2 || || P0 P1 P2 || || P0 P1 P2 || +// || phy 2 || || phy 1 || || phy 0 || +// ++============++ ++============++ ++============++ +// +static const u32 self_id_sequence[] = { +0x80000094 , +0x81000080 , +0x820000bc , +0x830000d0 , + }; +struct private_data *data = test->priv; +struct fw_card *card = data->card; + + card->node_id =LOCAL_BUS |0x03 ; + + card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 ); +KUNIT_EXPECT_NOT_NULL (test, card->local_node); +KUNIT_EXPECT_PTR_EQ (test, card->local_node, card->root_node); + +struct fw_node *node = card->root_node; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x03 ); +KUNIT_EXPECT_EQ (test, node->port_count,2 ); +KUNIT_EXPECT_NOT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_NULL (test, node->ports[1 ]); + +struct fw_node *parent = node; + node = parent->ports[0 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x02 ); +KUNIT_EXPECT_EQ (test, node->port_count,3 ); +KUNIT_EXPECT_PTR_EQ (test, node->ports[0 ], parent); +KUNIT_EXPECT_NOT_NULL (test, node->ports[1 ]); +KUNIT_EXPECT_NOT_NULL (test, node->ports[2 ]); + + parent = node; + node = parent->ports[2 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x01 ); +KUNIT_EXPECT_EQ (test, node->port_count,1 ); +KUNIT_EXPECT_PTR_EQ (test, node->ports[0 ], parent); + + node = parent->ports[1 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x00 ); +KUNIT_EXPECT_EQ (test, node->port_count,3 ); +KUNIT_EXPECT_PTR_EQ (test, node->ports[0 ], parent); +KUNIT_EXPECT_NULL (test, node->ports[1 ]); +KUNIT_EXPECT_NULL (test, node->ports[2 ]); + + ++card->color; +for_each_fw_node (card, card->root_node, release_fw_node); +KUNIT_EXPECT_EQ (test, data->release_count,4 ); +} + +static void node_tree_test_four_nodes_case2 (struct kunit *test) +{ +// root +// ++============++ +// || phy 3 || +// || P0 P1 P2 || +// ++===|==|==|==++ +// | | +// | +-----------------------------+ +// | +--------------+ | +// ++===|==|==x==++ ++===|==|==|==++ ++===|==x==x==++ +// || P0 P1 P2 || || P0 P1 P2 || || P0 P1 P2 || +// || phy 1 || || phy 0 || || phy 2 || +// ++============++ ++============++ ++============++ +// +static const u32 self_id_sequence[] = { +0x80000094 , +0x810000b0 , +0x82000080 , +0x830000dc , + }; +struct private_data *data = test->priv; +struct fw_card *card = data->card; + + card->node_id =LOCAL_BUS |0x03 ; + + card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 ); +KUNIT_EXPECT_NOT_NULL (test, card->local_node); +KUNIT_EXPECT_PTR_EQ (test, card->local_node, card->root_node); + +struct fw_node *node = card->root_node; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x03 ); +KUNIT_EXPECT_EQ (test, node->port_count,3 ); +KUNIT_EXPECT_NOT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_NULL (test, node->ports[1 ]); +KUNIT_EXPECT_NOT_NULL (test, node->ports[2 ]); + +struct fw_node *parent = node; + node = parent->ports[2 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x02 ); +KUNIT_EXPECT_EQ (test, node->port_count,1 ); +KUNIT_EXPECT_PTR_EQ (test, node->ports[0 ], parent); + + node = parent->ports[0 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x01 ); +KUNIT_EXPECT_EQ (test, node->port_count,2 ); +KUNIT_EXPECT_PTR_EQ (test, node->ports[0 ], parent); +KUNIT_EXPECT_NOT_NULL (test, node->ports[1 ]); + + parent = node; + node = parent->ports[1 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x00 ); +KUNIT_EXPECT_EQ (test, node->port_count,3 ); +KUNIT_EXPECT_PTR_EQ (test, node->ports[0 ], parent); +KUNIT_EXPECT_NULL (test, node->ports[1 ]); +KUNIT_EXPECT_NULL (test, node->ports[2 ]); + + ++card->color; +for_each_fw_node (card, card->root_node, release_fw_node); +KUNIT_EXPECT_EQ (test, data->release_count,4 ); +} + +static void node_tree_test_four_nodes_case3 (struct kunit *test) +{ +// root +// ++============++ +// || phy 3 || +// || P0 P1 P2 || +// ++===|==|==|==++ +// | | +--------------------------------+ +// | +--------------------+ | +// | | | +// ++===|==|==x==++ ++===|==|==|==++ ++===|==|==x==++ +// || P0 P1 P2 || || P0 P1 P2 || || P0 P1 P2 || +// || phy 0 || || phy 1 || || phy 2 || +// ++============++ ++============++ ++============++ +// +static const u32 self_id_sequence[] = { +0x80000090 , +0x81000058 , +0x82000060 , +0x830000fc , + }; +struct private_data *data = test->priv; +struct fw_card *card = data->card; + + card->node_id =LOCAL_BUS |0x03 ; + + card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 ); +KUNIT_EXPECT_NOT_NULL (test, card->local_node); +KUNIT_EXPECT_PTR_EQ (test, card->local_node, card->root_node); + +struct fw_node *node = card->root_node; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x03 ); +KUNIT_EXPECT_EQ (test, node->port_count,3 ); +KUNIT_EXPECT_NOT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_NOT_NULL (test, node->ports[1 ]); +KUNIT_EXPECT_NOT_NULL (test, node->ports[2 ]); + +struct fw_node *parent = node; + node = parent->ports[2 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x02 ); +KUNIT_EXPECT_EQ (test, node->port_count,2 ); +KUNIT_EXPECT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_PTR_EQ (test, node->ports[1 ], parent); + + node = parent->ports[1 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x01 ); +KUNIT_EXPECT_EQ (test, node->port_count,3 ); +KUNIT_EXPECT_NULL (test, node->ports[0 ]); +KUNIT_EXPECT_NULL (test, node->ports[1 ]); +KUNIT_EXPECT_PTR_EQ (test, node->ports[2 ], parent); + + node = parent->ports[0 ]; +KUNIT_EXPECT_EQ (test, node->node_id,LOCAL_BUS |0x00 ); +KUNIT_EXPECT_EQ (test, node->port_count,2 ); +KUNIT_EXPECT_PTR_EQ (test, node->ports[0 ], parent); +KUNIT_EXPECT_NULL (test, node->ports[1 ]); + + ++card->color; +for_each_fw_node (card, card->root_node, release_fw_node); +KUNIT_EXPECT_EQ (test, data->release_count,4 ); +}static struct kunit_case node_tree_test_cases[] = { +KUNIT_CASE (node_tree_test_two_nodes), +KUNIT_CASE (node_tree_test_two_nodes_1394a), +KUNIT_CASE (node_tree_test_three_nodes_case0), +KUNIT_CASE (node_tree_test_three_nodes_case1), +KUNIT_CASE (node_tree_test_four_nodes_case0), +KUNIT_CASE (node_tree_test_four_nodes_case1), +KUNIT_CASE (node_tree_test_four_nodes_case2), +KUNIT_CASE (node_tree_test_four_nodes_case3), {} };static struct kunit_suite node_tree_test_suite = { .name ="firewire-node-tree" , + .init = node_tree_test_init, + .exit = node_tree_test_exit, .test_cases = node_tree_test_cases, };kunit_test_suite (node_tree_test_suite);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1386/1815 firewire: core: add KUnit tests for failure of tree building
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Sakamoto <[email protected]>
[ Upstream commit f744022705b7eb479a1931ddd95aae4e9a4be221 ]
Abdun Nihaal has reported a memory leak when tree building fails in the middle of self ID sequence enumeration. This is caused by an invalid self ID sequence and is not a common occurrence.
This commit is intended to assist in fixing the issue by adding KUnit tests to show the cases in which the memory leak is triggered. The leak occurs internally in the build_tree() function, therefore it cannot be detected directly by the tests.
Stable-dep-of: 05bfb1327dc5 ("firewire: core: fix memory leak in error path of build_tree()")
--- drivers/firewire/node-tree-test.c | 84 +++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)
drivers/firewire/node-tree-test.c +84 -0
@@ -506,6 +506,86 @@ static void node_tree_test_four_nodes_case3(struct kunit *test)KUNIT_EXPECT_EQ (test, data->release_count,4 ); } +static void node_tree_test_invalid_extended_self_id_sequence (struct kunit *test) +{ +// Use the same node tree as node_tree_test_four_nodes_case1, except for the invalid +// content of self ID packet for the phy 3. +static const u32 self_id_sequence[] = { +0x80000094 , +0x81000080 , +0x820000bc , +0x830000d1 ,// Invalid. + }; +struct private_data *data = test->priv; +struct fw_card *card = data->card; + + card->node_id =LOCAL_BUS |0x03 ; + +// TODO: Memory leak. + card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 ); +KUNIT_EXPECT_NULL (test, card->local_node); +} + +static void node_tree_test_invalid_phy_id (struct kunit *test) +{ +// Use the same node tree as node_tree_test_four_nodes_case1, except for the invalid +// phy ID for phy 3. +static const u32 self_id_sequence[] = { +0x80000094 , +0x81000080 , +0x820000bc , +0x8f0000d0 ,// Invalid. + }; +struct private_data *data = test->priv; +struct fw_card *card = data->card; + + card->node_id =LOCAL_BUS |0x03 ; + +// TODO: Memory leak. + card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 ); +KUNIT_EXPECT_NULL (test, card->local_node); +} + +static void node_tree_test_invalid_child_port_count (struct kunit *test) +{ +// Use the same node tree as node_tree_test_four_nodes_case1, except for the invalid +// count of child ports for phy 3. +static const u32 self_id_sequence[] = { +0x80000094 , +0x81000080 , +0x820000bc , +0x830000fc ,// Invalid. + }; +struct private_data *data = test->priv; +struct fw_card *card = data->card; + + card->node_id =LOCAL_BUS |0x03 ; + +// TODO: Memory leak. + card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 ); +KUNIT_EXPECT_NULL (test, card->local_node); +} + +static void node_tree_test_invalid_parent_port_count (struct kunit *test) +{ +// Use the same node tree as node_tree_test_four_nodes_case1, except for the invalid +// count of parent ports for phy 3. +static const u32 self_id_sequence[] = { +0x80000094 , +0x81000080 , +0x820000bc , +0x830000e8 ,// Invalid. + }; +struct private_data *data = test->priv; +struct fw_card *card = data->card; + + card->node_id =LOCAL_BUS |0x03 ; + +// TODO: Memory leak. + card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 ); +KUNIT_EXPECT_NULL (test, card->local_node); +} +static struct kunit_case node_tree_test_cases[] = {KUNIT_CASE (node_tree_test_two_nodes),KUNIT_CASE (node_tree_test_two_nodes_1394a),
@@ -515,6 +595,10 @@ static struct kunit_case node_tree_test_cases[] = {KUNIT_CASE (node_tree_test_four_nodes_case1),KUNIT_CASE (node_tree_test_four_nodes_case2),KUNIT_CASE (node_tree_test_four_nodes_case3), +KUNIT_CASE (node_tree_test_invalid_extended_self_id_sequence), +KUNIT_CASE (node_tree_test_invalid_phy_id), +KUNIT_CASE (node_tree_test_invalid_child_port_count), + KUNIT_CASE(node_tree_test_invalid_parent_port_count), {} };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1387/1815 firewire: core: consolidate port counting in build_tree()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Sakamoto <[email protected]>
[ Upstream commit 87c48e54f28d410af0c12b5dd339307bb43abeea ]
The self ID sequence describes the state of each port for each PHY. Currently, build_tree() counts the ports in two separate places.
Consolidate the port counting in one place.
Stable-dep-of: 05bfb1327dc5 ("firewire: core: fix memory leak in error path of build_tree()")
--- drivers/firewire/core-topology.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/firewire/core-topology.c +10 -8
@@ -119,8 +119,8 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int selfwhile (enumerator.quadlet_count >0 ) {unsigned int child_port_count =0 ; +unsigned int parent_port_count =0 ;unsigned int total_port_count =0 ; -unsigned int parent_count =0 ;unsigned int quadlet_count;const u32 *self_id_sequence;unsigned int port_capacity;
@@ -148,16 +148,19 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int selfswitch (port_status) {case PHY_PACKET_SELF_ID_PORT_STATUS_CHILD : ++child_port_count; - fallthrough; +break ;case PHY_PACKET_SELF_ID_PORT_STATUS_PARENT : + ++parent_port_count; +break ;case PHY_PACKET_SELF_ID_PORT_STATUS_NCONN : ++total_port_count; - fallthrough; +break ;case PHY_PACKET_SELF_ID_PORT_STATUS_NONE :default :break ; } } + total_port_count += child_port_count + parent_port_count;if (phy_id !=phy_packet_self_id_get_phy_id (self_id_sequence[0 ])) { fw_err(card, "PHY ID mismatch in self ID: %d != %d\n",
@@ -203,7 +206,6 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self// we temporarily abuse node->color for remembering the entry in // the node->ports array where the parent node should be. Later, // when we handle the parent node, we fix up the reference. - ++parent_count; node->color = port_index;break ;
@@ -223,10 +225,10 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self// Check that the node reports exactly one parent port, except for the root, which // of course should have no parents. -if ((enumerator.quadlet_count ==0 && parent_count !=0 ) || - (enumerator.quadlet_count >0 && parent_count !=1 )) { +if ((enumerator.quadlet_count ==0 && parent_port_count !=0 ) || + (enumerator.quadlet_count >0 && parent_port_count !=1 )) {fw_err (card,"parent port inconsistency for node %d: " -"parent_count=%d\n" , phy_id, parent_count); +"parent_count=%d\n" , phy_id, parent_port_count);return NULL ; }
@@ -235,7 +237,7 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int selflist_add_tail (&node->link, &stack); stack_depth +=1 - child_port_count; -if (node->phy_speed ==SCODE_BETA && parent_count + child_port_count >1 ) +if (node->phy_speed ==SCODE_BETA && parent_port_count + child_port_count >1 ) beta_repeaters_present = true;// If PHYs report different gap counts, set an invalid count which will force a gap
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1388/1815 firewire: core: validate parent port count before allocating nodes in build_tree()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Sakamoto <[email protected]>
[ Upstream commit a563a7cb645a79a3a7e31bed8cbf95980ef5feb1 ]
The node tree requires each child node to have exactly one port connected to a parent node, while the root node must have no such port. This can be validated by comparing the parent port count for a PHY with the rest of the self ID sequence.
Currently, this validation is done after the node has been allocated. Move it before the allocation so that an invalid self ID sequence can cause an error without having to clean up the newly allocated node.
Stable-dep-of: 05bfb1327dc5 ("firewire: core: fix memory leak in error path of build_tree()")
--- drivers/firewire/core-topology.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/firewire/core-topology.c +9 -9
@@ -162,6 +162,15 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self } total_port_count += child_port_count + parent_port_count; +// Check that the node reports exactly one parent port, except for the root, which +// of course should have no parents. +if ((enumerator.quadlet_count ==0 && parent_port_count !=0 ) || + (enumerator.quadlet_count >0 && parent_port_count !=1 )) { +fw_err (card,"parent port inconsistency for node %d: parent_count=%d\n" , + phy_id, parent_port_count); +return NULL ; + } +if (phy_id !=phy_packet_self_id_get_phy_id (self_id_sequence[0 ])) {fw_err (card,"PHY ID mismatch in self ID: %d != %d\n" , phy_id,phy_packet_self_id_get_phy_id (self_id_sequence[0 ]));
@@ -223,15 +232,6 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self } } -// Check that the node reports exactly one parent port, except for the root, which -// of course should have no parents. -if ((enumerator.quadlet_count ==0 && parent_port_count !=0 ) || - (enumerator.quadlet_count >0 && parent_port_count !=1 )) { -fw_err (card,"parent port inconsistency for node %d: " -"parent_count=%d\n" , phy_id, parent_port_count); -return NULL ; - } -/* Pop the child nodes off the stack and push the new node. */ __list_del (h->prev, &stack);list_add_tail (&node->link, &stack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1389/1815 firewire: core: fix memory leak in error path of build_tree()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Sakamoto <[email protected]>
[ Upstream commit 05bfb1327dc5fb61528bab31cd8f0c1e4bddec23 ]
In the error path of build_tree(), node instances can remain in the local linked list when the function returns.
Whenever an invalid value is detected in the self ID sequence, each allocated node instance is either an entry in the linked list or an entry in the ports array of its parent node. Therefore, the allocate node instances can be safely released by traversing the linked list from its head.
Release the remaining node instances with for_each_fw_node() before returning to the caller.
--- drivers/firewire/core-topology.c | 30 +++++++++++++++++++++--------- drivers/firewire/node-tree-test.c | 4 ---- 2 files changed, 21 insertions(+), 13 deletions(-)
drivers/firewire/core-topology.c +21 -9
@@ -88,6 +88,17 @@ static inline struct fw_node *fw_node(struct list_head *l) return list_entry(l, struct fw_node, link); } +typedef void (*fw_node_callback_t )(struct fw_card *card,struct fw_node *node, +struct fw_node *parent); + +static void for_each_fw_node (struct fw_card *card,struct fw_node *root, +fw_node_callback_t callback); + +static void free_fw_node (struct fw_card *card,struct fw_node *node,struct fw_node *parent) +{ +kfree (node); +} +/* * This function builds the tree representation of the topology given * by the self IDs from the latest bus reset. During the construction
@@ -134,7 +145,7 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int selfif (PTR_ERR (self_id_sequence) != -ENODATA ) {fw_err (card,"inconsistent extended self IDs: %ld\n" ,PTR_ERR (self_id_sequence)); -return NULL ; + goto error; }break ; }
@@ -168,18 +179,18 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self (enumerator.quadlet_count > 0 && parent_port_count != 1)) {fw_err (card,"parent port inconsistency for node %d: parent_count=%d\n" , phy_id, parent_port_count); -return NULL ; + goto error; }if (phy_id !=phy_packet_self_id_get_phy_id (self_id_sequence[0 ])) {fw_err (card,"PHY ID mismatch in self ID: %d != %d\n" , phy_id,phy_packet_self_id_get_phy_id (self_id_sequence[0 ])); -return NULL ; + goto error; }if (child_port_count > stack_depth) {fw_err (card,"topology stack underflow\n" ); -return NULL ; + goto error; }/*
@@ -197,7 +208,7 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self node =fw_node_create (self_id_sequence[0 ], total_port_count, card->color);if (node ==NULL ) {fw_err (card,"out of memory while building topology\n" ); -return NULL ; + goto error; }if (phy_id == (card->node_id &0x3f ))
@@ -256,12 +267,13 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self card->beta_repeaters_present = beta_repeaters_present;return local_node; +error: + ++card->color; +list_for_each_entry_safe (node, child, &stack, link) +for_each_fw_node (card, node, free_fw_node); +return NULL ; } -typedef void (*fw_node_callback_t )(struct fw_card * card, -struct fw_node * node, -struct fw_node * parent); -static void for_each_fw_node (struct fw_card *card,struct fw_node *root,fw_node_callback_t callback) {
drivers/firewire/node-tree-test.c +0 -4
@@ -521,7 +521,6 @@ static void node_tree_test_invalid_extended_self_id_sequence(struct kunit *test) card->node_id =LOCAL_BUS |0x03 ; -// TODO: Memory leak. card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 );KUNIT_EXPECT_NULL (test, card->local_node); }
@@ -541,7 +540,6 @@ static void node_tree_test_invalid_phy_id(struct kunit *test) card->node_id =LOCAL_BUS |0x03 ; -// TODO: Memory leak. card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 );KUNIT_EXPECT_NULL (test, card->local_node); }
@@ -561,7 +559,6 @@ static void node_tree_test_invalid_child_port_count(struct kunit *test) card->node_id =LOCAL_BUS |0x03 ; -// TODO: Memory leak. card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 );KUNIT_EXPECT_NULL (test, card->local_node); }
@@ -581,7 +578,6 @@ static void node_tree_test_invalid_parent_port_count(struct kunit *test) card->node_id =LOCAL_BUS |0x03 ; -// TODO: Memory leak. card->local_node =build_tree (card, self_id_sequence,ARRAY_SIZE (self_id_sequence),123 );KUNIT_EXPECT_NULL (test, card->local_node); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1390/1815 objtool/klp: Fix cross-module klp relocation section naming
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit 07f14d6af9d7791fdc2b44a3dd0693e42c71d2b8 ]
A klp relocation section is .klp.rela.<objname>.<secname>, where objname is the object being patched.
klp-build wrongly derives objname from where the referenced symbol lives, not where it's referenced. For a cross-module reference like patched can_isotp code calling can.ko's can_rx_unregister(), that gives .klp.rela.can..text rather than .klp.rela.can_isotp..text. Unless the patch happens to patch can.ko as well, the relocation never gets applied and the call goes off into the weeds.
Name the intermediate section __klp_relocs.<objname> so post-link can read the patched object's name from there.
--- tools/objtool/include/objtool/klp.h | 10 ++++-- tools/objtool/klp-diff.c | 17 +++++++-- tools/objtool/klp-post-link.c | 53 +++++++++++++++++------------ 3 files changed, 52 insertions(+), 28 deletions(-)
tools/objtool/include/objtool/klp.h +7 -3
@@ -14,11 +14,15 @@#define KLP_FUNCS_SEC ".init.klp_funcs"/* -* __klp_relocs is an intermediate section which are created by klp diff and -* converted into KLP symbols/relas by "objtool klp post-link". This is needed -* to work around the linker, which doesn't preserve SHN_LIVEPATCH or +* __klp_relocs.<objname> are intermediate sections which are created by klp +* diff and converted into KLP symbols/relas by "objtool klp post-link". This +* is needed to work around the linker, which doesn't preserve SHN_LIVEPATCH or * SHF_RELA_LIVEPATCH, nor does it support having two RELA sections for a * single PROGBITS section. +* +* "objname" is the name of the object being patched ("vmlinux" or a module +* name). post-link uses it to name the resulting +* .klp.rela.objname.section_name sections. */ #define KLP_RELOCS_SEC "__klp_relocs"#define KLP_STRINGS_SEC ".rodata.klp.str1.1"
tools/objtool/klp-diff.c +14 -3
@@ -1381,8 +1381,8 @@ static int clone_reloc_klp(struct elfs *e, struct reloc *patched_reloc, }/* -* Create the __klp_relocs entry. This will be converted to an actual -* KLP rela by "objtool klp post-link". +* Create the __klp_relocs.<objname> entry. This will be converted to +* an actual KLP rela by "objtool klp post-link". * * This intermediate step is necessary to prevent corruption by the * linker, which doesn't know how to properly handle two rela sections
@@ -1390,7 +1390,18 @@ static int clone_reloc_klp(struct elfs *e, struct reloc *patched_reloc,*/ if (!klp_relocs) { - klp_relocs =elf_create_section (e->out,KLP_RELOCS_SEC ,0 , +const char *objname =find_modname (e); +char sec_name[SEC_NAME_LEN ]; + +if (!objname) +return -1 ; + +/* section format: __klp_relocs.objname */ +if (snprintf_check (sec_name,SEC_NAME_LEN , +KLP_RELOCS_SEC ".%s" , objname)) +return -1 ; + + klp_relocs =elf_create_section (e->out, sec_name,0 ,0 ,SHT_PROGBITS ,8 ,SHF_ALLOC );if (!klp_relocs)return -1 ;
tools/objtool/klp-post-link.c +31 -22
98 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1391/1815 objtool/klp: Dont match local symbols against exports
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit 86a697572c6271083694025eefa8de518eeef623 ]
While cloning a reloc, klp diff calls find_export() to determine whether the referenced symbol is exported. That decides whether the reference needs a klp reloc, which object the klp symbol belongs to, and whether the symbol's data needs to be copied into the patch module.
But find_export() matches purely on symbol name, so a static function or variable which happens to share its name with an export is mistaken for a reference to that export:
- klp_reloc_needed() creates a klp reloc pointing at the exporting module's symbol rather than the local one. For a vmlinux export it skips the klp reloc altogether, leaving a normal reloc which the module loader resolves to the vmlinux symbol.
- clone_reloc() treats the symbol as external and clones it without its data, leaving a dangling reference.
- validate_special_section_klp_reloc() attributes a static branch or call key to the wrong module, and for a vmlinux export skips the unsupported-key check entirely.
Exports are always global, so ignore local symbols in find_export().
--- tools/objtool/klp-diff.c | 3 +++ 1 file changed, 3 insertions(+)
tools/objtool/klp-diff.c +3 -0
@@ -1102,6 +1102,9 @@ static struct export *find_export(struct symbol *sym) {struct export *export; +if (is_local_sym (sym)) +return NULL ; +hash_for_each_possible (exports, export, hash,str_hash (sym->name)) {if (!strcmp (export->sym, sym->name))return export;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1392/1815 objtool/klp: Fix relocations for EXPORT_SYMBOL_FOR_MODULES() symbols
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit 4cd3cfb8b54feca89a682720434092a87bfa4967 ]
EXPORT_SYMBOL_FOR_MODULES() puts a symbol in a "module:<names>" namespace, which the module loader grants access to by matching the importing module's name against that list.
klp_reloc_needed() only creates a klp reloc for module-owned exports; a vmlinux export gets a normal reloc. For a vmlinux symbol exported with EXPORT_SYMBOL_FOR_MODULES(), using a normal reloc results in a modpost failure in klp-build:
ERROR: modpost: module livepatch-foo uses symbol mpol_shared_policy_lookup from namespace module:kvm, but does not import it.
And the modpost error is correct: even with that error removed, the patch module would fail to load:
livepatch_foo: module uses symbol (mpol_shared_policy_lookup) from namespace module:kvm, but does not import it.
livepatch_foo: Unknown symbol mpol_shared_policy_lookup (err -22)
Treat it like an unexported symbol by using a klp reloc.
Note this only affects "module:" namespaces. Ordinary namespaced exports continue to work with normal relocs thanks to copy_import_ns(), which propagates the patched object's import_ns tags to the patch module.
--- tools/objtool/klp-diff.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
tools/objtool/klp-diff.c +23 -5
@@ -30,7 +30,9 @@ struct elfs {struct export {struct hlist_node hash; -char *mod, *sym; +char *mod; +char *sym; +bool mod_ns; };bool debug, debug_correlate, debug_clone;
@@ -135,7 +137,7 @@ static int read_exports(void) }while (fgets (line,1024 , file)) { -char *sym, *mod, *type; +char *sym, *mod, *type, *namespace;struct export *export; sym =strchr (line,'\t' );
@@ -162,6 +164,14 @@ static int read_exports(void) *type++ ='\0' ; + namespace =strchr (type,'\t' ); +if (!namespace) { +ERROR ("malformed Module.symvers (namespace) at line %d" , line_num); +return -1 ; + } + + *namespace++ ='\0' ; +if (*sym =='\0' || *mod =='\0' ) {ERROR ("malformed Module.symvers at line %d" , line_num);return -1 ;
@@ -188,6 +198,9 @@ static int read_exports(void)return -1 ; } +/* EXPORT_SYMBOL_FOR_MODULES() */ + export->mod_ns =strstarts (namespace,"module:" ); +hash_add (exports, &export->hash,str_hash (sym)); }
@@ -1175,11 +1188,16 @@ static bool klp_reloc_needed(struct reloc *patched_reloc)* clusterfunk that is late module patching, the patch module is * allowed to be loaded before any modules it depends on. * -* If exported by vmlinux, a normal reloc will do. +* If exported by vmlinux to all modules, a normal reloc will do. */ export =find_export (patched_sym); -if (export) -return strcmp (export->mod,"vmlinux" ); +if (export) { +if (strcmp (export->mod,"vmlinux" )) +return true; + +/* EXPORT_SYMBOL_FOR_MODULES() gets a klp reloc */ +return export->mod_ns; + }if (!patched_sym->twin) {/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1393/1815 PCI/ASPM: Use pcie_capability_clear_and_set_word() for ASPM disable/restore
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krishna Chaitanya Chundru <[email protected]>
[ Upstream commit 75a3b50ad9dc99ce9693a0086b968c6d3501db21 ]
pcie_aspm_cap_init() disables ASPM L0s/L1 on both ends of the Link before touching L1SS config, then later restores the LNKCTL state that was in effect beforehand. Both steps use raw pcie_capability_write_word() calls: the disable step computes the new value by hand from a snapshot taken earlier in the function, and the restore step writes that same snapshot straight back.
Switch both steps to pcie_capability_clear_and_set_word(), masked to PCI_EXP_LNKCTL_ASPMC, matching the accessor pcie_config_aspm_dev() already uses elsewhere in this file for the exact same register. This does a live read-modify-write of just the ASPM Control bits instead of relying on a stale snapshot for the rest of the word, and is consistent with how the rest of the file already touches this register. No functional change.
--- drivers/pci/pcie/aspm.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/pci/pcie/aspm.c +10 -6
@@ -894,10 +894,10 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)/* Disable L0s/L1 before updating L1SS config */ if (FIELD_GET (PCI_EXP_LNKCTL_ASPMC , child_lnkctl) ||FIELD_GET (PCI_EXP_LNKCTL_ASPMC , parent_lnkctl)) { -pcie_capability_write_word (child,PCI_EXP_LNKCTL , - child_lnkctl & ~PCI_EXP_LNKCTL_ASPMC ); -pcie_capability_write_word (parent,PCI_EXP_LNKCTL , - parent_lnkctl & ~PCI_EXP_LNKCTL_ASPMC ); +pcie_capability_clear_and_set_word (child,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_ASPMC ,0 ); +pcie_capability_clear_and_set_word (parent,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_ASPMC ,0 ); }/*
@@ -927,8 +927,12 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)/* Restore L0s/L1 if they were enabled */ if (FIELD_GET (PCI_EXP_LNKCTL_ASPMC , child_lnkctl) ||FIELD_GET (PCI_EXP_LNKCTL_ASPMC , parent_lnkctl)) { -pcie_capability_write_word (parent,PCI_EXP_LNKCTL , parent_lnkctl); -pcie_capability_write_word (child,PCI_EXP_LNKCTL , child_lnkctl); +pcie_capability_clear_and_set_word (parent,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_ASPMC , + parent_lnkctl &PCI_EXP_LNKCTL_ASPMC ); +pcie_capability_clear_and_set_word (child,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_ASPMC , + child_lnkctl &PCI_EXP_LNKCTL_ASPMC ); }/* Save default state */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1394/1815 super: fix dying superblock warning messages
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 9ac8fd831252e52aa78399eaccc11a72f6c2af1a ]
WARN_ON_ONCE() takes a condition, not a message. The string literals are always true, so the warnings still trigger but the messages are never printed.
Use WARN_ONCE(1, ...) instead to print the messages and keep the once-only behavior.
Found with a Coccinelle script. Clang's -Wstring-conversion also flags such calls but is not enabled in kernel builds.
--- fs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/super.c +2 -2
@@ -2018,7 +2018,7 @@ int freeze_super(struct super_block *sb, enum freeze_holder who, const void *freint ret;if (!super_lock_excl (sb)) { -WARN_ON_ONCE ("Dying superblock while freezing!" ); +WARN_ONCE (1 ,"Dying superblock while freezing!" );return -EINVAL ; }atomic_inc (&sb->s_active);
@@ -2182,7 +2182,7 @@ int thaw_super(struct super_block *sb, enum freeze_holder who, const void *freeze_owner) {if (!super_lock_excl (sb)) { -WARN_ON_ONCE ("Dying superblock while thawing!" ); +WARN_ONCE (1 ,"Dying superblock while thawing!" );return -EINVAL ; }return thaw_super_locked (sb, who, freeze_owner);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1395/1815 iomap: iomap_bio_read_folio_range_sync is missing a call to bio_uninit
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
[ Upstream commit accb6624e383872e7703974a5d5826755fb27032 ]
Which could leak blkg references.
--- fs/iomap/bio.c | 1 + 1 file changed, 1 insertion(+)
fs/iomap/bio.c +1 -0
@@ -184,5 +184,6 @@ int iomap_bio_read_folio_range_sync(const struct iomap_iter *iter, error =fs_bio_integrity_verify (&bio, sector, len);fs_bio_integrity_free (&bio); } +bio_uninit (&bio);return error; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1396/1815 arm64/efi: Avoid voluntary preemption with efi_mm installed
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
[ Upstream commit e98a9d0146372b046d863164025a66ab4488b972 ]
Gus reports a bad kernel memory access when using software PAN (CONFIG_ARM64_SW_TTBR0_PAN=y) on a machine with support for EFI runtime services:
Unable to handle kernel access to user memory outside uaccess routines
at virtual address 00000000f322ff30
Mem abort info:
ESR = 0x0000000096000004
FSC = 0x04: level 0 translation fault
Internal error: Oops: 0000000096000004 [#1] SMP
Workqueue: efi_rts_wq efi_call_rts
pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : efi_call_rts+0xd8/0x288
Call trace:
efi_call_rts+0xd8/0x288 (P)
process_one_work+0x178/0x4f8
worker_thread+0x194/0x328This is because the fpsimd context management code called from __efi_fpsimd_begin() can preempt voluntarily, returning later to the EFI code with an incorrect value for TTBR0_EL1 thanks to the deferred mm switching used by the software PAN implementation.
Since EFI runtime services cannot preempt voluntarily and because the fpsimd switching code does not rely on the TTBR0_EL1 mappings, simply reorder the fpsimd switch so that it occurs before we change the page-table.
--- arch/arm64/kernel/efi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/efi.c +2 -2
@@ -184,6 +184,8 @@ void arch_efi_call_virt_setup(void)efi_virtmap_load (); } +__efi_fpsimd_begin (); +/* * Enable access to the valid TTBR0_EL1 and invoke the errata * workaround directly since there is no return from exception when
@@ -191,8 +193,6 @@ void arch_efi_call_virt_setup(void)*/ uaccess_ttbr0_enable ();post_ttbr_update_workaround (); - -__efi_fpsimd_begin (); }void arch_efi_call_virt_teardown (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1397/1815 mfd: cs42l43: Fix regmap defaults ordering
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Keepax <[email protected]>
[ Upstream commit 9d0e4b1ae5b045a2c92b0b9a1c3b268191c219d9 ]
The regmap defaults should be ordered as binary search is done on the array. A few registers were added in the wrong places, move these to be in register address order.
--- drivers/mfd/cs42l43.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/mfd/cs42l43.c +8 -8
@@ -115,14 +115,14 @@ const struct reg_default cs42l43_reg_default[CS42L43_N_DEFAULTS] = { { CS42L43_DECIM_HPF_WNF_CTRL2, 0x00000001 }, { CS42L43_DECIM_HPF_WNF_CTRL3, 0x00000001 }, { CS42L43_DECIM_HPF_WNF_CTRL4, 0x00000001 }, - { CS42L43B_DECIM_HPF_WNF_CTRL5, 0x00000001 }, - { CS42L43B_DECIM_HPF_WNF_CTRL6, 0x00000001 }, { CS42L43_DMIC_PDM_CTRL, 0x00000000 }, { CS42L43_DECIM_VOL_CTRL_CH1_CH2, 0x20122012 }, { CS42L43_DECIM_VOL_CTRL_CH3_CH4, 0x20122012 }, { CS42L43B_DECIM_VOL_CTRL_CH1_CH2, 0x20122012 }, { CS42L43B_DECIM_VOL_CTRL_CH3_CH4, 0x20122012 }, { CS42L43B_DECIM_VOL_CTRL_CH5_CH6, 0x20122012 }, + { CS42L43B_DECIM_HPF_WNF_CTRL5, 0x00000001 }, + { CS42L43B_DECIM_HPF_WNF_CTRL6, 0x00000001 }, { CS42L43_INTP_VOLUME_CTRL1, 0x00000180 }, { CS42L43_INTP_VOLUME_CTRL2, 0x00000180 }, { CS42L43_AMP1_2_VOL_RAMP, 0x00000022 },
@@ -160,10 +160,10 @@ const struct reg_default cs42l43_reg_default[CS42L43_N_DEFAULTS] = { { CS42L43_SWIRE_DP2_CH2_INPUT, 0x00000000 }, { CS42L43_SWIRE_DP3_CH1_INPUT, 0x00000000 }, { CS42L43_SWIRE_DP3_CH2_INPUT, 0x00000000 }, - { CS42L43B_SWIRE_DP3_CH3_INPUT, 0x00000000 }, - { CS42L43B_SWIRE_DP3_CH4_INPUT, 0x00000000 }, { CS42L43_SWIRE_DP4_CH1_INPUT, 0x00000000 }, { CS42L43_SWIRE_DP4_CH2_INPUT, 0x00000000 }, + { CS42L43B_SWIRE_DP3_CH3_INPUT, 0x00000000 }, + { CS42L43B_SWIRE_DP3_CH4_INPUT, 0x00000000 }, { CS42L43B_SWIRE_DP4_CH3_INPUT, 0x00000000 }, { CS42L43B_SWIRE_DP4_CH4_INPUT, 0x00000000 }, { CS42L43_ASRC_INT1_INPUT1, 0x00000000 },
@@ -178,14 +178,10 @@ const struct reg_default cs42l43_reg_default[CS42L43_N_DEFAULTS] = { { CS42L43_ISRC1INT2_INPUT1, 0x00000000 }, { CS42L43_ISRC1DEC1_INPUT1, 0x00000000 }, { CS42L43_ISRC1DEC2_INPUT1, 0x00000000 }, - { CS42L43B_ISRC1DEC3_INPUT1, 0x00000000 }, - { CS42L43B_ISRC1DEC4_INPUT1, 0x00000000 }, { CS42L43_ISRC2INT1_INPUT1, 0x00000000 }, { CS42L43_ISRC2INT2_INPUT1, 0x00000000 }, { CS42L43_ISRC2DEC1_INPUT1, 0x00000000 }, { CS42L43_ISRC2DEC2_INPUT1, 0x00000000 }, - { CS42L43B_ISRC2DEC3_INPUT1, 0x00000000 }, - { CS42L43B_ISRC2DEC4_INPUT1, 0x00000000 }, { CS42L43_EQ1MIX_INPUT1, 0x00800000 }, { CS42L43_EQ1MIX_INPUT2, 0x00800000 }, { CS42L43_EQ1MIX_INPUT3, 0x00800000 },
@@ -212,6 +208,10 @@ const struct reg_default cs42l43_reg_default[CS42L43_N_DEFAULTS] = { { CS42L43_AMP4MIX_INPUT2, 0x00800000 }, { CS42L43_AMP4MIX_INPUT3, 0x00800000 }, { CS42L43_AMP4MIX_INPUT4, 0x00800000 }, + { CS42L43B_ISRC1DEC3_INPUT1, 0x00000000 }, + { CS42L43B_ISRC1DEC4_INPUT1, 0x00000000 }, + { CS42L43B_ISRC2DEC3_INPUT1, 0x00000000 }, + { CS42L43B_ISRC2DEC4_INPUT1, 0x00000000 }, { CS42L43_ASRC_INT_ENABLES, 0x00000100 }, { CS42L43_ASRC_DEC_ENABLES, 0x00000100 }, { CS42L43_PDNCNTL, 0x00000000 },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1398/1815 backlight: aw99706: Validate all DT property values consistently
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junjie Cao <[email protected]>
[ Upstream commit 3d142b19b09ea62d6e9a33d46d1b858b3ad05707 ]
The lookup helpers for dim-mode and ramp-ctl take a shortcut when lookup_tbl is NULL: they accept any u32 value without range-checking and return success unconditionally. Out-of-range values get silently truncated by regmap_update_bits instead of triggering the dev_warn + default-fallback path that the other properties use.
Add a field-width check for the NULL-table case so that values exceeding the register field maximum are rejected the same way a table-lookup miss is.
The switching frequency table has a second hole: reserved slots use 0 as their marker, so "awinic,sw-freq-hz = <0>" matches slot 0 and programs a reserved encoding. Make the reserved marker U32_MAX and skip such slots during lookup.
While here, also switch the error returns to -EINVAL for consistency.
--- drivers/video/backlight/aw99706.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/video/backlight/aw99706.c +10 -5
@@ -60,7 +60,7 @@#define AW99706_MTPLDOSEL_REG 0x1E#define AW99706_MTPRUN_REG 0x1F -#define RESV 0 +#define RESV U32_MAX/* Boost switching frequency table, in Hz */ static const u32 aw99706_sw_freq_tbl[] = {
@@ -94,17 +94,19 @@ static int aw99706_dt_property_lookup(const struct aw99706_dt_prop *prop,int i;if (!prop->lookup_tbl) { +if (dt_val > (prop->mask >>__ffs (prop->mask))) +return -EINVAL ; *val = dt_val;return 0 ; }for (i =0 ; i < prop->tbl_size; i++) -if (prop->lookup_tbl[i] == dt_val) +if (prop->lookup_tbl[i] !=RESV && prop->lookup_tbl[i] == dt_val)break ; *val = i; -return i == prop->tbl_size ?-1 :0 ; +return i == prop->tbl_size ? -EINVAL :0 ; }#define MIN_ILED_MAX 5000
@@ -116,11 +118,14 @@ aw99706_dt_property_iled_max_convert(const struct aw99706_dt_prop *prop, u32 dt_val, u8 *val) {if (dt_val >MAX_ILED_MAX || dt_val <MIN_ILED_MAX ) -return -1 ; +return -EINVAL ; + +if ((dt_val -MIN_ILED_MAX ) %STEP_ILED_MAX ) +return -EINVAL ; *val = (dt_val -MIN_ILED_MAX ) /STEP_ILED_MAX ; -return (dt_val -MIN_ILED_MAX ) %STEP_ILED_MAX ; +return 0 ; }static const struct aw99706_dt_prop aw99706_dt_props[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1399/1815 backlight: ktd2801: Fix unmet dependency on GPIOLIB
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 5859fa79c7d85d0c242a9a1ffb40bab9732d4ef1 ]
LEDS_EXPRESSWIRE depends on GPIOLIB, so its selector, BACKLIGHT_KTD2801 also needs to ensure GPIOLIB is enabled. Otherwise:
WARNING: unmet direct dependencies detected for LEDS_EXPRESSWIRE
Depends on [n]: NEW_LEDS [=n] && GPIOLIB [=n]
Selected by [y]:
- BACKLIGHT_KTD2801 [=y] && HAS_IOMEM [=y] && BACKLIGHT_CLASS_DEVICE [=y]
This unmet dependency was found by kconfirm, a static analysis tool for Kconfig.
--- drivers/video/backlight/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/backlight/Kconfig +1 -1
@@ -193,7 +193,7 @@ config BACKLIGHT_KTD253 config BACKLIGHT_KTD2801 tristate "Backlight Driver for Kinetic KTD2801" - depends on GPIOLIB || COMPILE_TEST + depends on GPIOLIB select LEDS_EXPRESSWIRE help Say Y to enable the backlight driver for the Kinetic KTD2801 1-wire
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1400/1815 perf build: Remove leftover feature tests for removed cxx and clang support
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit b60f6bc128b972e018de6bcfa7007b4021f4a31a ]
56b11a2126bf2f42 ("perf bpf: Remove support for embedding clang for compiling BPF events (-e foo.c)") removed the test-cxx.cpp and test-clang.cpp sources, but left behind their entries in the feature test FILES list, the build rules and the cxx and clang entries in FEATURE_TESTS_EXTRA.
Since the sources no longer exist, those rules would always fail, making the artificial feature-cxx and feature-clang results to be perpetually disabled/absent, remove the leftover entries, making the feature test scripts list match the available sources.
--- tools/build/Makefile.feature | 2 -- tools/build/feature/Makefile | 14 -------------- 2 files changed, 16 deletions(-)
tools/build/Makefile.feature +0 -2
@@ -123,9 +123,7 @@ FEATURE_TESTS_EXTRA := \ libbfd-liberty-z \ libopencsd \ libperl \ - cxx \ llvm \ - clang \ libbpf \ libpfm4 \ libdebuginfod \
tools/build/feature/Makefile +0 -14
@@ -55,7 +55,6 @@ FILES= \ test-bpf.bin \ test-libbpf.bin \ test-sdt.bin \ - test-cxx.bin \ test-gettid.bin \ test-jvmti.bin \ test-jvmti-cmlr.bin \
@@ -63,7 +62,6 @@ FILES= \ test-sched_getcpu.bin \ test-setns.bin \ test-libopencsd.bin \ - test-clang.bin \ test-llvm.bin \ test-llvm-perf.bin \ test-libaio.bin \
@@ -335,9 +333,6 @@ $(OUTPUT)test-libbpf.bin: $(OUTPUT)test-sdt.bin: $(BUILD) -$(OUTPUT)test-cxx.bin: - $(BUILDXX) -std=gnu++11 - $(OUTPUT)test-gettid.bin: $(BUILD)
@@ -363,15 +358,6 @@ $(OUTPUT)test-llvm-perf.bin: $(shell $(LLVM_CONFIG) --system-libs) \ > $(@:.bin=.make.output) 2>&1 -$(OUTPUT)test-clang.bin: - $(BUILDXX) -std=gnu++17 \ - -I$(shell $(LLVM_CONFIG) --includedir) \ - -L$(shell $(LLVM_CONFIG) --libdir) \ - -Wl,--start-group -lclang-cpp -Wl,--end-group \ - $(shell $(LLVM_CONFIG) --libs Core option) \ - $(shell $(LLVM_CONFIG) --system-libs) \ - > $(@:.bin=.make.output) 2>&1 - -include $(OUTPUT)*.d $(OUTPUT)test-libaio.bin:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1401/1815 drm/amd/pm: silence uninitialized variable warnings
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 b4cb43789b6ac0f25fc0d9b21c5e7a6225cf6a31 ]
Smatch complains that:
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu15/smu_v15_0_8_ppt.c:1964 smu_v15_0_8_set_performance_level() error: uninitialized symbol 'ret'.
In this line there is an "if (ret)" condition where "ret" is either zero or uninitialized. Initialize "ret" at the start of the function to avoid a potential uninitialized variable bug. But also delete the condition since it is never true.
--- drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c +1 -4
@@ -1915,7 +1915,7 @@ static int smu_v15_0_8_set_performance_level(struct smu_context *smu,struct smu_dpm_table *gfx_table = &dpm_context->dpm_tables.gfx_table;struct smu_dpm_table *uclk_table = &dpm_context->dpm_tables.uclk_table;struct smu_umd_pstate_table *pstate_table = &smu->pstate_table; -int ret; +int ret =0 ;switch (level) {case AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM :
@@ -1956,9 +1956,6 @@ static int smu_v15_0_8_set_performance_level(struct smu_context *smu,SMU_DPM_TABLE_MAX (uclk_table); } -if (ret) - goto out; -smu_cmn_reset_custom_level (smu);break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1402/1815 kunit: tool: fix _list_tests filtering wrong variable when list has TAP prefix
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohammad Abu-Khader <[email protected]>
[ Upstream commit dea754ded9518b51740c417d2c1e02ff540784c6 ]
_list_tests() runs the kernel to list tests, strips printk timestamp lines via extract_tap_lines(), then drops the dummy TAP header from the cleaned lines. However the subsequent regex filter mistakenly operates on the original output instead of the cleaned lines. When the kernel output includes timestamp prefixes (common with UML or slower setups), e.g.:
[ 0.100000] suite.test1 [ 0.100000] suite.test2
the anchored regex ^[^\s.]+\.[^\s.]+$ rejects them and --list_tests returns an empty list.
Filter lines instead of output, matching the behavior of the adjacent _list_tests_attr() which already returns the cleaned list.
Add a regression test with timestamp-prefixed input to verify the fix.
--- tools/testing/kunit/kunit.py | 2 +- tools/testing/kunit/kunit_tool_test.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-)
tools/testing/kunit/kunit.py +1 -1
@@ -126,7 +126,7 @@ def _list_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) lines.pop() # Filter out any extraneous non-test output that might have gotten mixed in. - return [l for l in output if re.match(r'^[^\s.]+\.[^\s.]+$', l)] + return [l for l in lines if re.match(r'^[^\s.]+\.[^\s.]+$', l)] def _list_tests_attr(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) -> Iterable[str]: args = ['kunit.action=list_attr']
tools/testing/kunit/kunit_tool_test.py +12 -0
@@ -979,6 +979,18 @@ class KUnitMainTest(unittest.TestCase): self.linux_source_mock.run_kernel.assert_called_once_with( args=['kunit.action=list'], build_dir='.kunit', filter_glob='suite*', filter='', filter_action=None, timeout=300) + def test_list_tests_with_prefix(self): + want = ['suite.test1', 'suite.test2', 'suite2.test1'] + self.linux_source_mock.run_kernel.return_value = [ + '[ 0.100000] TAP version 14', + '[ 0.200000] suite.test1', + '[ 0.200000] suite.test2', + '[ 0.300000] suite2.test1'] + + got = kunit._list_tests(self.linux_source_mock, + kunit.KunitExecRequest(None, None, None, False, False, '.kunit', 300, 'suite*', '', None, None, 'suite', False, False, False)) + self.assertEqual(got, want) + @mock.patch.object(kunit, '_list_tests') def test_run_isolated_by_suite(self, mock_tests): mock_tests.return_value = ['suite.test1', 'suite.test2', 'suite2.test1']
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1403/1815 bpf, riscv: Clear fetch destination on faulting arena atomic
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 1519f488e8ce430c68ade11d24b8459631f5dca9 ]
A RMW atomic on an arena pointer is converted to BPF_PROBE_ATOMIC and gets an exception table entry, but that entry records no destination register to clear unless the instruction is a load-acquire today. That is right for a plain BPF_{ADD,AND,OR,XOR}, which only writes memory, but an RMW carrying BPF_FETCH also reads the old value into a register:src_reg for BPF_{ADD,AND,OR,XOR} | BPF_FETCH and BPF_XCHG, and r0 for BPF_CMPXCHG. emit_atomic_rmw() emits it that way, e.g.:
[...]
case BPF_XCHG:
ctx->ex_insn_off = ctx->ninsns;
emit(is64 ? rv_amoswap_d(rs, rs, rd, 1, 1) :
rv_amoswap_w(rs, rs, rd, 1, 1), ctx);
[...]Thus, a fault over an unmapped arena page ex_handler_bpf() jumps over the access but leaves rs untouched, and the program resumes with whatever it held before the atomic instead of the 0 that every other BPF_PROBE_* access delivers. Fill the exception table entry in from bpf_atomic_load_reg(), which returns the BPF register an atomic reads the memory operand into or -1 when it has none. A load-acquire ends up with the same register it gets today, it just goes through the helper. Unlike x86-64 and arm64, riscv64 does not report arena violations from its exception handler, so there is no access direction to correct here, only the missing register clear.
--- arch/riscv/net/bpf_jit_comp64.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
arch/riscv/net/bpf_jit_comp64.c +13 -4
@@ -1986,10 +1986,19 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx, ret =emit_atomic_rmw (rd, rs, insn, ctx);/* ret can be 1 (skip-zext); extable entry still needs to be added */ -if (ret >=0 ) - ret =add_exception_handler (insn, -bpf_atomic_is_load_acq (insn) ? rd :REG_DONT_CLEAR_MARKER , - ctx) ?: ret; +if (ret >=0 ) { +/* +* A load-acquire reads into dst_reg, and a read-modify-write +* carrying BPF_FETCH reads the old value into src_reg, or into +* r0 for a BPF_CMPXCHG. Clear that register on fault, the +* remaining atomics have no destination register. +*/ +int load_reg =bpf_atomic_load_reg (insn); + + ret =add_exception_handler (insn, load_reg <0 ? +REG_DONT_CLEAR_MARKER : regmap[load_reg], + ctx) ?: ret; + }if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1404/1815 bpf: Derive the atomic load register in one place
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 41c5dbb4be3c1ef4a5e2ce4c28de60b2be3cdccf ]
check_atomic_rmw() open codes the mapping from a BPF_ATOMIC to the register it reads the old value into, the BPF_STX case of insn_def_regno() open codes the very same mapping a second time, the const folding and the liveness transfer functions a third and a fourth time, and BPF JITs need it as well to know which register a faulting BPF_PROBE_ATOMIC has to clear.
Add a small helper so that all of them can share it. No functional change. The BPF_LOAD_ACQ case is there for the JITs, which do walk all instruction classes. const_reg_xfer() loses its explicit BPF_ATOMIC mode test since the helper checks class and mode itself; the BPF_PROBE_ATOMIC it additionally accepts cannot be seen there as it is only set from bpf_do_misc_fixups(), that is, after const folding has run. arg_track_xfer() keeps its mode test since that also guards the stack clearing next to it.
Stable-dep-of: cf92a108601a ("bpf, x86: Clear fetch destination on faulting arena atomic")
--- include/linux/filter.h | 24 ++++++++++++++++++++++++ kernel/bpf/const_fold.c | 11 +++-------- kernel/bpf/fixups.c | 11 +---------- kernel/bpf/liveness.c | 9 +++------ kernel/bpf/verifier.c | 13 ++----------- 5 files changed, 33 insertions(+), 35 deletions(-)
include/linux/filter.h +24 -0
@@ -414,6 +414,30 @@ static inline bool bpf_atomic_is_load_acq(const struct bpf_insn *insn) insn->imm ==BPF_LOAD_ACQ ; } +/* +* Given an instruction @insn, return the number of the BPF register that a +* BPF_ATOMIC reads the value at its memory operand into, or -1 if there is +* no such register. That is the register a BPF_PROBE_ATOMIC has to clear when +* the access faults. Like bpf_atomic_is_load_acq(), @insn is not assumed to +* be a BPF_ATOMIC here. +*/ +static inline int bpf_atomic_load_reg (const struct bpf_insn *insn) +{ +if (BPF_CLASS (insn->code) !=BPF_STX || + (BPF_MODE (insn->code) !=BPF_ATOMIC && +BPF_MODE (insn->code) !=BPF_PROBE_ATOMIC )) +return -1 ; + +switch (insn->imm) { +case BPF_LOAD_ACQ : +return insn->dst_reg; +case BPF_CMPXCHG : +return BPF_REG_0 ; +default : +return (insn->imm &BPF_FETCH ) ? insn->src_reg :-1 ; + } +} +/* Memory store, *(uint *) (dst_reg + off16) = imm32 */ #define BPF_ST_MEM (SIZE ,DST ,OFF ,IMM ) \
kernel/bpf/const_fold.c +3 -8
@@ -199,14 +199,9 @@ static void const_reg_xfer(struct bpf_verifier_env *env, struct const_arg_info * ci_out[r] = unknown;break ;case BPF_STX : -if (mode !=BPF_ATOMIC ) -break ; -if (insn->imm ==BPF_CMPXCHG ) - ci_out[BPF_REG_0 ] = unknown; -else if (insn->imm ==BPF_LOAD_ACQ ) - *dst = unknown; -else if (insn->imm &BPF_FETCH ) - *src = unknown; + r =bpf_atomic_load_reg (insn); +if (r >=0 ) + ci_out[r] = unknown;break ; } }
kernel/bpf/fixups.c +1 -10
@@ -29,16 +29,7 @@ static int insn_def_regno(const struct bpf_insn *insn)case BPF_ST :return -1 ;case BPF_STX : -if (BPF_MODE (insn->code) ==BPF_ATOMIC || -BPF_MODE (insn->code) ==BPF_PROBE_ATOMIC ) { -if (insn->imm ==BPF_CMPXCHG ) -return BPF_REG_0 ; -else if (insn->imm ==BPF_LOAD_ACQ ) -return insn->dst_reg; -else if (insn->imm &BPF_FETCH ) -return insn->src_reg; - } -return -1 ; +return bpf_atomic_load_reg (insn);default :return insn->dst_reg; }
kernel/bpf/liveness.c +3 -6
@@ -1213,12 +1213,9 @@ static void arg_track_xfer(struct bpf_verifier_env *env, struct bpf_insn *insn,clear_stack_for_all_offs (insn, at_out, insn->dst_reg, at_stack_out, sz); -if (insn->imm ==BPF_CMPXCHG ) - at_out[BPF_REG_0 ] = none; -else if (insn->imm ==BPF_LOAD_ACQ ) - *dst = none; -else if (insn->imm &BPF_FETCH ) - *src = none; + r =bpf_atomic_load_reg (insn); +if (r >=0 ) + at_out[r] = none; } }else if (class ==BPF_ST &&BPF_MODE (insn->code) ==BPF_MEM ) {u32 sz =bpf_size_to_bytes (BPF_SIZE (insn->code));
kernel/bpf/verifier.c +2 -11
@@ -6507,21 +6507,12 @@ static int check_atomic_rmw(struct bpf_verifier_env *env,return -EACCES ; } -if (insn->imm &BPF_FETCH ) { -if (insn->imm ==BPF_CMPXCHG ) - load_reg =BPF_REG_0 ; -else - load_reg = insn->src_reg; - + load_reg =bpf_atomic_load_reg (insn); +if (load_reg >=0 ) {/* check and record load of old value */ err =check_reg_arg (env, load_reg,DST_OP );if (err)return err; - }else { -/* This instruction accesses a memory location but doesn't -* actually load it into a register. -*/ - load_reg =-1 ; } dst_reg =cur_regs (env) + insn->dst_reg;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1405/1815 bpf, x86: Clear fetch destination on faulting arena atomic
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit cf92a108601a3f2465b550e44a98c8a78cabf8d1 ]
populate_extable() encodes "there is no destination register to clear" as DONT_CLEAR in the DST_REG field of the exception table metadata, and later ex_handler_bpf() then reuses that very value to derive the direction it reports the fault with is_write = (reg == DONT_CLEAR). The two coincide for a plain load or store, but not for a RMW carrying BPF_FETCH. Such an atomic writes memory, so it has to be reported as a WRITE, and it also reads the old value into a register, src_reg for BPF_ADD | BPF_FETCH and BPF_XCHG, r0 for BPF_CMPXCHG, so that register has to be cleared on fault. A single DONT_CLEAR cannot say both, and the store branch picks it unconditionally:
[...]
} else {
arena_reg = reg2pt_regs[dst_reg];
fixup_reg = DONT_CLEAR;
}
[...]The reported direction is therefore right, but on a fault over an unmapped arena page the fetch destination keeps whatever it held before the atomic, where every other BPF_PROBE_* access delivers 0. Give the metadata its own ARENA_WRITE bit so that the reported direction no longer depends on whether there is a register to clear, and fill DST_REG in from bpf_atomic_load_reg(). BPF_{AND,OR,XOR} | BPF_FETCH need no handling here, bpf_jit_supports_insn() already rejects those in the arena.
--- arch/x86/net/bpf_jit_comp.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-)
arch/x86/net/bpf_jit_comp.c +27 -8
@@ -1473,17 +1473,20 @@ static int emit_atomic_ld_st_index(u8 **pprog, u32 atomic_op, u32 size,* * Bit layout of `fixup` (32-bit): * -* +-----------+--------+-----------+---------+----------+ -* | 31 | 30-24 | 23-16 | 15-8 | 7-0 | -* | | | | | | -* | ARENA_ACC | Unused | ARENA_REG | DST_REG | INSN_LEN | -* +-----------+--------+-----------+---------+----------+ +* +-----------+-------------+--------+-----------+---------+----------+ +* | 31 | 30 | 29-24 | 23-16 | 15-8 | 7-0 | +* | | | | | | | +* | ARENA_ACC | ARENA_WRITE | Unused | ARENA_REG | DST_REG | INSN_LEN | +* +-----------+-------------+--------+-----------+---------+----------+ * * - INSN_LEN (8 bits): Length of faulting insn (max x86 insn = 15 bytes (fits in 8 bits)). * - DST_REG (8 bits): Offset of dst_reg from reg2pt_regs[] (max offset = 112 (fits in 8 bits)). -* This is set to DONT_CLEAR if the insn is a store. +* This is set to DONT_CLEAR if the insn does not read into a register. * - ARENA_REG (8 bits): Offset of the register that is used to calculate the * address for load/store when accessing the arena region. +* - ARENA_WRITE (1 bit): This bit is set when the faulting instruction wrote to the arena region. +* It is independent of DST_REG, since a read-modify-write both writes to +* memory and reads the old value into a register. * - ARENA_ACCESS (1 bit): This bit is set when the faulting instruction accessed the arena region. * * Bit layout of `data` (32-bit):
@@ -1502,6 +1505,7 @@ static int emit_atomic_ld_st_index(u8 **pprog, u32 atomic_op, u32 size,#define FIXUP_INSN_LEN_MASK GENMASK(7, 0)#define FIXUP_REG_MASK GENMASK(15, 8)#define FIXUP_ARENA_REG_MASK GENMASK(23, 16) +#define FIXUP_ARENA_WRITE BIT(30)#define FIXUP_ARENA_ACCESS BIT(31)#define DATA_ARENA_OFFSET_MASK GENMASK(31, 16)
@@ -1510,7 +1514,7 @@ bool ex_handler_bpf(const struct exception_table_entry *x, struct pt_regs *regs)u32 reg =FIELD_GET (FIXUP_REG_MASK , x->fixup);u32 insn_len =FIELD_GET (FIXUP_INSN_LEN_MASK , x->fixup);bool is_arena = !!(x->fixup &FIXUP_ARENA_ACCESS ); -bool is_write = (reg ==DONT_CLEAR ); +bool is_write = !!(x->fixup &FIXUP_ARENA_WRITE );unsigned long addr;s16 off;u32 arena_reg;
@@ -2304,6 +2308,7 @@ st: insn_off = insn->off;struct exception_table_entry *ex;u8 *_insn = image + proglen + (start_of_ldx - temp);u32 arena_reg, fixup_reg; +bool is_write;s64 delta;if (!bpf_prog->aux->extable)
@@ -2340,15 +2345,29 @@ st: insn_off = insn->off; bpf_atomic_is_load_acq(insn)) { arena_reg = reg2pt_regs[src_reg]; fixup_reg = reg2pt_regs[dst_reg]; + is_write = false; } else { +/* +* A store has no destination register to clear, +* except for a read-modify-write with BPF_FETCH, +* which also reads the old value into src_reg, or +* into r0 for a BPF_CMPXCHG. Either way the access +* is still reported as a write. +*/ +int load_reg =bpf_atomic_load_reg (insn); + arena_reg = reg2pt_regs[dst_reg]; - fixup_reg =DONT_CLEAR ; + fixup_reg = load_reg <0 ?DONT_CLEAR : + reg2pt_regs[load_reg]; + is_write = true; } ex->fixup =FIELD_PREP (FIXUP_INSN_LEN_MASK , prog - start_of_ldx) |FIELD_PREP (FIXUP_ARENA_REG_MASK , arena_reg) |FIELD_PREP (FIXUP_REG_MASK , fixup_reg); ex->fixup |=FIXUP_ARENA_ACCESS ; +if (is_write) + ex->fixup |=FIXUP_ARENA_WRITE ; ex->data |=FIELD_PREP (DATA_ARENA_OFFSET_MASK , insn->off); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1406/1815 bpf, arm64: Clear fetch destination on faulting arena atomic
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit ea3f20cb5918fea8e3786899b78fc7bb867c6a5e ]
Same problem as on x86-64: add_exception_handler() folds "there is no destination register to clear" and "this is a store" into one DONT_CLEAR value ...
if (BPF_CLASS(insn->code) != BPF_LDX && !bpf_atomic_is_load_acq(insn))
dst_reg = DONT_CLEAR;... which ex_handler_bpf() then reads back as the access direction:
bool is_write = (dst_reg == DONT_CLEAR);
A RMW carrying BPF_FETCH is both. emit_lse_atomic() reads the old value into src_reg for BPF_{ADD,AND,OR,XOR} | BPF_FETCH and BPF_XCHG, and into r0 for BPF_CMPXCHG, so a fault over an unmapped arena page is correctly reported as a WRITE but leaves that register holding a stale value instead of the 0 that every other BPF_PROBE_* access delivers. Same as on x86-64, add a separate ARENA_WRITE bit for the direction.
FIXUP_REG is now filled in by the callers of add_exception_handler(), the BPF_PROBE_ATOMIC one deriving it from bpf_atomic_load_reg(), so that the helper only has to determine the direction. This is how the riscv64 JIT already does it, and it stops the two store callers from handing in a dst_reg that was only going to be overwritten with DONT_CLEAR anyway.
--- arch/arm64/net/bpf_jit_comp.c | 44 ++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 14 deletions(-)
arch/arm64/net/bpf_jit_comp.c +30 -14
@@ -1082,23 +1082,27 @@ static void build_epilogue(struct jit_ctx *ctx, bool was_classic)* * Bit layout of `fixup` (32-bit): * -* +-----------+--------+-----------+-----------+----------+ -* | 31-27 | 26-22 | 21 | 20-16 | 15-0 | -* | | | | | | -* | FIXUP_REG | Unused | ARENA_ACC | ARENA_REG | OFFSET | -* +-----------+--------+-----------+-----------+----------+ +* +-----------+--------+-------------+-----------+-----------+----------+ +* | 31-27 | 26-23 | 22 | 21 | 20-16 | 15-0 | +* | | | | | | | +* | FIXUP_REG | Unused | ARENA_WRITE | ARENA_ACC | ARENA_REG | OFFSET | +* +-----------+--------+-------------+-----------+-----------+----------+ * * - OFFSET (16 bits): Offset used to compute address for Load/Store instruction. * - ARENA_REG (5 bits): Register that is used to calculate the address for load/store when * accessing the arena region. * - ARENA_ACCESS (1 bit): This bit is set when the faulting instruction accessed the arena region. +* - ARENA_WRITE (1 bit): This bit is set when the faulting instruction wrote to the arena region. +* It is independent of FIXUP_REG, since a read-modify-write both writes to +* memory and reads the old value into a register. * - FIXUP_REG (5 bits): Destination register for the load instruction (cleared on fault) or set to -* DONT_CLEAR if it is a store instruction. +* DONT_CLEAR if the instruction does not read into a register. */ #define BPF_FIXUP_OFFSET_MASK GENMASK(15, 0)#define BPF_FIXUP_ARENA_REG_MASK GENMASK(20, 16)#define BPF_ARENA_ACCESS BIT(21) +#define BPF_ARENA_WRITE BIT(22)#define BPF_FIXUP_REG_MASK GENMASK(31, 27)#define DONT_CLEAR 5/* Unused ARM64 register from BPF's POV */
@@ -1109,7 +1113,7 @@ bool ex_handler_bpf(const struct exception_table_entry *ex,s16 off =FIELD_GET (BPF_FIXUP_OFFSET_MASK , ex->fixup);int arena_reg =FIELD_GET (BPF_FIXUP_ARENA_REG_MASK , ex->fixup);bool is_arena = !!(ex->fixup &BPF_ARENA_ACCESS ); -bool is_write = (dst_reg ==DONT_CLEAR ); +bool is_write = !!(ex->fixup &BPF_ARENA_WRITE );unsigned long addr;if (is_arena) {
@@ -1132,7 +1136,7 @@ static int add_exception_handler(const struct bpf_insn *insn, {off_t ins_offset;s16 off = insn->off; -bool is_arena; +bool is_arena, is_write;int arena_reg;unsigned long pc;struct exception_table_entry *ex;
@@ -1181,15 +1185,18 @@ static int add_exception_handler(const struct bpf_insn *insn,/* * A load-acquire is of BPF_STX class, but reads from src_reg into * dst_reg like a BPF_LDX does, hence it must not be treated as a store -* here. +* here. A read-modify-write carrying BPF_FETCH is reported as a write +* even though it does have a register to clear, see the callers. */ -if (BPF_CLASS (insn->code) !=BPF_LDX && !bpf_atomic_is_load_acq (insn)) - dst_reg =DONT_CLEAR ; + is_write =BPF_CLASS (insn->code) !=BPF_LDX && + !bpf_atomic_is_load_acq (insn); ex->fixup =FIELD_PREP (BPF_FIXUP_REG_MASK , dst_reg);if (is_arena) { ex->fixup |=BPF_ARENA_ACCESS ; +if (is_write) + ex->fixup |=BPF_ARENA_WRITE ;/* * insn->src_reg/dst_reg holds the address in the arena region with upper 32-bits * being zero because of a preceding addr_space_cast(r<n>, 0x0, 0x1) instruction.
@@ -1876,7 +1883,7 @@ static int build_insn(const struct bpf_verifier_env *env, const struct bpf_insnbreak ; } - ret =add_exception_handler (insn, ctx, dst); + ret =add_exception_handler (insn, ctx,DONT_CLEAR );if (ret)return ret;break ;
@@ -1943,7 +1950,7 @@ static int build_insn(const struct bpf_verifier_env *env, const struct bpf_insnbreak ; } - ret =add_exception_handler (insn, ctx, dst); + ret =add_exception_handler (insn, ctx,DONT_CLEAR );if (ret)return ret;break ;
@@ -1966,7 +1973,16 @@ static int build_insn(const struct bpf_verifier_env *env, const struct bpf_insnreturn ret;if (BPF_MODE (insn->code) ==BPF_PROBE_ATOMIC ) { - ret =add_exception_handler (insn, ctx, dst); +/* +* A load-acquire reads into dst_reg, and a read-modify-write +* carrying BPF_FETCH reads the old value into src_reg, or into +* r0 for a BPF_CMPXCHG. Clear that register on fault, the +* remaining atomics have no destination register. +*/ +int load_reg =bpf_atomic_load_reg (insn); + + ret =add_exception_handler (insn, ctx, load_reg <0 ? +DONT_CLEAR : bpf2a64[load_reg]);if (ret)return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1407/1815 bpf, s390: Clear fetch destination on faulting arena atomic
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit cc3e12330599f097f0e1f792435686ddc276f26d ]
Same missing register clear as on riscv64. A RMW atomic on an arena pointer is converted to BPF_PROBE_ATOMIC and gets an exception table entry, but bpf_jit_probe_atomic_pre() only fills in the arena base and the probe offset, leaving probe->reg at the -1 that bpf_jit_probe_init() set, which bpf_jit_probe_post() writes into the entry and ex_handler_bpf() then reads back as "there is nothing to clear".
That is right for a plain BPF_{ADD,AND,OR,XOR}, which only writes memory, but an RMW carrying BPF_FETCH also reads the old value into a register:src_reg for BPF_{ADD,AND,OR,XOR} | BPF_FETCH and BPF_XCHG, and r0 for BPF_CMPXCHG. So on a fault over an unmapped arena page the program resumes at the landing pad with whatever that register held before the atomic instead of the 0 that every other BPF_PROBE_* access delivers.
Fill probe->reg in from bpf_atomic_load_reg(). Unlike x86-64 and arm64, s390x does not report arena violations from its exception handler, so there is no access direction to correct here, only the missing register clear.
--- arch/s390/net/bpf_jit_comp.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/s390/net/bpf_jit_comp.c +11 -0
@@ -771,6 +771,8 @@ static void bpf_jit_probe_atomic_pre(struct bpf_jit *jit,struct bpf_insn *insn, struct bpf_jit_probe *probe) { + int load_reg; +if (BPF_MODE (insn->code) !=BPF_PROBE_ATOMIC )return ;
@@ -780,6 +782,14 @@ static void bpf_jit_probe_atomic_pre(struct bpf_jit *jit,EMIT4 (0xb9080000 ,REG_W1 , insn->dst_reg); probe->arena_reg =REG_W1 ; probe->prg = jit->prg; +/* +* A read-modify-write carrying BPF_FETCH reads the old value into +* src_reg, or into r0 for a BPF_CMPXCHG. Clear that register on +* fault, the remaining atomics only write memory. +*/ + load_reg =bpf_atomic_load_reg (insn); +if (load_reg >=0 ) + probe->reg = reg2hex[load_reg]; } static int bpf_jit_probe_post(struct bpf_jit *jit, struct bpf_prog *fp,
@@ -1642,6 +1652,7 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,if (load_probe.prg !=-1 ) { probe.prg = jit->prg; probe.arena_reg = load_probe.arena_reg; + probe.reg = load_probe.reg; } loop_start = jit->prg;/* 0: {csy|csg} %w0,%src,off(%arena) */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1408/1815 selftests: harness: Mark test fixture objects __maybe_unused
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Matlack <[email protected]>
[ Upstream commit 37ffa24c9d07edcd414d34283e02af3f3866cf12 ]
Mark _##fixture_name##_##test_name##_object __maybe_unused since it may not ever be read. This pointer is only read in XFAIL_ADD(), which tests are not required to use.
clang made a change to -Wunused-but-set-variable (split out into its own subwarning, -Wunused-but-set-global) that causes this warning to be emitted for various selftests and can be upgraded to an error in selftest that set -Werror.
VFIO selftests have been broken since commit ff556bd98348 ("vfio:
selftests: Add -Wall and -Werror to the Makefile"), and the net selftests builds have been noisy due to -Wall.
--- tools/testing/selftests/kselftest_harness.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kselftest_harness.h +1 -1
@@ -467,7 +467,7 @@ static inline void __kselftest_memset_safe(void *s, int c, size_t n) !__atomic_test_and_set(_metadata->no_teardown, __ATOMIC_RELAXED)) \ fixture_name##_teardown(_metadata, self, variant); \ } \ - static struct __test_metadata *_##fixture_name##_##test_name##_object; \ + static struct __test_metadata *_##fixture_name##_##test_name##_object __maybe_unused; \ static void __attribute__((constructor(KSELFTEST_PRIO_TEST))) \ _register_##fixture_name##_##test_name(void) \ { \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1409/1815 selftests/bpf: vmtest.sh: Preserve command quoting when running in the VM
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <[email protected]>
[ Upstream commit 3a59f11e0f989bdd637c87151992605a6559a7cb ]
vmtest.sh captures the trailing command with command="$@", which flattens the arguments into a single space-separated string, and then pastes it into the generated guest init script:
cd /root/bpf
echo ${command}
stdbuf -oL -eL ${command}That here-doc is unquoted, so the host expands ${command} and the flattened text lands in the script verbatim. The guest bash then parses those lines as shell source, re-splitting the text on whitespace and glob-expanding it against /root/bpf. As a result any command with a glob or an argument containing spaces is corrupted before it reaches the test binary. For example:
vmtest.sh -- ./test_progs -a 'verifier_*'
has 'verifier_*' expanded in the guest into the matching object/skeleton files (verifier_align.bpf.o verifier_align.skel.h ...), so test_progs is handed a list of filenames instead of the intended name filter and runs no matching tests.
Quote each argument with printf '%q ' so the command is reproduced verbatim inside the VM: the escaped text goes through exactly one round of quote removal when the guest parses the init script, yielding the original argv with globs and special characters intact. The common case (e.g. -t <name>) is unaffected.
Only do this when there is a command to quote. printf '%q ' with no arguments still applies the format once and emits '', which the -s (debug shell) path would take for a real command and try to run.
Note this makes the trailing command strictly an argv rather than a shell
snippet: passing it pre-quoted as one word, e.g.
vmtest.sh -- "./test_progs -t foo"
no longer works, and neither does embedding guest-side shell syntax such as ';' or a redirection. 'sh -c ...' still works.
The RV64 recipe in README.rst does depend on the old double parse: it wraps the denylist in \" so the literal quotes reach the guest, whose second parse of the init script removes them. Under %q those quotes now survive into argv, and parse_test_list() strtok_r()s on ',' turns them into junk filters:
-d ",exceptions," -> ["] [exceptions] ["]
That is harmless for DENYLIST.riscv64 only because its first line is a comment, so the leading field is empty. A denylist starting with a real entry would silently lose it - ["*arena*] never matches - so drop the backslashes and let the host consume the quotes instead.
--- tools/testing/selftests/bpf/README.rst | 4 ++-- tools/testing/selftests/bpf/vmtest.sh | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/README.rst +2 -2
@@ -107,12 +107,12 @@ Docker container and local rootfs image. The overall steps are as follows: tools/testing/selftests/bpf/vmtest.sh \ -l <path of local rootfs image> -- \ ./test_progs -d \ - \"$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \ + "$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \ | cut -d'#' -f1 \ | sed -e 's/^[[:space:]]*//' \ -e 's/[[:space:]]*$//' \ | tr -s '\n' ',' \ - )\" + )" Link: https://github.com/pulehui/riscv-bpf-vmtest.git [0] Link: https://github.com/libbpf/ci/blob/main/rootfs/mkrootfs_debian.sh [1]
tools/testing/selftests/bpf/vmtest.sh +11 -2
@@ -428,8 +428,17 @@ main() if [[ $# -eq 0 && "${debug_shell}" == "no" ]]; then echo "No command specified, will run ${DEFAULT_COMMAND} in the vm" - else - command="$@" + elif [[ $# -gt 0 ]]; then + # Quote each argument so the command survives into the guest: the + # host expands ${command} into the generated init script, which + # the guest bash then parses as shell source. Without the %q + # escapes an argument with a space or a glob (e.g. -a 'verifier_*') + # is re-split and expanded against /root/bpf there. + # + # Skip this when there is no command: printf '%q ' would still + # apply the format once and emit '', which is not the empty + # command that -s (debug shell) expects. + command=$(printf '%q ' "$@") fi local kconfig_file="${OUTPUT_DIR}/latest.config"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1410/1815 ASoC: spacemit: advertise only DMA-backed DAI streams
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 0a91bb72980e4aa5f0c1be33d691e7767d7db9ed ]
The static DAI template initializes both playback and capture stream capabilities before dma-names is examined. As a result, snd_soc_dai_stream_valid() considers both directions valid even when the device only provides a single DMA channel.
Move the playback and capture capability initialization into spacemit_i2s_init_dai(), where it is performed only for the stream directions backed by a corresponding DMA channel. This preserves the existing capabilities for devices with both "tx" and "rx" DMA channels, while preventing unsupported stream directions from being advertised.
Initialize rate_min and rate_max together with the other stream capabilities to preserve the existing rate constraints.
--- sound/soc/spacemit/k1_i2s.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
sound/soc/spacemit/k1_i2s.c +4 -16
@@ -347,22 +347,6 @@ static const struct snd_soc_dai_ops spacemit_i2s_dai_ops = {static struct snd_soc_dai_driver spacemit_i2s_dai = { .ops = &spacemit_i2s_dai_ops, - .playback = { - .channels_min =1 , - .channels_max =2 , - .rates =SPACEMIT_PCM_RATES , - .rate_min =SNDRV_PCM_RATE_8000 , - .rate_max =SNDRV_PCM_RATE_48000 , - .formats =SPACEMIT_PCM_FORMATS , - }, - .capture = { - .channels_min =1 , - .channels_max =2 , - .rates =SPACEMIT_PCM_RATES , - .rate_min =SNDRV_PCM_RATE_8000 , - .rate_max =SNDRV_PCM_RATE_48000 , - .formats =SPACEMIT_PCM_FORMATS , - }, .symmetric_rate =1 , };
@@ -392,6 +376,8 @@ static int spacemit_i2s_init_dai(struct spacemit_i2s_dev *i2s, dai->playback.channels_min =1 ; dai->playback.channels_max =2 ; dai->playback.rates =SPACEMIT_PCM_RATES ; + dai->playback.rate_min =SNDRV_PCM_RATE_8000 ; + dai->playback.rate_max =SNDRV_PCM_RATE_48000 ; dai->playback.formats =SPACEMIT_PCM_FORMATS ; i2s->playback_dma_data.addr_width =DMA_SLAVE_BUSWIDTH_2_BYTES ;
@@ -404,6 +390,8 @@ static int spacemit_i2s_init_dai(struct spacemit_i2s_dev *i2s, dai->capture.channels_min =1 ; dai->capture.channels_max =2 ; dai->capture.rates =SPACEMIT_PCM_RATES ; + dai->capture.rate_min =SNDRV_PCM_RATE_8000 ; + dai->capture.rate_max =SNDRV_PCM_RATE_48000 ; dai->capture.formats =SPACEMIT_PCM_FORMATS ; i2s->capture_dma_data.addr_width =DMA_SLAVE_BUSWIDTH_2_BYTES ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1411/1815 spi: img-spfi: dont disable runtime PM on DMA deferred probe
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 923e41ed59511cffe98357c7d58d0294a1c157ee ]
When dma_request_chan() returns -EPROBE_DEFER, the error path jumps to disable_pm and calls pm_runtime_disable() even though pm_runtime_enable() was never called, leaving disable_depth unbalanced and the device permanently PM-disabled.
Route the defer path through free_dma to skip pm_runtime_disable().
--- drivers/spi/spi-img-spfi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/spi-img-spfi.c +3 -2
@@ -611,7 +611,7 @@ static int img_spfi_probe(struct platform_device *pdev) ret =PTR_ERR (spfi->tx_ch); spfi->tx_ch =NULL ;if (ret == -EPROBE_DEFER ) - goto disable_pm; + goto free_dma; } spfi->rx_ch =dma_request_chan (spfi->dev,"rx" );
@@ -619,7 +619,7 @@ static int img_spfi_probe(struct platform_device *pdev) ret =PTR_ERR (spfi->rx_ch); spfi->rx_ch =NULL ;if (ret == -EPROBE_DEFER ) - goto disable_pm; + goto free_dma; }if (!spfi->tx_ch || !spfi->rx_ch) {
@@ -647,6 +647,7 @@ static int img_spfi_probe(struct platform_device *pdev) disable_pm:pm_runtime_disable (spfi->dev); +free_dma:if (spfi->rx_ch)dma_release_channel (spfi->rx_ch);if (spfi->tx_ch)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1412/1815 PCI/ASPM: Disable/restore ASPM on every function for multi-function devices
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krishna Chaitanya Chundru <[email protected]>
[ Upstream commit 733cd811b3ac50586164a0864c4351fe23e21890 ]
pcie_aspm_cap_init() disables ASPM L0s/L1 before touching L1SS config, then restores the pre-existing state afterward. Both steps only ever touched link->downstream, i.e. function 0 of the downstream component, leaving sibling functions (>0) on a multi-function device untouched.
This means the "disable" step does not actually disable ASPM link-wide on a multi-function device: a sibling function can still have L1 enabled even after this step runs. PCIe r7.0, sec 7.5.3.7, recommends programming the same ASPM Control value for all functions of a multi-function device, and pcie_config_aspm_link() already loops over every function on the bus for exactly this reason.
Loop over every function on linkbus->devices for both the disable and restore steps, keeping the existing sec 7.5.3.7 ordering (disable downstream functions before upstream, restore upstream before downstream functions). The masked pcie_capability_clear_and_set_word() accessor from the previous commit makes this safe: it only ever touches the ASPM Control bits, so function-specific bits elsewhere in LNKCTL (e.g. Read Completion Boundary, CLKREQ Enable) on sibling functions are left untouched.
--- drivers/pci/pcie/aspm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pci/pcie/aspm.c +6 -3
@@ -861,6 +861,7 @@ static void pcie_aspm_override_default_link_state(struct pcie_link_state *link)static void pcie_aspm_cap_init (struct pcie_link_state *link,int blacklist) {struct pci_dev *child = link->downstream, *parent = link->pdev; +struct pci_dev *fn;u16 parent_lnkctl, child_lnkctl;struct pci_bus *linkbus = parent->subordinate;
@@ -894,8 +895,9 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)/* Disable L0s/L1 before updating L1SS config */ if (FIELD_GET (PCI_EXP_LNKCTL_ASPMC , child_lnkctl) ||FIELD_GET (PCI_EXP_LNKCTL_ASPMC , parent_lnkctl)) { -pcie_capability_clear_and_set_word (child,PCI_EXP_LNKCTL , -PCI_EXP_LNKCTL_ASPMC ,0 ); +list_for_each_entry (fn, &linkbus->devices, bus_list) +pcie_capability_clear_and_set_word (fn,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_ASPMC ,0 );pcie_capability_clear_and_set_word (parent,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_ASPMC ,0 ); }
@@ -930,7 +932,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)pcie_capability_clear_and_set_word (parent,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_ASPMC , parent_lnkctl &PCI_EXP_LNKCTL_ASPMC ); -pcie_capability_clear_and_set_word (child,PCI_EXP_LNKCTL , +list_for_each_entry (fn, &linkbus->devices, bus_list) +pcie_capability_clear_and_set_word (fn,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_ASPMC , child_lnkctl &PCI_EXP_LNKCTL_ASPMC ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1413/1815 objtool/klp: Fix vmlinux .klp.symid link error for .exitcall.exit symbols
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Puranjay Mohan <[email protected]>
[ Upstream commit 6656cf1e975aa152c082012b820efffaebd49979 ]
Building a kernel via klp-build fails to link:
__exitcall_aes_mod_exit' referenced in section .klp.symid' of vmlinux.o: defined in discarded section .exitcall.exit' of vmlinux.o __exitcall_dax_exit' referenced in section .klp.symid' of vmlinux.o: defined in discarded section .exitcall.exit' of vmlinux.o __exitcall_hid_exit' referenced in section .klp.symid' of vmlinux.o: defined in discarded section .exitcall.exit' of vmlinux.o __exitcall_usb_serial_module_exit' referenced in section .klp.symid' of vmlinux.o: defined in discarded section .exitcall.exit' of vmlinux.o
module_exit() on a built-in emits a static __exitcall_$fn pointer into .exitcall.exit, which vmlinux.lds.h discards unconditionally via EXIT_CALL. When two built-in translation units define a module_exit() function of the same name, the resulting local symbols collide, symid_needed() sees a duplicate and emits a .klp.symid entry for each, referencing symbols the linker then throws away.
Same-named module_exit() functions are not rare:
dax_exit drivers/dax/device.c, drivers/dax/fsdev.c hid_exit drivers/hid/hid-core.c, drivers/hid/usbhid/hid-core.c aes_mod_exit arch/arm64/crypto/aes-ce-ccm-glue.c, lib/crypto/aes.c usb_serial_module_exit module_usb_serial_driver() expands to this fixed
name in each of its ~49 users
The last one makes the collision structural rather than accidental: any kernel with two built-in USB serial drivers has it. This is not arch specific either; it only requires the objects to be built in rather than modular, which is why a monolithic config trips it while a typical distro config does not.
Add .exitcall.exit to the discarded section list so its symbols don't get symids.
This is the same failure mode as "objtool/klp: Fix vmlinux .klp.symid link error for .no_trim_symbol symbols", for another unconditionally discarded allocated section.
--- tools/objtool/klp-symid.c | 1 + 1 file changed, 1 insertion(+)
tools/objtool/klp-symid.c +1 -0
@@ -30,6 +30,7 @@static const char *const discarded_secs[] = {".discard" , +".exitcall.exit" ,".modinfo" ,".no_trim_symbol" ,"__tracepoint_check" ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1414/1815 objtool/klp: Fix .kcfi_traps special section extraction
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit 7df1638df97b2aaaff4731b72d4940053257c952 ]
create_fake_symbols() creates a symbol per entry for special sections. It does so in two steps: first for the sections which have ANNOTATE_DATA_SPECIAL annotations, then for the rest, using entsize or the reloc count to infer the entry size. The second step skips the sections already handled by the first one by looking for a symbol at offset 0.
That heuristic is too fuzzy: with Clang and CONFIG_CFI, it misfires on .kcfi_traps because Clang emits a .Ltmp* assembler-local label at the start of the section, so no symbols are created and clone_special_sections() extracts nothing. klp-build still reports SUCCESS, but the livepatch module has no __kcfi_traps section and the traps for the patched functions are lost.
Look for the actual fake symbols created by the first step instead.
--- tools/objtool/include/objtool/elf.h | 1 + tools/objtool/klp-diff.c | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-)
tools/objtool/include/objtool/elf.h +1 -0
@@ -97,6 +97,7 @@ struct symbol { u8 included : 1; u8 klp : 1; u8 dont_correlate : 1; + u8 fake : 1;struct list_head pv_target;struct reloc *relocs;struct section *group_sec;
tools/objtool/klp-diff.c +24 -2
@@ -1597,6 +1597,7 @@ static int create_fake_symbol(struct elf *elf, struct section *sec, unsigned long offset, size_t size) { char name[SYM_NAME_LEN]; +struct symbol *sym;unsigned int type;static int ctr;char *c;
@@ -1613,7 +1614,24 @@ static int create_fake_symbol(struct elf *elf, struct section *sec,* while still allowing objdump to disassemble it. */ type =is_text_sec (sec) ?STT_NOTYPE :STT_OBJECT ; -return elf_create_symbol (elf, name, sec,STB_LOCAL , type, offset, size) ?0 :-1 ; + + sym =elf_create_symbol (elf, name, sec,STB_LOCAL , type, offset, size); +if (!sym) +return -1 ; + + sym->fake =1 ; +return 0 ; +} + +static bool has_fake_symbols (struct section *sec) +{ +struct symbol *sym; + +sec_for_each_sym (sec, sym) +if (sym->fake) +return true; + +return false; }/*
@@ -1705,7 +1723,11 @@ static int create_fake_symbols(struct elf *elf)unsigned int entry_size;unsigned long offset; -if (!is_special_section (sec) ||find_symbol_by_offset (sec,0 )) +if (!is_special_section (sec)) +continue ; + +/* Skip sections already handled by step 1 above */ +if (has_fake_symbols (sec))continue ;if (!sec->rsec) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1415/1815 power: supply: bd71815: Fix temperature reading
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Vaittinen <[email protected]>
[ Upstream commit c15f0eabec5a051cb8190fa2bff3b211730f4acb ]
The temperature read from the hardware is never returned to caller. Furthermore, the check for temperature validity is wrong. This yields garbage value to be returned to caller, and also detection of bad values read from hardware to fail.
--- drivers/power/supply/bd71828-power.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/bd71828-power.c +2 -2
@@ -224,13 +224,13 @@ static int bd71815_get_temp(struct bd71828_power *pwr, int *temp)if (ret)return ret; - t =200 - t; -if (t >200 ) {dev_err (pwr->dev,"Failed to read battery temperature\n" );return -ENODATA ; } + *temp =200 - t; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1416/1815 power: supply: bd71828: Fix current direction
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Vaittinen <[email protected]>
[ Upstream commit d012fab12fed2053e0dca4c8cd4e2b2053afabfb ]
Both the current and the average current registers contain same 'direction' -bit to denote the direction of the current. The code reading these registers incorrectly caches the direction read from the first register, and uses it also for the second.
Fix this by initializing the direction bit for both register reads.
--- drivers/power/supply/bd71828-power.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/power/supply/bd71828-power.c +3 -2
@@ -191,12 +191,13 @@ static int bd71828_get_current_ds_adc(struct bd71828_power *pwr, int *curr, int {__be16 tmp_curr;char *tmp = (char *)&tmp_curr; -int dir =1 ;int regs[] = { pwr->regs->ibat, pwr->regs->ibat_avg };int *vals[] = { curr, curr_avg };int ret, i; -for (dir =1 , i =0 ; i <ARRAY_SIZE (regs); i++) { +for (i =0 ; i <ARRAY_SIZE (regs); i++) { +int dir =1 ; + ret =regmap_bulk_read (pwr->regmap, regs[i], &tmp_curr,sizeof (tmp_curr));if (ret)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1417/1815 power: supply: bd71828: Drop duplicate power-supply property
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Vaittinen <[email protected]>
[ Upstream commit 6605209ceb53eaa25582d1f4726217bd09eff392 ]
The POWER_SUPPLY_PROP_HEALTH is added into property-array twice.
Drop the duplicate property.
--- drivers/power/supply/bd71828-power.c | 1 - 1 file changed, 1 deletion(-)
drivers/power/supply/bd71828-power.c +0 -1
@@ -639,7 +639,6 @@ static const enum power_supply_property bd71828_charger_props[] = {static const enum power_supply_property bd71828_battery_props[] = {POWER_SUPPLY_PROP_STATUS , -POWER_SUPPLY_PROP_HEALTH ,POWER_SUPPLY_PROP_VOLTAGE_NOW ,POWER_SUPPLY_PROP_HEALTH ,POWER_SUPPLY_PROP_PRESENT ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1418/1815 power: supply: bd71828: Do not hide errors
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Vaittinen <[email protected]>
[ Upstream commit a3c841e420e124783a805919ab072551543e477b ]
The bd71828 reports success / continues operation even when some regmap operations fail. This can lead incorrect data to be reported.
Return appropriate errors when operations fail.
--- drivers/power/supply/bd71828-power.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/power/supply/bd71828-power.c +7 -3
@@ -455,8 +455,10 @@ static int bd71828_charger_get_property(struct power_supply *psy,switch (psp) {case POWER_SUPPLY_PROP_ONLINE : ret =get_chg_online (pwr, &online); -if (!ret) - val->intval = online; +if (ret) +return ret; + + val->intval = online;break ;case POWER_SUPPLY_PROP_VOLTAGE_NOW : ret = bd7182x_read16_himask(pwr, pwr->regs->vdcin,
@@ -1217,7 +1219,9 @@ static int bd71828_power_probe(struct platform_device *pdev)return dev_err_probe (&pdev->dev, ret,"sense resistor missing\n" );dev_set_drvdata (&pdev->dev, pwr); -bd71828_init_hardware (pwr); + ret =bd71828_init_hardware (pwr); +if (ret) +return dev_err_probe (&pdev->dev, ret,"hardware init failed\n" ); bat_cfg.drv_data = pwr; bat_cfg.fwnode =dev_fwnode (&pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1419/1815 power: supply: bd99954: Drop bad register fields
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Vaittinen <[email protected]>
[ Upstream commit 177299384a224377b4152242d875e752e5958c02 ]
The bd99954 driver creates regmap fields for all the registers. All the fields for VBUS_UCD_FCTRL_SET (extended command 0x33) are accidentally created for VCC_UCD_FCTRL_SET (extended command 0x2b), causing all reads/writes for the fields to access wrong register. Luckily the fields for VBUS_UCD_FCTRL_SET are unused.
Taking a look at the data-sheet all the fields in the VBUS_UCD_FCTRL_SET are marked as: "In normal operation, please don’t set these registers" with not much of additional documentation. As the fields are wrong and because there seems to be no users of the fields - it is better to just drop them. This will also decrease the memory footprint.
Drop incorrect VBUS_UCD_FCTRL_SET fields.
Datasheet: https://fscdn.rohm.com/en/products/databook/datasheet/ic/power/battery_management/bd99954xxx-e.pdf
--- drivers/power/supply/bd99954-charger.h | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
drivers/power/supply/bd99954-charger.h +1 -22
@@ -279,17 +279,7 @@ enum bd9995x_fields {F_VBUS_EXTID ,F_VBUS_IDRDET ,F_VBUS_INDO , -F_VBUS_UCDSWEN , -F_VBUS_RREF_EN , -F_VBUS_DPPU_EN , -F_VBUS_DPREF_EN , -F_VBUS_DMREF_EN , -F_VBUS_DPDET_EN , -F_VBUS_DMDET_EN , -F_VBUS_DPSINK_EN , -F_VBUS_DMSINK_EN , -F_VBUS_DP_BUFF_EN , -F_VBUS_DM_BUFF_EN , +F_VBUS_EXTCLKENBL ,F_VBUS_PLSTESTEN , F_VBUS_UCDSWEN_TSTENB,
@@ -626,17 +616,6 @@ static const struct reg_field bd9995x_reg_fields[] = { [F_VBUS_EXTID] = REG_FIELD(VBUS_IDD_STATUS, 5, 5), [F_VBUS_IDRDET] = REG_FIELD(VBUS_IDD_STATUS, 4, 4), [F_VBUS_INDO] = REG_FIELD(VBUS_IDD_STATUS, 0, 3), - [F_VBUS_UCDSWEN] = REG_FIELD(VCC_UCD_FCTRL_SET, 10, 10), - [F_VBUS_RREF_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 9, 9), - [F_VBUS_DPPU_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 8, 8), - [F_VBUS_DPREF_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 7, 7), - [F_VBUS_DMREF_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 6, 6), - [F_VBUS_DPDET_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 5, 5), - [F_VBUS_DMDET_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 4, 4), - [F_VBUS_DPSINK_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 3, 3), - [F_VBUS_DMSINK_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 2, 2), - [F_VBUS_DP_BUFF_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 1, 1), - [F_VBUS_DM_BUFF_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 0, 0), [F_VBUS_EXTCLKENBL] = REG_FIELD(VBUS_UCD_FCTRL_EN, 15, 15), [F_VBUS_PLSTESTEN] = REG_FIELD(VBUS_UCD_FCTRL_EN, 14, 14),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1420/1815 power: supply: bq27xxx: bq27520g4: fix REG_TTES address
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henrik Grimler <[email protected]>
[ Upstream commit c774a623c821a173c950e1297f8e8c85a89455be ]
According to the technical reference manual the StandbyTimeToEmpty (TTES) register is at 0x1a, not 0x1c. At 0x1c StateOfHealth instead resides.
--- drivers/power/supply/bq27xxx_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/bq27xxx_battery.c +1 -1
@@ -330,7 +330,7 @@ static u8 [BQ27XXX_REG_FLAGS] = 0x0a, [BQ27XXX_REG_TTE] = 0x16, [BQ27XXX_REG_TTF] = INVALID_REG_ADDR, - [BQ27XXX_REG_TTES] = 0x1c, + [BQ27XXX_REG_TTES] = 0x1a, [BQ27XXX_REG_TTECP] = INVALID_REG_ADDR, [BQ27XXX_REG_NAC] = 0x0c, [BQ27XXX_REG_RC] = 0x10,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1421/1815 power: supply: bq27xxx: bq28z610: fix invalid AverageEnergy address
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henrik Grimler <[email protected]>
[ Upstream commit e9387e9ab5121f330d313afb90430c02200f9782 ]
bq28z610 currently uses the AveragePower reg, 0x22, for reading both AveragePower and AvailableEnergy. The technical reference manual does not mention AvailableEnergy, and it does not make sense to read a cumulative, always positive, property like AvailableEnergy from a rate property like AveragePower. Set REG_AE as invalid to fix it.
--- drivers/power/supply/bq27xxx_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/bq27xxx_battery.c +1 -1
@@ -516,7 +516,7 @@ static u8 [BQ27XXX_REG_RC] = 0x10, [BQ27XXX_REG_FCC] = 0x12, [BQ27XXX_REG_CYCT] = 0x2a, - [BQ27XXX_REG_AE] = 0x22, + [BQ27XXX_REG_AE] = INVALID_REG_ADDR, [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP] = 0x22,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1422/1815 power: supply: bq27xxx: bq27z561: fix invalid AverageEnergy address
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henrik Grimler <[email protected]>
[ Upstream commit 2da28b059e0ddcd2e1956eeae383246207965573 ]
bq27z561 currently uses the AveragePower reg, 0x22, for reading both AveragePower and AvailableEnergy. The technical reference manual does not mention AvailableEnergy, and it does not make sense to read a cumulative, always positive, property like AvailableEnergy from a rate property like AveragePower. Set REG_AE as invalid to fix it.
--- drivers/power/supply/bq27xxx_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/bq27xxx_battery.c +1 -1
@@ -495,7 +495,7 @@ static u8 [BQ27XXX_REG_RC] = 0x10, [BQ27XXX_REG_FCC] = 0x12, [BQ27XXX_REG_CYCT] = 0x2a, - [BQ27XXX_REG_AE] = 0x22, + [BQ27XXX_REG_AE] = INVALID_REG_ADDR, [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP] = 0x22,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1423/1815 selftests: drv-net: so_txtime: fix qdisc replace with handle
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
[ Upstream commit dbf34acdfb29781dd4a8a86f7111d99c016fc7e8 ]
The blamed commit updated a tc replace command by adding a handle.
- tc(f"qdisc replace dev {ifname} root {qdisc} {optargs}")
+ tc(f"qdisc replace dev {ifname} root handle 1: {qdisc} {optargs}")
This breaks the test if the root qdisc already has that handle and is of different kind, with
"Invalid qdisc name: must match existing qdisc."
If no handle is asked, or the kind differs, tc replace removes the old qdisc and grafts a new one.
If a handle is asked and exists, tc replace tries to change the qdisc in place, for which the kind must be the same.
It does not trigger in all setups, like netdevsim or debian 13, which do not have root handle 1:. But it is a common root handle.
Solve the bug by first deleting the existing root qdisc if one exists.
Wrap that command in a try block, because it will fail for default qdiscs with handle 0: with
"Error: Cannot delete qdisc with handle of zero."
--- tools/testing/selftests/drivers/net/so_txtime.py | 5 +++++ 1 file changed, 5 insertions(+)
tools/testing/selftests/drivers/net/so_txtime.py +5 -0
@@ -12,6 +12,7 @@ import time from lib.py import ksft_exit, ksft_run, ksft_variants from lib.py import KsftNamedVariant, KsftSkipEx from lib.py import NetDrvEpEnv, bkg, cmd, defer, tc +from lib.py import CmdExitFailure def test_so_txtime(cfg, clockid, ipver, args_tx, args_rx, expect_success):
@@ -45,6 +46,10 @@ def _qdisc_setup(ifname, qdisc, optargs=""): """ orig = tc(f"qdisc show dev {ifname} root", json=True)[0].get("kind", None) defer(tc, f"qdisc replace dev {ifname} root {orig}") + try: + tc(f"qdisc del dev {ifname} root") + except CmdExitFailure: + pass tc(f"qdisc replace dev {ifname} root handle 1: {qdisc} {optargs}")
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1424/1815 bpf: Fix UAF in bpf_trampoline_multi_attach_free on update failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Zhu <[email protected]>
[ Upstream commit 0253073fb7d79a2dd2eae9581ea16db2aef395a6 ]
When bpf_trampoline_update() fails before modify_fentry_multi()/ unregister_fentry_multi() is called, cur_image is unchanged (cur_image == old_image) and ftrace still calls into it. Freeing old_image in that case causes a UAF.
Only free old_image when it differs from cur_image.
--- kernel/bpf/trampoline.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
kernel/bpf/trampoline.c +11 -1
@@ -1592,7 +1592,17 @@ static void bpf_trampoline_multi_attach_init(struct bpf_trampoline *tr)static void bpf_trampoline_multi_attach_free (struct bpf_trampoline *tr) { -if (tr->multi_attach.old_image) +/* +* Only free old_image if it is no longer the active image. +* When bpf_trampoline_update() fails before modify_fentry_multi()/ +* unregister_fentry_multi() is called, cur_image is unchanged +* (cur_image == old_image) and ftrace still points to it. Freeing +* it would cause a UAF when ftrace calls into the freed memory. +* On success, cur_image is either a new image or NULL, so +* old_image != cur_image means the image is stale. +*/ +if (tr->multi_attach.old_image && + tr->multi_attach.old_image != tr->cur_image)bpf_tramp_image_put (tr->multi_attach.old_image); tr->multi_attach.old_image =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1425/1815 selftests/namespaces: Fix racy pipe handshake in timens and pidns_separate
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo B. Marlière (SUSE) <[email protected]>
[ Upstream commit dcacab904fe78d60840ba947a104993ee9ded887 ]
In timens_separate and pidns_separate both the child and the grandchild write a 'Y' readiness byte to the same pipe, but the parent expects a single 'Y' followed by the grandchild's pid. If the grandchild's byte arrives first, the parent takes it for the child's and reads the pid misaligned, ending up with a garbage value.
The parent stores that pid in self->grandchild_pid so that FIXTURE_TEARDOWN() can kill the grandchild. A garbage pid leaves the real grandchild alive in pause(), holding the test runner's TAP pipe open and hanging the whole collection.
The grandchild has nothing to report, so drop its write() and leave the child as the sole writer.
--- tools/testing/selftests/namespaces/nsid_test.c | 4 ---- 1 file changed, 4 deletions(-)
tools/testing/selftests/namespaces/nsid_test.c +0 -4
@@ -649,8 +649,6 @@ TEST_F(nsid, timens_separate)/* Fork a grandchild to actually enter the new namespace */ pid_t grandchild =fork ();if (grandchild ==0 ) { -/* Grandchild is in the new namespace */ -write (pipefd[1 ],"Y" ,1 );close (pipefd[1 ]);pause ();_exit (0 );
@@ -771,8 +769,6 @@ TEST_F(nsid, pidns_separate)/* Fork a grandchild to actually enter the new namespace */ pid_t grandchild =fork ();if (grandchild ==0 ) { -/* Grandchild is in the new namespace */ -write (pipefd[1 ],"Y" ,1 );close (pipefd[1 ]);pause ();_exit (0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1426/1815 sched/isolation: Defer freeing of cpumask memblock memory to initcall
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <[email protected]>
[ Upstream commit 2b58c749b8c5244e259a0230bc57b10b010dc545 ]
When testing a linux-next kernel with commit 59bd1d914bb5 ("memblock:
warn when freeing reserved memory before memory map is initialized"), the following warning was hit when there was a "nohz_full" kernel boot parameter.
Cannot free reserved memory because of deferred initialization of the memory map
WARNING: mm/memblock.c:904 at __free_reserved_area+0xde/0xf0, CPU#0: swapper/0/0
:
Call Trace:
<TASK>
memblock_phys_free+0xcb/0x100
housekeeping_init+0x14c/0x170
start_kernel+0x207/0x450
x86_64_start_reservations+0x24/0x30
x86_64_start_kernel+0xda/0xe0
common_startup_64+0x13e/0x141
</TASK>IOW, we shouldn't free memblock allocated memory so early in the boot process when memory map isn't fully initialized in deferred_init_memmap().
Fix it by saving the housekeeping cpumask memblock memory to be freed into a llist free list in housekeeping_init() and add a new housekeeping_late_init() helper to defer the actual freeing of memblock memory to when initcall's are being processed. The cpumask memblock memory is treated as a llist_node with the size of a "long" type which is also smallest cpumask size that can be allocated.
The non-atomic version of the llist APIs are used as there is no contention.
This commit depends on the presence of commit 7c2eee9c1367 ("memblock:
don't touch memblock arrays when memblock_free() is called late") to prevent a KASAN UAF bug report [1].
[1] https://lore.kernel.org/lkml/[email protected]/
--- kernel/sched/isolation.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
kernel/sched/isolation.c +15 -1
@@ -8,6 +8,7 @@* */ #include <linux/sched/isolation.h> +#include <linux/llist.h> #include <linux/pci.h> #include "sched.h"
@@ -27,6 +28,7 @@ struct housekeeping { };static struct housekeeping housekeeping; +static __initdata LLIST_HEAD (memblock_freelist);bool housekeeping_enabled (enum hk_type type) {
@@ -189,10 +191,22 @@ void __init housekeeping_init(void)WARN_ON_ONCE (cpumask_empty (omask));cpumask_copy (nmask, omask);RCU_INIT_POINTER (housekeeping.cpumasks[type], nmask); -memblock_free (omask,cpumask_size ()); +__llist_add ((struct llist_node *)omask, &memblock_freelist); } } +static int __init housekeeping_late_init (void ) +{ +struct llist_node *llnode, *pos, *t; + +/* Free allocated memblock memory, if any */ + llnode =__llist_del_all (&memblock_freelist); +llist_for_each_safe (pos, t, llnode) +memblock_free (pos,cpumask_size ()); +return 0 ; +} +pure_initcall (housekeeping_late_init); +static void __init housekeeping_setup_type (enum hk_type type,cpumask_var_t housekeeping_staging) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1427/1815 xenbus: Unregister reboot notifier on init 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 d330fb86a7170f845123ae82d95df440fad9b707 ]
xs_init() registers xs_reboot_nb before initializing XenStore communications and starting xenwatch. If either operation fails, the notifier remains registered and a later initialization attempt can hit a duplicate registration.
Check the notifier registration result and unregister it on every subsequent failure path.
Message-ID: <[email protected]>
--- drivers/xen/xenbus/xenbus_xs.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/xen/xenbus/xenbus_xs.c +12 -4
@@ -915,19 +915,27 @@ int xs_init(void)int err;struct task_struct *task; -register_reboot_notifier (&xs_reboot_nb); + err =register_reboot_notifier (&xs_reboot_nb); +if (err) +return err;/* Initialize the shared memory rings to talk to xenstored */ err =xb_init_comms ();if (err) -return err; + goto err_unregister_reboot_notifier; task =kthread_run (xenwatch_thread,NULL ,"xenwatch" ); -if (IS_ERR (task)) -return PTR_ERR (task); +if (IS_ERR (task)) { + err =PTR_ERR (task); + goto err_unregister_reboot_notifier; + }/* shutdown watches for kexec boot */ xs_reset_watches ();return 0 ; + +err_unregister_reboot_notifier: +unregister_reboot_notifier (&xs_reboot_nb); +return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1428/1815 s390/debug: Fix deadlock during unregister
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Oberparleiter <[email protected]>
[ Upstream commit 445c31ac638fd1af203d79bdf25fc0cb3149fbbc ]
Unregistering an s390dbf debug area while one of the associated debugfs files is being written to can cause a deadlock:
$ echo >.../vmur/level $ rmmod vmur
===================================================
debugfs write
debugfs_file_get()
debug_unregister()
mutex_lock(debug_mutex)
debugfs_remove()
wait for debugfs_file_put()
debug_file_ops.write()
debug_input()
mutex_lock(debug_mutex) ==> DEADLOCKFix this by splitting debug_unregister() into an s390dbf and debugfs part, and running only the s390dbf part with debug_mutex locked.
--- arch/s390/kernel/debug.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/s390/kernel/debug.c +8 -2
@@ -993,8 +993,8 @@ void debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas)mutex_unlock (&debug_mutex); } -/* Remove debugfs entries and remove from internal list. */ -static void _debug_unregister (debug_info_t *id) +/* Remove debugfs entries. */ +static void _debug_unregister_debugfs (debug_info_t *id) {int i;
@@ -1004,6 +1004,11 @@ static void _debug_unregister(debug_info_t *id)debugfs_remove (id->debugfs_entries[i]); }debugfs_remove (id->debugfs_root_entry); +} + +/* Remove from internal list. */ +static void _debug_unregister (debug_info_t *id) +{if (id == debug_area_first) debug_area_first = id->next;if (id == debug_area_last)
@@ -1029,6 +1034,7 @@ void debug_unregister(debug_info_t *id)mutex_lock (&debug_mutex);_debug_unregister (id);mutex_unlock (&debug_mutex); +_debug_unregister_debugfs (id);debug_info_put (id); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1429/1815 clocksource/drivers/clps711x: Do not unmap clocksource MMIO
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 e998c6300ef4e062a704ee17b5a812c0b595cf42 ]
clps711x_clksrc_init() stores the timer base address in the static tcd pointer and registers it as both the clocksource MMIO address and the sched_clock read address.
The clocksource init path must therefore keep the mapping alive after clps711x_timer_init() returns. However, the shared unmap_io exit path is also reached after successful clocksource registration, so the MMIO mapping is torn down while the clocksource and sched_clock readers may still access it.
Return directly after successful clocksource registration and leave the mapping alive for the registered readers. Keep the unmap_io path for the error paths and for the clockevent init path.
--- drivers/clocksource/clps711x-timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/clps711x-timer.c +1 -1
@@ -94,7 +94,7 @@ static int __init clps711x_timer_init(struct device_node *np)switch (of_alias_get_id (np,"timer" )) {case CLPS711X_CLKSRC_CLOCKSOURCE :clps711x_clksrc_init (clock, base); -break ; +return 0 ;case CLPS711X_CLKSRC_CLOCKEVENT : ret =_clps711x_clkevt_init (clock, base, irq);break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1430/1815 clocksource/drivers/samsung_pwm: Switch to raw_spinlock_t type
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 3b212f9d70805d91febae01d618868f4860e267c ]
Samsung PWM timer might be used as a clock source on some legacy systems. When PREEMPT_RT is enabled on ARM, regular spinlock is converted to a sleeping lock (mutex-based), which must not be used in atomic context such as hard interrupt handlers. Switch the samsung_pwm_lock to the raw_spinlock, which remains a true non-sleeping spinlock even under PREEMPT_RT.
--- drivers/clocksource/samsung_pwm_timer.c | 22 +++++++++++----------- drivers/pwm/pwm-samsung.c | 22 +++++++++++----------- include/clocksource/samsung_pwm.h | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-)
drivers/clocksource/samsung_pwm_timer.c +11 -11
@@ -56,7 +56,7 @@#define TCON_AUTORELOAD (chan) \ ((chan < 5) ? _TCON_AUTORELOAD(chan) : _TCON_AUTORELOAD4(chan)) -DEFINE_SPINLOCK (samsung_pwm_lock); +DEFINE_RAW_SPINLOCK (samsung_pwm_lock);EXPORT_SYMBOL (samsung_pwm_lock);struct samsung_pwm_clocksource {
@@ -87,14 +87,14 @@ static void samsung_timer_set_prescale(unsigned int channel, u16 prescale)if (channel >=2 ) shift =TCFG0_PRESCALER1_SHIFT ; -spin_lock_irqsave (&samsung_pwm_lock, flags); +raw_spin_lock_irqsave (&samsung_pwm_lock, flags); reg =readl (pwm.base +REG_TCFG0 ); reg &= ~(TCFG0_PRESCALER_MASK << shift); reg |= (prescale -1 ) << shift;writel (reg, pwm.base +REG_TCFG0 ); -spin_unlock_irqrestore (&samsung_pwm_lock, flags); +raw_spin_unlock_irqrestore (&samsung_pwm_lock, flags); }static void samsung_timer_set_divisor (unsigned int channel,u8 divisor)
@@ -106,14 +106,14 @@ static void samsung_timer_set_divisor(unsigned int channel, u8 divisor) bits = (fls (divisor) -1 ) - pwm.variant.div_base; -spin_lock_irqsave (&samsung_pwm_lock, flags); +raw_spin_lock_irqsave (&samsung_pwm_lock, flags); reg =readl (pwm.base +REG_TCFG1 ); reg &= ~(TCFG1_MUX_MASK << shift); reg |= bits << shift;writel (reg, pwm.base +REG_TCFG1 ); -spin_unlock_irqrestore (&samsung_pwm_lock, flags); +raw_spin_unlock_irqrestore (&samsung_pwm_lock, flags); }static void samsung_time_stop (unsigned int channel)
@@ -124,13 +124,13 @@ static void samsung_time_stop(unsigned int channel)if (channel >0 ) ++channel; -spin_lock_irqsave (&samsung_pwm_lock, flags); +raw_spin_lock_irqsave (&samsung_pwm_lock, flags); tcon =readl_relaxed (pwm.base +REG_TCON ); tcon &= ~TCON_START (channel);writel_relaxed (tcon, pwm.base +REG_TCON ); -spin_unlock_irqrestore (&samsung_pwm_lock, flags); +raw_spin_unlock_irqrestore (&samsung_pwm_lock, flags); }static void samsung_time_setup (unsigned int channel,unsigned long tcnt)
@@ -142,7 +142,7 @@ static void samsung_time_setup(unsigned int channel, unsigned long tcnt)if (tcon_chan >0 ) ++tcon_chan; -spin_lock_irqsave (&samsung_pwm_lock, flags); +raw_spin_lock_irqsave (&samsung_pwm_lock, flags); tcon =readl_relaxed (pwm.base +REG_TCON );
@@ -153,7 +153,7 @@ static void samsung_time_setup(unsigned int channel, unsigned long tcnt)writel_relaxed (tcnt, pwm.base +REG_TCMPB (channel));writel_relaxed (tcon, pwm.base +REG_TCON ); -spin_unlock_irqrestore (&samsung_pwm_lock, flags); +raw_spin_unlock_irqrestore (&samsung_pwm_lock, flags); }static void samsung_time_start (unsigned int channel,bool periodic)
@@ -164,7 +164,7 @@ static void samsung_time_start(unsigned int channel, bool periodic)if (channel >0 ) ++channel; -spin_lock_irqsave (&samsung_pwm_lock, flags); +raw_spin_lock_irqsave (&samsung_pwm_lock, flags); tcon =readl_relaxed (pwm.base +REG_TCON );
@@ -178,7 +178,7 @@ static void samsung_time_start(unsigned int channel, bool periodic)writel_relaxed (tcon, pwm.base +REG_TCON ); -spin_unlock_irqrestore (&samsung_pwm_lock, flags); +raw_spin_unlock_irqrestore (&samsung_pwm_lock, flags); } static int samsung_set_next_event(unsigned long cycles,
drivers/pwm/pwm-samsung.c +11 -11
@@ -102,7 +102,7 @@ struct samsung_pwm_chip {* IP. Should this change, both drivers will need to be modified to * properly synchronize accesses to particular instances. */ -static DEFINE_SPINLOCK (samsung_pwm_lock); +static DEFINE_RAW_SPINLOCK (samsung_pwm_lock);#endif static inline
@@ -141,14 +141,14 @@ static void pwm_samsung_set_divisor(struct samsung_pwm_chip *our_chip, bits = (fls (divisor) -1 ) - our_chip->variant.div_base; -spin_lock_irqsave (&samsung_pwm_lock, flags); +raw_spin_lock_irqsave (&samsung_pwm_lock, flags); reg =readl (our_chip->base +REG_TCFG1 ); reg &= ~(TCFG1_MUX_MASK << shift); reg |= bits << shift;writel (reg, our_chip->base +REG_TCFG1 ); -spin_unlock_irqrestore (&samsung_pwm_lock, flags); +raw_spin_unlock_irqrestore (&samsung_pwm_lock, flags); }static int pwm_samsung_is_tdiv (struct samsung_pwm_chip *our_chip,unsigned int chan)
@@ -249,7 +249,7 @@ static int pwm_samsung_enable(struct pwm_chip *chip, struct pwm_device *pwm)unsigned long flags;u32 tcon; -spin_lock_irqsave (&samsung_pwm_lock, flags); +raw_spin_lock_irqsave (&samsung_pwm_lock, flags); tcon =readl (our_chip->base +REG_TCON );
@@ -263,7 +263,7 @@ static int pwm_samsung_enable(struct pwm_chip *chip, struct pwm_device *pwm) our_chip->disabled_mask &= ~BIT (pwm->hwpwm); -spin_unlock_irqrestore (&samsung_pwm_lock, flags); +raw_spin_unlock_irqrestore (&samsung_pwm_lock, flags);return 0 ; }
@@ -275,7 +275,7 @@ static void pwm_samsung_disable(struct pwm_chip *chip, struct pwm_device *pwm)unsigned long flags;u32 tcon; -spin_lock_irqsave (&samsung_pwm_lock, flags); +raw_spin_lock_irqsave (&samsung_pwm_lock, flags); tcon =readl (our_chip->base +REG_TCON ); tcon &= ~TCON_AUTORELOAD (tcon_chan);
@@ -290,7 +290,7 @@ static void pwm_samsung_disable(struct pwm_chip *chip, struct pwm_device *pwm) our_chip->disabled_mask |=BIT (pwm->hwpwm); -spin_unlock_irqrestore (&samsung_pwm_lock, flags); +raw_spin_unlock_irqrestore (&samsung_pwm_lock, flags); } static void pwm_samsung_manual_update(struct samsung_pwm_chip *our_chip,
@@ -298,11 +298,11 @@ static void pwm_samsung_manual_update(struct samsung_pwm_chip *our_chip, {unsigned long flags; -spin_lock_irqsave (&samsung_pwm_lock, flags); +raw_spin_lock_irqsave (&samsung_pwm_lock, flags);__pwm_samsung_manual_update (our_chip, pwm); -spin_unlock_irqrestore (&samsung_pwm_lock, flags); +raw_spin_unlock_irqrestore (&samsung_pwm_lock, flags); } static int __pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm,
@@ -390,7 +390,7 @@ static void pwm_samsung_set_invert(struct samsung_pwm_chip *our_chip,unsigned long flags;u32 tcon; -spin_lock_irqsave (&samsung_pwm_lock, flags); +raw_spin_lock_irqsave (&samsung_pwm_lock, flags); tcon =readl (our_chip->base +REG_TCON );
@@ -404,7 +404,7 @@ static void pwm_samsung_set_invert(struct samsung_pwm_chip *our_chip,writel (tcon, our_chip->base +REG_TCON ); -spin_unlock_irqrestore (&samsung_pwm_lock, flags); +raw_spin_unlock_irqrestore (&samsung_pwm_lock, flags); } static int pwm_samsung_set_polarity(struct pwm_chip *chip,
include/clocksource/samsung_pwm.h +1 -1
@@ -15,7 +15,7 @@* spinlock is not shared between both drivers. */ #ifdef CONFIG_CLKSRC_SAMSUNG_PWM -extern spinlock_t samsung_pwm_lock; +extern raw_spinlock_t samsung_pwm_lock;#endif struct samsung_pwm_variant {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1431/1815 clocksource/drivers/armada: Unwind timer clock on init 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 8b4127f6db40381229f3564d34ac35f36311c201 ]
The Armada timer init paths enable their clock before calling the common initialization routine. If that routine returns an error, the clock is left enabled even though the timer was not initialized successfully.
--- drivers/clocksource/timer-armada-370-xp.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/clocksource/timer-armada-370-xp.c +15 -3
@@ -349,7 +349,11 @@ static int __init armada_xp_timer_init(struct device_node *np) timer_clk =clk_get_rate (clk); -return armada_370_xp_timer_common_init (np); + ret =armada_370_xp_timer_common_init (np); +if (ret) +clk_disable_unprepare (clk); + +return ret; }TIMER_OF_DECLARE (armada_xp,"marvell,armada-xp-timer" , armada_xp_timer_init);
@@ -387,7 +391,11 @@ static int __init armada_375_timer_init(struct device_node *np) timer25Mhz = false; } -return armada_370_xp_timer_common_init (np); + ret =armada_370_xp_timer_common_init (np); +if (ret) +clk_disable_unprepare (clk); + +return ret; }TIMER_OF_DECLARE (armada_375,"marvell,armada-375-timer" , armada_375_timer_init);
@@ -410,7 +418,11 @@ static int __init armada_370_timer_init(struct device_node *np) timer_clk =clk_get_rate (clk) /TIMER_DIVIDER ; timer25Mhz = false; -return armada_370_xp_timer_common_init (np); + ret =armada_370_xp_timer_common_init (np); +if (ret) +clk_disable_unprepare (clk); + +return ret; }TIMER_OF_DECLARE (armada_370,"marvell,armada-370-timer" , armada_370_timer_init);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1432/1815 ALSA: seq: midi: Optimize event_input locking with RCU
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 4cc25cdd3cffa475edb8dec8199b3227038ebcfb ]
The recent fix for serializing the output teardown introduced a spinlock invocation at every MIDI output event via event_process_midi. Since this is a hot path, let's do performance optimization with RCU.
The new output_substream __rcu pointer is published via rcu_assign_pointer() in midisynth_use() after output_rfile is set, and cleared in midisynth_unuse() before the resource teardown. event_process_midi() reads it under rcu_read_lock() and bumps output_use_lock inside that section, which is necessary to close the window between the pointer dereference and the refcount increment.
midisynth_unuse() calls synchronize_rcu() before snd_use_lock_sync():
this guarantees that any reader who obtained a non-NULL pointer has already called atomic_inc (output_use_lock), so the subsequent snd_use_lock_sync() sees the correct in-flight count.
--- sound/core/seq/seq_midi.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
sound/core/seq/seq_midi.c +11 -13
@@ -43,8 +43,8 @@ struct seq_midisynth {int device;int subdevice;struct snd_rawmidi_file input_rfile; -spinlock_t output_lock;/* protects output_rfile publication */ snd_use_lock_t output_use_lock;/* in-flight event_input users */ +struct snd_rawmidi_substream __rcu *output_substream;struct snd_rawmidi_file output_rfile;int seq_client;int seq_port;
@@ -134,8 +134,8 @@ static int event_process_midi(struct snd_seq_event *ev, int direct,if (snd_BUG_ON (!msynth))return -EINVAL ; - scoped_guard(spinlock_irqsave, &msynth->output_lock) { - substream = msynth->output_rfile.output; +scoped_guard (rcu) { + substream =rcu_dereference (msynth->output_substream);if (!substream)return -ENODEV ;snd_use_lock_use (&msynth->output_use_lock);
@@ -177,7 +177,6 @@ static int snd_seq_midisynth_new(struct seq_midisynth *msynth, msynth->card = card; msynth->device = device; msynth->subdevice = subdevice; -spin_lock_init (&msynth->output_lock);snd_use_lock_init (&msynth->output_use_lock);return 0 ; }
@@ -252,8 +251,8 @@ static int midisynth_use(void *private_data, struct snd_seq_port_subscribe *inforeturn err; }snd_midi_event_reset_decode (msynth->parser); -scoped_guard (spinlock_irqsave, &msynth->output_lock) - msynth->output_rfile = rfile; + msynth->output_rfile = rfile; +rcu_assign_pointer (msynth->output_substream, rfile.output);return 0 ; }
@@ -261,17 +260,16 @@ static int midisynth_use(void *private_data, struct snd_seq_port_subscribe *infostatic int midisynth_unuse (void *private_data,struct snd_seq_port_subscribe *info) {struct seq_midisynth *msynth = private_data; -struct snd_rawmidi_file rfile = {}; +struct snd_rawmidi_file rfile; - scoped_guard(spinlock_irqsave, &msynth->output_lock) { - rfile = msynth->output_rfile; - msynth->output_rfile = (struct snd_rawmidi_file ){}; - } +rcu_assign_pointer (msynth->output_substream,NULL ); +synchronize_rcu (); +snd_use_lock_sync (&msynth->output_use_lock); + rfile = msynth->output_rfile; + msynth->output_rfile = (struct snd_rawmidi_file ){};if (snd_BUG_ON (!rfile.output))return -EINVAL ; - -snd_use_lock_sync (&msynth->output_use_lock);snd_rawmidi_drain_output (rfile.output);return snd_rawmidi_kernel_release (&rfile); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1433/1815 ALSA: seq: midi: Serialize input teardown with event_input
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Keeping <[email protected]>
[ Upstream commit 403f7f3ad3808a0096d84cf228fab68dc253fd9d ]
snd_midi_input_event() must not be running while a rawmidi substream is closing, since this can lead to the trigger state becoming out-of-step through this sequence in snd_rawmidi_input_trigger():
snd_rawmidi_input_trigger(up=0) snd_midi_input_event() -> snd_rawmidi_kernel_read() -> snd_rawmidi_input_trigger(up=1) -> cancel_work_sync()
which ends with the underlying device being active unexpectedly.
When this is called from close_substream(), further input can re-trigger the input event leaving it running after rawmidi_release_priv() has set rfile->rmidi to NULL which leads to:
Unable to handle kernel NULL pointer dereference at virtual address 00000000000000b0 Call trace: snd_midi_input_event+0x3c/0x134 [snd_seq_midi] (P) snd_rawmidi_input_event_work+0x1c/0x2c process_one_work+0x150/0x3a4 worker_thread+0x190/0x318
Apply a similar approach to commit ef7607ab1c8ad ("ALSA: seq: midi:
Serialize output teardown with event_input") which fixed the same issue in the output direction, but updated to use RCU following Takashi Iwai's proposed follow-on patch [1].
With this change in place, midisynth_unsubscribe() clears the input file so snd_midi_input_event() will not re-trigger the stream and will be quiesced by the cancel_work_sync() in snd_rawmidi_input_trigger().
[1] https://lore.kernel.org/linux-sound/[email protected]/
--- sound/core/seq/seq_midi.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-)
sound/core/seq/seq_midi.c +31 -6
@@ -42,6 +42,8 @@ struct seq_midisynth {struct snd_rawmidi *rmidi;int device;int subdevice; +struct snd_rawmidi_substream __rcu *input_substream; +snd_use_lock_t input_use_lock;/* in-flight event_input users */ struct snd_rawmidi_file input_rfile;snd_use_lock_t output_use_lock;/* in-flight event_input users */ struct snd_rawmidi_substream __rcu *output_substream;
@@ -76,6 +78,14 @@ static void snd_midi_input_event(struct snd_rawmidi_substream *substream) msynth = runtime->private_data;if (msynth ==NULL )return ; + +scoped_guard (rcu) { +if (rcu_dereference (msynth->input_substream) != substream) +return ; + +snd_use_lock_use (&msynth->input_use_lock); + } +memset (&ev,0 ,sizeof (ev));while (runtime->avail >0 ) { res =snd_rawmidi_kernel_read (substream, buf,sizeof (buf));
@@ -95,6 +105,8 @@ static void snd_midi_input_event(struct snd_rawmidi_substream *substream)memset (&ev,0 ,sizeof (ev)); } } + +snd_use_lock_free (&msynth->input_use_lock); }static int dump_midi (struct snd_rawmidi_substream *substream,const char *buf,int count)
@@ -177,6 +189,7 @@ static int snd_seq_midisynth_new(struct seq_midisynth *msynth, msynth->card = card; msynth->device = device; msynth->subdevice = subdevice; +snd_use_lock_init (&msynth->input_use_lock);snd_use_lock_init (&msynth->output_use_lock);return 0 ; }
@@ -187,28 +200,31 @@ static int midisynth_subscribe(void *private_data, struct snd_seq_port_subscribeint err;struct seq_midisynth *msynth = private_data;struct snd_rawmidi_runtime *runtime; +struct snd_rawmidi_file rfile = {};struct snd_rawmidi_params params;/* open midi port */ err =snd_rawmidi_kernel_open (msynth->rmidi, msynth->subdevice,SNDRV_RAWMIDI_LFLG_INPUT , - &msynth->input_rfile); + &rfile);if (err <0 ) {pr_debug ("ALSA: seq_midi: midi input open failed!!!\n" );return err; } - runtime = msynth->input_rfile.input->runtime; + runtime = rfile.input->runtime;memset (¶ms,0 ,sizeof (params)); params.avail_min =1 ; params.buffer_size = input_buffer_size; - err =snd_rawmidi_input_params (msynth->input_rfile.input, ¶ms); + err =snd_rawmidi_input_params (rfile.input, ¶ms);if (err <0 ) { -snd_rawmidi_kernel_release (&msynth->input_rfile); +snd_rawmidi_kernel_release (&rfile);return err; }snd_midi_event_reset_encode (msynth->parser); runtime->event = snd_midi_input_event; runtime->private_data = msynth; + msynth->input_rfile = rfile; +rcu_assign_pointer (msynth->input_substream, rfile.input);snd_rawmidi_kernel_read (msynth->input_rfile.input,NULL ,0 );return 0 ; }
@@ -218,10 +234,19 @@ static int midisynth_unsubscribe(void *private_data, struct snd_seq_port_subscri {int err;struct seq_midisynth *msynth = private_data; +struct snd_rawmidi_file rfile; -if (snd_BUG_ON (!msynth->input_rfile.input)) +rcu_assign_pointer (msynth->input_substream,NULL ); +synchronize_rcu (); +snd_use_lock_sync (&msynth->input_use_lock); + + rfile = msynth->input_rfile; + msynth->input_rfile = (struct snd_rawmidi_file ){}; + +if (snd_BUG_ON (!rfile.input))return -EINVAL ; - err =snd_rawmidi_kernel_release (&msynth->input_rfile); + + err =snd_rawmidi_kernel_release (&rfile);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1434/1815 nvmet: fix max_qid race between configfs and controller allocation
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maurizio Lombardi <[email protected]>
[ Upstream commit f1a8846e06388113dfdbb89dee005083fa9afdf9 ]
The function nvmet_subsys_attr_qid_max_store() can race against nvmet_alloc_ctrl() when a subsystem's max_qid limit is modified.
Suppose max_qid is currently 64. If nvmet_alloc_ctrl() executes:ctrl->sqs = kzalloc_objs(struct nvmet_sq *, subsys->max_qid + 1); and at this exact point, a userspace process changes max_qid to 128, nvmet_subsys_attr_qid_max_store() will set the new max_qid value. It attempts to delete active controllers to force a reconnect, but the new controller won't be deleted because it hasn't been added to the subsys->ctrls list yet.
nvmet_alloc_ctrl() then proceeds and adds the new controller to the subsys->ctrls list. Later, when nvmet_install_queue() is called, it will see max_qid set to 128, but the memory allocated for sqs is only sized for 64 entries. This results in a KASAN out-of-bounds warning and potential memory corruptions.
Fix this by protecting the queue allocations and list insertion in nvmet_alloc_ctrl() with down_read(&nvmet_config_sem). Because nvmet_subsys_attr_qid_max_store() acquires down_write(&nvmet_config_sem) to modify the attribute, this safely prevents the configfs writer from modifying max_qid during controller creation.
Copy the max_qid from the subsystem to the controller's structure during the allocation; ctrl->max_qid never changes as long as the controller remains in LIVE state, so this will prevent similar race conditions.
--- drivers/nvme/target/admin-cmd.c | 8 ++--- drivers/nvme/target/core.c | 49 +++++++++++++++++-------------- drivers/nvme/target/fabrics-cmd.c | 2 +- drivers/nvme/target/nvmet.h | 6 ++++ drivers/nvme/target/pci-epf.c | 2 +- 5 files changed, 39 insertions(+), 28 deletions(-)
drivers/nvme/target/admin-cmd.c +4 -4
@@ -1337,7 +1337,7 @@ static u16 nvmet_set_feat_arbitration(struct nvmet_req *req)void nvmet_execute_set_features (struct nvmet_req *req) { -struct nvmet_subsys *subsys =nvmet_req_subsys (req); +struct nvmet_ctrl *ctrl =nvmet_req_ctrl (req);u32 cdw10 =le32_to_cpu (req->cmd->common.cdw10);u32 cdw11 =le32_to_cpu (req->cmd->common.cdw11);u16 status =0 ;
@@ -1359,7 +1359,7 @@ void nvmet_execute_set_features(struct nvmet_req *req)break ; }nvmet_set_result (req, - (subsys->max_qid -1 ) | ((subsys->max_qid -1 ) <<16 )); + (ctrl->max_qid -1 ) | ((ctrl->max_qid -1 ) <<16 ));break ;case NVME_FEAT_IRQ_COALESCE : status =nvmet_set_feat_irq_coalesce (req);
@@ -1496,7 +1496,7 @@ void nvmet_get_feat_async_event(struct nvmet_req *req)void nvmet_execute_get_features (struct nvmet_req *req) { -struct nvmet_subsys *subsys =nvmet_req_subsys (req); +struct nvmet_ctrl *ctrl =nvmet_req_ctrl (req);u32 cdw10 =le32_to_cpu (req->cmd->common.cdw10);u16 status =0 ;
@@ -1536,7 +1536,7 @@ void nvmet_execute_get_features(struct nvmet_req *req)break ;case NVME_FEAT_NUM_QUEUES :nvmet_set_result (req, - (subsys->max_qid-1 ) | ((subsys->max_qid-1 ) <<16 )); + (ctrl->max_qid-1 ) | ((ctrl->max_qid-1 ) <<16 ));break ;case NVME_FEAT_KATO :nvmet_get_feat_kato (req);
drivers/nvme/target/core.c +27 -22
94 lines not on this page · raw message
drivers/nvme/target/fabrics-cmd.c +1 -1
@@ -370,7 +370,7 @@ static void nvmet_execute_io_connect(struct nvmet_req *req) goto out; } -if (unlikely (qid > ctrl->subsys->max_qid)) { +if (unlikely (qid > ctrl->max_qid)) {pr_warn ("invalid queue id (%d)\n" , qid); status =NVME_SC_CONNECT_INVALID_PARAM |NVME_STATUS_DNR ; req->cqe->result.u32 =IPO_IATTR_CONNECT_SQE (qid);
drivers/nvme/target/nvmet.h +6 -0
@@ -265,6 +265,7 @@ struct nvmet_ctrl {uuid_t hostid;u16 cntlid; +u16 max_qid;u32 kato;struct nvmet_port *port;
@@ -753,6 +754,11 @@ static inline struct nvmet_subsys *nvmet_req_subsys(struct nvmet_req *req)return req->sq->ctrl->subsys; } +static inline struct nvmet_ctrl *nvmet_req_ctrl (struct nvmet_req *req) +{ +return req->sq->ctrl; +} +static inline bool nvmet_is_disc_subsys (struct nvmet_subsys *subsys) {return subsys->type !=NVME_NQN_NVME ;
drivers/nvme/target/pci-epf.c +1 -1
@@ -2081,7 +2081,7 @@ static int nvmet_pci_epf_create_ctrl(struct nvmet_pci_epf *nvme_epf, }/* Allocate our queues, up to the maximum number. */ - ctrl->nr_queues =min (ctrl->tctrl->subsys->max_qid +1 , max_nr_queues); + ctrl->nr_queues =min (ctrl->tctrl->max_qid +1 , max_nr_queues); ret =nvmet_pci_epf_alloc_queues (ctrl);if (ret) goto out_put_ctrl;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1435/1815 selftests/cgroup: Preserve CPU hotplug write errors
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rui Qi <[email protected]>
[ Upstream commit ddabc5dbd262f3ca981e679ddae99ed7a9adb279 ]
The cpuset partition root state selftest checks several CPU hotplug transitions. If writing to a CPU online file fails, the helper still runs pause afterwards and returns the status of pause instead of the failed write.
This hides the real hotplug failure and can make later checks run against expectations for a transition that never happened. Move the write before the bookkeeping and return when it fails, so callers can observe the hotplug error and the test does not record a CPU as offline unless the offline operation actually succeeded.
Also change the O* command handler in set_ctrl_state() to use "eval $COMM $REDIRECT" like all other handlers. The previous version set COMM but still called write_cpu_online directly, bypassing the redirect that captures stderr for error reporting.
Changes since v1:
- Use eval $COMM $REDIRECT in the O* handler instead of calling write_cpu_online directly (Waiman Long)
--- tools/testing/selftests/cgroup/test_cpuset_prs.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/cgroup/test_cpuset_prs.sh +3 -2
@@ -520,6 +520,7 @@ write_cpu_online() CPU=${1%=*} VAL=${1#*=} CPUFILE=//sys/devices/system/cpu/cpu${CPU}/online + echo $VAL > $CPUFILE || return 1 if [[ $VAL -eq 0 ]] then OFFLINE_CPUS="$OFFLINE_CPUS $CPU"
@@ -529,7 +530,6 @@ write_cpu_online() sort | uniq -u) } fi - echo $VAL > $CPUFILE pause 0.05 }
@@ -597,7 +597,8 @@ set_ctrl_state() eval $COMM $REDIRECT ;; O*) VAL=${CMD#?} - write_cpu_online $VAL + COMM="write_cpu_online $VAL" + eval $COMM $REDIRECT ;; T*) COMM="echo 0 > $TFILE" eval $COMM $REDIRECT
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1436/1815 x86/pkeys: Fix pkey_alloc() return value when pkeys are not supported
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bijan Tabatabai <[email protected]>
[ Upstream commit dee87e09b0dd63da9b1e1876167ccae37842dfd0 ]
The man page for pkey_alloc(2) specifies that it should return -1 with the errno set to ENOSPC when pkeys are not supported [1]. However, on x86 pkey_alloc() sets errno to EINVAL when called for the first time on a CPU that does not support pkeys.
The root cause of this is the x86 implementation of mm_pkey_alloc() not directly checking if pkeys are supported. It only checks if all the pkeys have been allocated by comparing the allocation map against all_pkeys_mask. When OSPKE is not enabled, init_new_context() skips the initialization of the allocation map, leaving it as 0, while all_pkeys_mask is 1. mm_pkey_alloc() interprets this as there being a pkey available and it returns pkey 0. Then, pkey_alloc() fails with -EINVAL from arch_set_user_pkey_access() instead of returning -ENOSPC. Subsequent calls to pkey_alloc() do return -ENOSPC because pkey 0 is left marked as allocated.
Change mm_pkey_alloc() to directly check if OSPKE is enabled, and return -1 if it is not, which causes pkey_alloc() to return -ENOSPC. The arm64 and powerpc implementations of mm_pkey_alloc() already do this check.
[1] https://man7.org/linux/man-pages/man2/pkey_alloc.2.html
[ dhansen: use arch_pkeys_enabled() to follow arm ]
--- arch/x86/include/asm/pkeys.h | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/include/asm/pkeys.h +3 -0
@@ -88,6 +88,9 @@ int mm_pkey_alloc(struct mm_struct *mm)u16 all_pkeys_mask = ((1U <<arch_max_pkey ()) -1 );int ret; +if (!arch_pkeys_enabled ()) +return -1 ; +/* * Are we out of pkeys? We must handle this specially * because ffz() behavior is undefined if there are no
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1437/1815 bpftool: Fix double close in map dump
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuan Chen <[email protected]>
[ Upstream commit 259d60f5bfa41056fe01cbf2ba3f6f0331865a16 ]
map_dump() closes the map fd in its error path, and do_dump() then closes the same fd again after a successful dump. Closing an already closed fd leaves errno set to EBADF, which poisons later errno checks such as the batch file read check in do_batch(). Let do_dump() own the fd and remove the close from map_dump().
The same double-close pattern exists in do_show_subset(): both show_map_close_json() and show_map_close_plain() already close the fd, so drop the extra close() there as well.
Also propagate the error when bpf_map_get_info_by_fd() fails on a subsequent map in do_dump(): set err = -1 before breaking out of the loop, so a later failure is not silently hidden after an earlier iteration succeeded.
--- tools/bpf/bpftool/map.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tools/bpf/bpftool/map.c +1 -3
@@ -659,8 +659,6 @@ static int do_show_subset(int argc, char **argv)show_map_close_json (fds[i], &info); else show_map_close_plain(fds[i], &info); - -close (fds[i]); }if (json_output && nb_fds >1 )jsonw_end_array (json_wtr);/* root array */
@@ -895,7 +893,6 @@ map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr, exit_free:free (key);free (value); -close (fd);free_map_kv_btf (btf);return err;
@@ -944,6 +941,7 @@ static int do_dump(int argc, char **argv)for (i =0 ; i < nb_fds; i++) {if (bpf_map_get_info_by_fd (fds[i], &info, &len)) {p_err ("can't get map info: %s" ,strerror (errno)); + err =-1 ;break ; } err =map_dump (fds[i], &info, wtr, nb_fds >1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1438/1815 ocfs2: validate orphan slot during inode read
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: ZhengYuan Huang <[email protected]>
[ Upstream commit b2d31acbd3b182755b019183fb46949ba5e39b9f ]
Patch series "ocfs2: validate active orphan slots during inode read".
OCFS2 trusts active ordinary and append-DIO orphan slots read from dinodes. A corrupted slot can therefore index osb_orphan_wipes or the slot-local system-inode cache outside their allocations before the corruption is reported.
Patch 1 validates the ordinary orphan slot used by inode wipe processing. Patch 2 validates the append-DIO orphan slot used by DIO completion and orphan recovery. Both checks reject corrupt metadata at the existing inode validation boundary.
This patch (of 2):
[BUG]
A corrupted dinode with OCFS2_ORPHANED_FL can carry an i_orphaned_slot outside the mounted filesystem slot range. ocfs2_wipe_inode() uses it to index osb_orphan_wipes before looking up the orphan directory, causing an out-of-bounds memory access.
BUG: KASAN: slab-use-after-free in ocfs2_get_system_file_inode+0x780/0x820 fs/ocfs2/sysfile.c:102 Read of size 8 at addr ffff88800b767c00 by task kworker/u8:3/85 Call Trace: ... ocfs2_get_system_file_inode+0x780/0x820 fs/ocfs2/sysfile.c:102 ocfs2_wipe_inode+0x292/0xf70 fs/ocfs2/inode.c:840 ocfs2_delete_inode fs/ocfs2/inode.c:1155 [inline] ocfs2_evict_inode+0x6c9/0x1170 fs/ocfs2/inode.c:1295 evict+0x38e/0x8f0 fs/inode.c:810 iput_final fs/inode.c:1914 [inline] iput fs/inode.c:1966 [inline] iput+0x55b/0x8b0 fs/inode.c:1926 ocfs2_recover_orphans+0x610/0xe40 fs/ocfs2/journal.c:2374 ocfs2_complete_recovery+0x5af/0xd00 fs/ocfs2/journal.c:1373 ...
[CAUSE]ocfs2_validate_inode_block() validates i_suballoc_slot but leaves the active ordinary orphan slot unchecked. Downstream consumers assume that the value is smaller than osb->max_slots.
[FIX]
Reject an active i_orphaned_slot outside the slot range during dinode validation, before the inode reaches orphan wipe processing.
--- fs/ocfs2/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/ocfs2/inode.c +8 -0
@@ -1528,6 +1528,14 @@ int ocfs2_validate_inode_block(struct super_block *sb, goto bail; } +if ((le32_to_cpu (di->i_flags) &OCFS2_ORPHANED_FL ) && +le16_to_cpu (di->i_orphaned_slot) >=OCFS2_SB (sb)->max_slots) { + rc =ocfs2_error (sb,"Invalid dinode %llu: orphaned slot %u\n" , + (unsigned long long )bh->b_blocknr, +le16_to_cpu (di->i_orphaned_slot)); + goto bail; + } +/* * Reject dinodes whose i_mode does not name one of the seven * canonical POSIX file types. ocfs2_populate_inode() copies
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1439/1815 ocfs2: validate DIO orphan slot during inode read
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: ZhengYuan Huang <[email protected]>
[ Upstream commit bb88131c9831075b8dc08cdd375743e5d44c7ca2 ]
[BUG]
A corrupted append-DIO dinode (high byte at offset 0xa1 corrupted from 0 to 1) can carry an i_dio_orphaned_slot outside the mounted filesystem slot range and trigger a use-after-free error:
BUG: KASAN: slab-use-after-free in ocfs2_get_system_file_inode+0x780/0x820 fs/ocfs2/sysfile.c:102 Read of size 8 at addr ffff88800b767c00 by task kworker/u8:3/85 Call Trace: ... ocfs2_get_system_file_inode+0x780/0x820 fs/ocfs2/sysfile.c:102 ocfs2_wipe_inode+0x292/0xf70 fs/ocfs2/inode.c:840 ocfs2_delete_inode fs/ocfs2/inode.c:1155 [inline] ocfs2_evict_inode+0x6c9/0x1170 fs/ocfs2/inode.c:1295 evict+0x38e/0x8f0 fs/inode.c:810 iput_final fs/inode.c:1914 [inline] iput fs/inode.c:1966 [inline] iput+0x55b/0x8b0 fs/inode.c:1926 ocfs2_recover_orphans+0x610/0xe40 fs/ocfs2/journal.c:2374 ocfs2_complete_recovery+0x5af/0xd00 fs/ocfs2/journal.c:1373 ...
[CAUSE]ocfs2_del_inode_from_orphan() uses i_dio_orphaned_slot to index the slot-local system inode cache. The dinode validator does not check this active slot, so an out-of-range value produces an invalid cache entry pointer that is dereferenced as an inode pointer.
[FIX]
Reject an active i_dio_orphaned_slot outside the slot range during dinode validation, before DIO orphan recovery can consume it.
--- fs/ocfs2/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/ocfs2/inode.c +8 -0
@@ -1536,6 +1536,14 @@ int ocfs2_validate_inode_block(struct super_block *sb, goto bail; } +if ((le32_to_cpu (di->i_flags) &OCFS2_DIO_ORPHANED_FL ) && +le16_to_cpu (di->i_dio_orphaned_slot) >=OCFS2_SB (sb)->max_slots) { + rc =ocfs2_error (sb,"Invalid dinode %llu: DIO orphaned slot %u\n" , + (unsigned long long )bh->b_blocknr, +le16_to_cpu (di->i_dio_orphaned_slot)); + goto bail; + } +/* * Reject dinodes whose i_mode does not name one of the seven * canonical POSIX file types. ocfs2_populate_inode() copies
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1440/1815 ocfs2: fix circular locking dependency in ocfs2_init_acl()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krystian Kaniewski <[email protected]>
[ Upstream commit bd7c05fb4a4776dff5a87b19008d28458647d15d ]
A lockdep warning indicates a circular locking dependency between &oi->ip_xattr_sem and &journal->j_trans_barrier:
WARNING: possible circular locking dependency detected is trying to acquire lock:
(&oi->ip_xattr_sem){++++}-{4:4}, at: ocfs2_init_acl+0x2fd/0x7e0 fs/ocfs2/acl.c:367
but task is already holding lock:
(&journal->j_trans_barrier){.+.+}-{4:4}, at: ocfs2_start_trans+0x3ab/0x700 fs/ocfs2/journal.c:369
The deadlock involves two code paths: Path 1 (setxattr) where ocfs2_xattr_set() acquires ip_xattr_sem (write) and then starts a transaction, which acquires j_trans_barrier (read); and Path 2 (mkdir/mknod) where ocfs2_mknod() starts a transaction (j_trans_barrier read) and then calls ocfs2_init_acl(), which attempts to acquire ip_xattr_sem (read) on the parent directory to retrieve the default ACL.
Because rw_semaphores are subject to writer priority, a pending writer on j_trans_barrier (e.g., the journal commit thread) can cause Path 1 to block, while Path 2 is blocked waiting for Path 1 to release ip_xattr_sem.
The patch fixes the lock ordering by precomputing the ACL state before starting the OCFS2 transaction, while preserving POSIX ACL storage semantics and the existing inode/security initialization order. By reading the parent directory's default ACL and preparing the new inode's ACLs outside the transaction, ip_xattr_sem is always acquired before j_trans_barrier.
struct ocfs2_acl_state encapsulates the prepared ACL state, while ocfs2_acl_init_prepare() and ocfs2_acl_init_release() avoid code duplication between ocfs2_mknod() and ocfs2_init_security_and_acl(). ocfs2_calc_xattr_init() and ocfs2_init_acl() use this precomputed state, removing internal ip_xattr_sem acquisition and redundant disk reads.
Additionally, remove the ip_xattr_sem acquisition from ocfs2_xattr_set_handle(). This function is only used while initializing a new inode that has not yet been inserted into the inode hash or attached to a dentry, meaning there is no risk of concurrent access and the lock is unnecessary.
--- fs/ocfs2/acl.c | 135 ++++++++++++++++++++++++++++++----------------- fs/ocfs2/acl.h | 19 +++++-- fs/ocfs2/namei.c | 17 ++++-- fs/ocfs2/xattr.c | 86 ++++++++++++++++++------------ fs/ocfs2/xattr.h | 9 ++-- 5 files changed, 173 insertions(+), 93 deletions(-)
fs/ocfs2/acl.c +88 -47
@@ -110,8 +110,7 @@ static void *ocfs2_acl_to_xattr(const struct posix_acl *acl, size_t *size)return ocfs2_acl; } -static struct posix_acl *ocfs2_get_acl_nolock (struct inode *inode, -int type, +static struct posix_acl *ocfs2_get_acl_nolock (struct inode *inode,int type,struct buffer_head *di_bh) {int name_index;
@@ -349,63 +348,105 @@ int ocfs2_acl_chmod(struct inode *inode, struct buffer_head *bh)* Initialize the ACLs of a new inode. If parent directory has default ACL, * then clone to new inode. Called from ocfs2_mknod. */ -int ocfs2_init_acl (handle_t *handle, -struct inode *inode, -struct inode *dir, -struct buffer_head *di_bh, -struct buffer_head *dir_bh, -struct ocfs2_alloc_context *meta_ac, -struct ocfs2_alloc_context *data_ac) +void ocfs2_acl_init_release (struct ocfs2_acl_state *state) +{ +posix_acl_release (state->default_acl); +posix_acl_release (state->acl); + state->default_acl =NULL ; + state->acl =NULL ; +} + +int ocfs2_acl_init_prepare (struct inode *inode,struct inode *dir, +struct buffer_head *dir_bh, +struct ocfs2_acl_state *state) {struct ocfs2_super *osb =OCFS2_SB (inode->i_sb); -struct posix_acl *acl =NULL ; -int ret =0 , ret2; -umode_t mode; - -if (!S_ISLNK (inode->i_mode)) { -if (osb->s_mount_opt &OCFS2_MOUNT_POSIX_ACL ) { -down_read (&OCFS2_I (dir)->ip_xattr_sem); - acl =ocfs2_get_acl_nolock (dir,ACL_TYPE_DEFAULT , - dir_bh); -up_read (&OCFS2_I (dir)->ip_xattr_sem); -if (IS_ERR (acl)) -return PTR_ERR (acl); +int ret =0 ; + + state->default_acl =NULL ; + state->acl =NULL ; + state->mode = inode->i_mode; + +if (S_ISLNK (inode->i_mode)) +return 0 ; + +if (osb->s_mount_opt &OCFS2_MOUNT_POSIX_ACL ) { +down_read (&OCFS2_I (dir)->ip_xattr_sem); + state->default_acl = +ocfs2_get_acl_nolock (dir,ACL_TYPE_DEFAULT , dir_bh); +up_read (&OCFS2_I (dir)->ip_xattr_sem); +if (IS_ERR (state->default_acl)) { + ret =PTR_ERR (state->default_acl); + state->default_acl =NULL ; +return ret; } -if (!acl) { - mode = inode->i_mode & ~current_umask (); - ret =ocfs2_acl_set_mode (inode, di_bh, handle, mode); -if (ret) { -mlog_errno (ret); +if (state->default_acl) { + state->acl =posix_acl_dup (state->default_acl); +if (!state->acl) { + ret = -ENOMEM ; goto cleanup; } + ret =__posix_acl_create (&state->acl,GFP_NOFS , + &state->mode); +if (ret <0 ) + goto cleanup; +if (ret ==0 ) { +posix_acl_release (state->acl); + state->acl =NULL ; + } +if (!S_ISDIR (inode->i_mode)) { +posix_acl_release (state->default_acl); + state->default_acl =NULL ; + } + }else { + state->mode &= ~current_umask (); } + }else { + state->mode &= ~current_umask (); } -if ((osb->s_mount_opt &OCFS2_MOUNT_POSIX_ACL ) && acl) { -if (S_ISDIR (inode->i_mode)) { + +return 0 ; +cleanup: +ocfs2_acl_init_release (state); +return ret; +} + +int ocfs2_init_acl (handle_t *handle,struct inode *inode, +struct buffer_head *di_bh, +struct ocfs2_alloc_context *meta_ac, +struct ocfs2_alloc_context *data_ac, +struct ocfs2_acl_state *state) +{ +struct ocfs2_super *osb =OCFS2_SB (inode->i_sb); +int ret =0 ; + +if (S_ISLNK (inode->i_mode)) +return 0 ; + +if (osb->s_mount_opt &OCFS2_MOUNT_POSIX_ACL ) { +if (S_ISDIR (inode->i_mode) && state->default_acl) { ret =ocfs2_set_acl (handle, inode, di_bh, -ACL_TYPE_DEFAULT , acl, - meta_ac, data_ac); +ACL_TYPE_DEFAULT , + state->default_acl, meta_ac, + data_ac);if (ret) - goto cleanup; +return ret; } - mode = inode->i_mode; - ret =__posix_acl_create (&acl,GFP_NOFS , &mode); -if (ret <0 ) -return ret; + } - ret2 =ocfs2_acl_set_mode (inode, di_bh, handle, mode); -if (ret2) { -mlog_errno (ret2); - ret = ret2; - goto cleanup; - } -if (ret >0 ) { - ret =ocfs2_set_acl (handle, inode, - di_bh,ACL_TYPE_ACCESS , - acl, meta_ac, data_ac); + ret =ocfs2_acl_set_mode (inode, di_bh, handle, state->mode); +if (ret) { +mlog_errno (ret); +return ret; + } + +if (osb->s_mount_opt &OCFS2_MOUNT_POSIX_ACL ) { +if (state->acl) { + ret =ocfs2_set_acl (handle, inode, di_bh, +ACL_TYPE_ACCESS , state->acl, + meta_ac, data_ac); } } -cleanup: -posix_acl_release (acl); +return ret; }
fs/ocfs2/acl.h +15 -4
@@ -20,9 +20,20 @@ struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type, bool rcu);int ocfs2_iop_set_acl (struct mnt_idmap *idmap,struct dentry *dentry,struct posix_acl *acl,int type);extern int ocfs2_acl_chmod (struct inode *,struct buffer_head *); -extern int ocfs2_init_acl (handle_t *,struct inode *,struct inode *, -struct buffer_head *,struct buffer_head *, -struct ocfs2_alloc_context *, -struct ocfs2_alloc_context *); +struct ocfs2_acl_state { +struct posix_acl *default_acl; +struct posix_acl *acl; +umode_t mode; +}; + +int ocfs2_acl_init_prepare (struct inode *inode,struct inode *dir, +struct buffer_head *dir_bh, +struct ocfs2_acl_state *state); +void ocfs2_acl_init_release (struct ocfs2_acl_state *state); +int ocfs2_init_acl (handle_t *handle,struct inode *inode, +struct buffer_head *di_bh, +struct ocfs2_alloc_context *meta_ac, +struct ocfs2_alloc_context *data_ac, +struct ocfs2_acl_state *state);#endif /* OCFS2_ACL_H */
fs/ocfs2/namei.c +12 -5
@@ -256,6 +256,7 @@ static int ocfs2_mknod(struct mnt_idmap *idmap,sigset_t oldset;int did_block_signals =0 ;struct ocfs2_dentry_lock *dl =NULL ; +struct ocfs2_acl_state acl_state = {0 }; trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name, (unsigned long long)OCFS2_I(dir)->ip_blkno,
@@ -330,10 +331,14 @@ static int ocfs2_mknod(struct mnt_idmap *idmap, } } + status =ocfs2_acl_init_prepare (inode, dir, parent_fe_bh, &acl_state); +if (status <0 ) + goto leave; +/* calculate meta data/clusters for setting security and acl xattr */ - status =ocfs2_calc_xattr_init (dir, parent_fe_bh, mode, - &si, &want_clusters, - &xattr_credits, &want_meta); + status =ocfs2_calc_xattr_init (dir, mode, &si, &want_clusters, + &xattr_credits, &want_meta, + &acl_state);if (status <0 ) {mlog_errno (status); goto leave;
@@ -411,8 +416,8 @@ static int ocfs2_mknod(struct mnt_idmap *idmap,inc_nlink (dir); } - status =ocfs2_init_acl (handle, inode, dir, new_fe_bh, parent_fe_bh, - meta_ac, data_ac); + status =ocfs2_init_acl (handle, inode, new_fe_bh, meta_ac, data_ac, + &acl_state);if (status <0 ) {mlog_errno (status);
@@ -477,6 +482,8 @@ static int ocfs2_mknod(struct mnt_idmap *idmap,brelse (parent_fe_bh);kfree (si.value); +ocfs2_acl_init_release (&acl_state); +ocfs2_free_dir_lookup_result (&lookup);if (inode_ac)
fs/ocfs2/xattr.c +52 -34
138 lines not on this page · raw message
fs/ocfs2/xattr.h +6 -3
@@ -57,9 +57,12 @@ int ocfs2_init_security_set(handle_t *, struct inode *,int ocfs2_calc_security_init (struct inode *,struct ocfs2_security_xattr_info *,int *,int *,struct ocfs2_alloc_context **); -int ocfs2_calc_xattr_init (struct inode *,struct buffer_head *, -umode_t ,struct ocfs2_security_xattr_info *, -int *,int *,int *); + +struct ocfs2_acl_state ; +int ocfs2_calc_xattr_init (struct inode *dir,umode_t mode, +struct ocfs2_security_xattr_info *si, +int *want_clusters,int *xattr_credits, +int *want_meta,struct ocfs2_acl_state *acl_state);/* * xattrs can live inside an inode, as part of an external xattr block,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1441/1815 Squashfs: check block offset is not negative
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Phillip Lougher <[email protected]>
[ Upstream commit e300eb5002925b29be803d2661af07266cfa267e ]
If a negative offset is read off disk (for example the offset into the decompressed fragment block), this will cause squashfs_copy_data() to perform an out of bounds access.
Fix by checking if offset is negative, and returning 0. This matches existing behaviour where an offset beyond the block returns 0 bytes copied.
To trigger this out of bounds access requires a crafted Squashfs filesystem and CAP_SYS_ADMIN to mount it. Unprivileged users will not be able to mount such a filesystem, but once mounted, an unprivileged user can trigger the out of bounds access by reading the crafted file with the negative offset.
--- fs/squashfs/cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/squashfs/cache.c +1 -1
@@ -299,7 +299,7 @@ int squashfs_copy_data(void *buffer, struct squashfs_cache_entry *entry, {int remaining = length; -if (length ==0 ) +if (length ==0 || offset <0 )return 0 ;else if (buffer ==NULL )return min (length, entry->length - offset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1442/1815 selftests/bpf: Fix for veristat file/prog filters processing
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduard Zingerman <[email protected]>
[ Upstream commit 98d309ec8189fd91698d1a72946c3d888270c57e ]
At the moment veristat filtering behaves unexpectedly for the following filter expression:
-f !file/prog
The expression rejects all programs with name 'prog', and all programs in a file with name 'file'. This commit fixes the expression to exclude only a program 'prog' from a file 'file'. Additionally, the commit makes empty filters like '-f ""' or '-f "/"' and error. Here is the filtering behaviour compared old versus new:
| filter | file | prog | old verdict | new verdict | |----------+------+------+-------------+-------------| | !foo | foo | bar | skipped | skipped | | !foo | bar | foo | skipped | skipped | | !foo | bar | bar | processed | processed | | !foo/bar | foo | bar | skipped | skipped | | !foo/bar | foo | buz | skipped | processed | (!) | !foo/bar | bar | bar | skipped | processed | (!) | !foo/ | foo | bar | skipped | skipped | | !foo/ | bar | bar | processed | processed | | !/bar | foo | bar | skipped | skipped | | !/bar | foo | foo | processed | processed | | !/ | foo | bar | processed | error | (!) | ! | foo | bar | processed | error | (!) |----------+------+------+-------------+-------------| | foo | foo | bar | processed | processed | | foo | bar | foo | processed | processed | | foo | bar | bar | skipped | skipped | | foo/bar | foo | bar | processed | processed | | foo/bar | foo | buz | skipped | skipped | | foo/bar | bar | bar | skipped | skipped | | foo/ | foo | bar | processed | processed | | foo/ | bar | bar | skipped | skipped | | /bar | foo | bar | processed | processed | | /bar | foo | foo | skipped | skipped | | / | foo | bar | processed | error | (!) | | foo | bar | skipped | error | (!)
--- tools/testing/selftests/bpf/veristat.c | 76 +++++++++++++++++--------- 1 file changed, 49 insertions(+), 27 deletions(-)
tools/testing/selftests/bpf/veristat.c +49 -27
@@ -514,6 +514,40 @@ static bool is_bpf_obj_file(const char *path) {return err ==0 ; } +/* Exact filter match */ +static bool name_filter_matches (struct filter *f,const char *filename,const char *prog_name) +{ +if (f->any_glob) +return glob_matches (filename, f->any_glob) || + (prog_name &&glob_matches (prog_name, f->any_glob)); +if (f->file_glob && f->prog_glob) +return prog_name && +glob_matches (filename, f->file_glob) && +glob_matches (prog_name, f->prog_glob); +if (f->file_glob) +return glob_matches (filename, f->file_glob); +if (f->prog_glob) +return prog_name &&glob_matches (prog_name, f->prog_glob); +return false; +} + +/* Check if the filter does not outright reject the file name */ +static bool name_filter_may_match (struct filter *f,const char *filename) +{ +if (f->file_glob) +return glob_matches (filename, f->file_glob); +/* +* If we don't know program name yet, any_glob filter +* has to assume that current BPF object file might be +* relevant; we'll check again later on after opening +* BPF object file, at which point program name will +* be known finally. +*/ +if (f->any_glob || f->prog_glob) +return true; +return false; +} +static bool should_process_file_prog (const char *filename,const char *prog_name) {struct filter *f;
@@ -521,16 +555,7 @@ static bool should_process_file_prog(const char *filename, const char *prog_namefor (i =0 ; i < env.deny_filter_cnt; i++) { f = &env.deny_filters[i]; -if (f->kind !=FILTER_NAME ) -continue ; - -if (f->any_glob &&glob_matches (filename, f->any_glob)) -return false; -if (f->any_glob && prog_name &&glob_matches (prog_name, f->any_glob)) -return false; -if (f->file_glob &&glob_matches (filename, f->file_glob)) -return false; -if (f->prog_glob && prog_name &&glob_matches (prog_name, f->prog_glob)) +if (f->kind ==FILTER_NAME &&name_filter_matches (f, filename, prog_name))return false; }
@@ -540,24 +565,15 @@ static bool should_process_file_prog(const char *filename, const char *prog_namecontinue ; allow_cnt++; -if (f->any_glob) { -if (glob_matches (filename, f->any_glob)) -return true; -/* If we don't know program name yet, any_glob filter -* has to assume that current BPF object file might be -* relevant; we'll check again later on after opening -* BPF object file, at which point program name will -* be known finally. -*/ -if (!prog_name ||glob_matches (prog_name, f->any_glob)) -return true; - }else { -if (f->file_glob && !glob_matches (filename, f->file_glob)) -continue ; -if (f->prog_glob && prog_name && !glob_matches (prog_name, f->prog_glob)) -continue ; +if (prog_name &&name_filter_matches (f, filename, prog_name)) +return true; +/* +* If there is no prog_name and the file name is not blocked by +* the filter, allow to open the file. Afterwards there would be +* a second refining query with prog_name set. +*/ +if (!prog_name &&name_filter_may_match (f, filename))return true; - } }/* if there are no file/prog name allow filters, allow all progs,
@@ -703,6 +719,12 @@ static int append_filter(struct filter **filters, int *cnt, const char *str) } } +if ((!f->any_glob && !f->file_glob && !f->prog_glob) || + (f->any_glob &&strcmp (f->any_glob,"" ) ==0 )) { +fprintf (stderr,"Invalid filter: '%s'\n" , str); +return -EINVAL ; + } + *cnt +=1 ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1443/1815 scsi: mpt3sas: Avoid freeing unallocated PCIe SGL buffers
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit b9f679dfe629004b593f018df33b330d799bcee4 ]
_base_release_memory_pools() unconditionally frees every ioc->pcie_sg_lookup[] entry, including ones the setup loop never allocated after a partial failure, causing a "bad dma" warning on debug kernels or a NULL pointer dereference otherwise.
--- drivers/scsi/mpt3sas/mpt3sas_base.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/mpt3sas/mpt3sas_base.c +2 -0
@@ -5870,6 +5870,8 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)if (ioc->pcie_sgl_dma_pool) {for (i =0 ; i < ioc->scsiio_depth; i++) { +if (!ioc->pcie_sg_lookup[i].pcie_sgl) +continue ;dma_pool_free (ioc->pcie_sgl_dma_pool, ioc->pcie_sg_lookup[i].pcie_sgl, ioc->pcie_sg_lookup[i].pcie_sgl_dma);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1444/1815 scsi: ufs: core: Set task state before io_schedule_timeout()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 720d8b2f2457f4962ca353dd90395e2660d9a10d ]
Set the task state to TASK_UNINTERRUPTIBLE before calling io_schedule_timeout() in ufshcd_wait_for_pending_cmds(). Without setting the task state, io_schedule_timeout() returns immediately because the task state remains TASK_RUNNING. This results in a busy loop that wastes CPU cycles.
--- drivers/ufs/core/ufshcd.c | 1 + 1 file changed, 1 insertion(+)
drivers/ufs/core/ufshcd.c +1 -0
@@ -1317,6 +1317,7 @@ static int ufshcd_wait_for_pending_cmds(struct ufs_hba *hba,break ; } +__set_current_state (TASK_UNINTERRUPTIBLE );io_schedule_timeout (msecs_to_jiffies (20 ));if (ktime_to_us (ktime_sub (ktime_get (), start)) > wait_timeout_us) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1445/1815 net: page_pool: fix UAF in __page_pool_release_netmem_dma on xa_cmpxchg race
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jijie Shao <[email protected]>
[ Upstream commit 24ef02f934eeb48830cff6b739abc3c62b1d107b ]
This bug was discovered while testing the hns3 driver under channel reconfiguration (ethtool -L / ethtool -G) with iperf3 traffic on arm64. The race is intermittently triggered when page_pool_destroy() runs page_pool_scrub() concurrently with page return via page_pool_put_netmem() on a different CPU. A WARN in page_pool_clear_pp_info() surfaced the dangling DMA index bits left by the cmpxchg loser, which led to the investigation.
page_pool_scrub() iterates pool->dma_mapped via xa_for_each() with no page ref held. __page_pool_release_netmem_dma() currently reads and writes netmem fields (dma_addr, DMA index bits in pp_magic) after xa_cmpxchg() returns. The unref path calls put_page() unconditionally regardless of the cmpxchg outcome; when it loses the cmpxchg, it still frees the page before the scrub winner finishes these netmem accesses, so scrub touches a freed page -- a Use-After-Free.
Fix this by splitting the DMA release into two functions:
1. __page_pool_unmap_netmem_dma() caches dma_addr before xa_cmpxchg(), does the cmpxchg to remove the DMA mapping, and calls dma_unmap on the cached address. It never touches netmem fields after the cmpxchg, making it safe for the scrub path which holds no page ref.
2. __page_pool_release_netmem_dma() wraps the above and additionally clears dma_addr and DMA index bits in netmem fields. This is safe only when the caller holds a page ref, so it is used by the return path (page_pool_return_netmem).
The scrub path calls __page_pool_unmap_netmem_dma() directly; the return path calls __page_pool_release_netmem_dma().
--- net/core/page_pool.c | 66 +++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 31 deletions(-)
net/core/page_pool.c +35 -31
@@ -500,29 +500,40 @@ static int page_pool_register_dma_index(struct page_pool *pool,return err; } -static int page_pool_release_dma_index (struct page_pool *pool, -netmem_ref netmem) +static void __page_pool_unmap_netmem_dma (struct page_pool *pool, +netmem_ref netmem) {struct page *old, *page =netmem_to_page (netmem);unsigned long id; +dma_addr_t dma; -if (unlikely (!PP_DMA_INDEX_BITS )) -return 0 ; - - id =netmem_get_dma_index (netmem); -if (!id) -return -1 ; +if (!pool->dma_map) +return ; -if (in_softirq ()) - old =xa_cmpxchg (&pool->dma_mapped, id, page,NULL ,0 ); -else - old =xa_cmpxchg_bh (&pool->dma_mapped, id, page,NULL ,0 ); -if (old != page) -return -1 ; +/* Cache dma_addr before xa_cmpxchg. The scrub path holds no page ref; +* the unref path calls put_page() regardless of cmpxchg outcome, so +* after the cmpxchg we cannot safely touch netmem fields. +*/ + dma =page_pool_get_dma_addr_netmem (netmem); -netmem_set_dma_index (netmem,0 ); +if (likely (PP_DMA_INDEX_BITS )) { + id =netmem_get_dma_index (netmem); +if (!id) +return ; + +if (in_softirq ()) + old =xa_cmpxchg (&pool->dma_mapped, + id, page,NULL ,0 ); +else + old =xa_cmpxchg_bh (&pool->dma_mapped, + id, page,NULL ,0 ); +if (old != page) +return ; + } -return 0 ; +dma_unmap_page_attrs (pool->p.dev, dma, +PAGE_SIZE << pool->p.order, pool->p.dma_dir, +DMA_ATTR_SKIP_CPU_SYNC |DMA_ATTR_WEAK_ORDERING ); }static bool page_pool_dma_map (struct page_pool *pool,netmem_ref netmem,gfp_t gfp)
@@ -728,24 +739,16 @@ void page_pool_clear_pp_info(netmem_ref netmem) static __always_inline void __page_pool_release_netmem_dma(struct page_pool *pool,netmem_ref netmem) { -dma_addr_t dma; - +/* Caller must hold a page ref: __page_pool_unmap_netmem_dma() is +* safe without a ref, but the field clears below require it. +*/ if (!pool->dma_map) -/* Always account for inflight pages, even if we didn't -* map them -*/ return ; -if (page_pool_release_dma_index (pool, netmem)) -return ; - - dma =page_pool_get_dma_addr_netmem (netmem); - -/* When page is unmapped, it cannot be returned to our pool */ -dma_unmap_page_attrs (pool->p.dev, dma, -PAGE_SIZE << pool->p.order, pool->p.dma_dir, -DMA_ATTR_SKIP_CPU_SYNC |DMA_ATTR_WEAK_ORDERING ); +__page_pool_unmap_netmem_dma (pool, netmem);page_pool_set_dma_addr_netmem (netmem,0 ); +if (likely (PP_DMA_INDEX_BITS )) +netmem_set_dma_index (netmem,0 ); }/* Disconnects a page (from a page_pool). API users can have a need
@@ -1171,8 +1174,9 @@ static void page_pool_scrub(struct page_pool *pool)synchronize_net (); } +/* No page ref, dma-unmap only. */ xa_for_each (&pool->dma_mapped, id, ptr) -__page_pool_release_netmem_dma (pool,page_to_netmem ((struct page *)ptr)); +__page_pool_unmap_netmem_dma (pool,page_to_netmem ((struct page *)ptr)); }/* No more consumers should exist, but producers could still
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1446/1815 bpf, arm64: Fix stack-passed arguments for indirect trampolines
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Puranjay Mohan <[email protected]>
[ Upstream commit 50de1c47a41d4031f6002969e71dc6954dedb6b2 ]
save_args() reads stack-passed arguments relative to FP assuming the trampoline is entered through the fentry call from a traced function, in which case both the parent frame (FP/x9) and the traced function frame (FP/LR) are saved before FP is set, so the arguments start at FP + 32.
An indirect trampoline for a struct_ops callback is entered through a function pointer (blr), so only the FP/LR frame is pushed and the arguments start at FP + 16, not FP + 32. Every stack-passed argument of a struct_ops callback with more than eight argument slots is read two slots off.
This went unnoticed because no struct_ops member passed arguments on the stack until bpf_testmod_ops3::test_arena_stack, added by
commit 2d4de9a493a0 ("selftests/bpf: Test stack-passed struct_ops arena arguments"). That member covers this on arm64 once the JIT gains arena argument support later in this series. Pass is_struct_ops into save_args() and pick the offset accordingly, mirroring the x86 fix.
--- arch/arm64/net/bpf_jit_comp.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
arch/arm64/net/bpf_jit_comp.c +13 -6
@@ -2512,9 +2512,8 @@ static void clear_garbage(struct jit_ctx *ctx, int reg, int effective_bytes) }static void save_args (struct jit_ctx *ctx,int bargs_off,int oargs_off, -const struct btf_func_model *m, -const struct arg_aux *a, -bool for_call_origin) +const struct btf_func_model *m,const struct arg_aux *a, +bool for_call_origin,bool is_struct_ops) {int i;int reg;
@@ -2534,7 +2533,15 @@ static void save_args(struct jit_ctx *ctx, int bargs_off, int oargs_off, bargs_off +=8 ; } - soff =32 ;/* on stack arguments start from FP + 32 */ +/* +* On-stack arguments start above the frame(s) pushed by the trampoline +* prologue. Entered through the fentry call from a traced function, the +* prologue saves both the parent (FP/x9) and the traced function +* (FP/LR) frames, so the arguments start at FP + 32. A struct_ops +* callback is called indirectly and only the FP/LR frame is saved, so +* they start at FP + 16. +*/ + soff = is_struct_ops ?16 :32 ; doff = (for_call_origin ? oargs_off : bargs_off);/* save on stack arguments */
@@ -2730,7 +2737,7 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im,store_func_meta (ctx, func_meta, func_meta_off);/* save args for bpf */ -save_args (ctx, bargs_off, oargs_off, m, a, false); +save_args (ctx, bargs_off, oargs_off, m, a, false, is_struct_ops);/* save callee saved registers */ emit (A64_STR64I (A64_R (19 ),A64_SP , regs_off), ctx);
@@ -2779,7 +2786,7 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im,if (flags &BPF_TRAMP_F_CALL_ORIG ) {/* save args for original func */ -save_args (ctx, bargs_off, oargs_off, m, a, true); +save_args (ctx, bargs_off, oargs_off, m, a, true, is_struct_ops);/* call original func */ emit (A64_LDR64I (A64_R (10 ),A64_SP , retaddr_off), ctx);emit (A64_ADR (A64_LR ,AARCH64_INSN_SIZE *2 ), ctx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1447/1815 fs/ntfs3: fix integer overflow in MFT cluster validation
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhan Xusheng <[email protected]>
[ Upstream commit c510c63873103a5da6a498fe537bdb5d6f8d03a2 ]
In ntfs_init_from_boot(), the boot sector's MFT cluster numbers are validated against the volume size with:
if (mlcn * sct_per_clst >= sectors || mlcn2 * sct_per_clst >= sectors) goto out;
mlcn and mlcn2 are u64 fields read directly from the boot sector. sct_per_clst is bounded above by 4096 (true_sectors_per_clst() plus the is_power_of_2() check below it), but the multiplication is done in u64 and wraps when mlcn (or mlcn2) is large enough -- e.g. mlcn near 2^62 with sct_per_clst == 4 wraps to 0, which compares below any non-zero 'sectors', so the check is bypassed and the malformed record is accepted.
The accepted mlcn is then used unchanged in
sbi->mft.lbo = mlcn << cluster_bits;
In practice the resulting reads fail at the block layer (sb_bread() returns NULL via grow_buffers()'s check_mul_overflow() guard), so today this manifests as mount failing in odd places rather than as something more dangerous, but the validation step is still wrong and there is no reason for callers to rely on the block layer to catch a value that should never have been accepted in the first place.
Use check_mul_overflow() to compute the two sector positions and fail the mount if either multiplication wraps; this preserves the existing semantics (mlcn * sct_per_clst >= sectors) instead of switching to division (mlcn >= sectors / sct_per_clst), which would tighten the check at edge cases where 'sectors' is not a multiple of sct_per_clst. The check_*_overflow() style is the one ntfs3 already uses for similar on-disk arithmetic in fs/ntfs3/run.c.
--- fs/ntfs3/super.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
fs/ntfs3/super.c +11 -2
@@ -65,6 +65,7 @@#include <linux/minmax.h> #include <linux/module.h> #include <linux/nls.h> +#include <linux/overflow.h> #include <linux/proc_fs.h> #include <linux/seq_file.h> #include <linux/statfs.h>
@@ -957,7 +958,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,struct ntfs_sb_info *sbi = sb->s_fs_info;int err;u32 mb, gb, boot_sector_size, sct_per_clst, record_size; -u64 sectors, clusters, mlcn, mlcn2, dev_size0; +u64 sectors, clusters, mlcn, mlcn2, mft_pos, mft2_pos, dev_size0;struct NTFS_BOOT *boot;struct buffer_head *bh;struct MFT_REC *rec;
@@ -1026,7 +1027,15 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size, mlcn2 =le64_to_cpu (boot->mft2_clst); sectors =le64_to_cpu (boot->sectors_per_volume); -if (mlcn * sct_per_clst >= sectors || mlcn2 * sct_per_clst >= sectors) { +/* +* Convert mlcn/mlcn2 to sector positions before comparing with +* 'sectors'. All three are u64 values that come from the boot +* sector, so use check_mul_overflow() to keep a wraparound from +* silently bypassing the comparison. +*/ +if (check_mul_overflow (mlcn, (u64 )sct_per_clst, &mft_pos) || +check_mul_overflow (mlcn2, (u64 )sct_per_clst, &mft2_pos) || + mft_pos >= sectors || mft2_pos >= sectors) { ntfs_err( sb, "%s: start of MFT 0x%llx (0x%llx) is out of volume 0x%llx.",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1448/1815 fs/ntfs3: reject out-of-range evcn in mi_enum_attr()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhan Xusheng <[email protected]>
[ Upstream commit 20fd9f64c0050658f2031e6bd5d552c6f0c8f7e3 ]
In mi_enum_attr(), the start/end VCN validation for non-resident attributes is:
if (svcn > evcn + 1) goto out;
When evcn is U64_MAX the "evcn + 1" expression wraps to 0 and any svcn passes the check. For evcn values close to U64_MAX (but not equal to it) the right-hand side is still a meaningless near-wrap upper bound, so a malformed on-disk attribute with svcn == 0 and evcn near U64_MAX can pass mi_enum_attr() unrejected.
VCN (virtual cluster number) is a cluster index, so any valid evcn is bounded by the volume's total cluster count, which ntfs3 holds in sbi->used.bitmap.nbits (set up in ntfs_init_from_boot() before any caller of mi_enum_attr() runs). Reject evcn values that fall outside this range.
However, an empty non-resident attribute (no allocated clusters) is legitimately encoded with svcn == 0 and evcn == -1 (U64_MAX), e.g. via attr->nres.evcn = cpu_to_le64((u64)vcn - 1) with vcn == 0. That sentinel must keep passing, so exclude evcn == U64_MAX from the range check. The existing "svcn > evcn + 1" test still tolerates the sentinel ("0 > 0" is false) and continues to require svcn == 0 for it, while the range check rejects every other out-of-range evcn and thereby also defuses the "evcn + 1" wraparound.
svcn does not need its own bound: once evcn < nbits, "svcn > evcn + 1" implies svcn <= nbits.
--- fs/ntfs3/record.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-)
fs/ntfs3/record.c +31 -3
@@ -202,7 +202,7 @@ struct ATTRIB *mi_enum_attr(struct ntfs_inode *ni, struct mft_inode *mi,u32 used =le32_to_cpu (rec->used);u32 t32, off, asize, prev_type;u16 t16; -u64 data_size, alloc_size, tot_size; +u64 svcn, evcn, data_size, alloc_size, tot_size;if (!attr) {u32 total =le32_to_cpu (rec->total);
@@ -310,10 +310,38 @@ struct ATTRIB *mi_enum_attr(struct ntfs_inode *ni, struct mft_inode *mi,if (t32 &&le16_to_cpu (attr->name_off) + t32 > t16) goto out; -/* Check start/end vcn. */ -if (le64_to_cpu (attr->nres.svcn) >le64_to_cpu (attr->nres.evcn) +1 ) +/* +* Check start/end vcn. svcn == 0 with evcn == -1 (U64_MAX) is the +* sentinel for an empty non-resident attribute (no allocated +* clusters) and must be accepted: "svcn > evcn + 1" tolerates it, +* since "(u64)-1 + 1" is 0 and "0 > 0" is false. +* +* For a non-empty attribute evcn is a cluster index and must lie +* within the volume (sbi->used.bitmap.nbits, set up in +* ntfs_init_from_boot() before any caller of mi_enum_attr() runs). +* Bounding evcn also prevents a malformed value close to U64_MAX +* from slipping through the near-wrap "evcn + 1" upper bound. +*/ + svcn =le64_to_cpu (attr->nres.svcn); + evcn =le64_to_cpu (attr->nres.evcn); +if (svcn > evcn +1 ) goto out; +if (is_attr_ext (attr)) { +/* sparsed/compressed attribute. */ +#ifdef CONFIG_NTFS3_64BIT_CLUSTER +/* No limits. */ +#else +/* Check evcn fits into 32 bits. */ +if (evcn !=U64_MAX && evcn >= (1ull <<32 )) + goto out; +#endif + }else { +/* Check out of volume for normal attribute. */ +if (evcn !=U64_MAX && evcn >= mi->sbi->used.bitmap.nbits) + goto out; + } + data_size =le64_to_cpu (attr->nres.data_size);if (le64_to_cpu (attr->nres.valid_size) > data_size) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1449/1815 ALSA: core: Fix use-after-free in snd_card_do_free()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Nogikh <[email protected]>
[ Upstream commit 5ae1a690c522fea2900ff56c8c2ace7b059f5e04 ]
A use-after-free was detected in snd_card_do_free() when a sound card managed by devres is unbound while a user-space application still holds an open file descriptor.
For managed cards, the memory is allocated using devres_alloc(), and its release function is set to __snd_card_release(), which calls snd_card_free(). When the device is unbound, the unbind thread calls snd_card_free(), which drops a reference to the card's device. If the user thread still has an open file descriptor, the reference count does not reach zero, and the unbind thread blocks on wait_for_completion(&released).
When the user thread closes the file descriptor, it drops the final reference, invoking the device release callback release_card_device(), which calls snd_card_do_free(). snd_card_do_free() performs cleanup and calls complete(card->release_completion). This wakes up the unbind thread, which returns from snd_card_free() and __snd_card_release(). The devres core then immediately frees the memory block containing the snd_card structure.
Meanwhile, the user thread continues execution in snd_card_do_free() and evaluates if (!card->managed). It reads the managed boolean from the snd_card structure that was just freed by the unbind thread, triggering a KASAN use-after-free.
Fix this by caching the value of card->managed in a local variable before calling complete(). This ensures that the card pointer is not dereferenced after the unbind thread has been woken up and potentially freed the card.
BUG: KASAN: use-after-free in snd_card_do_free sound/core/init.c:604 [inline] BUG: KASAN: use-after-free in release_card_device+0x1ab/0x1b0 sound/core/init.c:153 Read of size 1 at addr ffff8881912ec909 by task syz-executor130/5857 Call Trace: <TASK> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 print_address_description+0x55/0x1e0 mm/kasan/report.c:378 print_report+0x58/0x70 mm/kasan/report.c:482 kasan_report+0x117/0x150 mm/kasan/report.c:595 snd_card_do_free sound/core/init.c:604 [inline] release_card_device+0x1ab/0x1b0 sound/core/init.c:153 device_release+0xc4/0x1f0 drivers/base/core.c:-1 kobject_cleanup lib/kobject.c:689 [inline] kobject_release lib/kobject.c:720 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x222/0x550 lib/kobject.c:737 snd_card_file_remove+0x331/0x390 sound/core/init.c:1125 snd_pcm_release+0x12c/0x160 sound/core/pcm_native.c:2986 __fput+0x418/0xa50 fs/file_table.c:512 fput_close_sync+0x11f/0x240 fs/file_table.c:617 __do_sys_close fs/open.c:1511 [inline] __se_sys_close fs/open.c:1496 [inline] __x64_sys_close+0x7e/0x110 fs/open.c:1496 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x174/0x580 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>
--- sound/core/init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/core/init.c +3 -1
@@ -584,6 +584,8 @@ EXPORT_SYMBOL_GPL(snd_card_disconnect_sync);static int snd_card_do_free (struct snd_card *card) { +bool managed = card->managed; + card->releasing = true;#if IS_ENABLED (CONFIG_SND_MIXER_OSS )if (snd_mixer_oss_notify_callback)
@@ -601,7 +603,7 @@ static int snd_card_do_free(struct snd_card *card) }if (card->release_completion)complete (card->release_completion); -if (!card->managed) +if (!managed)kfree (card);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1450/1815 HID: haptic: dont write an uninitialized value to unhandled usages
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 3efb7f6491526f5012f9ec94769e9ed832feeef8 ]
fill_effect_buf() initializes value only for the four haptic usages handled by its switch, but writes it to field->value[] for every usage. An unhandled usage can therefore receive either an uninitialized value or one left over from the previous usage. hid_output_report() then serializes that value into the effect's report buffer.
Skip unhandled usages instead. This also matches switch_mode(), which only updates fields it recognizes.
Found with Clang's -Wconditional-uninitialized.
--- drivers/hid/hid-haptic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-haptic.c +1 -1
@@ -187,7 +187,7 @@ static void fill_effect_buf(struct hid_haptic_device *haptic, value = waveform_ordinal;break ;default : -break ; +continue ; } field->value[j] = value;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1451/1815 tracing: Have trace_event_update_all() only handle module that is loading
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
[ Upstream commit ae70b04ab9c7f6162a8c0fdd18a62a945c133142 ]
The function trace_event_update_all() does a scan of events looking to replace enums with their values in the strings that get exported to the event format files. It's run at boot up on all events and again when a module loads.
The issue is that when a module loads, it still runs on *all* events. There's no reason to process every event when a module loads as the previous events have already been processed. Only execute on the events that are loaded with the module.
--- kernel/trace/trace.c | 2 +- kernel/trace/trace.h | 4 ++-- kernel/trace/trace_events.c | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-)
kernel/trace/trace.c +1 -1
@@ -4669,7 +4669,7 @@ trace_event_update_with_eval_map(struct module *mod, map = start; -trace_event_update_all (map, len); +trace_event_update_all (map, len, mod);if (len <=0 )return ;
kernel/trace/trace.h +2 -2
@@ -2286,13 +2286,13 @@ static inline const char *get_syscall_name(int syscall)#ifdef CONFIG_EVENT_TRACING void trace_event_init (void ); -void trace_event_update_all (struct trace_eval_map **map,int len); +void trace_event_update_all (struct trace_eval_map **map,int len,struct module *mod);/* Used from boot time tracer */ extern int ftrace_set_clr_event (struct trace_array *tr,char *buf,int set);extern int trigger_process_regex (struct trace_event_file *file,char *buff);#else static inline void __init trace_event_init (void ) { } -static inline void trace_event_update_all (struct trace_eval_map **map,int len) { } +static inline void trace_event_update_all (struct trace_eval_map **map,int len,struct module *mod) { }#endif #ifdef CONFIG_TRACER_SNAPSHOT
kernel/trace/trace_events.c +5 -1
@@ -3577,7 +3577,7 @@ static void update_event_fields(struct trace_event_call *call, }/* Update all events for replacing eval and sanitizing */ -void trace_event_update_all (struct trace_eval_map **map,int len) +void trace_event_update_all (struct trace_eval_map **map,int len,struct module *mod) {struct trace_event_call *call, *p;const char *last_system =NULL ;
@@ -3589,6 +3589,10 @@ void trace_event_update_all(struct trace_eval_map **map, int len)mutex_lock (&event_mutex);down_write (&trace_event_sem);list_for_each_entry_safe (call, p, &ftrace_events, list) { + +if (mod && call->module != mod) +continue ; +/* events are usually grouped together with systems */ if (!last_system || call->class->system != last_system) { first = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1452/1815 ASoC: SOF: validate topology volume range before allocation
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 a698e4a60fa54268a38f4e66378851a196cb139b ]
SOF treats the topology mixer min and max values as non-negative indices into its volume table. It stores them in signed fields, allocates max + 1 entries through an int argument, and later indexes the table with the stored range.
An inverted range is invalid, while a maximum at or above INT_MAX cannot be represented safely after the increment or in the signed fields. Validate the complete range before storing it or allocating the table.
--- sound/soc/sof/topology.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
sound/soc/sof/topology.c +12 -6
@@ -846,6 +846,7 @@ static int sof_control_load_volume(struct snd_soc_component *scomp,struct snd_soc_tplg_mixer_control *mc = container_of(hdr, struct snd_soc_tplg_mixer_control, hdr);int tlv[SOF_TLV_ITEMS ]; +u32 min, max;unsigned int mask;int ret;
@@ -853,6 +854,11 @@ static int sof_control_load_volume(struct snd_soc_component *scomp,if (le32_to_cpu (mc->num_channels) >SND_SOC_TPLG_MAX_CHAN )return -EINVAL ; + min =le32_to_cpu (mc->min); + max =le32_to_cpu (mc->max); +if (min > max || max >=INT_MAX ) +return -EINVAL ; +/* * If control has more than 2 channels we need to override the info. This is because even if * ASoC layer has defined topology's max channel count to SND_SOC_TPLG_MAX_CHAN = 8, the
@@ -863,12 +869,12 @@ static int sof_control_load_volume(struct snd_soc_component *scomp, kc->info = snd_sof_volume_info; scontrol->comp_id = sdev->next_comp_id; - scontrol->min_volume_step =le32_to_cpu (mc->min); - scontrol->max_volume_step =le32_to_cpu (mc->max); + scontrol->min_volume_step = min; + scontrol->max_volume_step = max; scontrol->num_channels =le32_to_cpu (mc->num_channels); - scontrol->max =le32_to_cpu (mc->max); -if (le32_to_cpu (mc->max) ==1 ) + scontrol->max = max; +if (max ==1 ) goto skip;/* extract tlv data */
@@ -878,7 +884,7 @@ static int sof_control_load_volume(struct snd_soc_component *scomp, }/* set up volume table */ - ret =set_up_volume_table (scontrol, tlv,le32_to_cpu (mc->max) +1 ); + ret =set_up_volume_table (scontrol, tlv, max +1 );if (ret <0 ) {dev_err (scomp->dev,"error: setting up volume table\n" );return ret;
@@ -911,7 +917,7 @@ static int sof_control_load_volume(struct snd_soc_component *scomp,return 0 ; err: -if (le32_to_cpu (mc->max) >1 ) +if (max >1 )kfree (scontrol->volume_table);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1453/1815 HID: multitouch: reclassify HTIX5288 to WIN_8_FORCE_MULTI_INPUT_NSMU
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xianglin Lin <[email protected]>
[ Upstream commit 69226cd6fad7a07370ec9a009af1c174de7635c5 ]
Commit b5e65ae557da ("HID: multitouch: Add quirk for Hantick 5288 touchpad") assigned MT_CLS_NSMU to the HTIX5288 (0911:5288). This was necessary because the device sometimes fails to send touch release signals when transitioning from >=2 fingers to <2 fingers, and MT_QUIRK_NOT_SEEN_MEANS_UP fixes stuck touches by treating missing contacts as released.
However, MT_CLS_NSMU only carries MT_QUIRK_NOT_SEEN_MEANS_UP. It lacks MT_QUIRK_CONTACT_CNT_ACCURATE and MT_QUIRK_IGNORE_DUPLICATES. As a result, after a two-finger scroll finger lift, the device still reports stale coordinates from the released contact in subsequent frames, and the driver overwrites the remaining active slot with those frozen coordinates. The remaining finger appears stuck at the lift position until all fingers are lifted.
This was confirmed via evtest on Arch Linux 7.1.3: after TRACKING_ID=-1 for the released slot, every subsequent frame contained duplicate position pairs -- the real moving finger's coordinates followed by the lifted finger's frozen position, both attributed to the active slot.
Reclassify the device to MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU (0x0018), which preserves the original MT_QUIRK_NOT_SEEN_MEANS_UP fix while adding the necessary Win8 quirks (CONTACT_CNT_ACCURATE, IGNORE_DUPLICATES), preventing stale coordinate contamination.
The additional FORCE_MULTI_INPUT flag is harmless here: it separates the mouse and touchpad collections into distinct input devices, which is the standard behavior libinput already expects.
--- drivers/hid/hid-multitouch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-multitouch.c +1 -1
@@ -2722,7 +2722,7 @@ static const struct hid_device_id mt_devices[] = { HID_ANY_ID) },/* Hantick */ - { .driver_data = MT_CLS_NSMU, + { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU,HID_DEVICE (BUS_I2C ,HID_GROUP_MULTITOUCH_WIN_8 , I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288) },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1454/1815 HID: tmff: Use 64-bit arithmetic for force feedback scaling
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 463f7cc26ce3ccc8fb76d6194f83214be7105e2f ]
The logical minimum and maximum values come from the HID report descriptor and cover the full signed 32-bit range. Subtracting them in an int can overflow before the force feedback value is scaled. The subsequent multiplication can overflow as well, producing an incorrect value despite the final range checks.
Use 64-bit intermediates for both scaling helpers, as done by commit 48d1677779ad ("HID: pidff: Fix integer overflow in pidff_rescale") for the same arithmetic in the PID driver. This keeps the arithmetic defined for the complete descriptor range before the result is clamped.
--- drivers/hid/hid-tmff.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/hid/hid-tmff.c +5 -4
@@ -17,6 +17,7 @@#include <linux/hid.h> #include <linux/input.h> +#include <linux/math64.h> #include <linux/slab.h> #include <linux/module.h>
@@ -47,9 +48,9 @@ struct tmff_device {/* Changes values from 0 to 0xffff into values from minimum to maximum */ static inline int tmff_scale_u16 (unsigned int in,int minimum,int maximum) { -int ret; +s64 ret; - ret = (in * (maximum - minimum) /0xffff ) + minimum; + ret =div_s64 ((s64 )in * ((s64 )maximum - minimum),0xffff ) + minimum;if (ret < minimum)return minimum;if (ret > maximum)
@@ -60,9 +61,9 @@ static inline int tmff_scale_u16(unsigned int in, int minimum, int maximum)/* Changes values from -0x80 to 0x7f into values from minimum to maximum */ static inline int tmff_scale_s8 (int in,int minimum,int maximum) { -int ret; +s64 ret; - ret = (((in +0x80 ) * (maximum - minimum)) /0xff ) + minimum; + ret =div_s64 ((s64)(in +0x80 ) * ((s64 )maximum - minimum),0xff ) + minimum;if (ret < minimum)return minimum;if (ret > maximum)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1455/1815 selftests/bpf: Use ping_command() for IPv6 pings in lwt_ip_encap
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrii Nakryiko <[email protected]>
[ Upstream commit 073574da7a8e6055b1687c256bea070ab4b4ebea ]
lwt_ip_encap hardcodes the ping6 binary for its IPv6 pings. iputils merged ping6 into ping long ago and distros have started dropping the compat symlink -- Arch's iputils 20250605 ships only arping, clockdiff, ping and tracepath. There, every lwt_ip_encap subtest fails:
check_ping_ok:FAIL:ip netns exec ns-lwt-ip-encap-1-0101330 ping6 -c 1 \
-W1 -I veth1 fb04::1 > /dev/null unexpected error: 256 (errno 2)
#217/1 lwt_ip_encap_ipv4/egress:FAILThe IPv4 subtests fail too, because check_ping_ok() pings both families. SYS() runs the command through system(), so a missing binary is indistinguishable from an unreachable peer.
network_helpers.c has had ping_command() for exactly this since commit 372642ea83ff ("selftests/bpf: Move netcnt test under test_progs"): it falls back to "ping -6" when ping6 is not present. lwt_ip_encap.c is the last hardcoded ping6 user. Fix that.
--- tools/testing/selftests/bpf/prog_tests/lwt_ip_encap.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/prog_tests/lwt_ip_encap.c +7 -4
@@ -410,7 +410,8 @@ static int test_gso_fix(const char *ns1, const char *ns3, int family)static int check_ping_ok (const char *ns1) {SYS (fail,"ip netns exec %s ping -c 1 -W1 -I veth1 %s > /dev/null" , ns1,IP4_ADDR_DST ); -SYS (fail,"ip netns exec %s ping6 -c 1 -W1 -I veth1 %s > /dev/null" , ns1,IP6_ADDR_DST ); +SYS (fail,"ip netns exec %s %s -c 1 -W1 -I veth1 %s > /dev/null" , ns1, +ping_command (AF_INET6 ),IP6_ADDR_DST );return 0 ; fail:return -1 ;
@@ -424,7 +425,8 @@ static int check_ping_fails(const char *ns1)if (!ret)return -1 ; - ret =SYS_NOFAIL ("ip netns exec %s ping6 -c 1 -W1 -I veth1 %s" , ns1,IP6_ADDR_DST ); + ret =SYS_NOFAIL ("ip netns exec %s %s -c 1 -W1 -I veth1 %s" , ns1, +ping_command (AF_INET6 ),IP6_ADDR_DST );if (!ret)return -1 ;
@@ -657,9 +659,10 @@ static void lwt_ip_encap_vxlan(bool ipv4_encap) skel->bss->fexit_triggered = false;if (ipv4_encap) -SYS (out,"ip netns exec %s ping -c 1 -W1 %s" , ns1,IP4_ADDR_DST ); +SYS (out,"ip netns exec %s ping -c 1 -W1 %s" , ns1,IP4_ADDR_DST );else -SYS (out,"ip netns exec %s ping6 -c 1 -W1 %s" , ns1,IP6_ADDR_DST ); +SYS (out,"ip netns exec %s %s -c 1 -W1 %s" , ns1, +ping_command (AF_INET6 ),IP6_ADDR_DST );if (!ASSERT_TRUE (skel->bss->fexit_triggered,"fexit_triggered" )) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1456/1815 bpf: Fix arm64 KASAN false positive after bpf_throw
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mykyta Yatsenko <[email protected]>
[ Upstream commit b0e872a31e157d48479507c2821ba8bf6323b7ad ]
arm64 passes zero as the stack pointer while walking BPF frames, so bpf_throw() leaves stale KASAN stack poison after jumping to the exception callback.
Use the frame pointer as the fallback stack watermark.
--- kernel/bpf/helpers.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/bpf/helpers.c +5 -3
@@ -3395,11 +3395,13 @@ __bpf_kfunc void bpf_throw(u64 cookie)WARN_ON_ONCE (!ctx.aux->exception_boundary);WARN_ON_ONCE (!ctx.bp);WARN_ON_ONCE (!ctx.cnt); -/* Prevent KASAN false positives for CONFIG_KASAN_STACK by unpoisoning +/* +* Prevent KASAN false positives for CONFIG_KASAN_STACK by unpoisoning * deeper stack depths than ctx.sp as we do not return from bpf_throw, -* which skips compiler generated instrumentation to do the same. +* which skips compiler generated instrumentation to do the same. Some +* architectures cannot recover sp while unwinding, so fall back to bp. */ -kasan_unpoison_task_stack_below ((void *)(long )ctx.sp); +kasan_unpoison_task_stack_below ((void *)(long )(ctx.sp ?: ctx.bp)); ctx.aux->bpf_exception_cb (cookie, ctx.sp + ctx.aux->stack_arg_sp_adjust, ctx.bp,0 ,0 );WARN (1 ,"A call to BPF exception callback should never return\n" ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1457/1815 riscv, bpf: Fix missing sign-ext for signed 1-byte and 2-byte kfunc args
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 f2aaa621591093cfe8224a25ef2f04a3b1e304b0 ]
On RV64, the ABI requires sign-extension for signed 1-byte and 2-byte kfunc args. However, the RV64 JIT currently does not perform sign-extension for such kfunc args.
Before commit 7ce090afbf72 ("bpf: Infer zext_dst based on static register liveness analysis"), state pruning could potentially omit zero-extension of 32-bit subregisters, which inadvertently masked the above issue by making the args appear as if they had been properly sign-extended. After that commit, the problem is exposed, causing the kfunc_call/kfunc_call_test4 selftest to fail.
Fix this by extending the existing sign-extension logic to handle signed 1-byte and 2-byte kfunc args as well.
--- arch/riscv/net/bpf_jit_comp64.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/riscv/net/bpf_jit_comp64.c +3 -2
@@ -1830,9 +1830,10 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,for (idx =0 ; idx < fm->nr_args; idx++) {u8 reg =bpf_to_rv_reg (BPF_REG_1 + idx, ctx); +bool sign = fm->arg_flags[idx] &BTF_FMODEL_SIGNED_ARG ; -if (fm->arg_size[idx] ==sizeof (int )) -emit_sextw (reg, reg, ctx); +if (sign_extend (reg, reg, fm->arg_size[idx], sign, ctx)) +return -EINVAL ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1458/1815 ring-buffer: Remove trace_buffer::cpus
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <[email protected]>
[ Upstream commit d9b5e22bf24d5c82522475306cd332b287ac43bc ]
The 'cpus' field in struct trace_buffer became useless in commit 8e7b58c27b3c ("ring-buffer: Just update the subbuffers when changing their allocation order"). Remove it
--- kernel/trace/ring_buffer.c | 2 -- 1 file changed, 2 deletions(-)
kernel/trace/ring_buffer.c +0 -2
@@ -572,7 +572,6 @@ struct ring_buffer_per_cpu {struct trace_buffer {unsigned flags; -int cpus;atomic_t record_disabled;atomic_t resizing;cpumask_var_t cpumask;
@@ -2783,7 +2782,6 @@ static struct trace_buffer *alloc_buffer(unsigned long size, unsigned flags,init_irq_work (&buffer->irq_work.work, rb_wake_up_waiters);init_waitqueue_head (&buffer->irq_work.waiters); - buffer->cpus = nr_cpu_ids; bsize =sizeof (void *) * nr_cpu_ids; buffer->buffers = kzalloc(ALIGN(bsize, cache_line_size()),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1459/1815 ACPI: scan: fix bus ID cleanup on device_add() failures
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xu <[email protected]>
[ Upstream commit a414485ebc2aa50907d0ce97cde2b1a353696897 ]
When device_add() fails after acpi_device_set_name() has allocated an instance ID and a new acpi_device_bus_id has been linked into acpi_bus_id_list, the rollback path only removes wakeup_list and detaches the ACPI handle data.
That leaves the bus-ID bookkeeping behind and keeps the allocated instance number consumed.
Move the bus-ID cleanup and wakeup-list removal into a single helper.
Use it from both the normal device teardown path and the device_add() rollback path. The wakeup list node is initialized before registration, so it can be deleted without checking whether the device is wakeup- capable like in the original teardown path.
--- drivers/acpi/scan.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/acpi/scan.c +9 -4
@@ -524,12 +524,10 @@ static void acpi_device_release(struct device *dev)kfree (acpi_dev); } -static void acpi_device_del (struct acpi_device *device) +static void acpi_device_cleanup (struct acpi_device *device) {struct acpi_device_bus_id *acpi_device_bus_id; -mutex_lock (&acpi_device_lock); -list_for_each_entry (acpi_device_bus_id, &acpi_bus_id_list, node)if (!strcmp (acpi_device_bus_id->bus_id,acpi_device_hid (device))) {
@@ -544,6 +542,13 @@ static void acpi_device_del(struct acpi_device *device) }list_del (&device->wakeup_list); +} + +static void acpi_device_del (struct acpi_device *device) +{ +mutex_lock (&acpi_device_lock); + +acpi_device_cleanup (device);mutex_unlock (&acpi_device_lock);
@@ -803,7 +808,7 @@ int acpi_device_add(struct acpi_device *device) err:mutex_lock (&acpi_device_lock); -list_del (&device->wakeup_list); +acpi_device_cleanup (device); err_unlock:mutex_unlock (&acpi_device_lock);
Signature · 1 line
2.53.0