7.2.6-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 1197/1815 coresight: etm4x: missing cscfg_csdev_disable_active_config() in perf enable
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yeoreum Yun <[email protected]>
[ Upstream commit 0a47f0be6557b4a851addd430383a4dc7ee08752 ]
In the perf enable path, there are missing cases where cscfg_csdev_disable_active_config() is not called:
- Branch broadcast is selected but not supported by the hardware
- etm4_enable_hw() fails
This can lead to a leak of config_desc->active_cnt. Fix this by properly calling cscfg_csdev_disable_active_config() in these error paths.
--- .../coresight/coresight-etm4x-core.c | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +25 -19
@@ -757,8 +757,7 @@ static int etm4_parse_event_config(struct coresight_device *csdev, .ATTR_CFG_FLD_timestamp_CFG = U64_MAX, };struct perf_event_attr *attr = &event->attr; -unsigned long cfg_hash; -int preset, cc_threshold; +int cc_threshold;u8 ts_level;/* Clear configuration from previous run */
@@ -844,16 +843,6 @@ static int etm4_parse_event_config(struct coresight_device *csdev,/* bit[12], Return stack enable bit */ config->cfg |=TRCCONFIGR_RS ; -/* -* Set any selected configuration and preset. A zero configid means no -* configuration active, preset = 0 means no preset selected. -*/ - cfg_hash =ATTR_CFG_GET_FLD (attr, configid); -if (cfg_hash) { - preset =ATTR_CFG_GET_FLD (attr, preset); - ret =cscfg_csdev_enable_active_config (csdev, cfg_hash, preset); - } -/* branch broadcast - enable if selected and supported */ if (ATTR_CFG_GET_FLD (attr, branch_broadcast)) {if (!drvdata->trcbb) {
@@ -877,7 +866,9 @@ static int etm4_enable_perf(struct coresight_device *csdev, struct coresight_path *path) {struct etmv4_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); -int ret; +struct perf_event_attr *attr = &event->attr; +unsigned long cfg_hash; +int ret, preset;if (WARN_ON_ONCE (drvdata->cpu !=smp_processor_id ()))return -EINVAL ;
@@ -888,7 +879,19 @@ static int etm4_enable_perf(struct coresight_device *csdev,/* Configure the tracer based on the session's specifics */ ret =etm4_parse_event_config (csdev, event);if (ret) - goto out; + goto err; + +/* +* Set any selected configuration and preset. A zero configid means no +* configuration active, preset = 0 means no preset selected. +*/ + cfg_hash =ATTR_CFG_GET_FLD (attr, configid); +if (cfg_hash) { + preset =ATTR_CFG_GET_FLD (attr, preset); + ret =cscfg_csdev_enable_active_config (csdev, cfg_hash, preset); +if (ret) + goto err; + } drvdata->trcid = path->trace_id;
@@ -897,16 +900,19 @@ static int etm4_enable_perf(struct coresight_device *csdev,/* And enable it */ ret =etm4_enable_hw (drvdata); - -out: -/* Failed to start tracer; roll back to DISABLED mode */ if (ret) { -coresight_set_mode (csdev,CS_MODE_DISABLED ); -return ret; +if (cfg_hash) +cscfg_csdev_disable_active_config (csdev); + goto err; } csdev->path = path;return 0 ; + +err: +/* Failed to start tracer; roll back to DISABLED mode */ +coresight_set_mode (csdev,CS_MODE_DISABLED ); +return ret; }static int etm4_enable_sysfs (struct coresight_device *csdev,struct coresight_path *path)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1198/1815 perf: arm_pmuv3: Zero initialize hw_id branch stack field
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Clark <[email protected]>
[ Upstream commit 7c3b63386c27bed8d59a4b4c283d02860420eb0a ]
PERF_SAMPLE_BRANCH_HW_INDEX is supported by BRBE so hw_id is passed to userspace, but it's never set by the BRBE driver. Zero initialize it as it should be according to the docs:
* For the architectures whose raw branch records are
* already stored in age order, the hw_idx should be 0.
It's probably too risky to remove PERF_SAMPLE_BRANCH_HW_INDEX from BRBE now in case anyone is setting it and reading the value, but zero initializing the whole struct also protects against the same issue with new fields that are added in the future.
--- drivers/perf/arm_pmuv3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/arm_pmuv3.c +1 -1
@@ -1361,7 +1361,7 @@ static int branch_records_alloc(struct arm_pmu *armpmu)struct pmu_hw_events *events_cpu; events_cpu =per_cpu_ptr (armpmu->hw_events, cpu); - events_cpu->branch_stack =kmalloc (size,GFP_KERNEL ); + events_cpu->branch_stack =kzalloc (size,GFP_KERNEL );if (!events_cpu->branch_stack)return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1199/1815 arm_mpam: Fix a NULL pointer dereference on unbinding after an error interrupt
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Horgan <[email protected]>
[ Upstream commit fc996c39689bb15aa80e5366809434f7258fb703 ]
If a user unbinds an MSC after mpam_disable() has been run in response to an error interrupt then a dereference of a NULL pointer occurs as mpam_disable() sets the drvdata to NULL. Add an early return to the driver remove callback to avoid this.
--- drivers/resctrl/mpam_devices.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/resctrl/mpam_devices.c +3 -0
@@ -2023,6 +2023,9 @@ static void mpam_msc_drv_remove(struct platform_device *pdev) {struct mpam_msc *msc =platform_get_drvdata (pdev); +if (!msc) +return ; +mutex_lock (&mpam_list_lock);mpam_msc_destroy (msc);mutex_unlock (&mpam_list_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1200/1815 arm_mpam: Disable driver unbind to avoid UAF
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Horgan <[email protected]>
[ Upstream commit bb1a0f582d519c0461b0940116e2b52c5ba31459 ]
When a user unbinds an MSC and that MSC is the only MSC left for a component then the corresponding mpam_component will be freed. If the user then goes on to read the schemata file in the resctrl filesystem then the mpam_component will be accessed from resctrl_arch_get_config() leading to a use after free.
As the MPAM driver is not a module the unbind sysfs interface is the only way to trigger the remove. Instead of dealing with the complexity of allowing some unused MSC to unbind just remove the unbind sysfs interface.
--- drivers/resctrl/mpam_devices.c | 1 + 1 file changed, 1 insertion(+)
drivers/resctrl/mpam_devices.c +1 -0
@@ -2139,6 +2139,7 @@ static int mpam_msc_drv_probe(struct platform_device *pdev)static struct platform_driver mpam_msc_driver = { .driver = { .name ="mpam_msc" , + .suppress_bind_attrs = true, }, .probe = mpam_msc_drv_probe, .remove = mpam_msc_drv_remove,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1201/1815 bpf: Reject load-acquire from pointers requiring fault protection
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 7db0a00445f1a40bacfe9b747405c11cb5f10fc9 ]
A BPF_LOAD_ACQ is not rewritten to a BPF_PROBE_MEM load by the verifier, unlike a regular BPF_LDX, so the JIT emits a plain load with no exception table entry and a fault panics the kernel instead of being handled.
Reject the source pointer types that a BPF_LDX would have had that fault protection applied to, i.e. the ones bpf_convert_ctx_accesses() turns into BPF_PROBE_MEM: a bare PTR_TO_BTF_ID, PTR_TO_BTF_ID | PTR_UNTRUSTED, PTR_TO_BTF_ID | MEM_ALLOC | PTR_UNTRUSTED and PTR_TO_MEM | MEM_RDONLY | PTR_UNTRUSTED.
This is reachable e.g. by loading ->mm out of a trusted task_struct yields an untrusted pointer to mm_struct, and it is NULL for a kernel thread:
[...]
SEC("tp_btf/sched_switch")
int BPF_PROG(demo, bool preempt, struct task_struct *prev,
struct task_struct *next)
{
struct mm_struct *mm = next->mm; /* untrusted */
out_ldx = (__u64)mm->pgd; /* BPF_LDX */
out_acq = load_acquire(&mm->pgd); /* BPF_LOAD_ACQ */
return 0; }
[...]
Both dereference the same pointer, but only the BPF_LDX is protected (x86-64 JIT, jump targets shown prog-relative):
[...]
; out_ldx = (__u64)mm->pgd;
17: movq $-10485760, %r10 1e: movq %rsi, %r11 21: addq $184, %r11 28: subq %r10, %r11 2b: movabsq $140737498841088, %r10 35: cmpq %r10, %r11 38: ja 0x3e <-- kernel addr? 3a: xorl %edi, %edi <-- no: dst = 0, skip the load 3c: jmp 0x45 3e: movq 184(%rsi), %rdi <-- yes: load + extable entry
[...]
; load_acquire(&mm->pgd)
53: movq %rsi, %rdi
56: movq 184(%rdi), %rax <-- no check, no extable entry
[...]
Note that BPF_PROBE_MEM is not visible in a bpftool xlated dump, as bpf_insn_prepare_dump() rewrites it back to BPF_MEM.
A PTR_TRUSTED pointer is deliberately not on the list. Such a load is not converted either, but it does not need to be, since the pointer is guaranteed live, so load-acquire from it stays allowed.
The check is gated on BPF_LOAD_ACQ so that atomic RMW and store-release error messages are unchanged; writes (RMW / store-release) to such pointers are already rejected elsewhere, so only load-acquire needs this.
--- kernel/bpf/verifier.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
kernel/bpf/verifier.c +26 -1
@@ -4843,6 +4843,30 @@ static bool is_arena_reg(struct bpf_verifier_env *env, int regno)return reg->type ==PTR_TO_ARENA ; } +static bool is_load_acq_unsafe (struct bpf_verifier_env *env,int regno, +struct bpf_insn *insn) +{ +const struct bpf_reg_state *reg =reg_state (env, regno); + +/* +* A BPF_LOAD_ACQ is not rewritten to a BPF_PROBE_MEM load by the +* verifier, unlike a regular BPF_LDX. The JIT would emit a plain load +* with no exception table entry, so a fault (e.g. NULL deref) crashes +* the kernel instead of being handled. +* +* Reject the source pointer types that a BPF_LDX would have had that +* fault protection applied to, i.e. the ones bpf_convert_ctx_accesses() +* turns into BPF_PROBE_MEM: a bare PTR_TO_BTF_ID and any PTR_UNTRUSTED +* pointer (untrusted btf ids, untrusted MEM_ALLOC, rdonly untrusted +* memory). A PTR_TRUSTED pointer is not among them, is not converted, +* and stays allowed. Same for the other flagged PTR_TO_BTF_ID variants +* (MEM_ALLOC, MEM_RCU, ...), hence the exact match on the base type. +*/ +return insn->imm ==BPF_LOAD_ACQ && + (reg->type ==PTR_TO_BTF_ID || + (type_flag (reg->type) &PTR_UNTRUSTED )); +} +/* Return false if @regno contains a pointer whose type isn't supported for * atomic instruction @insn. */
@@ -4859,7 +4883,8 @@ static bool atomic_ptr_type_ok(struct bpf_verifier_env *env, int regno,return false;if (is_arena_reg (env, regno))return bpf_jit_supports_insn (insn, true); - +if (is_load_acq_unsafe (env, regno, insn)) +return false;return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1202/1815 bpf, riscv: Add and use bpf_atomic_is_load_acq() helper
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 e2577cd62060be91a3d7d11a56e5a61faae4b7f7 ]
A load-acquire is the only BPF_STX class instruction that reads from src_reg into dst_reg, that is, it has the operand roles of a BPF_LDX. JIT code which tells loads from stores apart by instruction class alone has to special case it, for example when deciding which register holds the faulting address and which one to clear from an exception handler.
riscv64 already does so, open coded as a bare insn->imm test. Add a bpf_atomic_is_load_acq() helper and convert riscv64 over to it, so that the x86-64 and arm64 JITs can use the same helper in subsequent patches.
Unlike bpf_atomic_is_load_store(), which presumes that its argument is already known to be a BPF_ATOMIC instruction, the new helper is called from code which still sees all instruction classes, so it checks class and mode itself.
Also, move bpf_atomic_is_load_store() to filter.h next to BPF_ATOMIC_OP, so that both helpers stay together. No functional change intended.
Stable-dep-of: 4cf8def58b77 ("bpf, x86: Fix exception table metadata for arena load-acquire")
--- arch/riscv/net/bpf_jit_comp64.c | 2 +- include/linux/bpf.h | 15 --------------- include/linux/filter.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 16 deletions(-)
arch/riscv/net/bpf_jit_comp64.c +1 -1
@@ -1988,7 +1988,7 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,/* ret can be 1 (skip-zext); extable entry still needs to be added */ if (ret >=0 ) ret =add_exception_handler (insn, - insn->imm ==BPF_LOAD_ACQ ? rd :REG_DONT_CLEAR_MARKER , +bpf_atomic_is_load_acq (insn) ? rd :REG_DONT_CLEAR_MARKER , ctx) ?: ret;if (ret)
include/linux/bpf.h +0 -15
@@ -1118,21 +1118,6 @@ static inline bool bpf_pseudo_func(const struct bpf_insn *insn)return bpf_is_ldimm64 (insn) && insn->src_reg ==BPF_PSEUDO_FUNC ; } -/* Given a BPF_ATOMIC instruction @atomic_insn, return true if it is an -* atomic load or store, and false if it is a read-modify-write instruction. -*/ -static inline bool -bpf_atomic_is_load_store (const struct bpf_insn *atomic_insn) -{ -switch (atomic_insn->imm) { -case BPF_LOAD_ACQ : -case BPF_STORE_REL : -return true; -default : -return false; - } -} -struct bpf_prog_ops {int (*test_run)(struct bpf_prog *prog,const union bpf_attr *kattr,union bpf_attr __user *uattr);
include/linux/filter.h +31 -0
@@ -383,6 +383,37 @@ static inline bool insn_is_cast_user(const struct bpf_insn *insn)/* Legacy alias */ #define BPF_STX_XADD (SIZE ,DST ,SRC ,OFF ) BPF_ATOMIC_OP(SIZE, BPF_ADD, DST, SRC, OFF) +/* +* Given a BPF_ATOMIC instruction @atomic_insn, return true if it is an +* atomic load or store, and false if it is a read-modify-write instruction. +*/ +static inline bool +bpf_atomic_is_load_store (const struct bpf_insn *atomic_insn) +{ +switch (atomic_insn->imm) { +case BPF_LOAD_ACQ : +case BPF_STORE_REL : +return true; +default : +return false; + } +} + +/* +* A load-acquire is the only BPF_STX class instruction that reads into +* dst_reg from src_reg + off16, i.e. it has the operand roles of a BPF_LDX. +* Unlike bpf_atomic_is_load_store(), @insn is not assumed to be a BPF_ATOMIC +* instruction here, so that callers which walk all instruction classes can +* use this directly. +*/ +static inline bool bpf_atomic_is_load_acq (const struct bpf_insn *insn) +{ +return BPF_CLASS (insn->code) ==BPF_STX && + (BPF_MODE (insn->code) ==BPF_ATOMIC || +BPF_MODE (insn->code) ==BPF_PROBE_ATOMIC ) && + insn->imm ==BPF_LOAD_ACQ ; +} +/* Memory store, *(uint *) (dst_reg + off16) = imm32 */ #define BPF_ST_MEM (SIZE ,DST ,OFF ,IMM ) \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1203/1815 bpf, x86: Fix exception table metadata for arena load-acquire
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 4cf8def58b779ad2827f81760837b7a844d6c7d6 ]
A load-acquire from an arena pointer is converted to BPF_PROBE_ATOMIC and gets an exception table entry, but the entry is filled in as if it were a store, since populate_extable() decides based on instruction class alone and a load-acquire is of BPF_STX class:
if (BPF_CLASS(insn->code) == BPF_LDX) {
arena_reg = reg2pt_regs[src_reg];
fixup_reg = reg2pt_regs[dst_reg];
} else {
arena_reg = reg2pt_regs[dst_reg];
fixup_reg = DONT_CLEAR;
}For a load-acquire dst_reg holds the loaded value and src_reg holds the address, so both assignments in the else branch are wrong. On a fault over an unmapped arena page ex_handler_bpf() then:
- computes the reported address from the value register instead of the address register
- reports the access as a WRITE, since it derives the direction
from fixup_reg == DONT_CLEAR
- leaves dst_reg untouched, so the program continues with a stale value instead of the 0 that BPF_PROBE_* loads deliver
The access itself is emitted correctly, emit_atomic_ld_st_index() uses src_reg as the address, so this is a broken probe contract and a wrong diagnostic rather than a memory safety issue.
Use bpf_atomic_is_load_acq() helper so a load-acquire takes the load path.
--- arch/x86/net/bpf_jit_comp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/net/bpf_jit_comp.c +6 -1
@@ -2331,8 +2331,13 @@ st: insn_off = insn->off;* BPF_PROBE_ATOMIC) before being used for the memory access. Pass * the reg holding the unmodified 32-bit address to * ex_handler_bpf(). +* +* 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. */ -if (BPF_CLASS (insn->code) ==BPF_LDX ) { +if (BPF_CLASS (insn->code) ==BPF_LDX || +bpf_atomic_is_load_acq (insn)) { arena_reg = reg2pt_regs[src_reg]; fixup_reg = reg2pt_regs[dst_reg]; }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1204/1815 bpf, arm64: Fix exception table metadata for arena load-acquire
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 af22d273aa1f61fb86ec712b3ed785da73c3296e ]
Same problem as on x86-64: add_exception_handler() decides whether an instruction is a load by its class, and a load-acquire is of BPF_STX class even though it reads from src_reg into dst_reg. As a result ...
if (BPF_CLASS(insn->code) != BPF_LDX)
dst_reg = DONT_CLEAR;... drops the register to clear, and ...
if (BPF_CLASS(insn->code) == BPF_LDX)
arena_reg = bpf2a64[insn->src_reg];
else
arena_reg = bpf2a64[insn->dst_reg];... hands ex_handler_bpf() the value register instead of the address register. A load-acquire from an arena pointer that faults on an unmapped page is therefore reported as a WRITE at a bogus address, and dst_reg keeps its previous value instead of being cleared to 0.
Note that emit_atomic_ld_st() already picks src_reg as the address for BPF_LOAD_ACQ, so only the exception table metadata was out of sync with the emitted access.
Same as on x86-64, use bpf_atomic_is_load_acq() so a load-acquire takes the load path.
--- arch/arm64/net/bpf_jit_comp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm64/net/bpf_jit_comp.c +7 -2
@@ -1178,7 +1178,12 @@ static int add_exception_handler(const struct bpf_insn *insn, ex->insn = ins_offset; -if (BPF_CLASS (insn->code) !=BPF_LDX ) +/* +* 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. +*/ +if (BPF_CLASS (insn->code) !=BPF_LDX && !bpf_atomic_is_load_acq (insn)) dst_reg =DONT_CLEAR ; ex->fixup =FIELD_PREP (BPF_FIXUP_REG_MASK , dst_reg);
@@ -1193,7 +1198,7 @@ static int add_exception_handler(const struct bpf_insn *insn,* memory access. Pass the reg holding the unmodified 32-bit address to * ex_handler_bpf. */ -if (BPF_CLASS (insn->code) ==BPF_LDX ) +if (BPF_CLASS (insn->code) ==BPF_LDX ||bpf_atomic_is_load_acq (insn)) arena_reg = bpf2a64[insn->src_reg];else arena_reg = bpf2a64[insn->dst_reg];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1205/1815 regulator: qcom-rpmh: Fix PMIC5 BOB bypass mode handling
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kamal Wadhwa <[email protected]>
[ Upstream commit abd14bebb87e0fa2749371272c8b31d6ee5f0a36 ]
Currently, when rpmh_regulator_set_mode_bypass() helper function is called to set bypass mode, it sends PMIC4's BOB bypass mode value for even if its a PMIC5 BOB.
To fix this, introduce new hw_data parameterpmic_bypass_mode to store bypass mode value. Use it to send correct PMIC bypass mode value that corresponds to PMIC4/5 BOB regulators from the helper function.
--- drivers/regulator/qcom-rpmh-regulator.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/regulator/qcom-rpmh-regulator.c +5 -1
@@ -111,6 +111,7 @@ static const struct resource_name_formats vreg_rsc_name_lookup[NUM_REGULATOR_TYP* @hpm_min_load_uA: Minimum load current in microamps that requires * high power mode (HPM) operation. This is used * for LDO hardware type regulators only. +* @pmic_bypass_mode: The PMIC bypass mode value. * @pmic_mode_map: Array indexed by regulator framework mode * containing PMIC hardware modes. Must be large * enough to index all framework modes supported
@@ -125,6 +126,7 @@ struct rpmh_vreg_hw_data {int n_linear_ranges;int n_voltages;int hpm_min_load_uA; +int pmic_bypass_mode;const int *pmic_mode_map;unsigned int (*of_map_mode)(unsigned int mode); };
@@ -311,7 +313,7 @@ static int rpmh_regulator_vrm_set_mode_bypass(struct rpmh_vreg *vreg,return pmic_mode;if (bypassed) - cmd.data =PMIC4_BOB_MODE_PASS ; + cmd.data = vreg->hw_data->pmic_bypass_mode;else cmd.data = pmic_mode;
@@ -767,6 +769,7 @@ static const struct rpmh_vreg_hw_data pmic4_bob = { }, .n_linear_ranges = 1, .n_voltages = 84, + .pmic_bypass_mode = PMIC4_BOB_MODE_PASS, .pmic_mode_map = pmic_mode_map_pmic4_bob, .of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode, };
@@ -975,6 +978,7 @@ static const struct rpmh_vreg_hw_data pmic5_bob = { }, .n_linear_ranges = 1, .n_voltages = 32, + .pmic_bypass_mode = PMIC5_BOB_MODE_PASS, .pmic_mode_map = pmic_mode_map_pmic5_bob, .of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1206/1815 ASoC: tas675x: sort the register default table
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
[ Upstream commit 3521d209ca70bf77b8c1dcccab5ca4df9468877f ]
reg_defaults must be sorted by ascending register address, as regcache_lookup_reg() locates entries in it with bsearch(). See commit fd80df352ba1 ("regcache: Add support for sorting defaults arrays").
TAS675X_AC_LDG_CTRL_REG (0xb5), TAS675X_TWEETER_DETECT_CTRL_REG (0xb6), TAS675X_TWEETER_DETECT_THRESH_REG (0xb7) and TAS675X_AC_LDG_FREQ_CTRL_REG (0xb8) are listed before the 0x7c - 0xa0 block, which leaves 14 of the 69 entries unreachable. regcache_reg_needs_sync() then cannot compare them against their default and reports that a sync is needed, so they are written to the device on every regcache_sync() even when they were never touched.
Sort the table by register address.
--- sound/soc/codecs/tas675x.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
sound/soc/codecs/tas675x.c +9 -9
@@ -1924,15 +1924,6 @@ static const struct reg_default tas675x_reg_defaults[] = { { TAS675X_PWM_PHASE_M_CTRL_CH2_REG, 0x00 }, { TAS675X_PWM_PHASE_M_CTRL_CH3_REG, 0x00 }, { TAS675X_PWM_PHASE_M_CTRL_CH4_REG, 0x00 }, - { TAS675X_DC_LDG_CTRL_REG, 0x00 }, - { TAS675X_DC_LDG_LO_CTRL_REG, 0x00 }, - { TAS675X_DC_LDG_TIME_CTRL_REG, 0x00 }, - { TAS675X_DC_LDG_SL_CH1_CH2_CTRL_REG, 0x11 }, - { TAS675X_DC_LDG_SL_CH3_CH4_CTRL_REG, 0x11 }, - { TAS675X_AC_LDG_CTRL_REG, 0x10 }, - { TAS675X_TWEETER_DETECT_CTRL_REG, 0x08 }, - { TAS675X_TWEETER_DETECT_THRESH_REG, 0x00 }, - { TAS675X_AC_LDG_FREQ_CTRL_REG, 0xC8 }, { TAS675X_REPORT_ROUTING_1_REG, 0x00 }, { TAS675X_OTSD_RECOVERY_EN_REG, 0x00 }, { TAS675X_REPORT_ROUTING_2_REG, 0xA2 },
@@ -1943,6 +1934,15 @@ static const struct reg_default tas675x_reg_defaults[] = { { TAS675X_GPIO1_OUTPUT_SEL_REG, 0x00 }, { TAS675X_GPIO2_OUTPUT_SEL_REG, 0x00 }, { TAS675X_GPIO_CTRL_REG, TAS675X_GPIO_CTRL_RSTVAL }, + { TAS675X_DC_LDG_CTRL_REG, 0x00 }, + { TAS675X_DC_LDG_LO_CTRL_REG, 0x00 }, + { TAS675X_DC_LDG_TIME_CTRL_REG, 0x00 }, + { TAS675X_DC_LDG_SL_CH1_CH2_CTRL_REG, 0x11 }, + { TAS675X_DC_LDG_SL_CH3_CH4_CTRL_REG, 0x11 }, + { TAS675X_AC_LDG_CTRL_REG, 0x10 }, + { TAS675X_TWEETER_DETECT_CTRL_REG, 0x08 }, + { TAS675X_TWEETER_DETECT_THRESH_REG, 0x00 }, + { TAS675X_AC_LDG_FREQ_CTRL_REG, 0xC8 }, { TAS675X_OTW_CTRL_CH1_CH2_REG, 0x11 }, { TAS675X_OTW_CTRL_CH3_CH4_REG, 0x11 }, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1207/1815 ACPI: PCI: Avoid misleading _OSC messages for non-PCIe host bridges without _OSC
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kazuma Kondo <[email protected]>
[ Upstream commit fa608d2875b57fac792a9e1c11aa1da91737f04a ]
After commit 7d703df7f4f5 ("ACPI: bus: Split _OSC evaluation out of acpi_run_osc()"), the _OSC evaluation path now returns AE_ERROR to negotiate_os_control() instead of propagating AE_NOT_FOUND from acpi_evaluate_object().
This has not caused any functional issues so far, but it produces additional misleading messages for non-PCIe host bridges without _OSC on some Intel servers:
kernel: ACPI: Enabled 2 GPEs in block 00 to 7F
kernel: ACPI: PCI Root Bridge [UNC0] (domain 0000 [bus fe])
kernel: acpi PNP0A03:00: _OSC: OS supports [ExtendedConfig ASPM ClockPM Segments MSI EDR HPX-Type3]
+ kernel: acpi PNP0A03:00: _OSC: OS requested [PCIeHotplug SHPCHotplug PME AER PCIeCapability LTR DPC]
+ kernel: acpi PNP0A03:00: _OSC: platform willing to grant [PCIeHotplug SHPCHotplug PME AER PCIeCapability LTR DPC]
+ kernel: acpi PNP0A03:00: _OSC: platform retains control of PCIe features (AE_ERROR)
kernel: PCI host bridge to bus 0000:fe
Previously, negotiate_os_control() silently ignored AE_NOT_FOUND for non-PCIe host bridges without _OSC, but after the above change, it no longer does so.
As a result, negotiate_os_control() logs messages as if the OS had negotiated with the platform via _OSC, even though the non-PCIe host bridge has no _OSC method and no such negotiation actually occurs.
Skip _OSC negotiation for non-PCIe host bridges that do not define an _OSC method before attempting to evaluate it.
--- drivers/acpi/pci_root.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/acpi/pci_root.c +7 -4
@@ -574,6 +574,13 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm)return ; } +if (!is_pcie (root) && !is_cxl (root) && !acpi_has_method (handle,"_OSC" )) { +dev_dbg (&device->dev,"Non-PCIe host bridge without _OSC, skipping\n" ); + + *no_aspm =1 ; +return ; + } + support =calculate_support ();decode_osc_support (root,"OS supports" , support);
@@ -615,10 +622,6 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm)*/ *no_aspm =1 ; -/* _OSC is optional for PCI host bridges */ -if (status ==AE_NOT_FOUND && !is_pcie (root)) -return ; -if (control) {decode_osc_control (root,"OS requested" , requested);decode_osc_control (root,"platform willing to grant" , control);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1208/1815 thermal/drivers/spacemit: Validate clamped trip thresholds
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: surendra <[email protected]>
[ Upstream commit 68b78ad1e3533c1330dc9b7517947491c1a909c3 ]
k1_tsensor_set_trips() checks the requested trip temperatures before converting them to the sensor register representation. Distinct out-of-range temperatures can clamp to the same hardware value, leaving the sensor with an invalid low/high threshold pair.
Validate the ordering after conversion and clamping.
--- drivers/thermal/spacemit/k1_tsensor.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/thermal/spacemit/k1_tsensor.c +2 -3
@@ -156,13 +156,12 @@ static int k1_tsensor_set_trips(struct thermal_zone_device *tz, int low, int higstruct k1_tsensor *ts = ch->ts;u32 val; -if (low >= high) -return -EINVAL ; - low =clamp_val (low /1000 +TEMPERATURE_OFFSET ,TEMPERATURE_OFFSET ,FIELD_MAX (K1_TSENSOR_THRSH_LOW_MASK )); high =clamp_val (high /1000 +TEMPERATURE_OFFSET ,TEMPERATURE_OFFSET ,FIELD_MAX (K1_TSENSOR_THRSH_HIGH_MASK )); +if (low >= high) +return -EINVAL ; val =readl (ts->base +K1_TSENSOR_THRSH_REG (ch->id));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1209/1815 ACPI: video: Release PCI device reference after lookup
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 3d7ed9b8ef47b8bcae1fc3e12f7590a217862a89 ]
video_detect_portege_r100() uses pci_get_device() only as a boolean check for the Trident CyberBlade XP4m32 device. pci_get_device() takes a reference on a matching PCI device, but the callback returns without releasing it.
Drop the reference after selecting the vendor backlight quirk so the PCI device can be released normally.
--- drivers/acpi/video_detect.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/acpi/video_detect.c +3 -1
@@ -137,8 +137,10 @@ static int video_detect_portege_r100(const struct dmi_system_id *d)struct pci_dev *dev;/* Search for Trident CyberBlade XP4m32 to confirm Portégé R100 */ dev =pci_get_device (PCI_VENDOR_ID_TRIDENT ,0x2100 ,NULL ); -if (dev) +if (dev) { acpi_backlight_dmi = acpi_backlight_vendor; +pci_dev_put (dev); + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1210/1815 perf/x86/intel/pt: Factor out pt_config_enable()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit c6df517796189723ffbdd7679206c97d3642c2ef ]
pt_config() enables tracing by allowing NMIs and pause/resume, issuing the necessary barriers, and calling pt_config_start(). A later change needs to re-enable tracing on a (re-)start path without repeating the full pt_config() setup (filters, RTIT_CTL, buffer configuration).
Factor that enabling sequence out into a new helper, pt_config_enable(), so it can be called on its own.
No functional change intended.
Stable-dep-of: 2e17bf3a469a ("perf/x86/intel/pt: Fix stop/start with no update")
--- arch/x86/events/intel/pt.c | 41 ++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 17 deletions(-)
arch/x86/events/intel/pt.c +24 -17
@@ -502,6 +502,29 @@ static u64 pt_config_filters(struct perf_event *event)return rtit_ctl; } +static void pt_config_enable (struct perf_event *event) +{ +struct pt *pt =this_cpu_ptr (&pt_ctx); + +/* +* Allow resume before starting so as not to overwrite a value set by a +* PMI. +*/ +barrier (); +WRITE_ONCE (pt->resume_allowed,1 ); +/* Configuration is complete, it is now OK to handle an NMI */ +barrier (); +WRITE_ONCE (pt->handle_nmi,1 ); +barrier (); +pt_config_start (event); +barrier (); +/* +* Allow pause after starting so its pt_config_stop() doesn't race with +* pt_config_start(). +*/ +WRITE_ONCE (pt->pause_allowed,1 ); +} +static void pt_config (struct perf_event *event) {struct pt *pt =this_cpu_ptr (&pt_ctx);
@@ -541,23 +564,7 @@ static void pt_config(struct perf_event *event) event->hw.aux_config = reg; -/* -* Allow resume before starting so as not to overwrite a value set by a -* PMI. -*/ -barrier (); -WRITE_ONCE (pt->resume_allowed,1 ); -/* Configuration is complete, it is now OK to handle an NMI */ -barrier (); -WRITE_ONCE (pt->handle_nmi,1 ); -barrier (); -pt_config_start (event); -barrier (); -/* -* Allow pause after starting so its pt_config_stop() doesn't race with -* pt_config_start(). -*/ -WRITE_ONCE (pt->pause_allowed,1 ); +pt_config_enable (event); }static void pt_config_stop (struct perf_event *event)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1211/1815 perf/x86/intel/pt: Use bitwise access for PERF_HES_STOPPED
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 265bb4ef75fa657f4957d72087a6a246b89d5f0d ]
The Intel PT driver reads and writes event->hw.state as a whole value, assuming it is either 0 or PERF_HES_STOPPED. That is true today, but a subsequent fix needs to also track an open AUX output buffer using the PERF_HES_UPTODATE bit of the same field.
When more than one bit can be set, whole-value assignments would overwrite the other bits and whole-value comparisons would fail to match.
Convert all accesses to set, clear and test the PERF_HES_STOPPED bit individually, in preparation for that change.
No functional change intended: event->hw.state currently only ever holds 0 or PERF_HES_STOPPED, so the bitwise forms are equivalent.
Stable-dep-of: 2e17bf3a469a ("perf/x86/intel/pt: Fix stop/start with no update")
--- arch/x86/events/intel/pt.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/x86/events/intel/pt.c +8 -8
@@ -1540,12 +1540,12 @@ void intel_pt_interrupt(void)perf_aux_output_end (&pt->handle,local_xchg (&buf->data_size,0 )); -if (!event->hw.state) { +if (!(event->hw.state &PERF_HES_STOPPED )) {int ret; buf =perf_aux_output_begin (&pt->handle, event);if (!buf) { - event->hw.state =PERF_HES_STOPPED ; + event->hw.state |=PERF_HES_STOPPED ;WRITE_ONCE (pt->resume_allowed,0 );return ; }
@@ -1639,7 +1639,7 @@ static void pt_event_start(struct perf_event *event, int mode) goto fail_end_stop; } - hwc->state =0 ; + hwc->state &= ~PERF_HES_STOPPED ;pt_config_buffer (buf);pt_config (event);
@@ -1649,7 +1649,7 @@ static void pt_event_start(struct perf_event *event, int mode) fail_end_stop:perf_aux_output_end (&pt->handle,0 ); fail_stop: - hwc->state =PERF_HES_STOPPED ; + hwc->state |=PERF_HES_STOPPED ; }static void pt_event_stop (struct perf_event *event,int mode)
@@ -1680,10 +1680,10 @@ static void pt_event_stop(struct perf_event *event, int mode)pt_config_stop (event); -if (event->hw.state ==PERF_HES_STOPPED ) +if (event->hw.state &PERF_HES_STOPPED )return ; - event->hw.state =PERF_HES_STOPPED ; + event->hw.state |=PERF_HES_STOPPED ;if (mode &PERF_EF_UPDATE ) {struct pt_buffer *buf =perf_get_aux (&pt->handle);
@@ -1778,10 +1778,10 @@ static int pt_event_add(struct perf_event *event, int mode)if (mode &PERF_EF_START ) {pt_event_start (event,0 ); ret = -EINVAL ; -if (hwc->state ==PERF_HES_STOPPED ) +if (hwc->state &PERF_HES_STOPPED ) goto fail; }else { - hwc->state =PERF_HES_STOPPED ; + hwc->state |=PERF_HES_STOPPED ; } ret =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1212/1815 perf/x86/intel/pt: Fix stop/start with no update
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 2e17bf3a469a41457a3bc31b1f8fd66b6ce94a6d ]
If pt_event_stop() is called without PERF_EF_UPDATE flag, then perf_aux_output_end() is not called. A subsequent call to pt_event_start() will call perf_aux_output_begin() again which violates the rule against nesting and triggers a WARNING in perf_aux_output_begin().
Originally, pt_event_stop() was never called without PERF_EF_UPDATE, because the only code paths to do so are from event overflow, and Intel PT does not do that.
However the introduction of group throttling by commit 9734e25fbf5ae ("perf: Fix the throttle logic for a group") meant that an Intel PT event could be throttled if it was part of a group. Throttling calls PMU
->stop() / ->start() callbacks without flags.
An example is when AUX area sampling is used. The following commands hit the issue:
echo 10000 > /proc/sys/kernel/perf_event_max_sample_rate
perf record -F32000 --aux-sample -e '{intel_pt//u,cycles:u}' \
-- bash -c 'for i in `seq 1 100000` ; do true ; done'Use PERF_HES_UPTODATE to track whether perf_aux_output_begin() and perf_aux_output_end() are balanced. A cleared PERF_HES_UPTODATE bit indicates that an AUX output context is still open.
Amend pt_event_start() / pt_event_stop() accordingly so that begin/end stay balanced:
- In non-snapshot mode, stop() always closes the buffer (the buffer may have run out of space, and that accounting is done by the update), so a following start() opens a fresh one as before.
- In snapshot/overwrite mode, stop() without PERF_EF_UPDATE leaves the buffer open so that pt_event_snapshot_aux() can still copy from it, and start() then only re-enables tracing instead of calling perf_aux_output_begin() again.
Note that pt_event_del() calls pt_event_stop() with PERF_EF_UPDATE flag set (as is required by the documentation), so a final call to perf_aux_output_end() is assured.
--- arch/x86/events/intel/pt.c | 45 ++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 9 deletions(-)
arch/x86/events/intel/pt.c +36 -9
@@ -1540,6 +1540,8 @@ void intel_pt_interrupt(void)perf_aux_output_end (&pt->handle,local_xchg (&buf->data_size,0 )); + event->hw.state |=PERF_HES_UPTODATE ; +if (!(event->hw.state &PERF_HES_STOPPED )) {int ret;
@@ -1561,6 +1563,8 @@ void intel_pt_interrupt(void)pt_config_buffer (buf);pt_config_start (event); + + event->hw.state &= ~PERF_HES_UPTODATE ; } }
@@ -1629,6 +1633,18 @@ static void pt_event_start(struct perf_event *event, int mode)return ; } +/* +* Re-start subsequent to a call to pt_event_stop() without the +* PERF_EF_UPDATE flag. Absence of PERF_HES_UPTODATE indicates that +* perf_aux_output_begin() has already been called. This path can +* come about only in snapshot/overwrite mode - see pt_event_stop(). +*/ +if (!(hwc->state &PERF_HES_UPTODATE )) { + hwc->state &= ~PERF_HES_STOPPED ; +pt_config_enable (event); +return ; + } + buf =perf_aux_output_begin (&pt->handle, event);if (!buf) goto fail_stop;
@@ -1639,7 +1655,7 @@ static void pt_event_start(struct perf_event *event, int mode) goto fail_end_stop; } - hwc->state &= ~PERF_HES_STOPPED ; + hwc->state &= ~(PERF_HES_STOPPED |PERF_HES_UPTODATE );pt_config_buffer (buf);pt_config (event);
@@ -1649,12 +1665,13 @@ static void pt_event_start(struct perf_event *event, int mode) fail_end_stop:perf_aux_output_end (&pt->handle,0 ); fail_stop: - hwc->state |=PERF_HES_STOPPED ; + hwc->state |=PERF_HES_STOPPED |PERF_HES_UPTODATE ; }static void pt_event_stop (struct perf_event *event,int mode) {struct pt *pt =this_cpu_ptr (&pt_ctx); +struct pt_buffer *buf;if (mode &PERF_EF_PAUSE ) {if (READ_ONCE (pt->pause_allowed))
@@ -1680,17 +1697,24 @@ static void pt_event_stop(struct perf_event *event, int mode)pt_config_stop (event); -if (event->hw.state &PERF_HES_STOPPED ) -return ; - event->hw.state |=PERF_HES_STOPPED ; -if (mode &PERF_EF_UPDATE ) { -struct pt_buffer *buf =perf_get_aux (&pt->handle); +if (event->hw.state &PERF_HES_UPTODATE ) +return ; -if (!buf) -return ; + buf =perf_get_aux (&pt->handle); +if (!buf) +return ; +/* +* When not in snapshot/overwrite mode, there is a possibility that the +* buffer has run out of space. The accounting for that is handled by +* the update, so always update in that case. Snapshot/overwrite mode is +* treated differently to allow for pt_event_snapshot_aux() which can +* still get called if the AUX-sampling event is not stopped until after +* PT is stopped. +*/ +if ((mode &PERF_EF_UPDATE ) || !buf->snapshot) {if (WARN_ON_ONCE (pt->handle.event != event))return ;
@@ -1705,6 +1729,7 @@ static void pt_event_stop(struct perf_event *event, int mode)local_xchg (&buf->data_size, buf->nr_pages <<PAGE_SHIFT );perf_aux_output_end (&pt->handle,local_xchg (&buf->data_size,0 )); + event->hw.state |=PERF_HES_UPTODATE ; } }
@@ -1775,6 +1800,8 @@ static int pt_event_add(struct perf_event *event, int mode)if (pt->handle.event) goto fail; + event->hw.state |=PERF_HES_UPTODATE ; +if (mode &PERF_EF_START ) {pt_event_start (event,0 ); ret = -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1213/1815 sched/fair: Also gate overloaded status update for SD_ASYM_CPUCAPACITY
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Neri <[email protected]>
[ Upstream commit 6060d61d13a10da8c90da4eadf4a421825149883 ]
The argument sg_overloaded of update_sg_lb_stats() is only consumed when balancing at the root domain. It only makes sense to update it in such a case. Commit 3229adbe7875 ("sched/fair: Do not compute overloaded status unnecessarily during lb") updated the logic accordingly but missed the case in which the root domain has the SD_ASYM_CPUCAPACITY flag. Fix this.
--- kernel/sched/fair.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/sched/fair.c +3 -1
@@ -11867,7 +11867,9 @@ static inline void update_sg_lb_stats(struct lb_env *env,/* Check for a misfit task on the cpu */ if (sgs->group_misfit_task_load < rq->misfit_task_load) { sgs->group_misfit_task_load = rq->misfit_task_load; - *sg_overloaded =1 ; + +if (balancing_at_rd) + *sg_overloaded =1 ; } }else if (env->idle &&sched_reduced_capacity (rq, env->sd)) {/* Check for a task running on a CPU with reduced capacity */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1214/1815 sched/fair: Check CPU capacity before comparing group types during load balance
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Neri <[email protected]>
[ Upstream commit 50b101f6e586b4417d060a976fd831cd87e86e2b ]
update_sd_pick_busiest() may incorrectly select a fully_busy group as the busiest group when its per-CPU capacity exceeds that of the destination CPU. This happens because the type of busiest group is initialized to group_has_spare and allows the fully_busy group to win the type comparison.
update_sd_pick_busiest() should not choose a candidate scheduling group with at most one runnable task if its per-CPU capacity is greater than that of the destination CPU. Such a check already exists, but it is done too
late: after the type comparison, preventing a subsequent fully_busy group of equal per-CPU capacity from being correctly selected.
Move this check to occur before comparing group types.
--- kernel/sched/fair.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
kernel/sched/fair.c +11 -11
@@ -11948,6 +11948,17 @@ static bool update_sd_pick_busiest(struct lb_env *env, sds->local_stat.group_type != group_has_spare))return false; +/* +* Candidate sg has no more than one task per CPU and has higher +* per-CPU capacity. Migrating tasks to less capable CPUs may harm +* throughput. Maximize throughput, power/energy consequences are not +* considered. +*/ +if ((env->sd->flags &SD_ASYM_CPUCAPACITY ) && + (sgs->group_type <= group_fully_busy) && + (capacity_greater (sg->sgc->min_capacity,capacity_of (env->dst_cpu)))) +return false; +if (sgs->group_type > busiest->group_type)return true;
@@ -12054,17 +12065,6 @@ static bool update_sd_pick_busiest(struct lb_env *env,break ; } -/* -* Candidate sg has no more than one task per CPU and has higher -* per-CPU capacity. Migrating tasks to less capable CPUs may harm -* throughput. Maximize throughput, power/energy consequences are not -* considered. -*/ -if ((env->sd->flags &SD_ASYM_CPUCAPACITY ) && - (sgs->group_type <= group_fully_busy) && - (capacity_greater (sg->sgc->min_capacity,capacity_of (env->dst_cpu)))) -return false; -return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1215/1815 Bluetooth: btqca: Fix qca_set_bdaddr() waiting for wrong HCI event
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit cf81f0a3db2a5c34ee6e4ea379c631fab6d13e01 ]
qca_set_bdaddr() waits for HCI_EV_VENDOR when sending EDL_WRITE_BD_ADDR_OPCODE (0xFC14), but the controller responds with Command Complete event as confirmed by btmon on WCN7850:
< HCI Command: Vendor (0x3f|0x0014) plen 6 #3 [hci0]
11 22 33 44 55 66
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4 #4 [hci0]
Vendor (0x3f|0x0014) ncmd 1
Status: Success (0x00)Fix by passing 0 as the event parameter to __hci_cmd_sync_ev() to wait for the command complete event instead.
--- drivers/bluetooth/btqca.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/bluetooth/btqca.c +1 -2
@@ -1029,8 +1029,7 @@ int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)baswap (&bdaddr_swapped, bdaddr); skb =__hci_cmd_sync_ev (hdev,EDL_WRITE_BD_ADDR_OPCODE ,6 , - &bdaddr_swapped,HCI_EV_VENDOR , -HCI_INIT_TIMEOUT ); + &bdaddr_swapped,0 ,HCI_INIT_TIMEOUT );if (IS_ERR (skb)) { err =PTR_ERR (skb);bt_dev_err (hdev,"QCA Change address cmd failed (%d)" , err);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1216/1815 Bluetooth: btusb: Fix BD_ADDR byte order in btusb_set_bdaddr_wcn6855()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit d0b15d812688d3f0f3fe1c4426e12814d0c294dc ]
btusb_set_bdaddr_wcn6855() sends the address without swapping byte order for VSC 0xFC14, but the command expects the address in reversed byte order compared to other HCI commands like HCI_Create_Connection, resulting in a wrong BD_ADDR being set.
btmon log on WCN6855 shows VSC 0xFC14 is sent with swapped bytes 11 22 33 44 55 66, and Read BD ADDR returns the expected address 11:22:33:44:55:66:
< HCI Command: Vendor (0x3f|0x0014) plen 6 #3 [hci0]
11 22 33 44 55 66
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4 #4 [hci0]
Vendor (0x3f|0x0014) ncmd 1
Status: Success (0x00)< HCI Command: Read BD ADDR (0x04|0x0009) plen 0 #11 [hci0]
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 10 #12 [hci0]
Read BD ADDR (0x04|0x0009) ncmd 1
Status: Success (0x00)
Address: 11:22:33:44:55:66 (OUI 11-22-33)Fix by swapping the input address before issuing the command.
--- drivers/bluetooth/btusb.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/bluetooth/btusb.c +5 -4
@@ -3083,14 +3083,15 @@ static int btusb_set_bdaddr_ath3012(struct hci_dev *hdev,static int btusb_set_bdaddr_wcn6855 (struct hci_dev *hdev,const bdaddr_t *bdaddr) { +bdaddr_t bdaddr_swapped;struct sk_buff *skb; -u8 buf[6 ];long ret; -memcpy (buf, bdaddr,sizeof (bdaddr_t)); +baswap (&bdaddr_swapped, bdaddr); - skb =__hci_cmd_sync_ev (hdev,0xfc14 ,sizeof (buf), buf, -HCI_EV_CMD_COMPLETE ,HCI_INIT_TIMEOUT ); + skb =__hci_cmd_sync_ev (hdev,0xfc14 ,sizeof (bdaddr_swapped), + &bdaddr_swapped,HCI_EV_CMD_COMPLETE , +HCI_INIT_TIMEOUT );if (IS_ERR (skb)) { ret =PTR_ERR (skb);bt_dev_err (hdev,"Change address command failed (%ld)" , ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1217/1815 Bluetooth: btusb: Record matched usb_device_id into btusb_data
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit ff50db7a522e7bd3bd1c4db6da715e4bdb53af97 ]
Add @match_id to btusb_data to record the matched usb_device_id which will be used later.
Stable-dep-of: 33c6a8d01889 ("Bluetooth: btusb: QCA: Fix populating devcoredump fields on unenabled devices")
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -1021,6 +1021,7 @@ struct btusb_data {bool usb_alt6_packet_flow;int isoc_altsetting;int suspend_count; +const struct usb_device_id *match_id;int (*recv_event)(struct hci_dev *hdev,struct sk_buff *skb);int (*recv_acl)(struct hci_dev *hdev,struct sk_buff *skb);
@@ -4119,6 +4120,7 @@ static int btusb_probe(struct usb_interface *intf,if (!data)return -ENOMEM ; + data->match_id = id; err =usb_find_common_endpoints (intf->cur_altsetting, &data->bulk_rx_ep, &data->bulk_tx_ep, &data->intr_ep,NULL );if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1218/1815 Bluetooth: btusb: QCA: Fix populating devcoredump fields on unenabled devices
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit 33c6a8d01889a84cc773c0c20c8323bce84af27d ]
Devcoredump is not enabled for ATH3012 or QCA_ROME, but they unconditionally populate devcoredump fields in btusb_setup_qca().
Fix by populating devcoredump fields only when BTUSB_QCA_WCN6855 is set, which marks the first generation of QCA BT SoCs for which devcoredump is enabled.
--- drivers/bluetooth/btusb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/bluetooth/btusb.c +4 -2
@@ -3708,8 +3708,10 @@ static int btusb_setup_qca(struct hci_dev *hdev)if (err)return err; - btdata->qca_dump.fw_version =le32_to_cpu (ver.patch_version); - btdata->qca_dump.controller_id =le32_to_cpu (ver.rom_version); +if (btdata->match_id->driver_info &BTUSB_QCA_WCN6855 ) { + btdata->qca_dump.fw_version =le32_to_cpu (ver.patch_version); + btdata->qca_dump.controller_id =le32_to_cpu (ver.rom_version); + }if (!(status &QCA_SYSCFG_UPDATED )) { err =btusb_setup_qca_load_nvm (hdev, &ver, info);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1219/1815 perf trace-event: Fix integer truncation in do_read() and skip()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tanushree Shah <[email protected]>
[ Upstream commit c108c1391be0826920991d24532fbae8f6373ddc ]
The do_read() and skip() functions use 'int' for size parameters, truncating 64-bit sizes from callers. This causes two issues:
1. Uninitialized memory dump: do_read() reads fewer bytes than allocated, leaving uninitialized heap memory that gets written to output files.
2. Out-of-bounds read: Parsing functions process the full 64-bit size while only partial data was read into the buffer.
Change do_read(), __do_read(), and skip() to use size_t for size parameters and ssize_t for return values (where applicable), matching read()/write() system calls.
Update callers to use ssize_t for storing return values.
--- tools/perf/util/trace-event-read.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
tools/perf/util/trace-event-read.c +14 -14
@@ -25,18 +25,18 @@ static int input_fd;static ssize_t trace_data_size;static bool repipe; -static int __do_read (int fd,void *buf,int size) +static ssize_t __do_read (int fd,void *buf,size_t size) { -int rsize = size; +size_t rsize = size;while (size) { -int ret =read (fd, buf, size); +ssize_t ret =read (fd, buf, size);if (ret <=0 )return -1 ;if (repipe) { -int retw =write (STDOUT_FILENO , buf, ret); +ssize_t retw =write (STDOUT_FILENO , buf, ret);if (retw <=0 || retw != ret) {pr_debug ("repiping input file" );
@@ -51,13 +51,13 @@ static int __do_read(int fd, void *buf, int size)return rsize; } -static int do_read (void *data,int size) +static ssize_t do_read (void *data,size_t size) { -int r; +ssize_t r; r =__do_read (input_fd, data, size);if (r <=0 ) { -pr_debug ("reading input file (size expected=%d received=%d)" , +pr_debug ("reading input file (size expected=%zu received=%zd)" , size, r);return -1 ; }
@@ -68,10 +68,10 @@ static int do_read(void *data, int size) }/* If it fails, the next read will report it */ -static void skip (int size) +static void skip (size_t size) {char buf[BUFSIZ ]; -int r; +size_t r;while (size) { r = size >BUFSIZ ?BUFSIZ : size;
@@ -202,7 +202,7 @@ static int read_header_files(struct tep_handle *pevent)unsigned long long size;char *header_page;char buf[BUFSIZ ]; -int ret =0 ; +ssize_t ret =0 ;if (do_read (buf,12 ) <0 )return -1 ;
@@ -250,7 +250,7 @@ static int read_header_files(struct tep_handle *pevent)static int read_ftrace_file (struct tep_handle *pevent,unsigned long long size) { -int ret; +ssize_t ret;char *buf; buf =malloc (size);
@@ -276,7 +276,7 @@ static int read_ftrace_file(struct tep_handle *pevent, unsigned long long size)static int read_event_file (struct tep_handle *pevent,char *sys,unsigned long long size) { -int ret; +ssize_t ret;char *buf; buf =malloc (size);
@@ -322,7 +322,7 @@ static int read_event_files(struct tep_handle *pevent)int systems;int count;int i,x; -int ret; +ssize_t ret; systems =read4 (pevent);
@@ -350,7 +350,7 @@ static int read_saved_cmdline(struct tep_handle *pevent) {unsigned long long size;char *buf; -int ret; +ssize_t ret;/* it can have 0 size */ size =read8 (pevent);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1220/1815 scsi: sd: Fix error handling in sd_probe() after large pool creation failure
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 e3cc6ea1a745e7f5d326f919a428b244fa119d8f ]
After device_add(&sdkp->disk_dev) succeeds, sd_large_pool_create() failure must unregister disk_dev and let scsi_disk_release() free sdkp. Going through out_free_index kfree()s an already registered device and leaks the sysfs entry.
--- drivers/scsi/sd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/sd.c +3 -1
@@ -4089,7 +4089,9 @@ static int sd_probe(struct scsi_device *sdp)if (sdp->sector_size >PAGE_SIZE ) {if (sd_large_pool_create ()) { error = -ENOMEM ; - goto out_free_index; +device_unregister (&sdkp->disk_dev); +put_disk (gd); + goto out; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1221/1815 scsi: sd: Fix special_vec mempool leak when scsi_alloc_sgtables() fails
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 bb31844d88b77138b67aa20c3600203baff40140 ]
sd_set_special_bvec() allocates a special payload page for UNMAP and WRITE SAME commands. If scsi_alloc_sgtables() fails afterward in sd_setup_unmap_cmnd() or sd_setup_write_same{10,16}_cmnd(), the SCSI midlayer does not call uninit_command() because RQF_DONTPREP is not set yet, leaking the page.
Call sd_uninit_command() on error, and clear RQF_SPECIAL_PAYLOAD after freeing the page.
--- drivers/scsi/sd.c | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-)
drivers/scsi/sd.c +30 -17
@@ -958,6 +958,21 @@ static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd,return protect; } +static void sd_uninit_command (struct scsi_cmnd *cmd) +{ +struct request *rq =scsi_cmd_to_rq (cmd); +struct scsi_device *sdp = cmd->device; + +if (!(rq->rq_flags &RQF_SPECIAL_PAYLOAD )) +return ; + +if (sdp->sector_size >PAGE_SIZE ) +mempool_free (rq->special_vec.bv_page, sd_large_page_pool); +else +mempool_free (rq->special_vec.bv_page, sd_page_pool); + rq->rq_flags &= ~RQF_SPECIAL_PAYLOAD ; +} +static void *sd_set_special_bvec (struct scsi_cmnd *cmd,unsigned int data_len) {struct page *page;
@@ -990,6 +1005,7 @@ static blk_status_t sd_setup_unmap_cmnd(struct scsi_cmnd *cmd)u32 nr_blocks =sectors_to_logical (sdp,blk_rq_sectors (rq));unsigned int data_len =24 ;char *buf; +blk_status_t ret; buf =sd_set_special_bvec (cmd, data_len);if (!buf)
@@ -1008,7 +1024,10 @@ static blk_status_t sd_setup_unmap_cmnd(struct scsi_cmnd *cmd) cmd->transfersize = data_len; rq->timeout =SD_TIMEOUT ; -return scsi_alloc_sgtables (cmd); + ret =scsi_alloc_sgtables (cmd); +if (ret !=BLK_STS_OK ) +sd_uninit_command (cmd); +return ret; }static void sd_config_atomic (struct scsi_disk *sdkp,struct queue_limits *lim)
@@ -1079,6 +1098,7 @@ static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd,u64 lba =sectors_to_logical (sdp,blk_rq_pos (rq));u32 nr_blocks =sectors_to_logical (sdp,blk_rq_sectors (rq));u32 data_len = sdp->sector_size; +blk_status_t ret;if (!sd_set_special_bvec (cmd, data_len))return BLK_STS_RESOURCE ;
@@ -1094,7 +1114,10 @@ static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd, cmd->transfersize = data_len; rq->timeout = unmap ?SD_TIMEOUT :SD_WRITE_SAME_TIMEOUT ; -return scsi_alloc_sgtables (cmd); + ret =scsi_alloc_sgtables (cmd); +if (ret !=BLK_STS_OK ) +sd_uninit_command (cmd); +return ret; } static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd,
@@ -1106,6 +1129,7 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd,u64 lba =sectors_to_logical (sdp,blk_rq_pos (rq));u32 nr_blocks =sectors_to_logical (sdp,blk_rq_sectors (rq));u32 data_len = sdp->sector_size; +blk_status_t ret;if (!sd_set_special_bvec (cmd, data_len))return BLK_STS_RESOURCE ;
@@ -1121,7 +1145,10 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd, cmd->transfersize = data_len; rq->timeout = unmap ?SD_TIMEOUT :SD_WRITE_SAME_TIMEOUT ; -return scsi_alloc_sgtables (cmd); + ret =scsi_alloc_sgtables (cmd); +if (ret !=BLK_STS_OK ) +sd_uninit_command (cmd); +return ret; }static blk_status_t sd_setup_write_zeroes_cmnd (struct scsi_cmnd *cmd)
@@ -1550,20 +1577,6 @@ static blk_status_t sd_init_command(struct scsi_cmnd *cmd) } } -static void sd_uninit_command (struct scsi_cmnd *SCpnt) -{ -struct request *rq =scsi_cmd_to_rq (SCpnt); -struct scsi_device *sdp = SCpnt->device; -unsigned sector_size = sdp->sector_size; - -if (rq->rq_flags &RQF_SPECIAL_PAYLOAD ) { -if (sector_size >PAGE_SIZE ) -mempool_free (rq->special_vec.bv_page, sd_large_page_pool); -else -mempool_free (rq->special_vec.bv_page, sd_page_pool); - } -} -static bool sd_need_revalidate (struct gendisk *disk,struct scsi_disk *sdkp) {if (sdkp->device->removable || sdkp->write_prot) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1222/1815 scsi: sd: Fix sd_done() sense handling condition
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 a640d4546b11be5709a82bdc63d7dafd8ddc6c9e ]
Only enter the sense_key switch when the command returned CHECK CONDITION with valid, non-deferred sense. The old condition let deferred or invalid sense fall through and mis-handle the I/O.
--- drivers/scsi/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +2 -2
@@ -2419,8 +2419,8 @@ static int sd_done(struct scsi_cmnd *SCpnt) } sdkp->medium_access_timed_out =0 ; -if (!scsi_status_is_check_condition (result) && - (!sense_valid || sense_deferred)) +if (!scsi_status_is_check_condition (result) || + !sense_valid || sense_deferred) goto out;switch (sshdr.sense_key) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1223/1815 btrfs: zoned: dont force read-only on transient -EAGAIN from reloc merge
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit e549093c11a2fff8430df3dfbdb45eb9811a69a5 ]
On a zoned FS, btrfs_delayed_refs_rsv_refill() returns -EAGAIN whenever the over-committed metadata plus the zone_unusable bytes exceeds the usable size in a metadata block-group to avoid heavy over-commit of metadata and early ENOSPC in one transaction.
If this happens while doing reclaim, the transaction is getting aborted.
Treat -EAGAIN as a soft, retryable condition in case of block-group reclaim.
--- fs/btrfs/block-group.c | 8 ++++++- fs/btrfs/relocation.c | 49 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 51 insertions(+), 6 deletions(-)
fs/btrfs/block-group.c +7 -1
@@ -2047,6 +2047,11 @@ static int btrfs_reclaim_block_group(struct btrfs_block_group *bg, int *reclaimetrace_btrfs_reclaim_block_group (bg); ret =btrfs_relocate_chunk (fs_info, bg->start, false); +if (btrfs_is_zoned (fs_info) && ret == -EAGAIN ) { +btrfs_dec_block_group_ro (bg); +btrfs_debug (fs_info,"deferring reclaim of chunk %llu" , bg->start); +return ret; + }if (ret) {btrfs_dec_block_group_ro (bg); btrfs_err(fs_info, "error relocating chunk %llu",
@@ -2113,7 +2118,8 @@ void btrfs_reclaim_block_groups(struct btrfs_fs_info *fs_info, unsigned int limispin_unlock (&fs_info->unused_bgs_lock); ret =btrfs_reclaim_block_group (bg, &reclaimed); -if (ret && !READ_ONCE (space_info->periodic_reclaim)) +if ((btrfs_is_zoned (fs_info) && ret == -EAGAIN ) || + (ret && !READ_ONCE (space_info->periodic_reclaim)))btrfs_link_bg_list (bg, &retry_list);btrfs_put_block_group (bg);
fs/btrfs/relocation.c +44 -5
85 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1224/1815 btrfs: defrag: fix deadlock between defrag and delalloc space reservation
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit ba02eab28041f9a4bbe9fc90c7249644fef6de0f ]
While running fsstress with autodefrag and flushoncommit, hit a deadlock due to the fact that defrag reserves delalloc space while it's holding dirty and locked folios, besides the extent range lock. The stack traces are the following:
[958.624] task:kworker/u50:3 state:D stack:0 pid:20365 tgid:20365 ppid:2 task_flags:0x4208060 flags:0x00080000 [958.626] Workqueue: events_unbound btrfs_async_reclaim_metadata_space [btrfs] [958.627] Call Trace: [958.628] <TASK> [958.628] __schedule+0x4be/0x10f0 [958.629] ? preempt_count_add+0x69/0xa0 [958.630] schedule+0x26/0xd0 [958.631] wait_current_trans+0x102/0x160 [btrfs] [958.632] ? __pfx_autoremove_wake_function+0x10/0x10 [958.633] start_transaction+0x374/0x900 [btrfs] [958.634] btrfs_commit_current_transaction+0x1d/0x70 [btrfs] [958.635] flush_space+0xca/0x5e0 [btrfs] [958.636] ? _raw_spin_unlock+0x15/0x30 [958.637] ? btrfs_reduce_alloc_profile+0x8c/0x190 [btrfs] [958.639] ? _raw_spin_unlock+0x15/0x30 [958.640] ? calc_available_free_space.isra.0+0x6f/0x110 [btrfs] [958.641] do_async_reclaim_metadata_space+0x84/0x190 [btrfs] [958.642] btrfs_async_reclaim_metadata_space+0x64/0x80 [btrfs] [958.644] process_one_work+0x19d/0x3a0 [958.644] worker_thread+0x1c4/0x330 [958.645] ? __pfx_worker_thread+0x10/0x10 [958.646] kthread+0xfc/0x130 [958.647] ? __pfx_kthread+0x10/0x10 [958.648] ret_from_fork+0x1f7/0x2c0 [958.648] ? __pfx_kthread+0x10/0x10 [958.649] ret_from_fork_asm+0x1a/0x30 [958.650] </TASK> [958.651] task:kworker/u49:7 state:D stack:0 pid:52990 tgid:52990 ppid:2 task_flags:0x4208060 flags:0x00080000 [958.653] Workqueue: writeback wb_workfn (flush-btrfs-334) [958.655] Call Trace: [958.655] <TASK> [958.656] __schedule+0x4be/0x10f0 [958.657] ? __blk_flush_plug+0xe9/0x140 [958.658] schedule+0x26/0xd0 [958.658] io_schedule+0x42/0x70 [958.659] folio_wait_bit_common+0x12b/0x330 [958.660] ? folio_wait_bit_common+0x100/0x330 [958.662] ? __pfx_wake_page_function+0x10/0x10 [958.663] extent_write_cache_pages+0x599/0x830 [btrfs] [958.664] ? acpi_fwnode_get_reference_args+0x1fa/0x270 [958.665] btrfs_writepages+0x77/0x130 [btrfs] [958.666] ? __pfx_end_bbio_data_write+0x10/0x10 [btrfs] [958.667] do_writepages+0xc6/0x160 [958.668] __writeback_single_inode+0x42/0x310 [958.669] writeback_sb_inodes+0x231/0x570 [958.670] wb_writeback+0x8a/0x340 [958.671] wb_workfn+0xbf/0x450 [958.672] ? finish_task_switch.isra.0+0xc1/0x350 [958.673] process_one_work+0x19d/0x3a0 [958.673] worker_thread+0x1c4/0x330 [958.674] ? __pfx_worker_thread+0x10/0x10 [958.675] kthread+0xfc/0x130 [958.676] ? __pfx_kthread+0x10/0x10 [958.676] ret_from_fork+0x1f7/0x2c0 [958.677] ? __pfx_kthread+0x10/0x10 [958.678] ret_from_fork_asm+0x1a/0x30 [958.679] </TASK> [958.679] task:btrfs-cleaner state:D stack:0 pid:296750 tgid:296750 ppid:2 task_flags:0x208040 flags:0x00080000 [958.681] Call Trace: [958.682] <TASK> [958.682] __schedule+0x4be/0x10f0 [958.683] schedule+0x26/0xd0 [958.684] handle_reserve_ticket+0x1b9/0x2c0 [btrfs] [958.685] ? __pfx_autoremove_wake_function+0x10/0x10 [958.686] reserve_bytes+0x283/0x4c0 [btrfs] [958.687] btrfs_reserve_metadata_bytes+0x18/0xb0 [btrfs] [958.688] btrfs_delalloc_reserve_metadata+0x121/0x320 [btrfs] [958.690] btrfs_delalloc_reserve_space+0x46/0xb0 [btrfs] [958.691] btrfs_defrag_file+0x903/0x1110 [btrfs] [958.692] btrfs_run_defrag_inodes+0x334/0x430 [btrfs] [958.694] cleaner_kthread+0x97/0x1c0 [btrfs] [958.694] ? __pfx_cleaner_kthread+0x10/0x10 [btrfs] [958.696] kthread+0xfc/0x130 [958.696] ? __pfx_kthread+0x10/0x10 [958.697] ret_from_fork+0x1f7/0x2c0 [958.698] ? __pfx_kthread+0x10/0x10 [958.699] ret_from_fork_asm+0x1a/0x30 [958.700] </TASK> [958.716] task:fsstress state:D stack:0 pid:296769 tgid:296769 ppid:296768 task_flags:0x400140 flags:0x00080000 [958.718] Call Trace: [958.719] <TASK> [958.719] __schedule+0x4be/0x10f0 [958.720] ? preempt_count_add+0x69/0xa0 [958.721] schedule+0x26/0xd0 [958.722] wb_wait_for_completion+0x79/0xc0 [958.723] ? __pfx_autoremove_wake_function+0x10/0x10 [958.724] __writeback_inodes_sb_nr+0xc5/0xf0 [958.725] try_to_writeback_inodes_sb+0x55/0x70 [958.726] btrfs_commit_transaction+0x19d/0xeb0 [btrfs] [958.727] ? start_transaction+0x343/0x900 [btrfs] [958.728] btrfs_mksubvol+0x28b/0x4e0 [btrfs] [958.729] btrfs_mksnapshot+0x74/0xa0 [btrfs] [958.730] __btrfs_ioctl_snap_create+0x194/0x210 [btrfs] [958.732] btrfs_ioctl_snap_create_v2+0xef/0x150 [btrfs] [958.733] btrfs_ioctl+0x7ec/0x2a70 [btrfs] [958.734] ? __virt_addr_valid+0xe4/0x180 [958.735] ? __check_object_size+0x1cd/0x1f0 [958.736] ? kmem_cache_free+0x146/0x380 [958.737] ? _raw_spin_unlock+0x15/0x30 [958.738] ? do_sys_openat2+0x83/0xd0 [958.739] __x64_sys_ioctl+0x92/0xe0 [958.740] do_syscall_64+0x60/0x590 [958.741] ? clear_bhb_loop+0x60/0xb0 [958.742] entry_SYSCALL_64_after_hwframe+0x76/0x7e [958.743] RIP: 0033:0x7f4431e108db [958.744] RSP: 002b:00007ffcd147db20 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [958.746] RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f4431e108db [958.747] RDX: 00007ffcd147eb90 RSI: 0000000050009417 RDI: 0000000000000005 [958.749] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 [958.751] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffcd147fbf0 [958.752] R13: 00007ffcd147eb90 R14: 0000000000000005 R15: 0000000000000003 [958.754] </TASK>
What happens is the following:
1) The cleaner kthread is running autodefrag, and in defrag_one_range() it acquired all the folios for the range and locked them.
Then it locked the extent range in the inode's iotree.
It got two subranges from defrag_collect_targets(), the first one with folio A and the second one with folio B.
After it defragged the first subrange, folio A remains locked and dirty - it's only unlocked when defrag_one_range() returns.
When it attempts to defrag the second subrange (containing folio B), btrfs_delalloc_reserve_space() creates a space reservation ticket, due to lack of free metadata space and blocks waiting for the async metadata reclaim task to free space and wake it up;
2) The async reclaim metadata task attempts to commit the current transaction, but it blocks because there is another task that started the commit first;
3) A task creating a snapshot is committing the transaction and because the fs was mounted with flushoncommit, it calls try_to_writeback_inodes_sb(), which spawns a task to flush delalloc and waits for it to complete;
4) The task flushing delalloc (kworker/u49:7), finds that folio A for the inode being defragged is dirty, so it tries to lock it...
But it blocks because folio A is locked by the defrag task (the cleaner kthread) which is blocked waiting for the reservation ticket to be served, but the async reclaim metadata task is blocked waiting for the transaction commit, which in turn is blocked waiting for the delalloc flush task, which is trying to lock folio A, resulting in a deadlock.
The same type of problem can happen if the async reclaim task starts to flush delalloc, as that requires both locking the folio and the extent range in the inode's io tree, and in this case we don't need the fs to be mounted with flushoncommit. This type of problem has ocurred several times in the past with reflinks for example, where we had a dirty folio while holding the extent range locked and then starting a transaction blocked waiting for the async reclaim task due to lack of free metadata space.
So fix this by reserving delalloc space before locking folios and locking the extent range in the inode's iotree. We can not simply unlock the folios for each subrange given by defrag_collect_targets() after we defrag it because the same folio may be present too in the next subrange (due to large folios).
--- fs/btrfs/defrag.c | 50 +++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 17 deletions(-)
fs/btrfs/defrag.c +33 -17
@@ -1130,20 +1130,15 @@ static_assert(PAGE_ALIGNED(CLUSTER_SIZE));* * - Extent bits are locked */ -static int defrag_one_locked_target (struct btrfs_inode *inode, -struct defrag_target_range *target, -struct folio **folios,int nr_pages, -struct extent_state **cached_state) +static void defrag_one_locked_target (struct btrfs_inode *inode, +struct defrag_target_range *target, +struct folio **folios,int nr_pages, +struct extent_state **cached_state) {struct btrfs_fs_info *fs_info = inode->root->fs_info; -struct extent_changeset *data_reserved =NULL ;const u64 start = target->start;const u64 len = target->len; -int ret =0 ; - ret =btrfs_delalloc_reserve_space (inode, &data_reserved, start, len); -if (ret <0 ) -return ret;btrfs_clear_extent_bit (&inode->io_tree, start, start + len -1 ,EXTENT_DELALLOC |EXTENT_DO_ACCOUNTING |EXTENT_DEFRAG , cached_state);
@@ -1164,10 +1159,6 @@ static int defrag_one_locked_target(struct btrfs_inode *inode,continue ;btrfs_folio_clamp_set_dirty (fs_info, folio, start, len); } -btrfs_delalloc_release_extents (inode, len); -extent_changeset_free (data_reserved); - -return ret; } static int defrag_one_range(struct btrfs_inode *inode, u64 start, u32 len,
@@ -1183,6 +1174,8 @@ static int defrag_one_range(struct btrfs_inode *inode, u64 start, u32 len,u64 cur = start;const unsigned int nr_pages = ((start + len -1 ) >>PAGE_SHIFT ) - (start >>PAGE_SHIFT ) +1 ; +struct extent_changeset *data_reserved =NULL ; +u64 last_defrag_end = start;int ret =0 ;ASSERT (nr_pages <=CLUSTER_SIZE /PAGE_SIZE );
@@ -1192,6 +1185,22 @@ static int defrag_one_range(struct btrfs_inode *inode, u64 start, u32 len,if (!folios)return -ENOMEM ; +/* +* Reserve delalloc space before locking the range and before locking +* and dirtying any folios - otherwise we could deadlock, for example +* after defrag of one range we dirty folios and keep them locked when +* we move to the next range, so reserving delalloc space right before +* each range could trigger flushing of delalloc and deadlock on the +* extent lock or trigger a transaction commit with flushoncommit, which +* can either deadlock on the lock of a folio made dirty in the previous +* range or the extent lock. +*/ + ret =btrfs_delalloc_reserve_space (inode, &data_reserved, start, len); +if (ret <0 ) { +kfree (folios); +return ret; + } +/* Prepare all pages */ for (int i =0 ; cur < start + len && i < nr_pages; i++) { folios[i] =defrag_prepare_one_folio (inode, cur >>PAGE_SHIFT );
@@ -1226,10 +1235,11 @@ static int defrag_one_range(struct btrfs_inode *inode, u64 start, u32 len, goto unlock_extent;list_for_each_entry (entry, &target_list, list) { - ret =defrag_one_locked_target (inode, entry, folios, nr_pages, - &cached_state); -if (ret <0 ) -break ; +defrag_one_locked_target (inode, entry, folios, nr_pages, &cached_state); +if (entry->start > last_defrag_end) +btrfs_delalloc_release_space (inode, data_reserved, last_defrag_end, + entry->start - last_defrag_end, true); + last_defrag_end = entry->start + entry->len; }list_for_each_entry_safe (entry, tmp, &target_list, list) {
@@ -1246,6 +1256,12 @@ static int defrag_one_range(struct btrfs_inode *inode, u64 start, u32 len,folio_put (folios[i]); }kfree (folios); +btrfs_delalloc_release_extents (inode, len); +if (last_defrag_end < start + len) +btrfs_delalloc_release_space (inode, data_reserved, last_defrag_end, + start + len - last_defrag_end, true); +extent_changeset_free (data_reserved); +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1225/1815 btrfs: always wait for ordered extents to avoid OE races
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit ec78575dde998c21be7e0cb2503b5620f34b6255 ]
[BUG]
Syzbot reported a bug that there can be conflicting OEs for the same range:
BTRFS critical (device loop4): panic in insert_ordered_extent:264: overlapping ordered extents, existing oe file_offset 16384 num_bytes 430080 flags 0x1089, new oe file_offset 16384 num_bytes 430080 flags 0x80 (errno=-17 Object alrea[ 179.162726][ T6897] BTRFS critical (device loop4): panic in insert_ordered_extent:264: overlapping ordered extents, existing oe file_offset 16384 num_bytes 430080 flags 0x1089, new oe file_offset 16384 num_bytes 430080 flags 0x80 (errno=-17 Object already exists)
------------[ cut here ]------------ kernel BUG at fs/btrfs/ordered-data.c:264! Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/09/2026 RIP: 0010:btrfs_alloc_ordered_extent+0x943/0xad0 Call Trace: <TASK> cow_file_range+0x744/0x12a0 fallback_to_cow+0x5ea/0xa00 run_delalloc_nocow+0x110c/0x17a0 btrfs_run_delalloc_range+0xbe4/0x1c20 writepage_delalloc+0x104d/0x1ba0 btrfs_writepages+0x1667/0x28b0 do_writepages+0x338/0x560 filemap_fdatawrite_range+0x1f2/0x300 btrfs_fdatawrite_range+0x54/0xf0 btrfs_direct_write+0x6a0/0xc30 btrfs_do_write_iter+0x329/0x790 do_iter_readv_writev+0x624/0x8d0 vfs_writev+0x34c/0x990 __se_sys_pwritev2+0x17a/0x2a0 do_syscall_64+0x174/0x580 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> ---[ end trace 0000000000000000 ]---
[CAUSE]
Since commit ff66fe666233 ("btrfs: fix incorrect buffered IO fallback for append direct writes"), if the direct IO finished short, we will revert the isize back to the original one, so that append writes can be respected during the buffered fallback.
Normally we rely on lock_and_cleanup_extent_if_need() function during buffered writeback to wait for any existing ordered extents.
But that ordered extent waiting only happens if the start_pos is inside the isize.
Since we have reverted the isize during failed direct IO, we will not wait for any ordered extents.
This means we can have a race where the direct IO OE is still in the tree, finished but not yet removed, then we're inserting the OE for the buffered write, causing the above crash.
[FIX]
Make the OE wait to be unconditional, to handle the reverted isize situation.
And since lock_and_cleanup_extent_if_need() now either lock the extents or return -EAGAIN, also remove the branches that handles no-extent-locked cases, and rename it to remove the "_if_need" suffix.
The following micro benchmark shows the runtime difference for btrfs_buffered_write(), doing xfs_io -f -c "pwrite 0 1m" workload, all values are the average runtime in nano seconds.
function runtime | before | after
-----------------------------------+-------------+---------------
lock_and_cleanup_extent_if_need() | 58.2 | 183.0 btrfs_buffered_write() | 2115.6 | 2973.3
The overall runtime of btrfs_buffered_write() is still pretty tiny (still less than 3 micro seconds), I'd say the extra cost is still acceptable.
An alternative to fix this problem is to wait ordered extents during iomap_end() where the isize revert is done.
But that solution will break nowait requirement, as if a nowait direct IO finished short, we have to wait for the OEs unconditionally or the next append buffered IO can still hit the same problem.
So here we have to move the wait cost to buffered write, but at least the code is slightly more streamline.
--- fs/btrfs/file.c | 102 +++++++++++++++++++----------------------------- 1 file changed, 40 insertions(+), 62 deletions(-)
fs/btrfs/file.c +40 -62
@@ -875,62 +875,56 @@ static noinline int prepare_one_folio(struct inode *inode, struct folio **folio_/* * Locks the extent and properly waits for data=ordered extents to finish -* before allowing the folios to be modified if need. +* before allowing the folios to be modified. * * Return: -* 1 - the extent is locked -* 0 - the extent is not locked, and everything is OK +* 0 - the extent is locked * -EAGAIN - need to prepare the folios again */ static noinline int -lock_and_cleanup_extent_if_need (struct btrfs_inode *inode,struct folio *folio, -loff_t pos,size_t write_bytes, -u64 *lockstart,u64 *lockend,bool nowait, -struct extent_state **cached_state) +lock_and_cleanup_extent (struct btrfs_inode *inode,struct folio *folio, +loff_t pos,size_t write_bytes, +u64 *lockstart,u64 *lockend,bool nowait, +struct extent_state **cached_state) {struct btrfs_fs_info *fs_info = inode->root->fs_info; +struct btrfs_ordered_extent *ordered;u64 start_pos;u64 last_pos; -int ret =0 ; start_pos =round_down (pos, fs_info->sectorsize); last_pos =round_up (pos + write_bytes, fs_info->sectorsize) -1 ; -if (start_pos < inode->vfs_inode.i_size) { -struct btrfs_ordered_extent *ordered; - -if (nowait) { -if (!btrfs_try_lock_extent (&inode->io_tree, start_pos, - last_pos, cached_state)) { -folio_unlock (folio); -folio_put (folio); -return -EAGAIN ; - } - }else { -btrfs_lock_extent (&inode->io_tree, start_pos, last_pos, - cached_state); - } - - ordered =btrfs_lookup_ordered_range (inode, start_pos, - last_pos - start_pos +1 ); -if (ordered && - ordered->file_offset + ordered->num_bytes > start_pos && - ordered->file_offset <= last_pos) { -btrfs_unlock_extent (&inode->io_tree, start_pos, last_pos, - cached_state); +if (nowait) { +if (!btrfs_try_lock_extent (&inode->io_tree, start_pos, + last_pos, cached_state)) {folio_unlock (folio);folio_put (folio); -btrfs_start_ordered_extent (ordered); -btrfs_put_ordered_extent (ordered);return -EAGAIN ; } -if (ordered) -btrfs_put_ordered_extent (ordered); + }else { +btrfs_lock_extent (&inode->io_tree, start_pos, last_pos, + cached_state); + } - *lockstart = start_pos; - *lockend = last_pos; - ret =1 ; + ordered =btrfs_lookup_ordered_range (inode, start_pos, + last_pos - start_pos +1 ); +if (ordered && + ordered->file_offset + ordered->num_bytes > start_pos && + ordered->file_offset <= last_pos) { +btrfs_unlock_extent (&inode->io_tree, start_pos, last_pos, + cached_state); +folio_unlock (folio); +folio_put (folio); +btrfs_start_ordered_extent (ordered); +btrfs_put_ordered_extent (ordered); +return -EAGAIN ; } +if (ordered) +btrfs_put_ordered_extent (ordered); + + *lockstart = start_pos; + *lockend = last_pos;/* * We should be called after prepare_one_folio() which should have locked
@@ -938,7 +932,7 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct folio *folio,*/ WARN_ON (!folio_test_locked (folio)); -return ret; +return 0 ; }/*
@@ -1195,7 +1189,6 @@ static int copy_one_range(struct btrfs_inode *inode, struct iov_iter *iter,const u64 reserved_start =round_down (start, fs_info->sectorsize);u64 reserved_len;struct folio *folio =NULL ; -int extents_locked;u64 lockstart;u64 lockend;bool only_release_metadata = false;
@@ -1253,18 +1246,16 @@ static int copy_one_range(struct btrfs_inode *inode, struct iov_iter *iter, reserved_len = last_block - reserved_start; } - extents_locked =lock_and_cleanup_extent_if_need (inode, folio, start, - write_bytes, &lockstart, - &lockend, nowait, - &cached_state); -if (extents_locked <0 ) { -if (!nowait && extents_locked == -EAGAIN ) + ret =lock_and_cleanup_extent (inode, folio, start, write_bytes, + &lockstart, &lockend, nowait, &cached_state); +if (ret <0 ) { +if (!nowait) goto again;btrfs_delalloc_release_extents (inode, reserved_len);release_space (inode, *data_reserved, reserved_start, reserved_len, only_release_metadata); -return extents_locked; +return ret; } copied = copy_folio_from_iter_atomic(folio, offset_in_folio(folio, start),
@@ -1288,11 +1279,8 @@ static int copy_one_range(struct btrfs_inode *inode, struct iov_iter *iter,/* No copied bytes, unlock, release reserved space and exit. */ if (copied ==0 ) { -if (extents_locked) -btrfs_unlock_extent (&inode->io_tree, lockstart, lockend, - &cached_state); -else -btrfs_free_extent_state (cached_state); +btrfs_unlock_extent (&inode->io_tree, lockstart, lockend, + &cached_state);btrfs_delalloc_release_extents (inode, reserved_len);release_space (inode, *data_reserved, reserved_start, reserved_len, only_release_metadata);
@@ -1311,17 +1299,7 @@ static int copy_one_range(struct btrfs_inode *inode, struct iov_iter *iter, ret =btrfs_dirty_folio (inode, folio, start, copied, &cached_state, only_release_metadata); -/* -* If we have not locked the extent range, because the range's start -* offset is >= i_size, we might still have a non-NULL cached extent -* state, acquired while marking the extent range as delalloc through -* btrfs_dirty_page(). Therefore free any possible cached extent state -* to avoid a memory leak. -*/ -if (extents_locked) -btrfs_unlock_extent (&inode->io_tree, lockstart, lockend, &cached_state); -else -btrfs_free_extent_state (cached_state); +btrfs_unlock_extent (&inode->io_tree, lockstart, lockend, &cached_state);btrfs_delalloc_release_extents (inode, reserved_len);if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1226/1815 btrfs: fix a lockdep caused by path resolution during device scan
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 108cc873398932af589c295f78c348513b8d70d9 ]
[BUG]
There is a lockdep report related to device scan:
======================================================
WARNING: possible circular locking dependency detected 7.2.0-20260712.rc2.git0.e3321fa3034d.300.fc44.s390x+debug #1 Not tainted
------------------------------------------------------
(udev-worker)/1653 is trying to acquire lock:
0000006919232220 (&type->i_mutex_dir_key#2){++++}-{3:3}, at: lookup_slow+0x3e/0x70
but task is already holding lock:00000069238564d8 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: device_list_add.constprop.0+0x148/0xc60 which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #5 (&fs_devs->device_list_mutex){+.+.}-{3:3}:
lock_acquire+0x150/0x3f0
__mutex_lock+0xba/0xdc0
mutex_lock_nested+0x32/0x40
write_all_supers+0x7a/0x670
btrfs_sync_log+0xae6/0xdd0
btrfs_sync_file+0x4fa/0x7a0
__s390x_sys_fsync+0x52/0xa0
__do_syscall+0x172/0x750
system_call+0x72/0x90
-> #4 (&fs_info->tree_log_mutex){+.+.}-{3:3}:
lock_acquire+0x150/0x3f0
__mutex_lock+0xba/0xdc0
mutex_lock_nested+0x32/0x40
btrfs_sync_log+0xaba/0xdd0
btrfs_sync_file+0x4fa/0x7a0
__s390x_sys_fsync+0x52/0xa0
__do_syscall+0x172/0x750
system_call+0x72/0x90
-> #3 (btrfs_trans_num_extwriters){.+.+}-{0:0}:
lock_acquire+0x150/0x3f0
join_transaction+0x108/0x680
start_transaction+0x21a/0x660
btrfs_join_transaction+0x32/0x40
btrfs_dirty_inode+0x52/0xf0
touch_atime+0x90/0xc0
filemap_read+0x446/0x450
vfs_read+0x208/0x370
ksys_read+0x88/0x120
__do_syscall+0x172/0x750
system_call+0x72/0x90
-> #2 (btrfs_trans_num_writers){.+.+}-{0:0}:
reacquire_held_locks+0x14c/0x240
__lock_release.isra.0+0xd8/0x380
lock_release+0xf6/0x270
percpu_up_read+0x28/0xf0
__btrfs_end_transaction+0x178/0x1f0
btrfs_dirty_inode+0x82/0xf0
touch_atime+0x90/0xc0
btrfs_file_mmap_prepare+0x8c/0xa0
__mmap_region+0x214/0x780
mmap_region+0x108/0x160
do_mmap+0x402/0x5a0
vm_mmap_pgoff+0x156/0x230
ksys_mmap_pgoff+0x17e/0x220
__s390x_sys_old_mmap+0xa8/0x140
__do_syscall+0x172/0x750
system_call+0x72/0x90
-> #1 (&mm->mmap_lock){++++}-{3:3}:
lock_acquire+0x150/0x3f0
__might_fault+0x7a/0xa0
filldir64+0x11c/0x210
offset_readdir+0x92/0x200
iterate_dir+0xcc/0x2d0
__do_sys_getdents64+0x7a/0x130
__do_syscall+0x172/0x750
system_call+0x72/0x90
-> #0 (&type->i_mutex_dir_key#2){++++}-{3:3}:
check_prev_add+0x160/0xf40
__lock_acquire+0x12aa/0x15a0
lock_acquire+0x150/0x3f0
down_read+0x5a/0x280
lookup_slow+0x3e/0x70
path_lookupat+0x1f0/0x370
filename_lookup+0xce/0x1f0
kern_path+0x48/0x70
is_same_device+0x146/0x300
device_list_add.constprop.0+0x1be/0xc60
btrfs_scan_one_device+0x13a/0x2f0
btrfs_control_ioctl+0x110/0x1e0
__s390x_sys_ioctl+0xfa/0x130
__do_syscall+0x172/0x750
system_call+0x72/0x90
other info that might help us debug this:
Chain exists of:
&type->i_mutex_dir_key#2 --> &fs_info->tree_log_mutex --> &fs_devs->device_list_mutex
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&fs_devs->device_list_mutex);
lock(&fs_info->tree_log_mutex);
lock(&fs_devs->device_list_mutex);
rlock(&type->i_mutex_dir_key#2);
*** DEADLOCK ***
2 locks held by (udev-worker)/1653:
#0: 0000016c727051c8 (uuid_mutex){+.+.}-{3:3}, at: btrfs_control_ioctl+0x102/0x1e0
#1: 00000069238564d8 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: device_list_add.constprop.0+0x148/0xc60
stack backtrace:
CPU: 2 UID: 0 PID: 1653 Comm: (udev-worker) Not tainted 7.2.0-20260712.rc2.git0.e3321fa3034d.300.fc44.s390x+debug #1 PREEMPT
Hardware name: IBM 3931 A01 701 (LPAR)
Call Trace:
[<0000016c70680e3e>] dump_stack_lvl+0xae/0x108
[<0000016c7078aa44>] print_circular_bug+0x1a4/0x230
[<0000016c7078ac5c>] check_noncircular+0x18c/0x1b0
[<0000016c7078c030>] check_prev_add+0x160/0xf40
[<0000016c7078fbaa>] __lock_acquire+0x12aa/0x15a0
[<0000016c7078fff0>] lock_acquire+0x150/0x3f0
[<0000016c7180e2fa>] down_read+0x5a/0x280
[<0000016c70b88dde>] lookup_slow+0x3e/0x70
[<0000016c70b8f5d0>] path_lookupat+0x1f0/0x370
[<0000016c70b900ae>] filename_lookup+0xce/0x1f0
[<0000016c70b90218>] kern_path+0x48/0x70
[<0000016c70f5b4a6>] is_same_device+0x146/0x300
[<0000016c70f67cfe>] device_list_add.constprop.0+0x1be/0xc60
[<0000016c70f688da>] btrfs_scan_one_device+0x13a/0x2f0
[<0000016c70ed9cb0>] btrfs_control_ioctl+0x110/0x1e0
[<0000016c70b97d0a>] __s390x_sys_ioctl+0xfa/0x130
[<0000016c718004d2>] __do_syscall+0x172/0x750
[<0000016c718155d2>] system_call+0x72/0x90[CAUSE]
Btrfs device scan will call is_same_device() with device_list_mutex held. But is_same_device() will call kern_path() which will do path resolution and lock the inode.
So device scan has the following lock sequence:
mutex_lock(device_list_mutex) from device_list_add()
|
v
inode_lock_shared() from lookup_slow() during kern_path().
Meanwhile another thread is fsyncing, which has the following lock sequence:
inode_lock() from btrfs_inode_lock() inside btrfs_direct_write()
|
v
mutex_lock(tree_log_mutex() from btrfs_sync_log(), which is further triggered from iomap_dio_complete()->generic_write_sync()->btrfs_sync_file().
|
v
mutex_lock(device_list_mutex) from write_all_supers() inside btrfs_sync_log().
So the device scan has a reversed lock sequence, compared to the fsync one, this means we can have the following deadlock:
Device scan | Fsync
----------------------------------------+--------------------------------
device_list_mutex locked |
| inode locked
| try to lock device_list_mutex
try to lock inode |
[FIX]
Instead of a full path lookup, use dev_t to determine if two device paths are pointing to the same block device.
Inside kernel dev_t is going to uniquely determine a block device, and the device path lookup is already done by lookup_bdev(), which is done without device_list_mutex held, thus no reversed locking sequence.
--- fs/btrfs/volumes.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)
fs/btrfs/volumes.c +1 -36
@@ -740,41 +740,6 @@ const u8 *btrfs_sb_fsid_ptr(const struct btrfs_super_block *sb)return has_metadata_uuid ? sb->metadata_uuid : sb->fsid; } -static bool is_same_device (struct btrfs_device *device,const char *new_path) -{ -struct path old = { .mnt =NULL , .dentry =NULL }; -struct path new = { .mnt =NULL , .dentry =NULL }; -char AUTO_KFREE (old_path ); -bool is_same = false; -int ret; - -if (!device->name) - goto out; - - old_path =kzalloc (PATH_MAX ,GFP_NOFS ); -if (!old_path) - goto out; - -rcu_read_lock (); - ret =strscpy (old_path,rcu_dereference (device->name),PATH_MAX ); -rcu_read_unlock (); -if (ret <0 ) - goto out; - - ret =kern_path (old_path,LOOKUP_FOLLOW , &old); -if (ret) - goto out; - ret =kern_path (new_path,LOOKUP_FOLLOW , &new); -if (ret) - goto out; -if (path_equal (&old, &new)) - is_same = true; -out: -path_put (&old); -path_put (&new); -return is_same; -} -/* * Add new device to list of registered devices *
@@ -895,7 +860,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,MAJOR (path_devt),MINOR (path_devt), current->comm, task_pid_nr(current)); - }else if (!device->name || !is_same_device (device, path)) { + }else if (!device->name || device->devt != path_devt) {const char *old_name;/*
Signature · 1 line
2.53.0
Re: [PATCH 7.2 1226/1815] btrfs: fix a lockdep caused by path resolution during device scan
Quoted 1 line · Greg Kroah-Hartman
7.2-stable review patch. If anyone has any objections, please let me know.
Please drop this one.
There are already users (although the minority of users) who do not use an initramfs to boot, and the device path of rootfs stays as "/dev/root".
With this patch, there will be no way to update the "/dev/root" name of the rootfs.
Normally it is just a cosmetic problem, but tools like grub2 will be unable to probe the driver for the rootfs.
I'd argue we should discourage root btrfs without an initramfs, and grub2 should use device number/libblkid to properly detect rootfs devices, but still there are users complaining.
There will be a special hot fix for it, but I'd prefer to at least delay this one.
The deadlock itself is not easy to trigger, it requires block device files created on btrfs, and doing block device scan on that file over btrfs.
Thanks,
Qu
Quoted 241 lines
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit
108cc873398932af589c295f78c348513b8d70d9][BUG]
There is a lockdep report related to device scan:======================================================
WARNING: possible circular locking dependency detected 7.2.0-20260712.rc2.git0.e3321fa3034d.300.fc44.s390x+debug #1 Not tainted
------------------------------------------------------
(udev-worker)/1653 is trying to acquire lock:
0000006919232220 (&type->i_mutex_dir_key#2){++++}-{3:3}, at:lookup_slow+0x3e/0x70
but task is already holding lock:00000069238564d8(&fs_devs->device_list_mutex){+.+.}-{3:3}, at: device_list_add.constprop.0+0x148/0xc60 which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #5 (&fs_devs->device_list_mutex){+.+.}-{3:3}:lock_acquire+0x150/0x3f0 __mutex_lock+0xba/0xdc0 mutex_lock_nested+0x32/0x40 write_all_supers+0x7a/0x670 btrfs_sync_log+0xae6/0xdd0 btrfs_sync_file+0x4fa/0x7a0 __s390x_sys_fsync+0x52/0xa0 __do_syscall+0x172/0x750 system_call+0x72/0x90 -> #4 (&fs_info->tree_log_mutex){+.+.}-{3:3}: lock_acquire+0x150/0x3f0 __mutex_lock+0xba/0xdc0 mutex_lock_nested+0x32/0x40 btrfs_sync_log+0xaba/0xdd0 btrfs_sync_file+0x4fa/0x7a0 __s390x_sys_fsync+0x52/0xa0 __do_syscall+0x172/0x750 system_call+0x72/0x90 -> #3 (btrfs_trans_num_extwriters){.+.+}-{0:0}: lock_acquire+0x150/0x3f0 join_transaction+0x108/0x680 start_transaction+0x21a/0x660 btrfs_join_transaction+0x32/0x40 btrfs_dirty_inode+0x52/0xf0 touch_atime+0x90/0xc0 filemap_read+0x446/0x450 vfs_read+0x208/0x370 ksys_read+0x88/0x120 __do_syscall+0x172/0x750 system_call+0x72/0x90 -> #2 (btrfs_trans_num_writers){.+.+}-{0:0}: reacquire_held_locks+0x14c/0x240 __lock_release.isra.0+0xd8/0x380 lock_release+0xf6/0x270 percpu_up_read+0x28/0xf0 __btrfs_end_transaction+0x178/0x1f0 btrfs_dirty_inode+0x82/0xf0 touch_atime+0x90/0xc0 btrfs_file_mmap_prepare+0x8c/0xa0 __mmap_region+0x214/0x780 mmap_region+0x108/0x160 do_mmap+0x402/0x5a0 vm_mmap_pgoff+0x156/0x230 ksys_mmap_pgoff+0x17e/0x220 __s390x_sys_old_mmap+0xa8/0x140 __do_syscall+0x172/0x750 system_call+0x72/0x90 -> #1 (&mm->mmap_lock){++++}-{3:3}: lock_acquire+0x150/0x3f0 __might_fault+0x7a/0xa0 filldir64+0x11c/0x210 offset_readdir+0x92/0x200 iterate_dir+0xcc/0x2d0 __do_sys_getdents64+0x7a/0x130 __do_syscall+0x172/0x750 system_call+0x72/0x90 -> #0 (&type->i_mutex_dir_key#2){++++}-{3:3}: check_prev_add+0x160/0xf40 __lock_acquire+0x12aa/0x15a0 lock_acquire+0x150/0x3f0 down_read+0x5a/0x280 lookup_slow+0x3e/0x70 path_lookupat+0x1f0/0x370 filename_lookup+0xce/0x1f0 kern_path+0x48/0x70 is_same_device+0x146/0x300 device_list_add.constprop.0+0x1be/0xc60 btrfs_scan_one_device+0x13a/0x2f0 btrfs_control_ioctl+0x110/0x1e0 __s390x_sys_ioctl+0xfa/0x130 __do_syscall+0x172/0x750 system_call+0x72/0x90 other info that might help us debug this: Chain exists of: &type->i_mutex_dir_key#2 --> &fs_info->tree_log_mutex --> &fs_devs->device_list_mutex Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&fs_devs->device_list_mutex); lock(&fs_info->tree_log_mutex); lock(&fs_devs->device_list_mutex); rlock(&type->i_mutex_dir_key#2); *** DEADLOCK *** 2 locks held by (udev-worker)/1653: #0: 0000016c727051c8 (uuid_mutex){+.+.}-{3:3}, at: btrfs_control_ioctl+0x102/0x1e0 #1: 00000069238564d8 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: device_list_add.constprop.0+0x148/0xc60 stack backtrace: CPU: 2 UID: 0 PID: 1653 Comm: (udev-worker) Not tainted 7.2.0-20260712.rc2.git0.e3321fa3034d.300.fc44.s390x+debug #1 PREEMPT Hardware name: IBM 3931 A01 701 (LPAR) Call Trace: [<0000016c70680e3e>] dump_stack_lvl+0xae/0x108 [<0000016c7078aa44>] print_circular_bug+0x1a4/0x230 [<0000016c7078ac5c>] check_noncircular+0x18c/0x1b0 [<0000016c7078c030>] check_prev_add+0x160/0xf40 [<0000016c7078fbaa>] __lock_acquire+0x12aa/0x15a0 [<0000016c7078fff0>] lock_acquire+0x150/0x3f0 [<0000016c7180e2fa>] down_read+0x5a/0x280 [<0000016c70b88dde>] lookup_slow+0x3e/0x70 [<0000016c70b8f5d0>] path_lookupat+0x1f0/0x370 [<0000016c70b900ae>] filename_lookup+0xce/0x1f0 [<0000016c70b90218>] kern_path+0x48/0x70 [<0000016c70f5b4a6>] is_same_device+0x146/0x300 [<0000016c70f67cfe>] device_list_add.constprop.0+0x1be/0xc60 [<0000016c70f688da>] btrfs_scan_one_device+0x13a/0x2f0 [<0000016c70ed9cb0>] btrfs_control_ioctl+0x110/0x1e0 [<0000016c70b97d0a>] __s390x_sys_ioctl+0xfa/0x130 [<0000016c718004d2>] __do_syscall+0x172/0x750 [<0000016c718155d2>] system_call+0x72/0x90[CAUSE]
Btrfs device scan will callis_same_device()withdevice_list_mutexheld. Butis_same_device()will callkern_path()which will do path resolution and lock the inode.So device scan has the following lock sequence:
mutex_lock(device_list_mutex)fromdevice_list_add()| v
inode_lock_shared()fromlookup_slow()duringkern_path().Meanwhile another thread is fsyncing, which has the following lock sequence:
inode_lock()frombtrfs_inode_lock()insidebtrfs_direct_write()| v mutex_lock(tree_log_mutex() from btrfs_sync_log(), which is further triggered from iomap_dio_complete()->generic_write_sync()->btrfs_sync_file(). | v
mutex_lock(device_list_mutex)fromwrite_all_supers()insidebtrfs_sync_log().So the device scan has a reversed lock sequence, compared to the fsync one, this means we can have the following deadlock:
Device scan | Fsync
----------------------------------------+--------------------------------
device_list_mutexlocked |
| inode locked
| try to lockdevice_list_mutex
try to lock inode |[FIX]
Instead of a full path lookup, usedev_tto determine if two device paths are pointing to the same block device.Inside kernel
dev_tis going to uniquely determine a block device, and the device path lookup is already done bylookup_bdev(), which is done withoutdevice_list_mutexheld, thus no reversed locking sequence.Reported-by Christian Borntraeger <[email protected]>Fixes 2e8b6bc0ab41 ("btrfs: avoid unnecessary device path update for the same device")Reviewed-by Filipe Manana <[email protected]>Signed-off-by Qu Wenruo <[email protected]>Signed-off-by David Sterba <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- fs/btrfs/volumes.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)fs/btrfs/volumes.c +1
-36@@ -740,41 +740,6 @@ const u8 *btrfs_sb_fsid_ptr(const struct btrfs_super_block *sb)return has_metadata_uuid ? sb->metadata_uuid : sb->fsid; } -static bool is_same_device (struct btrfs_device *device,const char *new_path) -{ -struct path old = { .mnt =NULL , .dentry =NULL }; -struct path new = { .mnt =NULL , .dentry =NULL }; -char AUTO_KFREE (old_path ); -bool is_same = false; -int ret; - -if (!device->name) - goto out; - - old_path =kzalloc (PATH_MAX ,GFP_NOFS ); -if (!old_path) - goto out; - -rcu_read_lock (); - ret =strscpy (old_path,rcu_dereference (device->name),PATH_MAX ); -rcu_read_unlock (); -if (ret <0 ) - goto out; - - ret =kern_path (old_path,LOOKUP_FOLLOW , &old); -if (ret) - goto out; - ret =kern_path (new_path,LOOKUP_FOLLOW , &new); -if (ret) - goto out; -if (path_equal (&old, &new)) - is_same = true; -out: -path_put (&old); -path_put (&new); -return is_same; -} -/* * Add new device to list of registered devices * @@ -895,7 +860,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,MAJOR (path_devt),MINOR (path_devt), current->comm, task_pid_nr(current)); - }else if (!device->name || !is_same_device (device, path)) { + }else if (!device->name || device->devt != path_devt) {const char *old_name;/*
Re: [PATCH 7.2 1226/1815] btrfs: fix a lockdep caused by path resolution during device scan
Quoted 13 lines · Qu Wenruo
Quoted 1 line · Greg Kroah-Hartman
7.2-stable review patch. If anyone has any objections, please let me know.
Please drop this one.
There are already users (although the minority of users) who do not use an initramfs to boot, and the device path of rootfs stays as "
/dev/root".With this patch, there will be no way to update the "
/dev/root" name of the rootfs.Normally it is just a cosmetic problem, but tools like grub2 will be unable to probe the driver for the rootfs.
Quoted 8 lines
I'd argue we should discourage root btrfs without an initramfs, and grub2 should use device number/libblkid to properly detect rootfs devices, but still there are users complaining.
There will be a special hot fix for it, but I'd prefer to at least delay this one.
The deadlock itself is not easy to trigger, it requires block device files created on btrfs, and doing block device scan on that file over btrfs.
Thanks,
Qu
I see that the stable-queue now has a revert for this patch queued up in staging-7.2. That could make sense if this patch had already made it into a 7.2.y release. However, it hasn't yet, so I think it would make more sense to either (a) just drop this patch from queue-7.2 or
(b) add the revert to queue-7.2 instead of staging-7.2.
(I guess I'm afraid 7.2.6 might be released with this patch even though it's already known that it needs to be dropped or reverted. Maybe I'm overreacting, but I just want to make sure this doesn't fall through the cracks.)
Signature · 1 line
-Barry K. Nathan <[email protected]>
Sasha Levin
maintainerRe: [PATCH 7.2 1226/1815] btrfs: fix a lockdep caused by path resolution during device scan
In reply to Qu WenruoQuoted 1 line
Please drop this one.
Dropped from the 7.2 queue.
Signature · 2 lines
Thanks, Sasha
Greg Kroah-Hartman
maintainerPATCH 1227/1815 btrfs: make sure EXTENT_BUFFER_READING is cleared under refs_lock
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 690c2accacb1aca91ab8186d15dee56da8723f31 ]
[FALSE ALERTS]
There is a bug report that the warning inside invalidate_and_check_btree_folios() got triggered during btrfs/298:
BTRFS info (device sdd): first mount of filesystem f9bf732a-a19b-44b9-99a7-614ddff168e2
BTRFS info (device sdd): using crc32c checksum algorithm
BTRFS error (device sdd): failed to find fsid cb2fdb42-b638-4f2f-badd-4127467ba674 when attempting to open seed devices BTRFS error (device sdd): failed to read chunk tree: -2
------------[ cut here ]------------ WARNING: disk-io.c:3342 at invalidate_and_check_btree_folios+0x260/0x3c0 [btrfs], CPU#4: mount/125993 CPU: 4 UID: 0 PID: 125993 Comm: mount Tainted: G W OE 7.1.0-rc7-custom+ #1 PREEMPT(full) Hardware name: QEMU KVM Virtual Machine, BIOS edk2-20250812-19.fc42 08/12/2025 Call trace: invalidate_and_check_btree_folios+0x260/0x3c0 [btrfs] (P) open_ctree+0x1f50/0x23b0 [btrfs] btrfs_get_tree+0x89c/0xc48 [btrfs] vfs_get_tree+0x30/0x110 vfs_cmd_create+0x58/0xe8 __arm64_sys_fsconfig+0x39c/0x518 invoke_syscall.constprop.0+0x48/0x120 el0_svc_common.constprop.0+0x40/0xe8 do_el0_svc+0x24/0x38 el0_svc+0x50/0x310 el0t_64_sync_handler+0xa0/0xe8 el0t_64_sync+0x198/0x1a0 ---[ end trace 0000000000000000 ]--- BTRFS warning (device sdd): unable to release extent buffer 365985792 owner 3 gen 17 refs 3 flags 0x5
[CAUSE]
In that invalidate_and_check_btree_folios() we wait for the eb to finish its read, then check if it's only held by us and the btree inode.
If not, then do a warning as it may be still held, and could cause problems.
But there is a small window where the check can lead to false alerts:
Thread A (Read endio) | Thread B (Unmount)
----------------------------------+-------------------------------------
end_bbio_meta_read() | | The eb has one extra ref held | | by the reader, and has | | EXTENT_BUFFER_READING flag set | invalidate_and_check_btree_folios() | | | |- clear_extent_buffer_reading() | | | | |- wait_on_bit_io(); | | | The EXTENT_BUFFER_READING flag is | | | cleared | | |- if (refcount_read(eb->refs) > 2) | | The eb is held by the read, us | | and btree inode, thus it | | will trigger the warning |- free_extent_buffer() |
[FIX]
Introduce a helper, free_extent_buffer_clear_reading().
If the new parameter, @clear_reading, is set, we will hold the spinlock at the beginning of free_extent_buffer_clear_reading() to make sure the EXTENT_BUFFER_READING flag is cleared inside the same critical section of decreasing refs.
Now free_extent_buffer() will just call free_extent_buffer_clear_reading() with @clear_reading set to false, so no behavior change.
But for end_bbio_meta_read(), it will not clear_extent_buffer_reading() directly, but pass @clear_reading as true.
Then inside invalidate_and_check_btree_folios(), hold the refs_lock before reading refs.
So that we eliminate the race window completely.
--- fs/btrfs/disk-io.c | 16 ++++++++++++++-- fs/btrfs/extent_io.c | 43 +++++++++++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 12 deletions(-)
fs/btrfs/disk-io.c +14 -2
@@ -3314,6 +3314,8 @@ static void invalidate_and_check_btree_folios(struct btrfs_fs_info *fs_info)*/ rcu_read_lock ();xa_for_each (&fs_info->buffer_tree, index, eb) { +unsigned int refs; +/* Increase the ref so that the eb won't disappear. */ if (!refcount_inc_not_zero (&eb->refs))continue ;
@@ -3323,17 +3325,27 @@ static void invalidate_and_check_btree_folios(struct btrfs_fs_info *fs_info)if (test_bit (EXTENT_BUFFER_READING , &eb->bflags))wait_on_bit_io (&eb->bflags,EXTENT_BUFFER_READING ,TASK_UNINTERRUPTIBLE ); +/* +* We hold the spinlock to make sure above +* EXTENT_BUFFER_READING flag is cleared with the held +* ref dropped. +* Or we can hit a race window and lead to false alerts. +*/ +spin_lock (&eb->refs_lock); + refs =refcount_read (&eb->refs); +spin_unlock (&eb->refs_lock); +/* * The refs threshold is 2, one held by us at the beginning * of the loop, one for the ownership in the buffer tree. */ -if (unlikely (refcount_read (&eb->refs) >2 ||extent_buffer_under_io (eb))) { +if (unlikely (refs >2 ||extent_buffer_under_io (eb))) {WARN_ON_ONCE (IS_ENABLED (CONFIG_BTRFS_DEBUG ));btrfs_warn (fs_info,"unable to release extent buffer %llu owner %llu gen %llu refs %u flags 0x%lx" , eb->start,btrfs_header_owner (eb),btrfs_header_generation (eb), -refcount_read (&eb->refs), eb->bflags); + refs, eb->bflags); }free_extent_buffer (eb);rcu_read_lock ();
fs/btrfs/extent_io.c +33 -10
81 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1228/1815 btrfs: check if root is readonly when setting posix acl
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sun YangKai <[email protected]>
[ Upstream commit 01c2f41fc441f75b3f9326443372faceb1cb6638 ]
For a filesystem which has btrfs read-only property set to true, all write operations including acl and xattr should be denied. However, acl can still be set even if btrfs ro property is true.
This happens because no function on the set_acl code path checks the root is readonly or not. It was checked in btrfs_setxattr_trans() but got removed in commit 353c2ea735e4 ("btrfs: remove redundant readonly root check in btrfs_setxattr_trans")
That commit didn't check if all the callers properly check the root's read-only flag. A previous fix is commit b51111271b03 ("btrfs: check if root is readonly while setting security xattr").
Always check if the root is read-only before performing the set acl operation.
--- fs/btrfs/acl.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/btrfs/acl.c +4 -0
@@ -15,6 +15,7 @@#include "xattr.h" #include "acl.h" #include "misc.h" +#include "btrfs_inode.h" struct posix_acl *btrfs_get_acl (struct inode *inode,int type,bool rcu) {
@@ -107,6 +108,9 @@ int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,struct inode *inode =d_inode (dentry);umode_t old_mode = inode->i_mode; +if (btrfs_root_readonly (BTRFS_I (inode)->root)) +return -EROFS ; +if (type ==ACL_TYPE_ACCESS && acl) { ret =posix_acl_update_mode (idmap, inode, &inode->i_mode, &acl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1229/1815 btrfs: replace writeback inhibition xarray with a fixed inline buffer
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Martins <[email protected]>
[ Upstream commit 67bd829a14b7d71ffea28147b98dadf9ee684568 ]
Commit f9a48549a15a ("btrfs: inhibit extent buffer writeback to prevent COW amplification") tracks the extent buffers a transaction handle has inhibited in a per-handle xarray. Keying the tracking to the transaction handle is correct, but using an xarray for it causes two problems in production.
First, a write_iops regression. Every COW calls btrfs_inhibit_eb_writeback() from btrfs_force_cow_block() and should_cow_block(), which does an xa_store() keyed by eb->start. The kernel test robot reported a 22.6% fio.write_iops regression on a single-task 4k randwrite workload (ftruncate ioengine, buffered IO) on btrfs. The cost is the per-COW xarray store done on every COW'd block. Replacing it with a non-allocating fixed buffer recovers the lost throughput, and that buffer does more per-COW bookkeeping yet still recovers, so the cost is the xarray operation itself rather than the extra tracking work.
Second, an unbounded cleanup walk. btrfs_uninhibit_all_eb_writeback() iterates every eb the handle inhibited with xa_for_each(). A single handle that COWs a very large number of blocks (inode eviction, or truncate of a file with many extents, where btrfs_truncate_inode_items() loops over many search_again descents under one handle) makes that walk arbitrarily long. It runs in __btrfs_end_transaction() before num_writers is dropped, so it blocks the committing thread; this shows up as multi-second stalls and RCU stall reports.
Replace the xarray with a fixed inline array on btrfs_trans_handle, managed with a CLOCK (second-chance) eviction policy. Inhibiting a buffer becomes an array append with no allocation and no tree walk, and the end-of-handle cleanup is bounded by the array size.
The set that actually needs protection is the working set the handle revisits across search_again descents, the search path frontier, which is on the order of the tree height. It is not every block the handle ever COWs. should_cow_block() re-inhibiting an already tracked buffer marks it referenced, so revisited buffers survive eviction while write-once buffers are reclaimed first. A small fixed buffer is therefore enough where a non-evicting array would either overflow or have to grow without bound. BTRFS_INHIBITED_EBS_SLOTS is 8 and the reference bits pack into a u32.
The CLOCK eviction is what justifies the extra complexity over a plain non-evicting array. The test workload stresses amplification: it removes 16 heavily fragmented 64 MiB files in one transaction while background writeback keeps writing out in-use metadata. A re-COW event is a buffer already COWed in the running transaction that was written back and then COWed again; the figure below is the ratio of re-COW events to first-COW events summed across the eviction (n=5, lower is better):
tracking re-COW per first-COW no inhibition 6.1 non-evicting array, 32 slots 3.8 CLOCK array, 8 slots (this patch) 1.6 unbounded xarray (reverted) 1.4
The non-evicting array fills with write-once buffers and stops covering the buffers the handle keeps revisiting, so even at four times the slots it leaves most of the amplification. CLOCK evicts the cold buffers and keeps the revisited ones, recovering almost all of the unbounded benefit. The eviction policy, not the buffer size, is what closes the gap.
eb->writeback_inhibitors and the WB_SYNC_ALL bypass in lock_extent_buffer_for_io() are unchanged, so fsync and commit behavior are unaffected. A reference is taken on each tracked buffer so it cannot be freed while the array points at it; eviction drops that reference and the inhibitor count.
There's another testing report, showing 20% latency improvement on
reflink and deduplication synthetic benchmark. Full detailed report at
https://github.com/lcf0399/linux-regression-evidence/tree/main/btrfs-remap-writeback-inhibition-v2 .
--- fs/btrfs/extent_io.c | 87 ++++++++++++++++++++++++++---------------- fs/btrfs/transaction.c | 2 - fs/btrfs/transaction.h | 25 ++++++++++-- 3 files changed, 77 insertions(+), 37 deletions(-)
fs/btrfs/extent_io.c +55 -32
@@ -3129,47 +3129,71 @@ static inline void btrfs_release_extent_buffer(struct extent_buffer *eb)kmem_cache_free (extent_buffer_cache, eb); } +/* +* Claim a slot to track an extent buffer in, evicting the coldest tracked buffer +* when the array is full. +* +* Slots fill in order until the array is full. After that a CLOCK (second +* chance) scan advances the hand, clearing one reference bit per step, until +* it lands on an unreferenced slot whose buffer is evicted. Clearing a bit per +* step bounds the scan to BTRFS_INHIBITED_EBS_SLOTS iterations. +*/ +static int btrfs_inhibit_claim_slot (struct btrfs_trans_handle *trans) +{ +int slot; + +if (trans->nr_inhibited_ebs <BTRFS_INHIBITED_EBS_SLOTS ) +return trans->nr_inhibited_ebs++; + +while (trans->inhibited_ebs_referenced & (1U << trans->inhibited_ebs_hand)) { + trans->inhibited_ebs_referenced &= ~(1U << trans->inhibited_ebs_hand); + trans->inhibited_ebs_hand = + (trans->inhibited_ebs_hand +1 ) %BTRFS_INHIBITED_EBS_SLOTS ; + } + slot = trans->inhibited_ebs_hand; + trans->inhibited_ebs_hand = (trans->inhibited_ebs_hand +1 ) %BTRFS_INHIBITED_EBS_SLOTS ; + +atomic_dec (&trans->inhibited_ebs[slot]->writeback_inhibitors); +free_extent_buffer (trans->inhibited_ebs[slot]); + +return slot; +} +/* * Inhibit writeback on buffer during transaction. * * @trans: transaction handle that will own the inhibitor * @eb: extent buffer to inhibit writeback on * -* Attempt to track this extent buffer in the transaction's inhibited set. If -* memory allocation fails, the buffer is simply not tracked. It may be written -* back and need re-COW, which is the original behavior. This is acceptable -* since inhibiting writeback is an optimization. +* Attempt to track this extent buffer in the transaction's inhibited set. When +* the set is full the coldest tracked buffer is evicted instead. An untracked +* buffer may be written back and need re-COW, which is the original behavior. +* This is acceptable since inhibiting writeback is an optimization. */ void btrfs_inhibit_eb_writeback (struct btrfs_trans_handle *trans,struct extent_buffer *eb) { -unsigned long index = eb->start >> trans->fs_info->nodesize_bits; -void *old; +int slot;lockdep_assert_held (&eb->lock); -/* Check if already inhibited by this handle. */ - old =xa_load (&trans->writeback_inhibited_ebs, index); -if (old == eb) -return ; - -/* Take reference for the xarray entry. */ -refcount_inc (&eb->refs); - old =xa_store (&trans->writeback_inhibited_ebs, index, eb,GFP_NOFS ); -if (xa_is_err (old)) { -/* Allocation failed, just skip inhibiting this buffer. */ -free_extent_buffer (eb); -return ; +/* Already tracked: set its reference bit (second chance) and return. */ +for (int i =0 ; i < trans->nr_inhibited_ebs; i++) { +if (trans->inhibited_ebs[i] == eb) { + trans->inhibited_ebs_referenced |=1U << i; +return ; + } } -/* Handle replacement of different eb at same index. */ -if (old && old != eb) { -struct extent_buffer *old_eb = old; - -atomic_dec (&old_eb->writeback_inhibitors); -free_extent_buffer (old_eb); - } + slot =btrfs_inhibit_claim_slot (trans); +/* +* Pin the eb while the array holds a raw pointer to it; the counter is +* what lock_extent_buffer_for_io() checks. +*/ +refcount_inc (&eb->refs);atomic_inc (&eb->writeback_inhibitors); + trans->inhibited_ebs[slot] = eb; + trans->inhibited_ebs_referenced |=1U << slot; }/*
@@ -3177,14 +3201,13 @@ void btrfs_inhibit_eb_writeback(struct btrfs_trans_handle *trans, struct extent_*/ void btrfs_uninhibit_all_eb_writeback (struct btrfs_trans_handle *trans) { -struct extent_buffer *eb; -unsigned long index; - -xa_for_each (&trans->writeback_inhibited_ebs, index, eb) { -atomic_dec (&eb->writeback_inhibitors); -free_extent_buffer (eb); +for (int i =0 ; i < trans->nr_inhibited_ebs; i++) { +atomic_dec (&trans->inhibited_ebs[i]->writeback_inhibitors); +free_extent_buffer (trans->inhibited_ebs[i]); } -xa_destroy (&trans->writeback_inhibited_ebs); + trans->nr_inhibited_ebs =0 ; + trans->inhibited_ebs_referenced =0 ; + trans->inhibited_ebs_hand =0 ; } static struct extent_buffer *__alloc_extent_buffer(struct btrfs_fs_info *fs_info,
fs/btrfs/transaction.c +0 -2
@@ -698,8 +698,6 @@ start_transaction(struct btrfs_root *root, unsigned int num_items, goto alloc_fail; } -xa_init (&h->writeback_inhibited_ebs); -/* * If we are JOIN_NOLOCK we're already committing a transaction and * waiting on this guy, so we don't need to do the sb_start_intwrite
fs/btrfs/transaction.h +22 -3
@@ -7,12 +7,12 @@#define BTRFS_TRANSACTION_H #include <linux/atomic.h> +#include <linux/build_bug.h> #include <linux/refcount.h> #include <linux/list.h> #include <linux/time64.h> #include <linux/mutex.h> #include <linux/wait.h> -#include <linux/xarray.h> #include "btrfs_inode.h" #include "delayed-ref.h"
@@ -23,6 +23,7 @@ struct btrfs_fs_info;struct btrfs_root_item ;struct btrfs_root ;struct btrfs_path ; +struct extent_buffer ;/* * Signal that a direct IO write is in progress, to avoid deadlock for sync
@@ -136,6 +137,18 @@ enum {#define TRANS_EXTWRITERS (__TRANS_START | __TRANS_ATTACH) +/* +* Number of extent buffers a transaction handle tracks for writeback +* inhibition. The CLOCK reference bits pack into a u32 so this must not exceed +* 32, and keeping it a power of two lets the compiler reduce the CLOCK hand +* modulo to a mask. +*/ +#define BTRFS_INHIBITED_EBS_SLOTS 8 + +static_assert (BTRFS_INHIBITED_EBS_SLOTS <=32 ); +static_assert (BTRFS_INHIBITED_EBS_SLOTS !=0 && + (BTRFS_INHIBITED_EBS_SLOTS & (BTRFS_INHIBITED_EBS_SLOTS -1 )) ==0 ); +struct btrfs_trans_handle {u64 transid;u64 bytes_reserved;
@@ -163,8 +176,14 @@ struct btrfs_trans_handle {struct btrfs_fs_info *fs_info;struct list_head new_bgs;struct btrfs_block_rsv delayed_rsv; -/* Extent buffers with writeback inhibited by this handle. */ -struct xarray writeback_inhibited_ebs; + +/* Extent buffers this handle has inhibited writeback on. */ +struct extent_buffer *inhibited_ebs[BTRFS_INHIBITED_EBS_SLOTS ]; +/* CLOCK reference bit per slot. */ +u32 inhibited_ebs_referenced; +u32 nr_inhibited_ebs; +/* CLOCK hand. */ +u32 inhibited_ebs_hand; };/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1230/1815 btrfs: retry verity reads for not-uptodate Merkle folios
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yichong Chen <[email protected]>
[ Upstream commit 8cc569696dac51fc62bb39b3b8f530582b916d29 ]
btrfs_read_merkle_tree_page() can find a folio in the mapping that is not uptodate. After taking the folio lock, the current code treats that state as a read error and returns -EIO.
That can make a previous transient read failure sticky. If the failed read left a not-uptodate folio in the mapping, later callers find that folio and fail instead of retrying the read.
Keep the existing page-cache insertion and locking order, but retry the Merkle item read when a not-uptodate folio is found in the mapping. Also unlock the folio when read_key_bytes() fails so that a later caller can lock it and retry the read.
--- fs/btrfs/verity.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
fs/btrfs/verity.c +11 -5
@@ -720,14 +720,18 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode, goto out;folio_lock (folio); -/* If it's not uptodate after we have the lock, we got a read error. */ -if (!folio_test_uptodate (folio)) { +/* Folio was truncated from mapping. */ +if (!folio->mapping) {folio_unlock (folio);folio_put (folio); -return ERR_PTR (-EIO ); + goto again; } -folio_unlock (folio); - goto out; +/* Another reader may have filled the folio while we waited. */ +if (folio_test_uptodate (folio)) { +folio_unlock (folio); + goto out; + } + goto read_folio; } folio = filemap_alloc_folio(mapping_gfp_constraint(inode->i_mapping, ~__GFP_FS),
@@ -744,6 +748,7 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode,return ERR_PTR (ret); } +read_folio:/* * Merkle item keys are indexed from byte 0 in the merkle tree. * They have the form:
@@ -753,6 +758,7 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode, ret =read_key_bytes (BTRFS_I (inode),BTRFS_VERITY_MERKLE_ITEM_KEY , off,folio_address (folio),PAGE_SIZE , folio);if (ret <0 ) { +folio_unlock (folio);folio_put (folio);return ERR_PTR (ret); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1231/1815 btrfs: zoned: flush active metadata block group at btree_writepages() start
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit ecc05eda9a346848ae01a6c8bfa3f0bec133bd8b ]
btree_writepages() writes the btree inode's dirty metadata in ascending logical address order. On a zoned filesystem only one metadata and one system block group is active for writing at a time, and check_bg_is_active() (via btrfs_check_meta_write_pointer()) pivots the active block group as writeback moves from one block group to the next.
If the active block group sits at a higher logical address than another block group that also holds dirty metadata, the ascending walk reaches the lower one first and, to write it, has to finish the active block group and activate the lower one. It cannot finish a block group that still has unsent IO, and during WB_SYNC_ALL && !for_sync (commit) writeback it deliberately refuses to wait for that IO under fs_info->zoned_meta_io_lock, as that can deadlock. The pivot thus cannot issue the submission itself either, so it gives up:btrfs_check_meta_write_pointer() returns -EAGAIN, which btrfs_write_and_wait_transaction() treats as fatal and aborts the transaction, forcing the filesystem read-only. This happens intermittently under metadata-heavy relocation (e.g. fstests btrfs/187).
Flush the active metadata and system block groups at the start of btree_writepages(), under the fs_info->zoned_meta_io_lock it already holds, so they have no unsent IO left and the later pivot can finish them and make forward progress.
--- fs/btrfs/extent_io.c | 113 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 92 insertions(+), 21 deletions(-)
fs/btrfs/extent_io.c +92 -21
@@ -2496,6 +2496,76 @@ void btrfs_btree_wait_writeback_range(struct btrfs_fs_info *fs_info, u64 start, } } +static int write_meta_extent_buffer (struct btrfs_eb_write_context *ctx, +struct writeback_control *wbc) +{ +struct extent_buffer *eb = ctx->eb; +int ret; + + ret =btrfs_check_meta_write_pointer (eb->fs_info, ctx); +if (ret) +return ret; + +if (!lock_extent_buffer_for_io (eb, wbc)) +return 0 ; + +/* Implies write in zoned mode. */ +if (ctx->zoned_bg) { +/* Mark the last eb in the block group. */ +btrfs_schedule_zone_finish_bg (ctx->zoned_bg, eb); + ctx->zoned_bg->meta_write_pointer += eb->len; + } +write_one_eb (eb, wbc); +return 0 ; +} + +/* +* On a zoned filesystem, write out the currently dirty metadata extent buffers +* of @bg. Used to flush the active metadata/system block group before the +* ascending-address walk in btree_writepages(), so that walk can pivot the +* active block group away (finishing it) instead of aborting the commit; see +* the caller for details. +*/ +static void flush_active_meta_bg (struct address_space *mapping, +struct writeback_control *wbc, +struct btrfs_eb_write_context *ctx, +struct btrfs_block_group *bg) +{ +struct btrfs_fs_info *fs_info =inode_to_fs_info (mapping->host); +unsigned long index = bg->start >> fs_info->nodesize_bits; +unsigned long end = (btrfs_block_group_end (bg) -1 ) >> fs_info->nodesize_bits; +struct eb_batch batch; +unsigned int nr_ebs; + +ASSERT (btrfs_is_zoned (fs_info)); +lockdep_assert_held (&fs_info->zoned_meta_io_lock); + +eb_batch_init (&batch); +while (index <= end && + (nr_ebs =buffer_tree_get_ebs_tag (fs_info, &index, end, +PAGECACHE_TAG_DIRTY , &batch))) { +struct extent_buffer *eb; + +while ((eb =eb_batch_next (&batch)) !=NULL ) { + ctx->eb = eb; + +/* +* If the eb is behind the write pointer (-EBUSY, e.g. +* already being written by someone else) skip it and +* carry on. Only a hole at the write pointer (-EAGAIN) +* stops the flush. The main walk in btree_writepages() +* then deals with it. +*/ +if (write_meta_extent_buffer (ctx, wbc) == -EAGAIN ) { +eb_batch_release (&batch); +return ; + } + } +eb_batch_release (&batch); +cond_resched (); + } +} +int btree_writepages (struct address_space *mapping,struct writeback_control *wbc) {struct btrfs_eb_write_context ctx = { .wbc = wbc };
@@ -2531,6 +2601,22 @@ int btree_writepages(struct address_space *mapping, struct writeback_control *wbelse tag =PAGECACHE_TAG_DIRTY ;btrfs_zoned_meta_io_lock (fs_info); + +/* +* On a zoned filesystem, flush the currently active metadata/system +* block group(s) first, under this same lock, so the ascending-address +* walk below can pivot the active block group instead of aborting the +* transaction commit with -EAGAIN. +*/ +if (btrfs_is_zoned (fs_info) && wbc->sync_mode ==WB_SYNC_ALL && + !wbc->for_sync) { +if (fs_info->active_meta_bg) +flush_active_meta_bg (mapping, wbc, &ctx, + fs_info->active_meta_bg); +if (fs_info->active_system_bg) +flush_active_meta_bg (mapping, wbc, &ctx, + fs_info->active_system_bg); + } retry:if (wbc->sync_mode ==WB_SYNC_ALL )buffer_tree_tag_for_writeback (fs_info, index, end);
@@ -2541,28 +2627,13 @@ int btree_writepages(struct address_space *mapping, struct writeback_control *wbwhile ((eb =eb_batch_next (&batch)) !=NULL ) { ctx.eb = eb; - ret =btrfs_check_meta_write_pointer (eb->fs_info, &ctx); -if (ret) { -if (ret == -EBUSY ) - ret =0 ; - -if (ret) { - done = true; -break ; - } -continue ; - } - -if (!lock_extent_buffer_for_io (eb, wbc)) -continue ; - -/* Implies write in zoned mode. */ -if (ctx.zoned_bg) { -/* Mark the last eb in the block group. */ -btrfs_schedule_zone_finish_bg (ctx.zoned_bg, eb); - ctx.zoned_bg->meta_write_pointer += eb->len; + ret =write_meta_extent_buffer (&ctx, wbc); +if (ret == -EBUSY ) { + ret =0 ; + }else if (ret) { + done = true; +break ; } -write_one_eb (eb, wbc); } nr_to_write_done = (wbc->nr_to_write <=0 );eb_batch_release (&batch);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1232/1815 btrfs: zoned: dont clobber the extent buffer when zeroing it out
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit db4b9eefc8ee0bcaeee4d5e6a7313905f6a2fe7c ]
On a zoned filesystem a freed-but-still-dirty tree block is written out as zeros (EXTENT_BUFFER_ZONED_ZEROOUT) only to keep the zone write pointer advancing. btree_csum_one_bio() implemented this by memzeroing the extent buffer's own folios before submission.
That destroys the in-memory buffer while it may still be referenced. In particular btrfs_free_tree_block() can run on it afterwards and reads the header to add a delayed reference; once the header has been zeroed it frees bytenr 0 and corrupts the extent tree (the btrfs_header_bytenr(buf) != 0 ASSERT in btrfs_free_tree_block(), or an "unable to find ref" abort). It is flaky and reproduces under fsstress, e.g. generic/461 and generic/013.
Write the zeros to disk from the shared zero page instead and leave the extent buffer content untouched, so any later reference - including the delayed reference from btrfs_free_tree_block() - still sees a valid header. end_bbio_meta_write() now clears writeback on the buffer's own folios, as the bio no longer carries them.
--- fs/btrfs/disk-io.c | 13 +++++++------ fs/btrfs/extent_io.c | 31 ++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 13 deletions(-)
fs/btrfs/disk-io.c +7 -6
@@ -271,14 +271,15 @@ int btree_csum_one_bio(struct btrfs_bio *bbio)return -EIO ;/* -* If an extent_buffer is marked as EXTENT_BUFFER_ZONED_ZEROOUT, don't -* checksum it but zero-out its content. This is done to preserve -* ordering of I/O without unnecessarily writing out data. +* An extent_buffer marked EXTENT_BUFFER_ZONED_ZEROOUT is written out as +* zeros to preserve ordering of I/O without persisting the now +* unnecessary block. The bio is fed from the shared zero page (see +* write_one_eb()), so there is nothing to checksum here. Crucially, the +* buffer's own content is left intact: it may still be referenced, e.g. +* btrfs_free_tree_block() reads its header to add a delayed reference. */ -if (test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags)) { -memzero_extent_buffer (eb,0 , eb->len); +if (test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags))return 0 ; - }if (WARN_ON_ONCE (found_start != eb->start))return -EIO ;
fs/btrfs/extent_io.c +24 -7
@@ -2379,14 +2379,17 @@ static struct extent_buffer *find_extent_buffer_nolock(static void end_bbio_meta_write (struct btrfs_bio *bbio) {struct extent_buffer *eb = bbio->private; -struct folio_iter fi;if (bbio->bio.bi_status !=BLK_STS_OK )set_btree_ioerr (eb); -bio_for_each_folio_all (fi, &bbio->bio) { -btrfs_meta_folio_clear_writeback (fi.folio, eb); - } +/* +* Clear writeback on the buffer's own folios. The bio may carry the +* shared zero page instead (EXTENT_BUFFER_ZONED_ZEROOUT), so iterate +* the extent buffer folios rather than the bio folios. +*/ +for (int i =0 ; i <num_extent_folios (eb); i++) +btrfs_meta_folio_clear_writeback (eb->folios[i], eb);buffer_tree_clear_mark (eb,PAGECACHE_TAG_WRITEBACK );clear_and_wake_up_bit (EXTENT_BUFFER_WRITEBACK , &eb->bflags);
@@ -2427,7 +2430,8 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,struct btrfs_fs_info *fs_info = eb->fs_info;struct btrfs_bio *bbio; -prepare_eb_write (eb); +if (!test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags)) +prepare_eb_write (eb); bbio = btrfs_bio_alloc(INLINE_EXTENT_BUFFER_PAGES, REQ_OP_WRITE | REQ_META | wbc_to_write_flags(wbc),
@@ -2447,8 +2451,21 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,btrfs_meta_folio_set_writeback (folio, eb);if (!folio_test_dirty (folio)) wbc->nr_to_write -=folio_nr_pages (folio); -bio_add_folio_nofail (&bbio->bio, folio, range_len, -offset_in_folio (folio, range_start)); +if (test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags)) { +u32 off =0 ; + +while (off < range_len) { +u32 add =min_t (u32,PAGE_SIZE , range_len - off); + +bio_add_folio_nofail (&bbio->bio, +page_folio (ZERO_PAGE (0 )), + add,0 ); + off += add; + } + }else { +bio_add_folio_nofail (&bbio->bio, folio, range_len, +offset_in_folio (folio, range_start)); + }wbc_account_cgroup_owner (wbc, folio, range_len);folio_unlock (folio); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1233/1815 btrfs: use aligned range for locking in extent_fiemap()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 681e073614515b892cacef0eeec0c761a2c2ab87 ]
The @end parameter for all extent io tree helpers is inclusive, but the call site in extent_fiemap() is passing an exclusive end into btrfs_lock_extent(), which will step into the next block unexpectedly.
Pass the inclusive end into btrfs_lock_extent() and btrfs_unlock_extent().
--- fs/btrfs/fiemap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/fiemap.c +2 -2
@@ -660,7 +660,7 @@ static int extent_fiemap(struct btrfs_inode *inode, range_end =round_up (start + len, sectorsize); prev_extent_end = range_start; -btrfs_lock_extent (&inode->io_tree, range_start, range_end, &cached_state); +btrfs_lock_extent (&inode->io_tree, range_start, range_end -1 , &cached_state); ret =fiemap_find_last_extent_offset (inode, path, &last_extent_end);if (ret <0 )
@@ -840,7 +840,7 @@ static int extent_fiemap(struct btrfs_inode *inode, } out_unlock: -btrfs_unlock_extent (&inode->io_tree, range_start, range_end, &cached_state); +btrfs_unlock_extent (&inode->io_tree, range_start, range_end -1 , &cached_state);if (ret ==BTRFS_FIEMAP_FLUSH_CACHE ) {btrfs_release_path (path);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1234/1815 btrfs: qgroup: fix a wrong length calculation in qgroup_free_reserved_data()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 9102b179512e11644fb0489ae62010a09afa199c ]
In that function, we round down the start position and round up the ending position.
But during the calculation of @len, we use "round_up(start + len, sectorsize)", which is the rounded up end position, not the rounded up length.
Which results a much larger length, and later we are still using "start + len", which is completely incorrect.
Fix it by declaring a local @aligned_start and @aligned_len and use them instead.
--- fs/btrfs/qgroup.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
fs/btrfs/qgroup.c +11 -7
@@ -4339,12 +4339,13 @@ static int qgroup_free_reserved_data(struct btrfs_inode *inode,struct ulist_node *unode;struct ulist_iterator uiter;struct extent_changeset changeset; +const u32 sectorsize = root->fs_info->sectorsize; +const u64 aligned_start =round_down (start, sectorsize); +const u64 aligned_len =round_up (start + len, sectorsize) - aligned_start;u64 freed =0 ;int ret;extent_changeset_init_bytes_only (&changeset); - len =round_up (start + len, root->fs_info->sectorsize); - start =round_down (start, root->fs_info->sectorsize);ULIST_ITER_INIT (&uiter);while ((unode =ulist_next (&reserved->range_changed, &uiter))) {
@@ -4356,12 +4357,15 @@ static int qgroup_free_reserved_data(struct btrfs_inode *inode,extent_changeset_release (&changeset); -/* Only free range in range [start, start + len) */ -if (range_start >= start + len || - range_start + range_len <= start) +/* +* Only free the range within +* [aligned_start, aligned_start + aligned_len). +*/ +if (range_start >= aligned_start + aligned_len || + range_start + range_len <= aligned_start)continue ; - free_start =max (range_start, start); - free_len =min (start + len, range_start + range_len) - + free_start =max (range_start, aligned_start); + free_len =min (aligned_start + aligned_len, range_start + range_len) - free_start;/* * TODO: To also modify reserved->ranges_reserved to reflect
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1235/1815 perf sched: Suppress latency table output when trace samples are missing
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Tomlin <[email protected]>
[ Upstream commit 4a81d59a9d81e6db4e76f84a3d2638e64ff79533 ]
When 'perf sched latency' is executed on a perf.data file that lacks tracepoint samples (i.e., a file recorded without the -R flag or containing only non-tracepoint events), perf_session__has_traces() correctly outputs an error message. However, perf_sched__read_events() subsequently falls through and returns 0 (success).
Consequently, caller functions such as perf_sched__lat() assume event processing succeeded and proceed to render empty latency header tables and total summary statistics.
Fix this behaviour by ensuring perf_sched__read_events() aborts early and returns a suitable error code when perf_session__has_traces() evaluates to false.
Additionally, validate thread__get_runtime() against NULL in map_switch_event() to prevent potential null-pointer dereferences.
--- tools/perf/builtin-sched.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
tools/perf/builtin-sched.c +12 -11
@@ -1833,7 +1833,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_sample *sampl sched_out:if (sched->map.task_name) { tr =thread__get_runtime (sched->curr_out_thread[this_cpu.cpu]); -if (strcmp (tr->shortname,"" ) ==0 ) +if (tr ==NULL ||strcmp (tr->shortname,"" ) ==0 ) goto out;if (proceed ==1 )
@@ -2001,7 +2001,7 @@ static int perf_sched__read_events(struct perf_sched *sched) .mode = PERF_DATA_MODE_READ, .force = sched->force, }; -int rc =-1 ; +int rc =-1 , err; session =perf_session__new (&data, &sched->tool);if (IS_ERR (session)) {
@@ -2018,18 +2018,19 @@ static int perf_sched__read_events(struct perf_sched *sched)if (perf_session__set_tracepoints_handlers (session, handlers)) goto out_delete; -if (perf_session__has_traces (session,"record -R" )) { -int err =perf_session__process_events (session); -if (err) { -pr_err ("Failed to process events, error %d" , err); - goto out_delete; - } +if (!perf_session__has_traces (session,"record -R" )) + goto out_delete; - sched->nr_events =evlist__stats (session->evlist)->nr_events[0 ]; - sched->nr_lost_events =evlist__stats (session->evlist)->total_lost; - sched->nr_lost_chunks =evlist__stats (session->evlist)->nr_events[PERF_RECORD_LOST ]; + err =perf_session__process_events (session); +if (err) { +pr_err ("Failed to process events, error %d" , err); + goto out_delete; } + sched->nr_events =evlist__stats (session->evlist)->nr_events[0 ]; + sched->nr_lost_events =evlist__stats (session->evlist)->total_lost; + sched->nr_lost_chunks =evlist__stats (session->evlist)->nr_events[PERF_RECORD_LOST ]; + rc =0 ; out_delete:perf_session__delete (session);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1236/1815 perf sched: Handle missing trace samples in pipe mode
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Tomlin <[email protected]>
[ Upstream commit 44f8dd1ee1d55db399a443e1715cd8cdd3268362 ]
For pipe mode streams, event attributes are received dynamically during event processing, meaning session->evlist is not populated prior to perf_session__process_events(). To handle pipe input correctly:
- Register the missing .attr, .tracing_data, .build_id, and .feature callbacks in cmd_sched()
- Promote the handlers array to file-scope (latency_handlers[]) and dynamically assign matching tracepoint handlers
(or process_sched_ignore) inside perf_sched__process_tracepoint_sample() when evsel->handler is NULL; replace process_sched_wakeup_ignore() with process_sched_ignore()
- Perform the trace check post-processing when handling pipe data
--- tools/perf/builtin-sched.c | 72 +++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 21 deletions(-)
tools/perf/builtin-sched.c +51 -21
@@ -1581,12 +1581,6 @@ static int process_sched_wakeup_event(const struct perf_tool *tool,return 0 ; } -static int process_sched_wakeup_ignore (const struct perf_tool *tool__maybe_unused , -struct perf_sample *sample__maybe_unused , -struct machine *machine__maybe_unused ) -{ -return 0 ; -}static bool thread__has_color (struct thread *thread) {
@@ -1938,6 +1932,22 @@ typedef int (*tracepoint_handler)(const struct perf_tool *tool,struct perf_sample *sample, struct machine *machine); +static struct evsel_str_handler latency_handlers[] = { + {"sched:sched_switch" , process_sched_switch_event, }, + {"sched:sched_stat_runtime" , process_sched_runtime_event, }, + {"sched:sched_wakeup" , process_sched_wakeup_event, }, + {"sched:sched_waking" , process_sched_wakeup_event, }, + {"sched:sched_wakeup_new" , process_sched_wakeup_event, }, + {"sched:sched_migrate_task" , process_sched_migrate_task_event, }, +}; + +static int process_sched_ignore (const struct perf_tool *tool__maybe_unused , +struct perf_sample *sample__maybe_unused , +struct machine *machine__maybe_unused ) +{ +return 0 ; +} + static int perf_sched__process_tracepoint_sample(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample,
@@ -1946,7 +1956,23 @@ static int perf_sched__process_tracepoint_sample(const struct perf_tool *tool __struct evsel *evsel = sample->evsel;int err =0 ; -if (evsel->handler !=NULL ) { +if (evsel->handler ==NULL ) { + evsel->handler = process_sched_ignore; +for (size_t i =0 ; i <ARRAY_SIZE (latency_handlers); i++) { +if (!evsel__name_is (evsel, latency_handlers[i].name)) +continue ; + +if (!strcmp (latency_handlers[i].name,"sched:sched_wakeup" ) && + sample->evsel->evlist && +evlist__find_tracepoint_by_name (sample->evsel->evlist,"sched:sched_waking" )) +break ; + + evsel->handler = latency_handlers[i].handler; +break ; + } + } + +if (evsel->handler != process_sched_ignore) {tracepoint_handler f = evsel->handler; err =f (tool, sample, machine); }
@@ -1987,14 +2013,6 @@ static int perf_sched__process_comm(const struct perf_tool *tool __maybe_unused,static int perf_sched__read_events (struct perf_sched *sched) { -struct evsel_str_handler handlers[] = { - {"sched:sched_switch" , process_sched_switch_event, }, - {"sched:sched_stat_runtime" , process_sched_runtime_event, }, - {"sched:sched_wakeup" , process_sched_wakeup_event, }, - {"sched:sched_waking" , process_sched_wakeup_event, }, - {"sched:sched_wakeup_new" , process_sched_wakeup_event, }, - {"sched:sched_migrate_task" , process_sched_migrate_task_event, }, - };struct perf_session *session;struct perf_data data = { .path = input_name,
@@ -2011,14 +2029,17 @@ static int perf_sched__read_events(struct perf_sched *sched)symbol__init (perf_session__env (session)); -/* prefer sched_waking if it is captured */ -if (evlist__find_tracepoint_by_name (session->evlist,"sched:sched_waking" )) - handlers[2 ].handler = process_sched_wakeup_ignore; +if (!perf_data__is_pipe (session->data)) { +/* prefer sched_waking if it is captured */ +if (evlist__find_tracepoint_by_name (session->evlist,"sched:sched_waking" )) + latency_handlers[2 ].handler = process_sched_ignore; -if (perf_session__set_tracepoints_handlers (session, handlers)) - goto out_delete; +if (perf_session__set_tracepoints_handlers (session, latency_handlers)) + goto out_delete; + } -if (!perf_session__has_traces (session,"record -R" )) +if (!perf_data__is_pipe (session->data) && + !perf_session__has_traces (session,"record -R" )) goto out_delete; err =perf_session__process_events (session);
@@ -2027,6 +2048,11 @@ static int perf_sched__read_events(struct perf_sched *sched) goto out_delete; } +if (perf_data__is_pipe (session->data) && + !perf_session__has_traces (session,"record -R" )) { + goto out_delete; + } + sched->nr_events =evlist__stats (session->evlist)->nr_events[0 ]; sched->nr_lost_events =evlist__stats (session->evlist)->total_lost; sched->nr_lost_chunks =evlist__stats (session->evlist)->nr_events[PERF_RECORD_LOST ];
@@ -5172,6 +5198,10 @@ int cmd_sched(int argc, const char **argv) sched.tool.namespaces = perf_event__process_namespaces; sched.tool.lost = perf_event__process_lost; sched.tool.fork = perf_sched__process_fork_event; + sched.tool.attr = perf_event__process_attr; + sched.tool.tracing_data = perf_event__process_tracing_data; + sched.tool.build_id = perf_event__process_build_id; + sched.tool.feature = perf_event__process_feature; argc =parse_options_subcommand (argc, argv, sched_options, sched_subcommands, sched_usage,PARSE_OPT_STOP_AT_NON_OPTION );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1237/1815 pinctrl: airoha: fix mdio bitfield names
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit a8454680a6ce75fbbd8086bcb654eacf7897bc0f ]
Fix misprint in mdio bitfield name of GPIO_2ND_I2C_MODE register.
While at it also fix an7583 mdio. It should use an7583 specific mdio bitfield.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +6 -5
@@ -49,7 +49,7 @@/* MUX */ #define REG_GPIO_2ND_I2C_MODE 0x0214 -#define GPIO_MDC_IO_MASTER_MODE_MODE BIT(14) +#define GPIO_MDC_IO_MASTER_MODE_MASK BIT(14)#define GPIO_I2C_MASTER_MODE_MODE BIT(13)#define GPIO_I2S_MODE_MASK BIT(12)#define GPIO_I2C_SLAVE_MODE_MODE BIT(11)
@@ -66,6 +66,7 @@#define GPIO_2ND_I2C_MODE_MASK BIT(0)#define REG_GPIO_SPI_CS1_MODE 0x0218 +#define AN7583_GPIO_MDC_IO_MASTER_MODE_MASK BIT(22)#define GPIO_PCM_SPI_CS4_MODE_MASK BIT(21)#define GPIO_PCM_SPI_CS3_MODE_MASK BIT(20)#define GPIO_PCM_SPI_CS2_MODE_P156_MASK BIT(19)
@@ -1026,8 +1027,8 @@ static const struct airoha_pinctrl_func_group mdio_func_group[] = { .regmap[0] = {AIROHA_FUNC_MUX ,REG_GPIO_2ND_I2C_MODE , -GPIO_MDC_IO_MASTER_MODE_MODE , -GPIO_MDC_IO_MASTER_MODE_MODE +GPIO_MDC_IO_MASTER_MODE_MASK , +GPIO_MDC_IO_MASTER_MODE_MASK }, .regmap[1] = { AIROHA_FUNC_MUX,
@@ -1051,8 +1052,8 @@ static const struct airoha_pinctrl_func_group an7583_mdio_func_group[] = { .regmap[1] = {AIROHA_FUNC_MUX ,REG_GPIO_SPI_CS1_MODE , -GPIO_MDC_IO_MASTER_MODE_MODE , -GPIO_MDC_IO_MASTER_MODE_MODE +AN7583_GPIO_MDC_IO_MASTER_MODE_MASK , +AN7583_GPIO_MDC_IO_MASTER_MODE_MASK }, .regmap_size = 2, },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1238/1815 pinctrl: airoha: an7581: fix pinconf of i2c_scl/i2c_sda pins
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 65ce9d5d781f872596194771d62ad6e1260fcf4f ]
Pinconfs of i2c_sda/i2c_scl pins are swapped, this needs to be fixed.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +8 -8
@@ -1844,8 +1844,8 @@ static const struct airoha_pinctrl_func an7583_pinctrl_funcs[] = {static const struct airoha_pinctrl_conf en7581_pinctrl_pullup_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_PU ,UART1_TXD_PU_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_PU ,UART1_RXD_PU_MASK ), -PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PU ,I2C_SDA_PU_MASK ), -PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_PU ,I2C_SCL_PU_MASK ), +PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PU ,I2C_SCL_PU_MASK ), +PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_PU ,I2C_SDA_PU_MASK ),PINCTRL_CONF_DESC (4 ,REG_I2C_SDA_PU ,SPI_CS0_PU_MASK ),PINCTRL_CONF_DESC (5 ,REG_I2C_SDA_PU ,SPI_CLK_PU_MASK ),PINCTRL_CONF_DESC (6 ,REG_I2C_SDA_PU ,SPI_MOSI_PU_MASK ),
@@ -1961,8 +1961,8 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_pullup_conf[] = {static const struct airoha_pinctrl_conf en7581_pinctrl_pulldown_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_PD ,UART1_TXD_PD_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_PD ,UART1_RXD_PD_MASK ), -PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PD ,I2C_SDA_PD_MASK ), -PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_PD ,I2C_SCL_PD_MASK ), +PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PD ,I2C_SCL_PD_MASK ), +PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_PD ,I2C_SDA_PD_MASK ),PINCTRL_CONF_DESC (4 ,REG_I2C_SDA_PD ,SPI_CS0_PD_MASK ),PINCTRL_CONF_DESC (5 ,REG_I2C_SDA_PD ,SPI_CLK_PD_MASK ),PINCTRL_CONF_DESC (6 ,REG_I2C_SDA_PD ,SPI_MOSI_PD_MASK ),
@@ -2078,8 +2078,8 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_pulldown_conf[] = {static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e2_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_E2 ,UART1_TXD_E2_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_E2 ,UART1_RXD_E2_MASK ), -PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E2 ,I2C_SDA_E2_MASK ), -PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_E2 ,I2C_SCL_E2_MASK ), +PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E2 ,I2C_SCL_E2_MASK ), +PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_E2 ,I2C_SDA_E2_MASK ),PINCTRL_CONF_DESC (4 ,REG_I2C_SDA_E2 ,SPI_CS0_E2_MASK ),PINCTRL_CONF_DESC (5 ,REG_I2C_SDA_E2 ,SPI_CLK_E2_MASK ),PINCTRL_CONF_DESC (6 ,REG_I2C_SDA_E2 ,SPI_MOSI_E2_MASK ),
@@ -2195,8 +2195,8 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e2_conf[] = {static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e4_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_E4 ,UART1_TXD_E4_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_E4 ,UART1_RXD_E4_MASK ), -PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E4 ,I2C_SDA_E4_MASK ), -PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_E4 ,I2C_SCL_E4_MASK ), +PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E4 ,I2C_SCL_E4_MASK ), +PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_E4 ,I2C_SDA_E4_MASK ),PINCTRL_CONF_DESC (4 ,REG_I2C_SDA_E4 ,SPI_CS0_E4_MASK ),PINCTRL_CONF_DESC (5 ,REG_I2C_SDA_E4 ,SPI_CLK_E4_MASK ),PINCTRL_CONF_DESC (6 ,REG_I2C_SDA_E4 ,SPI_MOSI_E4_MASK ),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1239/1815 pinctrl: airoha: an7583: fix I2C0_SDA_PD register bit order
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit d560e28bdca824781898023496658404df01be9f ]
I2C1_SCL_PD and RG_I2C1_SDA_PD bits are swapped, fix it.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +2 -2
@@ -185,8 +185,8 @@#define I2C_SDA_PU_MASK BIT(0)#define REG_I2C_SDA_PD 0x0048 -#define AN7583_I2C1_SDA_PD_MASK BIT(16) -#define AN7583_I2C1_SCL_PD_MASK BIT(15) +#define AN7583_I2C1_SCL_PD_MASK BIT(16) +#define AN7583_I2C1_SDA_PD_MASK BIT(15)#define SPI_MISO_PD_MASK BIT(14)#define SPI_MOSI_PD_MASK BIT(13)#define SPI_CLK_PD_MASK BIT(12)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1240/1815 pinctrl: airoha: an7581: fix mux/conf of pcie_reset pins
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 739bc85aed14b739dca5b7aff4241b778af80220 ]
In the an7581 case
* gpio47 and pcie_reset0 shares pin 60,
* gpio48 and pcie_reset1 shares pin 61,
* gpio49 and pcie_reset2 shares pin 62.
but current driver treat them as pins 61--63. This is wrong.
Also current an7581 pinmux implementation have following issues:
* current pcie_reset pin function actually sets corresponding pins as gpios.
* there is no proper way to set pcie_reset pins as gpios.
* there is no way to set pcie_reset pins as pwm.
This patch fixes above issues.
WARNING:
There is a contradiction in the Airoha documentation. AN7581 programming guide claims:
- gpio44 and pcie_reset0 shares the same pin
- gpio45 and pcie_reset1 shares the same pin
- gpio46 and pcie_reset2 shares the same pin
While AN7581 datasheet claims:
- gpio47 and pcie_reset0 shares the same pin
- gpio48 and pcie_reset1 shares the same pin
- gpio49 and pcie_reset2 shares the same pin
The datasheet should be considered as a more reliable source. Thanks to Benjamin Larsson for clarification.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 122 +++++++++++++++++++----- 1 file changed, 97 insertions(+), 25 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +97 -25
@@ -470,9 +470,9 @@ static struct pinctrl_pin_desc en7581_pinctrl_pins[] = {PINCTRL_PIN (57 ,"gpio44" ),PINCTRL_PIN (58 ,"gpio45" ),PINCTRL_PIN (59 ,"gpio46" ), -PINCTRL_PIN (61 ,"pcie_reset0" ), -PINCTRL_PIN (62 ,"pcie_reset1" ), - PINCTRL_PIN(63, "pcie_reset2"), +PINCTRL_PIN (60 ,"pcie_reset0" ), +PINCTRL_PIN (61 ,"pcie_reset1" ), + PINCTRL_PIN(62, "pcie_reset2"), };static const int en7581_pon_pins[] = {49 ,50 ,51 ,52 ,53 ,54 };
@@ -555,9 +555,12 @@ static const int en7581_gpio43_pins[] = { 56 };static const int en7581_gpio44_pins[] = {57 };static const int en7581_gpio45_pins[] = {58 };static const int en7581_gpio46_pins[] = {59 }; -static const int en7581_pcie_reset0_pins[] = {61 }; -static const int en7581_pcie_reset1_pins[] = {62 }; -static const int en7581_pcie_reset2_pins[] = {63 }; +static const int en7581_gpio47_pins[] = {60 }; +static const int en7581_gpio48_pins[] = {61 }; +static const int en7581_gpio49_pins[] = {62 }; +static const int en7581_pcie_reset0_pins[] = {60 }; +static const int en7581_pcie_reset1_pins[] = {61 }; +static const int en7581_pcie_reset2_pins[] = {62 };static const struct pingroup en7581_pinctrl_groups[] = {PINCTRL_PIN_GROUP ("pon" , en7581_pon),
@@ -640,6 +643,9 @@ static const struct pingroup en7581_pinctrl_groups[] = {PINCTRL_PIN_GROUP ("gpio44" , en7581_gpio44),PINCTRL_PIN_GROUP ("gpio45" , en7581_gpio45),PINCTRL_PIN_GROUP ("gpio46" , en7581_gpio46), +PINCTRL_PIN_GROUP ("gpio47" , en7581_gpio47), +PINCTRL_PIN_GROUP ("gpio48" , en7581_gpio48), +PINCTRL_PIN_GROUP ("gpio49" , en7581_gpio49),PINCTRL_PIN_GROUP ("pcie_reset0" , en7581_pcie_reset0),PINCTRL_PIN_GROUP ("pcie_reset1" , en7581_pcie_reset1), PINCTRL_PIN_GROUP("pcie_reset2", en7581_pcie_reset2),
@@ -883,6 +889,7 @@ static const char *const an7583_pcm_spi_groups[] = { "pcm_spi",static const char *const i2s_groups[] = {"i2s" };static const char *const emmc_groups[] = {"emmc" };static const char *const pnand_groups[] = {"pnand" }; +static const char *const gpio_groups[] = {"gpio47" ,"gpio48" ,"gpio49" };static const char *const pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" ,"pcie_reset2" };static const char *const an7583_pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" };
@@ -907,7 +914,8 @@ static const char *const pwm_groups[] = { "gpio0", "gpio1","gpio40" ,"gpio41" ,"gpio42" ,"gpio43" ,"gpio44" ,"gpio45" , - "gpio46" }; +"gpio46" ,"gpio47" , + "gpio48", "gpio49" };static const char *const an7583_pwm_groups[] = {"gpio0" ,"gpio1" ,"gpio2" ,"gpio3" , "gpio4", "gpio5",
@@ -1406,6 +1414,45 @@ static const struct airoha_pinctrl_func_group pnand_func_group[] = { }, }; +#define AIROHA_PINCTRL_GPIO (gpio, mux_val) \ + { \ + .name = (gpio), \ + .regmap[0] = { \ + AIROHA_FUNC_MUX, \ + REG_GPIO_PON_MODE, \ + (mux_val), \ + (mux_val) \ + }, \ + .regmap_size = 1, \ + } + +#define AIROHA_PINCTRL_GPIO_EXT (gpio, mux_val, smux_val) \ + { \ + .name = (gpio), \ + .regmap[0] = { \ + AIROHA_FUNC_PWM_EXT_MUX, \ + REG_GPIO_FLASH_MODE_CFG_EXT, \ + (mux_val), \ + 0 \ + }, \ + .regmap[1] = { \ + AIROHA_FUNC_MUX, \ + REG_GPIO_PON_MODE, \ + (smux_val), \ + (smux_val) \ + }, \ + .regmap_size = 2, \ + } + +static const struct airoha_pinctrl_func_group gpio_func_group[] = { +AIROHA_PINCTRL_GPIO_EXT ("gpio47" ,GPIO47_FLASH_MODE_CFG , +GPIO_PCIE_RESET0_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio48" ,GPIO48_FLASH_MODE_CFG , +GPIO_PCIE_RESET1_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio49" ,GPIO49_FLASH_MODE_CFG , +GPIO_PCIE_RESET2_MASK ), +}; +static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = { { .name ="pcie_reset0" ,
@@ -1413,7 +1460,7 @@ static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = {AIROHA_FUNC_MUX ,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET0_MASK , -GPIO_PCIE_RESET0_MASK +0 }, .regmap_size = 1, }, {
@@ -1422,7 +1469,7 @@ static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = {AIROHA_FUNC_MUX ,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET1_MASK , -GPIO_PCIE_RESET1_MASK +0 }, .regmap_size = 1, }, {
@@ -1431,7 +1478,7 @@ static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = { AIROHA_FUNC_MUX,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET2_MASK , -GPIO_PCIE_RESET2_MASK + 0 }, .regmap_size = 1, },
@@ -1484,6 +1531,24 @@ static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = { .regmap_size = 1, \ } \ +#define AIROHA_PINCTRL_PWM_EXT_SEC (gpio, mux_val, smux_val) \ + { \ + .name = (gpio), \ + .regmap[0] = { \ + AIROHA_FUNC_PWM_EXT_MUX, \ + REG_GPIO_FLASH_MODE_CFG_EXT, \ + (mux_val), \ + (mux_val) \ + }, \ + .regmap[1] = { \ + AIROHA_FUNC_MUX, \ + REG_GPIO_PON_MODE, \ + (smux_val), \ + (smux_val) \ + }, \ + .regmap_size = 2, \ + } +static const struct airoha_pinctrl_func_group pwm_func_group[] = {AIROHA_PINCTRL_PWM ("gpio0" ,GPIO0_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM ("gpio1" ,GPIO1_FLASH_MODE_CFG ),
@@ -1528,6 +1593,12 @@ static const struct airoha_pinctrl_func_group pwm_func_group[] = {AIROHA_PINCTRL_PWM_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio46" ,GPIO46_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio47" ,GPIO47_FLASH_MODE_CFG , +GPIO_PCIE_RESET0_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio48" ,GPIO48_FLASH_MODE_CFG , +GPIO_PCIE_RESET1_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio49" ,GPIO49_FLASH_MODE_CFG , + GPIO_PCIE_RESET2_MASK), }; static const struct airoha_pinctrl_func_group an7583_pwm_func_group[] = {
@@ -1804,6 +1875,7 @@ static const struct airoha_pinctrl_func en7581_pinctrl_funcs[] = {PINCTRL_FUNC_DESC ("i2s" , i2s),PINCTRL_FUNC_DESC ("emmc" , emmc),PINCTRL_FUNC_DESC ("pnand" , pnand), +PINCTRL_FUNC_DESC ("gpio" , gpio),PINCTRL_FUNC_DESC ("pcie_reset" , pcie_reset),PINCTRL_FUNC_DESC ("pwm" , pwm), PINCTRL_FUNC_DESC("phy1_led0", phy1_led0),
@@ -1897,9 +1969,9 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_pullup_conf[] = {PINCTRL_CONF_DESC (57 ,REG_GPIO_H_PU ,BIT (12 )),PINCTRL_CONF_DESC (58 ,REG_GPIO_H_PU ,BIT (13 )),PINCTRL_CONF_DESC (59 ,REG_GPIO_H_PU ,BIT (14 )), -PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_PU ,PCIE0_RESET_PU_MASK ), -PINCTRL_CONF_DESC (62 ,REG_I2C_SDA_PU ,PCIE1_RESET_PU_MASK ), - PINCTRL_CONF_DESC(63, REG_I2C_SDA_PU, PCIE2_RESET_PU_MASK), +PINCTRL_CONF_DESC (60 ,REG_I2C_SDA_PU ,PCIE0_RESET_PU_MASK ), +PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_PU ,PCIE1_RESET_PU_MASK ), + PINCTRL_CONF_DESC(62, REG_I2C_SDA_PU, PCIE2_RESET_PU_MASK), }; static const struct airoha_pinctrl_conf an7583_pinctrl_pullup_conf[] = {
@@ -2014,9 +2086,9 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_pulldown_conf[] = {PINCTRL_CONF_DESC (57 ,REG_GPIO_H_PD ,BIT (12 )),PINCTRL_CONF_DESC (58 ,REG_GPIO_H_PD ,BIT (13 )),PINCTRL_CONF_DESC (59 ,REG_GPIO_H_PD ,BIT (14 )), -PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_PD ,PCIE0_RESET_PD_MASK ), -PINCTRL_CONF_DESC (62 ,REG_I2C_SDA_PD ,PCIE1_RESET_PD_MASK ), - PINCTRL_CONF_DESC(63, REG_I2C_SDA_PD, PCIE2_RESET_PD_MASK), +PINCTRL_CONF_DESC (60 ,REG_I2C_SDA_PD ,PCIE0_RESET_PD_MASK ), +PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_PD ,PCIE1_RESET_PD_MASK ), + PINCTRL_CONF_DESC(62, REG_I2C_SDA_PD, PCIE2_RESET_PD_MASK), }; static const struct airoha_pinctrl_conf an7583_pinctrl_pulldown_conf[] = {
@@ -2131,9 +2203,9 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e2_conf[] = {PINCTRL_CONF_DESC (57 ,REG_GPIO_H_E2 ,BIT (12 )),PINCTRL_CONF_DESC (58 ,REG_GPIO_H_E2 ,BIT (13 )),PINCTRL_CONF_DESC (59 ,REG_GPIO_H_E2 ,BIT (14 )), -PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_E2 ,PCIE0_RESET_E2_MASK ), -PINCTRL_CONF_DESC (62 ,REG_I2C_SDA_E2 ,PCIE1_RESET_E2_MASK ), - PINCTRL_CONF_DESC(63, REG_I2C_SDA_E2, PCIE2_RESET_E2_MASK), +PINCTRL_CONF_DESC (60 ,REG_I2C_SDA_E2 ,PCIE0_RESET_E2_MASK ), +PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_E2 ,PCIE1_RESET_E2_MASK ), + PINCTRL_CONF_DESC(62, REG_I2C_SDA_E2, PCIE2_RESET_E2_MASK), }; static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e2_conf[] = {
@@ -2248,9 +2320,9 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e4_conf[] = {PINCTRL_CONF_DESC (57 ,REG_GPIO_H_E4 ,BIT (12 )),PINCTRL_CONF_DESC (58 ,REG_GPIO_H_E4 ,BIT (13 )),PINCTRL_CONF_DESC (59 ,REG_GPIO_H_E4 ,BIT (14 )), -PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_E4 ,PCIE0_RESET_E4_MASK ), -PINCTRL_CONF_DESC (62 ,REG_I2C_SDA_E4 ,PCIE1_RESET_E4_MASK ), - PINCTRL_CONF_DESC(63, REG_I2C_SDA_E4, PCIE2_RESET_E4_MASK), +PINCTRL_CONF_DESC (60 ,REG_I2C_SDA_E4 ,PCIE0_RESET_E4_MASK ), +PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_E4 ,PCIE1_RESET_E4_MASK ), + PINCTRL_CONF_DESC(62, REG_I2C_SDA_E4, PCIE2_RESET_E4_MASK), }; static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e4_conf[] = {
@@ -2310,9 +2382,9 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e4_conf[] = { };static const struct airoha_pinctrl_conf en7581_pinctrl_pcie_rst_od_conf[] = { -PINCTRL_CONF_DESC (61 ,REG_PCIE_RESET_OD ,PCIE0_RESET_OD_MASK ), -PINCTRL_CONF_DESC (62 ,REG_PCIE_RESET_OD ,PCIE1_RESET_OD_MASK ), -PINCTRL_CONF_DESC (63 ,REG_PCIE_RESET_OD ,PCIE2_RESET_OD_MASK ), +PINCTRL_CONF_DESC (60 ,REG_PCIE_RESET_OD ,PCIE0_RESET_OD_MASK ), +PINCTRL_CONF_DESC (61 ,REG_PCIE_RESET_OD ,PCIE1_RESET_OD_MASK ), +PINCTRL_CONF_DESC (62 ,REG_PCIE_RESET_OD ,PCIE2_RESET_OD_MASK ), };static const struct airoha_pinctrl_conf an7583_pinctrl_pcie_rst_od_conf[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1241/1815 pinctrl: airoha: an7583: fix muxing of non-gpio default pins
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit aaa41d8010c04635e035a9d334885b07edc8af21 ]
Current an7583 pinmux implementation have following issues:
* pins 51 and 52 can't be set as pcie_reset, current pcie_reset code will sets pins to gpio mode instead.
* there is no proper way to set pins 41--54 to gpio mode.
* pins 41--53 can't be actually set as pwm pins. These pins must be muxed to gpio mode as well.
This patch fixes above issues.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 99 +++++++++++++++++++++---- 1 file changed, 86 insertions(+), 13 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +86 -13
@@ -85,6 +85,18 @@#define GPIO_SPI_CS1_MODE_MASK BIT(0)#define REG_GPIO_PON_MODE 0x021c +#define AN7583_MDIO_0_GPIO_MODE_MASK BIT(26) +#define AN7583_MDC_0_GPIO_MODE_MASK BIT(25) +#define AN7583_UART_RXD_GPIO_MODE_MASK BIT(24) +#define AN7583_UART_TXD_GPIO_MODE_MASK BIT(23) +#define AN7583_SPI_MISO_GPIO_MODE_MASK BIT(22) +#define AN7583_SPI_MOSI_GPIO_MODE_MASK BIT(21) +#define AN7583_SPI_CS_GPIO_MODE_MASK BIT(20) +#define AN7583_SPI_CLK_GPIO_MODE_MASK BIT(19) +#define AN7583_I2C1_SDA_GPIO_MODE_MASK BIT(18) +#define AN7583_I2C1_SCL_GPIO_MODE_MASK BIT(17) +#define AN7583_I2C0_SDA_GPIO_MODE_MASK BIT(16) +#define AN7583_I2C0_SCL_GPIO_MODE_MASK BIT(15)#define GPIO_PARALLEL_NAND_MODE_MASK BIT(14)#define GPIO_SGMII_MDIO_MODE_MASK BIT(13)#define GPIO_PCIE_RESET2_MASK BIT(12)
@@ -783,6 +795,10 @@ static const int an7583_gpio45_pins[] = { 47 };static const int an7583_gpio46_pins[] = {48 };static const int an7583_gpio47_pins[] = {49 };static const int an7583_gpio48_pins[] = {50 }; +static const int an7583_gpio49_pins[] = {51 }; +static const int an7583_gpio50_pins[] = {52 }; +static const int an7583_gpio51_pins[] = {53 }; +static const int an7583_gpio52_pins[] = {54 };static const int an7583_pcie_reset0_pins[] = {51 };static const int an7583_pcie_reset1_pins[] = {52 };
@@ -863,6 +879,10 @@ static const struct pingroup an7583_pinctrl_groups[] = {PINCTRL_PIN_GROUP ("gpio46" , an7583_gpio46),PINCTRL_PIN_GROUP ("gpio47" , an7583_gpio47),PINCTRL_PIN_GROUP ("gpio48" , an7583_gpio48), +PINCTRL_PIN_GROUP ("gpio49" , an7583_gpio49), +PINCTRL_PIN_GROUP ("gpio50" , an7583_gpio50), +PINCTRL_PIN_GROUP ("gpio51" , an7583_gpio51), +PINCTRL_PIN_GROUP ("gpio52" , an7583_gpio52),PINCTRL_PIN_GROUP ("pcie_reset0" , an7583_pcie_reset0), PINCTRL_PIN_GROUP("pcie_reset1", an7583_pcie_reset1), };
@@ -892,6 +912,11 @@ static const char *const pnand_groups[] = { "pnand" };static const char *const gpio_groups[] = {"gpio47" ,"gpio48" ,"gpio49" };static const char *const pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" ,"pcie_reset2" }; +static const char *const an7583_gpio_groups[] = {"gpio39" ,"gpio40" ,"gpio41" , +"gpio42" ,"gpio43" ,"gpio44" , +"gpio45" ,"gpio46" ,"gpio47" , +"gpio48" ,"gpio49" ,"gpio50" , +"gpio51" ,"gpio52" };static const char *const an7583_pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" };static const char *const pwm_groups[] = {"gpio0" ,"gpio1" ,"gpio2" ,"gpio3" ,
@@ -938,7 +963,8 @@ static const char *const an7583_pwm_groups[] = { "gpio0", "gpio1","gpio42" ,"gpio43" ,"gpio44" ,"gpio45" ,"gpio46" ,"gpio47" , - "gpio48" }; +"gpio48" ,"gpio49" , + "gpio50", "gpio51" };static const char *const phy1_led0_groups[] = {"gpio33" ,"gpio34" ,"gpio35" ,"gpio42" }; static const char *const phy2_led0_groups[] = { "gpio33", "gpio34",
@@ -1484,6 +1510,36 @@ static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = { }, }; +static const struct airoha_pinctrl_func_group an7583_gpio_func_group[] = { +AIROHA_PINCTRL_GPIO_EXT ("gpio39" ,GPIO39_FLASH_MODE_CFG , +AN7583_I2C0_SCL_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio40" ,GPIO40_FLASH_MODE_CFG , +AN7583_I2C0_SDA_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio41" ,GPIO41_FLASH_MODE_CFG , +AN7583_I2C1_SCL_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio42" ,GPIO42_FLASH_MODE_CFG , +AN7583_I2C1_SDA_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio43" ,GPIO43_FLASH_MODE_CFG , +AN7583_SPI_CLK_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG , +AN7583_SPI_CS_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG , +AN7583_SPI_MOSI_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio46" ,GPIO46_FLASH_MODE_CFG , +AN7583_SPI_MISO_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio47" ,GPIO47_FLASH_MODE_CFG , +AN7583_UART_TXD_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio48" ,GPIO48_FLASH_MODE_CFG , +AN7583_UART_RXD_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio49" ,GPIO49_FLASH_MODE_CFG , +GPIO_PCIE_RESET0_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio50" ,GPIO50_FLASH_MODE_CFG , +GPIO_PCIE_RESET1_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio51" ,GPIO51_FLASH_MODE_CFG , +AN7583_MDC_0_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO ("gpio52" ,AN7583_MDIO_0_GPIO_MODE_MASK ), +}; +static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = { { .name ="pcie_reset0" ,
@@ -1491,7 +1547,7 @@ static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = {AIROHA_FUNC_MUX ,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET0_MASK , -GPIO_PCIE_RESET0_MASK +0 }, .regmap_size = 1, }, {
@@ -1500,7 +1556,7 @@ static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = { AIROHA_FUNC_MUX,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET1_MASK , -GPIO_PCIE_RESET1_MASK + 0 }, .regmap_size = 1, },
@@ -1637,16 +1693,32 @@ static const struct airoha_pinctrl_func_group an7583_pwm_func_group[] = {AIROHA_PINCTRL_PWM_EXT ("gpio36" ,GPIO36_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio37" ,GPIO37_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio38" ,GPIO38_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio39" ,GPIO39_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio40" ,GPIO40_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio41" ,GPIO41_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio42" ,GPIO42_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio43" ,GPIO43_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio46" ,GPIO46_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio47" ,GPIO47_FLASH_MODE_CFG ), - AIROHA_PINCTRL_PWM_EXT("gpio48", GPIO48_FLASH_MODE_CFG), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio39" ,GPIO39_FLASH_MODE_CFG , +AN7583_I2C0_SCL_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio40" ,GPIO40_FLASH_MODE_CFG , +AN7583_I2C0_SDA_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio41" ,GPIO41_FLASH_MODE_CFG , +AN7583_I2C1_SCL_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio42" ,GPIO42_FLASH_MODE_CFG , +AN7583_I2C1_SDA_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio43" ,GPIO43_FLASH_MODE_CFG , +AN7583_SPI_CLK_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio44" ,GPIO44_FLASH_MODE_CFG , +AN7583_SPI_CS_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio45" ,GPIO45_FLASH_MODE_CFG , +AN7583_SPI_MOSI_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio46" ,GPIO46_FLASH_MODE_CFG , +AN7583_SPI_MISO_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio47" ,GPIO47_FLASH_MODE_CFG , +AN7583_UART_TXD_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio48" ,GPIO48_FLASH_MODE_CFG , +AN7583_UART_RXD_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio49" ,GPIO49_FLASH_MODE_CFG , +GPIO_PCIE_RESET0_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio50" ,GPIO50_FLASH_MODE_CFG , +GPIO_PCIE_RESET1_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio51" ,GPIO51_FLASH_MODE_CFG , + AN7583_MDC_0_GPIO_MODE_MASK), };#define AIROHA_PINCTRL_PHY_LED0 (gpio, mux_val, map_mask, map_val) \
@@ -1901,6 +1973,7 @@ static const struct airoha_pinctrl_func an7583_pinctrl_funcs[] = {PINCTRL_FUNC_DESC ("pcm_spi" , an7583_pcm_spi),PINCTRL_FUNC_DESC ("emmc" , emmc),PINCTRL_FUNC_DESC ("pnand" , pnand), +PINCTRL_FUNC_DESC ("gpio" , an7583_gpio),PINCTRL_FUNC_DESC ("pcie_reset" , an7583_pcie_reset),PINCTRL_FUNC_DESC ("pwm" , an7583_pwm), PINCTRL_FUNC_DESC("phy1_led0", an7583_phy1_led0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1242/1815 pinctrl: airoha: an7583: fix spi group pins
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit ccc41d25590645096bdbf420b43e7c22627b3f59 ]
pcm pins were used insted of spi pins. This patch fixes an issue.
Thanks to Daniel Schwierzeck for noticing it.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +1 -1
@@ -738,7 +738,7 @@ static const int an7583_jtag_udi_pins[] = { 23, 24, 22, 25, 26 };static const int an7583_jtag_dfd_pins[] = {23 ,24 ,22 ,25 ,26 };static const int an7583_pcm1_pins[] = {10 ,11 ,12 ,13 ,14 };static const int an7583_pcm2_pins[] = {28 ,29 ,30 ,31 ,24 }; -static const int an7583_spi_pins[] = {28 ,29 ,30 ,31 }; +static const int an7583_spi_pins[] = {45 ,46 ,47 ,48 };static const int an7583_spi_quad_pins[] = {25 ,26 };static const int an7583_spi_cs1_pins[] = {27 };static const int an7583_pcm_spi_pins[] = {28 ,29 ,30 ,31 ,10 ,11 ,12 ,13 };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1243/1815 pinctrl: airoha: add missed get_direction() function for gpio_chip
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit d6392502a9e6b11c3a93eb4c987672a8c638d749 ]
This patch adds missed get_direction() function for gpio_chip. Also it reimplements pinconf's get_direction() function using newly defined function.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 50 +++++++++++++++++-------- 1 file changed, 34 insertions(+), 16 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +34 -16
@@ -2504,6 +2504,22 @@ static int airoha_gpio_get(struct gpio_chip *chip, unsigned int gpio)return err ? err : !!(val &BIT (pin)); } +static int airoha_gpio_get_direction (struct gpio_chip *chip,unsigned int gpio) +{ +struct airoha_pinctrl *pinctrl =gpiochip_get_data (chip); +u32 val, mask; +u8 index; +int err; + + index = gpio /AIROHA_REG_GPIOCTRL_NUM_PIN ; + err =regmap_read (pinctrl->regmap, pinctrl->gpiochip.dir[index], &val); +if (err) +return err; + + mask =BIT (2 * (gpio %AIROHA_REG_GPIOCTRL_NUM_PIN )); +return val & mask ?GPIO_LINE_DIRECTION_OUT :GPIO_LINE_DIRECTION_IN ; +} +static int airoha_gpio_direction_output (struct gpio_chip *chip,unsigned int gpio,int value) {
@@ -2637,19 +2653,13 @@ static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl,struct device *dev = &pdev->dev;int irq, err; - chip->data = gpio_data_regs; - chip->dir = gpio_dir_regs; - chip->out = gpio_out_regs; - chip->status = irq_status_regs; - chip->level = irq_level_regs; - chip->edge = irq_edge_regs; - gc->parent = dev; gc->label =dev_name (dev); gc->request = gpiochip_generic_request; gc->free = gpiochip_generic_free; gc->direction_input = pinctrl_gpio_direction_input; gc->direction_output = airoha_gpio_direction_output; + gc->get_direction = airoha_gpio_get_direction; gc->set = airoha_gpio_set; gc->get = airoha_gpio_get; gc->base =-1 ;
@@ -2859,21 +2869,18 @@ static int airoha_pinctrl_set_conf(struct airoha_pinctrl *pinctrl,static int airoha_pinconf_get_direction (struct pinctrl_dev *pctrl_dev,u32 p) {struct airoha_pinctrl *pinctrl =pinctrl_dev_get_drvdata (pctrl_dev); -u32 val, mask; -int err, pin; -u8 index; +int ret, pin; pin =airoha_convert_pin_to_reg_offset (pctrl_dev,NULL , p);if (pin <0 )return pin; - index = pin /AIROHA_REG_GPIOCTRL_NUM_PIN ; - err =regmap_read (pinctrl->regmap, pinctrl->gpiochip.dir[index], &val); -if (err) -return err; + ret =airoha_gpio_get_direction (&pinctrl->gpiochip.chip, pin); +if (ret <0 ) +return ret; - mask =BIT (2 * (pin %AIROHA_REG_GPIOCTRL_NUM_PIN )); -return val & mask ?PIN_CONFIG_OUTPUT_ENABLE :PIN_CONFIG_INPUT_ENABLE ; +return ret ==GPIO_LINE_DIRECTION_OUT ? +PIN_CONFIG_OUTPUT_ENABLE :PIN_CONFIG_INPUT_ENABLE ; } static int airoha_pinconf_get(struct pinctrl_dev *pctrl_dev,
@@ -3119,6 +3126,17 @@ static int airoha_pinctrl_probe(struct platform_device *pdev) pinctrl->desc.pins = data->pins; pinctrl->desc.npins = data->num_pins; +/* +* some pinctrl operations (ex: get_direction) might use gpio registers +* before gpio chip abstraction will be completely initialized. +*/ + pinctrl->gpiochip.data = gpio_data_regs; + pinctrl->gpiochip.dir = gpio_dir_regs; + pinctrl->gpiochip.out = gpio_out_regs; + pinctrl->gpiochip.status = irq_status_regs; + pinctrl->gpiochip.level = irq_level_regs; + pinctrl->gpiochip.edge = irq_edge_regs; + err =devm_pinctrl_register_and_init (dev, &pinctrl->desc, pinctrl, &pinctrl->ctrl);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1244/1815 pinctrl: airoha: fix getting gpiochip/pinctrl pointers in the IRQ handling code
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit b8dd30554847bde27e8a4584dd447c1c3ac585ce ]
airoha_irq_unmask(), airoha_irq_mask(), airoha_irq_type() functions impements brain damaged logic to retrieve gpiochip and pinctrl pointers.
Details:
gpiochip = irq_data_get_irq_chip_data(data);
will initialize gpiochip variable with data->chip_data value. This value initialized inside gpiochip_irq_map() function
static int gpiochip_irq_map(struct irq_domain *d, unsigned int irq,
irq_hw_number_t hwirq)
{
struct gpio_chip *gc = d->host_data;
...
irq_set_chip_data(irq, gc);
...
}Thus gpiochip variable of 'struct airoha_pinctrl_gpiochip *' type will be initialized with a pointer to a variable of 'struct gpio_chip' type.
Luckily, gpio_chip is the first element of airoha_pinctrl_gpiochip, so gpiochip pointer will get a correct value.
This patch implements correct logic of getting gpiochip and pinctrl pointers.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +9 -11
@@ -2535,18 +2535,17 @@ static int airoha_gpio_direction_output(struct gpio_chip *chip,/* irq callbacks */ static void airoha_irq_unmask (struct irq_data *data) { +struct gpio_chip *gc =irq_data_get_irq_chip_data (data); +struct airoha_pinctrl *pinctrl =gpiochip_get_data (gc); +struct airoha_pinctrl_gpiochip *gpiochip = &pinctrl->gpiochip;u8 offset = data->hwirq %AIROHA_REG_GPIOCTRL_NUM_PIN ;u8 index = data->hwirq /AIROHA_REG_GPIOCTRL_NUM_PIN ;u32 mask =GENMASK (2 * offset +1 ,2 * offset); -struct airoha_pinctrl_gpiochip *gpiochip; -struct airoha_pinctrl *pinctrl;u32 val =BIT (2 * offset); - gpiochip =irq_data_get_irq_chip_data (data);if (WARN_ON_ONCE (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type)))return ; - pinctrl = container_of(gpiochip, struct airoha_pinctrl, gpiochip);switch (gpiochip->irq_type[data->hwirq]) {case IRQ_TYPE_LEVEL_LOW : val = val <<1 ;
@@ -2572,14 +2571,12 @@ static void airoha_irq_unmask(struct irq_data *data)static void airoha_irq_mask (struct irq_data *data) { +struct gpio_chip *gc =irq_data_get_irq_chip_data (data); +struct airoha_pinctrl *pinctrl =gpiochip_get_data (gc); +struct airoha_pinctrl_gpiochip *gpiochip = &pinctrl->gpiochip;u8 offset = data->hwirq %AIROHA_REG_GPIOCTRL_NUM_PIN ;u8 index = data->hwirq /AIROHA_REG_GPIOCTRL_NUM_PIN ;u32 mask =GENMASK (2 * offset +1 ,2 * offset); -struct airoha_pinctrl_gpiochip *gpiochip; -struct airoha_pinctrl *pinctrl; - - gpiochip =irq_data_get_irq_chip_data (data); - pinctrl = container_of(gpiochip, struct airoha_pinctrl, gpiochip);regmap_clear_bits (pinctrl->regmap, gpiochip->level[index], mask);regmap_clear_bits (pinctrl->regmap, gpiochip->edge[index], mask);
@@ -2587,9 +2584,10 @@ static void airoha_irq_mask(struct irq_data *data)static int airoha_irq_type (struct irq_data *data,unsigned int type) { -struct airoha_pinctrl_gpiochip *gpiochip; +struct gpio_chip *gc =irq_data_get_irq_chip_data (data); +struct airoha_pinctrl *pinctrl =gpiochip_get_data (gc); +struct airoha_pinctrl_gpiochip *gpiochip = &pinctrl->gpiochip; - gpiochip =irq_data_get_irq_chip_data (data);if (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type))return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1245/1815 pinctrl: airoha: add missed IRQ resource helpers
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit a02fa031b9520e46e98bff17e12b472eba770670 ]
Without hooking .irq_request_resources, gpiolib cannot set GPIOD_FLAG_USED_AS_IRQ. This breaks pin direction locking and can allow userspace or another driver to reconfigure an active IRQ pin as an output
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/airoha/pinctrl-airoha.c +1 -0
@@ -2640,6 +2640,7 @@ static const struct irq_chip airoha_gpio_irq_chip = { .irq_mask_ack = airoha_irq_mask, .irq_set_type = airoha_irq_type, .flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, }; static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1246/1815 pinctrl: airoha: fix IRQ mask/unmask code
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 20b996280640f492ebdd41c2d2c991801df75e61 ]
When using IRQCHIP_IMMUTABLE, airoha_irq_unmask() must manually call gpiochip_enable_irq() and airoha_irq_mask() must call gpiochip_disable_irq(). Without these calls, gpiolib never sets the GPIOD_FLAG_IRQ_IS_ENABLED bit. Because this bit is missing, gpiod_direction_output() will not realize the pin is actively used as an interrupt.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/airoha/pinctrl-airoha.c +2 -0
@@ -2546,6 +2546,7 @@ static void airoha_irq_unmask(struct irq_data *data)if (WARN_ON_ONCE (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type)))return ; +gpiochip_enable_irq (gc,irqd_to_hwirq (data));switch (gpiochip->irq_type[data->hwirq]) {case IRQ_TYPE_LEVEL_LOW : val = val <<1 ;
@@ -2580,6 +2581,7 @@ static void airoha_irq_mask(struct irq_data *data)regmap_clear_bits (pinctrl->regmap, gpiochip->level[index], mask);regmap_clear_bits (pinctrl->regmap, gpiochip->edge[index], mask); +gpiochip_disable_irq (gc,irqd_to_hwirq (data)); }static int airoha_irq_type (struct irq_data *data,unsigned int type)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1247/1815 pinctrl: airoha: fix edge-triggered interrupts handling
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 3de4686cdf0ccf6d78ca96ccaea621cbcf69fc3a ]
Edge-triggered interrupts are handled incorrectly because of
* no irq_ack() handler was defined,
* no handle_level_irq() handler was used,
This patch probably fixes an issue
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 37 ++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +33 -4
@@ -2579,11 +2579,28 @@ static void airoha_irq_mask(struct irq_data *data)u8 index = data->hwirq /AIROHA_REG_GPIOCTRL_NUM_PIN ;u32 mask =GENMASK (2 * offset +1 ,2 * offset); +if (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type)) +return ; +regmap_clear_bits (pinctrl->regmap, gpiochip->level[index], mask);regmap_clear_bits (pinctrl->regmap, gpiochip->edge[index], mask);gpiochip_disable_irq (gc,irqd_to_hwirq (data)); } +static void airoha_irq_ack (struct irq_data *data) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (data); +struct airoha_pinctrl *pinctrl =gpiochip_get_data (gc); +struct airoha_pinctrl_gpiochip *gpiochip = &pinctrl->gpiochip; +u8 offset = data->hwirq %AIROHA_PIN_BANK_SIZE ; +u8 index = data->hwirq /AIROHA_PIN_BANK_SIZE ; + +if (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type)) +return ; + +regmap_write (pinctrl->regmap, gpiochip->status[index],BIT (offset)); +} +static int airoha_irq_type (struct irq_data *data,unsigned int type) {struct gpio_chip *gc =irq_data_get_irq_chip_data (data);
@@ -2593,13 +2610,26 @@ static int airoha_irq_type(struct irq_data *data, unsigned int type)if (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type))return -EINVAL ; +if (type ==IRQ_TYPE_NONE ) { + gpiochip->irq_type[data->hwirq] =IRQ_TYPE_NONE ; +irq_set_handler_locked (data, handle_bad_irq); + +return 0 ; + } +if (type ==IRQ_TYPE_PROBE ) {if (gpiochip->irq_type[data->hwirq])return 0 ; type =IRQ_TYPE_EDGE_RISING |IRQ_TYPE_EDGE_FALLING ; } + gpiochip->irq_type[data->hwirq] = type &IRQ_TYPE_SENSE_MASK ; +if (type &IRQ_TYPE_EDGE_BOTH ) +irq_set_handler_locked (data, handle_edge_irq); +else +irq_set_handler_locked (data, handle_level_irq); +return 0 ; }
@@ -2624,8 +2654,7 @@ static irqreturn_t airoha_irq_handler(int irq, void *data)for_each_set_bit (irq, &status,AIROHA_PIN_BANK_SIZE ) {u32 offset = irq + i *AIROHA_PIN_BANK_SIZE ; -generic_handle_irq (irq_find_mapping (girq->domain, - offset)); +generic_handle_domain_irq (girq->domain, offset);regmap_write (pinctrl->regmap, pinctrl->gpiochip.status[i],BIT (irq)); }
@@ -2639,7 +2668,7 @@ static const struct irq_chip airoha_gpio_irq_chip = { .name = "airoha-gpio-irq", .irq_unmask = airoha_irq_unmask, .irq_mask = airoha_irq_mask, - .irq_mask_ack = airoha_irq_mask, + .irq_ack = airoha_irq_ack, .irq_set_type = airoha_irq_type, .flags =IRQCHIP_SET_TYPE_MASKED |IRQCHIP_IMMUTABLE , GPIOCHIP_IRQ_RESOURCE_HELPERS,
@@ -2667,7 +2696,7 @@ static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl, gc->ngpio =AIROHA_NUM_PINS ; girq->default_type =IRQ_TYPE_NONE ; - girq->handler = handle_simple_irq; + girq->handler = handle_bad_irq;gpio_irq_chip_set_chip (girq, &airoha_gpio_irq_chip); irq =platform_get_irq (pdev,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1248/1815 Bluetooth: virtio_bt: avoid OOB read of build info string
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 502adc06ba76dee19c292ae4a07d74d202fe734d ]
The virtbt_setup_zephyr() sends the Zephyr vendor command 0xfc08 (Read Build Information) and hands the response to bt_dev_info() and hci_set_fw_info() as a "%s" string starting at skb->data + 1, without checking the length. A backend that answers with status only leaves that pointer past the end of the received data, so the walk reads adjacent slab memory until it meets a NUL. Those bytes reach the kernel log and the firmware-info debugfs file.
To fix this, print the string with a bounded "%.*s" limited to skb->len - 1. A short or unterminated response then prints as much as arrived instead of failing setup.
This mirrors commit dd068ef04412 ("Bluetooth: bpa10x: avoid OOB read of revision string in bpa10x_setup()"), which fixed the identical pattern.
--- drivers/bluetooth/virtio_bt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/bluetooth/virtio_bt.c +6 -2
@@ -120,9 +120,13 @@ static int virtbt_setup_zephyr(struct hci_dev *hdev)if (IS_ERR (skb))return PTR_ERR (skb); -bt_dev_info (hdev,"%s" , (char *)(skb->data +1 )); +/* Bounded print: the backend controls skb->len. */ +if (skb->len >1 ) { +int len = skb->len -1 ; -hci_set_fw_info (hdev,"%s" , skb->data +1 ); +bt_dev_info (hdev,"%.*s" , len, (char *)(skb->data +1 )); +hci_set_fw_info (hdev,"%.*s" , len, skb->data +1 ); + }kfree_skb (skb);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1249/1815 Bluetooth: L2CAP: use proto_lock for l2cap_data to fix l2cap_disconn_ind
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 2b66c83ff1751d6bd3201b3017206262ab46dc05 ]
hci_conn::l2cap_data is accessed without locks in l2cap_disconn_ind via hci_conn_timeout (disc_work) -> hci_proto_disconn_ind -> l2cap_disconn_ind. This is UAF if the l2cap_conn is deleted concurrently.
disc_work is disabled sync in hci_conn_del(), so we cannot take hci_dev_lock in disc_work.
Fix by using proto_lock to guard l2cap_data, in addition to hdev->lock which is held in other access paths.
--- net/bluetooth/l2cap_core.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
net/bluetooth/l2cap_core.c +17 -6
@@ -1833,7 +1833,10 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)hci_chan_del (conn->hchan); conn->hchan =NULL ; +spin_lock (&hcon->proto_lock); hcon->l2cap_data =NULL ; +spin_unlock (&hcon->proto_lock); +mutex_unlock (&conn->lock);l2cap_conn_put (conn); }
@@ -7168,8 +7171,6 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon) }kref_init (&conn->ref); - hcon->l2cap_data = conn; - conn->hcon =hci_conn_get (hcon); conn->hchan = hchan;BT_DBG ("hcon %p conn %p hchan %p" , hcon, conn, hchan);
@@ -7198,6 +7199,11 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon) conn->disc_reason =HCI_ERROR_REMOTE_USER_TERM ; +spin_lock (&hcon->proto_lock); + conn->hcon =hci_conn_get (hcon); + hcon->l2cap_data = conn; +spin_unlock (&hcon->proto_lock); +return conn; }
@@ -7582,13 +7588,18 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)int l2cap_disconn_ind (struct hci_conn *hcon) { -struct l2cap_conn *conn = hcon->l2cap_data; +struct l2cap_conn *conn; +int ret =HCI_ERROR_REMOTE_USER_TERM ;BT_DBG ("hcon %p" , hcon); -if (!conn) -return HCI_ERROR_REMOTE_USER_TERM ; -return conn->disc_reason; +spin_lock (&hcon->proto_lock); + conn = hcon->l2cap_data; +if (conn) + ret = conn->disc_reason; +spin_unlock (&hcon->proto_lock); + +return ret; }static void l2cap_disconn_cfm (struct hci_conn *hcon,u8 reason)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1250/1815 Bluetooth: btintel: Fix diagnostics event detection
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit ad0e7ac7da9a9a0095570bd6add3e27f259de104 ]
For a diagnostics VSE, diagnostics_hdr[] sits at the start of the event payload, skb->data[2], but btintel_recv_event() wrongly guards its memcmp with @len, which is measured from skb->data[3] for the earlier INTEL_BOOTLOADER check.
Fix by using (@len + 1) instead, which ==
(skb->len - HCI_EVENT_HDR_SIZE) exactly.
--- drivers/bluetooth/btintel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bluetooth/btintel.c +1 -1
@@ -3834,7 +3834,7 @@ int btintel_recv_event(struct hci_dev *hdev, struct sk_buff *skb)/* Handle all diagnostics events separately. May still call * hci_recv_frame. */ -if (len >=sizeof (diagnostics_hdr) && +if (len +1 >=sizeof (diagnostics_hdr) &&memcmp (&skb->data[2 ], diagnostics_hdr,sizeof (diagnostics_hdr)) ==0 ) {return btintel_diagnostics (hdev, skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1251/1815 Bluetooth: hci_conn: fix the SCO setup context lifetime
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 42de40abe25db9211107af8896d0fd741f10648d ]
hci_setup_sync() queues a conn_handle_t with a NULL destroy callback, so the context is only freed if hci_enhanced_setup_sync() actually runs. An entry that is cancelled instead is leaked, as _hci_cmd_sync_cancel_entry() does not release entry->data when there is no destroy callback, and hci_cmd_sync_clear() cancels every pending entry when the controller is unregistered.
The context also stores a bare hci_conn pointer, so the connection can be freed while the work is queued. The dequeue in hci_conn_del() does not cover it either, as it matches on entry->data == conn and entry->data is the wrapper here. Same problem as commit 2f5d635ad590 ("Bluetooth:hci_sync: hold conn in hci_connect_acl/le_sync() callbacks").
Hold the connection and release both from a destroy callback. The submission failure path drops both, since hci_cmd_sync_submit() does not call the destroy callback when it fails to queue.
--- net/bluetooth/hci_conn.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
net/bluetooth/hci_conn.c +15 -5
@@ -283,8 +283,6 @@ static int hci_enhanced_setup_sync(struct hci_dev *hdev, void *data)struct hci_cp_enhanced_setup_sync_conn cp;const struct sco_param *param; -kfree (conn_handle); -if (!hci_conn_valid (hdev, conn))return -ECANCELED ;
@@ -453,6 +451,15 @@ static bool hci_setup_sync_conn(struct hci_conn *conn, __u16 handle)return true; } +static void hci_enhanced_setup_sync_destroy (struct hci_dev *hdev,void *data, +int err) +{ +struct conn_handle_t *conn_handle = data; + +hci_conn_put (conn_handle->conn); +kfree (conn_handle); +} +bool hci_setup_sync (struct hci_conn *conn,__u16 handle) {int result;
@@ -464,12 +471,15 @@ bool hci_setup_sync(struct hci_conn *conn, __u16 handle)if (!conn_handle)return false; - conn_handle->conn = conn; + conn_handle->conn =hci_conn_get (conn); conn_handle->handle = handle; result =hci_cmd_sync_queue (conn->hdev, hci_enhanced_setup_sync, - conn_handle,NULL ); -if (result <0 ) + conn_handle, + hci_enhanced_setup_sync_destroy); +if (result <0 ) { +hci_conn_put (conn);kfree (conn_handle); + }return result ==0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1252/1815 Bluetooth: hci_sync: free the advertising instance on the failure and cancel paths
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 120d8dc042e3d45073bb6e50ee7b058a0b182627 ]
adv_timeout_expire() hands a kmalloc()ed instance byte to hci_cmd_sync_queue() with a NULL destroy callback, and only adv_timeout_expire_sync() frees it. That leaks on two paths:
- the return value is not checked, and hci_cmd_sync_queue() does not take ownership when it fails (-ENETDOWN, -ENODEV, -ENOMEM);
- a cancelled entry is not released, as _hci_cmd_sync_cancel_entry() does not free entry->data when there is no destroy callback. hci_cmd_sync_clear() cancels every pending entry when the controller is unregistered.
Free the buffer from a destroy callback, and in the caller when the entry could not be queued at all.
--- net/bluetooth/hci_sync.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/bluetooth/hci_sync.c +9 -3
@@ -540,8 +540,6 @@ static int adv_timeout_expire_sync(struct hci_dev *hdev, void *data) {u8 instance = *(u8 *)data; -kfree (data); -hci_clear_adv_instance_sync (hdev,NULL , instance, false);if (list_empty (&hdev->adv_instances))
@@ -550,6 +548,12 @@ static int adv_timeout_expire_sync(struct hci_dev *hdev, void *data)return 0 ; } +static void adv_timeout_expire_destroy (struct hci_dev *hdev,void *data, +int err) +{ +kfree (data); +} +static void adv_timeout_expire (struct work_struct *work) {u8 *inst_ptr;
@@ -570,7 +574,9 @@ static void adv_timeout_expire(struct work_struct *work) goto unlock; *inst_ptr = hdev->cur_adv_instance; -hci_cmd_sync_queue (hdev, adv_timeout_expire_sync, inst_ptr,NULL ); +if (hci_cmd_sync_queue (hdev, adv_timeout_expire_sync, inst_ptr, + adv_timeout_expire_destroy) <0 ) +kfree (inst_ptr); unlock:hci_dev_unlock (hdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1253/1815 Bluetooth: MGMT: free the mesh send cancel command when it is cancelled
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 3c742feda8fcabf741a17bcf668b63c8f606f9c5 ]
mesh_send_cancel() queues the pending command with a NULL destroy callback, so it is only freed if send_cancel() runs. A cancelled entry is leaked, as _hci_cmd_sync_cancel_entry() does not release entry->data when there is no destroy callback, and hci_cmd_sync_clear() cancels every pending entry when the controller is unregistered. Nothing else reclaims it either: mgmt_pending_new() does not put the command on hdev->mgmt_pending.
The leak also pins the socket reference taken by mgmt_pending_new(), so the mgmt socket is never released.
Free the command from a destroy callback.
--- net/bluetooth/mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/bluetooth/mgmt.c +7 -2
@@ -2431,11 +2431,15 @@ static int send_cancel(struct hci_dev *hdev, void *data)mgmt_cmd_complete (cmd->sk, hdev->id,MGMT_OP_MESH_SEND_CANCEL ,0 ,NULL ,0 ); -mgmt_pending_free (cmd);return 0 ; } +static void send_cancel_destroy (struct hci_dev *hdev,void *data,int err) +{ +mgmt_pending_free (data); +} +static int mesh_send_cancel (struct sock *sk,struct hci_dev *hdev,void *data,u16 len) {
@@ -2456,7 +2460,8 @@ static int mesh_send_cancel(struct sock *sk, struct hci_dev *hdev,if (!cmd) err = -ENOMEM ;else - err =hci_cmd_sync_queue (hdev, send_cancel, cmd,NULL ); + err =hci_cmd_sync_queue (hdev, send_cancel, cmd, + send_cancel_destroy);if (err <0 ) { err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND_CANCEL,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1254/1815 Bluetooth: MGMT: free the HCI command when it is cancelled
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 414b365ecea6c30357adee6b8a7c5edc03a03575 ]
mgmt_hci_cmd_sync() queues the pending command with a NULL destroy callback, so it is only freed if send_hci_cmd_sync() runs. A cancelled entry is leaked, as _hci_cmd_sync_cancel_entry() does not release entry->data when there is no destroy callback, and hci_cmd_sync_clear() cancels every pending entry when the controller is unregistered. Nothing else reclaims it either: mgmt_pending_new() does not put the command on hdev->mgmt_pending.
The leak also pins the socket reference taken by mgmt_pending_new(), so the mgmt socket is never released.
Free the command from a destroy callback. The now-empty done label is replaced by a direct return.
--- net/bluetooth/mgmt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
net/bluetooth/mgmt.c +8 -5
@@ -2647,7 +2647,7 @@ static int send_hci_cmd_sync(struct hci_dev *hdev, void *data)if (IS_ERR (skb)) {mgmt_cmd_status (cmd->sk, hdev->id,MGMT_OP_HCI_CMD_SYNC ,mgmt_status (PTR_ERR (skb))); - goto done; +return 0 ; } mgmt_cmd_complete(cmd->sk, hdev->id, MGMT_OP_HCI_CMD_SYNC, 0,
@@ -2655,12 +2655,14 @@ static int send_hci_cmd_sync(struct hci_dev *hdev, void *data)kfree_skb (skb); -done: -mgmt_pending_free (cmd); -return 0 ; } +static void send_hci_cmd_sync_destroy (struct hci_dev *hdev,void *data,int err) +{ +mgmt_pending_free (data); +} +static int mgmt_hci_cmd_sync (struct sock *sk,struct hci_dev *hdev,void *data,u16 len) {
@@ -2686,7 +2688,8 @@ static int mgmt_hci_cmd_sync(struct sock *sk, struct hci_dev *hdev,if (!cmd) err = -ENOMEM ;else - err =hci_cmd_sync_queue (hdev, send_hci_cmd_sync, cmd,NULL ); + err =hci_cmd_sync_queue (hdev, send_hci_cmd_sync, cmd, + send_hci_cmd_sync_destroy);if (err <0 ) { err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_HCI_CMD_SYNC,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1255/1815 Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative
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 b0c0b37940115383e7ea65d4d988f9b9e613ab92 ]
btmtksdio_setup() calls pm_runtime_use_autosuspend() when runtime PM is supported, but btmtksdio_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 driver teardown, this reference is not dropped and usage_count remains unbalanced.
Add the missing pm_runtime_dont_use_autosuspend() call in the remove path before restoring the runtime PM usage reference.
This issue was found by manual code inspection.
--- drivers/bluetooth/btmtksdio.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/bluetooth/btmtksdio.c +3 -0
@@ -1480,6 +1480,9 @@ static void btmtksdio_remove(struct sdio_func *func)if (test_bit (BTMTKSDIO_FUNC_ENABLED , &bdev->tx_state))btmtksdio_close (hdev); +if (bdev->data->pm_runtime_supported) +pm_runtime_dont_use_autosuspend (bdev->dev); +/* Be consistent the state in btmtksdio_probe */ pm_runtime_get_noresume (bdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1256/1815 Bluetooth: MSFT: validate evt_prefix_len against the response length
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memis <[email protected]>
[ Upstream commit 0079e1a944634ab2dc1c7cdec1144486d096407e ]
read_supported_features() only checks that the response covers the fixed part of struct msft_rp_read_supported_features, which is 11 bytes:
if (skb->len < sizeof(*rp)) {
bt_dev_err(hdev, "MSFT supported features length mismatch");
goto failed;
}evt_prefix[] is a flexible array member and rp->evt_prefix_len is an unvalidated u8 taken straight out of that response, so
msft->evt_prefix = kmemdup(rp->evt_prefix, rp->evt_prefix_len, GFP_KERNEL);
copies up to 255 bytes from a reply that may have carried none of them. What is copied is data the controller never sent, and it is then used to match incoming vendor events in msft_vendor_evt().
This is not an out-of-bounds access. An skb data allocation always has at least SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) bytes past the payload, which is more than the 255 byte maximum, so the read stays inside the allocation and KASAN does not report it. It is still a read of bytes the host was never given, with the length fully controlled by the controller.
Reject a response that is too short for the prefix it declares.
Verified with an emulated controller over /dev/vhci on a KASAN kernel, with vhci made to advertise an MSFT opcode the way btintel, btqca, btmtk and btrtl do unconditionally. A reply of exactly 11 bytes declaring evt_prefix_len = 255 reaches kmemdup and copies 255 bytes ("skb->len=11 evt_prefix_len=255", with the copied buffer dumped); since the reply ends at the fixed part, all 255 come from past the end of the response. No KASAN report is produced, as expected from the allocation slack described above. With this patch the response is rejected with "MSFT event prefix length mismatch" and msft->evt_prefix is left unset.
--- net/bluetooth/msft.c | 5 +++++ 1 file changed, 5 insertions(+)
net/bluetooth/msft.c +5 -0
@@ -165,6 +165,11 @@ static bool read_supported_features(struct hci_dev *hdev,if (rp->sub_opcode !=MSFT_OP_READ_SUPPORTED_FEATURES ) goto failed; +if (skb->len <sizeof (*rp) + rp->evt_prefix_len) { +bt_dev_err (hdev,"MSFT event prefix length mismatch" ); + goto failed; + } +if (rp->evt_prefix_len >0 ) { msft->evt_prefix =kmemdup (rp->evt_prefix, rp->evt_prefix_len,GFP_KERNEL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1257/1815 pinctrl: fix PINCTRL_GENERIC_MUX not always being selectable
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alvin Šipraga <[email protected]>
[ Upstream commit 465f276bb928093685c2a2b98bf0a7ccc4283b8d ]
CONFIG_MULTIPLEXER can only be enabled indirectly. If it's not already enabled, then CONFIG_PINCTRL_GENERIC_MUX cannot be selected at all in menuconfig. That's because it depends on MULTIPLEXER.
Follow similar consumers of the multiplexer core and select MULTIPLEXER instead. This way the driver will be visible in menuconfig as long as PINCTRL is selected.
--- drivers/pinctrl/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/Kconfig +1 -1
@@ -275,8 +275,8 @@ config PINCTRL_GEMINI config PINCTRL_GENERIC_MUX tristate "Generic Pinctrl driver by using multiplexer" - depends on MULTIPLEXER depends on OF + select MULTIPLEXER select PINMUX select GENERIC_PINCTRL help
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1258/1815 bpf, cgroup: Fix storage null-ptr-deref after replacing prog
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 3f562c537e9ecf4bc5e206cfffc2cc047f1b7e94 ]
Syzkaller reported a storage null-ptr-deref issue after replacing prog. This occurs in the following scenario:
1. prog A, an empty prog, is attached to a cgrp.
2. prog B uses BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE and calls the bpf_get_local_storage helper.
3. link_update is called to replace prog A with prog B.
The reason is that __cgroup_bpf_replace fails to alloc and assign the required cgrp storage for the incoming replacement prog. Consequently, the new prog inherits an uninit storage, leading to null-ptr-deref panic when kick the new prog.
Fix this by rejecting a link update if new_prog's cgroup storage is incompatible with link->prog.
--- kernel/bpf/cgroup.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
kernel/bpf/cgroup.c +17 -0
@@ -1026,6 +1026,20 @@ static void replace_effective_prog(struct cgroup *cgrp, } } +static bool cgroup_bpf_storages_compatible (struct bpf_prog *old_prog, +struct bpf_prog *new_prog) +{ +enum bpf_cgroup_storage_type stype; + +for_each_cgroup_storage_type (stype) { +if (old_prog->aux->cgroup_storage[stype] != + new_prog->aux->cgroup_storage[stype]) +return false; + } + +return true; +} +/** * __cgroup_bpf_replace() - Replace link's program and propagate the change * to descendants
@@ -1064,6 +1078,9 @@ static int __cgroup_bpf_replace(struct cgroup *cgrp,if (!found)return -ENOENT ; +if (!cgroup_bpf_storages_compatible (link->link.prog, new_prog)) +return -EINVAL ; + cgrp->bpf.revisions[atype] +=1 ; old_prog =xchg (&link->link.prog, new_prog);replace_effective_prog (cgrp, atype, pl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1259/1815 iio: light: opt4060: Fix pointer type passed to div_u64_rem()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vidhu Sarwal <[email protected]>
[ Upstream commit 0ba0ed0d42ebd3144f0050c48374817f5f3f07d6 ]
div_u64_rem() expects a u32 * for the remainder, but opt4060_read_ev_period() passes val2, which is declared as an int *. While this has no functional impact, it triggers a pointer type mismatch.
There is no behavioural change because int and u32 have the same size and representation on all supported architectures, and the remainder is always less than MICRO, so it fits within the positive range of int.
Use a local u32 to receive the remainder before assigning it to *val2.
--- drivers/iio/light/opt4060.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/light/opt4060.c +3 -1
@@ -713,6 +713,7 @@ static ssize_t opt4060_read_ev_period(struct opt4060_chip *chip, int *val, {int ret, pers, fault_count, int_time;u64 uval; +u32 rem; int_time = opt4060_int_time_reg[chip->int_time][0 ];
@@ -738,7 +739,8 @@ static ssize_t opt4060_read_ev_period(struct opt4060_chip *chip, int *val, } uval =mul_u32_u32 (int_time, pers); - *val =div_u64_rem (uval,MICRO , val2); + *val =div_u64_rem (uval,MICRO , &rem); + *val2 = rem;return IIO_VAL_INT_PLUS_MICRO ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1260/1815 iio: light: gp2ap002: Fix unbalanced runtime PM on repeated event writes
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil Gautam <[email protected]>
[ Upstream commit 579c049b4cb6fc72ce2c505fc5334540be0efcd3 ]
The IIO core does not filter duplicate writes to the event enable attribute, so writing the same value twice invokes write_event_config() twice. Enabling twice leaks a runtime PM reference, preventing the device from ever suspending again; disabling twice underflows the usage count and triggers a "Runtime PM usage count underflow" warning.
Bail out early when the requested state matches the current state. While at it, switch to pm_runtime_resume_and_get() so a failed resume is propagated to userspace instead of silently marking the event enabled.
--- drivers/iio/light/gp2ap002.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/iio/light/gp2ap002.c +10 -3
@@ -342,6 +342,10 @@ static int gp2ap002_write_event_config(struct iio_dev *indio_dev, bool state) {struct gp2ap002 *gp2ap002 =iio_priv (indio_dev); +int ret; + +if (state == gp2ap002->enabled) +return 0 ;if (state) {/*
@@ -349,13 +353,16 @@ static int gp2ap002_write_event_config(struct iio_dev *indio_dev,* already) and reintialize the sensor by using runtime_pm * callbacks. */ -pm_runtime_get_sync (gp2ap002->dev); - gp2ap002->enabled = true; + ret =pm_runtime_resume_and_get (gp2ap002->dev); +if (ret) +return ret; + }else {pm_runtime_put_autosuspend (gp2ap002->dev); - gp2ap002->enabled = false; } + gp2ap002->enabled = state; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1261/1815 iio: light: gp2ap002: re-enable irq if runtime suspend fails
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil Gautam <[email protected]>
[ Upstream commit 5d89e7cbac40057f5241a0832a86ce0fe97e4818 ]
gp2ap002_runtime_suspend() disables the irq before writing OPMOD. If the write fails, the callback returns an error with the irq still disabled while the PM core marks the device active again.
re-enable the irq before returning the error so the irq state matches the active state the PM core restores.
--- drivers/iio/light/gp2ap002.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/light/gp2ap002.c +1 -0
@@ -649,6 +649,7 @@ static int gp2ap002_runtime_suspend(struct device *dev)/* Disable chip and IRQ, everything off */ ret =regmap_write (gp2ap002->map,GP2AP002_OPMOD ,0x00 );if (ret) { +enable_irq (gp2ap002->irq);dev_err (gp2ap002->dev,"error setting up operation mode\n" );return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1262/1815 net/sched: cls_api: fix teardown of an adopted proto on insert-race loss
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit d4e359b3608a0e184bbe8d61a5c3b50d0831c44a ]
In tc_new_tfilter() the create branch sets tp_created = 1 before calling tcf_chain_tp_insert_unique(). When the caller loses the race (another request inserted a proto at the same chain/prio first), insert_unique() destroys the caller's own tp_new and returns the winner's proto with an extra reference. tp_created was never cleared, so the loser's errout path treated the winner's live proto as its own and called tcf_chain_tp_delete_empty() on it, silently unlinking an active classifier that the winning request already advertised via RTM_NEWTFILTER.
Track the outcome of the insert step in a single tri-state variable so each errout path reacts correctly:
- TP_NOT_CREATED: no proto created; pursue the old path.
- TP_CREATED: proto inserted successfully; same code path as before.
- TP_NOT_OWNED: New - lost the insert race; tp is another request's proto (chain ref already released by tp_new's destroy)
Both errout reactions are single expressions derived from the state.
This fix is motivated by the Sashiko's automated review of Patch (net/sched: cls_api: Always acquire rtnl_lock when destroying locked classifiers) [1][2]. The review identified the silent-unlink behaviour of an adopted proto's teardown when a request loses the tcf_chain_tp_insert_unique() race.
[1] https://sashiko.dev/#/patchset/20260801125632.360365-1-jhs%40mojatatu.com
[2] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260801125632.360365-1-jhs%40mojatatu.com
--- net/sched/cls_api.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
net/sched/cls_api.c +13 -5
@@ -2248,6 +2248,12 @@ static bool is_ingress_or_clsact(struct tcf_block *block, struct Qdisc *q)return tcf_block_shared (block) || (q && !!(q->flags &TCQ_F_INGRESS )); } +enum tcf_tp_insert_state { +TP_NOT_CREATED =0 ,/* did not create and insert a new tp */ +TP_CREATED ,/* created and inserted a new tp */ +TP_NOT_OWNED ,/* created a proto but failed to insert */ +}; +static int tc_new_tfilter (struct sk_buff *skb,struct nlmsghdr *n,struct netlink_ext_ack *extack) {
@@ -2268,12 +2274,12 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,unsigned long cl;void *fh;int err; -int tp_created; +enum tcf_tp_insert_state tp_state;bool rtnl_held = false;u32 flags; replay: - tp_created =0 ; + tp_state =TP_NOT_CREATED ; err =nlmsg_parse_deprecated (n,sizeof (*t), tca,TCA_MAX , rtm_tca_policy, extack);
@@ -2395,13 +2401,15 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, goto errout_tp; } - tp_created =1 ; + tp_state =TP_CREATED ; tp =tcf_chain_tp_insert_unique (chain, tp_new, protocol, prio, rtnl_held);if (IS_ERR (tp)) { err =PTR_ERR (tp); goto errout_tp; } +if (tp != tp_new) + tp_state =TP_NOT_OWNED ; }else {mutex_unlock (&chain->filter_chain_lock); }
@@ -2455,13 +2463,13 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, } errout: -if (err && tp_created) +if (err && tp_state ==TP_CREATED )tcf_chain_tp_delete_empty (chain, tp, rtnl_held,NULL ); errout_tp:if (chain) {if (tp && !IS_ERR (tp))tcf_proto_put (tp, rtnl_held,NULL ); -if (!tp_created) +if (tp_state ==TP_NOT_CREATED )tcf_chain_put (chain); }tcf_block_release (q, block, rtnl_held);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1263/1815 riscv: cpufeature: Clarify ISA spec version for canonical order
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guodong Xu <[email protected]>
[ Upstream commit fdef048705daa3d4ed1fa212ee071bcbdac02d80 ]
Specify that chapter 27 refers to version 20191213 of the RISC-V ISA Unprivileged Architecture. The chapter numbering differs across specification versions - for example, in version 20250508, the ISA Extension Naming Conventions is chapter 36, not chapter 27.
Historical versions of the RISC-V specification can be found via Link [1].
--- arch/riscv/kernel/cpufeature.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/riscv/kernel/cpufeature.c +2 -1
@@ -452,7 +452,8 @@ static const unsigned int riscv_c_exts[] = {/* * The canonical order of ISA extension names in the ISA string is defined in -* chapter 27 of the unprivileged specification. +* Chapter 27 of the RISC-V Instruction Set Manual Volume I Unprivileged ISA +* (Document Version 20191213). * * Ordinarily, for in-kernel data structures, this order is unimportant but * isa_ext_arr defines the order of the ISA string in /proc/cpuinfo.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1264/1815 bpf: Fix mmap_lock leak in irq_work path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanghyun Park <[email protected]>
[ Upstream commit fa9dcacdcdf487f0ffef64bf67622f1caed509f1 ]
stack_map_get_build_id_offset() introduced a per-CPU irq_work to defer mmap_read_unlock() from NMI context, and bpf_find_vma() later reused the same mmap_unlock_work. Both callers only check whether the work is busy before taking mmap_lock, so a nested caller can reuse the slot before the first caller queues it. Two read locks may then be acquired while only one deferred unlock runs, leaking a read lock and blocking exit_mmap().
Reserve the per-CPU slot before mmap_read_trylock(). Use the same wrapper in stackmap and bpf_find_vma() so both callers release the reservation on trylock failure. Keep rejecting the slot while the irq_work remains busy. Release it after the irq_work callback unlocks the mm.
--- kernel/bpf/mmap_unlock_work.h | 51 ++++++++++++++++++++--------------- kernel/bpf/stackmap.c | 28 +++++++++++-------- kernel/bpf/task_iter.c | 14 +++++++--- 3 files changed, 56 insertions(+), 37 deletions(-)
kernel/bpf/mmap_unlock_work.h +29 -22
@@ -4,12 +4,15 @@#ifndef __MMAP_UNLOCK_WORK_H__#define __MMAP_UNLOCK_WORK_H__ +#include <linux/atomic.h> +#include <linux/err.h> #include <linux/irq_work.h> /* irq_work to run mmap_read_unlock() in irq_work */ struct mmap_unlock_irq_work {struct irq_work irq_work;struct mm_struct *mm; +atomic_t active; }; DECLARE_PER_CPU(struct mmap_unlock_irq_work, mmap_unlock_work);
@@ -18,32 +21,36 @@ DECLARE_PER_CPU(struct mmap_unlock_irq_work, mmap_unlock_work);* We cannot do mmap_read_unlock() when the irq is disabled, because of * risk to deadlock with rq_lock. To look up vma when the irqs are * disabled, we need to run mmap_read_unlock() in irq_work. We use a -* percpu variable to do the irq_work. If the irq_work is already used -* by another lookup, we fall over. +* percpu variable to do the irq_work. The active flag reserves the slot +* before mmap_read_trylock() and until the irq_work callback consumes mm. */ -static inline bool bpf_mmap_unlock_get_irq_work (struct mmap_unlock_irq_work **work_ptr) +static inline struct mmap_unlock_irq_work *bpf_mmap_unlock_guard_get (void ) { -struct mmap_unlock_irq_work *work =NULL ; -bool irq_work_busy = false; +struct mmap_unlock_irq_work *work; -if (irqs_disabled ()) { -if (!IS_ENABLED (CONFIG_PREEMPT_RT )) { - work =this_cpu_ptr (&mmap_unlock_work); -if (irq_work_is_busy (&work->irq_work)) { -/* cannot queue more up_read, fallback */ - irq_work_busy = true; - } - }else { -/* -* PREEMPT_RT does not allow to trylock mmap sem in -* interrupt disabled context. Force the fallback code. -*/ - irq_work_busy = true; - } - } +if (!irqs_disabled ()) +return NULL ; + +/* +* PREEMPT_RT does not allow to trylock mmap sem in interrupt +* disabled context. Force the fallback code. +*/ +if (IS_ENABLED (CONFIG_PREEMPT_RT )) +return ERR_PTR (-EBUSY ); + + work =this_cpu_ptr (&mmap_unlock_work); +if (irq_work_is_busy (&work->irq_work) || +atomic_cmpxchg_acquire (&work->active,0 ,1 )) +return ERR_PTR (-EBUSY ); - *work_ptr = work; -return irq_work_busy; +return work; +} + +static inline void +bpf_mmap_unlock_guard_put (struct mmap_unlock_irq_work *work) +{ +if (work) +atomic_set_release (&work->active,0 ); }static inline void bpf_mmap_unlock_mm (struct mmap_unlock_irq_work *work,struct mm_struct *mm)
kernel/bpf/stackmap.c +17 -11
@@ -414,8 +414,7 @@ static void stack_map_get_build_id_offset_sleepable(struct bpf_stack_build_id *istatic void stack_map_get_build_id_offset (struct bpf_stack_build_id *id_offs,u32 trace_nr,bool user,bool may_fault) { -struct mmap_unlock_irq_work *work =NULL ; -bool irq_work_busy =bpf_mmap_unlock_get_irq_work (&work); +struct mmap_unlock_irq_work *work;bool has_user_ctx = user && current && current->mm;struct stack_map_build_id_cache cache = {};struct vm_area_struct *vma;
@@ -426,15 +425,16 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,return ; } -/* If the irq_work is in use, fall back to report ips. Same -* fallback is used for kernel stack (!user) on a stackmap with -* build_id. -*/ -if (!has_user_ctx || irq_work_busy || !mmap_read_trylock (current->mm)) { -/* cannot access current->mm, fall back to ips */ -for (i =0 ; i < trace_nr; i++) -stack_map_build_id_set_ip (&id_offs[i]); -return ; +if (!has_user_ctx) + goto fallback; + + work =bpf_mmap_unlock_guard_get (); +if (IS_ERR (work)) + goto fallback; + +if (!mmap_read_trylock (current->mm)) { +bpf_mmap_unlock_guard_put (work); + goto fallback; }for (i =0 ; i < trace_nr; i++) {
@@ -465,6 +465,12 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs, vma->vm_pgoff); }bpf_mmap_unlock_mm (work, current->mm); +return ; + +fallback: +/* cannot access current->mm, fall back to ips */ +for (i =0 ; i < trace_nr; i++) +stack_map_build_id_set_ip (&id_offs[i]); } static struct perf_callchain_entry *
kernel/bpf/task_iter.c +10 -4
@@ -753,9 +753,8 @@ static struct bpf_iter_reg task_vma_reg_info = { BPF_CALL_5(bpf_find_vma, struct task_struct *, task, u64, start, bpf_callback_t, callback_fn, void *, callback_ctx, u64, flags) { -struct mmap_unlock_irq_work *work =NULL ; +struct mmap_unlock_irq_work *work;struct vm_area_struct *vma; -bool irq_work_busy = false;bool __maybe_unused mmput_needed = false;struct mm_struct *mm;int ret = -ENOENT ;
@@ -792,9 +791,14 @@ BPF_CALL_5(bpf_find_vma, struct task_struct *, task, u64, start,if (!mm)return -ENOENT ; - irq_work_busy =bpf_mmap_unlock_get_irq_work (&work); + work =bpf_mmap_unlock_guard_get (); +if (IS_ERR (work)) { + ret =PTR_ERR (work); + goto out; + } -if (irq_work_busy || !mmap_read_trylock (mm)) { +if (!mmap_read_trylock (mm)) { +bpf_mmap_unlock_guard_put (work); ret = -EBUSY ; goto out; }
@@ -1191,6 +1195,8 @@ static void do_mmap_read_unlock(struct irq_work *entry) work = container_of(entry, struct mmap_unlock_irq_work, irq_work);mmap_read_unlock_non_owner (work->mm); + work->mm =NULL ; +bpf_mmap_unlock_guard_put (work); }static int __init task_iter_init (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1265/1815 i3c: renesas: Return immediately if there is no transfer
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 33b5ecc5a16e270c8e0dd9835e7d9d2522f64129 ]
There is no need to allocate a transfer structure when i2c_nxfers is zero. Return immediately instead of unnecessarily allocating memory.
Stable-dep-of: b6e56fd8c8a8 ("i3c: renesas: Don't register devices when ENTDAA times out")
--- drivers/i3c/master/renesas-i3c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i3c/master/renesas-i3c.c +3 -3
@@ -957,13 +957,13 @@ static int renesas_i3c_i2c_xfers(struct i2c_dev_desc *dev,u8 start_bit =CNDCTL_STCND ;int i; +if (!i2c_nxfers) +return 0 ; + struct renesas_i3c_xfer *xfer __free(kfree) = renesas_i3c_alloc_xfer(i3c, 1);if (!xfer)return -ENOMEM ; -if (!i2c_nxfers) -return 0 ; -renesas_i3c_bus_enable (m, false);init_completion (&xfer->comp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1266/1815 i3c: renesas: Follow a unified pattern for transfer and command initialization
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 234a26e6febcf789d9f6779d67c01e3d0c1df5bc ]
Follow a unified pattern for transfer and command initialization across the driver. This keeps the code cleaner and easier to follow. Also, in some cases the I3C device was enabled before the transfer data structure was even allocated.
Stable-dep-of: b6e56fd8c8a8 ("i3c: renesas: Don't register devices when ENTDAA times out")
--- drivers/i3c/master/renesas-i3c.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/i3c/master/renesas-i3c.c +11 -11
@@ -663,6 +663,10 @@ static int renesas_i3c_daa(struct i3c_master_controller *m)if (!xfer)return -ENOMEM ; +init_completion (&xfer->comp); + cmd = xfer->cmds; + cmd->rx_count =0 ; +/* Enable I3C bus. */ renesas_i3c_bus_enable (m, true);
@@ -684,10 +688,6 @@ static int renesas_i3c_daa(struct i3c_master_controller *m)renesas_writel (i3c->regs,DATBAS (pos),datbas_dvdyad_with_parity (ret)); } -init_completion (&xfer->comp); - cmd = xfer->cmds; - cmd->rx_count =0 ; - ret =renesas_i3c_get_free_pos (i3c);if (ret <0 )return ret;
@@ -779,13 +779,13 @@ static int renesas_i3c_send_ccc_cmd(struct i3c_master_controller *m,if (!xfer)return -ENOMEM ; -renesas_i3c_bus_enable (m, true); -init_completion (&xfer->comp); cmd = xfer->cmds; cmd->rnw = ccc->rnw; cmd->cmd0 =0 ; +renesas_i3c_bus_enable (m, true); +/* Calculate the command descriptor. */ switch (ccc->id) {case I3C_CCC_SETDASA :
@@ -835,15 +835,15 @@ static int renesas_i3c_i3c_xfers(struct i3c_dev_desc *dev, struct i3c_xfer *i3c_struct renesas_i3c_i2c_dev_data *data =i3c_dev_get_master_data (dev);int i; -/* Enable I3C bus. */ -renesas_i3c_bus_enable (m, true); - struct renesas_i3c_xfer *xfer __free(kfree) = renesas_i3c_alloc_xfer(i3c, 1);if (!xfer)return -ENOMEM ;init_completion (&xfer->comp); +/* Enable I3C bus. */ +renesas_i3c_bus_enable (m, true); +for (i =0 ; i < i3c_nxfers; i++) {struct renesas_i3c_cmd *cmd = xfer->cmds;
@@ -964,12 +964,12 @@ static int renesas_i3c_i2c_xfers(struct i2c_dev_desc *dev,if (!xfer)return -ENOMEM ; -renesas_i3c_bus_enable (m, false); -init_completion (&xfer->comp); xfer->is_i2c_xfer = true; cmd = xfer->cmds; +renesas_i3c_bus_enable (m, false); +if (!(renesas_readl (i3c->regs,BCST ) &BCST_BFREF )) { cmd->err = -EBUSY ;return cmd->err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1267/1815 i3c: renesas: Dont register devices when ENTDAA times out
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tommaso Merciai <[email protected]>
[ Upstream commit b6e56fd8c8a8ac7992868a28702192372ab04015 ]
renesas_i3c_daa() derives the number of newly assigned dynamic addresses from cmd->rx_count, which the response ISR sets to the number of address slots ENTDAA left unassigned. It starts out as zero, which already means "every address was assigned", so a timed out transfer leaves that value in place and it gets used as a result.
On a bus with no target connected the ENTDAA times out and the driver registers RENESAS_I3C_MAX_DEVS devices that are not there, each costing the core two seconds on a GETPID that can only time out:
i3c i3c-0: Failed to add I3C device at address 9, error -110
...
i3c i3c-0: Failed to add I3C device at address 16, error -110
Start from maxdevs instead: no address is assigned before ENTDAA runs, and the existing rx_count >= maxdevs check then reports an empty bus.
--- drivers/i3c/master/renesas-i3c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i3c/master/renesas-i3c.c +1 -1
@@ -665,7 +665,7 @@ static int renesas_i3c_daa(struct i3c_master_controller *m)init_completion (&xfer->comp); cmd = xfer->cmds; - cmd->rx_count =0 ; + cmd->rx_count = i3c->maxdevs;/* Enable I3C bus. */ renesas_i3c_bus_enable (m, true);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1268/1815 arm64: dts: turris-mox: fix usb3 phys
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomáš Macholda <[email protected]>
[ Upstream commit 0c2a8eed95160e41b367a1fa605a2c1b24a9639a ]
After commit 00e6d608fe80b0f6 ("arm64: dts: marvell: armada-37xx: swap PHYs' order in USB3 controller node") swapped USB3 PHY order, USB initialization breaks on Turris MOX.
This regression was exposed by commit 91ddf6f722084383 ("phy: marvell:
mvebu-a3700-utmi: fix incorrect USB2_PHY_CTRL register access") which made USB2 devices not work at all.
Fix the issue by explicitly adding all USB3 PHYs and PHY names to Turris MOX device-tree.
--- arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts +2 -1
@@ -290,7 +290,8 @@ connector { &usb3 { status = "okay"; - phys = <&comphy2 0>; + phys = <&usb2_utmi_otg_phy>, <&comphy2 0>; + phy-names = "usb2-phy", "usb3-phy"; }; &mdio {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1269/1815 ARM: dts: helios4: add vcc-supply to EEPROM
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 ef65cf08bd1aa723de2854d02fb8eb8cca273c90 ]
The at24 driver requests a 'vcc' supply for the EEPROM, producing 'supply vcc not found, using dummy regulator' at boot when the property is missing.
The EEPROM sits on the Helios 4 and is powered by the same always-on 3.3V rail used by other on-board I2C devices. Add vcc-supply = <®_3p3v> to silence the warning.
--- arch/arm/boot/dts/marvell/armada-388-helios4.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/marvell/armada-388-helios4.dts +4 -0
@@ -201,6 +201,10 @@ temp_sensor: temp@4c { reg = <0x4c>; vcc-supply = <®_3p3v>; }; + + eeprom@53 { + vcc-supply = <®_3p3v>; + }; }; i2c@11100 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1270/1815 ARM: dts: helios4: add vcc-supply to GPIO expander
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 c23988f84496e937dd255564cb30bec67608dcc6 ]
The pca953x driver requests a 'vcc' supply, producing:
pca953x 0-0020: supply vcc not found, using dummy regulator
The PCA9655 (PCA9555-compatible) expander is powered by the same always-on 3.3V rail as the other I2C devices on the bus. Add vcc-supply = <®_3p3v> to silence the warning.
--- arch/arm/boot/dts/marvell/armada-388-helios4.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/marvell/armada-388-helios4.dts +1 -0
@@ -169,6 +169,7 @@ expander0: gpio-expander@20 { gpio-controller; #gpio-cells = <2>; reg = <0x20>; + vcc-supply = <®_3p3v>; pinctrl-names = "default"; pinctrl-0 = <&pca0_pins>; interrupt-parent = <&gpio0>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1271/1815 ARM: dts: helios4: add SATA regulator supplies
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 7a90520e8c9a8f48fe6f3e741cf34d8c2b6dbc61 ]
The ahci-mvebu driver and libahci_platform request three supplies on SATA controller and port nodes:
- ahci-supply (controller power)
- phy-supply (PHY power)
- target-supply (disk power per port)
Without them the regulator core prints notices at boot, e.g.:
supply ahci not found, using dummy regulator supply phy not found, using dummy regulator supply target not found, using dummy regulator
The SATA controller and PHY inside the Armada 388 SoC are powered by the 3.3V I/O rail; the four disk bays are powered by the 5V HDD rail. Wire the existing fixed regulators accordingly.
--- arch/arm/boot/dts/marvell/armada-388-helios4.dts | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/boot/dts/marvell/armada-388-helios4.dts +8 -0
@@ -222,13 +222,17 @@ sata@a8000 { status = "okay"; #address-cells = <1>; #size-cells = <0>; + ahci-supply = <®_3p3v>; + phy-supply = <®_3p3v>; sata0: sata-port@0 { reg = <0>; + target-supply = <®_5p0v_hdd>; }; sata1: sata-port@1 { reg = <1>; + target-supply = <®_5p0v_hdd>; }; };
@@ -236,13 +240,17 @@ sata@e0000 { status = "okay"; #address-cells = <1>; #size-cells = <0>; + ahci-supply = <®_3p3v>; + phy-supply = <®_3p3v>; sata2: sata-port@0 { reg = <0>; + target-supply = <®_5p0v_hdd>; }; sata3: sata-port@1 { reg = <1>; + target-supply = <®_5p0v_hdd>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1272/1815 perf script: Fix metric_evlist leak in script_find_metrics
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit d4171c774070e9d1c45324e3667d7dcba9be7749 ]
Fix a memory leak in script_find_metrics() where metric_evlist is leaked when returning early on error paths.
--- tools/perf/builtin-script.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-script.c +1 -1
@@ -2276,8 +2276,8 @@ static int script_find_metrics(const struct pmu_metric *pm, }pr_debug ("Found metric '%s' whose evsels match those of in the perf data\n" , pm->metric_name); -evlist__put (metric_evlist); out: +evlist__put (metric_evlist);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1273/1815 perf stat: Fix evsel_list leak in cmd_stat
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 340641a4b5fff4f4b12261c9d92169f6e2ea11f4 ]
Fix a memory leak in cmd_stat() where evsel_list is leaked if an error occurs while opening the output file.
--- tools/perf/builtin-stat.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/perf/builtin-stat.c +6 -3
@@ -2726,7 +2726,8 @@ int cmd_stat(int argc, const char **argv) output =fopen (output_name, mode);if (!output) {perror ("failed to create output file" ); -return -1 ; + status =-1 ; + goto out; }if (!stat_config.json_output) {clock_gettime (CLOCK_REALTIME , &tm);
@@ -2737,7 +2738,8 @@ int cmd_stat(int argc, const char **argv) output =fdopen (output_fd, mode);if (!output) {perror ("Failed opening logfd" ); -return -errno; + status = -errno; + goto out; } }
@@ -2746,7 +2748,8 @@ int cmd_stat(int argc, const char **argv)parse_options_usage (stat_usage, stat_options,"o" ,1 );parse_options_usage (NULL , stat_options,"log-fd" ,0 );parse_options_usage (NULL , stat_options,"interval-clear" ,0 ); -return -1 ; + status =-1 ; + goto out; } stat_config.output = output;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1274/1815 perf tools: Fix sb_evlist leaks in top and record
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 08e96e3c737bf63d917c6c4e0bb67450ad53f1d8 ]
Fix a memory leak in cmd_top() where top.sb_evlist was not freed if evlist__add_bpf_sb_event() fails. Note that evlist__start_sb_thread() and evlist__stop_sb_thread() take ownership of the evlist and free it, so we must only free it if we fail before starting the thread. Also set top.sb_evlist to NULL to prevent use-after-free bugs.
Apply the same fix to builtin-record.c to avoid leaking rec->sb_evlist and calling pthread_join on uninitialized threads in the error path.
--- tools/perf/builtin-record.c | 2 ++ tools/perf/builtin-top.c | 2 ++ 2 files changed, 4 insertions(+)
tools/perf/builtin-record.c +2 -0
@@ -2258,6 +2258,8 @@ static int record__setup_sb_evlist(struct record *rec)if (evlist__add_bpf_sb_event (rec->sb_evlist,perf_session__env (rec->session))) {pr_err ("Couldn't ask for PERF_RECORD_BPF_EVENT side band events.\n." ); +evlist__put (rec->sb_evlist); + rec->sb_evlist =NULL ;return -1 ; } }
tools/perf/builtin-top.c +2 -0
@@ -1881,6 +1881,8 @@ int cmd_top(int argc, const char **argv)if (evlist__add_bpf_sb_event (top.sb_evlist, &host_env)) {pr_err ("Couldn't ask for PERF_RECORD_BPF_EVENT side band events.\n." ); status = -EINVAL ; +evlist__put (top.sb_evlist); + top.sb_evlist =NULL ; goto out_put_evlist; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1275/1815 perf python: Fix memory leak in pyrf_evlist__get_pollfd
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 38d778acbee3ee96c14e33863b747e674d975eae ]
Fix a Python list object leak in pyrf_evlist__get_pollfd() by adding a missing Py_DECREF on the error exit path.
--- tools/perf/util/python.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/python.c +3 -0
@@ -1781,6 +1781,8 @@ static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist, evlist = pevlist->evlist; list =PyList_New (0 ); +if (!list) +return NULL ;for (i =0 ; i <evlist__core (evlist)->pollfd.nr; ++i) {PyObject *file;
@@ -1799,6 +1801,7 @@ static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist,return list; free_list: +Py_XDECREF (list);return PyErr_NoMemory (); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1276/1815 perf synthetic-events: Fix uninitialized pthread_join
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 54ba44db4dddc4ca06b49bae0f9d6c5861430b18 ]
In perf_event__synthesize_threads(), fix an uninitialized pthread_join() call when thread creation fails by only joining the successfully created threads.
--- tools/perf/util/synthetic-events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/synthetic-events.c +2 -2
@@ -1104,8 +1104,8 @@ int perf_event__synthesize_threads(const struct perf_tool *tool, } err =0 ; out_join: -for (i =0 ; i < thread_nr; i++) -pthread_join (synthesize_threads[i],NULL ); +for (j =0 ; j < i; j++) +pthread_join (synthesize_threads[j],NULL );free (args); free_threads:free (synthesize_threads);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1277/1815 perf test: Fix skiplist leak in cmd_test
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 44e82c4d2ff37f073946b594840fd549ab6b9fb8 ]
Fix a memory leak in cmd_test() where skiplist was not freed on exit paths.
--- tools/perf/tests/builtin-test.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/perf/tests/builtin-test.c +7 -2
@@ -1796,9 +1796,14 @@ int cmd_test(int argc, const char **argv)rlimit__bump_memlock (); suites =build_suites (); -if (!suites) -return errno ? -errno : -ENOMEM ; +if (!suites) { +int err = errno; + +intlist__delete (skiplist); +return err ? -err : -ENOMEM ; + } ret =__cmd_test (suites, argc, argv, skiplist);free (suites); +intlist__delete (skiplist);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1278/1815 perf python: Check counts_values size in set_values
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 612aca22a978d43f6e6765272676a17afdba8572 ]
The set_values function incorrectly assumed the list contained exactly 5 elements. Add a check to prevent out-of-bounds access.
--- tools/perf/util/python.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)
tools/perf/util/python.c +30 -8
@@ -875,11 +875,11 @@ static void pyrf_counts_values__delete(struct pyrf_counts_values *pcounts_values 0, help }static PyMemberDef pyrf_counts_values_members[] = { -counts_values_member_def (val,T_ULONG ,"Value of event" ), -counts_values_member_def (ena,T_ULONG ,"Time for which enabled" ), -counts_values_member_def (run,T_ULONG ,"Time for which running" ), -counts_values_member_def (id,T_ULONG ,"Unique ID for an event" ), -counts_values_member_def (lost,T_ULONG ,"Num of lost samples" ), +counts_values_member_def (val,T_ULONGLONG ,"Value of event" ), +counts_values_member_def (ena,T_ULONGLONG ,"Time for which enabled" ), +counts_values_member_def (run,T_ULONGLONG ,"Time for which running" ), +counts_values_member_def (id,T_ULONGLONG ,"Unique ID for an event" ), +counts_values_member_def (lost,T_ULONGLONG ,"Num of lost samples" ), { .name =NULL , }, };
@@ -889,8 +889,15 @@ static PyObject *pyrf_counts_values_get_values(struct pyrf_counts_values *self,if (!vals)return NULL ; -for (int i =0 ; i <5 ; i++) -PyList_SetItem (vals, i,PyLong_FromLong (self->values.values[i])); +for (int i =0 ; i <5 ; i++) { +PyObject *val =PyLong_FromUnsignedLongLong (self->values.values[i]); + +if (!val) { +Py_DECREF (vals); +return NULL ; + } +PyList_SetItem (vals, i, val); + }return vals; }
@@ -901,19 +908,34 @@ static int pyrf_counts_values_set_values(struct pyrf_counts_values *self, PyObjePy_ssize_t size;PyObject *item =NULL ; +if (list ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } +if (!PyList_Check (list)) {PyErr_SetString (PyExc_TypeError,"Value assigned must be a list" );return -1 ; } size =PyList_Size (list); +if (size !=5 ) { +PyErr_SetString (PyExc_ValueError,"List must have exactly 5 entries" ); +return -1 ; + } +for (Py_ssize_t i =0 ; i < size; i++) { +unsigned long long val; + item =PyList_GetItem (list, i);if (!PyLong_Check (item)) {PyErr_SetString (PyExc_TypeError,"List members should be numbers" );return -1 ; } - self->values.values[i] =PyLong_AsLong (item); + val =PyLong_AsUnsignedLongLong (item); +if (val == (unsigned long long )-1 &&PyErr_Occurred ()) +return -1 ; + self->values.values[i] = val; }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1279/1815 perf python: Handle Py_None for thread and cpu maps
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 054d1c7717b95d9089cd3b80e9e85fe1f2ea0471 ]
The python stubs allow passing None for threads and cpus to the perf.parse_events() and perf.parse_metrics() bindings. However, PyArg_ParseTuple parses None into a Py_None object, which is not a NULL pointer. Because the C code lacked an explicit check for Py_None, it would cast Py_None to a pyrf_thread_map/pyrf_cpu_map struct pointer and dereference it, causing a memory corruption crash.
Fix this pre-existing issue by explicitly checking for Py_None alongside NULL in pyrf__parse_events, pyrf__parse_metrics, and pyrf_evsel__open.
Stable-dep-of: 9a142beb1eba ("perf python: Validate CPU and thread maps in pyrf_evsel__open")
--- tools/perf/util/python.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
tools/perf/util/python.c +10 -6
@@ -1107,10 +1107,10 @@ static PyObject *pyrf_evsel__open(struct pyrf_evsel *pevsel, &pcpus, &pthreads, &group, &inherit))return NULL ; -if (pthreads !=NULL ) +if (pthreads !=NULL && pthreads != Py_None) threads = ((struct pyrf_thread_map *)pthreads)->threads; -if (pcpus !=NULL ) +if (pcpus !=NULL && pcpus != Py_None) cpus = ((struct pyrf_cpu_map *)pcpus)->cpus; evsel->core.attr.inherit = inherit;
@@ -2333,8 +2333,10 @@ static PyObject *pyrf__parse_events(PyObject *self, PyObject *args)return NULL ; } - threads = pthreads ? ((struct pyrf_thread_map *)pthreads)->threads :NULL ; - cpus = pcpus ? ((struct pyrf_cpu_map *)pcpus)->cpus :NULL ; + threads = (pthreads && pthreads != Py_None) ? + ((struct pyrf_thread_map *)pthreads)->threads :NULL ; + cpus = (pcpus && pcpus != Py_None) ? + ((struct pyrf_cpu_map *)pcpus)->cpus :NULL ;parse_events_error__init (&err);perf_evlist__set_maps (evlist__core (evlist), cpus, threads);
@@ -2367,8 +2369,10 @@ static PyObject *pyrf__parse_metrics(PyObject *self, PyObject *args)return NULL ; } - threads = pthreads ? ((struct pyrf_thread_map *)pthreads)->threads :NULL ; - cpus = pcpus ? ((struct pyrf_cpu_map *)pcpus)->cpus :NULL ; + threads = (pthreads && pthreads != Py_None) ? + ((struct pyrf_thread_map *)pthreads)->threads :NULL ; + cpus = (pcpus && pcpus != Py_None) ? + ((struct pyrf_cpu_map *)pcpus)->cpus :NULL ;perf_evlist__set_maps (evlist__core (evlist), cpus, threads); ret = metricgroup__parse_groups(evlist, pmu ?: "all",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1280/1815 perf python: Validate CPU and thread maps in pyrf_evsel__open
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 9a142beb1eba42b986dc7016f4fc1a3bc28b8c09 ]
Add explicit Py_TYPE checks to ensure the arguments passed are actually of the correct pyrf_thread_map and pyrf_cpu_map types.
--- tools/perf/util/python.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
tools/perf/util/python.c +12 -2
@@ -1107,11 +1107,21 @@ static PyObject *pyrf_evsel__open(struct pyrf_evsel *pevsel, &pcpus, &pthreads, &group, &inherit))return NULL ; -if (pthreads !=NULL && pthreads != Py_None) +if (pthreads !=NULL && pthreads != Py_None) { +if (!PyObject_TypeCheck (pthreads, &pyrf_thread_map__type)) { +PyErr_SetString (PyExc_TypeError,"threads must be a thread_map" ); +return NULL ; + } threads = ((struct pyrf_thread_map *)pthreads)->threads; + } -if (pcpus !=NULL && pcpus != Py_None) +if (pcpus !=NULL && pcpus != Py_None) { +if (!PyObject_TypeCheck (pcpus, &pyrf_cpu_map__type)) { +PyErr_SetString (PyExc_TypeError,"cpus must be a cpu_map" ); +return NULL ; + } cpus = ((struct pyrf_cpu_map *)pcpus)->cpus; + } evsel->core.attr.inherit = inherit;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1281/1815 perf python: Validate attribute setters in pyrf_evsel
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 0b274050c4d427828595c12c2e4e53d98612b4f9 ]
If val is NULL when setting an attribute, PyErr_SetString should be called as deleting the attribute isn't supported. In addition, ensure PyErr_Occurred is checked before setting the attribute to avoid setting a garbage value.
--- tools/perf/util/python.c | 89 ++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 12 deletions(-)
tools/perf/util/python.c +77 -12
@@ -1295,6 +1295,11 @@ static int pyrf_evsel__set_tracking(PyObject *self, PyObject *val, void *closureCHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + is_true =PyObject_IsTrue (val);if (is_true <0 )return -1 ;
@@ -1306,11 +1311,21 @@ static int pyrf_evsel__set_tracking(PyObject *self, PyObject *val, void *closurestatic int pyrf_evsel__set_attr_config (PyObject *self,PyObject *val,void *closure__maybe_unused ) {struct pyrf_evsel *pevsel = (void *)self; +unsigned long long new_val;CHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); - pevsel->evsel->core.attr.config =PyLong_AsUnsignedLongLong (val); -return PyErr_Occurred () ?-1 :0 ; +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + + new_val =PyLong_AsUnsignedLongLong (val); +if (PyErr_Occurred ()) +return -1 ; + + pevsel->evsel->core.attr.config = new_val; +return 0 ; }static PyObject *pyrf_evsel__get_attr_config (PyObject *self,void *closure__maybe_unused )
@@ -1325,11 +1340,21 @@ static PyObject *pyrf_evsel__get_attr_config(PyObject *self, void *closure __maystatic int pyrf_evsel__set_attr_read_format (PyObject *self,PyObject *val,void *closure__maybe_unused ) {struct pyrf_evsel *pevsel = (void *)self; +unsigned long long new_val;CHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); - pevsel->evsel->core.attr.read_format =PyLong_AsUnsignedLongLong (val); -return PyErr_Occurred () ?-1 :0 ; +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + + new_val =PyLong_AsUnsignedLongLong (val); +if (PyErr_Occurred ()) +return -1 ; + + pevsel->evsel->core.attr.read_format = new_val; +return 0 ; }static PyObject *pyrf_evsel__get_attr_read_format (PyObject *self,void *closure__maybe_unused )
@@ -1344,11 +1369,21 @@ static PyObject *pyrf_evsel__get_attr_read_format(PyObject *self, void *closurestatic int pyrf_evsel__set_attr_sample_period (PyObject *self,PyObject *val,void *closure__maybe_unused ) {struct pyrf_evsel *pevsel = (void *)self; +unsigned long long new_val;CHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); - pevsel->evsel->core.attr.sample_period =PyLong_AsUnsignedLongLong (val); -return PyErr_Occurred () ?-1 :0 ; +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + + new_val =PyLong_AsUnsignedLongLong (val); +if (PyErr_Occurred ()) +return -1 ; + + pevsel->evsel->core.attr.sample_period = new_val; +return 0 ; }static PyObject *pyrf_evsel__get_attr_sample_period (PyObject *self,void *closure__maybe_unused )
@@ -1363,11 +1398,21 @@ static PyObject *pyrf_evsel__get_attr_sample_period(PyObject *self, void *closurstatic int pyrf_evsel__set_attr_sample_type (PyObject *self,PyObject *val,void *closure__maybe_unused ) {struct pyrf_evsel *pevsel = (void *)self; +unsigned long long new_val;CHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); - pevsel->evsel->core.attr.sample_type =PyLong_AsUnsignedLongLong (val); -return PyErr_Occurred () ?-1 :0 ; +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + + new_val =PyLong_AsUnsignedLongLong (val); +if (PyErr_Occurred ()) +return -1 ; + + pevsel->evsel->core.attr.sample_type = new_val; +return 0 ; }static PyObject *pyrf_evsel__get_attr_sample_type (PyObject *self,void *closure__maybe_unused )
@@ -1391,11 +1436,21 @@ static PyObject *pyrf_evsel__get_attr_size(PyObject *self, void *closure __maybestatic int pyrf_evsel__set_attr_type (PyObject *self,PyObject *val,void *closure__maybe_unused ) {struct pyrf_evsel *pevsel = (void *)self; +unsigned long new_val;CHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); - pevsel->evsel->core.attr.type =PyLong_AsUnsignedLong (val); -return PyErr_Occurred () ?-1 :0 ; +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + + new_val =PyLong_AsUnsignedLong (val); +if (PyErr_Occurred ()) +return -1 ; + + pevsel->evsel->core.attr.type = new_val; +return 0 ; }static PyObject *pyrf_evsel__get_attr_type (PyObject *self,void *closure__maybe_unused )
@@ -1410,11 +1465,21 @@ static PyObject *pyrf_evsel__get_attr_type(PyObject *self, void *closure __maybestatic int pyrf_evsel__set_attr_wakeup_events (PyObject *self,PyObject *val,void *closure__maybe_unused ) {struct pyrf_evsel *pevsel = (void *)self; +unsigned long new_val;CHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); - pevsel->evsel->core.attr.wakeup_events =PyLong_AsUnsignedLong (val); -return PyErr_Occurred () ?-1 :0 ; +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + + new_val =PyLong_AsUnsignedLong (val); +if (PyErr_Occurred ()) +return -1 ; + + pevsel->evsel->core.attr.wakeup_events = new_val; +return 0 ; }static PyObject *pyrf_evsel__get_attr_wakeup_events (PyObject *self,void *closure__maybe_unused )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1282/1815 perf python: Fix count_values memory leak in pyrf_evsel__read
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit cb45ede21d02cc85de18ce6b60a51a7449f4179b ]
In pyrf_evsel__read, if PyArg_ParseTuple fails, the allocated count_values is leaked. Move the allocation of count_values after the PyArg_ParseTuple call to prevent the memory leak.
--- tools/perf/util/python.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
tools/perf/util/python.c +4 -5
@@ -1199,11 +1199,6 @@ static PyObject *pyrf_evsel__read(struct pyrf_evsel *pevsel,CHECK_INITIALIZED (evsel,"evsel" ); - count_values = PyObject_New(struct pyrf_counts_values, - &pyrf_counts_values__type); -if (!count_values) -return NULL ; -if (!PyArg_ParseTuple (args,"ii" , &cpu, &thread))return NULL ;
@@ -1222,6 +1217,10 @@ static PyObject *pyrf_evsel__read(struct pyrf_evsel *pevsel,if (evsel__ensure_counts (evsel))return PyErr_NoMemory (); + count_values = PyObject_New(struct pyrf_counts_values, &pyrf_counts_values__type); +if (!count_values) +return NULL ; +/* Set up pointers to the old and newly read counter values. */ old_count =perf_counts (evsel->prev_raw_counts, cpu_idx, thread_idx); new_count =perf_counts (evsel->counts, cpu_idx, thread_idx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1283/1815 perf python: Fix memory leak in pyrf__metrics_cb
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 1ec13016ba36f1bf7dc61e054068fe00f2f628c7 ]
In pyrf__metrics_cb, PyDict_SetItem does not steal the reference of the key and value, so they need to be decref'ed after successful insertion to avoid memory leaks.
--- tools/perf/util/python.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/python.c +2 -0
@@ -2508,6 +2508,8 @@ static int pyrf__metrics_cb(const struct pmu_metric *pm,Py_XDECREF (dict);return -ENOMEM ; } +Py_DECREF (key); +Py_DECREF (value); if (!add_to_dict(dict, "MetricName", pm->metric_name) || !add_to_dict(dict, "PMU", pm->pmu) ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1284/1815 perf synthetic-events: Fix divide by zero in perf_event__synthesize_threads
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 16a12a54e9a1151a37aab74914a51b86f7f58d0e ]
If scandir() finds no matching tasks in /proc, n is 0. If thread_nr is > 1, we bypass the single-thread fast path and then clamp thread_nr to n, making it 0. This results in a divide by zero when calculating num_per_thread.
Handle n <= 1 early to use the single-thread fast path and prevent the crash.
--- tools/perf/util/synthetic-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/synthetic-events.c +1 -1
@@ -1058,7 +1058,7 @@ int perf_event__synthesize_threads(const struct perf_tool *tool,else thread_nr = nr_threads_synthesize; -if (thread_nr <=1 ) { +if (thread_nr <=1 || n <=1 ) { err = __perf_event__synthesize_threads(tool, process, machine, needs_mmap, mmap_data,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1285/1815 apparmor: fix integer overflow in verify_tags() bounds check
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabrice Derepas <[email protected]>
[ Upstream commit 465946d3c560c0137e6a180ba054dddc4d049f5a ]
verify_tags() validates the tagset table unpacked from a policy blob. For each set it reads a count and checks that advancing the index by that count stays inside sets.table[]:
u32 cnt = tags->sets.table[i];
if (i+cnt >= tags->sets.size) {i, cnt and sets.size are all u32, so i+cnt is evaluated modulo 2^32. sets.table[] is filled by unpack_tagsets() with aa_unpack_u32(), so every entry is a raw unbounded 32-bit word taken from the policy blob, and verify_tags() is the function that is supposed to validate it. A count close to U32_MAX makes the sum wrap to a small value, the guard passes, and the inner loop then walks sets.table[++i] past the end of the kcalloc(size, sizeof(u32)) allocation.
Note that sets.size is bounded by 65535, because unpack_tagsets() reads it with aa_unpack_array() as a u16, so the wrap cannot be reached by growing the table; it is reached purely through the attacker-supplied count.
With sets.size = 2 and sets.table = { 0, 0xffffffff }:
i = 0: cnt = 0, guard 0 + 0 >= 2 is false, inner loop does not run i = 1: cnt = 0xffffffff, guard (1 + 0xffffffff) mod 2^32 == 0 >= 2 is
false, so the guard is bypassed and the inner loop reads sets.table[2] -- one element past a two element allocation
The walk continues until an out-of-bounds value happens to be >= hdrs.size or the access faults, so a crafted policy yields an out-of-bounds read on the policy load path (aa_replace_profiles -> aa_unpack -> unpack_policydb -> unpack_tags -> verify_tags). unpack_tags() runs before the perms and DFA tables are unpacked, so no other table needs to be well formed to reach it.
Policy load is gated by aa_may_manage_policy(), which checks CAP_MAC_ADMIN relative to the subject's own user namespace rather than the init user namespace, so with the default unprivileged_userns_apparmor_policy=1 the path is reachable from an unprivileged task in a matched-level nested namespace, not only by a globally privileged one.
Perform the addition in u64 so that it cannot wrap, restoring the intended i + cnt < sets.size guarantee.
--- security/apparmor/policy_unpack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/apparmor/policy_unpack.c +1 -1
@@ -730,7 +730,7 @@ static bool verify_tags(struct aa_tags_struct *tags, const char **info)/* count followed by count indexes into hdrs */ u32 cnt = tags->sets.table[i]; -if (i+cnt >= tags->sets.size) { +if ((u64 )i + cnt >= tags->sets.size) {AA_DEBUG (DEBUG_UNPACK ,"tagset too large %d+%d > sets.table[%d]" , i, cnt, tags->sets.size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1286/1815 fbdev: tdfxfb: fix PCI enable cleanup with pcim_enable_device()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 95a627143a696f70e17be5ed3b1e733bb6724b46 ]
tdfxfb_probe() enables the PCI device with pci_enable_device(), but several failure paths after that point return without disabling it. The framebuffer_alloc() failure path returns -ENOMEM directly, and the later shared out_err path releases the framebuffer and returns -ENXIO without balancing the PCI enable state.
The successful probe path has the same imbalance because tdfxfb_remove() releases the framebuffer, mappings and regions, but never calls pci_disable_device().
Use pcim_enable_device() so the PCI device is disabled automatically on probe failure and driver detach.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/video/fbdev/tdfxfb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/tdfxfb.c +1 -1
@@ -1385,7 +1385,7 @@ static int tdfxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err)return err; - err =pci_enable_device (pdev); + err =pcim_enable_device (pdev);if (err) {printk (KERN_ERR "tdfxfb: Can't enable pdev: %d\n" , err);return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1287/1815 fbdev: kyro: Validate overlay viewport coordinates
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danila Chernetsov <[email protected]>
[ Upstream commit 7b5c7bc55e13e7f5ac7b1eaf5c6d690389ea5ee3 ]
The overlay viewport end coordinates are computed from the viewport origin and dimensions using 32-bit unsigned arithmetic. Large input values can cause these calculations to wrap around before the resulting coordinates are passed to SetOverlayViewPort().
SetOverlayViewPort() packs the viewport coordinates into 16-bit register fields. The X coordinates are additionally adjusted by +2 and +1 before being written. Validate the coordinate calculations for 32-bit wraparound and ensure that the adjusted coordinates fit within their 16-bit register fields before calling SetOverlayViewPort().
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/video/fbdev/kyro/fbdev.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/video/fbdev/kyro/fbdev.c +23 -1
@@ -369,6 +369,9 @@ static int kyro_dev_overlay_create(u32 ulWidth,static int kyro_dev_overlay_viewport_set (u32 x,u32 y,u32 ulWidth,u32 ulHeight) { +u32 right; +u32 bottom; +if (deviceInfo.ulOverlayOffset ==0 )/* probably haven't called CreateOverlay yet */ return -EINVAL ;
@@ -378,11 +381,30 @@ static int kyro_dev_overlay_viewport_set(u32 x, u32 y, u32 ulWidth, u32 ulHeight (x < 2 && ulWidth + 2 == 0))return -EINVAL ; +/* +* SetOverlayViewPort() adjusts X coordinates by +2 (left) and +1 +* (right) before packing them into 16-bit register fields. +*/ +if (x >U16_MAX -2 || y >U16_MAX ) +return -EINVAL ; + + right = x + ulWidth; + bottom = y + ulHeight; + +if (right < x || bottom < y) +return -EINVAL ; + + right--; + bottom--; + +if (right >U16_MAX -1 || bottom >U16_MAX ) +return -EINVAL ; +/* Stop Ramdac Output */ DisableRamdacOutput (deviceInfo.pSTGReg);SetOverlayViewPort (deviceInfo.pSTGReg, - x, y, x + ulWidth -1 , y + ulHeight -1 ); + x, y, right, bottom);EnableOverlayPlane (deviceInfo.pSTGReg);/* Start Ramdac Output */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1288/1815 fbdev: clps711x-fb: Remove unreachable unregister_framebuffer() call
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 39dd7598fbe90c5b4bb77fb34d8f3dad8385d11c ]
The unregister_framebuffer() call in clps711x_fb_probe() is unreachable. register_framebuffer() failure jumps to the unwind label, while success returns immediately.
Remove it.
Found with Clang's -Wunreachable-code.
--- drivers/video/fbdev/clps711x-fb.c | 2 -- 1 file changed, 2 deletions(-)
drivers/video/fbdev/clps711x-fb.c +0 -2
@@ -329,8 +329,6 @@ static int clps711x_fb_probe(struct platform_device *pdev)return 0 ; -unregister_framebuffer (info); - out_fb_dealloc_cmap:regmap_update_bits (cfb->syscon,SYSCON_OFFSET ,SYSCON1_LCDEN ,0 );fb_dealloc_cmap (&info->cmap);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1289/1815 iommu/dma: Restore locking around msi_page_list
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Jones <[email protected]>
[ Upstream commit 5a9e89ea34e0e34ac5d7e949042d665533549e40 ]
Unlike a group's default domain, which is always freshly allocated and privately owned (iommu_group_alloc_default_domain()), VFIO type1's legacy container merges any newly attached group into an existing domain whenever their iommu_ops and cache-coherency enforcement match.
iommu_dma_get_msi_page() only asserts the caller's own group mutex is held (iommu_group_mutex_assert()). On an IOMMU that publishes IOMMU_RESV_SW_MSI, e.g. ARM SMMU, a VM with two such devices assigned through the legacy container can have their guest drivers probe and allocate MSIs in parallel; each host-side VFIO_DEVICE_SET_IRQS lands on a different device fd and group mutex, but both devices' domains are the same merged domain, so both can enter iommu_dma_get_msi_page() concurrently and corrupt msi_page_list.
commit 288683c92b1a ("iommu: Make iommu_dma_prepare_msi() into a generic operation") dropped the prior msi_prepare_lock on the reasoning that "each iommu_domain is unique to a group," which holds for default domains but not this VFIO type1 case. Restore the static lock, since it's only guarding a corner case and will likely never be contended.
iommufd avoids the equivalent problem by having its own callers (iommufd_sw_map_msi()) take a ctx-wide sw_msi_lock before ever reaching the shared list. VFIO type1 can't mirror that since it dispatches to iommu_dma_sw_msi() which is outside VFIO's jurisdiction.
--- drivers/iommu/dma-iommu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/iommu/dma-iommu.c +13 -0
@@ -2207,6 +2207,19 @@ static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev,dma_addr_t iova;int prot =IOMMU_WRITE |IOMMU_NOEXEC |IOMMU_MMIO ;size_t size =cookie_msi_granule (domain); +static DEFINE_MUTEX (msi_prepare_lock); + +/* +* Normally a device's default domain is only ever attached to that +* device's own group, and the group mutex held by +* iommu_group_mutex_assert()'s callers is enough on its own. A VFIO +* type1 container is the one case that breaks that assumption: it +* can merge devices from different groups onto one domain, so two +* devices' group mutexes don't serialize each other here. A static +* lock is sufficient due to the expectation that this is a corner +* case that will never be contended in practice. +*/ +guard (mutex)(&msi_prepare_lock); msi_addr &= ~(phys_addr_t)(size -1 );list_for_each_entry (msi_page, msi_page_list, list)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1290/1815 iommu/vt-d: Fix UCTP context table slot when copying root entries
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Desnes Nunes <[email protected]>
[ Upstream commit c6e63fc8e8fcefa5c32145dc0a3c82975b0ce152 ]
When translation is already enabled at boot (e.g. kdump), the vt-d driver copies context tables from the previous kernel's root table. In scalable mode, buses that only populate the upper root half (UCTP, devfn >= 0x80) should be written to ctxt_tbls[tbl_idx + 1] through copy_context_table(). However, the current copy path always uses tbl[tbl_idx + 0] in this situa- tion. Since idx wraps to 0 at devfn 0x80 due to a zeroed LCTP, new_ce for LCTP will be NULL and keep pos equals to 0. Thus, UCTP entries will be co- pied into tbl[tbl_idx + 0] instead of tbl[tbl_idx + 1], and written after- wards to root_entry[bus].lo instead of .hi in copy_translation_tables().
In short, devices on bus 0x80 with devfn >= 0x80 fail DMA with fault 0x39, which will break drivers running in kernels with translation pre-enabled. This fixes NO_PASID DMAR faults for UCTP-only buses such as:
DMAR: [DMA Read NO_PASID] Request device [80:14.0] fault addr 0xe81759000
[fault reason 0x39] SM: Present bit in Root Entry is clear
For instance, this fault yielded to locking issues between systemd and xHCI, blocking a system's reboot after a vmcore was captured with kdump:
systemd-udevd[246]: usb3: Worker [255] processing SEQNUM=2193 is taking a long time dracut-initqueue[277]: Timed out while waiting for udev queue to empty. systemd-udevd[246]: usb3: Worker [255] processing SEQNUM=2193 killed systemd-udevd[246]: usb3: Worker [255] terminated by signal 9 (KILL).
...
kdump[569]: saving vmcore complete
...
systemd-shutdown[1]: Rebooting.
INFO: task kworker/0:1:11 blocked for more than 122 seconds.
Not tainted 7.0.0-clean #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/0:1 state:D stack:0 pid:11 tgid:11 ppid:2 task_flags:0x4208160 flags:0x00080000
Workqueue: usb_hub_wq hub_event
Call Trace:
<TASK>
__schedule+0x299/0x5c0
schedule+0x27/0x80
schedule_timeout+0xbd/0x100
__wait_for_common+0x97/0x1b0
? __pfx_schedule_timeout+0x10/0x10
xhci_alloc_dev+0x9e/0x2b0
usb_alloc_dev+0x7a/0x3b0
hub_port_connect+0x285/0x960
hub_port_connect_change+0x94/0x290
port_event+0x4bb/0x840
hub_event+0x141/0x460
process_one_work+0x196/0x390
worker_thread+0x1af/0x320
? __pfx_worker_thread+0x10/0x10
kthread+0xe3/0x120
? __pfx_kthread+0x10/0x10
ret_from_fork+0x199/0x260
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
INFO: task systemd-shutdow:1 blocked for more than 122 seconds.
Not tainted 7.0.0-clean #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:systemd-shutdow state:D stack:0 pid:1 tgid:1 ppid:0 task_flags:0x400100 flags:0x00080000
Call Trace:
<TASK>
__schedule+0x299/0x5c0
schedule+0x27/0x80
schedule_preempt_disabled+0x15/0x30
__mutex_lock.constprop.0+0x547/0xac0
device_shutdown+0xac/0x1b0
kernel_restart+0x3a/0x70
__do_sys_reboot+0x147/0x240
do_syscall_64+0x11b/0x6a0
? handle_mm_fault+0x110/0x350
? do_user_addr_fault+0x206/0x680
? irqentry_exit+0x7a/0x4d0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
RIP: 0033:0x7fe2958da917
RSP: 002b:00007ffc5c458618 EFLAGS: 00000206 ORIG_RAX: 00000000000000a9
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fe2958da917
RDX: 0000000001234567 RSI: 0000000028121969 RDI: 00000000fee1dead
RBP: 00007ffc5c458790 R08: 0000000000000069 R09: 00000000ffffffff
R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000000
R13: 0000000000000000 R14: 00007ffc5c4588b8 R15: 0000000000000000
</TASK>
INFO: task systemd-shutdow:1 is blocked on a mutex likely owned by task kworker/0:1:11.--- drivers/iommu/intel/iommu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/iommu/intel/iommu.c +6 -4
@@ -1446,7 +1446,7 @@ static int copy_context_table(struct intel_iommu *iommu,struct context_entry **tbl, int bus, bool ext) { - int tbl_idx, pos = 0, idx, devfn, ret = 0, did; + int tbl_idx, tbl_slot = 0, idx, devfn, ret = 0, did;struct context_entry *new_ce =NULL , ce;struct context_entry *old_ce =NULL ;struct root_entry re;
@@ -1462,10 +1462,9 @@ static int copy_context_table(struct intel_iommu *iommu,if (idx ==0 ) {/* First save what we may have and clean up */ if (new_ce) { - tbl[tbl_idx] = new_ce; + tbl[tbl_idx + tbl_slot] = new_ce;__iommu_flush_cache (iommu, new_ce,VTD_PAGE_SIZE ); - pos =1 ; }if (old_ce)
@@ -1487,6 +1486,9 @@ static int copy_context_table(struct intel_iommu *iommu, } } +/* Track if saving UCTP or LCTP entries in scalable mode */ + tbl_slot = ext && devfn >=0x80 ?1 :0 ; + ret = -ENOMEM ; old_ce =memremap (old_ce_phys,PAGE_SIZE ,MEMREMAP_WB );
@@ -1515,7 +1517,7 @@ static int copy_context_table(struct intel_iommu *iommu, new_ce[idx] = ce; } - tbl[tbl_idx + pos] = new_ce; + tbl[tbl_idx + tbl_slot] = new_ce;__iommu_flush_cache (iommu, new_ce,VTD_PAGE_SIZE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1291/1815 iommu/vt-d: Clear Present bit before tearing down copied context entry
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit f532c57985b1a7d6b7e37e05506b46d413e5cca4 ]
copied_context_tear_down() zeroes the 128-bit context entry with context_clear_entry() while the Present bit is still set, and only then issues the context-cache and IOTLB invalidations. This leaves a window in which hardware can fetch a torn entry, with some fields already zeroed while Present is still set, leading to unpredictable behaviour or spurious faults. While x86 provides strong write ordering, the compiler may reorder the writes to the two 64-bit halves of the entry, and the hardware fetch is not guaranteed to be atomic with respect to multiple CPU writes.
There is no cacheline flush before the invalidation either, so on an IOMMU without coherent access to the context table the zeroed entry may not be visible to hardware at the point the invalidation is submitted.
Apply the same ownership handshake described in the VT-d spec, Section 6.5.3.3 ("Guidance to Software for Invalidations"): clear only the Present bit, flush it out to the IOMMU, perform the invalidations, and only then zero the remainder of the entry.
--- drivers/iommu/intel/iommu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iommu/intel/iommu.c +5 -1
@@ -1108,7 +1108,8 @@ static void copied_context_tear_down(struct intel_iommu *iommu,assert_spin_locked (&iommu->lock); did_old =context_domain_id (context); -context_clear_entry (context); +context_clear_present (context); +__iommu_flush_cache (iommu, context,sizeof (*context));if (did_old <cap_ndoms (iommu->cap)) { iommu->flush.flush_context(iommu, did_old,
@@ -1119,6 +1120,9 @@ static void copied_context_tear_down(struct intel_iommu *iommu, DMA_TLB_DSI_FLUSH); } +context_clear_entry (context); +__iommu_flush_cache (iommu, context,sizeof (*context)); +clear_context_copied (iommu, bus, devfn); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1292/1815 iommu/vt-d: Fix iopf_refcount leak on RID domain replacement
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit 236dd58fabd2e951b940a6ad88b81147899ed311 ]
intel_iommu_attach_device() enables IOPF for the new domain but never disables it for the old one. device_block_translation(), called at the start of the function, tears down translation but does not touch any IOPF state; blocking_domain_attach_dev() has to call iopf_for_domain_remove() explicitly before invoking it for exactly this reason.
identity_domain_attach_dev() has the same problem. Its comment claims that no PRI handling is needed because the device has been put in the blocking state, but the blocking state and the IOPF reference count are independent of each other.
As a result, replacing a domain that has an iopf_handler with another domain at RID level leaks a reference in info->iopf_refcount. The count never drops back to zero, so iopf_queue_remove_device() is never called and iommu_disable_pci_pri() triggers its WARN_ON(info->iopf_refcount) when the device is released.
The PASID paths already handle this correctly by way of iopf_for_domain_replace(); convert the two RID paths to do the same. Using the replace helper rather than a bare remove keeps the enable before the disable, so the reference count does not transiently reach zero and evict the device from the IOPF queue.
--- drivers/iommu/intel/iommu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/iommu/intel/iommu.c +8 -5
@@ -3141,13 +3141,13 @@ static int intel_iommu_attach_device(struct iommu_domain *domain,if (ret)return ret; - ret =iopf_for_domain_set (domain, dev); + ret =iopf_for_domain_replace (domain, old, dev);if (ret)return ret; ret =dmar_domain_attach_device (to_dmar_domain (domain), dev);if (ret) -iopf_for_domain_remove (domain, dev); +iopf_for_domain_replace (old, domain, dev);return ret; }
@@ -3850,10 +3850,13 @@ static int identity_domain_attach_dev(struct iommu_domain *domain,return 0 ;/* -* No PRI support with the global identity domain. No need to enable or -* disable PRI in this path as the iommu has been put in the blocking -* state. +* The identity domain has no iopf_handler, so no IOPF reference is +* taken for it. The reference held by the old domain must still be +* released here; putting the device in the blocking state above does +* not affect the IOPF reference count. */ +iopf_for_domain_remove (old, dev); +if (sm_supported (iommu)) ret =intel_pasid_setup_pass_through (iommu, dev,IOMMU_NO_PASID );else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1293/1815 iommu/vt-d: Tear down scalable-mode context on probe failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit c509fb73a1093a15accd7d43a61645d4b520f6ac ]
intel_pasid_setup_sm_context() walks a PCI device’s DMA aliases via pci_for_each_dma_alias() and programs a scalable-mode context entry for each RID. For a device with a dma_alias_mask, the callback is invoked once for the device’s own RID and once for each alias bit, all with the same pci_dev, so device_pasid_table_setup() runs for multiple RIDs.
pci_for_each_dma_alias() stops at the first callback error. Therefore, a failure partway through the walk can leave context entries for already processed RIDs present and still pointing to the device’s PASID table.
On this error path, intel_iommu_probe_device() currently jumps directly to intel_pasid_free_table(), which frees the PASID table without first tearing down those context entries. The IOMMU may then walk a present context entry whose PASID table pointer references freed memory.
intel_iommu_release_device() already performs teardown before freeing the table. Apply the same ordering on the probe failure path.
device_pasid_table_teardown() safely handles RIDs that were never
programmed: iommu_context_addr() returns NULL when no context table has been allocated, and clearing the Present bit of an already non-present entry is a no-op. So unwind is safe for both the alias that failed and any aliases not yet reached.
--- drivers/iommu/intel/iommu.c | 1 + 1 file changed, 1 insertion(+)
drivers/iommu/intel/iommu.c +1 -0
@@ -3322,6 +3322,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)return &iommu->iommu; free_table: +intel_pasid_teardown_sm_context (dev);intel_pasid_free_table (dev); clear_rbtree:device_rbtree_remove (info);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1294/1815 iommu/vt-d: Flush context cache with correct SID when tearing down aliases
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit c54e4ae971b98e8d650400137d332cee56c03f55 ]
domain_context_clear_one() and device_pasid_table_teardown() are both invoked once per DMA alias of a device. Each function locates the context entry using the bus/devfn pair provided by the pci_for_each_dma_alias() callback, then calls intel_context_flush_no_pasid(), which constructs a device-selective context-cache invalidation from info->bus and info->devfn (that is, always the requester ID of the device itself).
As a result, for every alias other than the device’s own RID, the context entry that was just cleared in memory is never invalidated in the context cache. Hardware may continue using that stale cached entry. In the scalable-mode teardown path, intel_pasid_free_table() can then free the PASID directory still referenced by that stale entry, allowing the IOMMU to walk freed memory.
Fix this by passing the source ID of the entry being torn down to intel_context_flush_no_pasid(), instead of deriving it from @info.
--- drivers/iommu/intel/iommu.c | 2 +- drivers/iommu/intel/iommu.h | 2 +- drivers/iommu/intel/pasid.c | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/iommu/intel/iommu.c +1 -1
@@ -1250,7 +1250,7 @@ static void domain_context_clear_one(struct device_domain_info *info, u8 bus, u8context_clear_present (context);__iommu_flush_cache (iommu, context,sizeof (*context));spin_unlock (&iommu->lock); -intel_context_flush_no_pasid (info, context, did); +intel_context_flush_no_pasid (info, context, did,PCI_DEVID (bus, devfn));context_clear_entry (context);__iommu_flush_cache (iommu, context,sizeof (*context)); }
drivers/iommu/intel/iommu.h +1 -1
@@ -1240,7 +1240,7 @@ void cache_tag_flush_range_np(struct dmar_domain *domain, unsigned long start, unsigned long end);void intel_context_flush_no_pasid (struct device_domain_info *info, -struct context_entry *context,u16 did); +struct context_entry *context,u16 did,u16 sid);int intel_iommu_enable_prq (struct intel_iommu *iommu);int intel_iommu_finish_prq (struct intel_iommu *iommu);
drivers/iommu/intel/pasid.c +6 -3
@@ -751,7 +751,7 @@ static void device_pasid_table_teardown(struct device *dev, u8 bus, u8 devfn)context_clear_present (context);__iommu_flush_cache (iommu, context,sizeof (*context));spin_unlock (&iommu->lock); -intel_context_flush_no_pasid (info, context, did); +intel_context_flush_no_pasid (info, context, did,PCI_DEVID (bus, devfn));context_clear_entry (context);__iommu_flush_cache (iommu, context,sizeof (*context)); }
@@ -955,9 +955,12 @@ static void __context_flush_dev_iotlb(struct device_domain_info *info)* This helper can only be used when IOMMU is working in the legacy mode or * IOMMU is in scalable mode but all PASID table entries of the device are * non-present. +* +* @sid identifies the context entry that was modified, which may be a DMA +* alias of @info->dev rather than its own requester ID. */ void intel_context_flush_no_pasid (struct device_domain_info *info, -struct context_entry *context,u16 did) +struct context_entry *context,u16 did,u16 sid) {struct intel_iommu *iommu = info->iommu;
@@ -967,7 +970,7 @@ void intel_context_flush_no_pasid(struct device_domain_info *info,* when operating in scalable mode. Therefore the @did value doesn't * matter in scalable mode. */ - iommu->flush.flush_context (iommu, did,PCI_DEVID (info->bus, info->devfn), + iommu->flush.flush_context (iommu, did, sid,DMA_CCMD_MASK_NOBIT ,DMA_CCMD_DEVICE_INVL );/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1295/1815 crypto: qat - use 2-arg strscpy where destination size is known
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 4525ac14115d07c3e4c57a8cd5c154916e9d1172 ]
To simplify the code, drop explicit and hard-coded size arguments from strscpy() where the destination buffer has a fixed size and strscpy() can automatically determine it using sizeof().
Stable-dep-of: 61135c1597af ("crypto: qat - remove dead ADF_HEX code")
--- drivers/crypto/intel/qat/qat_common/adf_cfg.c | 7 ++++--- drivers/crypto/intel/qat/qat_common/adf_cfg_services.c | 2 +- drivers/crypto/intel/qat/qat_common/adf_mstate_mgr.c | 3 ++- drivers/crypto/intel/qat/qat_common/adf_transport_debug.c | 3 ++- drivers/crypto/intel/qat/qat_common/qat_compression.c | 3 ++- 5 files changed, 11 insertions(+), 7 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_cfg.c +4 -3
@@ -2,6 +2,7 @@/* Copyright(c) 2014 - 2020 Intel Corporation */ #include <linux/mutex.h> #include <linux/slab.h> +#include <linux/string.h> #include <linux/list.h> #include <linux/seq_file.h> #include "adf_accel_devices.h"
@@ -284,13 +285,13 @@ int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev,return -ENOMEM ;INIT_LIST_HEAD (&key_val->list); -strscpy (key_val->key, key,sizeof (key_val->key)); +strscpy (key_val->key, key);if (type ==ADF_DEC ) {snprintf (key_val->val,ADF_CFG_MAX_VAL_LEN_IN_BYTES ,"%ld" , (*((long *)val))); }else if (type ==ADF_STR ) { -strscpy (key_val->val, (char *)val,sizeof (key_val->val)); +strscpy (key_val->val, (char *)val); }else if (type ==ADF_HEX ) {snprintf (key_val->val,ADF_CFG_MAX_VAL_LEN_IN_BYTES ,"0x%lx" , (unsigned long )val);
@@ -350,7 +351,7 @@ int adf_cfg_section_add(struct adf_accel_dev *accel_dev, const char *name)if (!sec)return -ENOMEM ; -strscpy (sec->name, name,sizeof (sec->name)); +strscpy (sec->name, name);INIT_LIST_HEAD (&sec->param_head);down_write (&cfg->lock);list_add_tail (&sec->list, &cfg->sec_list);
drivers/crypto/intel/qat/qat_common/adf_cfg_services.c +1 -1
@@ -60,7 +60,7 @@ static int adf_service_string_to_mask(struct adf_accel_dev *accel_dev, const chaif (len >ADF_CFG_MAX_VAL_LEN_IN_BYTES -1 )return -EINVAL ; -strscpy (services, buf,ADF_CFG_MAX_VAL_LEN_IN_BYTES ); +strscpy (services, buf); substr = services;while ((token =strsep (&substr,ADF_SERVICES_DELIMITER ))) {
drivers/crypto/intel/qat/qat_common/adf_mstate_mgr.c +2 -1
@@ -2,6 +2,7 @@/* Copyright(c) 2024 Intel Corporation */ #include <linux/slab.h> +#include <linux/string.h> #include <linux/types.h> #include "adf_mstate_mgr.h"
@@ -158,7 +159,7 @@ static struct adf_mstate_sect_h *adf_mstate_sect_add_header(struct adf_mstate_mgreturn NULL ; } -strscpy (sect->id, id,sizeof (sect->id)); +strscpy (sect->id, id); sect->size =0 ; sect->sub_sects =0 ; mgr->state +=sizeof (*sect);
drivers/crypto/intel/qat/qat_common/adf_transport_debug.c +2 -1
@@ -2,6 +2,7 @@/* Copyright(c) 2014 - 2020 Intel Corporation */ #include <linux/mutex.h> #include <linux/slab.h> +#include <linux/string.h> #include <linux/seq_file.h> #include "adf_accel_devices.h" #include "adf_transport_internal.h"
@@ -103,7 +104,7 @@ int adf_ring_debugfs_add(struct adf_etr_ring_data *ring, const char *name)if (!ring_debug)return -ENOMEM ; -strscpy (ring_debug->ring_name, name,sizeof (ring_debug->ring_name)); +strscpy (ring_debug->ring_name, name);snprintf (entry_name,sizeof (entry_name),"ring_%02d" , ring->ring_number);
drivers/crypto/intel/qat/qat_common/qat_compression.c +2 -1
@@ -2,6 +2,7 @@/* Copyright(c) 2022 Intel Corporation */ #include <linux/module.h> #include <linux/slab.h> +#include <linux/string.h> #include "adf_accel_devices.h" #include "adf_common_drv.h" #include "adf_transport.h"
@@ -144,7 +145,7 @@ static int qat_compression_create_instances(struct adf_accel_dev *accel_dev)int i;INIT_LIST_HEAD (&accel_dev->compression_list); -strscpy (key,ADF_NUM_DC ,sizeof (key)); +strscpy (key,ADF_NUM_DC ); ret =adf_cfg_get_param_value (accel_dev,SEC , key, val);if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1296/1815 crypto: qat - remove dead ADF_HEX code
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahsan Atta <[email protected]>
[ Upstream commit 61135c1597af56eb454d53c9d7cda90d5e5dc566 ]
The ADF_HEX value type is defined in the adf_cfg_val_type enum and handled in adf_cfg_add_key_value_param(), but no caller in the tree uses it.
Remove the unused ADF_HEX enum value and its dead handling code.
--- drivers/crypto/intel/qat/qat_common/adf_cfg.c | 3 --- drivers/crypto/intel/qat/qat_common/adf_cfg_common.h | 1 - 2 files changed, 4 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_cfg.c +0 -3
@@ -292,9 +292,6 @@ int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev, "%ld", (*((long *)val))); }else if (type ==ADF_STR ) {strscpy (key_val->val, (char *)val); - }else if (type ==ADF_HEX ) { -snprintf (key_val->val,ADF_CFG_MAX_VAL_LEN_IN_BYTES , -"0x%lx" , (unsigned long )val); }else {dev_err (&GET_DEV (accel_dev),"Unknown type given.\n" );kfree (key_val);
drivers/crypto/intel/qat/qat_common/adf_cfg_common.h +0 -1
@@ -28,7 +28,6 @@ enum adf_cfg_service_type {enum adf_cfg_val_type {ADF_DEC , -ADF_HEX ,ADF_STR };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1297/1815 hwrng: imx-rngc - Disable clock on registration failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 188bb9ad86c3b2d527385328a30c1d9510253202 ]
The RNGC clock is enabled manually before runtime PM is configured. If devm_hwrng_register() fails, probe returns without disabling the clock. The devm_pm_runtime_enable() cleanup only disables runtime PM and does not call imx_rngc_suspend().
Disable the clock before returning from this failure path.
--- drivers/char/hw_random/imx-rngc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/hw_random/imx-rngc.c +3 -1
@@ -313,8 +313,10 @@ static int __init imx_rngc_probe(struct platform_device *pdev)devm_pm_runtime_enable (&pdev->dev); ret =devm_hwrng_register (&pdev->dev, &rngc->rng); -if (ret) +if (ret) { +clk_disable_unprepare (rngc->clk);return dev_err_probe (&pdev->dev, ret,"hwrng registration failed\n" ); + } dev_info(&pdev->dev, "Freescale RNG%c registered (HW revision %d.%02d)\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1298/1815 media: amd: isp4: release partial allocations in isp4if_alloc_fw_gpumem()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yifei Gao <[email protected]>
[ Upstream commit fea97ee13c5332f67850733d6cefc1fe99460bde ]
isp4if_alloc_fw_gpumem() allocates several GPU memory pools in sequence. If one of them fails, it jumps to error_no_memory and returns -ENOMEM without releasing the pools that were already allocated, leaking them.
Release the already-allocated pools before returning. isp4if_gpu_mem_free() is a no-op on pools that were not allocated, so calling isp4if_dealloc_fw_gpumem() here safely frees exactly the pools that succeeded.
isp4if_gpu_mem_free() previously logged an error for a NULL entry, which is a normal case during partial-allocation cleanup, so make it silent.
--- drivers/media/platform/amd/isp4/isp4_interface.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/platform/amd/isp4/isp4_interface.c +2 -4
@@ -148,12 +148,9 @@ static void isp4if_gpu_mem_free(struct isp4_interface *ispif, struct isp4if_gpu_mem_info **mem_info_ptr) {struct isp4if_gpu_mem_info *mem_info = *mem_info_ptr; -struct device *dev = ispif->dev; -if (!mem_info) { -dev_err (dev,"invalid mem_info\n" ); +if (!mem_info)return ; - } *mem_info_ptr =NULL ; isp_kernel_buffer_free(&mem_info->mem_handle, &mem_info->gpu_mc_addr,
@@ -201,6 +198,7 @@ static int isp4if_alloc_fw_gpumem(struct isp4_interface *ispif) error_no_memory:dev_err (dev,"failed to allocate gpu memory\n" ); +isp4if_dealloc_fw_gpumem (ispif);return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1299/1815 media: amd: isp4: fix self-deadlock in isp4sd_pwron_and_init() error path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yifei Gao <[email protected]>
[ Upstream commit ef46d80a7015269a98c9505b5912a83798799199 ]
isp4sd_pwron_and_init() holds ops_mutex via guard(mutex) and, on any init failure, jumps to err_deinit and calls isp4sd_pwroff_and_deinit(). That helper takes the same ops_mutex, re-acquiring a non-recursive mutex already held by the current thread, so any init failure deadlocks.
Unwind the error path in stages instead, releasing only what each failure point acquired. This also avoids the issues that an unconditional teardown would hit at the earlier failures, such as a runtime-PM underflow from pm_runtime_resume_and_get() and MMIO access while the device is unpowered.
--- drivers/media/platform/amd/isp4/isp4_subdev.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/media/platform/amd/isp4/isp4_subdev.c +22 -6
@@ -687,7 +687,7 @@ int isp4sd_pwron_and_init(struct v4l2_subdev *sd)if (ret) {dev_err (dev,"fail to power on isp_subdev ret %d\n" , ret); - goto err_deinit; + goto err_module_disable; }/* ISPPG ISP Power Status */
@@ -697,7 +697,7 @@ int isp4sd_pwron_and_init(struct v4l2_subdev *sd)dev_err (dev,"fail to set performance state %u, ret %d\n" , perf_state, ret); - goto err_deinit; + goto err_power_off; } ispif->status =ISP4IF_STATUS_PWR_ON ;
@@ -709,12 +709,12 @@ int isp4sd_pwron_and_init(struct v4l2_subdev *sd) ret =isp4if_start (ispif);if (ret) {dev_err (dev,"fail to start isp_subdev interface\n" ); - goto err_deinit; + goto err_perf_restore; }if (isp4sd_start_resp_proc_threads (isp_subdev)) {dev_err (dev,"isp_start_resp_proc_threads fail\n" ); - goto err_deinit; + goto err_stop_interface; }dev_dbg (dev,"create resp threads ok\n" );
@@ -724,8 +724,24 @@ int isp4sd_pwron_and_init(struct v4l2_subdev *sd) isp_subdev->irq_enabled = true;return 0 ; -err_deinit: -isp4sd_pwroff_and_deinit (sd); + +err_stop_interface: +isp4if_stop (ispif); +err_perf_restore: + ret =dev_pm_genpd_set_performance_state (dev,ISP4SD_PERFORMANCE_STATE_LOW ); +if (ret) +dev_err (dev,"fail to set performance state %u, ret %d\n" , +ISP4SD_PERFORMANCE_STATE_LOW , ret); +err_power_off: +isp4hw_wreg (isp_subdev->mmio,ISP_SOFT_RESET ,0 ); +isp4hw_wreg (isp_subdev->mmio,ISP_POWER_STATUS ,0 ); + ret =pm_runtime_put_sync (dev); +if (ret) +dev_err (dev,"power off isp_subdev fail %d\n" , ret); + ispif->status =ISP4IF_STATUS_PWR_OFF ; +err_module_disable: +isp4sd_module_enable (isp_subdev, false); +msleep (20 );return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1300/1815 m68k: Fix backtraces for non-running tasks
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 09f71dbeb287e367beea56d9ac8a3d356ef5e02a ]
When no stack pointer is supplied, show_stack() starts at thread.esp0. This is the saved userspace register frame, not where a task was switched out. For kernel threads it points to the zeroed frame created by copy_thread(), so sched_show_task() prints no useful backtrace.
Use thread.ksp for non-current tasks. It is saved by switch_to() and is already used by __get_wchan(). For current, start at the current stack frame, as is already done when no task is supplied.
Tested on qemu-system-m68k -M virt using SysRq-t. All task dumps contained resolved frames.
--- arch/m68k/kernel/traps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/m68k/kernel/traps.c +2 -2
@@ -936,8 +936,8 @@ void show_stack(struct task_struct *task, unsigned long *stack,int i;if (!stack) { -if (task) - stack = (unsigned long *)task->thread.esp0; +if (task && task != current) + stack = (unsigned long *)task->thread.ksp;else stack = (unsigned long *)&stack; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1301/1815 netfilter: nft_ct: support expectation creation for natted flows
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit d4beefc90a66672e43fdf82b43e4b3c0b1b18c5e ]
This feature only works for connections originating from the host and only if there no source address rewrite.
Add the needed nat glue to have the expectation follow the original nat binding.
Stable-dep-of: 3679da4ad8be ("netfilter: nft_ct: move custom expectation support to helper")
--- net/netfilter/nft_ct.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
net/netfilter/nft_ct.c +35 -0
@@ -1297,6 +1297,17 @@ static int nft_ct_expect_obj_dump(struct sk_buff *skb,return 0 ; } +#if IS_ENABLED (CONFIG_NF_NAT ) +static void nft_ct_nat_follow_master (struct nf_conn *ct,struct nf_conntrack_expect *this) +{ +const struct nf_ct_helper_expectfn *expfn; + + expfn =nf_ct_helper_expectfn_find_by_name ("nat-follow-master" ); +if (expfn) + expfn->expectfn (ct, this); +} +#endif +static void nft_ct_expect_obj_eval (struct nft_object *obj,struct nft_regs *regs,const struct nft_pktinfo *pkt)
@@ -1342,6 +1353,13 @@ static void nft_ct_expect_obj_eval(struct nft_object *obj, priv->l4proto, NULL, &priv->dport); exp->timeout += priv->timeout; +#if IS_ENABLED (CONFIG_NF_NAT ) +if (ct->status &IPS_NAT_MASK ) { + exp->saved_proto.tcp.port = priv->dport; + exp->dir = !dir; + exp->expectfn = nft_ct_nat_follow_master; + } +#endif if (nf_ct_expect_related (exp,0 ) !=0 ) regs->verdict.code =NF_DROP ;
@@ -1375,6 +1393,13 @@ static struct nft_object_type nft_ct_expect_obj_type __read_mostly = { .owner = THIS_MODULE, }; +#if IS_ENABLED (CONFIG_NF_NAT ) +static struct nf_ct_helper_expectfn nft_ct_nat__read_mostly = { + .name ="nft_ct-follow-master" , + .expectfn = nft_ct_nat_follow_master, +}; +#endif +static int __init nft_ct_module_init (void ) {int err;
@@ -1400,6 +1425,9 @@ static int __init nft_ct_module_init(void) err =nft_register_obj (&nft_ct_timeout_obj_type);if (err <0 ) goto err4; +#endif +#if IS_ENABLED (CONFIG_NF_NAT ) +nf_ct_helper_expectfn_register (&nft_ct_nat);#endif return 0 ;
@@ -1425,6 +1453,13 @@ static void __exit nft_ct_module_exit(void)nft_unregister_obj (&nft_ct_helper_obj_type);nft_unregister_expr (&nft_notrack_type);nft_unregister_expr (&nft_ct_type); + +#if IS_ENABLED (CONFIG_NF_NAT ) +nf_ct_helper_expectfn_unregister (&nft_ct_nat); +synchronize_rcu (); +nf_ct_helper_expectfn_destroy (&nft_ct_nat); +synchronize_rcu (); +#endif }module_init (nft_ct_module_init);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1302/1815 netfilter: nft_ct: move custom expectation support to helper
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 3679da4ad8be84cddaf40bc307fef1fe13e051ff ]
Originally, the ct expectation support called nf_ct_helper_ext_add() for confirmed conntracks, which is invalid, triggering a splat. This was fixed by commit 1710eb913bdc ("netfilter: nft_ct: skip expectations for confirmed conntrack") which restricted it to unconfirmed conntracks.
However, early insertion of expectations into the expectations list when the conntrack is unconfirmed leads to stale entries pointing to the wrong hlist_head through .pprev due to ct extension reallocation.
Commit 7c9664351980 ("netfilter: move nat hlist_head to nf_conn") moved the nat hlist_head to nf_conn for this reason:
1. ...
2. When reallocation of extension area occurs we need to fixup the bysource hash head via hlist_replace_rcu.
I'd rather not increase the size of the struct nf_conn for this feature has very limited scope: only one expectation can be created at a time given expect_clash() will make nf_ct_expect_related() reports EBUSY. For this reason, relax nf_ct_expect_related() not to drop packets in case expectation creation fails, therefore, expectation creation becomes best effort.
To address this issue, add an internal ct helper and attach it to the conntrack entry to streamline the custom ct expectation support with existing ct helpers.
Expose a new nf_conntrack_helper_release() function to release the internal helper that is allocated and attached to the conntrack entry to create the custom expectations. The nft_ct module removal always waits for rcu grace period, then the NULL helper callback is observed after this.
This patch also restricts the creation of expectations to different helpers other than this custom helper that is created for this type of expectations.
--- include/net/netfilter/nf_conntrack_helper.h | 1 + net/netfilter/nf_conntrack_helper.c | 14 +- net/netfilter/nft_ct.c | 167 +++++++++++++++----- 3 files changed, 135 insertions(+), 47 deletions(-)
include/net/netfilter/nf_conntrack_helper.h +1 -0
@@ -108,6 +108,7 @@ void nf_ct_helper_init(struct nf_conntrack_helper *helper,int nf_conntrack_helper_register (struct nf_conntrack_helper *,struct nf_conntrack_helper **);int __nf_conntrack_helper_register (struct nf_conntrack_helper *);void nf_conntrack_helper_unregister (struct nf_conntrack_helper *); +void nf_conntrack_helper_release (struct nf_conntrack_helper *);int nf_conntrack_helpers_register (struct nf_conntrack_helper *,unsigned int ,struct nf_conntrack_helper **);
net/netfilter/nf_conntrack_helper.c +10 -4
@@ -456,6 +456,15 @@ static bool expect_iter_me(struct nf_conntrack_expect *exp, void *data)return this == me; } +void nf_conntrack_helper_release (struct nf_conntrack_helper *me) +{ +nf_ct_expect_iterate_destroy (expect_iter_me, me); + +if (refcount_dec_and_test (&me->ct_refcnt)) +kfree_rcu (me, rcu); +} +EXPORT_SYMBOL_GPL (nf_conntrack_helper_release); +void nf_conntrack_helper_unregister (struct nf_conntrack_helper *me) {mutex_lock (&nf_ct_helper_mutex);
@@ -471,10 +480,7 @@ void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me)*/ synchronize_rcu (); -nf_ct_expect_iterate_destroy (expect_iter_me, me); - -if (refcount_dec_and_test (&me->ct_refcnt)) -kfree_rcu (me, rcu); +nf_conntrack_helper_release (me); }EXPORT_SYMBOL_GPL (nf_conntrack_helper_unregister);
net/netfilter/nft_ct.c +124 -43
227 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1303/1815 NFSD: Release the export reference when reaping open stateids
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 6480bd703684ed3f760e9e36c4a699033c0806ae ]
nfs4_put_stid() releases the svc_export tracked in nfs4_stid.sc_export, but free_ol_stateid_reaplist() frees open and lock stateids by calling ->sc_free() directly, bypassing that path. An open stateid takes an sc_export reference in nfs4_open() and a lock stateid takes its own in init_lock_stateid(); both reach free_ol_stateid_reaplist() through their normal teardown, the open stateid via release_open_stateid() and the lock stateid via nfsd4_release_lockowner(), each through put_ol_stateid_locked(). The reference is therefore never dropped, pinning the export and blocking unmount for the lifetime of the stateid.
Release sc_export in free_ol_stateid_reaplist() the way nfs4_put_stid() does. ->sc_free() runs once per stateid, and a stateid reaches free_ol_stateid_reaplist() or nfs4_put_stid() but never both, so the reference is dropped exactly once. Revoked stateids reach this path with sc_export already cleared by drop_stid_export(), so they are skipped rather than double-freed.
nfs4_put_stid() itself read sc_export before acquiring cl_lock. drop_stid_export() clears that field and releases the reference under cl_lock, so a concurrent revocation could drop the export in the window between the read and the final put, releasing the same reference twice. Read sc_export while cl_lock is held so the two paths serialize and the reference is released exactly once.
--- fs/nfsd/nfs4state.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/nfsd/nfs4state.c +7 -1
@@ -1276,9 +1276,9 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_file *fp,void nfs4_put_stid (struct nfs4_stid *s) { -struct svc_export *exp = s->sc_export;struct nfs4_file *fp = s->sc_file;struct nfs4_client *clp = s->sc_client; +struct svc_export *exp;might_lock (&clp->cl_lock);
@@ -1289,6 +1289,8 @@ nfs4_put_stid(struct nfs4_stid *s)idr_remove (&clp->cl_stateids, s->sc_stateid.si_opaque.so_id);if (s->sc_status &SC_STATUS_ADMIN_REVOKED )atomic_dec (&s->sc_client->cl_admin_revoked); +/* Read under cl_lock to serialize with drop_stid_export(). */ + exp = s->sc_export;nfs4_free_cpntf_statelist (clp->net, s);spin_unlock (&clp->cl_lock); s->sc_free (s);
@@ -1745,6 +1747,7 @@ static void free_ol_stateid_reaplist(struct list_head *reaplist) {struct nfs4_ol_stateid *stp; +struct svc_export *exp;struct nfs4_file *fp;might_sleep ();
@@ -1754,7 +1757,10 @@ free_ol_stateid_reaplist(struct list_head *reaplist) st_locks);list_del (&stp->st_locks); fp = stp->st_stid.sc_file; + exp = stp->st_stid.sc_export; stp->st_stid.sc_free (&stp->st_stid); +if (exp) +exp_put (exp);if (fp)put_nfs4_file (fp); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1304/1815 nfsd: add protocol support for CB_NOTIFY
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
[ Upstream commit a0ac2a63d4b21455985436fbc70192da14a163fd ]
Add the necessary bits to nfs4_1.x and remove the duplicate definitions from nfs4.h and the uapi nfs4 header. Regenerate the xdr files.
Note that regenerating these files caused conflicts with the definitions of NFS4_VERIFIER_SIZE and NFS4_FHSIZE in include/uapi/linux/nfs4.h. These constants are defined by the RFC, and are not part of the kernel API. They have been removed. Userspace consumers who require those constants should plan to get them from more authoritative sources.
The nfsstat4 enum defined in the .x is fed to the xdrgen-generated wire encoder and decoder, which treat every enumerated value as legal on the wire. Do not carry the NFS4ERR_FIRST_FREE sentinel (which is not a protocol error code) into the .x; keeping it would make 10097 a value that could leak onto the wire. Instead base nfsd's internal error codes (NFSERR_EOF and friends) at an impossible nfsstat4 value, as lockd does for its nlm__int__* status codes.
Stable-dep-of: ec5a7c2dceb0 ("xdrgen: Emit a blank line ahead of enum declarations")
--- Documentation/sunrpc/xdr/nfs4_1.x | 241 ++++++++++- fs/nfsd/nfs4xdr_gen.c | 589 ++++++++++++++++++++++++++- fs/nfsd/nfs4xdr_gen.h | 2 +- fs/nfsd/nfsd.h | 9 +- fs/nfsd/trace.h | 1 + include/linux/nfs4.h | 127 ------ include/linux/sunrpc/xdrgen/nfs4_1.h | 279 ++++++++++++- include/uapi/linux/nfs4.h | 2 - 8 files changed, 1105 insertions(+), 145 deletions(-)
Documentation/sunrpc/xdr/nfs4_1.x +239 -2
@@ -45,19 +45,162 @@ pragma header nfs4; /* * Basic typedefs for RFC 1832 data type definitions */ -typedef hyper int64_t; -typedef unsigned int uint32_t; +typedef int int32_t; +typedef unsigned int uint32_t; +typedef hyper int64_t; +typedef unsigned hyper uint64_t; + +const NFS4_VERIFIER_SIZE = 8; +const NFS4_FHSIZE = 128; + +enum nfsstat4 { + NFS4_OK = 0, /* everything is okay */ + NFS4ERR_PERM = 1, /* caller not privileged */ + NFS4ERR_NOENT = 2, /* no such file/directory */ + NFS4ERR_IO = 5, /* hard I/O error */ + NFS4ERR_NXIO = 6, /* no such device */ + NFS4ERR_ACCESS = 13, /* access denied */ + NFS4ERR_EXIST = 17, /* file already exists */ + NFS4ERR_XDEV = 18, /* different filesystems */ + + /* + * Please do not allocate value 19; it was used in NFSv3 + * and we do not want a value in NFSv3 to have a different + * meaning in NFSv4.x. + */ + + NFS4ERR_NOTDIR = 20, /* should be a directory */ + NFS4ERR_ISDIR = 21, /* should not be directory */ + NFS4ERR_INVAL = 22, /* invalid argument */ + NFS4ERR_FBIG = 27, /* file exceeds server max */ + NFS4ERR_NOSPC = 28, /* no space on filesystem */ + NFS4ERR_ROFS = 30, /* read-only filesystem */ + NFS4ERR_MLINK = 31, /* too many hard links */ + NFS4ERR_NAMETOOLONG = 63, /* name exceeds server max */ + NFS4ERR_NOTEMPTY = 66, /* directory not empty */ + NFS4ERR_DQUOT = 69, /* hard quota limit reached*/ + NFS4ERR_STALE = 70, /* file no longer exists */ + NFS4ERR_BADHANDLE = 10001,/* Illegal filehandle */ + NFS4ERR_BAD_COOKIE = 10003,/* READDIR cookie is stale */ + NFS4ERR_NOTSUPP = 10004,/* operation not supported */ + NFS4ERR_TOOSMALL = 10005,/* response limit exceeded */ + NFS4ERR_SERVERFAULT = 10006,/* undefined server error */ + NFS4ERR_BADTYPE = 10007,/* type invalid for CREATE */ + NFS4ERR_DELAY = 10008,/* file "busy" - retry */ + NFS4ERR_SAME = 10009,/* nverify says attrs same */ + NFS4ERR_DENIED = 10010,/* lock unavailable */ + NFS4ERR_EXPIRED = 10011,/* lock lease expired */ + NFS4ERR_LOCKED = 10012,/* I/O failed due to lock */ + NFS4ERR_GRACE = 10013,/* in grace period */ + NFS4ERR_FHEXPIRED = 10014,/* filehandle expired */ + NFS4ERR_SHARE_DENIED = 10015,/* share reserve denied */ + NFS4ERR_WRONGSEC = 10016,/* wrong security flavor */ + NFS4ERR_CLID_INUSE = 10017,/* clientid in use */ + + /* NFS4ERR_RESOURCE is not a valid error in NFSv4.1 */ + NFS4ERR_RESOURCE = 10018,/* resource exhaustion */ + + NFS4ERR_MOVED = 10019,/* filesystem relocated */ + NFS4ERR_NOFILEHANDLE = 10020,/* current FH is not set */ + NFS4ERR_MINOR_VERS_MISMATCH= 10021,/* minor vers not supp */ + NFS4ERR_STALE_CLIENTID = 10022,/* server has rebooted */ + NFS4ERR_STALE_STATEID = 10023,/* server has rebooted */ + NFS4ERR_OLD_STATEID = 10024,/* state is out of sync */ + NFS4ERR_BAD_STATEID = 10025,/* incorrect stateid */ + NFS4ERR_BAD_SEQID = 10026,/* request is out of seq. */ + NFS4ERR_NOT_SAME = 10027,/* verify - attrs not same */ + NFS4ERR_LOCK_RANGE = 10028,/* overlapping lock range */ + NFS4ERR_SYMLINK = 10029,/* should be file/directory*/ + NFS4ERR_RESTOREFH = 10030,/* no saved filehandle */ + NFS4ERR_LEASE_MOVED = 10031,/* some filesystem moved */ + NFS4ERR_ATTRNOTSUPP = 10032,/* recommended attr not sup*/ + NFS4ERR_NO_GRACE = 10033,/* reclaim outside of grace*/ + NFS4ERR_RECLAIM_BAD = 10034,/* reclaim error at server */ + NFS4ERR_RECLAIM_CONFLICT= 10035,/* conflict on reclaim */ + NFS4ERR_BADXDR = 10036,/* XDR decode failed */ + NFS4ERR_LOCKS_HELD = 10037,/* file locks held at CLOSE*/ + NFS4ERR_OPENMODE = 10038,/* conflict in OPEN and I/O*/ + NFS4ERR_BADOWNER = 10039,/* owner translation bad */ + NFS4ERR_BADCHAR = 10040,/* utf-8 char not supported*/ + NFS4ERR_BADNAME = 10041,/* name not supported */ + NFS4ERR_BAD_RANGE = 10042,/* lock range not supported*/ + NFS4ERR_LOCK_NOTSUPP = 10043,/* no atomic up/downgrade */ + NFS4ERR_OP_ILLEGAL = 10044,/* undefined operation */ + NFS4ERR_DEADLOCK = 10045,/* file locking deadlock */ + NFS4ERR_FILE_OPEN = 10046,/* open file blocks op. */ + NFS4ERR_ADMIN_REVOKED = 10047,/* lockowner state revoked */ + NFS4ERR_CB_PATH_DOWN = 10048,/* callback path down */ + + /* NFSv4.1 errors start here. */ + + NFS4ERR_BADIOMODE = 10049, + NFS4ERR_BADLAYOUT = 10050, + NFS4ERR_BAD_SESSION_DIGEST = 10051, + NFS4ERR_BADSESSION = 10052, + NFS4ERR_BADSLOT = 10053, + NFS4ERR_COMPLETE_ALREADY = 10054, + NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055, + NFS4ERR_DELEG_ALREADY_WANTED = 10056, + NFS4ERR_BACK_CHAN_BUSY = 10057,/*backchan reqs outstanding*/ + NFS4ERR_LAYOUTTRYLATER = 10058, + NFS4ERR_LAYOUTUNAVAILABLE = 10059, + NFS4ERR_NOMATCHING_LAYOUT = 10060, + NFS4ERR_RECALLCONFLICT = 10061, + NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062, + NFS4ERR_SEQ_MISORDERED = 10063,/* unexpected seq.ID in req*/ + NFS4ERR_SEQUENCE_POS = 10064,/* [CB_]SEQ. op not 1st op */ + NFS4ERR_REQ_TOO_BIG = 10065,/* request too big */ + NFS4ERR_REP_TOO_BIG = 10066,/* reply too big */ + NFS4ERR_REP_TOO_BIG_TO_CACHE =10067,/* rep. not all cached*/ + NFS4ERR_RETRY_UNCACHED_REP =10068,/* retry & rep. uncached*/ + NFS4ERR_UNSAFE_COMPOUND =10069,/* retry/recovery too hard */ + NFS4ERR_TOO_MANY_OPS = 10070,/*too many ops in [CB_]COMP*/ + NFS4ERR_OP_NOT_IN_SESSION =10071,/* op needs [CB_]SEQ. op */ + NFS4ERR_HASH_ALG_UNSUPP = 10072, /* hash alg. not supp. */ + /* Error 10073 is unused. */ + NFS4ERR_CLIENTID_BUSY = 10074,/* clientid has state */ + NFS4ERR_PNFS_IO_HOLE = 10075,/* IO to _SPARSE file hole */ + NFS4ERR_SEQ_FALSE_RETRY= 10076,/* Retry != original req. */ + NFS4ERR_BAD_HIGH_SLOT = 10077,/* req has bad highest_slot*/ + NFS4ERR_DEADSESSION = 10078,/*new req sent to dead sess*/ + NFS4ERR_ENCR_ALG_UNSUPP= 10079,/* encr alg. not supp. */ + NFS4ERR_PNFS_NO_LAYOUT = 10080,/* I/O without a layout */ + NFS4ERR_NOT_ONLY_OP = 10081,/* addl ops not allowed */ + NFS4ERR_WRONG_CRED = 10082,/* op done by wrong cred */ + NFS4ERR_WRONG_TYPE = 10083,/* op on wrong type object */ + NFS4ERR_DIRDELEG_UNAVAIL=10084,/* delegation not avail. */ + NFS4ERR_REJECT_DELEG = 10085,/* cb rejected delegation */ + NFS4ERR_RETURNCONFLICT = 10086,/* layout get before return*/ + NFS4ERR_DELEG_REVOKED = 10087, /* deleg./layout revoked */ + NFS4ERR_PARTNER_NOTSUPP = 10088, + NFS4ERR_PARTNER_NO_AUTH = 10089, + NFS4ERR_UNION_NOTSUPP = 10090, + NFS4ERR_OFFLOAD_DENIED = 10091, + NFS4ERR_WRONG_LFS = 10092, + NFS4ERR_BADLABEL = 10093, + NFS4ERR_OFFLOAD_NO_REQS = 10094, + NFS4ERR_NOXATTR = 10095, + NFS4ERR_XATTR2BIG = 10096 +}; /* * Basic data types */ +typedef opaque attrlist4<>; typedef uint32_t bitmap4<>; +typedef opaque verifier4[NFS4_VERIFIER_SIZE]; +typedef uint64_t nfs_cookie4; +typedef opaque nfs_fh4<NFS4_FHSIZE>; typedef opaque utf8string<>; typedef utf8string utf8str_cis; typedef utf8string utf8str_cs; typedef utf8string utf8str_mixed; +typedef utf8str_cs component4; +typedef utf8str_cs linktext4; +typedef component4 pathname4<>; + /* * Timeval */
@@ -66,6 +209,21 @@ struct nfstime4 { uint32_t nseconds; }; +/* + * File attribute container + */ +struct fattr4 { + bitmap4 attrmask; + attrlist4 attr_vals; +}; + +/* + * Stateid + */ +struct stateid4 { + uint32_t seqid; + opaque other[12]; +}; /* * The following content was extracted from draft-ietf-nfsv4-delstid
@@ -245,3 +403,82 @@ const FATTR4_ACL_TRUEFORM = 89; const FATTR4_ACL_TRUEFORM_SCOPE = 90; const FATTR4_POSIX_DEFAULT_ACL = 91; const FATTR4_POSIX_ACCESS_ACL = 92; + +/* + * Directory notification types. + */ +enum notify_type4 { + NOTIFY4_CHANGE_CHILD_ATTRS = 0, + NOTIFY4_CHANGE_DIR_ATTRS = 1, + NOTIFY4_REMOVE_ENTRY = 2, + NOTIFY4_ADD_ENTRY = 3, + NOTIFY4_RENAME_ENTRY = 4, + NOTIFY4_CHANGE_COOKIE_VERIFIER = 5 +}; + +/* Changed entry information. */ +struct notify_entry4 { + component4 ne_file; + fattr4 ne_attrs; +}; + +/* Previous entry information */ +struct prev_entry4 { + notify_entry4 pe_prev_entry; + /* what READDIR returned for this entry */ + nfs_cookie4 pe_prev_entry_cookie; +}; + +struct notify_remove4 { + notify_entry4 nrm_old_entry; + nfs_cookie4 nrm_old_entry_cookie; +}; + +struct notify_add4 { + /* + * Information on object + * possibly renamed over. + */ + notify_remove4 nad_old_entry<1>; + notify_entry4 nad_new_entry; + /* what READDIR would have returned for this entry */ + nfs_cookie4 nad_new_entry_cookie<1>; + prev_entry4 nad_prev_entry<1>; + bool nad_last_entry; +}; + +struct notify_attr4 { + notify_entry4 na_changed_entry; +}; + +struct notify_rename4 { + notify_remove4 nrn_old_entry; + notify_add4 nrn_new_entry; +}; + +struct notify_verifier4 { + verifier4 nv_old_cookieverf; + verifier4 nv_new_cookieverf; +}; + +/* + * Objects of type notify_<>4 and + * notify_device_<>4 are encoded in this. + */ +typedef opaque notifylist4<>; + +struct notify4 { + /* composed from notify_type4 or notify_deviceid_type4 */ + bitmap4 notify_mask; + notifylist4 notify_vals; +}; + +struct CB_NOTIFY4args { + stateid4 cna_stateid; + nfs_fh4 cna_fh; + notify4 cna_changes<>; +}; + +struct CB_NOTIFY4res { + nfsstat4 cnr_status; +};
fs/nfsd/nfs4xdr_gen.c +584 -5
660 lines not on this page · raw message
fs/nfsd/nfs4xdr_gen.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Thu Jan 8 23:12:07 2026 */ +/* XDR specification modification time: Wed Mar 25 11:40:02 2026 */ #ifndef _LINUX_XDRGEN_NFS4_1_DECL_H#define _LINUX_XDRGEN_NFS4_1_DECL_H
fs/nfsd/nfsd.h +5 -4
@@ -332,13 +332,14 @@ void nfsd_lockd_shutdown(void);#define nfserr_noxattr cpu_to_be32(NFS4ERR_NOXATTR)/* -* Error codes for internal use. We use enum to choose numbers that are -* not already assigned, then covert to be32 resulting in a number that -* cannot conflict with any existing be32 nfserr value. +* Error codes for internal use. These are based at an impossible +* nfsstat4 value so that, once converted to be32, they cannot conflict +* with any value defined by the protocol (compare the nlm__int__* codes +* in fs/lockd/lockd.h). */ enum {/* end-of-file indicator in readdir */ -NFSERR_EOF =NFS4ERR_FIRST_FREE , +NFSERR_EOF =30000 ,#define nfserr_eof cpu_to_be32(NFSERR_EOF)/* replay detected */
fs/nfsd/trace.h +1 -0
@@ -1677,6 +1677,7 @@ TRACE_EVENT(nfsd_cb_setup_err, { OP_CB_RECALL, "CB_RECALL" }, \ { OP_CB_LAYOUTRECALL, "CB_LAYOUTRECALL" }, \ { OP_CB_RECALL_ANY, "CB_RECALL_ANY" }, \ + { OP_CB_NOTIFY, "CB_NOTIFY" }, \ { OP_CB_NOTIFY_LOCK, "CB_NOTIFY_LOCK" }, \ { OP_CB_OFFLOAD, "CB_OFFLOAD" })
include/linux/nfs4.h +0 -127
133 lines not on this page · raw message
include/linux/sunrpc/xdrgen/nfs4_1.h +275 -4
332 lines not on this page · raw message
include/uapi/linux/nfs4.h +0 -2
@@ -17,11 +17,9 @@#include <linux/types.h> #define NFS4_BITMAP_SIZE 3 -#define NFS4_VERIFIER_SIZE 8#define NFS4_STATEID_SEQID_SIZE 4#define NFS4_STATEID_OTHER_SIZE 12#define NFS4_STATEID_SIZE (NFS4_STATEID_SEQID_SIZE + NFS4_STATEID_OTHER_SIZE) -#define NFS4_FHSIZE 128#define NFS4_MAXPATHLEN PATH_MAX#define NFS4_MAXNAMLEN NAME_MAX#define NFS4_OPAQUE_LIMIT 1024
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1305/1815 lockd: Regenerate NLMv4 XDR code
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit e1d6e968ee26eee9654e35cd8141e38cefe307a4 ]
The checked-in NLMv4 xdrgen output predates the addition of enum value validation to generated decoders. As a result the decoders for fsh4_mode, fsh4_access, and nlm4_stats still accept any 32-bit value, while the current generator rejects values outside the enumeration. Resync the generated files with the in-tree xdrgen by regenerating from the unchanged nlm4.x specification.
This is a plain regeneration with no specification change; it also refreshes the recorded specification modification time to show that all existing enum decoders have picked up the xdrgen tool fix.
Stable-dep-of: ec5a7c2dceb0 ("xdrgen: Emit a blank line ahead of enum declarations")
--- fs/lockd/nlm3xdr_gen.c | 2 +- fs/lockd/nlm3xdr_gen.h | 2 +- fs/lockd/nlm4xdr_gen.c | 47 ++++++++++++++++++++++++++-- fs/lockd/nlm4xdr_gen.h | 2 +- fs/nfsd/nfs4xdr_gen.c | 2 +- fs/nfsd/nfs4xdr_gen.h | 2 +- include/linux/sunrpc/xdrgen/nfs4_1.h | 2 +- include/linux/sunrpc/xdrgen/nlm3.h | 2 +- include/linux/sunrpc/xdrgen/nlm4.h | 2 +- 9 files changed, 53 insertions(+), 10 deletions(-)
fs/lockd/nlm3xdr_gen.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Generated by xdrgen. Manual edits will be lost. // XDR specification file: ../../Documentation/sunrpc/xdr/nlm3.x -// XDR specification modification time: Thu Apr 23 10:56:34 2026 +// XDR specification modification time: Mon Jun 29 20:39:34 2026 #include <linux/sunrpc/svc.h>
fs/lockd/nlm3xdr_gen.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm3.x */ -/* XDR specification modification time: Thu Apr 23 10:56:34 2026 */ +/* XDR specification modification time: Mon Jun 29 20:39:34 2026 */ #ifndef _LINUX_XDRGEN_NLM3_DECL_H#define _LINUX_XDRGEN_NLM3_DECL_H
fs/lockd/nlm4xdr_gen.c +45 -2
71 lines not on this page · raw message
fs/lockd/nlm4xdr_gen.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm4.x */ -/* XDR specification modification time: Thu Dec 25 13:10:19 2025 */ +/* XDR specification modification time: Mon Jun 29 20:39:36 2026 */ #ifndef _LINUX_XDRGEN_NLM4_DECL_H#define _LINUX_XDRGEN_NLM4_DECL_H
fs/nfsd/nfs4xdr_gen.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Generated by xdrgen. Manual edits will be lost. // XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x -// XDR specification modification time: Wed Mar 25 11:40:02 2026 +// XDR specification modification time: Tue Jun 30 11:56:05 2026 #include <linux/sunrpc/svc.h>
fs/nfsd/nfs4xdr_gen.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Wed Mar 25 11:40:02 2026 */ +/* XDR specification modification time: Tue Jun 30 11:56:05 2026 */ #ifndef _LINUX_XDRGEN_NFS4_1_DECL_H#define _LINUX_XDRGEN_NFS4_1_DECL_H
include/linux/sunrpc/xdrgen/nfs4_1.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Wed Mar 25 11:40:02 2026 */ +/* XDR specification modification time: Tue Jun 30 11:56:05 2026 */ #ifndef _LINUX_XDRGEN_NFS4_1_DEF_H#define _LINUX_XDRGEN_NFS4_1_DEF_H
include/linux/sunrpc/xdrgen/nlm3.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm3.x */ -/* XDR specification modification time: Thu Apr 23 10:56:34 2026 */ +/* XDR specification modification time: Mon Jun 29 20:39:34 2026 */ #ifndef _LINUX_XDRGEN_NLM3_DEF_H#define _LINUX_XDRGEN_NLM3_DEF_H
include/linux/sunrpc/xdrgen/nlm4.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm4.x */ -/* XDR specification modification time: Thu Dec 25 13:10:19 2025 */ +/* XDR specification modification time: Mon Jun 29 20:39:36 2026 */ #ifndef _LINUX_XDRGEN_NLM4_DEF_H#define _LINUX_XDRGEN_NLM4_DEF_H
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1306/1815 xdrgen: Emit a blank line ahead of enum declarations
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit ec5a7c2dceb09caf36262ecbd633eb7d4f9e4d3d ]
Clean up.
The declaration templates for structs, pointers, and typedefs each begin with a blank line, which keeps successive declarations and the include block above them visually separated. The enum declaration template omits that blank line. trim_blocks collapses the template's lone comment line to nothing, so the omission stayed invisible as long as every generated header happened to lead with a non-enum declaration.
--- fs/lockd/nlm3xdr_gen.c | 2 +- fs/lockd/nlm3xdr_gen.h | 2 +- fs/lockd/nlm4xdr_gen.c | 2 +- fs/lockd/nlm4xdr_gen.h | 2 +- fs/nfsd/nfs4xdr_gen.c | 2 +- fs/nfsd/nfs4xdr_gen.h | 5 ++++- include/linux/sunrpc/xdrgen/nfs4_1.h | 2 +- include/linux/sunrpc/xdrgen/nlm3.h | 2 +- include/linux/sunrpc/xdrgen/nlm4.h | 2 +- tools/net/sunrpc/xdrgen/templates/C/enum/declaration/enum.j2 | 1 + 10 files changed, 13 insertions(+), 9 deletions(-)
fs/lockd/nlm3xdr_gen.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Generated by xdrgen. Manual edits will be lost. // XDR specification file: ../../Documentation/sunrpc/xdr/nlm3.x -// XDR specification modification time: Mon Jun 29 20:39:34 2026 +// XDR specification modification time: Mon Jun 29 20:42:29 2026 #include <linux/sunrpc/svc.h>
fs/lockd/nlm3xdr_gen.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm3.x */ -/* XDR specification modification time: Mon Jun 29 20:39:34 2026 */ +/* XDR specification modification time: Mon Jun 29 20:42:29 2026 */ #ifndef _LINUX_XDRGEN_NLM3_DECL_H#define _LINUX_XDRGEN_NLM3_DECL_H
fs/lockd/nlm4xdr_gen.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Generated by xdrgen. Manual edits will be lost. // XDR specification file: ../../Documentation/sunrpc/xdr/nlm4.x -// XDR specification modification time: Mon Jun 29 20:39:36 2026 +// XDR specification modification time: Mon Jun 29 20:42:29 2026 #include <linux/sunrpc/svc.h>
fs/lockd/nlm4xdr_gen.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm4.x */ -/* XDR specification modification time: Mon Jun 29 20:39:36 2026 */ +/* XDR specification modification time: Mon Jun 29 20:42:29 2026 */ #ifndef _LINUX_XDRGEN_NLM4_DECL_H#define _LINUX_XDRGEN_NLM4_DECL_H
fs/nfsd/nfs4xdr_gen.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Generated by xdrgen. Manual edits will be lost. // XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x -// XDR specification modification time: Tue Jun 30 11:56:05 2026 +// XDR specification modification time: Tue Jun 30 11:57:21 2026 #include <linux/sunrpc/svc.h>
fs/nfsd/nfs4xdr_gen.h +4 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Tue Jun 30 11:56:05 2026 */ +/* XDR specification modification time: Tue Jun 30 11:57:21 2026 */ #ifndef _LINUX_XDRGEN_NFS4_1_DECL_H#define _LINUX_XDRGEN_NFS4_1_DECL_H
@@ -21,10 +21,13 @@ bool xdrgen_encode_fattr4_time_deleg_access(struct xdr_stream *xdr, const fattr4bool xdrgen_decode_fattr4_time_deleg_modify (struct xdr_stream *xdr,fattr4_time_deleg_modify *ptr);bool xdrgen_encode_fattr4_time_deleg_modify (struct xdr_stream *xdr,const fattr4_time_deleg_modify *value); +bool xdrgen_decode_aclmodel4 (struct xdr_stream *xdr,aclmodel4 *ptr);bool xdrgen_encode_aclmodel4 (struct xdr_stream *xdr,aclmodel4 value); +bool xdrgen_decode_aclscope4 (struct xdr_stream *xdr,aclscope4 *ptr);bool xdrgen_encode_aclscope4 (struct xdr_stream *xdr,aclscope4 value); +bool xdrgen_decode_posixacetag4 (struct xdr_stream *xdr,posixacetag4 *ptr);bool xdrgen_encode_posixacetag4 (struct xdr_stream *xdr,posixacetag4 value);
include/linux/sunrpc/xdrgen/nfs4_1.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Tue Jun 30 11:56:05 2026 */ +/* XDR specification modification time: Tue Jun 30 11:57:21 2026 */ #ifndef _LINUX_XDRGEN_NFS4_1_DEF_H#define _LINUX_XDRGEN_NFS4_1_DEF_H
include/linux/sunrpc/xdrgen/nlm3.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm3.x */ -/* XDR specification modification time: Mon Jun 29 20:39:34 2026 */ +/* XDR specification modification time: Mon Jun 29 20:42:29 2026 */ #ifndef _LINUX_XDRGEN_NLM3_DEF_H#define _LINUX_XDRGEN_NLM3_DEF_H
include/linux/sunrpc/xdrgen/nlm4.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm4.x */ -/* XDR specification modification time: Mon Jun 29 20:39:36 2026 */ +/* XDR specification modification time: Mon Jun 29 20:42:29 2026 */ #ifndef _LINUX_XDRGEN_NLM4_DEF_H#define _LINUX_XDRGEN_NLM4_DEF_H
tools/net/sunrpc/xdrgen/templates/C/enum/declaration/enum.j2 +1 -0
@@ -1,3 +1,4 @@ {# SPDX-License-Identifier: GPL-2.0 #} + bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ name }} *ptr); bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, {{ name }} value);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1307/1815 xdrgen: Do not declare union XDR functions in the definitions header
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit d4ca0b0a6c62bc12407060754df11b23a90f3e57 ]
Unlike the struct, enum, typedef, and pointer templates, the union definitions template also emits xdrgen_decode_*() and xdrgen_encode_*() prototypes for a public union into that header. Those prototypes name struct xdr_stream, which the definitions header neither includes nor forward-declares, so any translation unit that includes the definitions header without xdr.h already in scope draws -Wvisibility warnings. The same public prototypes are emitted into the declarations header, which does include <linux/sunrpc/xdr.h>, making the definitions-header copies redundant.
Drop the prototype emission from the union definitions template so it matches the other type templates. Public unions keep their encode and decode prototypes through the declarations header.
--- .../net/sunrpc/xdrgen/templates/C/union/definition/close.j2 | 6 ------ 1 file changed, 6 deletions(-)
tools/net/sunrpc/xdrgen/templates/C/union/definition/close.j2 +0 -6
@@ -1,9 +1,3 @@ {# SPDX-License-Identifier: GPL-2.0 #} } u; }; -{%- if name in public_apis %} - - -bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, struct {{ name }} *ptr); -bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const struct {{ name }} *ptr); -{%- endif -%}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1308/1815 xdrgen: Add XDR width macros for short integer types
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit c488328375beb4e3a3ca0526919c81767ce1de95 ]
Commit ae78eb497868 ("xdrgen: Implement short (16-bit) integer types") taught the generator to emit XDR_short and XDR_unsigned_short in the computed maxsize macros and added the matching encode and decode primitives to _builtins.h, but it left the two width macros themselves undefined in _defs.h.
Define XDR_short and XDR_unsigned_short, each one XDR unit wide, to match the width the generator's maxsize table assigns them.
--- include/linux/sunrpc/xdrgen/_defs.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/sunrpc/xdrgen/_defs.h +2 -0
@@ -25,6 +25,8 @@ typedef struct {#define XDR_void (0)#define XDR_bool (1) +#define XDR_short (1) +#define XDR_unsigned_short (1)#define XDR_int (1)#define XDR_unsigned_int (1)#define XDR_long (1)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1309/1815 xdrgen: Fix opaque and string encoders for unbounded members
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit daa52e37851a5a1b5890e7a250a27e94a8b9f273 ]
The variable-length opaque and string encoder templates emit an unconditional bound check, "if (value->NAME.len > MAXSIZE) return false". XDR represents an unbounded specifier (opaque foo<>, string foo<>) as a maxsize of 0, so for an unbounded member the check degenerates to "len > 0" and the generated encoder refuses every non-empty value.
The decoder does not share this defect. It delegates to xdrgen_decode_opaque() and xdrgen_decode_string(), which treat a maxlen of 0 as unbounded and skip the length check. The sibling variable-length array templates already guard their bound check with maxsize != "0".
Guard the bound check the same way in each affected template -- the struct and pointer forms of both the opaque and string encoders -- so an unbounded member encodes a payload of any length while a bounded member keeps its limit.
An explicit zero-length bound (foo<0>) parses to the same maxsize of 0 and so also skips the check; xdrgen does not distinguish it from the unbounded form, matching the decoder and the array encoders.
--- tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/string.j2 | 2 ++ .../templates/C/pointer/encoder/variable_length_opaque.j2 | 2 ++ tools/net/sunrpc/xdrgen/templates/C/struct/encoder/string.j2 | 2 ++ .../xdrgen/templates/C/struct/encoder/variable_length_opaque.j2 | 2 ++ 4 files changed, 8 insertions(+)
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/string.j2 +2 -0
@@ -2,7 +2,9 @@ {% if annotate %} /* member {{ name }} (variable-length string) */ {% endif %} +{% if maxsize != "0" %} if (value->{{ name }}.len > {{ maxsize }}) return false; +{% endif %} if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) return false;
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/variable_length_opaque.j2 +2 -0
@@ -2,7 +2,9 @@ {% if annotate %} /* member {{ name }} (variable-length opaque) */ {% endif %} +{% if maxsize != "0" %} if (value->{{ name }}.len > {{ maxsize }}) return false; +{% endif %} if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) return false;
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/string.j2 +2 -0
@@ -2,7 +2,9 @@ {% if annotate %} /* member {{ name }} (variable-length string) */ {% endif %} +{% if maxsize != "0" %} if (value->{{ name }}.len > {{ maxsize }}) return false; +{% endif %} if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) return false;
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_opaque.j2 +2 -0
@@ -2,7 +2,9 @@ {% if annotate %} /* member {{ name }} (variable-length opaque) */ {% endif %} +{% if maxsize != "0" %} if (value->{{ name }}.len > {{ maxsize }}) return false; +{% endif %} if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1310/1815 arm64: Disable KCSAN instrumentation in delay.o
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Elver <[email protected]>
[ Upstream commit 5eaec4cf41a8f5ac1a0c69a607cdc5035a797f73 ]
KCSAN relies on udelay() for injecting delays. To avoid recursively triggering a watchpoint, where KCSAN sets up watchpoint on an address that is accessed by udelay() in the same thread, disable instrumentation in arm64's delay implementation.
Paul found a manifestation of this as follows:
| BUG: KCSAN: data-race in __delay / set_need_resched_current | | read (marked) to 0xffff000005899b48 of 8 bytes by interrupt on cpu 8: | __delay+0xb0/0x378 | __udelay+0x4c/0x60 | kcsan_setup_watchpoint+0x3b4/0x820 | __tsan_unaligned_write4+0x228/0x26c | set_need_resched_current+0x138/0x1a8 | rcu_exp_handler+0x418/0x4a0 | __flush_smp_call_function_queue+0x36c/0x4a0 | generic_smp_call_function_single_interrupt+0x20/0x30 | ipi_handler+0xec/0x558 | handle_percpu_devid_irq+0x220/0x2a0 | generic_handle_domain_irq+0x84/0xb4 | gic_handle_irq+0x64/0x144 | call_on_irq_stack+0x30/0x48 | do_interrupt_handler+0x80/0xb8 | el1_interrupt+0x3c/0x60 | el1h_64_irq_handler+0x18/0x24 | el1h_64_irq+0x6c/0x70 | smp_call_function_single+0x18c/0x25c | sync_rcu_exp_select_node_cpus+0x534/0x8bc | rcu_exp_sel_wait_wake+0x358/0xef4 | wait_rcu_exp_gp+0x30/0x44 | kthread_worker_fn+0x1b4/0x5dc | kthread+0x1d8/0x204 | ret_from_fork+0x10/0x20 | | write to 0xffff000005899b4c of 4 bytes by interrupt on cpu 8: | set_need_resched_current+0x138/0x1a8 | [...]
This matches what is already done in arch/x86/lib/Makefile.
--- arch/arm64/lib/Makefile | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/lib/Makefile +4 -0
@@ -1,4 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 + +# KCSAN uses udelay for introducing watchpoint delay; avoid recursion. +KCSAN_SANITIZE_delay.o := n + lib-y := clear_user.o delay.o copy_from_user.o \ copy_to_user.o copy_page.o \ clear_page.o csum.o insn.o memchr.o memcpy.o \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1311/1815 hwmon: (cros_ec) Register the thermal devices after the hwmon ones
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 9f1012119f2a4cb5a7f589dc77d5e15dbab49d00 ]
To guarantee consistency for the read-modify-write access in cros_ec_hwmon_cooling_set_cur_state(), locking is necessary. The locking will use standard hwmon device locks, which requires the hwmon device to be ready before the fan devices are set up.
Reorder the initialization so this works.
Stable-dep-of: 26db27364088 ("hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks")
--- drivers/hwmon/cros_ec_hwmon.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/hwmon/cros_ec_hwmon.c +6 -2
@@ -570,13 +570,17 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev) priv->fan_control_supported =cros_ec_hwmon_probe_fan_control_supported (priv->cros_ec); priv->temp_threshold_supported =is_cros_ec_cmd_available (priv->cros_ec,EC_CMD_THERMAL_GET_THRESHOLD ,1 ); -cros_ec_hwmon_register_fan_cooling_devices (dev, priv); hwmon_dev =devm_hwmon_device_register_with_info (dev,"cros_ec" , priv, &cros_ec_hwmon_chip_info,NULL ); +if (IS_ERR (hwmon_dev)) +return PTR_ERR (hwmon_dev); + +cros_ec_hwmon_register_fan_cooling_devices (dev, priv); +platform_set_drvdata (pdev, priv); -return PTR_ERR_OR_ZERO (hwmon_dev); +return 0 ; }static int cros_ec_hwmon_suspend (struct platform_device *pdev,pm_message_t state)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1312/1815 hwmon: (cros_ec) Store the hwmon device in cros_ec_hwmon_priv
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 434baf3aea987ae61d0d54b6cdf8fccf78383b4e ]
The upcoming locking scheme for thermal devices will require access to the hwmon device.
Add it do the priv struct.
Stable-dep-of: 26db27364088 ("hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks")
--- drivers/hwmon/cros_ec_hwmon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hwmon/cros_ec_hwmon.c +5 -5
@@ -24,6 +24,7 @@struct cros_ec_hwmon_priv {struct cros_ec_device *cros_ec; +struct device *hwmon_dev;const char *temp_sensor_names[EC_TEMP_SENSOR_ENTRIES +EC_TEMP_SENSOR_B_ENTRIES ];u8 usable_fans;bool fan_control_supported;
@@ -547,7 +548,6 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev)struct cros_ec_dev *ec_dev =dev_get_drvdata (dev->parent);struct cros_ec_device *cros_ec = ec_dev->ec_dev;struct cros_ec_hwmon_priv *priv; -struct device *hwmon_dev;u8 thermal_version;int ret;
@@ -571,10 +571,10 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev) priv->temp_threshold_supported =is_cros_ec_cmd_available (priv->cros_ec,EC_CMD_THERMAL_GET_THRESHOLD ,1 ); - hwmon_dev =devm_hwmon_device_register_with_info (dev,"cros_ec" , priv, - &cros_ec_hwmon_chip_info,NULL ); -if (IS_ERR (hwmon_dev)) -return PTR_ERR (hwmon_dev); + priv->hwmon_dev =devm_hwmon_device_register_with_info (dev,"cros_ec" , priv, + &cros_ec_hwmon_chip_info,NULL ); +if (IS_ERR (priv->hwmon_dev)) +return PTR_ERR (priv->hwmon_dev);cros_ec_hwmon_register_fan_cooling_devices (dev, priv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1313/1815 hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 26db273640887276a24ca2546b06e334508871f8 ]
To guarantee consistency for the read-modify-write access in cros_ec_hwmon_cooling_set_cur_state(), locking is necessary.
Use the existing hwmon device lock to do so.
--- drivers/hwmon/cros_ec_hwmon.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hwmon/cros_ec_hwmon.c +5 -0
@@ -5,6 +5,7 @@* Copyright (C) 2024 Thomas Weißschuh <[email protected]> */ +#include <linux/cleanup.h> #include <linux/device.h> #include <linux/hwmon.h> #include <linux/math.h>
@@ -402,6 +403,8 @@ static int cros_ec_hwmon_cooling_get_cur_state(struct thermal_cooling_device *cdu8 read_val;int ret; +guard (hwmon_lock)(priv->hwmon_priv->hwmon_dev); + ret =cros_ec_hwmon_read_pwm_value (priv->hwmon_priv->cros_ec, priv->index, &read_val);if (ret)return ret;
@@ -415,6 +418,8 @@ static int cros_ec_hwmon_cooling_set_cur_state(struct thermal_cooling_device *cd {const struct cros_ec_hwmon_cooling_priv *priv = cdev->devdata; +guard (hwmon_lock)(priv->hwmon_priv->hwmon_dev); +return cros_ec_hwmon_write_pwm_input (priv->hwmon_priv->cros_ec, priv->index, val); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1314/1815 hwmon: (pmbus/ltc4283) Add missing MODULE_DEVICE_TABLE for OF match table
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: surendra <[email protected]>
[ Upstream commit bd300460cee457c50a16a42654d6de4c85562785 ]
The driver registers ltc4283_of_match as the platform driver's .of_match_table so the kernel probes the device when a DT node with compatible "adi,ltc4283" is present, but the corresponding MODULE_DEVICE_TABLE(of, ...) call is absent.
Without it the module alias table (modules.alias) does not contain an "of:N*T*Cadi,ltc4283" entry, so udev / kmod cannot auto-load the module when the DT node appears, breaking modules-based deployments while built-in configurations happen to work by accident.
Add the missing MODULE_DEVICE_TABLE() to fix module auto-loading.
--- drivers/hwmon/ltc4283.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwmon/ltc4283.c +1 -0
@@ -1772,6 +1772,7 @@ static const struct of_device_id ltc4283_of_match[] = { { .compatible = "adi,ltc4283" }, { } }; +MODULE_DEVICE_TABLE (of, ltc4283_of_match);static const struct i2c_device_id ltc4283_i2c_id[] = { {"ltc4283" },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1315/1815 SUNRPC: check rpc_sockaddr2uaddr() return value in rpcb_register_inet4/6
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit fd22370226a0d8109045d0831fd5aaadee921693 ]
rpcb_register_inet4() and rpcb_register_inet6() store the result of rpc_sockaddr2uaddr() into map->r_addr without checking it for NULL. rpc_sockaddr2uaddr() returns NULL when its final kstrdup() fails, and the unchecked NULL is then carried into the synchronous RPCBPROC_SET encode path: rpcb_register_call() -> rpc_call_sync() -> rpcb_enc_getaddr() -> encode_rpcb_string(), whose first statement is strlen(string), dereferencing NULL and oopsing the kernel.
The crash reproduces under failslab on v6.12; with KASAN the NULL dereference surfaces as a fault on the shadow of address zero:
Oops: general protection fault, probably for non-canonical address
0xdffffc0000000000 [#1] PREEMPT SMP KASAN
RIP: 0010:strlen (lib/string.c:409)
Call Trace:
encode_rpcb_string (net/sunrpc/rpcb_clnt.c:890)
rpcb_enc_getaddr (net/sunrpc/rpcb_clnt.c:910)
rpcauth_wrap_req_encode (net/sunrpc/auth.c:745)
call_encode (net/sunrpc/clnt.c:1966)
__rpc_execute (net/sunrpc/sched.c:952)
rpc_run_task (net/sunrpc/clnt.c:1243)
rpc_call_sync (net/sunrpc/clnt.c:1272)
rpcb_v4_register (net/sunrpc/rpcb_clnt.c:500)
svc_generic_rpcbind_set
nfsd_rpcbind_set
svc_register
svc_setup_socket
svc_addsock
write_ports
nfsctl_transaction_write
vfs_writeThe crash is reachable when an in-kernel RPC service (nfsd, lockd, nfs-callback) registers with the local rpcbind under enough memory pressure for the small GFP_KERNEL kstrdup() in rpc_sockaddr2uaddr() to fail. The asynchronous getport path already handles this exact failure mode by returning -ENOMEM; only the two register helpers omit the check.
Mirror that handling: bail out with -ENOMEM when rpc_sockaddr2uaddr() returns NULL, before the address is fed into the encoder.
--- net/sunrpc/rpcb_clnt.c | 4 ++++ 1 file changed, 4 insertions(+)
net/sunrpc/rpcb_clnt.c +4 -0
@@ -490,6 +490,8 @@ static int rpcb_register_inet4(struct sunrpc_net *sn,int result; map->r_addr =rpc_sockaddr2uaddr (sap,GFP_KERNEL ); +if (!map->r_addr) +return -ENOMEM ; msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET ];if (port !=0 ) {
@@ -516,6 +518,8 @@ static int rpcb_register_inet6(struct sunrpc_net *sn,int result; map->r_addr =rpc_sockaddr2uaddr (sap,GFP_KERNEL ); +if (!map->r_addr) +return -ENOMEM ; msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET ];if (port !=0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1316/1815 sunrpc: xprtsock: annotate shared socket callbacks with READ_ONCE/WRITE_ONCE
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 33930840b5f0a79f826e7c69dc6cd78f72a67481 ]
xprtsock replaces and restores sk->sk_data_ready and sk->sk_write_space on live sockets with plain stores, and xs_udp_do_set_buffer_size() invokes sk->sk_write_space via a plain load. These callback pointers are shared with generic socket and protocol paths that may read or invoke them concurrently, so xprtsock needs the same READ_ONCE()/WRITE_ONCE() callback visibility contract that the validated 4022 family applied elsewhere.
When SUNRPC takes over an AF_LOCAL, UDP, or TCP socket and later restores the lower-socket callbacks during teardown, another CPU may still hold an earlier callback snapshot. The plain replace/restore pattern leaves the same visibility hole as the validated 4022 family, so a stale snapshot can still invoke xs_data_ready() or xs_udp_write_space() after the live callback fields have already been restored to the lower-socket handlers.
Use WRITE_ONCE() for the shared sk_data_ready and sk_write_space stores in xs_local_finish_connecting(), xs_udp_finish_connecting(), xs_tcp_finish_connecting(), and xs_restore_old_callbacks(). Use READ_ONCE() for the direct sk_write_space invocation in xs_udp_do_set_buffer_size(). This matches the required callback visibility contract while leaving adjacent sk_state_change and sk_error_report handling unchanged.
--- net/sunrpc/xprtsock.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
net/sunrpc/xprtsock.c +11 -9
@@ -1202,9 +1202,9 @@ static void xs_save_old_callbacks(struct sock_xprt *transport, struct sock *sk)static void xs_restore_old_callbacks (struct sock_xprt *transport,struct sock *sk) { - sk->sk_data_ready = transport->old_data_ready; +WRITE_ONCE (sk->sk_data_ready, transport->old_data_ready); sk->sk_state_change = transport->old_state_change; - sk->sk_write_space = transport->old_write_space; +WRITE_ONCE (sk->sk_write_space, transport->old_write_space); sk->sk_error_report = transport->old_error_report; }
@@ -1664,6 +1664,7 @@ static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt) { struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);struct sock *sk = transport->inet; +void (*write_space)(struct sock *sock);if (transport->rcvsize) { sk->sk_userlocks |=SOCK_RCVBUF_LOCK ;
@@ -1672,7 +1673,8 @@ static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt)if (transport->sndsize) { sk->sk_userlocks |=SOCK_SNDBUF_LOCK ; sk->sk_sndbuf = transport->sndsize * xprt->max_reqs *2 ; - sk->sk_write_space (sk); + write_space =READ_ONCE (sk->sk_write_space); +write_space (sk); } }
@@ -1988,8 +1990,8 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt,xs_save_old_callbacks (transport, sk); sk->sk_user_data = xprt; - sk->sk_data_ready = xs_data_ready; - sk->sk_write_space = xs_udp_write_space; +WRITE_ONCE (sk->sk_data_ready, xs_data_ready); +WRITE_ONCE (sk->sk_write_space, xs_udp_write_space); sk->sk_state_change = xs_local_state_change; sk->sk_error_report = xs_error_report; sk->sk_use_task_frag = false;
@@ -2191,8 +2193,8 @@ static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)xs_save_old_callbacks (transport, sk); sk->sk_user_data = xprt; - sk->sk_data_ready = xs_data_ready; - sk->sk_write_space = xs_udp_write_space; +WRITE_ONCE (sk->sk_data_ready, xs_data_ready); +WRITE_ONCE (sk->sk_write_space, xs_udp_write_space); sk->sk_use_task_frag = false;xprt_set_connected (xprt);
@@ -2378,9 +2380,9 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)xs_save_old_callbacks (transport, sk); sk->sk_user_data = xprt; - sk->sk_data_ready = xs_data_ready; +WRITE_ONCE (sk->sk_data_ready, xs_data_ready); sk->sk_state_change = xs_tcp_state_change; - sk->sk_write_space = xs_tcp_write_space; +WRITE_ONCE (sk->sk_write_space, xs_tcp_write_space); sk->sk_error_report = xs_error_report; sk->sk_use_task_frag = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1317/1815 NFS: Return a delegation the client fails to record
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 220af23d863995091f0edeb1e6aa0945b3db8b37 ]
When an NFS server grants a delegation in an OPEN reply, nfs_inode_set_delegation() records it on the client. However, three of its error flows return without sending DELEGRETURN.
A delegation can be relinquished only by DELEGRETURN (RFC 8881 Section 20.2.4), so dropping one silently leaves the server believing the client still holds it. If the server happens to recall that delegation, the client answers CB_RECALL with NFS4ERR_BADHANDLE because it has no record of the stateid. The server revokes the delegation and moves it onto its cl_revoked list, because the client never sends the FREE_STATEID that would drain it. Every subsequent SEQUENCE reply then carries SEQ4_STATUS_RECALLABLE_STATE_REVOKED, and the client's state manager loops issuing TEST_STATEID across its delegations without ever clearing the condition.
The window is easy to reach now that a server offers a write delegation on any write OPEN: a delegation recalled for one opener races a re-open that the server answers with a fresh write delegation.
Instead of dropping it, hand the delegation back during these error flows.
--- fs/nfs/delegation.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
fs/nfs/delegation.c +14 -4
@@ -447,11 +447,14 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred,struct nfs_inode *nfsi =NFS_I (inode);struct nfs_delegation *delegation, *old_delegation;struct nfs_delegation *freeme =NULL ; +bool orphaned = false;int status =0 ; delegation =kmalloc_obj (*delegation,GFP_KERNEL_ACCOUNT ); -if (delegation ==NULL ) +if (delegation ==NULL ) { +nfs4_proc_delegreturn (inode, cred, stateid,NULL ,0 );return -ENOMEM ; + }nfs4_stateid_copy (&delegation->stateid, stateid);refcount_set (&delegation->refcount,1 ); delegation->type = type;
@@ -500,11 +503,15 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, goto out; }if (test_and_set_bit (NFS_DELEGATION_RETURNING , - &old_delegation->flags)) + &old_delegation->flags)) { + orphaned = true; goto out; + } } -if (!nfs_detach_delegations_locked (nfsi, old_delegation, clp)) +if (!nfs_detach_delegations_locked (nfsi, old_delegation, clp)) { + orphaned = true; goto out; + } freeme = old_delegation; add_new:/*
@@ -539,8 +546,11 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred,nfs_update_delegated_mtime (inode); out:spin_unlock (&clp->cl_lock); -if (delegation !=NULL ) +if (delegation !=NULL ) { +if (orphaned) +nfs_do_return_delegation (inode, delegation,0 );__nfs_free_delegation (delegation); + }if (freeme !=NULL ) {nfs_do_return_delegation (inode, freeme,0 );nfs_mark_delegation_revoked (server, freeme);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1318/1815 nvmet: fix Reservation Register Replace for unregistered host with IEKEY
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengrong Li <[email protected]>
[ Upstream commit 0a96b9e440331bffbf049f80d7e5c96417d37e36 ]
When a host sends a Reservation Register command with RREGA=Replace and IEKEY=1 without being previously registered, nvmet returns Reservation Conflict.
The NVMe specification states:
"A host may replace its reservation key without regard to its
registration status or current reservation key value by setting the Ignore Existing Key (IEKEY) bit to '1' in the Reservation Register command."
Fix nvmet_pr_replace() to add a new registrant when the host is not found in the registrant list and IEKEY is set with a non-zero NRKEY. If IEKEY is set but NRKEY is zero, return Invalid Field since there is no valid reservation key to register.
Tested with nvme-cli against nvmet-tcp:
# no prior registration nvme resv-register /dev/nvmeXn1 -n 1 --rrega=2 --iekey --nrkey=0x9999
Before: RESERVATION_CONFLICT (0x4083)
After: success, registrant created with rkey 0x9999
--- drivers/nvme/target/pr.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
drivers/nvme/target/pr.c +25 -2
@@ -355,9 +355,15 @@ static u16 nvmet_pr_replace(struct nvmet_req *req,u16 status =NVME_SC_RESERVATION_CONFLICT |NVME_STATUS_DNR ;struct nvmet_ctrl *ctrl = req->sq->ctrl;struct nvmet_pr *pr = &req->ns->pr; -struct nvmet_pr_registrant *reg; +struct nvmet_pr_registrant *reg, *new =NULL ;u64 nrkey =le64_to_cpu (d->nrkey); +if (ignore_key && nrkey) { + new =kzalloc_obj (*new); +if (!new) +return NVME_SC_INTERNAL ; + } +down (&pr->pr_sem);list_for_each_entry_rcu (reg, &pr->registrant_list, entry) {if (uuid_equal (®->hostid, &ctrl->hostid)) {
@@ -365,9 +371,26 @@ static u16 nvmet_pr_replace(struct nvmet_req *req, status =nvmet_pr_update_reg_attr (pr, reg, nvmet_pr_update_reg_rkey, &nrkey); -break ; + goto free_data; + } + } + +if (ignore_key) { +if (!nrkey) { + status =NVME_SC_INVALID_FIELD |NVME_STATUS_DNR ; + goto free_data; } +INIT_LIST_HEAD (&new->entry); + new->rkey = nrkey; +uuid_copy (&new->hostid, &ctrl->hostid); +list_add_tail_rcu (&new->entry, &pr->registrant_list); + status =NVME_SC_SUCCESS ; + goto out; } + +free_data: +kfree (new); +out:up (&pr->pr_sem);return status; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1319/1815 nvmet: propagate percpu_ref_init() failure in nvmet_ns_enable()
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 751709592d2626eaa8dc17ef8137796758a3c37f ]
The return value of percpu_ref_init() is discarded. At this point ret is 0 from the preceding successful steps, so when the allocation inside percpu_ref_init() fails the code jumps to the out_pr_exit cleanup chain which ends with "return ret", i.e. reports success. The configfs enable store then tells userspace the namespace was enabled even though it was not and its backing device has already been torn down.
Capture the return value so the failure is propagated.
--- drivers/nvme/target/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/target/core.c +2 -1
@@ -610,7 +610,8 @@ int nvmet_ns_enable(struct nvmet_ns *ns) goto out_dev_put; } -if (percpu_ref_init (&ns->ref, nvmet_destroy_namespace,0 ,GFP_KERNEL )) + ret =percpu_ref_init (&ns->ref, nvmet_destroy_namespace,0 ,GFP_KERNEL ); +if (ret) goto out_pr_exit;nvmet_ns_changed (subsys, ns->nsid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1320/1815 nvme-pci: release descriptor pools on probe failure
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 cb144c2f67128abfa5c7ba33318617d19f192156 ]
The per-NUMA-node descriptor DMA pools are created lazily from nvme_init_hctx_common() once the admin tag set is allocated, but they are only destroyed in nvme_remove() via nvme_release_descriptor_pools(). Any probe failure after the admin tag set has been allocated unwinds through the out_disable label and nvme_pci_free_ctrl(), neither of which releases the pools, leaking the dma_pool objects.
Release the descriptor pools in the out_disable error path. It must not be added to nvme_pci_free_ctrl(), as that would double-free against nvme_remove() on the normal teardown path.
--- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvme/host/pci.c +1 -0
@@ -3840,6 +3840,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)nvme_dev_remove_admin (dev);nvme_dbbuf_dma_free (dev);nvme_free_queues (dev,0 ); +nvme_release_descriptor_pools (dev); out_release_iod_mempool:mempool_destroy (dev->dmavec_mempool); out_dev_unmap:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1321/1815 cgroup/cpuset: Use WRITE_ONCE() for shared prs_err updates
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guopeng Zhang <[email protected]>
[ Upstream commit 26d3a59e0241c3ef9f66ae1ae990f9326acbc059 ]
cpuset_partition_show() reads cs->prs_err without cpuset_mutex using READ_ONCE(). The field is documented as not lock protected, but several updates to live cpusets still use plain stores.
Convert the remaining prs_err stores on live cpusets to WRITE_ONCE().
--- kernel/cgroup/cpuset.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
kernel/cgroup/cpuset.c +13 -11
@@ -1548,7 +1548,7 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs,cpumask_copy (cs->effective_xcpus, tmp->new_cpus);spin_unlock_irq (&callback_lock);cpuset_force_rebuild (); - cs->prs_err =0 ; +WRITE_ONCE (cs->prs_err,0 );/* * Propagate changes in top_cpuset's effective_cpus down the hierarchy.
@@ -1622,7 +1622,7 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,WARN_ON_ONCE (!cpumask_subset (cs->effective_xcpus, subpartitions_cpus));if (cpumask_empty (excpus)) { - cs->prs_err =PERR_CPUSEMPTY ; +WRITE_ONCE (cs->prs_err,PERR_CPUSEMPTY ); goto invalidate; }
@@ -1637,13 +1637,13 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,if (adding) {WARN_ON_ONCE (cpumask_intersects (tmp->addmask, subpartitions_cpus));if (!capable (CAP_SYS_ADMIN )) - cs->prs_err =PERR_ACCESS ; +WRITE_ONCE (cs->prs_err,PERR_ACCESS );else if (cpumask_intersects (tmp->addmask, subpartitions_cpus) ||cpumask_subset (top_cpuset.effective_cpus, tmp->addmask)) - cs->prs_err =PERR_NOCPUS ; +WRITE_ONCE (cs->prs_err,PERR_NOCPUS );else if ((prs ==PRS_ISOLATED ) && !isolated_cpus_can_update (tmp->addmask, tmp->delmask)) - cs->prs_err =PERR_HKEEPING ; +WRITE_ONCE (cs->prs_err,PERR_HKEEPING );if (cs->prs_err) goto invalidate; }
@@ -2071,13 +2071,13 @@ static void compute_partition_effective_cpumask(struct cpuset *cs,* partition root. */ WARN_ON_ONCE (is_remote_partition (child)); - child->prs_err =0 ; +WRITE_ONCE (child->prs_err,0 );if (!cpumask_subset (child->effective_xcpus, cs->effective_xcpus)) - child->prs_err =PERR_INVCPUS ; +WRITE_ONCE (child->prs_err,PERR_INVCPUS );else if (populated &&cpumask_subset (new_ecpus, child->effective_xcpus)) - child->prs_err =PERR_NOCPUS ; +WRITE_ONCE (child->prs_err,PERR_NOCPUS );if (child->prs_err) {int old_prs = child->partition_root_state;
@@ -2381,8 +2381,10 @@ static void partition_cpus_change(struct cpuset *cs, struct cpuset *trialcs,return ; prs_err =validate_partition (cs, trialcs); -if (prs_err) - trialcs->prs_err = cs->prs_err = prs_err; +if (prs_err) { +WRITE_ONCE (cs->prs_err, prs_err); + trialcs->prs_err = prs_err; + }if (is_remote_partition (cs)) {if (trialcs->prs_err)
@@ -3801,7 +3803,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)if (remote && (cpumask_empty (subpartitions_cpus) || (cpumask_empty (&new_cpus) &&partition_is_populated (cs,NULL )))) { - cs->prs_err =PERR_HOTPLUG ; +WRITE_ONCE (cs->prs_err,PERR_HOTPLUG );remote_partition_disable (cs, tmp);compute_effective_cpumask (&new_cpus, cs, parent); remote = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1322/1815 selftests/cgroup: Avoid awk -e in cpuset tests
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 75e79a20190040800445ec95a4c4a84193d16992 ]
The cpuset selftests use awk -e to parse cgroup mount points. This works with gawk, but mawk rejects the option. In test_cpuset_prs.sh, this leaves CGROUP2 empty and causes the test to skip as if cgroup v2 were not mounted. The same non-portable invocation exists in the cpuset v1 hotplug test.
The scripts only need to pass a single awk program. Use the standard awk invocation without -e so mount point detection works with awk implementations that do not support the gawk extension.
--- tools/testing/selftests/cgroup/test_cpuset_prs.sh | 2 +- tools/testing/selftests/cgroup/test_cpuset_v1_hp.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/cgroup/test_cpuset_prs.sh +1 -1
@@ -20,7 +20,7 @@ skip_test() { WAIT_INOTIFY=$(cd $(dirname $0); pwd)/wait_inotify # Find cgroup v2 mount point -CGROUP2=$(mount -t cgroup2 | head -1 | awk -e '{print $3}') +CGROUP2=$(mount -t cgroup2 | head -1 | awk '{print $3}') [[ -n "$CGROUP2" ]] || skip_test "Cgroup v2 mount point not found!" SUBPARTS_CPUS=$CGROUP2/.__DEBUG__.cpuset.cpus.subpartitions CPULIST=$(cat $CGROUP2/cpuset.cpus.effective)
tools/testing/selftests/cgroup/test_cpuset_v1_hp.sh +1 -1
@@ -14,7 +14,7 @@ skip_test() { [[ $(id -u) -eq 0 ]] || skip_test "Test must be run as root!" # Find cpuset v1 mount point -CPUSET=$(mount -t cgroup | grep cpuset | head -1 | awk -e '{print $3}') +CPUSET=$(mount -t cgroup | grep cpuset | head -1 | awk '{print $3}') [[ -n "$CPUSET" ]] || skip_test "cpuset v1 mount point not found!" #
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1323/1815 selftests/sched_ext: Check skeleton open failure in exit test
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liang Luo <[email protected]>
[ Upstream commit 4dc310b41aba43e9d8dfafe46dce86f8b55c0354 ]
exit.c does not check the return value of exit__open(). If it returns NULL, which happens when the skeleton wrapper fails to allocate the object or open the BPF ELF, the very next line dereferences it via SCX_ENUM_INIT(). That macro expands to SCX_ENUM_SET(), which accesses skel->rodata, causing a NULL pointer dereference.
Every other selftest guards this with SCX_FAIL_IF(!skel, ...); exit.c is the only one missing it.
--- tools/testing/selftests/sched_ext/exit.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/sched_ext/exit.c +1 -0
@@ -31,6 +31,7 @@ static enum scx_test_status run(void *ctx)continue ; skel =exit__open (); +SCX_FAIL_IF (!skel,"Failed to open" );SCX_ENUM_INIT (skel); skel->rodata->exit_point = tc;SCX_FAIL_IF (exit__load (skel),"Failed to load skel" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1324/1815 pinctrl: rockchip: Decode drive strength in the get function
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Glass <[email protected]>
[ Upstream commit 8aa25c6e8893ed911b0cad37a5562fda9bc98438 ]
The decoding of the 2-bit and 8-bit level drive-strength values sits in rockchip_set_drive_perpin(), where it is unreachable: the SoCs whose banks declare these drive types (RK3506 and RV1103B) take the early ctrl->type branch in the set path, and the read-and-decode logic in a set function has no purpose. Meanwhile rockchip_get_drive_perpin() lacks the decoding, so pin_config_get() and the debugfs output report -EINVAL for these SoCs.
Move the two cases to rockchip_get_drive_perpin(), where they belong.
--- drivers/pinctrl/pinctrl-rockchip.c | 38 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/pinctrl/pinctrl-rockchip.c +19 -19
@@ -3267,6 +3267,25 @@ static int rockchip_get_drive_perpin(struct rockchip_pin_bank *bank,case DRV_TYPE_IO_1V8_ONLY : rmask_bits =RK3288_DRV_BITS_PER_PIN ;break ; +case DRV_TYPE_IO_LEVEL_2_BIT : + ret =regmap_read (regmap, reg, &data); +if (ret) +return ret; + data >>= bit; + +return data &0x3 ; +case DRV_TYPE_IO_LEVEL_8_BIT : + ret =regmap_read (regmap, reg, &data); +if (ret) +return ret; + data >>= bit; + data &= (1 <<8 ) -1 ; + + ret =hweight8 (data); +if (ret >0 ) +return ret -1 ; +else +return -EINVAL ;default :dev_err (dev,"unsupported pinctrl drive type: %d\n" , drv_type);return -EINVAL ;
@@ -3390,25 +3409,6 @@ static int rockchip_set_drive_perpin(struct rockchip_pin_bank *bank,case DRV_TYPE_IO_1V8_ONLY : rmask_bits =RK3288_DRV_BITS_PER_PIN ;break ; -case DRV_TYPE_IO_LEVEL_2_BIT : - ret =regmap_read (regmap, reg, &data); -if (ret) -return ret; - data >>= bit; - -return data &0x3 ; -case DRV_TYPE_IO_LEVEL_8_BIT : - ret =regmap_read (regmap, reg, &data); -if (ret) -return ret; - data >>= bit; - data &= (1 <<8 ) -1 ; - - ret =hweight8 (data); -if (ret >0 ) -return ret -1 ; -else -return -EINVAL ;default :dev_err (dev,"unsupported pinctrl drive type: %d\n" , drv_type);return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1325/1815 amt: Dont support cross-netns setup.
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit e99ecc3046ea5f5c6b5e1f8b4ef854c6c6998e06 ]
When a lower device is unregistered, amt_device_event() tries to unregister its upper AMT device, but it has two problems.
1. amt_lookup_upper_dev() looks up an upper device in the lower device's netns only
2. amt_device_event() unregisters a single upper device only
If AMT device is created on a lower device in another netns, removing the lower device triggers the splat below and gets stuck until all upper devices are removed. [0]
The cross-netns setup seems unintentional considering 1. and the following points:
* amt_link_setup() sets dev->netns_immutable to true
* skb_scrub_packet() is not called in the fast path
* iproute2 binary fails to find cross-netns lower device via link-netns:
# ip -n ns1 link add amt0 link-netns ns2 type amt dev veth1 Cannot find device "veth1"
Instead of supporting it properly and preparing for per-netns netdev unreg, let's forbid cross-netns setup.
Note that the problem 2. needs a separate fix.
[0]:
WARNING: net/core/dev.c:12518 at unregister_netdevice_many_notify+0x1cce/0x2250, CPU#48: ip/2031
Modules linked in:
CPU: 48 UID: 0 PID: 2031 Comm: ip Not tainted 7.2.0-rc5+ #27 PREEMPT(full)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1 04/01/2014
RIP: 0010:unregister_netdevice_many_notify (net/core/dev.c:12518)
Code: 89 ef e8 d5 52 ae fe e9 d0 f4 ff ff 48 8d 3d f9 3b 9c 02 48 c7 c6 c0 0b 63 84 ba ab 1f 00 00 67 48 0f b9 3a e9 65 ff ff ff 90 <0f> 0b 90 eb 81 48 8d 3d f6 3b 9c 02 48 c7 c6 c0 0b 63 84 ba e2 1f
RSP: 0018:ffffc90004abf160 EFLAGS: 00010212
RAX: ffff888104d38260 RBX: ffff88800b0911b8 RCX: dffffc0000000000
RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffffffff85b9f880
RBP: ffffc90004abf2d0 R08: ffffffff85b9f887 R09: 1ffffffff0b73f10
R10: dffffc0000000000 R11: fffffbfff0b73f11 R12: ffff88800b091d08
R13: ffff88800b091178 R14: dffffc0000000000 R15: ffff88800b091000
FS: 00007f555b86c600(0000) GS:ffff8881942a0000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000562107d489c0 CR3: 0000000109a40002 CR4: 0000000000372ef0
Call Trace:
<TASK>
rtnl_dellink (net/core/rtnetlink.c:3632 net/core/rtnetlink.c:3674)
rtnetlink_rcv_msg (net/core/rtnetlink.c:7112)
netlink_rcv_skb (net/netlink/af_netlink.c:2556)
netlink_unicast (net/netlink/af_netlink.c:1319)
netlink_sendmsg (net/netlink/af_netlink.c:1900)
____sys_sendmsg (net/socket.c:775)
__sys_sendmsg (net/socket.c:2738)
do_syscall_64 (arch/x86/entry/syscall_64.c:63)
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
...
unregister_netdevice: waiting for veth0 to become free. Usage count = 7
ref_tracker: netdev@ffff88800d7496d8 has 3/3 users at
__netdev_adjacent_dev_insert (./include/linux/netdevice.h:4525 ./include/linux/netdevice.h:4554 net/core/dev.c:8791)
__netdev_upper_dev_link (net/core/dev.c:8879 net/core/dev.c:8963)
netdev_upper_dev_link (net/core/dev.c:9009)
amt_newlink (drivers/net/amt.c:3321)--- drivers/net/amt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/amt.c +3 -0
@@ -3221,6 +3221,9 @@ static int amt_newlink(struct net_device *dev,struct nlattr **tb = params->tb;int err = -EINVAL ; +if (!net_eq (link_net,dev_net (dev))) +return err; + amt->net = link_net; amt->mode =nla_get_u32 (data[IFLA_AMT_MODE ]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1326/1815 PCI: ultrarisc: Get and enable DP1000 PCIe controller clocks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Wang <[email protected]>
[ Upstream commit e152c295d32a15975c480c352000454b9eb5fb07 ]
Add the required core, dbi, and aux clocks for the DP1000 PCIe controller and enable them before initializing the controller.
Also manage the clocks across system suspend and resume.
--- drivers/pci/controller/dwc/pcie-ultrarisc.c | 85 +++++++++++++++++++-- 1 file changed, 78 insertions(+), 7 deletions(-)
drivers/pci/controller/dwc/pcie-ultrarisc.c +78 -7
@@ -5,6 +5,7 @@* Copyright (C) 2026 UltraRISC Technology (Shanghai) Co., Ltd. */ +#include <linux/clk.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/of_device.h>
@@ -23,6 +24,12 @@#define ULTRARISC_PCIE_COMP_TIMEOUT_65_210MS 0x6 +struct ultrarisc_pcie { +struct dw_pcie pci; +struct clk_bulk_data *clks; +int num_clks; +}; +static struct pci_ops ultrarisc_pci_ops = { .map_bus = dw_pcie_own_conf_map_bus, .read = pci_generic_config_read32,
@@ -98,17 +105,47 @@ static const struct dw_pcie_ops dw_pcie_ops = { .start_link = ultrarisc_pcie_start_link, }; +static int ultrarisc_pcie_enable_clks (struct ultrarisc_pcie *ultra) +{ +return clk_bulk_prepare_enable (ultra->num_clks, ultra->clks); +} + +static void ultrarisc_pcie_disable_clks (void *data) +{ +struct ultrarisc_pcie *ultra = data; + +clk_bulk_disable_unprepare (ultra->num_clks, ultra->clks); +} + +static int ultrarisc_pcie_init_clks (struct ultrarisc_pcie *ultra) +{ +struct device *dev = ultra->pci.dev; +int ret; + + ultra->num_clks =devm_clk_bulk_get_all (dev, &ultra->clks); +if (ultra->num_clks <0 ) +return dev_err_probe (dev, ultra->num_clks,"Failed to get clocks\n" ); + + ret =ultrarisc_pcie_enable_clks (ultra); +if (ret) +return dev_err_probe (dev, ret,"Failed to enable clocks\n" ); + +return devm_add_action_or_reset (dev, ultrarisc_pcie_disable_clks, ultra); +} +static int ultrarisc_pcie_probe (struct platform_device *pdev) { +struct ultrarisc_pcie *ultra;struct device *dev = &pdev->dev;struct dw_pcie_rp *pp;struct dw_pcie *pci;int ret; - pci =devm_kzalloc (dev,sizeof (*pci),GFP_KERNEL ); -if (!pci) + ultra =devm_kzalloc (dev,sizeof (*ultra),GFP_KERNEL ); +if (!ultra)return -ENOMEM ; + pci = &ultra->pci; pci->dev = dev; pci->ops = &dw_pcie_ops;
@@ -117,7 +154,11 @@ static int ultrarisc_pcie_probe(struct platform_device *pdev) pp = &pci->pp; -platform_set_drvdata (pdev, pci); +platform_set_drvdata (pdev, ultra); + + ret =ultrarisc_pcie_init_clks (ultra); +if (ret) +return ret; pp->num_vectors =MAX_MSI_IRQS ;/* No L2/L3 Ready indication is available on this platform */
@@ -135,16 +176,46 @@ static int ultrarisc_pcie_probe(struct platform_device *pdev)static int ultrarisc_pcie_suspend_noirq (struct device *dev) { -struct dw_pcie *pci =dev_get_drvdata (dev); +struct ultrarisc_pcie *ultra =dev_get_drvdata (dev); +struct dw_pcie *pci = &ultra->pci; +int ret; + +/* +* A failed resume leaves the DWC suspended and the clocks disabled. +* A later suspend must not access the controller or disable them again. +*/ +if (pci->suspended) +return 0 ; + + ret =dw_pcie_suspend_noirq (pci); +if (ret) +return ret; + +if (pci->suspended) +ultrarisc_pcie_disable_clks (ultra); -return dw_pcie_suspend_noirq (pci); +return 0 ; }static int ultrarisc_pcie_resume_noirq (struct device *dev) { -struct dw_pcie *pci =dev_get_drvdata (dev); +struct ultrarisc_pcie *ultra =dev_get_drvdata (dev); +struct dw_pcie *pci = &ultra->pci; +int ret; -return dw_pcie_resume_noirq (pci); +if (pci->suspended) { + ret =ultrarisc_pcie_enable_clks (ultra); +if (ret) +return ret; + + ret =dw_pcie_resume_noirq (pci); +if (ret) { +ultrarisc_pcie_disable_clks (ultra); +return ret; + } + } + +return 0 ; }static const struct dev_pm_ops ultrarisc_pcie_pm_ops = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1327/1815 selftests: drv-net: Test queue stall upon reconfig
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohsin Bashir <[email protected]>
[ Upstream commit c98610c2eb7002436f6fca55b21c63200644549a ]
Add a reconfig_tx_stall test that detects the possibility of a TX stall after ring reconfiguration. The key observation is that drivers using netif_tx_start_all_queues() are prone to experiencing a stall when reconfiguration completes compared to drivers using netif_tx_wake_all_queues(). start_all_queues only clears DRV_XOFF, while wake_all_queues also calls __netif_schedule() to kick the qdisc. Without the kick, qdisc backlog present at reconfig time can stay stuck until a new trigger is issued.
The test caps the TX ring at 64 entries so it fills quickly, then installs FQ on a target TX queue and sends UDP packets with SO_TXTIME scheduled in the future. With napi_defer_hard_irqs slowing completions, the small ring can fill when FQ releases the burst, leaving requeued qdisc backlog with no FQ timer to rescue it. A subsequent ring reconfig must wake the queues to drain the backlog. Simply starting the queues can leave it stuck.
Some drivers lack backpressure on the TX path and may not be able to build up the qdisc backlog the test relies on. In that case report an expected failure (xfail) instead of a hard failure.
Testing on some of the existing drivers: Driver-A does not have the bug, Driver-B has the bug, Driver-C had the bug but it is fixed now.
Driver-A:./drivers/net/ring_reconfig.py -t reconfig_tx_stall TAP version 13
1..1
Sent 1024 SO_TXTIME packets (+100ms)
Backlog before reconfig: 1176378 bytes
ok 1 ring_reconfig.reconfig_tx_stall
Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
Driver-B:
TAP version 13
1..1
Sent 128 SO_TXTIME packets (+100ms)
Sent 128 SO_TXTIME packets (+200ms)
Backlog before reconfig: 148372 bytes
Check| At ./drivers/net/ring_reconfig.py, line 397, in reconfig_tx_stall:
Check| ksft_eq(0, backlog,
Check failed 0 != 148372 qdisc backlog stuck on queue 1 after ring ....
not ok 1 ring_reconfig.reconfig_tx_stall
Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0
Driver-C:
TAP version 13
1..1
Sent 128 SO_TXTIME packets (+100ms)
Backlog before reconfig: 192278 bytes
ok 1 ring_reconfig.reconfig_tx_stall
Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
Stable-dep-of: ef3d6cca02c8 ("selftests: drv-net: so_txtime: only send test traffic to sch_etf")
--- tools/testing/selftests/drivers/net/config | 3 + .../selftests/drivers/net/lib/py/env.py | 11 +- .../selftests/drivers/net/ring_reconfig.py | 255 +++++++++++++++++- 3 files changed, 263 insertions(+), 6 deletions(-)
tools/testing/selftests/drivers/net/config +3 -0
@@ -4,8 +4,11 @@ CONFIG_DEBUG_INFO_BTF_MODULES=n CONFIG_INET_PSP=y CONFIG_IPV6=y CONFIG_MACSEC=m +CONFIG_NET_ACT_SKBEDIT=m CONFIG_NET_CLS_ACT=y CONFIG_NET_CLS_BPF=y +CONFIG_NET_CLS_FLOWER=m +CONFIG_NET_CLS_MATCHALL=m CONFIG_NETCONSOLE=m CONFIG_NETCONSOLE_DYNAMIC=y CONFIG_NETCONSOLE_EXTENDED_LOG=y
tools/testing/selftests/drivers/net/lib/py/env.py +8 -3
@@ -114,10 +114,11 @@ class NetDrvEpEnv(NetDrvEnvBase): nsim_v4_pfx = "192.0.2." nsim_v6_pfx = "2001:db8::" - def __init__(self, src_path, nsim_test=None): + def __init__(self, src_path, nsim_test=None, queue_count=None): super().__init__(src_path) self._stats_settle_time = None + self._queue_count = queue_count # Things we try to destroy self.remote = None
@@ -179,9 +180,13 @@ class NetDrvEpEnv(NetDrvEnvBase): self._required_cmd = {} def create_local(self): + nsim_kwargs = {} + if self._queue_count: + nsim_kwargs["queue_count"] = self._queue_count + self._netns = NetNS() - self._ns = NetdevSimDev() - self._ns_peer = NetdevSimDev(ns=self._netns) + self._ns = NetdevSimDev(**nsim_kwargs) + self._ns_peer = NetdevSimDev(ns=self._netns, **nsim_kwargs) with open("/proc/self/ns/net") as nsfd0, \ open("/var/run/netns/" + self._netns.name) as nsfd1:
tools/testing/selftests/drivers/net/ring_reconfig.py +252 -3
276 lines not on this page · raw message
Signature · 1 line
2.53.0