6.12.119-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 1130/1756 thermal/drivers/ti-soc-thermal: Cancel pending alert work on remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weigang He <[email protected]>
[ Upstream commit aaa6c8dec49339710f9fd2a2af5646cf4111dbd4 ]
On a threshold crossing, the talert IRQ handler calls ti_thermal_report_sensor_temperature(), which queues the work embedded in the sensor's ti_thermal_data on the system workqueue. Nothing ever cancels or flushes that work.
ti_bandgap_remove() frees the talert IRQ last. free_irq() waits for a running handler, but not for the work the handler has queued. When remove returns, devres unregisters and frees the thermal zones and then frees the devm-allocated ti_thermal_data, so a work item that is still pending runs ti_thermal_work() on freed memory:
ti_thermal_work() data = container_of(work, struct ti_thermal_data, thermal_wq); thermal_zone_device_update(data->ti_thermal, ...);
Free the talert IRQ before removing the sensors, so that no new work can be queued, and cancel the work in ti_thermal_remove_sensor().
This needs an OMAP4460/4470 or OMAP5 SoC (DRA7 has TALERT but no ->report_temperature, so it never queues the work), a threshold crossing just before the driver is unbound or unloaded, and the work still pending when devres frees the data.
Found by static analysis tool CodeQL.
--- drivers/thermal/ti-soc-thermal/ti-bandgap.c | 7 ++++--- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/thermal/ti-soc-thermal/ti-bandgap.c +4 -3
@@ -1077,6 +1077,10 @@ void ti_bandgap_remove(struct platform_device *pdev)if (!soc_device_match (soc_no_cpu_notifier))cpu_pm_unregister_notifier (&bgp->nb); +/* Stop the alerts first: they queue work on the sensors' data */ +if (TI_BANDGAP_HAS (bgp,TALERT )) +free_irq (bgp->irq, bgp); +/* Remove sensor interfaces */ for (i =0 ; i < bgp->conf->sensor_count; i++) {if (bgp->conf->sensors[i].unregister_cooling)
@@ -1093,9 +1097,6 @@ void ti_bandgap_remove(struct platform_device *pdev)clk_put (bgp->fclock);clk_put (bgp->div_clk); -if (TI_BANDGAP_HAS (bgp,TALERT )) -free_irq (bgp->irq, bgp); -if (TI_BANDGAP_HAS (bgp,TSHUT ))free_irq (gpiod_to_irq (bgp->tshut_gpiod),NULL ); }
drivers/thermal/ti-soc-thermal/ti-thermal-common.c +4 -0
@@ -195,6 +195,10 @@ int ti_thermal_remove_sensor(struct ti_bandgap *bgp, int id) data =ti_bandgap_get_sensor_data (bgp, id); +/* Work queued by the talert IRQ must not outlive the data */ +if (!IS_ERR_OR_NULL (data)) +cancel_work_sync (&data->thermal_wq); +if (!IS_ERR_OR_NULL (data) && data->ti_thermal) {if (data->our_zone)thermal_zone_device_unregister (data->ti_thermal);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1131/1756 tools: hv: remove unused rte_smp_mb()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit b67eeae485e22893b678229169024a73b87cf113 ]
rte_smp_mb() has never been used, and its "static inline __always_inline" declares inline twice, so clang warns:
vmbus_bufring.c:61:15: warning: duplicate 'inline' declaration specifier [-Wduplicate-decl-specifier] vmbus_bufring.c:62:1: warning: unused function 'rte_smp_mb' [-Wunused-function]
Remove it.
--- tools/hv/vmbus_bufring.c | 6 ------ 1 file changed, 6 deletions(-)
tools/hv/vmbus_bufring.c +0 -6
@@ -58,12 +58,6 @@ void vmbus_br_setup(struct vmbus_br *br, void *buf, unsigned int blen) br->dsize = blen -sizeof (struct vmbus_bufring ); } -static inline __always_inline void -rte_smp_mb (void ) -{ - asmvolatile ("lock addl $0, -128(%%rsp); " :::"memory" ); -} -static inline int rte_atomic32_cmpset (volatile uint32_t *dst,uint32_t exp,uint32_t src) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1132/1756 char: scx200_gpio: check cdev_add() return value
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit fe26c195c265c033e474d015061a0183c7a02193 ]
cdev_add() can fail. The driver currently ignores the return value and reports probe success even when the cdev was not registered, leaving a chrdev region allocated with no working file operations.
Check the return value, emit an error, and unwind the chrdev region and platform device on failure.
--- drivers/char/scx200_gpio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/char/scx200_gpio.c +7 -1
@@ -107,10 +107,16 @@ static int __init scx200_gpio_init(void) }cdev_init (&scx200_gpio_cdev, &scx200_gpio_fileops); -cdev_add (&scx200_gpio_cdev, devid,MAX_PINS ); + rc =cdev_add (&scx200_gpio_cdev, devid,MAX_PINS ); +if (rc) { +dev_err (&pdev->dev,"cdev_add err: %d\n" , rc); + goto undo_chrdev_region; + }return 0 ;/* succeed */ +undo_chrdev_region: +unregister_chrdev_region (devid,MAX_PINS ); undo_platform_device_add:platform_device_del (pdev); undo_malloc:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1133/1756 bus: arm-cci: Drop CPU node reference in cci_ace_init_ports()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 41d6c0fcd4d75bf78c304c6660d60fcf757885ce ]
cci_ace_init_ports() looks up each possible CPU's node with of_get_cpu_node(), which returns the node with its reference count raised, but never releases it: neither when the CPU has no ACE port nor after the port has been recorded. Before the commit below the loop used for_each_child_of_node(), which manages the references itself.
The node is only needed for the port lookup, so drop the reference right after __cci_ace_get_port().
--- drivers/bus/arm-cci.c | 1 + 1 file changed, 1 insertion(+)
drivers/bus/arm-cci.c +1 -0
@@ -199,6 +199,7 @@ static void cci_ace_init_ports(void)continue ; port =__cci_ace_get_port (cpun,ACE_PORT ); +of_node_put (cpun);if (port <0 )continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1134/1756 bus: arm-cci: Drop cci-control-port node reference in __cci_ace_get_port()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 810ccc792193909ba9bbb4246e0eb0de14dad724 ]
__cci_ace_get_port() looks up the device's "cci-control-port" node with of_parse_phandle(), which returns the node with its reference count raised, and only compares the pointer against the probed ports. Neither the match nor the no-match return releases it.
Drop the reference on both paths once the comparison is done.
--- drivers/bus/arm-cci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/bus/arm-cci.c +4 -1
@@ -167,9 +167,12 @@ static int __cci_ace_get_port(struct device_node *dn, int type) cci_portn =of_parse_phandle (dn,"cci-control-port" ,0 );for (i =0 ; i < nb_cci_ports; i++) { ace_match = ports[i].type == type; -if (ace_match && cci_portn == ports[i].dn) +if (ace_match && cci_portn == ports[i].dn) { +of_node_put (cci_portn);return i; + } } +of_node_put (cci_portn);return -ENODEV ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1135/1756 clk: qcom: gcc-x1e80100: Dont poll the status bit of GCC_USB4_n_SYS_CLK
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit d42e0c55e6db7b8282e8dc63f7e70595da0f72f5 ]
These clocks are PHY-sourced and their halt bits seem not to update reliably. Ignore it to prevent spurious warnings.
--- drivers/clk/qcom/gcc-x1e80100.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/qcom/gcc-x1e80100.c +3 -3
@@ -5988,7 +5988,7 @@ static struct clk_branch gcc_usb4_0_sb_if_clk = {static struct clk_branch gcc_usb4_0_sys_clk = { .halt_reg =0x9f054 , - .halt_check =BRANCH_HALT , + .halt_check =BRANCH_HALT_SKIP , .clkr = { .enable_reg =0x9f054 , .enable_mask =BIT (0 ),
@@ -6205,7 +6205,7 @@ static struct clk_branch gcc_usb4_1_sb_if_clk = {static struct clk_branch gcc_usb4_1_sys_clk = { .halt_reg =0x2b054 , - .halt_check =BRANCH_HALT , + .halt_check =BRANCH_HALT_SKIP , .clkr = { .enable_reg =0x2b054 , .enable_mask =BIT (0 ),
@@ -6422,7 +6422,7 @@ static struct clk_branch gcc_usb4_2_sb_if_clk = {static struct clk_branch gcc_usb4_2_sys_clk = { .halt_reg =0x11054 , - .halt_check =BRANCH_HALT , + .halt_check =BRANCH_HALT_SKIP , .clkr = { .enable_reg =0x11054 , .enable_mask =BIT (0 ),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1136/1756 clk: qcom: mmcc-msm8996: Fix FD AHB clock register offset
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit 7cb2d65286b817d8d7e26f454a9c374d65e87072 ]
The FD AHB clock branch register is at offset 0x3b74, not 0x3ba74. The incorrect offset exceeds the regmap maximum of 0xb008, so regmap rejects accesses to it and the clock cannot be enabled.
Correct both the enable and halt register offsets so the driver can enable the branch and check its status.
--- drivers/clk/qcom/mmcc-msm8996.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/mmcc-msm8996.c +2 -2
@@ -3136,9 +3136,9 @@ static struct clk_branch fd_core_uar_clk = { };static struct clk_branch fd_ahb_clk = { - .halt_reg =0x3ba74 , + .halt_reg =0x3b74 , .clkr = { - .enable_reg =0x3ba74 , + .enable_reg =0x3b74 , .enable_mask =BIT (0 ), .hw.init = &(struct clk_init_data ){ .name ="fd_ahb_clk" ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1137/1756 clk: qcom: mmcc-sdm660: Fix MDSS AHB clock HWCG register offset
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit c5f338329a2d0d60f7874aa7a1addaa0e4e75a3b ]
The MDSS AHB clock HWCG bit resides in the same register as the branch enable and halt status bits, at offset 0x2308. The current HWCG register offset of 0x8a004 exceeds the regmap maximum of 0x40000, so regmap rejects the read in clk_branch_in_hwcg_mode(). Since the read error is ignored, the helper uses an uninitialized value to decide whether to skip the halt status check.
Correct the HWCG register offset so the helper reads the actual hardware clock gating state.
--- drivers/clk/qcom/mmcc-sdm660.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/mmcc-sdm660.c +1 -1
@@ -2022,7 +2022,7 @@ static struct clk_branch csiphy_ahb2crif_clk = {static struct clk_branch mdss_ahb_clk = { .halt_reg =0x2308 , .halt_check =BRANCH_HALT , - .hwcg_reg =0x8a004 , + .hwcg_reg =0x2308 , .hwcg_bit =1 , .clkr = { .enable_reg =0x2308 ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1138/1756 clk: qcom: mmcc-msm8960: Configure PLL15 only on APQ8064
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit 342db3b6cf7bad2a53ccd5e2d844faf260953d9d ]
PLL15 is specific to APQ8064, but the shared probe function configures it unconditionally, including on MSM8960. Its configuration registers at offsets 0x33c through 0x348 exceed the MSM8960 regmap maximum of 0x334, so regmap rejects these accesses. The PLL configuration helper ignores the errors and probe continues.
Only configure PLL15 when the selected descriptor is for APQ8064, matching the existing variant check for the GFX3D clock adjustments.
--- drivers/clk/qcom/mmcc-msm8960.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/qcom/mmcc-msm8960.c +2 -1
@@ -3120,7 +3120,8 @@ static int mmcc_msm8960_probe(struct platform_device *pdev)if (IS_ERR (regmap))return PTR_ERR (regmap); -clk_pll_configure_sr (&pll15, regmap, &pll15_config, false); +if (desc == &mmcc_apq8064_desc) +clk_pll_configure_sr (&pll15, regmap, &pll15_config, false);return qcom_cc_really_probe (&pdev->dev, desc, regmap); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1139/1756 clk: qcom: rcg2: Initialize shared floor clock state
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 72f34d429f6e51b0ef8c43ab7667c4fb4099dd46 ]
Shared floor RCGs use the cached parked_cfg whenever CCF considers the clock disabled. Unlike the other shared RCG variants, their ops do not initialize that cache, leaving it zeroed until the first disable or rate change. This can make registration report an undivided XO configuration instead of the boot-programmed parent and divider.
Initialize parked_cfg from CFG_REG without parking or otherwise changing the hardware. Propagate read failures so a clock with unknown initial state is not registered.
--- drivers/clk/qcom/clk-rcg2.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/clk/qcom/clk-rcg2.c +13 -13
@@ -1373,7 +1373,20 @@ const struct clk_ops clk_rcg2_shared_ops = { };EXPORT_SYMBOL_GPL (clk_rcg2_shared_ops); +static int clk_rcg2_shared_no_init_park (struct clk_hw *hw) +{ +struct clk_rcg2 *rcg =to_clk_rcg2 (hw); + +/* +* Read the config register so that the parent is properly mapped at +* registration time. +*/ +return regmap_read (rcg->clkr.regmap, rcg->cmd_rcgr +CFG_REG , + &rcg->parked_cfg); +} +const struct clk_ops clk_rcg2_shared_floor_ops = { + .init = clk_rcg2_shared_no_init_park, .enable = clk_rcg2_shared_enable, .disable = clk_rcg2_shared_disable, .get_parent = clk_rcg2_shared_get_parent,
@@ -1385,19 +1398,6 @@ const struct clk_ops clk_rcg2_shared_floor_ops = { };EXPORT_SYMBOL_GPL (clk_rcg2_shared_floor_ops); -static int clk_rcg2_shared_no_init_park (struct clk_hw *hw) -{ -struct clk_rcg2 *rcg =to_clk_rcg2 (hw); - -/* -* Read the config register so that the parent is properly mapped at -* registration time. -*/ -regmap_read (rcg->clkr.regmap, rcg->cmd_rcgr +CFG_REG , &rcg->parked_cfg); - -return 0 ; -} -/* * Like clk_rcg2_shared_ops but skip the init so that the clk frequency is left * unchanged at registration time.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1140/1756 clk: qcom: rcg2: Propagate force-enable status errors
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 8c0f93e10fa9e34009817bd37bb75c1b5a691fa2 ]
clk_rcg2_is_enabled() returns either a hardware status or a negative regmap error. The force-enable polling loop treats every nonzero return as an enabled clock, so a failed status read is incorrectly reported as success and clock reconfiguration can continue with unknown hardware state.
Check for negative returns before testing the enabled status and propagate the read error to the caller.
--- drivers/clk/qcom/clk-rcg2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg2.c +4 -1
@@ -1150,7 +1150,10 @@ static int clk_rcg2_set_force_enable(struct clk_hw *hw)/* wait for RCG to turn ON */ for (count =500 ; count >0 ; count--) { -if (clk_rcg2_is_enabled (hw)) + ret =clk_rcg2_is_enabled (hw); +if (ret <0 ) +return ret; +if (ret)return 0 ;udelay (1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1141/1756 clk: qcom: rcg2: Clear force enable after rate failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit d4e8c6b9aef42d06cf5755543ad10097b2217990 ]
Shared RCG rate changes assert force-enable before programming the new configuration. If programming fails, the function returns without clearing force-enable, leaving the root running while CCF can release temporary parent and resource references.
Attempt to clear force-enable on the configuration error path before returning the original programming error. This restores the same cleanup performed after a successful configuration while preserving the primary failure for callers.
--- drivers/clk/qcom/clk-rcg2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg2.c +3 -1
@@ -1182,8 +1182,10 @@ clk_rcg2_shared_force_enable_clear(struct clk_hw *hw, const struct freq_tbl *f)return ret; ret =clk_rcg2_configure (rcg, f); -if (ret) +if (ret) { +clk_rcg2_clear_force_enable (hw);return ret; + }return clk_rcg2_clear_force_enable (hw); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1142/1756 s390/ptrace: Preserve ILC when updating system call number
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 946b9dcff33bd4669464674ae1c00683b875be55 ]
When an attached debugger changes gpr2 via PTRACE_POKEUSR while the traced process has PIF_SYSCALL set, the int_code in pt_regs is also updated. In case of an svc it contains the instruction length code (ILC), as well as the system call number.
The ptrace code sets the ILC unconditionally to a value which matches the svc instruction. However the svc instruction also may have been executed via the execute or execute relative long instruction, which have a different length. Therefore preserve the ILC and only change the system call number using syscall_set_nr().
This makes sure that in case of a PSW rewind the instruction address points to the correct instruction.
--- arch/s390/kernel/ptrace.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/s390/kernel/ptrace.c +4 -5
@@ -32,6 +32,7 @@#include <asm/runtime_instr.h> #include <asm/facility.h> #include <asm/fpu.h> +#include <asm/syscall.h> #include "entry.h"
@@ -347,11 +348,9 @@ static int __poke_user(struct task_struct *child, addr_t addr, addr_t data)return -EINVAL ; } -if (test_pt_regs_flag (regs,PIF_SYSCALL ) && - addr == offsetof(struct user, regs.gprs[2])) { -struct pt_regs *regs =task_pt_regs (child); - - regs->int_code =0x20000 | (data &0xffff ); + if (addr == offsetof(struct user, regs.gprs[2])) { +if (test_pt_regs_flag (regs,PIF_SYSCALL )) +syscall_set_nr (child, regs, data); } *(addr_t *)((addr_t ) ®s->psw + addr) = data; } else if (addr < offsetof(struct user, regs.orig_gpr2)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1143/1756 s390/uprobes: Fix off-by-one bug in emulated PER handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 2ba01cf7b2598571486425a0605f1434909b532d ]
The uprobes code emulates some instructions, and with that also PER storage-alteration handling, in case a debugger is attached.
The PER storage-alteration handling contains an off-by-one bug, which may lead to PER traps which should not happen. Adjust the comparison in sim_stor_event() to fix that.
--- arch/s390/kernel/uprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/uprobes.c +1 -1
@@ -247,7 +247,7 @@ static void sim_stor_event(struct pt_regs *regs, void *addr, int len)return ;if (!(current->thread.per_user.control &PER_EVENT_STORE ))return ; -if ((void *)current->thread.per_user.start > (addr + len)) +if ((void *)current->thread.per_user.start > (addr + len -1 ))return ;if ((void *)current->thread.per_user.end < addr)return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1144/1756 nvme-tcp: fix selinux denied when calling sock_sendmsg
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peijie Shao <[email protected]>
[ Upstream commit 1be52169c3488ef98582ed553ab35cefa3978817 ]
In a SELinux enabled kernel, socket_create() initializes the security label of the socket using the security label of the calling process, this typically works well.
However, in a containerized environment like Kubernetes, problem arises when a privileged container(domain spc_t) connects to an NVMe target and mounts the NVMe as persistent storage for unprivileged containers(domain container_t).
This is because the container_t domain cannot access resources labeled with spc_t, resulting in socket_sendmsg returning -EACCES.
The solution is to use socket_create_kern() instead of socket_create(), which labels the socket context to kernel_t. Access control will then be handled by the VFS layer rather than the socket itself.
Stable-dep-of: 87a1ac965502 ("nvme-tcp: store and use the caller's network namespace")
--- drivers/nvme/host/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/tcp.c +2 -1
@@ -2033,7 +2033,8 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid, queue->cmnd_capsule_len =sizeof (struct nvme_command ) +NVME_TCP_ADMIN_CCSZ ; - ret =sock_create (ctrl->addr.ss_family,SOCK_STREAM , + ret =sock_create_kern (current->nsproxy->net_ns, + ctrl->addr.ss_family,SOCK_STREAM ,IPPROTO_TCP , &queue->sock);if (ret) { dev_err(nctrl->device,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1145/1756 nvme-tcp: store and use the callers network namespace
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Surabhi Gogte <[email protected]>
[ Upstream commit 87a1ac965502858f9207153a92c3aef8ecf6d4ae ]
nvme_tcp_alloc_queue() creates each socket using current->nsproxy->net_ns, which is correct for the initial connect that runs in userspace context. However, the reconnect and error recovery paths run from a workqueue where current netns is a kernel thread in init_net, so sockets created during reconnect end up in a different namespace than the one the controller was originally connected from.
Fix this by capturing the caller's network namespace at controller allocation time. Use ctrl->net for all socket creation so that every queue, on initial connect, reset, or reconnect, is created in the same namespace.
--- drivers/nvme/host/tcp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/nvme/host/tcp.c +6 -1
@@ -222,6 +222,7 @@ struct nvme_tcp_ctrl {struct delayed_work connect_work;struct nvme_tcp_request async_req;u32 io_queues[HCTX_MAX_TYPES ]; +struct net *net; };static LIST_HEAD (nvme_tcp_ctrl_list);
@@ -2033,7 +2034,7 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid, queue->cmnd_capsule_len =sizeof (struct nvme_command ) +NVME_TCP_ADMIN_CCSZ ; - ret =sock_create_kern (current->nsproxy->net_ns, + ret =sock_create_kern (ctrl->net, ctrl->addr.ss_family,SOCK_STREAM ,IPPROTO_TCP , &queue->sock);if (ret) {
@@ -2780,6 +2781,7 @@ static void nvme_tcp_free_ctrl(struct nvme_ctrl *nctrl)nvmf_free_options (nctrl->opts); free_ctrl: +put_net (ctrl->net);kfree (ctrl->queues);kfree (ctrl); }
@@ -3175,12 +3177,15 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev, goto out_free_ctrl; } + ctrl->net =get_net (current->nsproxy->net_ns); + ret =nvme_init_ctrl (&ctrl->ctrl, dev, &nvme_tcp_ctrl_ops,0 );if (ret) goto out_kfree_queues;return ctrl; out_kfree_queues: +put_net (ctrl->net);kfree (ctrl->queues); out_free_ctrl:kfree (ctrl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1146/1756 nvmet-fc: dont drop the last assoc reference in nvmet_fc_delete_ctrl()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Palla Raghunath <[email protected]>
[ Upstream commit 165301b5e2fd765fa05ea1044bbca8ba79820197 ]
syzbot hit a recursive locking report on subsys->lock when a subsystem is unlinked from an FC port.
nvmet_port_del_ctrls() holds subsys->lock while it calls ->delete_ctrl() for each controller. nvmet_fc_delete_ctrl() grabs a reference on the association, queues del_work and then drops the reference. If del_work gets to run to completion before that put, ours is the last reference. Freeing the assoc tears down the queues, the last nvmet_cq_put() drops the last ctrl reference, and nvmet_ctrl_free() goes for subsys->lock again:
WARNING: possible recursive locking detected
...
nvmet_ctrl_free+0xa6/0x8e0 drivers/nvme/target/core.c:1766 nvmet_cq_put+0x158/0x200 drivers/nvme/target/core.c:848 nvmet_fc_target_assoc_free+0x418/0x2220 drivers/nvme/target/fc.c:1173 nvmet_fc_delete_ctrl+0x717/0x7e0 drivers/nvme/target/fc.c:1581 nvmet_port_del_ctrls+0xfb/0x150 drivers/nvme/target/core.c:311 nvmet_port_subsys_drop_link+0x1e8/0x310 drivers/nvme/target/configfs.c:1119
It's a real hang, not only a lockdep warning. I reproduced it with fcloop by putting an msleep() before the put: rm on the configfs link gets stuck in D state for good.
I don't think we need that reference at all. del_work does list_del_rcu() and synchronize_rcu() before it drops the initial reference, so an assoc we find on assoc_list can't go away before rcu_read_unlock(). nvmet_fc_schedule_delete_assoc() doesn't sleep, so just call it inside the RCU section and get rid of the get/put. If the assoc is already being deleted, terminating is set and the call is a no-op, which matches what happened before when the get failed.
With the same msleep() in place the patched kernel unlinks cleanly and the assoc is freed from the workqueue.
--- drivers/nvme/target/fc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/nvme/target/fc.c +9 -6
@@ -1579,8 +1579,14 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl)list_for_each_entry_rcu (assoc, &tgtport->assoc_list, a_list) { queue = assoc->queues[0 ];if (queue && queue->nvme_sq.ctrl == ctrl) { -if (nvmet_fc_tgt_a_get (assoc)) - found_ctrl = true; +/* +* No assoc reference here: we're called with +* subsys->lock held, and if del_work beat us, +* our put would free the ctrl under that lock. +* RCU keeps the assoc alive until unlock. +*/ +nvmet_fc_schedule_delete_assoc (assoc); + found_ctrl = true;break ; } }
@@ -1588,11 +1594,8 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl)nvmet_fc_tgtport_put (tgtport); -if (found_ctrl) { -nvmet_fc_schedule_delete_assoc (assoc); -nvmet_fc_tgt_a_put (assoc); +if (found_ctrl)return ; - }spin_lock_irqsave (&nvmet_fc_tgtlock, flags); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1147/1756 nvmet-auth: reject undersized AUTH_SEND payloads
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Byeongchan <[email protected]>
[ Upstream commit c9359401036e8294c007a10e8c8d8da7030fcc76 ]
nvmet_execute_auth_send() allocates and copies the initiator-supplied transfer length, then reads auth_type and auth_id through a common DHCHAP message pointer. The existing zero and transfer-length checks do not ensure that both common-header bytes are present.
An unauthenticated NVMe/TCP initiator can complete ICReq and admin CONNECT, then send AUTH_SEND with tl equal to one. KASAN reports a one-byte slab out-of-bounds read when auth_id is loaded.
Reject payloads that do not cover the common auth_type/auth_id header before allocating or parsing them. The one-byte trigger and header-minus-one boundary were cleanly rejected in three fixed fresh-boot runs. Exact-header, valid DHCHAP, wrong-type, mismatch, and zero-length controls remained clean, and a following valid AUTH_SEND on the same connection received a response. The touched source is unchanged at 0c2669a9f4a1d607e7591ae50ccf3c432a0aff08, where the patch applies and builds cleanly.
The demonstrated impact is unauthenticated pre-authentication target-kernel denial of service. No disclosure, controlled write, RCE, or LPE was demonstrated. The source reproducer and complete logs are available on request and are not included in this public report.
OpenAI Codex assisted source inspection, test design, patch drafting, and evidence organization.
--- drivers/nvme/target/fabrics-cmd-auth.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/nvme/target/fabrics-cmd-auth.c +6 -0
@@ -256,6 +256,12 @@ void nvmet_execute_auth_send(struct nvmet_req *req)nvmet_check_transfer_len (req, tl);return ; } +if (tl < offsetof(struct nvmf_auth_dhchap_success2_data , rsvd1)) { + status =NVME_SC_INVALID_FIELD |NVME_STATUS_DNR ; + req->error_loc = + offsetof(struct nvmf_auth_send_command , tl); + goto done; + } d =kmalloc (tl,GFP_KERNEL );if (!d) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1148/1756 nvme: pass partition flags to passthrough checks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yao Sang <[email protected]>
[ Upstream commit 6908a702955929b0876baac9fdc57070780a76f0 ]
nvme_user_cmd() handles NVME_IOCTL_IO_CMD on namespace block devices, including partitions. It receives flags identifying a partition, but passes 0 to nvme_cmd_allowed(), bypassing the partition guard and allowing unprivileged passthrough commands to access sectors outside the partition.
Pass flags to the permission check, rejecting unprivileged commands on partitions.
--- drivers/nvme/host/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/ioctl.c +1 -1
@@ -361,7 +361,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns, c.common.cdw14 =cpu_to_le32 (cmd.cdw14); c.common.cdw15 =cpu_to_le32 (cmd.cdw15); -if (!nvme_cmd_allowed (ctrl, ns, &c,0 , open_for_write)) +if (!nvme_cmd_allowed (ctrl, ns, &c, flags, open_for_write))return -EACCES ;if (cmd.timeout_ms)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1149/1756 firmware: cs_dsp: clear dsp->running on the cs_dsp_run() error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingxuan Guo <[email protected]>
[ Upstream commit ad6be54d13496a0b5c6d1edeea99504e438cdb7a ]
cs_dsp_run() sets dsp->running = true once the core has been started, but the error path below it only stops and disables the core, leaving the flag set. The first thing that can fail after that point is the post_run client hook, and it is reachable in mainline: wm_adsp registers wm_adsp_event_post_run(), which can fail in wm_adsp_buffer_init().
The core is then stopped and disabled, but dsp->running still reads true, and that stale state is acted on elsewhere: cs_dsp_coeff_write_ctrl() and cs_dsp_coeff_read_ctrl() talk to the DSP when ctl->dsp->running is set, and client drivers use the flag to decide whether the firmware is up (cs35l41 checks cs_dsp.running before its early events and on hibernate/resume).
The flag cannot simply be moved below the hook: post_run hooks such as wm_adsp_event_post_run() read controls while they run, and cs_dsp_coeff_read_ctrl() only goes to the DSP when the flag is set.
Clear the flag on the error path, before the core is stopped - the order cs_dsp_stop() already uses.
--- drivers/firmware/cirrus/cs_dsp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/firmware/cirrus/cs_dsp.c +2 -0
@@ -2872,6 +2872,8 @@ int cs_dsp_run(struct cs_dsp *dsp)return 0 ; err: + dsp->running = false; +if (dsp->ops->stop_core) dsp->ops->stop_core (dsp);if (dsp->ops->disable_core)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1150/1756 ASoC: amd: acp: Fix .close() being skipped on rollback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 2c3400aa9f397da48a6760f5e84438973e01a00c ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/acp/acp-platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/acp/acp-platform.c +1 -1
@@ -314,7 +314,7 @@ static int acp_dma_open(struct snd_soc_component *component, struct snd_pcm_subslist_add_tail (&stream->list, &adata->stream_list);spin_unlock_irq (&adata->acp_lock); -return ret; +return 0 ; } static int acp_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1151/1756 ASoC: amd: ps: Fix acp63_pdm_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 172888114dda96492d40e4a6e0ed16146cb76e2b ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp63_pdm_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/ps/ps-pdm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/ps/ps-pdm-dma.c +1 -1
@@ -211,7 +211,7 @@ static int acp63_pdm_dma_open(struct snd_soc_component *component, pdm_data->acp63_base = adata->acp63_base; runtime->private_data = pdm_data; -return ret; +return 0 ; } static int acp63_pdm_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1152/1756 ASoC: amd: ps: Fix acp63_sdw_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 45dd2b22ea8934ed69dd05e6ecbf3c66ac3baebf ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp63_sdw_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/ps/ps-sdw-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/ps/ps-sdw-dma.c +1 -1
@@ -243,7 +243,7 @@ static int acp63_sdw_dma_open(struct snd_soc_component *component, stream->stream_id = cpu_dai->id; stream->instance = amd_manager->instance; runtime->private_data = stream; -return ret; +return 0 ; } static int acp63_sdw_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1153/1756 ASoC: amd: raven: Fix acp3x_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 37ceef26df57c4a86a5e984b1951995aa96d4342 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp3x_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/raven/acp3x-pcm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/raven/acp3x-pcm-dma.c +1 -1
@@ -237,7 +237,7 @@ static int acp3x_dma_open(struct snd_soc_component *component, i2s_data->acp3x_base = adata->acp3x_base; runtime->private_data = i2s_data; -return ret; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1154/1756 ASoC: amd: renoir: Fix acp_pdm_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit a92571113ef297840270e4d8d4263a842302c9c4 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp_pdm_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/renoir/acp3x-pdm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/renoir/acp3x-pdm-dma.c +1 -1
@@ -233,7 +233,7 @@ static int acp_pdm_dma_open(struct snd_soc_component *component, pdm_data->acp_base = adata->acp_base; runtime->private_data = pdm_data; -return ret; +return 0 ; } static int acp_pdm_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1155/1756 ASoC: amd: vangogh: Fix acp5x_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 38559fcd1c518a33055ef0a2cf7c04b57bfa9215 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp5x_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/vangogh/acp5x-pcm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/vangogh/acp5x-pcm-dma.c +1 -1
@@ -231,7 +231,7 @@ static int acp5x_dma_open(struct snd_soc_component *component, } i2s_data->acp5x_base = adata->acp5x_base; runtime->private_data = i2s_data; -return ret; +return 0 ; } static int acp5x_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1156/1756 ASoC: amd: yc: Fix acp6x_pdm_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 06654a3ef5137719be880a6cd12bd453050eafc5 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp6x_pdm_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/yc/acp6x-pdm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/yc/acp6x-pdm-dma.c +1 -1
@@ -209,7 +209,7 @@ static int acp6x_pdm_dma_open(struct snd_soc_component *component, pdm_data->acp6x_base = adata->acp6x_base; runtime->private_data = pdm_data; -return ret; +return 0 ; } static int acp6x_pdm_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1157/1756 ASoC: atmel: atmel-pcm-pdc: Fix atmel_pcm_close() being skipped on rollback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 50aaca643038774b6779c911c4f96bc7e0d607e9 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from atmel_pcm_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/atmel/atmel-pcm-pdc.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/atmel/atmel-pcm-pdc.c +2 -0
@@ -295,6 +295,8 @@ static int atmel_pcm_open(struct snd_soc_component *component, } runtime->private_data = prtd; +return 0 ; + out:return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1158/1756 ASoC: imx-pcm-rpmsg: Fix imx_rpmsg_pcm_close() being skipped on rollback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 85e56c3bbb7e8ea4626f8653afaef0d79d9cb7ba ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from imx_rpmsg_pcm_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/fsl/imx-pcm-rpmsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/fsl/imx-pcm-rpmsg.c +1 -1
@@ -278,7 +278,7 @@ static int imx_rpmsg_pcm_open(struct snd_soc_component *component, info->stream_timer[substream->stream].substream = substream;timer_setup (&info->stream_timer[substream->stream].timer, imx_rpmsg_timer_callback,0 ); -return ret; +return 0 ; } static int imx_rpmsg_pcm_close(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1159/1756 ASoC: intel: atom: Use __free(kfree) for stream pointer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 4889a8a73f65b8e4feb49ea434b8a41806513574 ]
Declare 'stream' with __free(kfree) so it is automatically freed when leaving scope. This allows direct returns from error paths and removes the explicit kfree(stream) call.
Set 'stream' to NULL after ownership has been transferred to runtime->private_data to prevent it from being freed on the success path.
This cleanup is a preparation step for upcoming locking changes.
Stable-dep-of: e3bb57581104 ("ASoC: intel: atom: Fix .shutdown() being skipped on rollback")
--- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
sound/soc/intel/atom/sst-mfld-platform-pcm.c +14 -6
@@ -11,6 +11,7 @@*/ #define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/cleanup.h> #include <linux/slab.h> #include <linux/io.h> #include <linux/module.h>
@@ -304,7 +305,7 @@ static int sst_media_open(struct snd_pcm_substream *substream, {int ret_val =0 ;struct snd_pcm_runtime *runtime = substream->runtime; -struct sst_runtime_stream *stream; + struct sst_runtime_stream *stream __free(kfree) = NULL; stream =kzalloc (sizeof (*stream),GFP_KERNEL );if (!stream)
@@ -330,7 +331,7 @@ static int sst_media_open(struct snd_pcm_substream *substream, ret_val =power_up_sst (stream);if (ret_val <0 ) - goto out_power_up; +return ret_val;/* * Make sure the period to be multiple of 1ms to align the
@@ -347,12 +348,19 @@ static int sst_media_open(struct snd_pcm_substream *substream,snd_pcm_hw_constraint_step (substream->runtime,0 ,SNDRV_PCM_HW_PARAM_PERIODS ,2 ); -return snd_pcm_hw_constraint_integer (runtime, -SNDRV_PCM_HW_PARAM_PERIODS ); + ret_val =snd_pcm_hw_constraint_integer (runtime, +SNDRV_PCM_HW_PARAM_PERIODS ); + +if (ret_val <0 ) +return ret_val; + + stream =NULL ; + +return ret_val; + out_ops:mutex_unlock (&sst_lock); -out_power_up: -kfree (stream); +return ret_val; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1160/1756 ASoC: Intel: atom: Use scoped_guard() for scoped locking
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 08d2d5e683e85a7dc33c1abfd50fdc380bfafb5a ]
Clean up the code using scoped_guard() for mutex locks. Merely code refactoring, and no behavior change.
Stable-dep-of: e3bb57581104 ("ASoC: intel: atom: Fix .shutdown() being skipped on rollback")
--- sound/soc/intel/atom/sst-atom-controls.c | 38 ++++++++++---------- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 20 ++++------- 2 files changed, 27 insertions(+), 31 deletions(-)
sound/soc/intel/atom/sst-atom-controls.c +20 -18
@@ -761,27 +761,29 @@ int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable)return ret; } -mutex_lock (&drv->lock); -if (enable) - timer_usage++; -else - timer_usage--; - -/* -* Send the command only if this call is the first enable or last -* disable -*/ -if ((enable && (timer_usage ==1 )) || - (!enable && (timer_usage ==0 ))) { - ret =sst_fill_and_send_cmd_unlocked (drv,SST_IPC_IA_CMD , -SST_FLAG_BLOCKED ,SST_TASK_SBA ,0 , &cmd, -sizeof (cmd.header) + cmd.header.length); -if (ret && enable) { + scoped_guard(mutex, &drv->lock) { +if (enable) + timer_usage++; +else timer_usage--; - enable = false; + +/* +* Send the command only if this call is the first enable or last +* disable +*/ +if ((enable && timer_usage ==1 ) || + (!enable && timer_usage ==0 )) { + ret =sst_fill_and_send_cmd_unlocked (drv,SST_IPC_IA_CMD , +SST_FLAG_BLOCKED , +SST_TASK_SBA ,0 , &cmd, +sizeof (cmd.header) + + cmd.header.length); +if (ret && enable) { + timer_usage--; + enable = false; + } } } -mutex_unlock (&drv->lock);if (!enable) sst->ops->power (sst->dev, false);
sound/soc/intel/atom/sst-mfld-platform-pcm.c +7 -13
@@ -313,15 +313,14 @@ static int sst_media_open(struct snd_pcm_substream *substream,spin_lock_init (&stream->status_lock);/* get the sst ops */ -mutex_lock (&sst_lock); -if (!sst || - !try_module_get (sst->dev->driver->owner)) { -dev_err (dai->dev,"no device available to run\n" ); - ret_val = -ENODEV ; - goto out_ops; + scoped_guard(mutex, &sst_lock) { +if (!sst || + !try_module_get (sst->dev->driver->owner)) { +dev_err (dai->dev,"no device available to run\n" ); +return -ENODEV ; + } + stream->ops = sst->ops; } - stream->ops = sst->ops; -mutex_unlock (&sst_lock); stream->stream_info.str_id =0 ;
@@ -356,11 +355,6 @@ static int sst_media_open(struct snd_pcm_substream *substream, stream =NULL ; -return ret_val; - -out_ops: -mutex_unlock (&sst_lock); -return ret_val; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1161/1756 ASoC: intel: atom: Fix .shutdown() being skipped on rollback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit e3bb575811042ca30ac9b7b4dacc74aab8efa512 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from sst_media_open(). ASoC only marks the DAI as started when .startup() returns 0, so .shutdown() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/atom/sst-mfld-platform-pcm.c +1 -1
@@ -355,7 +355,7 @@ static int sst_media_open(struct snd_pcm_substream *substream, stream =NULL ; -return ret_val; +return 0 ; } static void sst_media_close(struct snd_pcm_substream *substream,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1162/1756 ASoC: atmel-i2s: fix MCK generator error handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 2e2da92de9bffd2cdbb9a2558fe60de7f1bb09e3 ]
Disable the gclk and reset the MCK configuration when an error occurs while enabling the MCK generator.
This prevents the gclk from remaining enabled after a failed clock configuration.
--- sound/soc/atmel/atmel-i2s.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
sound/soc/atmel/atmel-i2s.c +13 -3
@@ -466,11 +466,21 @@ static int atmel_i2s_switch_mck_generator(struct atmel_i2s_dev *dev, mr |=ATMEL_I2SC_MR_IMCKMODE_I2SMCK ; ret =regmap_update_bits (dev->regmap,ATMEL_I2SC_MR , mr_mask, mr);if (ret) -return ret; + goto err_disable_gclk;/* Finally enable the I2S Master Clock generator. */ -return regmap_write (dev->regmap,ATMEL_I2SC_CR , -ATMEL_I2SC_CR_CKEN ); + ret =regmap_write (dev->regmap,ATMEL_I2SC_CR ,ATMEL_I2SC_CR_CKEN ); +if (ret) + goto err_reset_mr; + +return 0 ; + +err_reset_mr: +regmap_update_bits (dev->regmap,ATMEL_I2SC_MR , mr_mask,0 ); +err_disable_gclk: +clk_disable_unprepare (dev->gclk); + +return ret; } static int atmel_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1163/1756 ASoC: atmel-i2s: use optional API for muxclk
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit be952abd69c1f2c845e42e72147751e4c910cd81 ]
The muxclk is an optional clock according to the device tree binding.
Use devm_clk_get_optional() to handle the optional muxclk instead of handling the missing clock explicitly.
When muxclk is not available, devm_clk_get_optional() returns NULL. clk_set_parent() returns 0 when passed NULL, preserving the existing behavior.
Unlike the existing code, errors other than -EPROBE_DEFER are now returned instead of being silently ignored.
--- sound/soc/atmel/atmel-i2s.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
sound/soc/atmel/atmel-i2s.c +5 -11
@@ -585,21 +585,15 @@ static int atmel_i2s_sama5d2_mck_init(struct atmel_i2s_dev *dev, struct device_node *np) {struct clk *muxclk; -int err;if (!dev->gclk)return 0 ; -/* muxclk is optional, so we return error for probe defer only */ - muxclk =devm_clk_get (dev->dev,"muxclk" ); -if (IS_ERR (muxclk)) { - err =PTR_ERR (muxclk); -if (err == -EPROBE_DEFER ) -return -EPROBE_DEFER ; -dev_dbg (dev->dev, -"failed to get the I2S clock control: %d\n" , err); -return 0 ; - } +/* muxclk is optional */ + muxclk =devm_clk_get_optional (dev->dev,"muxclk" ); +if (IS_ERR (muxclk)) +return dev_err_probe (dev->dev,PTR_ERR (muxclk), +"failed to get the I2S clock control\n" );return clk_set_parent (muxclk, dev->gclk); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1164/1756 ASoC: atmel-i2s: use optional API for gclk
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit b431a055fb7688c0d3725fa3c55aeef852991178 ]
The gclk is an optional clock according to the device tree binding.
Use devm_clk_get_optional() to handle the optional gclk directly.
Unlike the existing code, errors other than -EPROBE_DEFER are now returned instead of being silently ignored.
--- sound/soc/atmel/atmel-i2s.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
sound/soc/atmel/atmel-i2s.c +4 -7
@@ -666,13 +666,10 @@ static int atmel_i2s_probe(struct platform_device *pdev) }/* Get audio clock to generate the I2S Master Clock (I2S_MCK) */ - dev->gclk =devm_clk_get (&pdev->dev,"gclk" ); -if (IS_ERR (dev->gclk)) { -if (PTR_ERR (dev->gclk) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; -/* Master Mode not supported */ - dev->gclk =NULL ; - } + dev->gclk =devm_clk_get_optional (&pdev->dev,"gclk" ); +if (IS_ERR (dev->gclk)) +return PTR_ERR (dev->gclk); + dev->dev = &pdev->dev; dev->regmap = regmap;platform_set_drvdata (pdev, dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1165/1756 sh: sh7785lcr: Register the PCA9564 controller as I2C bus 0
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 3b8386ffc0c33b6b5a6a8e64e1487c1adec57dc9 ]
Before commit 44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly specified"), a negative ID was replaced by zero, and I2C bus zero was instantiated. Since that commit, a negative ID is passed verbatim, instantiating an I2C bus with a dynamic number. As SH boards still use i2c_register_board_info(0, ...) to register I2C devices, they rely on the I2C bus being bus zero.
The SH7785LCR is the only SH board whose I2C adapter has a negative ID and its PCA9564 controller becomes i2c-1, causing registration of the R2025S/D RTC to fail and hwclock not detecting /dev/rtc0.
Set the platform device ID to 0 so that the adapter is registered as bus zero again.
--- arch/sh/boards/board-sh7785lcr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/boards/board-sh7785lcr.c +1 -1
@@ -256,7 +256,7 @@ static struct i2c_pca9564_pf_platform_data i2c_platform_data = {static struct platform_device i2c_device = { .name ="i2c-pca-platform" , - .id =-1 , + .id =0 , .dev = { .platform_data = &i2c_platform_data, },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1166/1756 ASoC: mediatek: mt8365: Fix out-of-bounds read in get_iir_coef()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Priyanka Mani <[email protected]>
[ Upstream commit e913917febd31998e3d0b9e8c861e538a6185045 ]
get_iir_coef() looks up a resampling coefficient set by reading an index "k" from iir_coef_tbl_matrix[][] and using it to index iir_coef_tbl_list[], which has 8 entries (valid indices 0..7).
Before the lookup, "k" is only rejected when it is >= IIR_NO_NEED (11), or equal to IIR_RATIOVER (9) or IIR_INV_COEF (10). The value 8 is neither a sentinel nor a valid table index, so it falls through to the else branch and iir_coef_tbl_list[8] is read one element past the end of the array. The bogus coef pointer and count are then returned to mt8365_dai_set_config(), which dereferences coef.
The current matrix never produces 8, so this cannot be triggered today, but the bounds check is wrong: it relies on the matrix contents instead of the size of the array it guards. Bound the lookup with the actual array size so only valid indices reach the table.
This was found by Smatch:
sound/soc/mediatek/mt8365/mt8365-dai-i2s.c:271 get_iir_coef()
error: buffer overflow 'iir_coef_tbl_list' 8 <= 8
--- sound/soc/mediatek/mt8365/mt8365-dai-i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/mediatek/mt8365/mt8365-dai-i2s.c +1 -1
@@ -267,7 +267,7 @@ static const u32 *get_iir_coef(unsigned int input_fs,if (k >=IIR_NO_NEED ) { }else if (k ==IIR_RATIOVER ) { }else if (k ==IIR_INV_COEF ) { - }else { + }else if (k <ARRAY_SIZE (iir_coef_tbl_list)) { coef = iir_coef_tbl_list[k].coef; cnt = iir_coef_tbl_list[k].cnt; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1167/1756 ASoC: codecs: wcd937x: request watchdog IRQs without devm
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit b3f17433a1eb9f89b79f8459d7661207abce0b9c ]
The watchdog IRQs are requested from the codec component probe and released from its remove callback. Use the same non-devm lifetime for both operations.
Use request_threaded_irq() and keep free_irq() in the component remove callback. Return errors from each request and unwind only IRQs that were successfully requested, including failures later in component probe.
--- sound/soc/codecs/wcd937x.c | 44 +++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 17 deletions(-)
sound/soc/codecs/wcd937x.c +27 -17
@@ -2535,23 +2535,23 @@ static int wcd937x_soc_codec_probe(struct snd_soc_component *component) WCD937X_IRQ_AUX_PDM_WD_INT);/* Request for watchdog interrupt */ - ret =devm_request_threaded_irq (dev, wcd937x->hphr_pdm_wd_int,NULL , wcd937x_wd_handle_irq, -IRQF_ONESHOT |IRQF_TRIGGER_RISING , -"HPHR PDM WDOG INT" , wcd937x); + ret =request_threaded_irq (wcd937x->hphr_pdm_wd_int,NULL , wcd937x_wd_handle_irq, +IRQF_ONESHOT |IRQF_TRIGGER_RISING , +"HPHR PDM WDOG INT" , wcd937x);if (ret) -dev_err (dev,"Failed to request HPHR watchdog interrupt (%d)\n" , ret); + goto err_free_clsh; - ret =devm_request_threaded_irq (dev, wcd937x->hphl_pdm_wd_int,NULL , wcd937x_wd_handle_irq, -IRQF_ONESHOT |IRQF_TRIGGER_RISING , -"HPHL PDM WDOG INT" , wcd937x); + ret =request_threaded_irq (wcd937x->hphl_pdm_wd_int,NULL , wcd937x_wd_handle_irq, +IRQF_ONESHOT |IRQF_TRIGGER_RISING , +"HPHL PDM WDOG INT" , wcd937x);if (ret) -dev_err (dev,"Failed to request HPHL watchdog interrupt (%d)\n" , ret); + goto err_free_hphr_irq; - ret =devm_request_threaded_irq (dev, wcd937x->aux_pdm_wd_int,NULL , wcd937x_wd_handle_irq, -IRQF_ONESHOT |IRQF_TRIGGER_RISING , -"AUX PDM WDOG INT" , wcd937x); + ret =request_threaded_irq (wcd937x->aux_pdm_wd_int,NULL , wcd937x_wd_handle_irq, +IRQF_ONESHOT |IRQF_TRIGGER_RISING , +"AUX PDM WDOG INT" , wcd937x);if (ret) -dev_err (dev,"Failed to request Aux watchdog interrupt (%d)\n" , ret); + goto err_free_hphl_irq;/* Disable watchdog interrupt for HPH and AUX */ disable_irq_nosync (wcd937x->hphr_pdm_wd_int);
@@ -2563,23 +2563,33 @@ static int wcd937x_soc_codec_probe(struct snd_soc_component *component) ARRAY_SIZE(wcd9375_dapm_widgets));if (ret <0 ) {dev_err (component->dev,"Failed to add snd_ctls\n" ); -wcd_clsh_ctrl_free (wcd937x->clsh_info); -return ret; + goto err_free_irqs; } ret =snd_soc_dapm_add_routes (dapm, wcd9375_audio_map,ARRAY_SIZE (wcd9375_audio_map));if (ret <0 ) {dev_err (component->dev,"Failed to add routes\n" ); -wcd_clsh_ctrl_free (wcd937x->clsh_info); -return ret; + goto err_free_irqs; } } ret =wcd937x_mbhc_init (component); -if (ret) +if (ret) {dev_err (component->dev,"mbhc initialization failed\n" ); + goto err_free_irqs; + } + +return ret; +err_free_irqs: +free_irq (wcd937x->aux_pdm_wd_int, wcd937x); +err_free_hphl_irq: +free_irq (wcd937x->hphl_pdm_wd_int, wcd937x); +err_free_hphr_irq: +free_irq (wcd937x->hphr_pdm_wd_int, wcd937x); +err_free_clsh: +wcd_clsh_ctrl_free (wcd937x->clsh_info);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1168/1756 scsi: scsi_debug: Fix a locking bug in resp_write_same()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 2f50ca3d46b4d5916874ba19612498c0a9c1f5f9 ]
If fetch_to_dev_buffer() fails in resp_write_same(), the function jumps to 'out' without releasing the data write lock acquired earlier via sdeb_data_write_lock(). Jump to 'unlock' instead so that sdeb_data_write_unlock() is called on the error path. This bug has been discovered by building the scsi_debug driver with Clang and modified lock context annotations. The modified lock context annotations are available in patch "scsi: scsi_debug: Improve lock context annotations".
--- drivers/scsi/scsi_debug.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/scsi_debug.c +3 -2
@@ -4587,7 +4587,7 @@ static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num,if (-1 == ret) { ret =DID_ERROR <<16 ; - goto out; + goto unlock; }else if (sdebug_verbose && !ndob && (ret < lb_size)) sdev_printk(KERN_INFO, scp->device, "%s: %s: lb size=%u, IO sent=%d bytes\n",
@@ -4604,8 +4604,9 @@ static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num,/* If ZBC zone then bump its write pointer */ if (sdebug_dev_is_zoned (devip))zbc_inc_wp (devip, lba, num); -sdeb_data_write_unlock (sip); ret =0 ; +unlock: +sdeb_data_write_unlock (sip); out:if (meta_data_locked)sdeb_meta_write_unlock (sip);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1169/1756 lib: validate in-memory LZ4 chunk length
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
[ Upstream commit 138a84817df01eda67bb23032ab49c23fe2ffc16 ]
We found and validated an issue in lib/decompress_unlz4.c. The bug is reachable by a root user through kexec_file_load() with a crafted external initrd.
unlz4() reads the compressed chunk length from an in-memory initrd and passes it to LZ4_decompress_safe(). It only checks the chunk length against the allocation size when the input is filled by a callback.
Reject an in-memory chunk that extends past the remaining input before calling the LZ4 decoder. This prevents malformed initrds from making the decoder read past the mapped archive.
--- lib/decompress_unlz4.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/decompress_unlz4.c +4 -0
@@ -139,6 +139,10 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,if (!fill) { inp +=4 ; size -=4 ; +if (chunksize > size) { +error ("data corrupted" ); + goto exit_2; + } }else {if (chunksize >LZ4_compressBound (uncomp_chunksize)) {error ("chunk length is longer than allocated" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1170/1756 ocfs2: retain all security xattrs during inode creation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit d637475617d8468c2740a3436428681bcc8d3572 ]
When creating a new inode, ocfs2_init_security_get() stores the security xattr returned by the LSM framework in ocfs2_security_xattr_info so that it can be written later within the same transaction. But ocfs2_initxattrs() only ever looks at the first element of the xattr array, and it keeps the name as a bare pointer into memory owned by the security layer instead of copying it. The value, by contrast, is already duplicated with kmemdup().
With stacked LSMs, security_inode_init_security() provides one xattr per LSM, so all labels but the first are silently dropped and never written to disk, leaving newly created files without the security xattrs the other LSMs rely on.
The borrowed name is not an outright bug with the LSMs in tree today:security_inode_init_security() frees only ->value once the callback returns, and documents ->name as the attribute name suffix, so the pointer stays valid for as long as ocfs2 uses it. It is fragile though, as an LSM that allocates the name together with the value would turn it into a use-after-free, so the rework below copies the names as well.
Fix this by storing copies of all the security xattrs: allocate an array in ocfs2_initxattrs(), copy the names and values, account for all of them in the credit calculations, and write each one in ocfs2_init_security_set().
While at it, switch the allocations from GFP_KERNEL to GFP_NOFS. The callback runs in the inode creation path with the parent directory locked, and the security layer allocates the very same xattr array with GFP_NOFS, so direct reclaim must not be allowed to recurse into the filesystem from here.
--- fs/ocfs2/namei.c | 6 +-- fs/ocfs2/xattr.c | 133 +++++++++++++++++++++++++++++++++++++---------- fs/ocfs2/xattr.h | 12 +++-- 3 files changed, 116 insertions(+), 35 deletions(-)
fs/ocfs2/namei.c +2 -4
@@ -244,7 +244,6 @@ static int ocfs2_mknod(struct mnt_idmap *idmap,int want_meta =0 ;int xattr_credits =0 ;struct ocfs2_security_xattr_info si = { - .name =NULL , .enable =1 , };int did_quota_inode =0 ;
@@ -471,7 +470,7 @@ static int ocfs2_mknod(struct mnt_idmap *idmap,brelse (new_fe_bh);brelse (parent_fe_bh); -kfree (si.value); +ocfs2_free_security_xattrs (&si);ocfs2_acl_init_release (&acl_state);
@@ -1827,7 +1826,6 @@ static int ocfs2_symlink(struct mnt_idmap *idmap,int want_clusters =0 ;int xattr_credits =0 ;struct ocfs2_security_xattr_info si = { - .name =NULL , .enable =1 , };int did_quota =0 , did_quota_inode =0 ;
@@ -2059,7 +2057,7 @@ static int ocfs2_symlink(struct mnt_idmap *idmap,brelse (new_fe_bh);brelse (parent_fe_bh); -kfree (si.value); +ocfs2_free_security_xattrs (&si);ocfs2_free_dir_lookup_result (&lookup);if (inode_ac)ocfs2_free_alloc_context (inode_ac);
fs/ocfs2/xattr.c +105 -28
193 lines not on this page · raw message
fs/ocfs2/xattr.h +9 -3
@@ -20,13 +20,18 @@ enum ocfs2_xattr_type { OCFS2_XATTR_MAX }; -struct ocfs2_security_xattr_info { -int enable; -const char *name; +struct ocfs2_security_xattr { +char *name;void *value;size_t value_len; }; +struct ocfs2_security_xattr_info { +int enable; +struct ocfs2_security_xattr *xattrs; +int count; +}; +extern const struct xattr_handler ocfs2_xattr_user_handler;extern const struct xattr_handler ocfs2_xattr_trusted_handler;extern const struct xattr_handler ocfs2_xattr_security_handler;
@@ -49,6 +54,7 @@ int ocfs2_xattr_remove(struct inode *, struct buffer_head *);int ocfs2_init_security_get (struct inode *,struct inode *,const struct qstr *,struct ocfs2_security_xattr_info *); +void ocfs2_free_security_xattrs (struct ocfs2_security_xattr_info *); int ocfs2_init_security_set(handle_t *, struct inode *, struct buffer_head *, struct ocfs2_security_xattr_info *,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1171/1756 ocfs2: fix possible deadlock between nfs_sync_rwlock and fs_reclaim
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 169bc4d16a8efa7852b101fdaa4c028505cd6750 ]
syzbot detected a circular locking dependency on &osb->nfs_sync_rwlock:
CPU0 CPU1
---- ----
lock(fs_reclaim);
lock(&ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE]);
lock(fs_reclaim); rlock(&osb->nfs_sync_rwlock);
*** DEADLOCK ***
Chain exists of: &osb->nfs_sync_rwlock --> &ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE] --> fs_reclaim
CPU0 is kswapd. The dentry shrinker runs under fs_reclaim and reaches ocfs2_delete_inode() through ->evict_inode():
kswapd
balance_pgdat
shrink_node
shrink_slab
super_cache_scan
prune_dcache_sb
shrink_dentry_list
dentry_kill
ocfs2_dentry_iput
evict
ocfs2_evict_inode
ocfs2_delete_inode
ocfs2_nfs_sync_lock
down_read(&osb->nfs_sync_rwlock) //C0: grabbingCPU1 is a task deleting an inode. It takes nfs_sync_rwlock first, then the orphan dir and inode alloc system inode i_rwsems, and allocates the metadata reservation with GFP_KERNEL while holding them:
evict
ocfs2_evict_inode
ocfs2_delete_inode
+ ocfs2_nfs_sync_lock
| down_read(&osb->nfs_sync_rwlock) //C1: hold
+ ocfs2_wipe_inode
+ inode_lock(orphan_dir_inode) //C1: hold
+ ocfs2_truncate_for_delete
| ocfs2_commit_truncate
| ocfs2_remove_btree_range
| ocfs2_reserve_blocks_for_rec_trunc
| ocfs2_reserve_new_metadata_blocks
| kzalloc_obj() //C1: grabbing
| // GFP_KERNEL -> might_alloc -> fs_reclaim_acquire
+ ocfs2_remove_inode
inode_lock(inode_alloc_inode)
jbd2 pins allocations to GFP_NOFS for the lifetime of a transaction handle, but these reservations are made before ocfs2_start_trans(), so fs_reclaim is acquired with ocfs2 locks still held and the cycle closes.
The same cycle is reachable from ocfs2_get_dentry() and ocfs2_get_parent(), which hold nfs_sync_rwlock for write across ocfs2_test_inode_bit() and ocfs2_iget().
This is more than a lockdep artifact. A GFP_KERNEL allocation under the orphan dir i_rwsem enters direct reclaim, which runs the shrinkers, which can evict another ocfs2 inode and re-enter ocfs2_wipe_inode() on the same task; the second inode_lock() on the singleton orphan dir inode then self-deadlocks, since i_rwsem is not recursive.
Establish a GFP_NOFS allocation context for the whole nfs_sync_rwlock critical section so that nothing holding it can recurse into filesystem reclaim. Do it in ocfs2_nfs_sync_lock()/ocfs2_nfs_sync_unlock() rather than at the call sites, so that future callers cannot forget it.
--- fs/ocfs2/dlmglue.c | 29 +++++++++++++++++++++++++---- fs/ocfs2/dlmglue.h | 5 +++-- fs/ocfs2/export.c | 10 ++++++---- fs/ocfs2/inode.c | 5 +++-- 4 files changed, 37 insertions(+), 12 deletions(-)
fs/ocfs2/dlmglue.c +25 -4
@@ -19,6 +19,7 @@#include <linux/time.h> #include <linux/delay.h> #include <linux/quotaops.h> +#include <linux/sched/mm.h> #include <linux/sched/signal.h> #define MLOG_MASK_PREFIX ML_DLM_GLUE
@@ -2855,21 +2856,34 @@ void ocfs2_rename_unlock(struct ocfs2_super *osb)ocfs2_cluster_unlock (osb, lockres,DLM_LOCK_EX ); } -int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex) +int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex,unsigned int *nofs_flag) {int status; +unsigned int flags;struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;if (ocfs2_is_hard_readonly (osb))return -EROFS ; +/* +* ocfs2_delete_inode() takes this lock from ->evict_inode(), which the +* dentry shrinker reaches while holding fs_reclaim. Anything allocated +* under the lock must therefore stay out of filesystem reclaim, or +* reclaim recurses back into the shrinker and tries to take this lock +* again. Cover the whole critical section, including the cluster lock +* and the sysfile inode locks the callers take below it. +*/ + flags =memalloc_nofs_save (); +if (ex)down_write (&osb->nfs_sync_rwlock);else down_read (&osb->nfs_sync_rwlock); -if (ocfs2_mount_local (osb)) +if (ocfs2_mount_local (osb)) { + *nofs_flag = flags;return 0 ; + } status =ocfs2_cluster_lock (osb, lockres, ex ?LKM_EXMODE :LKM_PRMODE ,0 ,0 );
@@ -2880,12 +2894,17 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex)up_write (&osb->nfs_sync_rwlock); else up_read(&osb->nfs_sync_rwlock); +memalloc_nofs_restore (flags); +return status; } -return status; + *nofs_flag = flags; + +return 0 ; } -void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex) +void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex, +unsigned int nofs_flag) {struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;
@@ -2896,6 +2915,8 @@ void ocfs2_nfs_sync_unlock(struct ocfs2_super *osb, int ex)up_write (&osb->nfs_sync_rwlock); else up_read(&osb->nfs_sync_rwlock); + +memalloc_nofs_restore (nofs_flag); } int ocfs2_trim_fs_lock(struct ocfs2_super *osb,
fs/ocfs2/dlmglue.h +3 -2
@@ -163,8 +163,9 @@ void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno);int ocfs2_rename_lock (struct ocfs2_super *osb);void ocfs2_rename_unlock (struct ocfs2_super *osb); -int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex); -void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex); +int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex,unsigned int *nofs_flag); +void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex, +unsigned int nofs_flag);void ocfs2_trim_fs_lock_res_init (struct ocfs2_super *osb);void ocfs2_trim_fs_lock_res_uninit (struct ocfs2_super *osb); int ocfs2_trim_fs_lock(struct ocfs2_super *osb,
fs/ocfs2/export.c +6 -4
@@ -37,6 +37,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,struct inode *inode;struct ocfs2_super *osb =OCFS2_SB (sb);u64 blkno = handle->ih_blkno; +unsigned int nofs_flag =0 ;int status, set;struct dentry *result;
@@ -59,7 +60,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,* This will synchronize us against ocfs2_delete_inode() on * all nodes */ - status =ocfs2_nfs_sync_lock (osb,1 ); + status =ocfs2_nfs_sync_lock (osb,1 , &nofs_flag);if (status <0 ) {mlog (ML_ERROR ,"getting nfs sync lock(EX) failed %d\n" , status); goto check_err;
@@ -89,7 +90,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, inode =ocfs2_iget (osb, blkno,0 ,0 ); unlock_nfs_sync: -ocfs2_nfs_sync_unlock (osb,1 ); +ocfs2_nfs_sync_unlock (osb,1 , nofs_flag); check_err:if (status <0 ) {
@@ -132,12 +133,13 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)u64 blkno;struct dentry *parent;struct inode *dir =d_inode (child); +unsigned int nofs_flag =0 ;int set;trace_ocfs2_get_parent (child, child->d_name.len, child->d_name.name, (unsigned long long )OCFS2_I (dir)->ip_blkno); - status =ocfs2_nfs_sync_lock (OCFS2_SB (dir->i_sb),1 ); + status =ocfs2_nfs_sync_lock (OCFS2_SB (dir->i_sb),1 , &nofs_flag);if (status <0 ) {mlog (ML_ERROR ,"getting nfs sync lock(EX) failed %d\n" , status); parent =ERR_PTR (status);
@@ -181,7 +183,7 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)ocfs2_inode_unlock (dir,0 ); unlock_nfs_sync: -ocfs2_nfs_sync_unlock (OCFS2_SB (dir->i_sb),1 ); +ocfs2_nfs_sync_unlock (OCFS2_SB (dir->i_sb),1 , nofs_flag); bail:trace_ocfs2_get_parent_end (parent);
fs/ocfs2/inode.c +3 -2
@@ -1046,6 +1046,7 @@ static void ocfs2_delete_inode(struct inode *inode) {int wipe, status;sigset_t oldset; +unsigned int nofs_flag =0 ;struct buffer_head *di_bh =NULL ;struct ocfs2_dinode *di =NULL ;
@@ -1080,7 +1081,7 @@ static void ocfs2_delete_inode(struct inode *inode)* shared mode so that all nodes can still concurrently * process deletes. */ - status =ocfs2_nfs_sync_lock (OCFS2_SB (inode->i_sb),0 ); + status =ocfs2_nfs_sync_lock (OCFS2_SB (inode->i_sb),0 , &nofs_flag);if (status <0 ) {mlog (ML_ERROR ,"getting nfs sync lock(PR) failed %d\n" , status);ocfs2_cleanup_delete_inode (inode,0 );
@@ -1152,7 +1153,7 @@ static void ocfs2_delete_inode(struct inode *inode)brelse (di_bh); bail_unlock_nfs_sync: -ocfs2_nfs_sync_unlock (OCFS2_SB (inode->i_sb),0 ); +ocfs2_nfs_sync_unlock (OCFS2_SB (inode->i_sb),0 , nofs_flag); bail_unblock:ocfs2_unblock_signals (&oldset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1172/1756 ocfs2: validate chunk and block counts of the local quota file
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
[ Upstream commit b10ef5d2c2083ea4c40e963c10a73a154793c5d4 ]
ocfs2_local_read_info() trusts dqi_chunks and dqi_blocks from the local quota file header. If dqi_blocks is too small, ocfs2_extend_local_quota_file() computes a bogus chunk length, extends the file, and maps logical block dqi_blocks, which is already in the inode's metadata cache (the header or a chunk header read at mount). sb_getblk() returns that cached buffer and ocfs2_set_new_buffer_uptodate() hits BUG_ON(ocfs2_buffer_cached()):
kernel BUG at fs/ocfs2/uptodate.c:509!
ocfs2_extend_local_quota_file+0x45c/0x1100 ocfs2_create_local_dquot+0x8ac/0xb50 ocfs2_acquire_dquot+0x614/0xae0 ocfs2_get_init_inode+0xe9/0x1b0 ocfs2_mkdir+0x174/0x430
ocfs2_local_quota_add_chunk() has the same exposure.
Reject a header whose counts don't fit the chunk layout or exceed i_size.
Reproduced with a crafted image (dqi_blocks = 1, chunk 0 dqc_free = 0); syzbot has no reproducer for this report.
--- fs/ocfs2/quota_local.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
fs/ocfs2/quota_local.c +24 -0
@@ -245,6 +245,25 @@ static void ocfs2_release_local_quota_bitmaps(struct list_head *head) } } +/* Check that the on-disk chunk and block counts match the file layout */ +static int ocfs2_check_local_quota_info (struct inode *inode, +unsigned int chunks, +unsigned int blocks) +{ +u64 chunk_len =ol_chunk_blocks (inode->i_sb) +1 ; +u64 min_blocks = chunks ?1 + chunk_len * (chunks -1 ) +1 :1 ; +u64 max_blocks =1 + chunk_len * chunks; + +if (blocks >= min_blocks && blocks <= max_blocks && + blocks <=i_size_read (inode) >> inode->i_sb->s_blocksize_bits) +return 0 ; + +return ocfs2_error (inode->i_sb, +"Quota file %llu has bad info: %u chunks, %u blocks\n" , + (unsigned long long )OCFS2_I (inode)->ip_blkno, + chunks, blocks); +} +/* Load quota bitmaps into memory */ static int ocfs2_load_local_quota_bitmaps(struct inode *inode, struct ocfs2_local_disk_dqinfo *ldinfo,
@@ -733,6 +752,11 @@ static int ocfs2_local_read_info(struct super_block *sb, int type) oinfo->dqi_blocks =le32_to_cpu (ldinfo->dqi_blocks); oinfo->dqi_libh = bh; + status =ocfs2_check_local_quota_info (lqinode, oinfo->dqi_chunks, + oinfo->dqi_blocks); +if (status <0 ) + goto out_err; +/* We crashed when using local quota file? */ if (!(oinfo->dqi_flags &OLQF_CLEAN )) { rec =OCFS2_SB (sb)->quota_rec;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1173/1756 resource, kunit: stop selecting GET_FREE_REGION
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 7c3f4d699f34535285d0ceb184927d71543d0064 ]
RESOURCE_KUNIT_TEST selects GET_FREE_REGION even when no other option needs it. Remove the selection to follow the dependency rule in Documentation/dev-tools/kunit/style.rst.
Skip resource_test_region_intersects() when GET_FREE_REGION is disabled. GET_FREE_REGION has no prompt, so configurations without a production consumer cannot enable it. Most configurations will therefore skip this case; this is intentional. The union and intersection tests remain available.
Since kunit_skip() does not return, the compiler drops the reference to the unavailable alloc_free_mem_region(), as in the CONFIG_OF_ADDRESS check in drivers/of/of_test.c.
--- kernel/resource_kunit.c | 3 +++ lib/Kconfig.debug | 1 - 2 files changed, 3 insertions(+), 1 deletion(-)
kernel/resource_kunit.c +3 -0
@@ -225,6 +225,9 @@ static void resource_test_region_intersects(struct kunit *test)struct resource *parent;resource_size_t start; +if (!IS_ENABLED (CONFIG_GET_FREE_REGION )) +kunit_skip (test,"CONFIG_GET_FREE_REGION is disabled" ); +/* Find an iomem_resource hole to hold test resources */ parent =alloc_free_mem_region (&iomem_resource,RES_TEST_TOTAL_SIZE ,SZ_1M ,"test resources" );
lib/Kconfig.debug +0 -1
@@ -2613,7 +2613,6 @@ config RESOURCE_KUNIT_TEST tristate "KUnit test for resource API" if !KUNIT_ALL_TESTS depends on KUNIT default KUNIT_ALL_TESTS - select GET_FREE_REGION help This builds the resource API unit test. Tests the logic of API provided by resource.c and ioport.h.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1174/1756 kcov: report spurious PCs in the interrupt selftest
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 5d9f31ed855fa89e533b222d0365da81ad3b10cc ]
The KCOV interrupt selftest enables KCOV_MODE_TRACE_PC without a coverage area so that spurious coverage causes a fault. If the fault path is instrumented, the coverage callback faults recursively. Observed failure modes include a stack overflow on x86_64 and arm32 getting stuck in abort handling, neither of which identifies the original coverage event.
The recursive failure is not new, but commit 9a79524d1420 ("kcov: use WRITE_ONCE() for selftest mode stores") made the selftest effective on configurations where the compiler had previously removed the mode store, exposing it more broadly.
Replace the open-coded kcov_mode stores with kcov_start() and kcov_stop(), passing a 16-word buffer that records up to 15 spurious PCs, with the first word holding the count. Keep KCOV enabled for the original 300 ms window, then disable it, print all recorded PCs and panic if any were recorded. Once the buffer fills, further PCs are discarded by the existing coverage callback. This preserves the selftest's hard failure while avoiding the recursive fault path.
Add decanonicalize_ip() as the inverse of canonicalize_ip(), which subtracts kaslr_offset() from recorded PCs. Restore that offset before printing the PCs with %pB, since KCOV records return addresses.
--- kernel/kcov.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-)
kernel/kcov.c +29 -6
@@ -198,6 +198,16 @@ static notrace unsigned long canonicalize_ip(unsigned long ip)return ip; } +#ifdef CONFIG_KCOV_SELFTEST +static unsigned long __init decanonicalize_ip (unsigned long ip) +{ +#ifdef CONFIG_RANDOMIZE_BASE + ip +=kaslr_offset (); +#endif +return ip; +} +#endif +/* * Entry point from instrumented code. * This is called once per basic-block/edge.
@@ -1074,9 +1084,11 @@ u64 kcov_common_handle(void)EXPORT_SYMBOL (kcov_common_handle);#ifdef CONFIG_KCOV_SELFTEST +static unsigned long selftest_area[16 ]__initdata ; +static void __init selftest (void ) { -unsigned long start; +unsigned long start, i, ip, count;pr_err ("running self test\n" );/*
@@ -1086,15 +1098,26 @@ static void __init selftest(void)* leaks out of that section and leads to spurious coverage. * It's hard to call the actual interrupt handler directly, * so we just loop here for a bit waiting for a timer interrupt. -* We set kcov_mode to enable tracing, but don't setup the area, -* so any attempt to trace will crash. Note: we must not call any +* A small coverage area records the PCs of any leaks. The first word +* holds the count, leaving room for 15 PCs. Note: we must not call any * potentially traced functions in this region. */ +kcov_start (current,NULL ,ARRAY_SIZE (selftest_area), + selftest_area,KCOV_MODE_TRACE_PC ,0 ); start = jiffies; -WRITE_ONCE (current->kcov_mode,KCOV_MODE_TRACE_PC );while ((jiffies - start) *MSEC_PER_SEC /HZ <300 ) - ; -WRITE_ONCE (current->kcov_mode,0 ); +cpu_relax (); +kcov_stop (current); + + count =READ_ONCE (selftest_area[0 ]); +if (count) { +pr_err ("spurious coverage detected during interrupt selftest:\n" ); +for (i =1 ; i <= count; i++) { + ip =decanonicalize_ip (selftest_area[i]); +pr_err (" %pB\n" , (void *)ip); + } +panic ("kcov: interrupt selftest detected spurious coverage" ); + } pr_err("done running self test\n"); }#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1175/1756 ALSA: pcm: Fix driver_tstamp value reporting
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amadeusz Sławiński <[email protected]>
[ Upstream commit 8ff1161ac5aa02f3261e00f07d6212be2b12384b ]
In some cases (system32 and compat64) due to incorrect assignment wrong value is being reported. Fix it.
--- sound/core/pcm_compat.c | 4 ++-- sound/core/pcm_native.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
sound/core/pcm_compat.c +2 -2
@@ -219,8 +219,8 @@ static int snd_pcm_status_user_compat64(struct snd_pcm_substream *substream, .audio_tstamp_data = status.audio_tstamp_data, .audio_tstamp_sec = status.audio_tstamp_sec, .audio_tstamp_nsec = status.audio_tstamp_nsec, - .driver_tstamp_sec = status.audio_tstamp_sec, - .driver_tstamp_nsec = status.audio_tstamp_nsec, + .driver_tstamp_sec = status.driver_tstamp_sec, + .driver_tstamp_nsec = status.driver_tstamp_nsec, .audio_tstamp_accuracy = status.audio_tstamp_accuracy, };
sound/core/pcm_native.c +2 -2
@@ -1173,8 +1173,8 @@ static int snd_pcm_status_user32(struct snd_pcm_substream *substream, .audio_tstamp_data = status64.audio_tstamp_data, .audio_tstamp_sec = status64.audio_tstamp_sec, .audio_tstamp_nsec = status64.audio_tstamp_nsec, - .driver_tstamp_sec = status64.audio_tstamp_sec, - .driver_tstamp_nsec = status64.audio_tstamp_nsec, + .driver_tstamp_sec = status64.driver_tstamp_sec, + .driver_tstamp_nsec = status64.driver_tstamp_nsec, .audio_tstamp_accuracy = status64.audio_tstamp_accuracy, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1176/1756 ALSA: jack: Fix kctl free at error in snd_jack_kctl_new()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit f421be924fec67f74bb0b6988ea8f0a3480df2a7 ]
When an error happens in snd_jack_kctl_new(), it tries to free the new kcontrol element via snd_ctl_free_one(). But snd_ctl_free_one() releases only the memories, and the internal linked list and hash entries still remain, which may lead to bogus accesses to user.
Replace with the correct destructor, snd_ctl_remove(), for clearing the whole resources of the given kcontrol, instead.
--- sound/core/jack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/jack.c +1 -1
@@ -454,7 +454,7 @@ static struct snd_jack_kctl * snd_jack_kctl_new(struct snd_card *card, const chareturn jack_kctl; error: -snd_ctl_free_one (kctl); +snd_ctl_remove (card, kctl);return NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1177/1756 ALSA: pcm: Protect delay DMA sync in forward and rewind, too
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit d5096bb9beacb448091c1c9541432021dd5c1fcd ]
Like the previous fix for snd_pcm_delay() (in the commit 50f413b83b31 "ALSA: pcm: Protect delay DMA sync against concurrent HW_FREE"), the snd_pcm_dma_buffer_sync() call in snd_pcm_forward() and snd_pcm_rewind() needs the similar protection against the concurrent hw_free action for avoiding potential UAFs.
--- sound/core/pcm_native.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/core/pcm_native.c +10 -0
@@ -3037,11 +3037,15 @@ static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream,static snd_pcm_sframes_t snd_pcm_rewind (struct snd_pcm_substream *substream,snd_pcm_uframes_t frames) { +struct snd_pcm_runtime *runtime = substream->runtime;snd_pcm_sframes_t ret;if (frames ==0 )return 0 ; +/* Keep the DMA buffer alive through the sync below. */ +if (!atomic_inc_unless_negative (&runtime->buffer_accessing)) +return -EBUSY ; scoped_guard(pcm_stream_lock_irq, substream) { ret =do_pcm_hwsync (substream);if (!ret)
@@ -3050,17 +3054,22 @@ static snd_pcm_sframes_t snd_pcm_rewind(struct snd_pcm_substream *substream, }if (ret >=0 )snd_pcm_dma_buffer_sync (substream,SNDRV_DMA_SYNC_DEVICE ); +atomic_dec (&runtime->buffer_accessing);return ret; }static snd_pcm_sframes_t snd_pcm_forward (struct snd_pcm_substream *substream,snd_pcm_uframes_t frames) { +struct snd_pcm_runtime *runtime = substream->runtime;snd_pcm_sframes_t ret;if (frames ==0 )return 0 ; +/* Keep the DMA buffer alive through the sync below. */ +if (!atomic_inc_unless_negative (&runtime->buffer_accessing)) +return -EBUSY ; scoped_guard(pcm_stream_lock_irq, substream) { ret =do_pcm_hwsync (substream);if (!ret)
@@ -3069,6 +3078,7 @@ static snd_pcm_sframes_t snd_pcm_forward(struct snd_pcm_substream *substream, }if (ret >=0 )snd_pcm_dma_buffer_sync (substream,SNDRV_DMA_SYNC_DEVICE ); +atomic_dec (&runtime->buffer_accessing);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1178/1756 ALSA: line6: Use kzalloc() for PCM buffer allocation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 9ec633573c1d162bfc82cae52d14c220c875612f ]
LINE6 driver allocates the PCM buffer via kmalloc(), and this might leave some bytes uninitialized that are out of the actual ring buffer size, while it's still exposed via mmap.
For avoiding the leak of the uninitialized kernel memory, simply replace it with kzalloc().
--- sound/usb/line6/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/line6/pcm.c +1 -1
@@ -155,7 +155,7 @@ static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm,/* Invoked multiple times in a row so allocate once only */ if (!test_and_set_bit (type, &pstr->opened) && !pstr->buffer) { pstr->buffer = -kmalloc (array3_size (line6pcm->line6->iso_buffers, +kzalloc (array3_size (line6pcm->line6->iso_buffers,LINE6_ISO_PACKETS , pkt_size),GFP_KERNEL );if (!pstr->buffer)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1179/1756 ALSA: vmaster: Serialize hook registration with control callbacks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 6215cf3ff5b0ff1ca5ab66b79021f9e28b02eae1 ]
An HDA virtual-master hook must have its private argument initialized before a control callback can invoke it. snd_hda_add_vmaster_hook() installs the trampoline through snd_ctl_add_vmaster_hook(), which stores master->hook before master->hook_private_data without serialization.
When a codec with a vmaster mute hook binds to an already registered card, snd_hda_gen_build_controls() publishes and initializes the Master Playback Switch before installing the hook. A native write that changes the switch can then run in the following order:
1. The codec bind path publishes and initializes the master control in __snd_hda_add_vmaster(), then calls snd_hda_add_vmaster_hook().
2. The hook setter stores master->hook, but has not yet stored its private argument.
3. SNDRV_CTL_IOCTL_ELEM_WRITE takes controls_rwsem and calls master_put() while the setter remains between those stores.
4. master_put() sees the callback and invokes vmaster_hook() with a NULL argument. The trampoline dereferences it before the setter can complete publication.
The write lock held by snd_ctl_elem_write() does not exclude the hook setter, so this can cause a NULL pointer dereference. Take the same controls_rwsem for writing inside snd_ctl_add_vmaster_hook() so the callback and its argument are installed together with respect to native control callbacks. Pass the card into the helper and update the HDA caller, keeping the lock in the ALSA core. Release it when registration returns, before the caller synchronizes the hook.
KASAN report as below:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
CPU: 1 UID: 0 PID: 499 Comm: alsa-vmaster-tr Not tainted 7.2.0-rc6-pmb-bt-functional-v1+ #1 PREEMPT(lazy)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:vmaster_hook+0x35/0xb0
Code: f5 53 48 89 fb 48 83 ec 08 e8 57 f0 9a fc eb 50 e8 50 f0 9a fc 48 8d 7b 08 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 75 59 48 8d 7b 10 48 8b 43 08 48 ba 00 00 00 00 00 fc
RSP: 0018:ffff888117647cd0 EFLAGS: 00010212
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff84e9ff50
RDX: 0000000000000001 RSI: 0000000000000000 RDI: 0000000000000008
RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000001
R10: ffffffff89427457 R11: ffff888115ad1d00 R12: ffffffff84e9ff30
R13: ffff888114943ca0 R14: 0000000000000000 R15: 0000000000000001
FS: 00007fe8167b3780(0000) GS:ffff88826b7e3000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000557c8c2842a8 CR3: 000000011579f005 CR4: 0000000000770ef0
PKRU: 55555554
Call Trace:
<TASK>
master_put+0x20e/0x2b0
snd_ctl_elem_write+0x37f/0x5e0
snd_ctl_ioctl+0x997/0xdd0
? __pfx_snd_ctl_ioctl+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? selinux_file_ioctl+0xaa/0x280
? __pfx_snd_ctl_ioctl+0x10/0x10
__x64_sys_ioctl+0x163/0x1d0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fe8168c291b
Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1c 48 8b 44 24 18 64 48 2b 04 25 28 00 00
RSP: 002b:00007fffab0cb150 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fe8168c291b
RDX: 00007fffab0cb310 RSI: 00000000c4c85513 RDI: 0000000000000003
RBP: 00007fffab0cb310 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007fffab0cb1c0 R14: 0000000000000001 R15: 0000557c4f71fd10
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]------ include/sound/control.h | 2 +- sound/core/vmaster.c | 7 ++++++- sound/pci/hda/hda_codec.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-)
include/sound/control.h +1 -1
@@ -286,7 +286,7 @@ snd_ctl_add_follower_uncached(struct snd_kcontrol *master,return _snd_ctl_add_follower (master, follower,SND_CTL_FOLLOWER_NEED_UPDATE ); } -int snd_ctl_add_vmaster_hook (struct snd_kcontrol *kctl, +int snd_ctl_add_vmaster_hook (struct snd_card *card,struct snd_kcontrol *kctl,void (*hook)(void *private_data,int ),void *private_data);void snd_ctl_sync_vmaster (struct snd_kcontrol *kctl,bool hook_only);
sound/core/vmaster.c +6 -1
@@ -464,6 +464,7 @@ EXPORT_SYMBOL(snd_ctl_make_virtual_master);/** * snd_ctl_add_vmaster_hook - Add a hook to a vmaster control +* @card: the card instance * @kcontrol: vmaster kctl element * @hook: the hook function * @private_data: the private_data pointer to be saved
@@ -471,13 +472,17 @@ EXPORT_SYMBOL(snd_ctl_make_virtual_master);* Adds the given hook to the vmaster control element so that it's called * at each time when the value is changed. * +* Takes the card's controls_rwsem lock internally. +* * Return: Zero. */ -int snd_ctl_add_vmaster_hook (struct snd_kcontrol *kcontrol, +int snd_ctl_add_vmaster_hook (struct snd_card *card,struct snd_kcontrol *kcontrol,void (*hook)(void *private_data,int ),void *private_data) {struct link_master *master =snd_kcontrol_chip (kcontrol); + +guard (rwsem_write)(&card->controls_rwsem); master->hook = hook; master->hook_private_data = private_data;return 0 ;
sound/pci/hda/hda_codec.c +1 -1
@@ -2073,7 +2073,7 @@ int snd_hda_add_vmaster_hook(struct hda_codec *codec,if (!hook->hook || !hook->sw_kctl)return 0 ; hook->codec = codec; -snd_ctl_add_vmaster_hook (hook->sw_kctl, vmaster_hook, hook); +snd_ctl_add_vmaster_hook (codec->card, hook->sw_kctl, vmaster_hook, hook);return 0 ; }EXPORT_SYMBOL_GPL (snd_hda_add_vmaster_hook);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1180/1756 ALSA: usb-audio: Use fixed control index for us16x08 mixer elements
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit a68a688ce220f1b359bec53fa38d1504314dc70f ]
The callbacks for us16x08 mixer elements assume that id.index points to the channel to be operated, and the assumption is correct for now. However, since the kctls are added via snd_usb_mixer_add_control() and it looks for the empty slot if the same control name is already present, in theory, the index can become more than the channel numbers (if a conflicting name really happens).
Since the mixer code in us16x08 doesn't need the search for an empty slot but requires the fixed index, this patch changes slightly how to assign the kcontrols. Now, a new argument is added to snd_usb_mixer_add_list() in order to disable the empty slot search, and use it in us16x08's add_new_ctl() helper function, instead.
--- sound/usb/mixer.c | 13 +++++++++---- sound/usb/mixer.h | 5 +++-- sound/usb/mixer_quirks.c | 2 +- sound/usb/mixer_us16x08.c | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-)
sound/usb/mixer.c +9 -4
@@ -581,20 +581,25 @@ static int check_matrix_bitmap(unsigned char *bmap,/* * add an alsa control element -* search and increment the index until an empty slot is found. +* when @look_for_empty is set, search and increment the index until an empty +* slot is found. * * if failed, give up and free the control instance. */ int snd_usb_mixer_add_list (struct usb_mixer_elem_list *list,struct snd_kcontrol *kctl, -bool is_std_info) +bool is_std_info, +bool look_for_empty) {struct usb_mixer_interface *mixer = list->mixer;int err; -while (snd_ctl_find_id (mixer->chip->card, &kctl->id)) - kctl->id.index++; +if (look_for_empty) { +while (snd_ctl_find_id (mixer->chip->card, &kctl->id)) + kctl->id.index++; + } + err =snd_ctl_add (mixer->chip->card, kctl);if (err <0 ) { usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n",
sound/usb/mixer.h +3 -2
@@ -110,10 +110,11 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,int snd_usb_mixer_add_list (struct usb_mixer_elem_list *list,struct snd_kcontrol *kctl, -bool is_std_info); +bool is_std_info, +bool look_for_empty);#define snd_usb_mixer_add_control (list, kctl) \ - snd_usb_mixer_add_list(list, kctl, true) + snd_usb_mixer_add_list(list, kctl, true, true) void snd_usb_mixer_elem_init_std(struct usb_mixer_elem_list *list, struct usb_mixer_interface *mixer,
sound/usb/mixer_quirks.c +1 -1
@@ -165,7 +165,7 @@ static int add_single_ctl_with_resume(struct usb_mixer_interface *mixer, } kctl->private_free = snd_usb_mixer_elem_free;/* don't use snd_usb_mixer_add_control() here, this is a special list element */ -return snd_usb_mixer_add_list (list, kctl, false); +return snd_usb_mixer_add_list (list, kctl, false, true); }/*
sound/usb/mixer_us16x08.c +2 -1
@@ -1128,7 +1128,8 @@ static int add_new_ctl(struct usb_mixer_interface *mixer,strscpy (kctl->id.name, name,sizeof (kctl->id.name)); - err =snd_usb_mixer_add_control (&elem->head, kctl); +/* look_for_empty=false, as we want the fixed id.index as channel */ + err =snd_usb_mixer_add_list (&elem->head, kctl, true, false);if (err <0 )return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1181/1756 thermal/drivers/sprd: validate the sensor id from the device tree
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weigang He <[email protected]>
[ Upstream commit b17d799ce49bfaad68be5ff3df995b3bd021a9d7 ]
sprd_thm_probe() reads each sensor child node's "reg" property into sen->id and uses it without validation: to compute the sensor's register offsets in sprd_thm_sensor_init(), as the thermal zone id, and finally as an index into thm->sensor[], which has SPRD_THM_MAX_SENSOR
(8) entries:
ret = of_property_read_u32(sen_child, "reg", &sen->id); ... thm->sensor[sen->id] = sen;
Only the number of sensor nodes is checked against SPRD_THM_MAX_SENSOR. A "reg" value of 8 or more, or one that is negative once stored in the int sen->id, makes the register offsets point outside the sensor range and the final store land outside thm->sensor[], overwriting the fields that follow it in struct sprd_thermal_data or other memory.
Reject an out-of-range id right after reading it, before it is used.
This does not address sparse ids, such as a single sensor with id 7:
they leave holes in thm->sensor[] that the later loops over 0..nr_sensors-1 dereference. That needs a separate fix.
Found by static analysis tool CodeQL.
--- drivers/thermal/sprd_thermal.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/thermal/sprd_thermal.c +6 -0
@@ -396,6 +396,12 @@ static int sprd_thm_probe(struct platform_device *pdev) goto of_put; } +if (sen->id <0 || sen->id >=SPRD_THM_MAX_SENSOR ) { +dev_err (&pdev->dev,"invalid sensor id %d\n" , sen->id); + ret = -EINVAL ; + goto of_put; + } + ret =sprd_thm_sensor_calibration (sen_child, thm, sen);if (ret) {dev_err (&pdev->dev,"efuse cal analysis failed" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1182/1756 tools/thermal/tmon: Fix string truncation warning in optarg copy
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 602da762f7a7c494a95cb204ac005965b214e556 ]
GCC warns about possible string truncation with -Wstringop-truncation:
tmon.c: In function ‘main’:
tmon.c:233:25: warning: ‘__builtin_strncpy’ specified bound 20 equals
destination size [-Wstringop-truncation]
233 | strncpy(ctrl_cdev, optarg,
CDEV_NAME_SIZE);
|^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Replace strncpy() with snprintf() to guarantee NUL-termination and silence the compiler warning.
--- tools/thermal/tmon/tmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/thermal/tmon/tmon.c +1 -1
@@ -230,7 +230,7 @@ int main(int argc, char **argv)switch (c) {case 'c' : no_control =0 ; -strncpy (ctrl_cdev, optarg,CDEV_NAME_SIZE ); +snprintf (ctrl_cdev,sizeof (ctrl_cdev),"%s" , optarg);break ;case 'd' :start_daemon_mode ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1183/1756 thermal: ti-soc-thermal: Fix the return value in ti_bandgap_get_sensor_data() kernel-doc
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 82bb005cd9cf5a9df4cfe4a52db90346ac5fd17a ]
ti_bandgap_get_sensor_data() returns an ERR_PTR() if the bandgap instance or sensor ID is invalid. Otherwise it returns the stored sensor data, which can be NULL if no data has been set or the stored value has been cleared.
This mismatch was already present in omap_bandgap_get_sensor_data() when the driver was introduced in staging.
Document the validation errors while retaining NULL as a possible stored value.
--- drivers/thermal/ti-soc-thermal/ti-bandgap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/ti-soc-thermal/ti-bandgap.c +2 -1
@@ -576,7 +576,8 @@ int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data)* @bgp: pointer to bandgap instance * @id: sensor id * -* Return: data stored by set function with sensor id on success or NULL +* Return: the stored sensor data, which may be %NULL, or an ERR_PTR() +* if @bgp or @id is invalid. */ void *ti_bandgap_get_sensor_data (struct ti_bandgap *bgp,int id) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1184/1756 mm, slab: add kerneldocs for common SLAB_ flags
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlastimil Babka <[email protected]>
[ Upstream commit b6da940130579769a42605b2c7f529b6f14ef1f8 ]
We have many SLAB_ flags but many are used only internally, by kunit tests or debugging subsystems cooperating with slab, or are set according to slab_debug boot parameter.
Create kerneldocs for the commonly used flags that may be passed to kmem_cache_create(). SLAB_TYPESAFE_BY_RCU already had a detailed description, so turn it to a kerneldoc. Add some details for SLAB_ACCOUNT, SLAB_RECLAIM_ACCOUNT and SLAB_HWCACHE_ALIGN. Reference them from the __kmem_cache_create_args() kerneldoc.
Stable-dep-of: 655668f0caf3 ("mm/slab: Mark the kmem_buckets_create() context as a Context: section")
--- include/linux/slab.h | 62 ++++++++++++++++++++++++++++++-------------- mm/slab_common.c | 14 +++++++++- 2 files changed, 55 insertions(+), 21 deletions(-)
include/linux/slab.h +42 -20
@@ -78,7 +78,17 @@ enum _slab_flag_bits {#define SLAB_POISON __SLAB_FLAG_BIT(_SLAB_POISON)/* Indicate a kmalloc slab */ #define SLAB_KMALLOC __SLAB_FLAG_BIT(_SLAB_KMALLOC) -/* Align objs on cache lines */ +/** +* define SLAB_HWCACHE_ALIGN - Align objects on cache line boundaries. +* +* Sufficiently large objects are aligned on cache line boundary. For object +* size smaller than a half of cache line size, the alignment is on the half of +* cache line size. In general, if object size is smaller than 1/2^n of cache +* line size, the alignment is adjusted to 1/2^n. +* +* If explicit alignment is also requested by the respective +* &struct kmem_cache_args field, the greater of both is alignments is applied. +*/ #define SLAB_HWCACHE_ALIGN __SLAB_FLAG_BIT(_SLAB_HWCACHE_ALIGN)/* Use GFP_DMA memory */ #define SLAB_CACHE_DMA __SLAB_FLAG_BIT(_SLAB_CACHE_DMA)
@@ -88,8 +98,8 @@ enum _slab_flag_bits {#define SLAB_STORE_USER __SLAB_FLAG_BIT(_SLAB_STORE_USER)/* Panic if kmem_cache_create() fails */ #define SLAB_PANIC __SLAB_FLAG_BIT(_SLAB_PANIC) -/* -* SLAB_TYPESAFE_BY_RCU - **WARNING** READ THIS! +/** +* define SLAB_TYPESAFE_BY_RCU - **WARNING** READ THIS! * * This delays freeing the SLAB page by a grace period, it does _NOT_ * delay object freeing. This means that if you do kmem_cache_free()
@@ -100,20 +110,22 @@ enum _slab_flag_bits {* stays valid, the trick to using this is relying on an independent * object validation pass. Something like: * -* begin: -* rcu_read_lock(); -* obj = lockless_lookup(key); -* if (obj) { -* if (!try_get_ref(obj)) // might fail for free objects -* rcu_read_unlock(); -* goto begin; -* -* if (obj->key != key) { // not the object we expected -* put_ref(obj); -* rcu_read_unlock(); -* goto begin; -* } -* } +* :: +* +* begin: +* rcu_read_lock(); +* obj = lockless_lookup(key); +* if (obj) { +* if (!try_get_ref(obj)) // might fail for free objects +* rcu_read_unlock(); +* goto begin; +* +* if (obj->key != key) { // not the object we expected +* put_ref(obj); +* rcu_read_unlock(); +* goto begin; +* } +* } * rcu_read_unlock(); * * This is useful if we need to approach a kernel structure obliquely,
@@ -147,7 +159,6 @@ enum _slab_flag_bits {* * Note that SLAB_TYPESAFE_BY_RCU was originally named SLAB_DESTROY_BY_RCU. */ -/* Defer freeing slabs to RCU */ #define SLAB_TYPESAFE_BY_RCU __SLAB_FLAG_BIT(_SLAB_TYPESAFE_BY_RCU)/* Trace allocations and frees */ #define SLAB_TRACE __SLAB_FLAG_BIT(_SLAB_TRACE)
@@ -180,7 +191,12 @@ enum _slab_flag_bits {#else # define SLAB_FAILSLAB __SLAB_FLAG_UNUSED#endif -/* Account to memcg */ +/** +* define SLAB_ACCOUNT - Account allocations to memcg. +* +* All object allocations from this cache will be memcg accounted, regardless of +* __GFP_ACCOUNT being or not being passed to individual allocations. +*/ #ifdef CONFIG_MEMCG # define SLAB_ACCOUNT __SLAB_FLAG_BIT(_SLAB_ACCOUNT)#else
@@ -207,7 +223,13 @@ enum _slab_flag_bits {#endif /* The following flags affect the page allocator grouping pages by mobility */ -/* Objects are reclaimable */ +/** +* define SLAB_RECLAIM_ACCOUNT - Objects are reclaimable. +* +* Use this flag for caches that have an associated shrinker. As a result, slab +* pages are allocated with __GFP_RECLAIMABLE, which affects grouping pages by +* mobility, and are accounted in SReclaimable counter in /proc/meminfo +*/ #ifndef CONFIG_SLUB_TINY #define SLAB_RECLAIM_ACCOUNT __SLAB_FLAG_BIT(_SLAB_RECLAIM_ACCOUNT)#else
mm/slab_common.c +13 -1
@@ -285,11 +285,23 @@ __kmem_cache_alias(const char *name, unsigned int size, slab_flags_t flags,* @object_size: The size of objects to be created in this cache. * @args: Additional arguments for the cache creation (see * &struct kmem_cache_args). -* @flags: See %SLAB_* flags for an explanation of individual @flags. +* @flags: See the desriptions of individual flags. The common ones are listed +* in the description below. * * Not to be called directly, use the kmem_cache_create() wrapper with the same * parameters. * +* Commonly used @flags: +* +* &SLAB_ACCOUNT - Account allocations to memcg. +* +* &SLAB_HWCACHE_ALIGN - Align objects on cache line boundaries. +* +* &SLAB_RECLAIM_ACCOUNT - Objects are reclaimable. +* +* &SLAB_TYPESAFE_BY_RCU - Slab page (not individual objects) freeing delayed +* by a grace period - see the full description before using. +* * Context: Cannot be called within a interrupt, but can be interrupted. * * Return: a pointer to the cache on success, NULL on failure.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1185/1756 mm/slab: Mark the kmem_buckets_create() context as a Context: section
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 655668f0caf32a42fef10aaf31137e52f46a0260 ]
kmem_buckets_create() had the same sentence about calling context as kmem_cache_create(), but lacked the "Context:" prefix, so kernel-doc rendered in the body instead of as a "context" section.
Give it the missing prefix. Additionally fix the "a interrupt" typo __kmem_cache_create_args() had.
--- mm/slab_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/slab_common.c +2 -2
@@ -302,7 +302,7 @@ __kmem_cache_alias(const char *name, unsigned int size, slab_flags_t flags,* &SLAB_TYPESAFE_BY_RCU - Slab page (not individual objects) freeing delayed * by a grace period - see the full description before using. * -* Context: Cannot be called within a interrupt, but can be interrupted. +* Context: Cannot be called within an interrupt, but can be interrupted. * * Return: a pointer to the cache on success, NULL on failure. */
@@ -406,7 +406,7 @@ static struct kmem_cache *kmem_buckets_cache __ro_after_init;* to/from userspace. * @ctor: A constructor for the objects, run when new allocations are made. * -* Cannot be called within an interrupt, but can be interrupted. +* Context: Cannot be called within an interrupt, but can be interrupted. * * Return: a pointer to the cache on success, NULL on failure. When * CONFIG_SLAB_BUCKETS is not enabled, ZERO_SIZE_PTR is returned, and
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1186/1756 module: Fix uninitialized count read of unloaded taint tracking record
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Deng <[email protected]>
[ Upstream commit 7a5c13cfdfcb1871050fdbe00ac223993f8925fa ]
try_add_tainted_module() allocates the tracking record without zeroing it and initializes the fields in this order:
mod_taint = kmalloc_obj(*mod_taint); strscpy(mod_taint->name, mod->name, MODULE_NAME_LEN); mod_taint->taints = mod->taints; list_add_rcu(&mod_taint->list, &unloaded_tainted_modules); mod_taint->count = 1;
The record is published by list_add_rcu() before the count field is written. The readers, unloaded_tainted_modules_seq_show() (debugfs, under rcu_read_lock()) and print_unloaded_tainted_modules() (panic path, under guard(rcu)), traverse the list under RCU and read mod_taint->count. module_mutex, which the writer holds, does not exclude RCU readers.
A reader that observes the new node between the list_add_rcu() and the count store reads an uninitialized u64 left over from previous slab use. This is a data race and leaks kernel heap residue through the debugfs file and the panic message.
The race window is two adjacent instructions; it is reachable when a tainted module is unloaded (rmmod) concurrently with a read of /sys/kernel/debug/module/unloaded_tainted, or with the module list printout of an oops on another CPU.
Fix this by initializing count before the record is published.
Found during a static-analysis-assisted audit: candidate sites were surfaced by a Coccinelle rule, and the reader/writer paths were confirmed by LLM-assisted (GLM-5.3) code inspection. The issue was not observed at runtime; it is identified by code inspection only.
--- kernel/module/tracking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/module/tracking.c +1 -1
@@ -40,8 +40,8 @@ int try_add_tainted_module(struct module *mod)return -ENOMEM ;strscpy (mod_taint->name, mod->name,MODULE_NAME_LEN ); mod_taint->taints = mod->taints; -list_add_rcu (&mod_taint->list, &unloaded_tainted_modules); mod_taint->count =1 ; +list_add_rcu (&mod_taint->list, &unloaded_tainted_modules); out:return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1187/1756 ipvs: fix buffer overflow when sending sync messages
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit 3e3fe49e8678c1a3d535ed02f32a9a6e80674263 ]
Sashiko reports for possible heap buffer overflow when generating sync message for the v0 and v1 message formats. We should read the cp->flags only once because another CPU can concurrently set the SEQ_MASK between the two reads.
Note that IPVS does not set the SEQ_MASK anymore for the ip_vs_ftp.c helper starting from commit 7f1c40757951 ("IPVS: make FTP work with full NAT support") (2.6.36+), so the problem should not be reproducible.
--- net/netfilter/ipvs/ip_vs_sync.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +14 -9
@@ -544,13 +544,15 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,struct ip_vs_sync_conn_v0 *s;struct ip_vs_sync_buff *buff;struct ipvs_master_sync_state *ms; -int id; +u32 flags, seq_mask;unsigned int len; +int id;if (unlikely (cp->af !=AF_INET ))return ; + flags =READ_ONCE (cp->flags);/* Do not sync ONE PACKET */ -if (cp->flags &IP_VS_CONN_F_ONE_PACKET ) +if (flags &IP_VS_CONN_F_ONE_PACKET )return ;if (!ip_vs_sync_conn_needed (ipvs, cp, pkts))
@@ -565,8 +567,8 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, id =select_master_thread_id (ipvs, cp); ms = &ipvs->ms[id]; buff = ms->sync_buff; - len = (cp->flags &IP_VS_CONN_F_SEQ_MASK ) ?FULL_CONN_SIZE : -SIMPLE_CONN_SIZE ; + seq_mask = flags &IP_VS_CONN_F_SEQ_MASK ; + len = seq_mask ?FULL_CONN_SIZE :SIMPLE_CONN_SIZE ;if (buff) { m = (struct ip_vs_sync_mesg_v0 *) buff->mesg;/* Send buffer if it is for v1 */
@@ -598,9 +600,9 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, s->caddr = cp->caddr.ip; s->vaddr = cp->vaddr.ip; s->daddr = cp->daddr.ip; - s->flags =htons (cp->flags & ~IP_VS_CONN_F_HASHED ); + s->flags =htons (flags & ~IP_VS_CONN_F_HASHED ); s->state =htons (cp->state); -if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) { +if (seq_mask) {struct ip_vs_sync_conn_options *opt = (struct ip_vs_sync_conn_options *)&s[1 ];memcpy (opt, &cp->sync_conn_opt,sizeof (*opt));
@@ -636,6 +638,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)int id;__u8 *p;unsigned int len, pe_name_len, pad; +u32 flags, seq_mask;/* Handle old version of the protocol */ if (sysctl_sync_ver (ipvs) ==0 ) {
@@ -648,6 +651,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts) sloop:if (!ip_vs_sync_conn_needed (ipvs, cp, pkts)) goto control; + flags =READ_ONCE (cp->flags);/* Sanity checks */ pe_name_len =0 ;
@@ -675,7 +679,8 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)#endif len =sizeof (struct ip_vs_sync_v4 ); -if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) + seq_mask = flags &IP_VS_CONN_F_SEQ_MASK ; +if (seq_mask) len +=sizeof (struct ip_vs_sync_conn_options ) +2 ;if (cp->pe_data_len)
@@ -721,7 +726,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)/* Set message type & copy members */ s->v4.type = (cp->af ==AF_INET6 ?STYPE_F_INET6 :0 ); s->v4.ver_size =htons (len &SVER_MASK );/* Version 0 */ - s->v4.flags =htonl (cp->flags & ~IP_VS_CONN_F_HASHED ); + s->v4.flags =htonl (flags & ~IP_VS_CONN_F_HASHED ); s->v4.state =htons (cp->state); s->v4.protocol = cp->protocol; s->v4.cport = cp->cport;
@@ -745,7 +750,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts) s->v4.vaddr = cp->vaddr.ip; s->v4.daddr = cp->daddr.ip; } -if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) { +if (seq_mask) { *(p++) =IPVS_OPT_SEQ_DATA ; *(p++) =sizeof (struct ip_vs_sync_conn_options );hton_seq (&cp->in_seq, (struct ip_vs_seq *)p);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1188/1756 wifi: cfg80211: track SSID regardless of country data
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 577f690ce5dc641d9d8646d15bb8e99ff4a8280e ]
If the country data cannot be found, the function exits and then doesn't track the SSID. Move the SSID tracking up to fix that.
--- net/wireless/sme.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
net/wireless/sme.c +19 -19
@@ -873,6 +873,25 @@ void __cfg80211_connect_result(struct net_device *dev,cfg80211_upload_connect_keys (wdev); +if (!wdev->u.client.ssid_len) { +rcu_read_lock (); +for_each_valid_link (cr, link) { +u32 ssid_len; + + ssid =ieee80211_bss_get_elem (cr->links[link].bss, +WLAN_EID_SSID ); + +if (!ssid || !ssid->datalen) +continue ; + + ssid_len =min (ssid->datalen,IEEE80211_MAX_SSID_LEN ); +memcpy (wdev->u.client.ssid, ssid->data, ssid_len); + wdev->u.client.ssid_len = ssid_len; +break ; + } +rcu_read_unlock (); + } +rcu_read_lock ();for_each_valid_link (cr, link) { country_elem =
@@ -898,25 +917,6 @@ void __cfg80211_connect_result(struct net_device *dev, country_data, country_datalen);kfree (country_data); -if (!wdev->u.client.ssid_len) { -rcu_read_lock (); -for_each_valid_link (cr, link) { -u32 ssid_len; - - ssid =ieee80211_bss_get_elem (cr->links[link].bss, -WLAN_EID_SSID ); - -if (!ssid || !ssid->datalen) -continue ; - - ssid_len =min (ssid->datalen,IEEE80211_MAX_SSID_LEN ); -memcpy (wdev->u.client.ssid, ssid->data, ssid_len); - wdev->u.client.ssid_len = ssid_len; -break ; - } -rcu_read_unlock (); - } -return ; out:for_each_valid_link (cr, link)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1189/1756 ALSA: pcm: Unlink substreams before releasing them
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit d1e57f8fb7a6b6d32a4aaa31fd6fc4c77339608f ]
A closing PCM substream can remain in its linked group after the driver close callback has freed its private data. With two configured dummy capture substreams on the same PCM device, linked with LINK, PREPARE on the surviving substream can still visit the closing member:
Final close of A PREPARE on linked B
---------------- -------------------
snd_pcm_drop(): group -> SETUP
do_hw_free(A)
dummy_pcm_close(A): free dpcm
Take snd_pcm_link_rwsem for reading Walk the group, including A dummy_pcm_prepare(A)
Read freed timer_ops
pcm_release_private(A)
snd_pcm_unlink(A)
Unlink at the start of final substream release, before dropping the stream or releasing driver resources. The link write lock waits for an existing group PREPARE, and unlink removes the closing member from later group actions. Keep the existing stop synchronization in do_hw_free() before the driver resources are freed.
Make unlink independent of the pcm_release callback so OSS substreams are covered too. Remove the native-only unlink callback and its registration, while retaining the callback hook for OSS cleanup.
The existing KASAN report below records the freed timer_ops read in dummy_pcm_prepare().
KASAN report as below:
BUG: KASAN: slab-use-after-free in dummy_pcm_prepare+0xb7/0xc0
Read of size 8 at addr ffff888106b35f00 by task alsa_pcm_fixtur/491
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? dummy_pcm_prepare+0xb7/0xc0
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? dummy_pcm_prepare+0xb7/0xc0
kasan_report+0xe0/0x110
? dummy_pcm_prepare+0xb7/0xc0
dummy_pcm_prepare+0xb7/0xc0
snd_pcm_do_prepare+0x71/0xb0
snd_pcm_action_group+0x505/0xb30
snd_pcm_action_nonatomic+0xab/0x150
snd_pcm_common_ioctl+0x1bf5/0x3a50
? srso_alias_return_thunk+0x5/0xfbef5
? do_vfs_ioctl+0x1f5/0x1280
? __pfx_do_vfs_ioctl+0x10/0x10
? ioctl_has_perm.constprop.0.isra.0+0x34f/0x500
? __pfx_snd_pcm_common_ioctl+0x10/0x10
? __fput+0x5ba/0xa60
? srso_alias_return_thunk+0x5/0xfbef5
snd_pcm_ioctl+0x76/0xb0
? __pfx_snd_pcm_ioctl+0x10/0x10
__x64_sys_ioctl+0x163/0x1d0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x41ee8d
Code: 04 25 28 00 00 00 48 89 45 c8 31 c0 48 8d 45 10 c7 45 b0 10 00 00 00 48 89 45 b8 48 8d 45 d0 48 89 45 c0 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1a 48 8b 45 c8 64 48 2b 04 25 28 00 00 00
RSP: 002b:00007ffcfa72fb60 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 000000000041ee8d
RDX: 0000000000000000 RSI: 0000000000004140 RDI: 0000000000000004
RBP: 00007ffcfa72fbb0 R08: 00007ffcfa72fb98 R09: 0000000000000110
R10: 0000000000000001 R11: 0000000000000246 R12: 00007ffcfa72fcd8
R13: 00007ffcfa72fcf0 R14: 00000000004a8f28 R15: 0000000000000001
</TASK>
Allocated by task 488:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x251/0x610
dummy_hrtimer_create+0x4a/0x170
dummy_pcm_open+0xe7/0x730
snd_pcm_open_substream+0x926/0x1580
snd_pcm_open+0x28d/0x6d0
snd_pcm_capture_open+0x82/0xe0
snd_open+0x1ec/0x3e0
chrdev_open+0x21f/0x660
do_dentry_open+0x5c8/0x1300
vfs_open+0x87/0x390
path_openat+0x2460/0x3cd0
do_file_open+0x21e/0x470
do_sys_openat2+0xf4/0x1b0
__x64_sys_openat+0x136/0x1e0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 490:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x307/0x580
dummy_hrtimer_free+0x72/0xe0
dummy_pcm_close+0x9f/0xd0
snd_pcm_release_substream.part.0+0x104/0x310
snd_pcm_release+0x106/0x240
__fput+0x39f/0xa60
fput_close_sync+0xff/0x200
__x64_sys_close+0x8c/0xf0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
==================================================================--- sound/core/pcm_native.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
sound/core/pcm_native.c +2 -8
@@ -2753,18 +2753,14 @@ static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream)return 0 ; } -static void pcm_release_private (struct snd_pcm_substream *substream) -{ -if (snd_pcm_stream_linked (substream)) -snd_pcm_unlink (substream); -} -void snd_pcm_release_substream (struct snd_pcm_substream *substream) { substream->ref_count--;if (substream->ref_count >0 )return ; +snd_pcm_unlink (substream); +snd_pcm_drop (substream);if (substream->hw_opened) {if (substream->runtime->state !=SNDRV_PCM_STATE_OPEN )
@@ -2848,8 +2844,6 @@ static int snd_pcm_open_file(struct file *file,return -ENOMEM ; } pcm_file->substream = substream; -if (substream->ref_count ==1 ) - substream->pcm_release = pcm_release_private; file->private_data = pcm_file;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1190/1756 platform/x86: hp-bioscfg: fix off-by-one in password length check
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
[ Upstream commit 0c22178524864af85ea380be4b2d36078c0edc9c ]
current_password and new_password hold MAX_PASSWD_SIZE bytes including the NUL, but validate_password_input() accepts a password of exactly MAX_PASSWD_SIZE characters when the firmware limits allow it. strscpy() then truncates it and fails with -E2BIG, which store_password_instance() ignores, so the write reports success with a truncated password stored.
For example, with a max_password_length of 64 or more, writing 64 characters succeeds but only 63 are stored.
Reject lengths of MAX_PASSWD_SIZE or more.
Compile tested only.
--- drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c +1 -1
@@ -74,7 +74,7 @@ static int validate_password_input(int instance_id, const char *buf,if (is_current && !length)return 0 ; -if (length >MAX_PASSWD_SIZE ) +if (length >=MAX_PASSWD_SIZE )return -E2BIG ; if (password_data->min_password_length > length ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1191/1756 platform/x86: hp-bioscfg: validate SPM state returned by firmware
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
[ Upstream commit 35fb43f1576e1352077afc33a535007e0568480c ]
status_show() indexes the 3-entry spm_state_types[] with the state byte returned by firmware. update_spm_state() stores the same byte, which key_mechanism_show() uses to index the 3-entry spm_mechanism_types[]. Neither is range checked, so a state above 2 makes the world-readable status and key_mechanism files print a string from a pointer read past the array.
Return -EIO for an out of range state.
Compile tested only.
--- drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c +7 -0
@@ -6,6 +6,7 @@* Copyright (c) 2022 HP Development Company, L.P. */ +#include <linux/array_size.h> #include "bioscfg.h" static const char *const spm_state_types[] = {
@@ -115,6 +116,9 @@ static ssize_t update_spm_state(void)if (ret <0 )return ret; +if (data.state >=ARRAY_SIZE (spm_mechanism_types)) +return -EIO ; + bioscfg_drv.spm_data.mechanism = data.state;if (bioscfg_drv.spm_data.mechanism) bioscfg_drv.spm_data.is_enabled =1 ;
@@ -150,6 +154,9 @@ static ssize_t status_show(struct kobject *kobj, struct kobj_attributeif (ret <0 )return ret; +if (data.state >=ARRAY_SIZE (spm_state_types)) +return -EIO ; +/* * 'status' is a read-only file that returns ASCII text in * JSON format reporting the status information.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1192/1756 platform/x86: hp-bioscfg: fix oops on short integer attribute buffer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
[ Upstream commit fd7545cd398adc09ec2f9b603d72671560ee6bf9 ]
hp_populate_integer_elements_from_buffer() ignores the return value of hp_get_string_from_buffer(). When fewer than 2 bytes are left in the buffer, dst_size is 0, kcalloc() returns ZERO_SIZE_PTR and hp_get_string_from_buffer() fails without writing to it, so kstrtoint() faults on address 0x10.
Return the error instead.
Compile tested only.
--- drivers/platform/x86/hp/hp-bioscfg/int-attributes.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/platform/x86/hp/hp-bioscfg/int-attributes.c +6 -1
@@ -331,7 +331,12 @@ static int hp_populate_integer_elements_from_buffer(u8 *buffer_ptr, u32 *buffer_// VALUE: integer_data->current_value =0 ; -hp_get_string_from_buffer (&buffer_ptr, buffer_size, dst, dst_size); + ret =hp_get_string_from_buffer (&buffer_ptr, buffer_size, dst, dst_size); +if (ret <0 ) { +kfree (dst); +return ret; + } + ret =kstrtoint (dst,10 , &integer_data->current_value);if (ret)pr_warn ("Unable to convert string to integer: %s\n" , dst);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1193/1756 serial: ma35d1: Do not force-enable an unselected console
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 171bb8a67cc1af7c88a65961adfb028430e0b783 ]
When another console is selected and there is no matching ttyNVT console argument, the core accepts the MA35D1 console without calling its setup function because it has CON_ENABLED set before registration. Its index remains -1 and printk repeatedly reports an invalid port, flooding the console and preventing boot.
Let the console core enable it after successful setup.
--- drivers/tty/serial/ma35d1_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/ma35d1_serial.c +1 -1
@@ -639,7 +639,7 @@ static struct console ma35d1serial_console = { .write = ma35d1serial_console_write, .device = uart_console_device, .setup = ma35d1serial_console_setup, - .flags = CON_PRINTBUFFER | CON_ENABLED, + .flags = CON_PRINTBUFFER, .index = -1, .data = &ma35d1serial_reg, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1194/1756 serial: pmac_zilog: report received breaks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tim Douglas <[email protected]>
[ Upstream commit 8db79ea07a67b126c773da6efdc00066000daeb8 ]
pmz_status_handle() sets PMACZILOG_FLAG_BREAK from RR0, and pmz_receive_chars() clears it on the null character that ends the break without marking that character, then tests BRK_ABRT in RR1, where the SCC does not set it in asynchronous mode. Breaks therefore arrive as plain NULs: brk is never counted and BRKINT, PARMRK and SysRq never see them.
Set BRK_ABRT in r1 for that character, as sunzilog does.
--- drivers/tty/serial/pmac_zilog.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/pmac_zilog.c +1 -0
@@ -233,6 +233,7 @@ static bool pmz_receive_chars(struct uart_pmac_port *uap) ch &= uap->parity_mask;if (ch ==0 && uap->flags &PMACZILOG_FLAG_BREAK ) { uap->flags &= ~PMACZILOG_FLAG_BREAK ; + r1 |=BRK_ABRT ; }#if defined(CONFIG_MAGIC_SYSRQ ) && defined(CONFIG_SERIAL_CORE_CONSOLE )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1195/1756 ASoC: codecs: wm8990: Fix definition of right input PGA controls
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 5bd6d05197affaf5a2d7fae0e06e7373fd839b7c ]
The right input PGA boost (R12MNBST, R34MNBST) and routing (R12MNB, R34MNB) bits are in Input Mixer4 (R42), not in Input Mixer3 (R41), where these controls write the left channel bits.
--- sound/soc/codecs/wm8990.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8990.c +4 -4
@@ -97,8 +97,8 @@ static const struct snd_kcontrol_new wm8990_snd_controls[] = {SOC_SINGLE ("LIN12 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_L12MNBST_BIT ,1 ,0 ),SOC_SINGLE ("LIN34 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_L34MNBST_BIT ,1 ,0 ),/* INMIXR */ -SOC_SINGLE ("RIN12 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_R12MNBST_BIT ,1 ,0 ), -SOC_SINGLE ("RIN34 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_R34MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN12 PGA Boost" ,WM8990_INPUT_MIXER4 ,WM8990_R12MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN34 PGA Boost" ,WM8990_INPUT_MIXER4 ,WM8990_R34MNBST_BIT ,1 ,0 ),/* LOMIX */ SOC_SINGLE_TLV("LOMIX LIN3 Bypass Volume", WM8990_OUTPUT_MIXER3,
@@ -377,9 +377,9 @@ SOC_DAPM_SINGLE_TLV("Record Right Volume", WM8990_INPUT_MIXER4, WM8990_RDBVOL_SHIFT, WM8990_RDBVOL_MASK, 0, in_mix_tlv),SOC_DAPM_SINGLE_TLV ("RIN2 Volume" ,WM8990_INPUT_MIXER6 ,WM8990_RI2BVOL_SHIFT ,7 ,0 , in_mix_tlv), -SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8990_INPUT_MIXER3 ,WM8990_L12MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8990_INPUT_MIXER4 ,WM8990_R12MNB_BIT ,1 ,0 ), -SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8990_INPUT_MIXER3 ,WM8990_L34MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8990_INPUT_MIXER4 ,WM8990_R34MNB_BIT , 1, 0), };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1196/1756 ASoC: codecs: wm8990: Fix definition of LOMIX AINLMUX Bypass Volume control
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 75e0b607e3456c9eb15dfb783984f814a89cbcaf ]
The LOMIX AINLMUX bypass volume (LLBLOVOL) is at bits 2:0 of Output Mixer5, not at bits 5:3, which hold the AINRMUX bypass volume (LRBLOVOL).
--- sound/soc/codecs/wm8990.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8990.c +1 -1
@@ -112,7 +112,7 @@ SOC_SINGLE_TLV("LOMIX RIN3 Bypass Volume", WM8990_OUTPUT_MIXER5,SOC_SINGLE_TLV ("LOMIX AINRMUX Bypass Volume" ,WM8990_OUTPUT_MIXER5 ,WM8990_LRBLOVOL_SHIFT ,WM8990_LRBLOVOL_MASK ,1 , out_mix_tlv),SOC_SINGLE_TLV ("LOMIX AINLMUX Bypass Volume" ,WM8990_OUTPUT_MIXER5 , -WM8990_LRBLOVOL_SHIFT ,WM8990_LRBLOVOL_MASK ,1 , out_mix_tlv), +WM8990_LLBLOVOL_SHIFT ,WM8990_LLBLOVOL_MASK ,1 , out_mix_tlv),/* ROMIX */ SOC_SINGLE_TLV("ROMIX RIN3 Bypass Volume", WM8990_OUTPUT_MIXER4,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1197/1756 ASoC: codecs: wm8991: Fix definition of right input PGA controls
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 2dfecdc25d4937a36675c0c36ee0addc99e1e7f9 ]
The right input PGA boost (R12MNBST, R34MNBST) and routing (R12MNB, R34MNB) bits are in Input Mixer4 (R42), not in Input Mixer3 (R41), where these controls write the left channel bits.
--- sound/soc/codecs/wm8991.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8991.c +4 -4
@@ -169,8 +169,8 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = {SOC_SINGLE ("LIN12 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_L12MNBST_BIT ,1 ,0 ),SOC_SINGLE ("LIN34 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_L34MNBST_BIT ,1 ,0 ),/* INMIXR */ -SOC_SINGLE ("RIN12 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_R12MNBST_BIT ,1 ,0 ), -SOC_SINGLE ("RIN34 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_R34MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN12 PGA Boost" ,WM8991_INPUT_MIXER4 ,WM8991_R12MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN34 PGA Boost" ,WM8991_INPUT_MIXER4 ,WM8991_R34MNBST_BIT ,1 ,0 ),/* LOMIX */ SOC_SINGLE_TLV("LOMIX LIN3 Bypass Volume", WM8991_OUTPUT_MIXER3,
@@ -446,9 +446,9 @@ static const struct snd_kcontrol_new wm8991_dapm_inmixr_controls[] = { WM8991_RDBVOL_SHIFT, WM8991_RDBVOL_MASK, 0, in_mix_tlv),SOC_DAPM_SINGLE_TLV ("RIN2 Volume" ,WM8991_INPUT_MIXER6 ,WM8991_RI2BVOL_SHIFT ,7 ,0 , in_mix_tlv), -SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8991_INPUT_MIXER3 ,WM8991_L12MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8991_INPUT_MIXER4 ,WM8991_R12MNB_BIT ,1 ,0 ), -SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8991_INPUT_MIXER3 ,WM8991_L34MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8991_INPUT_MIXER4 ,WM8991_R34MNB_BIT , 1, 0), };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1198/1756 ASoC: codecs: wm8991: Fix definition of LOMIX AINLMUX Bypass Volume control
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit fee722db39c2a1f18c944f747271fd1e131910a6 ]
The LOMIX AINLMUX bypass volume (LLBLOVOL) is at bits 2:0 of Output Mixer5, not at bits 5:3, which hold the AINRMUX bypass volume (LRBLOVOL).
--- sound/soc/codecs/wm8991.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8991.c +1 -1
@@ -184,7 +184,7 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = {SOC_SINGLE_TLV ("LOMIX AINRMUX Bypass Volume" ,WM8991_OUTPUT_MIXER5 ,WM8991_LRBLOVOL_SHIFT ,WM8991_LRBLOVOL_MASK ,1 , out_mix_tlv),SOC_SINGLE_TLV ("LOMIX AINLMUX Bypass Volume" ,WM8991_OUTPUT_MIXER5 , -WM8991_LRBLOVOL_SHIFT ,WM8991_LRBLOVOL_MASK ,1 , out_mix_tlv), +WM8991_LLBLOVOL_SHIFT ,WM8991_LLBLOVOL_MASK ,1 , out_mix_tlv),/* ROMIX */ SOC_SINGLE_TLV("ROMIX RIN3 Bypass Volume", WM8991_OUTPUT_MIXER4,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1199/1756 ASoC: codecs: wm8983: Fix definition of ADC 128x Oversampling control
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit c1af9e2272f025ff75be76e03413074d5e7801c9 ]
ADC 128x oversampling (ADCOSR128) is at bit 3 of ADC Control, not at bit 8, which is the high pass filter enable (HPFEN).
--- sound/soc/codecs/wm8983.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8983.c +1 -1
@@ -234,7 +234,7 @@ static const struct snd_kcontrol_new wm8983_snd_controls[] = { 8, 1, 0, pga_boost_tlv),SOC_DOUBLE ("ADC Inversion Switch" ,WM8983_ADC_CONTROL ,0 ,1 ,1 ,0 ), -SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8983_ADC_CONTROL ,8 ,1 ,0 ), +SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8983_ADC_CONTROL ,3 ,1 ,0 ),SOC_DOUBLE_R_TLV ("Playback Volume" ,WM8983_LEFT_DAC_DIGITAL_VOL , WM8983_RIGHT_DAC_DIGITAL_VOL, 0, 255, 0, dac_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1200/1756 ASoC: codecs: wm8985: Fix definition of ADC 128x Oversampling control
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit a747ec6e12cf7a71e42567a479af18b930890d9d ]
ADC 128x oversampling (ADCOSR128) is at bit 3 of ADC Control, not at bit 8, which is the high pass filter enable (HPFEN).
--- sound/soc/codecs/wm8985.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8985.c +1 -1
@@ -327,7 +327,7 @@ static const struct snd_kcontrol_new wm8985_common_snd_controls[] = { 8, 1, 0, pga_boost_tlv),SOC_DOUBLE ("ADC Inversion Switch" ,WM8985_ADC_CONTROL ,0 ,1 ,1 ,0 ), -SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8985_ADC_CONTROL ,8 ,1 ,0 ), +SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8985_ADC_CONTROL ,3 ,1 ,0 ),SOC_DOUBLE_R_TLV ("Playback Volume" ,WM8985_LEFT_DAC_DIGITAL_VOL , WM8985_RIGHT_DAC_DIGITAL_VOL, 0, 255, 0, dac_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1201/1756 ASoC: codecs: wm8994: Fix definition of WM8958 noise gate hold time controls
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 291d81d628f3453026b029507a26b856056e4fdc ]
The noise gate hold time (NG_HLD) is at bits 6:5 of each WM8958 DAC noise gate register, not at bits 3:1, which hold the threshold (NG_THR).
--- sound/soc/codecs/wm8994.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/wm8994.c +3 -3
@@ -700,17 +700,17 @@ static const char *wm8958_ng_text[] = { static SOC_ENUM_SINGLE_DECL(wm8958_aif1dac1_ng_hold, WM8958_AIF1_DAC1_NOISE_GATE, - WM8958_AIF1DAC1_NG_THR_SHIFT, + WM8958_AIF1DAC1_NG_HLD_SHIFT, wm8958_ng_text); static SOC_ENUM_SINGLE_DECL(wm8958_aif1dac2_ng_hold, WM8958_AIF1_DAC2_NOISE_GATE, - WM8958_AIF1DAC2_NG_THR_SHIFT, + WM8958_AIF1DAC2_NG_HLD_SHIFT, wm8958_ng_text); static SOC_ENUM_SINGLE_DECL(wm8958_aif2dac_ng_hold, WM8958_AIF2_DAC_NOISE_GATE, - WM8958_AIF2DAC_NG_THR_SHIFT, + WM8958_AIF2DAC_NG_HLD_SHIFT, wm8958_ng_text);static const struct snd_kcontrol_new wm8958_snd_controls[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1202/1756 ASoC: codecs: wm8955: Fix definition of Treble Cutoff control
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 71911bf5bb3fe97da2124d17fc1dd3dbb9379e03 ]
Treble cutoff (TC) is at bit 6 of Treble Control, not at bit 2, which is part of the treble volume (TRBL[3:0]).
--- sound/soc/codecs/wm8955.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8955.c +1 -1
@@ -426,7 +426,7 @@ static const char *treble_cutoff_text[] = {"High" ,"Low" }; -static SOC_ENUM_SINGLE_DECL(treble_cutoff, WM8955_TREBLE_CONTROL, 2, +static SOC_ENUM_SINGLE_DECL(treble_cutoff, WM8955_TREBLE_CONTROL, 6, treble_cutoff_text); static const DECLARE_TLV_DB_SCALE(digital_tlv, -12750, 50, 1);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1203/1756 ASoC: codecs: wm_hubs: Fix definition of MIXINR to MIXOUTR volume control
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 22bfcedd3febd6acc63ecf8bfd9638210e4b9a5e ]
The Right Output Mixer Right Input Volume (MIXINR_MIXOUTR_VOL) is at bits 2:0 of Output Mixer6, not at bits 8:6, which hold the IN2LN volume (IN2LN_MIXOUTR_VOL).
--- sound/soc/codecs/wm_hubs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm_hubs.c +1 -1
@@ -426,7 +426,7 @@ SOC_SINGLE_TLV("Right Output Mixer IN2RP Volume",SOC_SINGLE_TLV ("Right Output Mixer Left Input Volume" ,WM8993_OUTPUT_MIXER6 ,3 ,7 ,1 , outmix_tlv),SOC_SINGLE_TLV ("Right Output Mixer Right Input Volume" , -WM8993_OUTPUT_MIXER6 ,6 ,7 ,1 , outmix_tlv), +WM8993_OUTPUT_MIXER6 ,0 ,7 ,1 , outmix_tlv),SOC_SINGLE_TLV ("Right Output Mixer DAC Volume" , WM8993_OUTPUT_MIXER6, 9, 7, 1, outmix_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1204/1756 ASoC: codecs: wm8737: Fix definition of zero cross switches
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 121963197200ca89050f05a704f53c281702ec16 ]
The mic (xMZC) and PGA (xPZC) zero cross bits are bits 3 and 2 of each channel's Audio Path register. SOC_DOUBLE takes one register and two shifts, so both controls only write the left register. Use SOC_DOUBLE_R, as the Mic Boost Switch next to them does.
--- sound/soc/codecs/wm8737.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8737.c +4 -4
@@ -149,13 +149,13 @@ SOC_DOUBLE_R_TLV("Mic Boost Volume", WM8737_AUDIO_PATH_L, WM8737_AUDIO_PATH_R, 6, 3, 0, micboost_tlv),SOC_DOUBLE_R ("Mic Boost Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R ,4 ,1 ,0 ), -SOC_DOUBLE ("Mic ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , -3 ,1 ,0 ), +SOC_DOUBLE_R ("Mic ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , +3 ,1 ,0 ),SOC_DOUBLE_R_TLV ("Capture Volume" ,WM8737_LEFT_PGA_VOLUME ,WM8737_RIGHT_PGA_VOLUME ,0 ,255 ,0 , pga_tlv), -SOC_DOUBLE ("Capture ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , -2 ,1 ,0 ), +SOC_DOUBLE_R ("Capture ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , +2 ,1 ,0 ), SOC_DOUBLE("INPUT1 DC Bias Switch", WM8737_MISC_BIAS_CONTROL, 0, 1, 1, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1205/1756 ASoC: codecs: wm5100: Fix definition of EQ3 Band 1 Volume control
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 96d30816a9a4fa6b3cc470f82d0f53e8a6425ab9 ]
The EQ3 band 1 gain is in WM5100_EQ3_1, not in WM5100_EQ1_1, which holds the EQ1 band 1 gain.
--- sound/soc/codecs/wm5100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm5100.c +1 -1
@@ -658,7 +658,7 @@ SOC_SINGLE_TLV("EQ2 Band 4 Volume", WM5100_EQ2_2, WM5100_EQ2_B4_GAIN_SHIFT,SOC_SINGLE_TLV ("EQ2 Band 5 Volume" ,WM5100_EQ2_2 ,WM5100_EQ2_B5_GAIN_SHIFT ,24 ,0 , eq_tlv), -SOC_SINGLE_TLV ("EQ3 Band 1 Volume" ,WM5100_EQ1_1 ,WM5100_EQ3_B1_GAIN_SHIFT , +SOC_SINGLE_TLV ("EQ3 Band 1 Volume" ,WM5100_EQ3_1 ,WM5100_EQ3_B1_GAIN_SHIFT ,24 ,0 , eq_tlv),SOC_SINGLE_TLV ("EQ3 Band 2 Volume" ,WM5100_EQ3_1 ,WM5100_EQ3_B2_GAIN_SHIFT , 24, 0, eq_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1206/1756 ASoC: codecs: wm8750: Fix definition of ALC Capture NG Type control
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 8c299077c787c151c5c88928467d8e8d85cebdb7 ]
The noise gate type is wm8750_enum[7], bit 1 of WM8750_NGATE, not wm8750_enum[4], which is the 3D upper cut-off.
--- sound/soc/codecs/wm8750.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8750.c +1 -1
@@ -171,7 +171,7 @@ SOC_SINGLE("ALC Capture Hold Time", WM8750_ALC2, 0, 15, 0),SOC_SINGLE ("ALC Capture Decay Time" ,WM8750_ALC3 ,4 ,15 ,0 ),SOC_SINGLE ("ALC Capture Attack Time" ,WM8750_ALC3 ,0 ,15 ,0 ),SOC_SINGLE ("ALC Capture NG Threshold" ,WM8750_NGATE ,3 ,31 ,0 ), -SOC_ENUM ("ALC Capture NG Type" , wm8750_enum[4 ]), +SOC_ENUM ("ALC Capture NG Type" , wm8750_enum[7 ]),SOC_SINGLE ("ALC Capture NG Switch" ,WM8750_NGATE ,0 ,1 ,0 ), SOC_SINGLE("Left ADC Capture Volume", WM8750_LADC, 0, 255, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1207/1756 ASoC: codecs: wm8510: Fix definition of ADC Inversion Switch control
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 22d50113078dfbeff0d005d64fd9cc680249831c ]
ADC polarity is bit 0 of WM8510_ADC, not bit 0 of WM8510_COMP, which is the loopback enable. wm8974, which has the same register layout, already uses WM8974_ADC for this control.
--- sound/soc/codecs/wm8510.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8510.c +1 -1
@@ -135,7 +135,7 @@ SOC_SINGLE("Master Playback Volume", WM8510_DACVOL, 0, 127, 0),SOC_SINGLE ("High Pass Filter Switch" ,WM8510_ADC ,8 ,1 ,0 ),SOC_SINGLE ("High Pass Cut Off" ,WM8510_ADC ,4 ,7 ,0 ), -SOC_SINGLE ("ADC Inversion Switch" ,WM8510_COMP ,0 ,1 ,0 ), +SOC_SINGLE ("ADC Inversion Switch" ,WM8510_ADC ,0 ,1 ,0 ), SOC_SINGLE("Capture Volume", WM8510_ADCVOL, 0, 127, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1208/1756 rpmsg: mtk: release channel OF node on device teardown
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avi Weiss <[email protected]>
[ Upstream commit 00e100cfbf7bc159e462df16832cddeaf2cab770 ]
mtk_rpmsg_match_device_subnode() returns a referenced OF child node, which is stored in rpdev->dev.of_node.
mtk_rpmsg_release_device() later frees the containing allocation without dropping that ref.
Release the OF node when the RPMsg device is destroyed.
--- drivers/rpmsg/mtk_rpmsg.c | 1 + 1 file changed, 1 insertion(+)
drivers/rpmsg/mtk_rpmsg.c +1 -0
@@ -168,6 +168,7 @@ static void mtk_rpmsg_release_device(struct device *dev)struct rpmsg_device *rpdev =to_rpmsg_device (dev);struct mtk_rpmsg_device *mdev =to_mtk_rpmsg_device (rpdev); +of_node_put (dev->of_node);kfree (mdev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1209/1756 rpmsg: virtio: Remove uncallable offchannel functions
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dr. David Alan Gilbert <[email protected]>
[ Upstream commit 68decaf24d4d24f4f8708a248e65e9d77ea19b85 ]
The virtio_rpmsg_send_offchannel() and virtio_rpmsg_trysend_offchannel() are wired up to the send_offchannel and trysend_offchannel members of rpmsg_endpoint_ops, the only dereference of those was by the unused, and now removed rpmsg_send_offchannel() and rpmsg_trysend_offchannel() functions.
Remove them.
Stable-dep-of: 7dd4cffdf4c2 ("rpmsg: virtio: fix error handling in TX buffer wait")
--- drivers/rpmsg/virtio_rpmsg_bus.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -23
@@ -141,13 +141,9 @@ static void virtio_rpmsg_destroy_ept(struct rpmsg_endpoint *ept);static int virtio_rpmsg_send (struct rpmsg_endpoint *ept,void *data,int len);static int virtio_rpmsg_sendto (struct rpmsg_endpoint *ept,void *data,int len,u32 dst); -static int virtio_rpmsg_send_offchannel (struct rpmsg_endpoint *ept,u32 src, -u32 dst,void *data,int len);static int virtio_rpmsg_trysend (struct rpmsg_endpoint *ept,void *data,int len);static int virtio_rpmsg_trysendto (struct rpmsg_endpoint *ept,void *data,int len,u32 dst); -static int virtio_rpmsg_trysend_offchannel (struct rpmsg_endpoint *ept,u32 src, -u32 dst,void *data,int len);static ssize_t virtio_rpmsg_get_mtu (struct rpmsg_endpoint *ept);static struct rpmsg_device *__rpmsg_create_channel (struct virtproc_info *vrp,struct rpmsg_channel_info *chinfo);
@@ -156,10 +152,8 @@ static const struct rpmsg_endpoint_ops virtio_endpoint_ops = { .destroy_ept = virtio_rpmsg_destroy_ept, .send = virtio_rpmsg_send, .sendto = virtio_rpmsg_sendto, - .send_offchannel = virtio_rpmsg_send_offchannel, .trysend = virtio_rpmsg_trysend, .trysendto = virtio_rpmsg_trysendto, - .trysend_offchannel = virtio_rpmsg_trysend_offchannel, .get_mtu = virtio_rpmsg_get_mtu, };
@@ -544,7 +538,7 @@ static void rpmsg_downref_sleepers(struct virtproc_info *vrp)* the function will immediately fail, and -ENOMEM will be returned. * * Normally drivers shouldn't use this function directly; instead, drivers -* should use the appropriate rpmsg_{try}send{to, _offchannel} API +* should use the appropriate rpmsg_{try}send{to} API * (see include/linux/rpmsg.h). * * Return: 0 on success and an appropriate error value on failure.
@@ -664,14 +658,6 @@ static int virtio_rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len,return rpmsg_send_offchannel_raw (rpdev, src, dst, data, len, true); } -static int virtio_rpmsg_send_offchannel (struct rpmsg_endpoint *ept,u32 src, -u32 dst,void *data,int len) -{ -struct rpmsg_device *rpdev = ept->rpdev; - -return rpmsg_send_offchannel_raw (rpdev, src, dst, data, len, true); -} -static int virtio_rpmsg_trysend (struct rpmsg_endpoint *ept,void *data,int len) {struct rpmsg_device *rpdev = ept->rpdev;
@@ -689,14 +675,6 @@ static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data,return rpmsg_send_offchannel_raw (rpdev, src, dst, data, len, false); } -static int virtio_rpmsg_trysend_offchannel (struct rpmsg_endpoint *ept,u32 src, -u32 dst,void *data,int len) -{ -struct rpmsg_device *rpdev = ept->rpdev; - -return rpmsg_send_offchannel_raw (rpdev, src, dst, data, len, false); -} -static ssize_t virtio_rpmsg_get_mtu (struct rpmsg_endpoint *ept) {struct rpmsg_device *rpdev = ept->rpdev;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1210/1756 rpmsg: virtio: EPOLLOUT support
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Oppenlander <[email protected]>
[ Upstream commit c38d8b66c82c585199e2ad67282295f21cfa489f ]
Previously, polling an rpmsg endpoint (e.g. /dev/ttyRPMSGx) would generate EPOLLIN events but no EPOLLOUT events.
Unfortunately, poll support means that we can no longer disable tx-complete interrupts as there is no way to know whether a poller is waiting in sendq, so we always need notifications.
Stable-dep-of: 7dd4cffdf4c2 ("rpmsg: virtio: fix error handling in TX buffer wait")
--- drivers/rpmsg/virtio_rpmsg_bus.c | 101 ++++++++++--------------------- 1 file changed, 32 insertions(+), 69 deletions(-)
drivers/rpmsg/virtio_rpmsg_bus.c +32 -69
@@ -41,13 +41,12 @@* @buf_size: size of one rx or tx buffer * @last_sbuf: index of last tx buffer used * @bufs_dma: dma base addr of the buffers -* @tx_lock: protects svq, sbufs and sleepers, to allow concurrent senders. +* @tx_lock: protects svq and sbufs, to allow concurrent senders. * sending a message might require waking up a dozing remote * processor, which involves sleeping, hence the mutex. * @endpoints: idr of local endpoints, allows fast retrieval * @endpoints_lock: lock of the endpoints set * @sendq: wait queue of sending contexts waiting for a tx buffers -* @sleepers: number of senders that are waiting for a tx buffer * * This structure stores the rpmsg state of a given virtio remote processor * device (there might be several virtio proc devices for each physical
@@ -65,7 +64,6 @@ struct virtproc_info {struct idr endpoints;struct mutex endpoints_lock;wait_queue_head_t sendq; -atomic_t sleepers; };/* The feature bitmap for virtio rpmsg */
@@ -144,6 +142,8 @@ static int virtio_rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len,static int virtio_rpmsg_trysend (struct rpmsg_endpoint *ept,void *data,int len);static int virtio_rpmsg_trysendto (struct rpmsg_endpoint *ept,void *data,int len,u32 dst); +static __poll_t virtio_rpmsg_poll (struct rpmsg_endpoint *ept,struct file *filp, +poll_table *wait);static ssize_t virtio_rpmsg_get_mtu (struct rpmsg_endpoint *ept);static struct rpmsg_device *__rpmsg_create_channel (struct virtproc_info *vrp,struct rpmsg_channel_info *chinfo);
@@ -154,6 +154,7 @@ static const struct rpmsg_endpoint_ops virtio_endpoint_ops = { .sendto = virtio_rpmsg_sendto, .trysend = virtio_rpmsg_trysend, .trysendto = virtio_rpmsg_trysendto, + .poll = virtio_rpmsg_poll, .get_mtu = virtio_rpmsg_get_mtu, };
@@ -435,7 +436,6 @@ static void *get_a_tx_buf(struct virtproc_info *vrp)unsigned int len;void *ret; -/* support multiple concurrent senders */ mutex_lock (&vrp->tx_lock);/*
@@ -453,62 +453,6 @@ static void *get_a_tx_buf(struct virtproc_info *vrp)return ret; } -/** -* rpmsg_upref_sleepers() - enable "tx-complete" interrupts, if needed -* @vrp: virtual remote processor state -* -* This function is called before a sender is blocked, waiting for -* a tx buffer to become available. -* -* If we already have blocking senders, this function merely increases -* the "sleepers" reference count, and exits. -* -* Otherwise, if this is the first sender to block, we also enable -* virtio's tx callbacks, so we'd be immediately notified when a tx -* buffer is consumed (we rely on virtio's tx callback in order -* to wake up sleeping senders as soon as a tx buffer is used by the -* remote processor). -*/ -static void rpmsg_upref_sleepers (struct virtproc_info *vrp) -{ -/* support multiple concurrent senders */ -mutex_lock (&vrp->tx_lock); - -/* are we the first sleeping context waiting for tx buffers ? */ -if (atomic_inc_return (&vrp->sleepers) ==1 ) -/* enable "tx-complete" interrupts before dozing off */ -virtqueue_enable_cb (vrp->svq); - -mutex_unlock (&vrp->tx_lock); -} - -/** -* rpmsg_downref_sleepers() - disable "tx-complete" interrupts, if needed -* @vrp: virtual remote processor state -* -* This function is called after a sender, that waited for a tx buffer -* to become available, is unblocked. -* -* If we still have blocking senders, this function merely decreases -* the "sleepers" reference count, and exits. -* -* Otherwise, if there are no more blocking senders, we also disable -* virtio's tx callbacks, to avoid the overhead incurred with handling -* those (now redundant) interrupts. -*/ -static void rpmsg_downref_sleepers (struct virtproc_info *vrp) -{ -/* support multiple concurrent senders */ -mutex_lock (&vrp->tx_lock); - -/* are we the last sleeping context waiting for tx buffers ? */ -if (atomic_dec_and_test (&vrp->sleepers)) -/* disable "tx-complete" interrupts */ -virtqueue_disable_cb (vrp->svq); - -mutex_unlock (&vrp->tx_lock); -} -/** * rpmsg_send_offchannel_raw() - send a message across to the remote processor * @rpdev: the rpmsg channel
@@ -581,9 +525,6 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev,/* no free buffer ? wait for one (but bail after 15 seconds) */ while (!msg) { -/* enable "tx-complete" interrupts, if not already enabled */ -rpmsg_upref_sleepers (vrp); -/* * sleep until a free buffer is available or 15 secs elapse. * the timeout period is not configurable because there's
@@ -594,9 +535,6 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev, (msg =get_a_tx_buf (vrp)), msecs_to_jiffies(15000)); -/* disable "tx-complete" interrupts if we're the last sleeper */ -rpmsg_downref_sleepers (vrp); -/* timeout ? */ if (!err) {dev_err (dev,"timeout waiting for a tx buffer\n" );
@@ -675,6 +613,34 @@ static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data,return rpmsg_send_offchannel_raw (rpdev, src, dst, data, len, false); } +static __poll_t virtio_rpmsg_poll (struct rpmsg_endpoint *ept,struct file *filp, +poll_table *wait) +{ +struct rpmsg_device *rpdev = ept->rpdev; +struct virtio_rpmsg_channel *vch =to_virtio_rpmsg_channel (rpdev); +struct virtproc_info *vrp = vch->vrp; +__poll_t mask =0 ; + +poll_wait (filp, &vrp->sendq, wait); + +/* support multiple concurrent senders */ +mutex_lock (&vrp->tx_lock); + +/* +* check for a free buffer, either: +* - we haven't used all of the available transmit buffers (half of the +* allocated buffers are used for transmit, hence num_bufs / 2), or, +* - we ask the virtqueue if there's a buffer available +*/ +if (vrp->last_sbuf < vrp->num_bufs /2 || + !virtqueue_enable_cb (vrp->svq)) + mask |=EPOLLOUT ; + +mutex_unlock (&vrp->tx_lock); + +return mask; +} +static ssize_t virtio_rpmsg_get_mtu (struct rpmsg_endpoint *ept) {struct rpmsg_device *rpdev = ept->rpdev;
@@ -921,9 +887,6 @@ static int rpmsg_probe(struct virtio_device *vdev)WARN_ON (err);/* sanity check; this can't really happen */ } -/* suppress "tx-complete" interrupts */ -virtqueue_disable_cb (vrp->svq); - vdev->priv = vrp; rpdev_ctrl =rpmsg_virtio_add_ctrl_dev (vdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1211/1756 rpmsg: virtio: fix error handling in TX buffer wait
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Atul Akella <[email protected]>
[ Upstream commit 7dd4cffdf4c2a496ccf783303a03d687a2127baf ]
The TX buffer wait loop in rpmsg_send_offchannel_raw() ignores the possibility of wait_event_interruptible_timeout() returning a negative value, which happens when the wait is interrupted by a signal. In that case the loop spins back around and re-arms the wait instead of propagating the signal, which can stall a task that is trying to be killed.
Separately, on a genuine timeout (return value 0) the function returns -ERESTARTSYS, which is reserved for signal-interrupted syscalls that the kernel may restart. A timeout is not a signal and should not be treated as restartable; return -ETIMEDOUT instead.
Handle both cases explicitly: return err directly when negative, and return -ETIMEDOUT on timeout.
--- drivers/rpmsg/virtio_rpmsg_bus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +4 -1
@@ -535,10 +535,13 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev, (msg =get_a_tx_buf (vrp)), msecs_to_jiffies(15000)); +if (err <0 ) +return err; +/* timeout ? */ if (!err) {dev_err (dev,"timeout waiting for a tx buffer\n" ); -return -ERESTARTSYS ; +return -ETIMEDOUT ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1212/1756 ARM: 9486/1: set !LPAE MAX_PHYSMEM_BITS to 32 and remove supersection mappings
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 787a3446cafee59e31deaec662d74f86bff38999 ]
An ARM randconfig with CONFIG_GET_FREE_REGION=y and CONFIG_WERROR=y fails to build:
include/linux/minmax.h:86:37: error: conversion from 'long long unsigned int' to 'resource_size_t' {aka 'unsigned int'} changes value from '68719476735' to '4294967295' [-Werror=overflow]
Commit 14b80582c43e ("resource: Introduce alloc_free_mem_region()") made kernel/resource.c clamp against
(1ULL << MAX_PHYSMEM_BITS) - 1. resource_size_t is 32-bit without LPAE, but ARM's default MAX_PHYSMEM_BITS is 36.
That default was added by commit db57f88e4ccb ("ARM: 8411/1: Add default SPARSEMEM settings") because several platforms needed at least 36 physical address bits. !LPAE could map addresses above 32 bits only through supersections.
CONFIG_IO_36, added by commit 23bdf86aa06e ("[ARM] 3377/2: add support for intel xsc3 core"), enabled these for XSC3 I/O. IXP23xx placed static I/O mappings above 4GiB until its removal in 2012, and IOP13xx ioremap()ed its PCIe windows there until its removal in 2019. The only remaining XSC3 platform, PXA3xx, has nothing above 4GiB.
Supersection address bits overlap the descriptor domain field, so IO_36 also renumbered the domains to make DOMAIN_IO zero. Remove IO_36, the alternate domain numbering, and ioremap()'s supersection path. Reject !LPAE ioremap ranges extending past 4GiB before phys_addr_t truncation, drop the now-unneeded high static-mapping exclusion, and reduce ioremap alignment from 16MiB to the 2MiB covered by a PMD's pair of sections.
The other supersection user, create_36bit_mapping(), was added by commit 0b7cd62ecdc1 ("[ARM] 3017/1: Add support for 36-bit addresses to create_mapping()") for IXP2350 and carried IXP23xx's high static mappings. Before this change, its only remaining call path was efi_create_mapping() -> create_mapping_late(), for an EFI runtime region above 4GiB.
No real-world user of this !LPAE path is known. AArch32 UEFI requires RAM described by its memory map to be identity-mapped during boot services, which a 32-bit virtual address space cannot provide above 4GiB. Systems needing wider physical addressing are expected to use LPAE.
Remove create_36bit_mapping() and the supersection definitions. If firmware nevertheless advertises such a region on !LPAE, efi_create_mapping() rejects it before __pfn_to_phys() truncates its address to a low alias. EFI runtime services remain disabled, but the kernel continues to boot. LPAE kernels are unaffected.
With no remaining !LPAE mappings above 4GiB, set MAX_PHYSMEM_BITS to 32 for !LPAE and retain 36 for LPAE, where phys_addr_t is 64-bit.
--- arch/arm/include/asm/domain.h | 17 ----- arch/arm/include/asm/memory.h | 4 +- arch/arm/include/asm/pgtable-2level-hwdef.h | 1 - arch/arm/include/asm/pgtable-2level.h | 7 -- arch/arm/include/asm/sparsemem.h | 4 ++ arch/arm/kernel/efi.c | 13 ++++ arch/arm/mm/Kconfig | 7 -- arch/arm/mm/ioremap.c | 53 ++------------ arch/arm/mm/mmu.c | 76 +-------------------- 9 files changed, 27 insertions(+), 155 deletions(-)
arch/arm/include/asm/domain.h +0 -17
@@ -18,27 +18,10 @@* DOMAIN_IO - domain 2 includes all IO only * DOMAIN_USER - domain 1 includes all user memory only * DOMAIN_KERNEL - domain 0 includes all kernel memory only -* -* The domain numbering depends on whether we support 36 physical -* address for I/O or not. Addresses above the 32 bit boundary can -* only be mapped using supersections and supersections can only -* be set for domain 0. We could just default to DOMAIN_IO as zero, -* but there may be systems with supersection support and no 36-bit -* addressing. In such cases, we want to map system memory with -* supersections to reduce TLB misses and footprint. -* -* 36-bit addressing and supersections are only available on -* CPUs based on ARMv6+ or the Intel XSC3 core. */ -#ifndef CONFIG_IO_36 #define DOMAIN_KERNEL 0#define DOMAIN_USER 1#define DOMAIN_IO 2 -#else -#define DOMAIN_KERNEL 2 -#define DOMAIN_USER 1 -#define DOMAIN_IO 0 -#endif #define DOMAIN_VECTORS 3/*
arch/arm/include/asm/memory.h +2 -2
@@ -89,9 +89,9 @@#if !defined(CONFIG_SMP ) && !defined(CONFIG_ARM_LPAE )/* -* Allow 16MB-aligned ioremap pages +* Allow 2MB-aligned ioremap pages */ -#define IOREMAP_MAX_ORDER 24 +#define IOREMAP_MAX_ORDER 21#endif #define VECTORS_BASE UL(0xffff0000)
arch/arm/include/asm/pgtable-2level-hwdef.h +0 -1
@@ -35,7 +35,6 @@#define PMD_SECT_APX (_AT(pmdval_t, 1) << 15)/* v6 */ #define PMD_SECT_S (_AT(pmdval_t, 1) << 16)/* v6 */ #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17)/* v6 */ -#define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18)/* v6 */ #define PMD_SECT_AF (_AT(pmdval_t, 0))#define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
arch/arm/include/asm/pgtable-2level.h +0 -7
@@ -96,13 +96,6 @@#define SECTION_SIZE (1UL << SECTION_SHIFT)#define SECTION_MASK (~(SECTION_SIZE-1)) -/* -* ARMv6 supersection address mask and size definitions. -*/ -#define SUPERSECTION_SHIFT 24 -#define SUPERSECTION_SIZE (1UL << SUPERSECTION_SHIFT) -#define SUPERSECTION_MASK (~(SUPERSECTION_SIZE-1)) -#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)/*
arch/arm/include/asm/sparsemem.h +4 -0
@@ -19,7 +19,11 @@* These can be overridden in your mach/memory.h. */ #if !defined(MAX_PHYSMEM_BITS ) || !defined(SECTION_SIZE_BITS ) +#ifdef CONFIG_ARM_LPAE #define MAX_PHYSMEM_BITS 36 +#else +#define MAX_PHYSMEM_BITS 32 +#endif #define SECTION_SIZE_BITS 28#endif
arch/arm/kernel/efi.c +13 -0
@@ -6,6 +6,7 @@#include <linux/efi.h> #include <linux/memblock.h> #include <linux/screen_info.h> +#include <linux/sizes.h> #include <asm/efi.h> #include <asm/mach/map.h>
@@ -54,6 +55,18 @@ int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md) .length = md->num_pages * EFI_PAGE_SIZE, }; +/* +* Non-LPAE page tables cannot map EFI runtime regions extending +* beyond the 32-bit physical address space. +*/ +if (!IS_ENABLED (CONFIG_ARM_LPAE ) && + (md->phys_addr >=SZ_4G || + md->num_pages > (SZ_4G - md->phys_addr) /EFI_PAGE_SIZE )) { +pr_warn ("EFI runtime region at 0x%llx exceeds 32-bit physical address space\n" , + md->phys_addr); +return -ERANGE ; + } +/* * Order is important here: memory regions may have all of the * bits below set (and usually do), so we check them in order of
arch/arm/mm/Kconfig +0 -7
@@ -328,7 +328,6 @@ config CPU_XSC3 select CPU_PABRT_LEGACY select CPU_THUMB_CAPABLE select CPU_TLB_V4WBI if MMU - select IO_36 # Marvell PJ1 (Mohawk) config CPU_MOHAWK
@@ -652,12 +651,6 @@ config CPU_V7M_NUM_IRQ If unsure, keep default value. -# -# CPU supports 36-bit I/O -# -config IO_36 - bool - comment "Processor Features" config ARM_LPAE
arch/arm/mm/ioremap.c +7 -46
89 lines not on this page · raw message
arch/arm/mm/mmu.c +1 -75
94 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1213/1756 ARM: 9492/1: alignment: fix LSR #32 and ASR #32 offset decoding
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 9f878a6c2207f0c12f34a715a6a05cfc95f47460 ]
The register-offset form of LDR/STR may apply a shift to Rm. Per DecodeImmShift() (ARM ARM DDI0406C section A8.4.3, "Pseudocode details of instruction-specified shifts and rotates"), an imm5 of 0 encodes a shift of 32 for LSR and ASR; only LSL treats 0 as "no shift", and ROR with 0 encodes RRX.
do_alignment() special-cases RRX but not LSR or ASR, and IS_SHIFT() does not filter these encodings out, so the block is entered with shiftval == 0 and the offset becomes Rm instead of 0 (LSR #32) or the replicated sign of Rm (ASR #32).
do_alignment_finish_ldst() applies the offset to the base-register writeback of the post-indexed form, so the emulated access itself uses the correct faulting address but Rn is left holding the wrong value.
Reproduced on ARM926EJ-S (versatile_defconfig, CONFIG_ALIGNMENT_TRAP=y, gcc 13.3.0) with a misaligned base and Rm = 0x1000:
ldr r0, [r1], r2, lsr #32 Rn advanced by 0x1000, must be unchanged ldr r0, [r1], r2, asr #32 Rn advanced by 0x1000, must be unchanged ldr r0, [r1], r2, asr #32 with Rm negative, Rn must decrease by 1
All three are correct with the patch applied, while a lsr #1 control case is emulated correctly both before and after.
--- arch/arm/mm/alignment.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/arm/mm/alignment.c +8 -2
@@ -915,11 +915,17 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)break ;case SHIFT_LSR : - offset.un >>= shiftval; +if (shiftval ==0 ) + offset.un =0 ; +else + offset.un >>= shiftval;break ;case SHIFT_ASR : - offset.sn >>= shiftval; +if (shiftval ==0 ) + offset.sn >>=31 ; +else + offset.sn >>= shiftval;break ;case SHIFT_RORRRX :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1214/1756 ARM: 9519/1: dma-mapping: Fix wrong free function in __iommu_alloc_simple() error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 74f79365839720bdb0c6bb4fe85c5b2a929ff5d1 ]
In __iommu_alloc_simple(), when IOMMU mapping creation fails, the error path unconditionally called __free_from_pool() regardless of the allocation path taken.
For the COHERENT case, memory is allocated via __alloc_simple_buffer(), which does not use the atomic pool. Calling __free_from_pool() on such memory silently returns without freeing, causing a page memory leak.
Fix this by matching the free function to the allocation path:
- COHERENT: use __dma_free_buffer(virt_to_page(addr), size)
- non-COHERENT: use __free_from_pool(addr, size)
--- arch/arm/mm/dma-mapping.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/mm/dma-mapping.c +4 -1
@@ -1058,7 +1058,10 @@ static void *__iommu_alloc_simple(struct device *dev, size_t size, gfp_t gfp,return addr; err_mapping: -__free_from_pool (addr, size); +if (coherent_flag ==COHERENT ) +__dma_free_buffer (virt_to_page (addr), size); +else +__free_from_pool (addr, size);return NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1215/1756 PCI: Fix out-of-bounds MMIO read in nvme_disable_and_flr()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamad Raizudeen <[email protected]>
[ Upstream commit 6aaa3f42e3410ea8e26c857477260159f724cb1d ]
In nvme_disable_and_flr(), the PCI bar is mapped using NVME_REG_CC + sizeof(cfg) which is (0x14 + 4 = 0x18 bytes)
However, the function later reads the controller status from NVME_REG_CSTS - offset 0x1C, which is outside the mapped 0x18 byte boundary. This violates the API contract.
Fix this by increasing the mapping size to include NVME_REG_CSTS. Also change sizeof(cfg) to sizeof(u32) to make the intent clearer.
--- drivers/pci/quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/quirks.c +1 -1
@@ -4107,7 +4107,7 @@ static int nvme_disable_and_flr(struct pci_dev *dev, bool probe)if (probe)return 0 ; - bar =pci_iomap (dev,0 ,NVME_REG_CC +sizeof (cfg)); + bar =pci_iomap (dev,0 ,NVME_REG_CSTS +sizeof (u32));if (!bar)return -ENOTTY ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1216/1756 Bluetooth: btmtksdio: Remove redundant firmware filename override
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit 8c947cd1c27d6493ed7e6630e168222454f53edb ]
btmtksdio_setup() derives the firmware filename with btmtk_fw_get_filename() and then overwrites it with an snprintf() that open-codes that helper's fallback format. Commit 7f935b21bee4 ("Bluetooth:
btmtk: apply the common btmtk_fw_get_filename") added the helper call without removing the snprintf() it was meant to replace.
None of the device ids the helper special-cases can appear here: 0x6639, 0x7925 and the flavored 0x7961 belong to parts with no SDIO interface, and btmtksdio_setup() passes a flavor of 0 accordingly. The helper always falls through to the snprintf()'s own format, so both produce the same string and removing it is a no-op.
Remove it anyway, since it silently defeats the helper for any device id the helper special-cases.
Stable-dep-of: a2bb734c3687 ("Bluetooth: btmtksdio: Pass the hardware device id to mt79xx_setup()")
--- drivers/bluetooth/btmtksdio.c | 3 --- 1 file changed, 3 deletions(-)
drivers/bluetooth/btmtksdio.c +0 -3
@@ -1155,9 +1155,6 @@ static int btmtksdio_setup(struct hci_dev *hdev)btmtk_fw_get_filename (fwname,sizeof (fwname), dev_id, fw_version,0 ); -snprintf (fwname,sizeof (fwname), -"mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin" , - dev_id &0xffff , (fw_version &0xff ) +1 ); err =mt79xx_setup (hdev, fwname);if (err <0 )return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1217/1756 Bluetooth: btmtksdio: Pass the hardware device id to mt79xx_setup()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit a2bb734c368766a2499ed00590ea838cac13c76e ]
mt79xx_setup() passes a hardcoded 0 to btmtk_setup_firmware_79xx(), discarding the device id that btmtksdio_setup() has just read from register 0x70010200. That argument only gates the section filtering for MT6639, which has no SDIO interface, so this is a no-op on supported hardware and carries no Fixes: tag.
Pass the value that has already been read, matching the USB path. Declare dev_id as u32 while at it, since that is what btmtksdio_mtk_reg_read() writes through the pointer.
--- drivers/bluetooth/btmtksdio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/bluetooth/btmtksdio.c +5 -5
@@ -892,14 +892,14 @@ static int mt76xx_setup(struct hci_dev *hdev, const char *fwname)return 0 ; } -static int mt79xx_setup (struct hci_dev *hdev,const char *fwname) +static int mt79xx_setup (struct hci_dev *hdev,const char *fwname,u32 dev_id) {struct btmtksdio_dev *bdev =hci_get_drvdata (hdev);struct btmtk_hci_wmt_params wmt_params;u8 param =0x1 ;int err; - err =btmtk_setup_firmware_79xx (hdev, fwname, mtk_hci_wmt_sync,0 ); + err =btmtk_setup_firmware_79xx (hdev, fwname, mtk_hci_wmt_sync, dev_id);if (err <0 ) {bt_dev_err (hdev,"Failed to setup 79xx firmware (%d)" , err);return err;
@@ -1112,8 +1112,8 @@ static int btmtksdio_setup(struct hci_dev *hdev)ktime_t calltime, delta, rettime;unsigned long long duration;char fwname[64 ]; -int err, dev_id; -u32 fw_version =0 , val; +int err; +u32 dev_id, fw_version =0 , val; calltime =ktime_get ();set_bit (BTMTKSDIO_HW_TX_READY , &bdev->tx_state);
@@ -1155,7 +1155,7 @@ static int btmtksdio_setup(struct hci_dev *hdev)btmtk_fw_get_filename (fwname,sizeof (fwname), dev_id, fw_version,0 ); - err =mt79xx_setup (hdev, fwname); + err =mt79xx_setup (hdev, fwname, dev_id);if (err <0 )return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1218/1756 Bluetooth: L2CAP: take chan->lock for l2cap_chan_add/ready/del
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 385c0829e09e7a6380ae67998ac6ef6f4dfd5303 ]
chan->lock must be held for __l2cap_chan_add as eg. calls to l2cap_chan_close assume chan->conn writes are guarded by it.
It must be held for l2cap_chan_del() due to l2cap_sock.c:l2cap_chan_conn, l2cap_monitor_timeout, etc.
Similarly it should be held for l2cap_ops::ready (assumed in 6lowpan.c). Also teardown usually has chan->lock held, it should always have it held to have the same locking context.
The lock is not correctly held by l2cap_core in several places.
Add the missing locks for l2cap_chan_del/add/ready(), except in l2cap_ecred_rsp_defer() which needs separate fix as it needs lock nesting.
--- include/net/bluetooth/l2cap.h | 3 ++- net/bluetooth/l2cap_core.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
include/net/bluetooth/l2cap.h +2 -1
@@ -973,7 +973,8 @@ int l2cap_chan_check_security(struct l2cap_chan *chan, bool initiator);void l2cap_chan_set_defaults (struct l2cap_chan *chan,struct l2cap_chan *pchan);int l2cap_ertm_init (struct l2cap_chan *chan);void l2cap_chan_add (struct l2cap_conn *conn,struct l2cap_chan *chan); -void __l2cap_chan_add (struct l2cap_conn *conn,struct l2cap_chan *chan); +void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) + __must_hold(&chan->lock);typedef void (*l2cap_chan_func_t )(struct l2cap_chan *chan,void *data);void l2cap_chan_list (struct l2cap_conn *conn,l2cap_chan_func_t func,void *data);
net/bluetooth/l2cap_core.c +15 -0
@@ -706,7 +706,9 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)void l2cap_chan_add (struct l2cap_conn *conn,struct l2cap_chan *chan) {mutex_lock (&conn->lock); +l2cap_chan_lock (chan);__l2cap_chan_add (conn, chan); +l2cap_chan_unlock (chan);mutex_unlock (&conn->lock); }
@@ -4103,6 +4105,8 @@ static struct l2cap_chan *l2cap_new_connection(struct l2cap_conn *conn,if (!chan)return NULL ; +l2cap_chan_lock (chan); +l2cap_chan_set_defaults (chan, pchan); chan->ops = pchan->ops;
@@ -4111,10 +4115,13 @@ static struct l2cap_chan *l2cap_new_connection(struct l2cap_conn *conn,if (pchan->ops->new_connection && pchan->ops->new_connection (pchan, chan) <0 ) {l2cap_chan_del (chan,0 ); +l2cap_chan_unlock (chan);l2cap_chan_put (chan);return NULL ; } +l2cap_chan_unlock (chan); +return chan; }
@@ -5112,6 +5119,8 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, goto response_unlock; } +l2cap_chan_lock (chan); +bacpy (&chan->src, &conn->hcon->src);bacpy (&chan->dst, &conn->hcon->dst); chan->src_type =bdaddr_src_type (conn->hcon);
@@ -5145,6 +5154,8 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, result =L2CAP_CR_LE_SUCCESS ; } +l2cap_chan_unlock (chan); + response_unlock:l2cap_chan_unlock (pchan);l2cap_chan_put (pchan);
@@ -5335,6 +5346,8 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,continue ; } +l2cap_chan_lock (chan); +bacpy (&chan->src, &conn->hcon->src);bacpy (&chan->dst, &conn->hcon->dst); chan->src_type =bdaddr_src_type (conn->hcon);
@@ -5367,6 +5380,8 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, }else {l2cap_chan_ready (chan); } + +l2cap_chan_unlock (chan); } unlock:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1219/1756 Bluetooth: L2CAP: hold l2cap_conn::lock in l2cap_connect_cfm()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 115e6a21c88a5f708b2b025f7567ab78a782a74f ]
l2cap_new_connection() -> __l2cap_chan_add() modifies l2cap_conn::chan_l, which is guarded by l2cap_conn::lock. The lock is not held in l2cap_connect_cfm().
Fix by holding conn->lock in l2cap_connect_cfm() to make the locking systematic.
--- net/bluetooth/l2cap_core.c | 4 ++++ 1 file changed, 4 insertions(+)
net/bluetooth/l2cap_core.c +4 -0
@@ -7648,6 +7648,8 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)* we left off, because the list lock would prevent calling the * potentially sleeping l2cap_chan_lock() function. */ +mutex_lock (&conn->lock); + pchan =l2cap_global_fixed_chan (NULL , hcon);while (pchan) {struct l2cap_chan *chan, *next;
@@ -7672,6 +7674,8 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status) pchan = next; } +mutex_unlock (&conn->lock); +l2cap_conn_ready (conn); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1220/1756 Bluetooth: L2CAP: hold chan in l2cap_ecred_conn_rsp()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit b508a2a2d846ccc4c8f691e4e3dfca6f97dfe85a ]
l2cap_chan_del() calls l2cap_chan_put() to drop the conn->chan_l reference. If this was the last reference, UAF follows.
l2cap_ecred_conn_rsp() iterates chan_l list and calls l2cap_chan_del() on some members, without holding chan reference.
Fix by holding refcount while using chan after l2cap_chan_del().
Since orig is looked up by dcid provided by remote, it's also possible orig == chan, so reference needs to be held also after orig use.
--- net/bluetooth/l2cap_core.c | 5 +++++ 1 file changed, 5 insertions(+)
net/bluetooth/l2cap_core.c +5 -0
@@ -5433,12 +5433,14 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, chan->state == BT_CONNECTED)continue ; +l2cap_chan_hold (chan);l2cap_chan_lock (chan);/* Check that there is a dcid for each pending channel */ if (cmd_len <sizeof (dcid)) {l2cap_chan_del (chan,ECONNREFUSED );l2cap_chan_unlock (chan); +l2cap_chan_put (chan);continue ; }
@@ -5477,6 +5479,8 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn,__set_chan_timer (orig,0 );l2cap_chan_unlock (orig); } + +l2cap_chan_put (chan);continue ; }
@@ -5522,6 +5526,7 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, }l2cap_chan_unlock (chan); +l2cap_chan_put (chan); }return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1221/1756 Bluetooth: btmtk: Validate the firmware layout before parsing it
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit 760ac9d02dce001f2e20c17deb18e7bb63d8355e ]
btmtk_setup_firmware_79xx() reads the section count out of the firmware's global descriptor, then walks a 64-byte section map per section and hands each section's file-supplied offset and length to the WMT download path. None of that is checked against fw->size, so a truncated or corrupted file makes the driver read past the end of request_firmware()'s buffer. On 32-bit the section count can also wrap the section map size calculation.
Add btmtk_fw_validate_layout() to check that the header, global descriptor and section map array all fit, and btmtk_fw_validate_section() to check one section's offset and length, both written so the size arithmetic cannot wrap. A section count of zero is rejected as well: it passes every size check but leaves the download loop with nothing to do, so the function would report success on hardware it never programmed. They are helpers rather than open-coded because the MT7928 CBMCU download path added later needs the same arithmetic.
This is hardening against a corrupted /lib/firmware rather than a bug an unprivileged user can trigger, hence bluetooth-next and no Fixes: tag. Well-formed firmware files are unaffected.
--- drivers/bluetooth/btmtk.c | 74 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-)
drivers/bluetooth/btmtk.c +71 -3
@@ -6,6 +6,7 @@#include <linux/firmware.h> #include <linux/usb.h> #include <linux/iopoll.h> +#include <linux/overflow.h> #include <linux/unaligned.h> #include <net/bluetooth/bluetooth.h>
@@ -59,6 +60,67 @@ struct btmtk_section_map { }; } __packed; +/* Reject a firmware image whose header, global descriptor or section map +* array does not fit in the file, and hand back the validated section +* count, so that the section map walks stay inside the firmware buffer. +*/ +static int btmtk_fw_validate_layout (struct hci_dev *hdev, +const struct firmware *fw, +u32 *section_num) +{ +const struct btmtk_global_desc *globaldesc; +size_t need; + +if (fw->size <MTK_FW_ROM_PATCH_HEADER_SIZE +MTK_FW_ROM_PATCH_GD_SIZE ) { +bt_dev_err (hdev,"Firmware too small: %zu bytes, need at least %u" , + fw->size, +MTK_FW_ROM_PATCH_HEADER_SIZE +MTK_FW_ROM_PATCH_GD_SIZE ); +return -EINVAL ; + } + + globaldesc = (const struct btmtk_global_desc *)(fw->data + +MTK_FW_ROM_PATCH_HEADER_SIZE ); + *section_num =le32_to_cpu (globaldesc->section_num); + +if (!*section_num) { +bt_dev_err (hdev,"Firmware declares no sections" ); +return -EINVAL ; + } + +if (check_mul_overflow ((size_t )MTK_FW_ROM_PATCH_SEC_MAP_SIZE , + (size_t )*section_num, &need) || +check_add_overflow (need, + (size_t )(MTK_FW_ROM_PATCH_HEADER_SIZE + +MTK_FW_ROM_PATCH_GD_SIZE ), + &need)) { +bt_dev_err (hdev,"Firmware section count too large: %u" , + *section_num); +return -EINVAL ; + } + +if (fw->size < need) { +bt_dev_err (hdev,"Firmware truncated: %zu bytes, need %zu for %u sections" , + fw->size, need, *section_num); +return -EINVAL ; + } + +return 0 ; +} + +/* Reject a section whose payload does not lie within the firmware file. */ +static int btmtk_fw_validate_section (struct hci_dev *hdev, +const struct firmware *fw,int index, +u32 offset,u32 size) +{ +if (offset > fw->size || size > fw->size - offset) { +bt_dev_err (hdev,"Firmware section %d out of bounds: offset=%u, size=%u, fw_size=%zu" , + index, offset, size, fw->size); +return -EINVAL ; + } + +return 0 ; +} +static void btmtk_coredump (struct hci_dev *hdev) {int err;
@@ -137,7 +199,6 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname, {struct btmtk_hci_wmt_params wmt_params;struct btmtk_patch_header *hdr; -struct btmtk_global_desc *globaldesc =NULL ;struct btmtk_section_map *sectionmap;const struct firmware *fw;const u8 *fw_ptr;
@@ -153,11 +214,13 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,return err; } + err =btmtk_fw_validate_layout (hdev, fw, §ion_num); +if (err <0 ) + goto err_release_fw; + fw_ptr = fw->data; fw_bin_ptr = fw_ptr; hdr = (struct btmtk_patch_header *)fw_ptr; - globaldesc = (struct btmtk_global_desc *)(fw_ptr +MTK_FW_ROM_PATCH_HEADER_SIZE ); - section_num =le32_to_cpu (globaldesc->section_num);bt_dev_info (hdev,"HW/SW Version: 0x%04x%04x, Build Time: %s" ,le16_to_cpu (hdr->hwver),le16_to_cpu (hdr->swver), hdr->datetime);
@@ -180,6 +243,11 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,continue ;if (dl_size >0 ) { + err =btmtk_fw_validate_section (hdev, fw, i, + section_offset, dl_size); +if (err <0 ) + goto err_release_fw; + retry =20 ;while (retry >0 ) { cmd[0 ] =0 ;/* 0 means legacy dl mode. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1222/1756 Bluetooth: btmtk: Improve BT firmware logging
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit 046fa20e9c7abbafb166b431fe446c49b71cb15a ]
The firmware log line in btmtk_setup_firmware_79xx() never says which file was requested, which matters because btmtk_fw_get_filename() derives the name from the device id and firmware version at runtime. It reports the firmware's own hwver field as the HW version, when the device id the driver read from the chip is the more useful value and is already available as dev_id. And it prints datetime, a u8[16] with no guaranteed NUL terminator, with %s.
Log the filename before the image is parsed, so a file that fails validation still says which file it was, report dev_id as the HW version, and bound datetime with %.16s.
The datetime change is hardening rather than a fix, hence no Fixes: tag:
every file in linux-firmware terminates the field, and provoking the over-read needs a malformed file in /lib/firmware.
Log output on MT7922 after the change:
[ 365.245951] Bluetooth: hci0: Loading BT firmware: mediatek/BT_RAM_CODE_MT7922_1_1_hdr.bin [ 365.245956] Bluetooth: hci0: BT HW ver: 0x7922, SW ver: 0x008a, Build Time: 20260605203811
--- drivers/bluetooth/btmtk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/bluetooth/btmtk.c +4 -2
@@ -214,6 +214,8 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,return err; } +bt_dev_info (hdev,"Loading BT firmware: %s" , fwname); + err =btmtk_fw_validate_layout (hdev, fw, §ion_num);if (err <0 ) goto err_release_fw;
@@ -222,8 +224,8 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname, fw_bin_ptr = fw_ptr; hdr = (struct btmtk_patch_header *)fw_ptr; -bt_dev_info (hdev,"HW/SW Version: 0x%04x%04x, Build Time: %s" , -le16_to_cpu (hdr->hwver),le16_to_cpu (hdr->swver), hdr->datetime); +bt_dev_info (hdev,"BT HW ver: 0x%04x, SW ver: 0x%04x, Build Time: %.16s" , + dev_id &0xffff ,le16_to_cpu (hdr->swver), hdr->datetime);for (i =0 ; i < section_num; i++) { first_block =1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1223/1756 Bluetooth: btusb: Make btusb_recv_{event,acl}() take struct hci_dev *
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit d6d15018c8e1527841e39a6a80c60997e594ca70 ]
Both helpers currently take struct btusb_data *, which is private to btusb.c, as parameter type as below:
int btusb_recv_event(struct btusb_data *data, struct sk_buff *skb) int btusb_recv_acl(struct btusb_data *data, struct sk_buff *skb)
To allow vendor USB-transport-specific source files to share them as well, change the type to struct hci_dev *.
Stable-dep-of: fa96916cfd05 ("Bluetooth: btusb: Preserve event and ACL packet ordering")
--- drivers/bluetooth/btusb.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/bluetooth/btusb.c +10 -6
@@ -1207,14 +1207,16 @@ static inline void btusb_free_frags(struct btusb_data *data)spin_unlock_irqrestore (&data->rxlock, flags); } -static int btusb_recv_event (struct btusb_data *data,struct sk_buff *skb) +static int btusb_recv_event (struct hci_dev *hdev,struct sk_buff *skb) { +struct btusb_data *data =hci_get_drvdata (hdev); +if (data->intr_interval) {/* Trigger dequeue immediatelly if an event is received */ schedule_delayed_work (&data->rx_work,0 ); } -return data->recv_event (data->hdev, skb); +return data->recv_event (hdev, skb); }static int btusb_recv_intr (struct btusb_data *data,void *buffer,int count)
@@ -1274,7 +1276,7 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count) }/* Complete frame */ -btusb_recv_event (data, skb); +btusb_recv_event (data->hdev, skb); skb =NULL ; } }
@@ -1285,13 +1287,15 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)return err; } -static int btusb_recv_acl (struct btusb_data *data,struct sk_buff *skb) +static int btusb_recv_acl (struct hci_dev *hdev,struct sk_buff *skb) { +struct btusb_data *data =hci_get_drvdata (hdev); +/* Only queue ACL packet if intr_interval is set as it means * force_poll_sync has been enabled. */ if (!data->intr_interval) -return data->recv_acl (data->hdev, skb); +return data->recv_acl (hdev, skb);skb_queue_tail (&data->acl_q, skb);schedule_delayed_work (&data->rx_work, data->intr_interval);
@@ -1346,7 +1350,7 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count)if (!hci_skb_expect (skb)) {/* Complete frame */ -btusb_recv_acl (data, skb); +btusb_recv_acl (data->hdev, skb); skb =NULL ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1224/1756 Bluetooth: btusb: Preserve event and ACL packet ordering
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kiran K <[email protected]>
[ Upstream commit fa96916cfd05ceb1c26af0b2ea73daf5481cad2d ]
When force_poll_sync is enabled, commit 800fe5ec302e ("Bluetooth:
btusb: Add support for queuing during polling interval") defers ACL delivery to the RX worker. The event path currently wakes that worker before delivering the event, so queued ACL data can reach HCI first.
Deliver the event before waking the worker. This preserves the intended event-first ordering and the event callback's return value.
--- drivers/bluetooth/btusb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/bluetooth/btusb.c +4 -1
@@ -1210,13 +1210,16 @@ static inline void btusb_free_frags(struct btusb_data *data)static int btusb_recv_event (struct hci_dev *hdev,struct sk_buff *skb) {struct btusb_data *data =hci_get_drvdata (hdev); +int err; + + err = data->recv_event (hdev, skb);if (data->intr_interval) {/* Trigger dequeue immediatelly if an event is received */ schedule_delayed_work (&data->rx_work,0 ); } -return data->recv_event (hdev, skb); +return err; }static int btusb_recv_intr (struct btusb_data *data,void *buffer,int count)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1225/1756 Bluetooth: MGMT: Fix advertising instances with Global Advertising
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 0ad48c88a2ed3b58164fa771977868503b0abac3 ]
Global Advertising, enabled with MGMT_OP_SET_ADVERTISING, uses instance 0 and with extended advertising it has its own advertising set, but instances were still being treated as if they shared the same set:
- Add Advertising and Add Extended Advertising Data would return success without ever enabling the instance.
- Removing the last instance would disable all advertising sets, stopping Global Advertising while leaving its setting enabled.
- Disabling Global Advertising would disable all sets, including active instances.
Fix this by only overriding instances that share the advertising set of Global Advertising, and by tracking HCI_LE_ADV_0 rather than HCI_LE_ADV to determine the state of Global Advertising.
--- include/net/bluetooth/hci_sync.h | 1 + net/bluetooth/hci_event.c | 11 ++++- net/bluetooth/hci_sync.c | 2 +- net/bluetooth/mgmt.c | 83 +++++++++++++++++++++++++++----- 4 files changed, 83 insertions(+), 14 deletions(-)
include/net/bluetooth/hci_sync.h +1 -0
@@ -124,6 +124,7 @@ int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance);int hci_remove_advertising_sync (struct hci_dev *hdev,struct sock *sk,u8 instance,bool force);int hci_disable_advertising_sync (struct hci_dev *hdev); +int hci_disable_ext_adv_legacy_instance_sync (struct hci_dev *hdev);int hci_clear_adv_instance_sync (struct hci_dev *hdev,struct sock *sk,u8 instance,bool force);int hci_update_passive_scan_sync (struct hci_dev *hdev);
net/bluetooth/hci_event.c +9 -2
@@ -1620,15 +1620,22 @@ static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data,hci_dev_clear_flag (hdev,HCI_LE_ADV_0 );/* If just one instance was disabled check if there are -* any other instance enabled before clearing HCI_LE_ADV +* any other instance enabled, including instance 0, +* before clearing HCI_LE_ADV */ +if (hci_dev_test_flag (hdev,HCI_LE_ADV_0 )) + goto unlock; +list_for_each_entry_safe (adv, n, &hdev->adv_instances, list) {if (adv->enabled) goto unlock; } }else { -/* All instances shall be considered disabled */ +/* All instances shall be considered disabled, except +* instance 0 whose state is preserved so it can be +* re-enabled by hci_resume_advertising_sync. +*/ list_for_each_entry_safe (adv, n, &hdev->adv_instances, list) adv->enabled = false;
net/bluetooth/hci_sync.c +1 -1
@@ -1184,7 +1184,7 @@ int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy,return 0 ; } -static int hci_disable_ext_adv_legacy_instance_sync (struct hci_dev *hdev) +int hci_disable_ext_adv_legacy_instance_sync (struct hci_dev *hdev) {struct hci_cp_le_set_ext_adv_enable *cp;struct hci_cp_ext_adv_set *set;
net/bluetooth/mgmt.c +72 -11
135 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1226/1756 Bluetooth: HCI: Fix tracking of instances sharing handle 0x00
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 1bfecdbd031711e5205ae78f3b8c296e5a53bc55 ]
When the controller supports a single advertising set, instance 1 uses handle 0x00 which is the same handle used by instance 0 (Global Advertising), but hci_cc_le_set_ext_adv_enable would lookup the instance using the handle as instance identifier, marking instance 0 as enabled/disabled instead of instance 1, leaving its state out of sync.
Fix this by matching instances by handle and, for handle 0x00, using hdev->cur_adv_instance, now set when enabling an instance, to determine which instance owns the set. Also disable the instance sharing the advertising set of instance 0 before overriding it.
--- net/bluetooth/hci_event.c | 47 ++++++++++++++++++++++++++++++--------- net/bluetooth/hci_sync.c | 35 ++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 12 deletions(-)
net/bluetooth/hci_event.c +36 -11
@@ -1573,6 +1573,39 @@ static u8 hci_cc_le_set_adv_enable(struct hci_dev *hdev, void *data,return rp->status; } +/* Update the enabled state of the instance(s) using the advertising set +* identified by handle. +* +* Instances may share handle 0x00 with instance 0 (Global Advertising), e.g. +* when the controller supports a single advertising set, in which case the +* set is owned by the instance last enabled (hdev->cur_adv_instance) and any +* other instance sharing it shall be considered disabled. +*/ +static void hci_le_ext_adv_set_enabled (struct hci_dev *hdev,u8 handle, +bool enable) +{ +struct adv_info *adv; +bool owned = false; + +list_for_each_entry (adv, &hdev->adv_instances, list) { +if (adv->handle != handle) +continue ; + + adv->enabled = enable && + (handle || + adv->instance == hdev->cur_adv_instance); + owned |= adv->enabled; + } + +if (handle) +return ; + +if (enable && !owned) +hci_dev_set_flag (hdev,HCI_LE_ADV_0 ); +else +hci_dev_clear_flag (hdev,HCI_LE_ADV_0 ); +} +static u8 hci_cc_le_set_ext_adv_enable (struct hci_dev *hdev,void *data,struct sk_buff *skb) {
@@ -1594,18 +1627,13 @@ static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data,hci_dev_lock (hdev); -if (cp->num_of_sets) - adv =hci_find_adv_instance (hdev, set->handle); -if (cp->enable) {struct hci_conn *conn;hci_dev_set_flag (hdev,HCI_LE_ADV ); -if (adv) - adv->enabled = true; -else if (!set->handle) -hci_dev_set_flag (hdev,HCI_LE_ADV_0 ); +if (cp->num_of_sets) +hci_le_ext_adv_set_enabled (hdev, set->handle, true); conn =hci_lookup_le_connect (hdev);if (conn)
@@ -1614,10 +1642,7 @@ static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data, conn->conn_timeout); }else {if (cp->num_of_sets) { -if (adv) - adv->enabled = false; -else if (!set->handle) -hci_dev_clear_flag (hdev,HCI_LE_ADV_0 ); +hci_le_ext_adv_set_enabled (hdev, set->handle, false);/* If just one instance was disabled check if there are * any other instance enabled, including instance 0,
net/bluetooth/hci_sync.c +34 -1
@@ -1184,6 +1184,30 @@ int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy,return 0 ; } +/* Check if the advertising set with handle 0x00 is in use, either by instance +* 0 or by an instance sharing its advertising set. +*/ +static bool hci_ext_adv_handle_0_enabled (struct hci_dev *hdev) +{ +struct adv_info *adv; +bool enabled; + +hci_dev_lock (hdev); + + enabled =hci_dev_test_flag (hdev,HCI_LE_ADV_0 ); + +list_for_each_entry (adv, &hdev->adv_instances, list) { +if (!adv->handle && adv->enabled) { + enabled = true; +break ; + } + } + +hci_dev_unlock (hdev); + +return enabled; +} +int hci_disable_ext_adv_legacy_instance_sync (struct hci_dev *hdev) {struct hci_cp_le_set_ext_adv_enable *cp;
@@ -1191,7 +1215,7 @@ int hci_disable_ext_adv_legacy_instance_sync(struct hci_dev *hdev)u8 data[sizeof (*cp) +sizeof (*set) *1 ];u8 size; -if (!hci_dev_test_flag (hdev,HCI_LE_ADV_0 )) +if (!hci_ext_adv_handle_0_enabled (hdev))return 0 ;memset (data,0 ,sizeof (data));
@@ -1435,6 +1459,9 @@ int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance)return -EINVAL ; } }else { +/* Disable the advertising set with handle 0x00, including any +* instance sharing it, since it is going to be overridden. +*/ err =hci_disable_ext_adv_legacy_instance_sync (hdev);if (err)return err;
@@ -1700,6 +1727,12 @@ int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance) set->duration =cpu_to_le16 (duration /10 ); } +/* Track which instance owns the advertising set since the handle +* alone is ambiguous when instances share handle 0x00, see +* hci_cc_le_set_ext_adv_enable. +*/ + hdev->cur_adv_instance = instance; + return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_EXT_ADV_ENABLE, sizeof(*cp) + sizeof(*set) * cp->num_of_sets,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1227/1756 Bluetooth: MGMT: Fix pending state of instances added without HCI traffic
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 5548fb51aa3cc24545029a286882d261a8e77d8a ]
When Add Advertising completes without HCI communication, e.g. when the device is not powered or the instance is overridden by Global Advertising, the instance is left marked as pending, so a subsequent failure in add_adv_complete would remove it despite it having been successfully added.
Fix this by clearing the pending state before completing the command.
--- net/bluetooth/mgmt.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/bluetooth/mgmt.c +6 -0
@@ -9117,6 +9117,12 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,if (!hdev_is_powered (hdev) ||adv_overridden_by_global (hdev, adv) || !schedule_instance) { +/* Instance has been accepted so it shall no longer be +* considered pending, otherwise a later failure in +* add_adv_complete would remove it. +*/ + adv->pending = false; + rp.instance = cp->instance; err =mgmt_cmd_complete (sk, hdev->id,MGMT_OP_ADD_ADVERTISING ,MGMT_STATUS_SUCCESS , &rp,sizeof (rp));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1228/1756 Bluetooth: MGMT: Fix leaking instance on Add Extended Advertising Parameters
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit f7f0d0a9eb6e4616c0b3a2a95498b5204c5543c9 ]
If queueing the command fails the instance is never removed, despite it having already been added or modified by hci_add_adv_instance, so remove it as it is done by add_ext_adv_params_complete on failure, signaling it has been removed if it was previously added.
--- net/bluetooth/mgmt.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
net/bluetooth/mgmt.c +16 -3
@@ -9305,14 +9305,15 @@ static int add_ext_adv_params(struct sock *sk, struct hci_dev *hdev, data, data_len);if (!cmd) { err = -ENOMEM ; -hci_remove_adv_instance (hdev, cp->instance); - goto unlock; + goto remove; } err =hci_cmd_sync_queue (hdev, add_ext_adv_params_sync, cmd, add_ext_adv_params_complete); -if (err <0 ) +if (err <0 ) {mgmt_pending_free (cmd); + goto remove; + } }else { rp.instance = cp->instance; rp.tx_power =HCI_ADV_TX_POWER_NO_PREFERENCE ;
@@ -9323,6 +9324,18 @@ static int add_ext_adv_params(struct sock *sk, struct hci_dev *hdev, MGMT_STATUS_SUCCESS, &rp, sizeof(rp)); } + goto unlock; + +remove: +/* The instance may have been modified already so remove it, like it +* is done in add_ext_adv_params_complete, signaling it has been +* removed if it was previously added. +*/ +if (!adv->pending) +mgmt_advertising_removed (sk, hdev, cp->instance); + +hci_remove_adv_instance (hdev, cp->instance); + unlock:hci_dev_unlock (hdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1229/1756 Bluetooth: 6LoWPAN: Use RCU-safe device list removal
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 8c27d7d06e21ba9455ddae4e14f364c57f095cba ]
RCU readers of bt_6lowpan_devices must be able to follow an adapter's forward link until their read-side critical section ends. The entries are published with list_add_rcu(), but device_event() removes an entry on NETDEV_UNREGISTER with list_del(), poisoning that link.
When an adapter is being unregistered and 6LoWPAN is enabled, a 6lowpan_control debugfs write with an existing LE L2CAP connection can enter lookup_peer() after unregister's first synchronize_net(). If the connection has no peer on that adapter, the reader must advance to the next list entry. Neither RTNL nor devices_lock excludes this RCU reader.
The last peer's chan_close_cb() schedules delete_netdev(), which reaches unregister_netdevice_many_notify() through unregister_dev() and lowpan_unregister_netdev(). The following ordering is possible:
Unregister worker Control writer
----------------- --------------
synchronize_net() returns
lowpan_control_write() lookup_peer(): rcu_read_lock() reach adapter; no matching peer
device_event(): devices_lock
list_del(&entry->list)
spin_unlock(&devices_lock)
follow poisoned next link read invalid adapter address
post-notifier synchronize_net()
waits for the reader
This invalid pointer access can fault in lookup_peer(). The first grace period drains existing readers but permits new ones to start, and the later grace period cannot prevent the intervening poisoned-link access.
Use list_del_rcu() under the existing devices_lock to preserve the forward link for readers that already reached the adapter. The existing post-notifier synchronize_net() waits for those readers before netdevice teardown frees the private storage containing lowpan_btle_dev.
KASAN report as below:
[...]
[ 45.867526] Oops: general protection fault, probably for non-canonical address 0xfbd59c0000000023: 0000 [#1] SMP KASAN NOPTI
[ 45.869489] KASAN: maybe wild-memory-access in range [0xdead000000000118-0xdead00000000011f]
[ 45.870981] CPU: 1 UID: 0 PID: 646 Comm: sh Not tainted 7.2.0-rc6-pmb-bt-functional-v1+ #4 PREEMPT(lazy)
[ 45.872609] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 45.874380] RIP: 0010:lookup_peer+0x1ba/0x320
[ 45.875067] Code: 48 89 d9 ba 04 00 00 00 4c 89 fe bf a0 06 00 00 e8 2b e8 ad fb e9 56 ff ff ff e8 01 1e c3 fb 49 8d 7f 18 48 89 f8 48 c1 e8 03 <80> 3c 28 00 0f 85 4a 01 00 00 4d 8b 47 18 4c 89 f1 ba 04 00 00 00
[ 45.878206] RSP: 0018:ffff888114d67b90 EFLAGS: 00010212
[ 45.879106] RAX: 1bd5a00000000023 RBX: 0000000000000000 RCX: ffffffff85c1d19f
[ 45.880334] RDX: ffff88810dc35700 RSI: 0000000000000000 RDI: dead000000000118
[ 45.881455] RBP: dffffc0000000000 R08: 0000000000000001 R09: 0000000000000001
[ 45.882546] R10: ffffffff893d3057 R11: ffff88810dc35700 R12: ffff88810a690000
[ 45.883839] R13: ffff888115451038 R14: ffff88810a690000 R15: dead000000000100
[ 45.885186] FS: 00007fa889bac780(0000) GS:ffff8881fd852000(0000) knlGS:0000000000000000
[ 45.886539] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 45.887527] CR2: 00007ffe304f2f80 CR3: 0000000104f64005 CR4: 0000000000770ef0
[ 45.888687] PKRU: 55555554
[ 45.889183] Call Trace:
[ 45.889666] <TASK>
[ 45.890061] lowpan_control_write+0x445/0x9e0
[ 45.890854] ? __pfx_lowpan_control_write+0x10/0x10
[ 45.891738] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.892603] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.893383] ? __debugfs_file_get+0x1bd/0x7f0
[ 45.894057] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.894902] ? lock_acquire+0x17b/0x2f0
[ 45.895593] ? ksys_write+0x111/0x200
[ 45.896290] full_proxy_write+0x11f/0x180
[ 45.896991] vfs_write+0x25a/0x1010
[ 45.897642] ? __pfx_full_proxy_write+0x10/0x10
[ 45.898440] ? __pfx_vfs_write+0x10/0x10
[ 45.899178] ? lock_release+0x11f/0x280
[ 45.899855] ksys_write+0x111/0x200
[ 45.900435] ? __pfx_ksys_write+0x10/0x10
[ 45.901074] ? irqentry_exit+0xbe/0x820
[ 45.901722] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.902489] do_syscall_64+0x115/0x6a0
[ 45.903064] entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ 45.903813] RIP: 0033:0x7fa889c3e687
[ 45.904359] Code: 48 89 fa 4c 89 df e8 58 b3 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
[ 45.906981] RSP: 002b:00007ffd7651b960 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
[ 45.908070] RAX: ffffffffffffffda RBX: 00007fa889bac780 RCX: 00007fa889c3e687
[ 45.909102] RDX: 000000000000001c RSI: 00005570f25e8d10 RDI: 0000000000000001
[ 45.910133] RBP: 00005570f25e8d10 R08: 0000000000000000 R09: 0000000000000000
[ 45.911162] R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000001
[ 45.912190] R13: 000000000000001c R14: 0000000000000000 R15: 00005570f25e8a78
[ 45.913208] </TASK>
[ 45.913530] Modules linked in:
[ 45.914022] ---[ end trace 0000000000000000 ]---
[ 45.914709] RIP: 0010:lookup_peer+0x1ba/0x320
[ 45.915436] Code: 48 89 d9 ba 04 00 00 00 4c 89 fe bf a0 06 00 00 e8 2b e8 ad fb e9 56 ff ff ff e8 01 1e c3 fb 49 8d 7f 18 48 89 f8 48 c1 e8 03 <80> 3c 28 00 0f 85 4a 01 00 00 4d 8b 47 18 4c 89 f1 ba 04 00 00 00
[ 45.919191] RSP: 0018:ffff888114d67b90 EFLAGS: 00010212
[ 45.920046] RAX: 1bd5a00000000023 RBX: 0000000000000000 RCX: ffffffff85c1d19f
[ 45.921129] RDX: ffff88810dc35700 RSI: 0000000000000000 RDI: dead000000000118
[ 45.922553] RBP: dffffc0000000000 R08: 0000000000000001 R09: 0000000000000001
[ 45.923653] R10: ffffffff893d3057 R11: ffff88810dc35700 R12: ffff88810a690000
[ 45.925119] R13: ffff888115451038 R14: ffff88810a690000 R15: dead000000000100
[ 45.926180] FS: 00007fa889bac780(0000) GS:ffff8881fd852000(0000) knlGS:0000000000000000
[ 45.927817] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 45.928726] CR2: 00007ffe304f2f80 CR3: 0000000104f64005 CR4: 0000000000770ef0
[ 45.930069] PKRU: 55555554
[ 45.930456] Kernel panic - not syncing: Fatal exception
[ 45.931542] Kernel Offset: disabled
[ 45.932040] Rebooting in 1 seconds..--- net/bluetooth/6lowpan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/6lowpan.c +1 -1
@@ -1261,7 +1261,7 @@ static int device_event(struct notifier_block *unused,if (entry->netdev == netdev) {BT_DBG ("Unregistered netdev %s %p" , netdev->name, netdev); -list_del (&entry->list); +list_del_rcu (&entry->list);break ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1230/1756 Bluetooth: Add missing newline to bt_dev_{err,warn}_ratelimited()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hitalo Souza <[email protected]>
[ Upstream commit f51ee3bb5fbe9c2019c31befe330bddd3aee39c2 ]
bt_dev_err_ratelimited() and bt_dev_warn_ratelimited() pass the format string to bt_err_ratelimited()/bt_warn_ratelimited() without appending a newline, unlike bt_dev_err() and bt_dev_warn(), which go through BT_ERR()/BT_WARN() and add one. Only 2 of the 22 in-tree callers (both in virtio_bt) put the newline in their own format string.
A printk record without a trailing newline is stored with prb_commit() instead of prb_final_commit(), and readers of the log buffer (/dev/kmsg, syslog) do not see it until it is finalized, which only happens when the next record is reserved. These messages therefore stay invisible until some unrelated message is printed, and journald, which timestamps a record when it reads it, logs them with the time of that later message.
This was observed with a MediaTek MT7921 controller (USB 04ca:3802):
when an eSCO link is closed, the host still receives a few SCO packets for the handle after Disconnection Complete, so hci_scodata_packet() logs "SCO packet for unknown connection handle". Comparing the record's kernel timestamp (_SOURCE_MONOTONIC_TIMESTAMP) with the time journald received it, over one capture:
emitted logged delay 15:36:52.896 15:37:00.214 7.3 s 15:37:03.410 15:39:05.574 122.2 s 15:39:05.574 15:39:12.506 6.9 s 15:39:19.791 15:40:54.109 94.3 s 15:41:22.021 15:41:24.647 2.6 s
Each message showed up together with the next kernel message; the 94 s one looked as if it had been logged in the middle of a later, healthy eSCO connection.
bt_dev_err_ratelimited() lost its newline in commit 657cc646475b ("Bluetooth: Remove usage of BT_ERR_RATELIMITED macro"), which replaced BT_ERR_RATELIMITED(), the variant that appended "\n", with a direct call to bt_err_ratelimited(). bt_dev_warn_ratelimited() never had one.
Append the newline in both macros, as BT_ERR() and BT_WARN() do, and drop it from the two virtio_bt format strings so that their messages do not gain an empty line.
--- drivers/bluetooth/virtio_bt.c | 4 ++-- include/net/bluetooth/bluetooth.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/bluetooth/virtio_bt.c +2 -2
@@ -228,7 +228,7 @@ static void virtbt_rx_handle(struct virtio_bluetooth *vbt, struct sk_buff *skb)if (skb->len < min_hdr) {bt_dev_err_ratelimited (vbt->hdev, -"rx pkt_type 0x%02x payload %u < hdr %zu\n" , +"rx pkt_type 0x%02x payload %u < hdr %zu" , pkt_type, skb->len, min_hdr);kfree_skb (skb);return ;
@@ -251,7 +251,7 @@ static void virtbt_rx_work(struct work_struct *work)if (!len || len >VIRTBT_RX_BUF_SIZE ) {bt_dev_err_ratelimited (vbt->hdev, -"rx reply len %u outside [1, %u]\n" , +"rx reply len %u outside [1, %u]" , len,VIRTBT_RX_BUF_SIZE );kfree_skb (skb); }else {
include/net/bluetooth/bluetooth.h +2 -2
@@ -281,9 +281,9 @@ void bt_err_ratelimited(const char *fmt, ...); BT_DBG("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)#define bt_dev_warn_ratelimited (hdev, fmt, ...) \ - bt_warn_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__) + bt_warn_ratelimited("%s: " fmt "\n", bt_dev_name(hdev), ##__VA_ARGS__)#define bt_dev_err_ratelimited (hdev, fmt, ...) \ - bt_err_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__) + bt_err_ratelimited("%s: " fmt "\n", bt_dev_name(hdev), ##__VA_ARGS__)/* Connection and socket states */ enum bt_sock_state {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1231/1756 Bluetooth: hci_core: Keep RCU protection through LTK filtering
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 817cbcab91fe870e5b69c835cbd708242c9f8c8e ]
The LTK selected by hci_find_ltk() must remain allocated while its value is checked against the blocked-key list. The finder releases RCU before passing k->val to hci_is_blocked_key(). The helper's own RCU section protects the blocked-key list, but the selected LTK may already have been reclaimed before that section starts.
An LE ATT socket security request can reach smp_ltk_encrypt() without holding hdev->lock. With a matching stored LTK and an LTK-type blocked-key entry present, a concurrent MGMT_OP_LOAD_LONG_TERM_KEYS can remove the selected LTK in the following order:
Socket security Management / RCU reclamation
hci_find_ltk()
rcu_read_lock()
select k
rcu_read_unlock()
load_long_term_keys()
hci_dev_lock(hdev)
hci_smp_ltks_clear(hdev)
list_del_rcu(&k->list)
kfree_rcu(k, rcu)
grace period ends; k is freed
hci_is_blocked_key(..., k->val)
memcmp(b->val, val, ...)The final comparison reads freed LTK bytes. Entering a new RCU section in hci_is_blocked_key() cannot protect a pointer obtained before the completed grace period.
Keep the finder's RCU read-side section active through the blocked-key comparison and the warning that reads k->bdaddr. Release it before returning on either matched-key path. This delays reclamation until the finder has finished using the selected record, following the existing IRK lookup pattern.
KFENCE report as below:
==================================================================
BUG: KFENCE: use-after-free read in hci_is_blocked_key+0xdf/0x240
Use-after-free read at 0x00000000b9ee38e4 (in kfence-#249):
hci_is_blocked_key+0xdf/0x240
blocked_key_wrapper+0xc5/0x140 [pmbd_ltk_probe]
hci_find_ltk+0x1aa/0x3e0
smp_ltk_encrypt.isra.0+0xad/0x340
smp_conn_security+0x3b8/0x8c0
l2cap_sock_setsockopt+0x1c4b/0x2270
do_sock_setsockopt+0x1fb/0x430
__sys_setsockopt+0x106/0x180
__x64_sys_setsockopt+0xc2/0x160
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
kfence-#249: 0x00000000121f2ad9-0x000000005b5bfb3d, size=72, cache=kmalloc-96
allocated by task 495 on cpu 0 at 36.722380s (2.603973s ago):
hci_add_ltk+0x1f5/0x3a0
load_long_term_keys+0x6d0/0x860
hci_sock_sendmsg+0x128b/0x22e0
__sys_sendto+0x425/0x470
__x64_sys_sendto+0xe5/0x1c0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
freed by task 533 on cpu 0 at 36.993097s (2.339769s ago):
__rcu_free_sheaf_prepare+0x261/0x2a0
rcu_free_sheaf+0x1f/0xe0
rcu_core+0x661/0x1d10
handle_softirqs+0x201/0x930
__irq_exit_rcu+0x110/0x1e0
irq_exit_rcu+0xe/0x20
sysvec_apic_timer_interrupt+0x6c/0x80
asm_sysvec_apic_timer_interrupt+0x1a/0x20
srso_alias_return_thunk+0x0/0xfbef5
__asan_memcpy+0x23/0x60
create_monitor_ctrl_event+0x1a2/0x460
mgmt_cmd_complete+0x2da/0x580
load_long_term_keys+0x741/0x860
hci_sock_sendmsg+0x128b/0x22e0
__sys_sendto+0x425/0x470
__x64_sys_sendto+0xe5/0x1c0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
CPU: 1 UID: 0 PID: 495 Comm: python3 Tainted: G O 7.2.0-rc6-pmb-bt-functional-v1+ #1 PREEMPT(lazy)
Tainted: [O]=OOT_MODULE
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
==================================================================--- net/bluetooth/hci_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/hci_core.c +2 -2
@@ -1189,16 +1189,16 @@ struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,continue ;if (smp_ltk_is_sc (k) ||ltk_role (k->type) == role) { -rcu_read_unlock (); -if (hci_is_blocked_key (hdev,HCI_BLOCKED_KEY_TYPE_LTK , k->val)) {bt_dev_warn_ratelimited (hdev,"LTK blocked for %pMR" , &k->bdaddr); +rcu_read_unlock ();return NULL ; } +rcu_read_unlock ();return k; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1232/1756 Bluetooth: hci_sync: Serialize devcoredump reset during device open
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 6d91353f6dbcc5c4fbb47bbd0c7f885453cfc939 ]
An ACTIVE devcoredump's buffer cursors must remain valid from the packet handler's state check through its copy. hci_devcd_rx() holds hdev->lock across that interval, and hci_devcd_reset() requires the same lock. However, hci_dev_open_sync() invokes reset without taking it.
A registered VHCI controller can collect a dump through its debugfs interface while the controller is down. If a successful open overlaps with handling a nonempty dump packet, reset can run after the receiver's ACTIVE check and before its copy:
hci_devcd_rx() hci_dev_open_sync()
dequeue nonempty skb
hci_dev_lock(hdev)
handler observes ACTIVE
hdev->open(hdev) succeeds hci_devcd_reset(hdev)
dump.tail = NULL dump.state = IDLE
hci_devcd_copy()
compare against old dump.end
memcpy(NULL, ..., skb->len)
hci_dev_unlock(hdev)
Reset leaves dump.end pointing at the old buffer and purges only queued packets, so it cannot discard the skb already dequeued by the receiver. The bounds check can pass with a NULL tail, leading to a nonempty copy to address zero. KASAN reported a 24-byte NULL write in hci_devcd_rx().
Take hdev->lock around the open-time reset. The receiver then finishes its state check and copy using valid cursors before reset, or observes IDLE after reset and skips the copy.
KASAN report as below:
BUG: KASAN: null-ptr-deref in hci_devcd_rx+0x5d5/0x1a80
Write of size 24 at addr 0000000000000000 by task kworker/u17:0/496
CPU: 0 UID: 0 PID: 496 Comm: kworker/u17:0 Not tainted
7.2.0-rc6-pmb-bt-functional-v1+ #1 PREEMPT(lazy)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps
fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: hci0 hci_devcd_rx
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
kasan_report+0xe0/0x110
? hci_devcd_rx+0x5d5/0x1a80
kasan_check_range+0x105/0x1b0
__asan_memcpy+0x3c/0x60
hci_devcd_rx+0x5d5/0x1a80
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_hci_devcd_rx+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x280
? srso_alias_return_thunk+0x5/0xfbef5
process_one_work+0x908/0x19c0
? __pfx_process_one_work+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? lock_is_held_type+0x8f/0x100
? srso_alias_return_thunk+0x5/0xfbef5
worker_thread+0x65c/0xe40
? __pfx_worker_thread+0x10/0x10
kthread+0x34f/0x460
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_kthread+0x10/0x10
ret_from_fork+0x659/0x940
? __pfx_ret_from_fork+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? __switch_to+0x74f/0xf80
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
==================================================================
Disabling lock debugging due to kernel taint--- net/bluetooth/hci_sync.c | 2 ++ 1 file changed, 2 insertions(+)
net/bluetooth/hci_sync.c +2 -0
@@ -5357,7 +5357,9 @@ int hci_dev_open_sync(struct hci_dev *hdev) goto done; } +hci_dev_lock (hdev);hci_devcd_reset (hdev); +hci_dev_unlock (hdev);set_bit (HCI_RUNNING , &hdev->flags);hci_sock_dev_event (hdev,HCI_DEV_OPEN );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1233/1756 Bluetooth: ISO: Hold the listener during disconnect notification
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit b4a00dedc5cc6f6f98c07ec1b54d24a817d9fc88 ]
An ISO listener must remain alive until a queued child's disconnect notification completes. bt_accept_enqueue() retains only the child and stores a raw parent pointer; iso_conn_ready() drops its temporary listener reference after setup. iso_chan_del() saves that pointer, unlinks the child and then calls parent->sk_data_ready() without holding a listener reference.
With an incoming CIS child still queued, disconnect and listener release can proceed in this order:
HCI disconnect Listener release
iso_conn_del(): lock child
iso_chan_del(): save parent bt_accept_unlink(child)
iso_sock_cleanup_listen():
drain empty accept queue
iso_sock_release():
orphan and kill listener final sock_put(listener)
parent->sk_data_ready(parent)
After unlink, listener cleanup no longer has to take the child socket lock. The listener can therefore be freed before iso_chan_del() reads sk_data_ready, causing a use-after-free.
Take a temporary parent reference before bt_accept_unlink() and drop it after the notification. The child lock excludes accept dequeue while the child is still queued, so listener cleanup cannot complete before sock_hold(). The reference then keeps the listener alive across unlink and through the callback without changing lock order.
KASAN report as below:
==================================================================
BUG: KASAN: slab-use-after-free in iso_chan_del+0x302/0x320
Read of size 8 at addr ffff888105ca2188 by task kworker/2:1/50
CPU: 2 UID: 0 PID: 50 Comm: kworker/2:1 Not tainted
7.2.0-rc6-pmb-bt-functional-v1+ #1 PREEMPT(lazy)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps
fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: events iso_fixture_disconnect_work
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? iso_chan_del+0x302/0x320
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? iso_chan_del+0x302/0x320
kasan_report+0xe0/0x110
? iso_chan_del+0x302/0x320
iso_chan_del+0x302/0x320
iso_conn_del+0x19d/0x3c0
? __pfx_iso_disconn_cfm+0x10/0x10
iso_disconn_cfm+0x78/0x120
hci_disconn_complete_evt+0x319/0xa30
? find_held_lock+0x2b/0x80
hci_test_iso_disconn_event+0x85/0xb0
? __pfx_hci_test_iso_disconn_event+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? _raw_read_unlock+0x23/0x40
? srso_alias_return_thunk+0x5/0xfbef5
? __hci_dev_get+0x15d/0x280
iso_fixture_disconnect_work+0x67/0x290
process_one_work+0x908/0x19c0
? __pfx_process_one_work+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? lock_is_held_type+0x8f/0x100
? srso_alias_return_thunk+0x5/0xfbef5
worker_thread+0x65c/0xe40
? srso_alias_return_thunk+0x5/0xfbef5
? __kthread_parkme+0x175/0x220
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_worker_thread+0x10/0x10
kthread+0x34f/0x460
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_kthread+0x10/0x10
ret_from_fork+0x659/0x940
? __pfx_ret_from_fork+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? __switch_to+0x74f/0xf80
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
Allocated by task 521:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_noprof+0x2d7/0x770
sk_prot_alloc+0x13e/0x260
sk_alloc+0x37/0xb40
bt_sock_alloc+0x40/0x3b0
iso_sock_alloc.constprop.0+0x3a/0x360
iso_sock_create+0xc7/0x160
bt_sock_create+0x171/0x330
__sock_create+0x2c4/0x730
__sys_socket+0x141/0x210
__x64_sys_socket+0x77/0xc0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 521:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x307/0x580
__sk_destruct+0x64f/0x790
sk_destruct+0xb3/0xd0
__sk_free+0xdd/0x370
sk_free+0x51/0x80
iso_sock_release+0x46d/0x5b0
__sock_release+0xb8/0x270
sock_close+0x21/0x30
__fput+0x39f/0xa60
task_work_run+0x144/0x230
do_exit+0x834/0x2830
do_group_exit+0xc7/0x280
get_signal+0x20a9/0x2400
arch_do_signal_or_restart+0x94/0x6f0
exit_to_user_mode_loop+0xcf/0x570
do_syscall_64+0x4f0/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff888105ca2000
which
belongs to the cache kmalloc-2k of size
2048
The buggy address is located 392 bytes inside of
freed
2048-byte region [ffff888105ca2000,
ffff888105ca2800)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000
index:0xffff888105ca5000 pfn:0x105ca0
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x200000000000240(workingset|head|node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000240 ffff888100042f00 ffffea00042cd010
ffffea00042c9210
raw: ffff888105ca5000 0000000000080005 00000000f5000000
0000000000000000
head: 0200000000000240 ffff888100042f00 ffffea00042cd010
ffffea00042c9210
head: ffff888105ca5000 0000000000080005 00000000f5000000
0000000000000000
head: 0200000000000003 fffffffffffffe01 00000000ffffffff
00000000ffffffff
head: ffff888105ca1000 0000000000000000 00000000ffffffff
0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888105ca2080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888105ca2100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888105ca2180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888105ca2200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888105ca2280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================--- net/bluetooth/iso.c | 3 +++ 1 file changed, 3 insertions(+)
net/bluetooth/iso.c +3 -0
@@ -248,8 +248,11 @@ static void iso_chan_del(struct sock *sk, int err) parent =bt_sk (sk)->parent;if (parent) { +/* Unlinking the child allows the parent to be freed. */ +sock_hold (parent);bt_accept_unlink (sk); parent->sk_data_ready (parent); +sock_put (parent); }else { sk->sk_state_change (sk); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1234/1756 Bluetooth: MGMT: Reject quality report requests during unregister
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 213e7a99bea19e2f29f394321b86c792eec73a24 ]
A quality report request must not call a driver callback after its module text has been released. hci_mgmt_cmd() holds an hci_dev reference through set_exp_feature(), but that reference only preserves the device allocation. set_quality_report_func() takes req_lock and invokes hdev->set_quality_report without checking HCI_UNREGISTER.
This is unsafe when a SET_EXP_FEATURE request for an Intel controller would change HCI_QUALITY_REPORT and is delayed before taking req_lock while the controller is removed. With btintel_pcie and btintel built as modules and no other btintel dependents, the following order is possible:
Management request Removal and module unload
------------------ -------------------------
hci_mgmt_cmd(): retain hdev
hci_unregister_dev():
set HCI_UNREGISTER remove hdev from lookup close under req_lock release req_lock
btintel_pcie_remove(): return unload btintel_pcie, then btintel
set_quality_report_func():
take req_lock
call hdev->set_quality_reportWhen the request resumes after btintel unload, the indirect call targets released module text and can cause an instruction-fetch page fault. The close operation serializes with a running callback but does not prevent a delayed management handler from invoking it afterwards.
Check HCI_UNREGISTER immediately after acquiring the existing req_lock and return MGMT_STATUS_INVALID_INDEX via the common unlock path. If unregister passed its close section first, the request now rejects the removed controller before accessing the callback. If the request passes the check first, hci_dev_do_close() must wait for req_lock until the callback has returned, so unregister cannot finish before the use.
Oops report as below:
BUG: unable to handle page fault for address: ffffffffc0408e10
#PF: supervisor instruction fetch in kernel mode
#PF: error_code(0x0010) - not-present page
PGD 80a9067 P4D 80a9067 PUD 80ab067 PMD 0
Oops: Oops: 0010 [#1] SMP KASAN NOPTI
CPU: 1 UID: 0 PID: 439 Comm: btmgmt Tainted: G O 7.2.0-rc6-pmb-bt-functional-v1+ #1 PREEMPT(lazy)
Tainted: [O]=OOT_MODULE
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:0xffffffffc0408e10
Code: Unable to access opcode bytes at 0xffffffffc0408de6.
RSP: 0018:ffff888110927838 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 1ffff11022124f0c RCX: ffffffff85b1a1b6
RDX: ffff888117511d00 RSI: 0000000000000001 RDI: ffff888117598000
RBP: ffff888110927950 R08: 0000000000000001 R09: 0000000000000001
R10: ffffffff893d3057 R11: ffff888117511d00 R12: ffff888117598000
R13: 0000000000000001 R14: ffffffffc0408e10 R15: ffff888117599970
FS: 00007f15453f2040(0000) GS:ffff8881fd852000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffc0408de6 CR3: 000000010b832005 CR4: 0000000000770ef0
PKRU: 55555554
Call Trace:
<TASK>
? set_quality_report_func+0x232/0x660
? __pfx_set_quality_report_func+0x10/0x10
? pmbd_gate_maybe+0x47/0x60
? srso_alias_return_thunk+0x5/0xfbef5
? pmbd_probe_hit_cookie+0xe7/0x1c0
? srso_alias_return_thunk+0x5/0xfbef5
? pmbd_probe_hit_cookie+0xee/0x1c0
set_exp_feature+0xf7/0x260
? set_exp_feature+0xf7/0x260
? hci_sock_sendmsg+0x12b2/0x2400
? __pfx_hci_sock_sendmsg+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? selinux_socket_sendmsg+0x160/0x280
? sock_write_iter+0x4c0/0x550
? __pfx_hci_sock_sendmsg+0x10/0x10
? __pfx_sock_write_iter+0x10/0x10
? __file_has_perm+0x25e/0x420
? __pfx___file_has_perm+0x10/0x10
? do_iter_readv_writev+0x59c/0x860
? __pfx_do_iter_readv_writev+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? security_file_permission+0x26/0x80
? vfs_writev+0x30e/0xc10
? __pfx_vfs_writev+0x10/0x10
? __pfx_do_epoll_wait+0x10/0x10
? __pfx_do_epoll_ctl+0x10/0x10
? do_writev+0x241/0x2f0
? srso_alias_return_thunk+0x5/0xfbef5
? do_writev+0x241/0x2f0
? __pfx_do_writev+0x10/0x10
? irqentry_exit+0xbe/0x820
? do_syscall_64+0x115/0x6a0
? entry_SYSCALL_64_after_hwframe+0x77/0x7f
</TASK>
Modules linked in: [last unloaded: btintel(O)]
CR2: ffffffffc0408e10
---[ end trace 0000000000000000 ]---
RIP: 0010:0xffffffffc0408e10
Code: Unable to access opcode bytes at 0xffffffffc0408de6.
RSP: 0018:ffff888110927838 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 1ffff11022124f0c RCX: ffffffff85b1a1b6
RDX: ffff888117511d00 RSI: 0000000000000001 RDI: ffff888117598000
RBP: ffff888110927950 R08: 0000000000000001 R09: 0000000000000001
R10: ffffffff893d3057 R11: ffff888117511d00 R12: ffff888117598000
R13: 0000000000000001 R14: ffffffffc0408e10 R15: ffff888117599970
FS: 00007f15453f2040(0000) GS:ffff8881fd852000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffc0408de6 CR3: 000000010b832005 CR4: 0000000000770ef0
PKRU: 55555554
Kernel panic - not syncing: Fatal exception
Kernel Offset: disabled
Rebooting in 1 seconds..--- net/bluetooth/mgmt.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/bluetooth/mgmt.c +7 -0
@@ -4921,6 +4921,13 @@ static int set_quality_report_func(struct sock *sk, struct hci_dev *hdev,hci_req_sync_lock (hdev); +if (hci_dev_test_flag (hdev,HCI_UNREGISTER )) { + err =mgmt_cmd_status (sk, hdev->id, +MGMT_OP_SET_EXP_FEATURE , +MGMT_STATUS_INVALID_INDEX ); + goto unlock_quality_report; + } + val = !!cp->param[0 ]; changed = (val !=hci_dev_test_flag (hdev,HCI_QUALITY_REPORT ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1235/1756 Bluetooth: msft: Lock failed probe cleanup against feature readers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 21895f20fedc4504474bcb1022850b532ea4358e ]
The MSFT data must remain allocated while msft_get_features() reads its features. read_adv_mon_features() protects that access with hdev->lock, but msft_do_open() clears hdev->msft_data and frees the object without that lock when read_supported_features() fails.
After a successful probe, the data survives a normal close. A later open can fail the probe while a management feature request is running. hci_mgmt_cmd() permits requests during HCI_INIT, and the opener's hdev->req_lock does not serialize the management reader:
Management feature request HCI open
hold hdev->req_lock
msft_do_open()
hold hdev->lock
msft_get_features(): save msft
read_supported_features() fails
hdev->msft_data = NULL
kfree(msft) read msft->features
release hdev->lock release hdev->req_lock
The saved pointer then refers to freed memory, causing a use-after-free read. Advertisement reporting through mgmt_device_found() also reads the features with hdev->lock held.
Take hdev->lock around clearing and freeing msft_data in the failure branch. An existing feature reader finishes before the free, while a reader starting after cleanup sees NULL. Keep the synchronous probe outside this critical section, following the existing req_lock to hdev->lock ordering.
KASAN report as below:
==================================================================
BUG: KASAN: slab-use-after-free in msft_monitor_supported+0xa9/0xb0
Read of size 8 at addr ffff88811573ee00 by task mgmt-read-adv-m/532
CPU: 2 UID: 0 PID: 532 Comm: mgmt-read-adv-m Not tainted
7.2.0-rc6-pmb-bt-functional-v1+ #1 PREEMPT(lazy)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps
fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? msft_monitor_supported+0xa9/0xb0
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? msft_monitor_supported+0xa9/0xb0
kasan_report+0xe0/0x110
? msft_monitor_supported+0xa9/0xb0
msft_monitor_supported+0xa9/0xb0
read_adv_mon_features+0xdf/0x640
? trace_hardirqs_on+0x18/0x160
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_read_adv_mon_features+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? do_raw_read_unlock+0x49/0xe0
? srso_alias_return_thunk+0x5/0xfbef5
? _raw_read_unlock+0x23/0x40
hci_sock_sendmsg+0x12b5/0x2270
? __pfx_hci_sock_sendmsg+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? selinux_socket_sendmsg+0x160/0x280
__sys_sendto+0x425/0x470
? __pfx_hci_sock_sendmsg+0x10/0x10
? __pfx___sys_sendto+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? __sys_setsockopt+0x119/0x180
__x64_sys_sendto+0xe5/0x1c0
? lockdep_hardirqs_on_prepare+0xea/0x1a0
? srso_alias_return_thunk+0x5/0xfbef5
? trace_hardirqs_on+0x18/0x160
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f9ceb04a687
Code: 48 89 fa 4c 89 df e8 58 b3 00 00 8b 93 08 03 00 00 59 5e 48
83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b>
c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
RSP: 002b:00007ffe6ab96a70 EFLAGS: 00000202 ORIG_RAX: 000000000000002c
RAX: ffffffffffffffda RBX: 00007f9ceafb8780 RCX: 00007f9ceb04a687
RDX: 0000000000000006 RSI: 00007ffe6ab96aea RDI: 0000000000000003
RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000003
R13: 00007ffe6ab96d50 R14: 00007f9ceb1f6000 R15: 00005625e427dd68
</TASK>
Allocated by task 506:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x251/0x610
msft_register+0x54/0x260
hci_register_dev+0x6b7/0xc80
__vhci_create_device+0x330/0x840
vhci_write+0x287/0x440
vfs_write+0x637/0x1010
ksys_write+0x111/0x200
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 529:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x307/0x580
msft_do_open+0x604/0x9e0
hci_dev_open_sync+0x94a/0x2110
hci_dev_do_open+0x2f/0xb0
hci_dev_open+0x17d/0x300
hci_sock_ioctl+0x3c6/0x710
sock_do_ioctl+0x120/0x2b0
sock_ioctl+0x41b/0x670
__x64_sys_ioctl+0x163/0x1d0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff88811573ee00
which belongs to the cache kmalloc-256 of size 256
The buggy address is located 0 bytes inside of
freed 256-byte region [ffff88811573ee00, ffff88811573ef00)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0
pfn:0x11573e
head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x200000000000040(head|node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000040 ffff888100042b40 dead000000000100
dead000000000122
raw: 0000000000000000 0000000000100010 00000000f5000000
0000000000000000
head: 0200000000000040 ffff888100042b40 dead000000000100
dead000000000122
head: 0000000000000000 0000000000100010 00000000f5000000
0000000000000000
head: 0200000000000001 ffffffffffffff81 00000000ffffffff
00000000ffffffff
head: 0000000000000000 0000000000000000 00000000ffffffff
0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88811573ed00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88811573ed80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88811573ee00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88811573ee80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88811573ef00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================--- net/bluetooth/msft.c | 2 ++ 1 file changed, 2 insertions(+)
net/bluetooth/msft.c +2 -0
@@ -654,8 +654,10 @@ void msft_do_open(struct hci_dev *hdev) msft->features =0 ;if (!read_supported_features (hdev, msft)) { +hci_dev_lock (hdev); hdev->msft_data =NULL ;kfree (msft); +hci_dev_unlock (hdev);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1236/1756 Bluetooth: 6lowpan: Drain RCU readers on registration failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit ebba800d140b580540ad55f670d943e4a7edaffd ]
A lowpan_btle_dev is embedded in its net_device allocation and must remain alive until readers of bt_6lowpan_devices have left their RCU sections. setup_netdev() publishes it before registration, but its error path only unlinks it before calling free_netdev().
If a second controller's registration fails while multicast is sent on an existing 6LoWPAN interface, send_mcast_pkt() can already have selected the new entry. It reads entry->netdev before checking which interface owns it. An early failure, such as allocating the device's name node, leaves NETREG_UNINITIALIZED, so free_netdev() releases the storage immediately.
The following ordering frees the selected entry before the reader loads its netdev field:
Adapter creation (controller B) Multicast on controller A
setup_netdev()
list_add_rcu()
rcu_read_lock()
select B's entry
lowpan_register_netdev() fails
list_del_rcu()
free_netdev()
read entry->netdev
rcu_read_unlock()Removing the list node does not wait for that reader, and devices_lock does not serialize the multicast reader. The subsequent field load is a use-after-free, reported by KASAN in bt_xmit().
Wait for an RCU grace period after dropping devices_lock and before free_netdev(). This keeps the failed adapter allocated until traversals that could have selected it complete. The callback is already sleepable, and the wait happens outside the list spinlock.
KASAN report as below:
==================================================================
BUG: KASAN: slab-use-after-free in bt_xmit+0x1d06/0x21e0
Read of size 8 at addr ffff88810ef45030 by task python3/556
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? bt_xmit+0x1d06/0x21e0
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? bt_xmit+0x1d06/0x21e0
kasan_report+0xe0/0x110
? bt_xmit+0x1d06/0x21e0
bt_xmit+0x1d06/0x21e0
? __pfx_bt_xmit+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? lock_acquire+0x17b/0x2f0
? srso_alias_return_thunk+0x5/0xfbef5
? lock_is_held_type+0x8f/0x100
? dev_hard_start_xmit+0x187/0x660
? __pfx_bt_xmit+0x10/0x10
dev_hard_start_xmit+0x187/0x660
sch_direct_xmit+0x153/0x850
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_sch_direct_xmit+0x10/0x10
? do_raw_spin_lock+0x130/0x270
? __pfx_do_raw_spin_lock+0x10/0x10
? lock_is_held_type+0x8f/0x100
__dev_queue_xmit+0x3111/0x3aa0
? srso_alias_return_thunk+0x5/0xfbef5
? look_up_lock_class+0x59/0x130
? register_lock_class+0x41/0x790
? __pfx___dev_queue_xmit+0x10/0x10
? __lock_acquire+0x466/0x2260
? find_held_lock+0x2b/0x80
? ___neigh_create+0x1690/0x2540
? __local_bh_enable_ip+0xa6/0x120
? srso_alias_return_thunk+0x5/0xfbef5
? lockdep_hardirqs_on_prepare+0xea/0x1a0
? srso_alias_return_thunk+0x5/0xfbef5
? lock_acquire+0x17b/0x2f0
? srso_alias_return_thunk+0x5/0xfbef5
? find_held_lock+0x2b/0x80
? ip6_finish_output2+0x8be/0x1840
? srso_alias_return_thunk+0x5/0xfbef5
? neigh_connected_output+0x39f/0x4e0
? srso_alias_return_thunk+0x5/0xfbef5
neigh_connected_output+0x33f/0x4e0
ip6_finish_output2+0x8be/0x1840
ip6_finish_output+0x424/0xd50
ip6_output+0x210/0x640
? __pfx_ip6_mr_output+0x10/0x10
ip6_local_out+0x193/0x1c0
ip6_send_skb+0xfb/0x3e0
udp_v6_send_skb+0x6e1/0x1180
udpv6_sendmsg+0x1f9b/0x2a00
? get_random_u32+0xaf/0x640
? __pfx_udpv6_sendmsg+0x10/0x10
? lock_release+0xc8/0x280
? srso_alias_return_thunk+0x5/0xfbef5
? lockdep_hardirqs_on_prepare+0xea/0x1a0
? srso_alias_return_thunk+0x5/0xfbef5
? trace_hardirqs_on+0x18/0x160
? srso_alias_return_thunk+0x5/0xfbef5
? __local_bh_enable_ip+0xa6/0x120
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_udpv6_sendmsg+0x10/0x10
? inet6_sendmsg+0xff/0x140
inet6_sendmsg+0xff/0x140
__sys_sendto+0x320/0x470
? __pfx___sys_sendto+0x10/0x10
? exc_page_fault+0x5c/0xc0
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x280
? handle_mm_fault+0x12e/0x580
__x64_sys_sendto+0xe5/0x1c0
? lockdep_hardirqs_on_prepare+0xea/0x1a0
? srso_alias_return_thunk+0x5/0xfbef5
? trace_hardirqs_on+0x18/0x160
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Allocated by task 502:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kvmalloc_node_noprof+0x353/0x930
alloc_netdev_mqs+0xa0/0x1250
chan_ready_cb+0x198/0x1110
l2cap_recv_frame+0x6dc0/0x8830
l2cap_recv_acldata+0xe9f/0x10e0
hci_rx_work+0x5a6/0xf00
process_one_work+0x908/0x19c0
worker_thread+0x65c/0xe40
kthread+0x34f/0x460
ret_from_fork+0x659/0x940
ret_from_fork_asm+0x1a/0x30
Freed by task 502:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x307/0x580
free_netdev+0x6ca/0x8f0
chan_ready_cb+0xd91/0x1110
l2cap_recv_frame+0x6dc0/0x8830
l2cap_recv_acldata+0xe9f/0x10e0
hci_rx_work+0x5a6/0xf00
process_one_work+0x908/0x19c0
worker_thread+0x65c/0xe40
kthread+0x34f/0x460
ret_from_fork+0x659/0x940
ret_from_fork_asm+0x1a/0x30
The buggy address belongs to the object at ffff88810ef44000
which
belongs to the cache kmalloc-8k of size
8192
The buggy address is located 4144 bytes inside of
freed
8192-byte region [ffff88810ef44000,
ffff88810ef46000)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0
pfn:0x10ef40
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x200000000000040(head|node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000040 ffff888100043180 dead000000000100
dead000000000122
raw: 0000000000000000 0000000000020002 00000000f5000000
0000000000000000
head: 0200000000000040 ffff888100043180 dead000000000100
dead000000000122
head: 0000000000000000 0000000000020002 00000000f5000000
0000000000000000
head: 0200000000000003 fffffffffffffe01 00000000ffffffff
00000000ffffffff
head: ffff88810ef41a80 0000000000000000 00000000ffffffff
0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88810ef44f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88810ef44f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88810ef45000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88810ef45080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88810ef45100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Disabling lock debugging due to kernel taint--- net/bluetooth/6lowpan.c | 1 + 1 file changed, 1 insertion(+)
net/bluetooth/6lowpan.c +1 -0
@@ -705,6 +705,7 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_btle_dev **dev)spin_lock (&devices_lock);list_del_rcu (&(*dev)->list);spin_unlock (&devices_lock); +synchronize_rcu ();free_netdev (netdev); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1237/1756 Bluetooth: btmtk: fix skb double free on ISO padding failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 491d2212ea0f0f6a3abbd67729df0c6a3ec9c58a ]
btmtk_isopkt_pad() uses skb_pad(), which frees the skb on failure.
The error is propagated by alloc_mtk_intr_urb() and btusb_send_frame_mtk() up to hci_send_frame(), which frees the skb a second time:
err = hdev->send(hdev, skb);
if (err < 0) {
bt_dev_err(hdev, "sending frame failed (%d)", err);
kfree_skb(skb);
return err;
}Use __skb_put_padto(skb, MTK_ISO_THRESHOLD, false) so that the skb is left to the caller on error. This also replaces the open-coded skb_pad() + __skb_put() sequence.
--- drivers/bluetooth/btmtk.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/bluetooth/btmtk.c +2 -6
@@ -1081,12 +1081,8 @@ static int btmtk_isopkt_pad(struct hci_dev *hdev, struct sk_buff *skb)if (skb->len >MTK_ISO_THRESHOLD )return -EINVAL ; -if (skb_pad (skb,MTK_ISO_THRESHOLD - skb->len)) -return -ENOMEM ; - -__skb_put (skb,MTK_ISO_THRESHOLD - skb->len); - -return 0 ; +/* On error, the skb is freed by hci_send_frame(). */ +return __skb_put_padto (skb,MTK_ISO_THRESHOLD , false); }static int __set_mtk_intr_interface (struct hci_dev *hdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1238/1756 Bluetooth: hci_sync: Protect IRK identity reads with RCU
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 4b76fa362110cf1b74a0263c14406b71de99894c ]
hci_le_set_privacy_mode_sync() needs the IRK returned by hci_find_irk_by_addr() to remain allocated until its identity address and type have been copied into the command. The finder drops its RCU read lock before returning this borrowed pointer, leaving the later field reads unprotected.
When a privacy-capable controller has a pending peer with address resolution and device privacy enabled, accept-list programming can reach this helper while management reloads the IRKs. The request worker holds hdev->req_lock, whereas load_irks() takes hdev->lock, allowing the following ordering:
Request worker Management / RCU reclaim
hci_le_set_privacy_mode_sync()
hci_find_irk_by_addr()
rcu_read_lock()
find matching IRK
rcu_read_unlock()
return borrowed IRK
load_irks()
hci_dev_lock(hdev)
hci_smp_irks_clear()
list_del_rcu()
kfree_rcu()
hci_dev_unlock(hdev)
RCU grace period and IRK free
read irk->addr_type
copy irk->bdaddrThe request then accesses a freed IRK. KASAN reports a one-byte use-after-free read of addr_type on this path.
Keep an outer RCU read-side critical section across the lookup and both identity-field copies. The finder's nested unlock then leaves the IRK protected until the caller finishes copying it. Release RCU on a lookup miss and after copying the fields, before the synchronous HCI command can sleep.
KASAN report as below:
==================================================================
BUG: KASAN: slab-use-after-free in
hci_le_add_accept_list_sync+0x90f/0x940
Read of size 1 at addr ffff88810aa6072c by task kworker/u17:0/493
Workqueue: hci0 hci_cmd_sync_work
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? hci_le_add_accept_list_sync+0x90f/0x940
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? hci_le_add_accept_list_sync+0x90f/0x940
kasan_report+0xe0/0x110
? hci_le_add_accept_list_sync+0x90f/0x940
hci_le_add_accept_list_sync+0x90f/0x940
? __pfx_hci_le_add_accept_list_sync+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? conn_params_copy+0x3a0/0x650
hci_passive_scan_sync+0x8c9/0x1e80
? __pfx_hci_passive_scan_sync+0x10/0x10
? find_held_lock+0x2b/0x80
? hci_lookup_le_connect+0x181/0x3c0
? srso_alias_return_thunk+0x5/0xfbef5
? find_held_lock+0x2b/0x80
? hci_update_passive_scan_sync+0x437/0x950
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x280
hci_update_passive_scan_sync+0x461/0x950
hci_cmd_sync_work+0x1b3/0x450
? srso_alias_return_thunk+0x5/0xfbef5
process_one_work+0x908/0x19c0
? __pfx_process_one_work+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? lock_is_held_type+0x8f/0x100
? srso_alias_return_thunk+0x5/0xfbef5
worker_thread+0x65c/0xe40
? __pfx_worker_thread+0x10/0x10
kthread+0x34f/0x460
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_kthread+0x10/0x10
ret_from_fork+0x659/0x940
? __pfx_ret_from_fork+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? __switch_to+0x74f/0xf80
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
Allocated by task 507:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x251/0x610
hci_add_irk+0xb6/0x220
load_irks+0x5ef/0x7e0
hci_sock_sendmsg+0x128b/0x22e0
__sys_sendto+0x425/0x470
__x64_sys_sendto+0xe5/0x1c0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 0:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
__rcu_free_sheaf_prepare+0x65/0x2a0
rcu_free_sheaf+0x1f/0xe0
rcu_core+0x661/0x1d10
handle_softirqs+0x201/0x930
__irq_exit_rcu+0x110/0x1e0
irq_exit_rcu+0xe/0x20
sysvec_apic_timer_interrupt+0x6c/0x80
asm_sysvec_apic_timer_interrupt+0x1a/0x20
The buggy address belongs to the object at ffff88810aa60700
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 44 bytes inside of
freed 64-byte region [ffff88810aa60700, ffff88810aa60740)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0
pfn:0x10aa60
flags: 0x200000000000000(node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000000 ffff8881000428c0 dead000000000100
dead000000000122
raw: 0000000000000000 0000000000200020 00000000f5000000
0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88810aa60600: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88810aa60680: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88810aa60700: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff88810aa60780: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88810aa60800: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================
Disabling lock debugging due to kernel taint--- net/bluetooth/hci_sync.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/bluetooth/hci_sync.c +7 -1
@@ -2629,13 +2629,19 @@ static int hci_le_set_privacy_mode_sync(struct hci_dev *hdev,if (!(params->flags &HCI_CONN_FLAG_DEVICE_PRIVACY ))return 0 ; +rcu_read_lock (); + irk =hci_find_irk_by_addr (hdev, ¶ms->addr, params->addr_type); -if (!irk) +if (!irk) { +rcu_read_unlock ();return 0 ; + }memset (&cp,0 ,sizeof (cp)); cp.bdaddr_type = irk->addr_type;bacpy (&cp.bdaddr, &irk->bdaddr); +rcu_read_unlock (); + cp.mode =HCI_DEVICE_PRIVACY ;/* Note: params->privacy_mode is not updated since it is a copy */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1239/1756 Bluetooth: btintel: propagate version TLV parsing errors
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laxman Acharya Padhya <[email protected]>
[ Upstream commit 3a74624b5deae7f5e2b98e638687fbf9594a9781 ]
btintel_read_version_tlv() ignores the parser return value, so setup continues with partially initialized version data after a malformed TLV causes parsing to stop.
Return the parser error to the caller so an invalid response fails setup instead of being treated as successful. Keep this behavioral change separate from the bounds checks so it can be reverted independently if an existing controller sends malformed data.
Stable-dep-of: cf87709d7ff8 ("Bluetooth: btintel: Zero version data before parsing TLVs")
--- drivers/bluetooth/btintel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/bluetooth/btintel.c +3 -2
@@ -705,6 +705,7 @@ static int btintel_read_version_tlv(struct hci_dev *hdev, {struct sk_buff *skb;const u8 param[1 ] = {0xFF }; +int err;if (!version)return -EINVAL ;
@@ -723,10 +724,10 @@ static int btintel_read_version_tlv(struct hci_dev *hdev,return -EIO ; } -btintel_parse_version_tlv (hdev, version, skb); + err =btintel_parse_version_tlv (hdev, version, skb);kfree_skb (skb); -return 0 ; +return err; }/* ------- REGMAP IBT SUPPORT ------- */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1240/1756 Bluetooth: btintel: Zero version data before parsing TLVs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kiran K <[email protected]>
[ Upstream commit cf87709d7ff83b4de5d42b61e4a9806fe374cb9d ]
Firmware may omit optional TLVs, leaving their corresponding fields unset in the caller-supplied struct intel_version_tlv. Since the structure is typically stack-allocated and not cleared beforehand, fields for which no TLV is received retain uninitialized stack memory. This stale data can be logged via btintel_version_info_tlv() and copied back to the caller, leaking kernel stack contents.
Clear the structure in btintel_read_version_tlv() before parsing so that fields with no corresponding TLV are deterministically zero instead of containing garbage.
--- drivers/bluetooth/btintel.c | 1 + 1 file changed, 1 insertion(+)
drivers/bluetooth/btintel.c +1 -0
@@ -724,6 +724,7 @@ static int btintel_read_version_tlv(struct hci_dev *hdev,return -EIO ; } +memset (version,0 ,sizeof (*version)); err =btintel_parse_version_tlv (hdev, version, skb);kfree_skb (skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1241/1756 Bluetooth: MSFT: Serialize handle map cleanup with event processing
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 56e20c3d8ad340bbfc90221c4aae1c870485fb57 ]
MSFT monitor handle mappings must remain valid while vendor events look up and use them under hdev->lock. msft_do_close() removes and frees the mappings without that lock.
hci_dev_close_sync() clears HCI_UP and drains the RX workqueue before MSFT cleanup. However, a transport callback that already passed hci_recv_frame()'s state check can queue a vendor event after the drain returns, if no earlier shutdown callback has quiesced reception. The driver close callback runs after MSFT cleanup, so event processing can overlap the unlocked removal. msft_monitor_device_evt() can then traverse freed list entries or read handle_data->mgmt_handle after it is freed.
Take hdev->lock while resetting monitor states and removing handle mappings in msft_do_close(), as normal monitor cancellation already does. An active event reader then finishes before its mapping is freed, and later lookups see an empty handle map.
An instrumented kernel produced this KASAN report (timestamps removed and unrelated frames omitted):
BUG: KASAN: slab-use-after-free in msft_vendor_evt+0x1906/0x1990
Read of size 2 at addr ffff888104df3602 by task kworker/u17:2/502
Workqueue: hci0 hci_rx_work
Call Trace:
[...]
msft_vendor_evt+0x1906/0x1990
hci_vendor_evt+0x6f/0x90
hci_event_packet+0x894/0xc70
[...]
hci_rx_work+0x3f8/0xfa0
[...]
Allocated by task 499:
[...]
msft_add_monitor_sync+0x6a8/0x10a0
msft_add_monitor_pattern+0x7f/0xb0
hci_add_adv_monitor+0x1fa/0x2e0
[...]
Freed by task 499:
[...]
kfree+0x307/0x580
msft_do_close+0x238/0x750
hci_dev_close_sync+0x546/0x1380
[...]
The buggy address belongs to the object at ffff888104df3600
which belongs to the cache kmalloc-32 of size 32
The buggy address is located 2 bytes inside of
freed 32-byte region [ffff888104df3600, ffff888104df3620)
[...]--- net/bluetooth/msft.c | 4 ++++ 1 file changed, 4 insertions(+)
net/bluetooth/msft.c +4 -0
@@ -683,6 +683,8 @@ void msft_do_close(struct hci_dev *hdev)bt_dev_dbg (hdev,"Cleanup of MSFT extension" ); +hci_dev_lock (hdev); +/* The controller will silently remove all monitors on power off. * Therefore, remove handle_data mapping and reset monitor state. */
@@ -697,6 +699,8 @@ void msft_do_close(struct hci_dev *hdev)kfree (handle_data); } +hci_dev_unlock (hdev); +mutex_lock (&msft->filter_lock);list_for_each_entry_safe (address_filter, n, &msft->address_filters, list) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1242/1756 net: selftests: use skb_share_check() in the loopback receive hook
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit fbd3a301b1378423a5cfc23a42e3c0b04e26192c ]
The loopback hook gets a shared skb when another ETH_P_IP handler is bound to the device. skb_unshare() does not unshare it, so skb_linearize() on a non-linear frame hits BUG_ON(skb_shared()).
Use skb_share_check() instead.
--- net/core/selftests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/selftests.c +1 -1
@@ -190,7 +190,7 @@ static int net_test_loopback_validate(struct sk_buff *skb,struct tcphdr *thdr;struct iphdr *ihdr; - skb =skb_unshare (skb,GFP_ATOMIC ); + skb =skb_share_check (skb,GFP_ATOMIC );if (!skb) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1243/1756 net: stmmac: selftests: use skb_share_check() in the loopback receive hook
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit a7a89019bac0e8810bde7f1419f4adf9adc23d41 ]
The loopback hook gets a shared skb when another ETH_P_IP handler is bound to the device. skb_unshare() does not unshare it, so skb_linearize() on a non-linear frame hits BUG_ON(skb_shared()).
Use skb_share_check() instead.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +1 -1
@@ -262,7 +262,7 @@ static int stmmac_test_loopback_validate(struct sk_buff *skb,struct tcphdr *thdr;struct iphdr *ihdr; - skb =skb_unshare (skb,GFP_ATOMIC ); + skb =skb_share_check (skb,GFP_ATOMIC );if (!skb) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1244/1756 net/mlx5e: use skb_share_check() in the loopback selftest hook
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit 16fb7aa6955a0af9f67ca42a61d9be58dfc9382a ]
The loopback hook gets a shared skb when another ETH_P_IP handler is bound to the device. skb_linearize() on a non-linear frame then hits BUG_ON(skb_shared()).
Call skb_share_check() before linearizing the skb.
--- drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c +4 -0
@@ -166,6 +166,10 @@ mlx5e_test_loopback_validate(struct sk_buff *skb,struct udphdr *udph;struct iphdr *iph; + skb =skb_share_check (skb,GFP_ATOMIC ); +if (!skb) + goto out; +if (skb_linearize (skb)) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1245/1756 scsi: libsas: Fix out-of-bounds memcpy() in sas_ssp_task_response()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
[ Upstream commit 4d7f9c3fdce773f6c69d17c1d4a05bd5e17f4b99 ]
The min_t(int, ...) clamp of the device-provided sense_data_len turns negative for values >= 0x80000000 and is then used as the memcpy() length, reading and writing out of bounds. Compare as u32 instead. Well-formed responses are unaffected.
--- drivers/scsi/libsas/sas_task.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/libsas/sas_task.c +1 -1
@@ -25,7 +25,7 @@ void sas_ssp_task_response(struct device *dev, struct sas_task *task,case SAS_DATAPRES_SENSE_DATA : tstat->stat =SAS_SAM_STAT_CHECK_CONDITION ; tstat->buf_valid_size = -min_t (int,SAS_STATUS_BUF_SIZE , +min_t (u32,SAS_STATUS_BUF_SIZE ,be32_to_cpu (iu->sense_data_len));memcpy (tstat->buf, iu->sense_data, tstat->buf_valid_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1246/1756 scsi: hisi_sas: Fix incorrect delay values from magic-number cleanup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
[ Upstream commit 7307109c92f702434669bfcd29fb8058ccc07b45 ]
Commit 4ca7fe99fc84 ("scsi: hisi_sas: Use macro instead of magic number") replaced several delay constants with a single macro of value
100. However, three sites originally used different values:
- reset_hw_v3_hw: udelay(50) -> udelay(100) [doubled]
- disable_phy_v3_hw: mdelay(50) -> mdelay(100) [doubled]
- disable_host_v3_hw: mdelay(10) -> mdelay(100) [10x longer]
The overly long delays on the PHY disable and host shutdown paths increase boot and shutdown time for all local PHYs.
Add separate macros for each delay to restore the original values while still avoiding magic numbers.
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +6 -3
@@ -546,6 +546,9 @@ struct hisi_sas_err_record_v3 {#define IRQ_AXI_INDEX 11#define DELAY_FOR_RESET_HW 100 +#define STOP_PHY_DELAY_US 50 +#define DISABLE_PHY_DELAY_MS 50 +#define DISABLE_HOST_PHY_DELAY_MS 10#define HDR_SG_MOD 0x2#define LUN_SIZE 8#define ATTR_PRIO_REGION 9
@@ -980,7 +983,7 @@ static int reset_hw_v3_hw(struct hisi_hba *hisi_hba)/* Disable all of the PHYs */ hisi_sas_stop_phys (hisi_hba); -udelay (HISI_SAS_DELAY_FOR_PHY_DISABLE ); +udelay (STOP_PHY_DELAY_US );/* Ensure axi bus idle */ ret = hisi_sas_read32_poll_timeout(AXI_CFG, val, !val,
@@ -1069,7 +1072,7 @@ static void disable_phy_v3_hw(struct hisi_hba *hisi_hba, int phy_no) cfg &= ~PHY_CFG_ENA_MSK ;hisi_sas_phy_write32 (hisi_hba, phy_no,PHY_CFG , cfg); -mdelay (HISI_SAS_DELAY_FOR_PHY_DISABLE ); +mdelay (DISABLE_PHY_DELAY_MS ); state =hisi_sas_read32 (hisi_hba,PHY_STATE );if (state &BIT (phy_no)) {
@@ -2757,7 +2760,7 @@ static int disable_host_v3_hw(struct hisi_hba *hisi_hba)hisi_sas_stop_phys (hisi_hba); -mdelay (HISI_SAS_DELAY_FOR_PHY_DISABLE ); +mdelay (DISABLE_HOST_PHY_DELAY_MS ); reg_val =hisi_sas_read32 (hisi_hba,AXI_MASTER_CFG_BASE +AM_CTRL_GLOBAL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1247/1756 scsi: scsi_debug: Add READ BLOCK LIMITS and modify LOAD for tapes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai Mäkisara <[email protected]>
[ Upstream commit e7795366c41d7b31ab8c9c37bc07c1d058a99fed ]
The changes:
- Add READ BLOCK LIMITS (512 - 1048576 bytes)
- Make LOAD send New Media UA (not correct by the standard, but makes possible to test also this UA)
Stable-dep-of: 92821c2358c7 ("scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state")
--- drivers/scsi/scsi_debug.c | 127 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 121 insertions(+), 6 deletions(-)
drivers/scsi/scsi_debug.c +121 -6
@@ -80,6 +80,7 @@ static const char *sdebug_version_date = "20210520";#define INVALID_FIELD_IN_CDB 0x24#define INVALID_FIELD_IN_PARAM_LIST 0x26#define WRITE_PROTECTED 0x27 +#define UA_READY_ASC 0x28#define UA_RESET_ASC 0x29#define UA_CHANGED_ASC 0x2a#define TARGET_CHANGED_ASC 0x3f
@@ -175,7 +176,11 @@ static const char *sdebug_version_date = "20210520";/* Default parameters for tape drives */ #define TAPE_DEF_DENSITY 0x0 +#define TAPE_BAD_DENSITY 0x65#define TAPE_DEF_BLKSIZE 0 +#define TAPE_MIN_BLKSIZE 512 +#define TAPE_MAX_BLKSIZE 1048576 +#define TAPE_MAX_PARTITIONS 2#define SDEBUG_LUN_0_VAL 0
@@ -220,7 +225,8 @@ static const char *sdebug_version_date = "20210520";#define SDEBUG_UA_LUNS_CHANGED 5#define SDEBUG_UA_MICROCODE_CHANGED 6/* simulate firmware change */ #define SDEBUG_UA_MICROCODE_CHANGED_WO_RESET 7 -#define SDEBUG_NUM_UAS 8 +#define SDEBUG_UA_NOT_READY_TO_READY 8 +#define SDEBUG_NUM_UAS 9/* when 1==SDEBUG_OPT_MEDIUM_ERR, a medium error is simulated at this * sector on read commands: */
@@ -370,6 +376,8 @@ struct sdebug_dev_info {/* For tapes */ unsigned int tape_blksize;unsigned int tape_density; +unsigned char tape_partition; +unsigned int tape_location[TAPE_MAX_PARTITIONS ];struct dentry *debugfs_entry;struct spinlock list_lock;
@@ -491,14 +499,16 @@ enum sdeb_opcode_index {SDEB_I_ZONE_OUT =30 ,/* 0x94+SA; includes no data xfer */ SDEB_I_ZONE_IN =31 ,/* 0x95+SA; all have data-in */ SDEB_I_ATOMIC_WRITE_16 =32 , - SDEB_I_LAST_ELEM_P1 = 33, /* keep this last (previous + 1) */ +SDEB_I_READ_BLOCK_LIMITS =33 , +SDEB_I_LOCATE =34 , + SDEB_I_LAST_ELEM_P1 = 35, /* keep this last (previous + 1) */ };static const unsigned char opcode_ind_arr[256 ] = {/* 0x0; 0x0->0x1f: 6 byte cdbs */ SDEB_I_TEST_UNIT_READY ,SDEB_I_REZERO_UNIT ,0 ,SDEB_I_REQUEST_SENSE , -0 ,0 ,0 ,0 , +0 ,SDEB_I_READ_BLOCK_LIMITS ,0 ,0 ,SDEB_I_READ ,0 ,SDEB_I_WRITE ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,SDEB_I_INQUIRY ,0 ,0 ,SDEB_I_MODE_SELECT ,SDEB_I_RESERVE , SDEB_I_RELEASE,
@@ -506,7 +516,7 @@ static const unsigned char opcode_ind_arr[256] = {SDEB_I_ALLOW_REMOVAL ,0 ,/* 0x20; 0x20->0x3f: 10 byte cdbs */ 0 ,0 ,0 ,0 ,0 ,SDEB_I_READ_CAPACITY ,0 ,0 , -SDEB_I_READ ,0 ,SDEB_I_WRITE ,0 ,0 ,0 ,0 ,SDEB_I_VERIFY , +SDEB_I_READ ,0 ,SDEB_I_WRITE ,SDEB_I_LOCATE ,0 ,0 ,0 ,SDEB_I_VERIFY ,0 ,0 ,0 ,0 ,SDEB_I_PRE_FETCH ,SDEB_I_SYNC_CACHE ,0 ,0 ,0 ,0 ,0 ,SDEB_I_WRITE_BUFFER ,0 ,0 ,0 ,0 , /* 0x40; 0x40->0x5f: 10 byte cdbs */
@@ -581,6 +591,8 @@ static int resp_open_zone(struct scsi_cmnd *, struct sdebug_dev_info *);static int resp_close_zone (struct scsi_cmnd *,struct sdebug_dev_info *);static int resp_finish_zone (struct scsi_cmnd *,struct sdebug_dev_info *);static int resp_rwp_zone (struct scsi_cmnd *,struct sdebug_dev_info *); +static int resp_read_blklimits (struct scsi_cmnd *,struct sdebug_dev_info *); +static int resp_locate (struct scsi_cmnd *,struct sdebug_dev_info *);static int sdebug_do_add_host (bool mk_new_store);static int sdebug_add_host_helper (int per_host_idx);
@@ -808,6 +820,7 @@ static const struct opcode_info_t opcode_info_arr[SDEB_I_LAST_ELEM_P1 + 1] = { resp_pre_fetch, pre_fetch_iarr, {10, 0x2, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, /* PRE-FETCH (10) */ +/* READ POSITION (10) */ /* 30 */ {ARRAY_SIZE(zone_out_iarr), 0x94, 0x3, F_SA_LOW | F_M_ACCESS,
@@ -823,6 +836,12 @@ static const struct opcode_info_t opcode_info_arr[SDEB_I_LAST_ELEM_P1 + 1] = { resp_atomic_write,NULL ,/* ATOMIC WRITE 16 */ {16, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} }, + {0, 0x05, 0, F_D_IN, resp_read_blklimits, NULL, /* READ BLOCK LIMITS (6) */ + {6, 0, 0, 0, 0, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, + {0, 0x2b, 0, F_D_UNKN, resp_locate, NULL, /* LOCATE (10) */ + {10, 0x2, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xc7, 0, 0, + 0, 0, 0, 0} }, +/* sentinel */ {0xff, 0, 0, 0, NULL, NULL, /* terminating element */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
@@ -1501,6 +1520,12 @@ static int make_ua(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (sdebug_verbose) cp ="reported luns data has changed" ;break ; +case SDEBUG_UA_NOT_READY_TO_READY : +mk_sense_buffer (scp,UNIT_ATTENTION ,UA_READY_ASC , +0 ); +if (sdebug_verbose) + cp ="not ready to ready transition/media change" ; +break ;default :pr_warn ("unexpected unit attention code=%d\n" , k);if (sdebug_verbose)
@@ -2204,6 +2229,14 @@ static int resp_start_stop(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) changing = (stopped_state != want_stop);if (changing)atomic_xchg (&devip->stopped, want_stop); +if (sdebug_ptype ==TYPE_TAPE && !want_stop) { +int i; + +set_bit (SDEBUG_UA_NOT_READY_TO_READY , devip->uas_bm);/* not legal! */ +for (i =0 ; i <TAPE_MAX_PARTITIONS ; i++) + devip->tape_location[i] =0 ; + devip->tape_partition =0 ; + }if (!changing || (cmd[1 ] &0x1 ))/* state unchanged or IMMED bit set in cdb */ return SDEG_RES_IMMED_MASK ;else
@@ -2736,6 +2769,17 @@ static int resp_sas_sha_m_spg(unsigned char *p, int pcontrol)return sizeof (sas_sha_m_pg); } +static unsigned char partition_pg[] = {0x11 ,12 ,1 ,0 ,0x24 ,3 ,9 ,0 , +0xff ,0xff ,0x00 ,0x00 }; + +static int resp_partition_m_pg (unsigned char *p,int pcontrol,int target) +{/* Partition page for mode_sense (tape) */ +memcpy (p, partition_pg,sizeof (partition_pg)); +if (pcontrol ==1 ) +memset (p +2 ,0 ,sizeof (partition_pg) -2 ); +return sizeof (partition_pg); +} +/* PAGE_SIZE is more than necessary but provides room for future expansion. */ #define SDEBUG_MAX_MSENSE_SZ PAGE_SIZE
@@ -2876,6 +2920,12 @@ static int resp_mode_sense(struct scsi_cmnd *scp, } offset += len;break ; +case 0x11 :/* Partition Mode Page (tape) */ +if (!is_tape) + goto bad_pcode; + len =resp_partition_m_pg (ap, pcontrol, target); + offset += len; +break ;case 0x19 :/* if spc==1 then sas phy, control+discover */ if (subpcode >0x2 && subpcode <0xff ) goto bad_subpcode;
@@ -2974,9 +3024,16 @@ static int resp_mode_select(struct scsi_cmnd *scp, mselect6 ? 3 : 6, -1);return check_condition_result; } +if (arr[off] ==TAPE_BAD_DENSITY ) { +mk_sense_invalid_fld (scp,SDEB_IN_DATA ,0 ,-1 ); +return check_condition_result; + } blksize =get_unaligned_be16 (arr + off +6 ); -if ((blksize %4 ) !=0 ) { -mk_sense_invalid_fld (scp,SDEB_IN_DATA , off +6 ,-1 ); +if (blksize !=0 && + (blksize <TAPE_MIN_BLKSIZE || + blksize >TAPE_MAX_BLKSIZE || + (blksize %4 ) !=0 )) { +mk_sense_invalid_fld (scp,SDEB_IN_DATA ,1 ,-1 );return check_condition_result; } devip->tape_density = arr[off];
@@ -3177,6 +3234,36 @@ static int resp_log_sense(struct scsi_cmnd *scp, min_t(u32, len, SDEBUG_MAX_INQ_ARR_SZ)); } +enum {SDEBUG_READ_BLOCK_LIMITS_ARR_SZ =6 }; +static int resp_read_blklimits (struct scsi_cmnd *scp, +struct sdebug_dev_info *devip) +{ +unsigned char arr[SDEBUG_READ_BLOCK_LIMITS_ARR_SZ ]; + + arr[0 ] =4 ; +put_unaligned_be24 (TAPE_MAX_BLKSIZE , arr +1 ); +put_unaligned_be16 (TAPE_MIN_BLKSIZE , arr +4 ); +return fill_from_dev_buffer (scp, arr,SDEBUG_READ_BLOCK_LIMITS_ARR_SZ ); +} + +static int resp_locate (struct scsi_cmnd *scp, +struct sdebug_dev_info *devip) +{ +unsigned char *cmd = scp->cmnd; + +if ((cmd[1 ] &0x02 ) !=0 ) { +if (cmd[8 ] >=TAPE_MAX_PARTITIONS ) { +mk_sense_invalid_fld (scp,SDEB_IN_CDB ,8 ,-1 ); +return check_condition_result; + } + devip->tape_partition = cmd[8 ]; + } + devip->tape_location[devip->tape_partition] = +get_unaligned_be32 (cmd +3 ); + +return 0 ; +} +static inline bool sdebug_dev_is_zoned (struct sdebug_dev_info *devip) {return devip->nr_zones !=0 ;
@@ -4963,7 +5050,10 @@ static int resp_sync_cache(struct scsi_cmnd *scp,* a GOOD status otherwise. Model a disk with a big cache and yield * CONDITION MET. Actually tries to bring range in main memory into the * cache associated with the CPU(s). +* +* The pcode 0x34 is also used for READ POSITION by tape devices. */ +enum {SDEBUG_READ_POSITION_ARR_SZ =20 };static int resp_pre_fetch (struct scsi_cmnd *scp,struct sdebug_dev_info *devip) {
@@ -4975,6 +5065,31 @@ static int resp_pre_fetch(struct scsi_cmnd *scp,struct sdeb_store_info *sip =devip2sip (devip, true);u8 *fsp = sip->storep; +if (sdebug_ptype ==TYPE_TAPE ) { +if (cmd[0 ] ==PRE_FETCH ) {/* READ POSITION (10) */ +int all_length; +unsigned char arr[20 ]; +unsigned int pos; + + all_length =get_unaligned_be16 (cmd +7 ); +if ((cmd[1 ] &0xfe ) !=0 || + all_length !=0 ) {/* only short form */ +mk_sense_invalid_fld (scp,SDEB_IN_CDB , + all_length ?7 :1 ,0 ); +return check_condition_result; + } +memset (arr,0 ,SDEBUG_READ_POSITION_ARR_SZ ); + arr[1 ] = devip->tape_partition; + pos = devip->tape_location[devip->tape_partition]; +put_unaligned_be32 (pos, arr +4 ); +put_unaligned_be32 (pos, arr +8 ); +return fill_from_dev_buffer (scp, arr, +SDEBUG_READ_POSITION_ARR_SZ ); + } +mk_sense_invalid_opcode (scp); +return check_condition_result; + } +if (cmd[0 ] ==PRE_FETCH ) {/* 10 byte cdb */ lba =get_unaligned_be32 (cmd +2 ); nblks =get_unaligned_be16 (cmd +7 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1248/1756 scsi: scsi_debug: Add write support with block lengths and 4 bytes of data
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai Mäkisara <[email protected]>
[ Upstream commit e1ac21310aaa5810e08b2d2a9dcee93b60ad3f87 ]
The tape is implemented as fixed number (10 000) of 8-byte units. The first four bytes of a unit contains the type of the unit (data block, filemark or end-of-data mark). If the units is a data block, the first four bytes contain the block length and the remaining four bytes the first bytes of written data. This allows the user to use tags to see that the read block is what it was supposed to be.
The tape can contain two partitions. Initially it is formatted as one partition consisting of all 10 000 units.
This patch adds the WRITE(6) command for tapes and the WRITE FILEMARKS (6) command. The REWIND command is updated.
Stable-dep-of: 92821c2358c7 ("scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state")
--- drivers/scsi/scsi_debug.c | 217 +++++++++++++++++++++++++++++++++++++- 1 file changed, 212 insertions(+), 5 deletions(-)
drivers/scsi/scsi_debug.c +212 -5
@@ -71,6 +71,10 @@ static const char *sdebug_version_date = "20210520";#define NO_ADDITIONAL_SENSE 0x0#define OVERLAP_ATOMIC_COMMAND_ASC 0x0#define OVERLAP_ATOMIC_COMMAND_ASCQ 0x23 +#define FILEMARK_DETECTED_ASCQ 0x1 +#define EOP_EOM_DETECTED_ASCQ 0x2 +#define BEGINNING_OF_P_M_DETECTED_ASCQ 0x4 +#define EOD_DETECTED_ASCQ 0x5#define LOGICAL_UNIT_NOT_READY 0x4#define LOGICAL_UNIT_COMMUNICATION_FAILURE 0x8#define UNRECOVERED_READ_ERR 0x11
@@ -83,6 +87,7 @@ static const char *sdebug_version_date = "20210520";#define UA_READY_ASC 0x28#define UA_RESET_ASC 0x29#define UA_CHANGED_ASC 0x2a +#define TOO_MANY_IN_PARTITION_ASC 0x3b#define TARGET_CHANGED_ASC 0x3f#define LUNS_CHANGED_ASCQ 0x0e#define INSUFF_RES_ASC 0x55
@@ -180,7 +185,29 @@ static const char *sdebug_version_date = "20210520";#define TAPE_DEF_BLKSIZE 0#define TAPE_MIN_BLKSIZE 512#define TAPE_MAX_BLKSIZE 1048576 +#define TAPE_EW 20#define TAPE_MAX_PARTITIONS 2 +#define TAPE_UNITS 10000 + +/* The tape block data definitions */ +#define TAPE_BLOCK_FM_FLAG ((u32)0x1 << 30) +#define TAPE_BLOCK_EOD_FLAG ((u32)0x2 << 30) +#define TAPE_BLOCK_MARK_MASK ((u32)0x3 << 30) +#define TAPE_BLOCK_SIZE_MASK (~TAPE_BLOCK_MARK_MASK) +#define TAPE_BLOCK_MARK (a) (a & TAPE_BLOCK_MARK_MASK) +#define TAPE_BLOCK_SIZE (a) (a & TAPE_BLOCK_SIZE_MASK) +#define IS_TAPE_BLOCK_FM (a) ((a & TAPE_BLOCK_FM_FLAG) != 0) +#define IS_TAPE_BLOCK_EOD (a) ((a & TAPE_BLOCK_EOD_FLAG) != 0) + +struct tape_block { +u32 fl_size; +unsigned char data[4 ]; +}; + +/* Flags for sense data */ +#define SENSE_FLAG_FILEMARK 0x80 +#define SENSE_FLAG_EOM 0x40 +#define SENSE_FLAG_ILI 0x20#define SDEBUG_LUN_0_VAL 0
@@ -377,7 +404,10 @@ struct sdebug_dev_info {unsigned int tape_blksize;unsigned int tape_density;unsigned char tape_partition; +unsigned char tape_nbr_partitions;unsigned int tape_location[TAPE_MAX_PARTITIONS ]; +unsigned int tape_eop[TAPE_MAX_PARTITIONS ]; +struct tape_block *tape_blocks[TAPE_MAX_PARTITIONS ];struct dentry *debugfs_entry;struct spinlock list_lock;
@@ -501,7 +531,8 @@ enum sdeb_opcode_index {SDEB_I_ATOMIC_WRITE_16 =32 ,SDEB_I_READ_BLOCK_LIMITS =33 ,SDEB_I_LOCATE =34 , - SDEB_I_LAST_ELEM_P1 = 35, /* keep this last (previous + 1) */ +SDEB_I_WRITE_FILEMARKS =35 , + SDEB_I_LAST_ELEM_P1 = 36, /* keep this last (previous + 1) */ };
@@ -510,8 +541,8 @@ static const unsigned char opcode_ind_arr[256] = {SDEB_I_TEST_UNIT_READY ,SDEB_I_REZERO_UNIT ,0 ,SDEB_I_REQUEST_SENSE ,0 ,SDEB_I_READ_BLOCK_LIMITS ,0 ,0 ,SDEB_I_READ ,0 ,SDEB_I_WRITE ,0 ,0 ,0 ,0 ,0 , -0 ,0 ,SDEB_I_INQUIRY ,0 ,0 ,SDEB_I_MODE_SELECT ,SDEB_I_RESERVE , -SDEB_I_RELEASE , +SDEB_I_WRITE_FILEMARKS ,0 ,SDEB_I_INQUIRY ,0 ,0 , +SDEB_I_MODE_SELECT ,SDEB_I_RESERVE ,SDEB_I_RELEASE ,0 ,0 ,SDEB_I_MODE_SENSE ,SDEB_I_START_STOP ,0 ,SDEB_I_SEND_DIAG ,SDEB_I_ALLOW_REMOVAL ,0 , /* 0x20; 0x20->0x3f: 10 byte cdbs */
@@ -593,6 +624,8 @@ static int resp_finish_zone(struct scsi_cmnd *, struct sdebug_dev_info *);static int resp_rwp_zone (struct scsi_cmnd *,struct sdebug_dev_info *);static int resp_read_blklimits (struct scsi_cmnd *,struct sdebug_dev_info *);static int resp_locate (struct scsi_cmnd *,struct sdebug_dev_info *); +static int resp_write_filemarks (struct scsi_cmnd *,struct sdebug_dev_info *); +static int resp_rewind (struct scsi_cmnd *,struct sdebug_dev_info *);static int sdebug_do_add_host (bool mk_new_store);static int sdebug_add_host_helper (int per_host_idx);
@@ -793,7 +826,7 @@ static const struct opcode_info_t opcode_info_arr[SDEB_I_LAST_ELEM_P1 + 1] = {/* 20 */ {0 ,0x1e ,0 ,0 ,NULL ,NULL ,/* ALLOW REMOVAL */ {6, 0, 0, 0, 0x3, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {0, 0x1, 0, 0, NULL, NULL, /* REWIND ?? */ + {0, 0x1, 0, 0, resp_rewind, NULL, {6, 0x1, 0, 0, 0, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {0, 0, 0, F_INV_OP | FF_RESPOND, NULL, NULL, /* ATA_PT */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
@@ -841,6 +874,8 @@ static const struct opcode_info_t opcode_info_arr[SDEB_I_LAST_ELEM_P1 + 1] = { {0 ,0x2b ,0 ,F_D_UNKN , resp_locate,NULL ,/* LOCATE (10) */ {10, 0x2, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, + {0, 0x10, 0, F_D_IN, resp_write_filemarks, NULL, /* WRITE FILEMARKS (6) */ + {6, 0x01, 0xff, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },/* sentinel */ {0xff, 0, 0, 0, NULL, NULL, /* terminating element */
@@ -1358,6 +1393,30 @@ static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) my_name, key, asc, asq); } +/* Sense data that has information fields for tapes */ +static void mk_sense_info_tape (struct scsi_cmnd *scp,int key,int asc,int asq, +unsigned int information,unsigned char tape_flags) +{ +if (!scp->sense_buffer) { +sdev_printk (KERN_ERR , scp->device, +"%s: sense_buffer is NULL\n" , __func__); +return ; + } +memset (scp->sense_buffer,0 ,SCSI_SENSE_BUFFERSIZE ); + +scsi_build_sense (scp,/* sdebug_dsense */ 0 , key, asc, asq); +/* only fixed format so far */ + + scp->sense_buffer[0 ] |=0x80 ;/* valid */ + scp->sense_buffer[2 ] |= tape_flags; +put_unaligned_be32 (information, &scp->sense_buffer[3 ]); + +if (sdebug_verbose) +sdev_printk (KERN_INFO , scp->device, +"%s: [sense_key,asc,ascq]: [0x%x,0x%x,0x%x]\n" , + my_name, key, asc, asq); +} +static void mk_sense_invalid_opcode (struct scsi_cmnd *scp) {mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_OPCODE ,0 );
@@ -3252,7 +3311,7 @@ static int resp_locate(struct scsi_cmnd *scp,unsigned char *cmd = scp->cmnd;if ((cmd[1 ] &0x02 ) !=0 ) { -if (cmd[8 ] >=TAPE_MAX_PARTITIONS ) { +if (cmd[8 ] >= devip->tape_nbr_partitions) {mk_sense_invalid_fld (scp,SDEB_IN_CDB ,8 ,-1 );return check_condition_result; }
@@ -3264,6 +3323,71 @@ static int resp_locate(struct scsi_cmnd *scp,return 0 ; } +static int resp_write_filemarks (struct scsi_cmnd *scp, +struct sdebug_dev_info *devip) +{ +unsigned char *cmd = scp->cmnd; +unsigned int i, count, pos; +u32 data; +int partition = devip->tape_partition; + +if ((cmd[1 ] &0xfe ) !=0 ) {/* probably write setmarks, not in >= SCSI-3 */ +mk_sense_invalid_fld (scp,SDEB_IN_CDB ,1 ,1 ); +return check_condition_result; + } + count =get_unaligned_be24 (cmd +2 ); + data =TAPE_BLOCK_FM_FLAG ; +for (i =0 , pos = devip->tape_location[partition]; i < count; i++, pos++) { +if (pos >= devip->tape_eop[partition] -1 ) {/* don't overwrite EOD */ + devip->tape_location[partition] = devip->tape_eop[partition] -1 ; +mk_sense_info_tape (scp,VOLUME_OVERFLOW ,NO_ADDITIONAL_SENSE , +EOP_EOM_DETECTED_ASCQ , count,SENSE_FLAG_EOM ); +return check_condition_result; + } + (devip->tape_blocks[partition] + pos)->fl_size = data; + } + (devip->tape_blocks[partition] + pos)->fl_size = +TAPE_BLOCK_EOD_FLAG ; + devip->tape_location[partition] = pos; + +return 0 ; +} + +static int resp_rewind (struct scsi_cmnd *scp, +struct sdebug_dev_info *devip) +{ + devip->tape_location[devip->tape_partition] =0 ; + +return 0 ; +} + +static int partition_tape (struct sdebug_dev_info *devip,int nbr_partitions, +int part_0_size,int part_1_size) +{ +int i; + +if (part_0_size + part_1_size >TAPE_UNITS ) +return -1 ; + devip->tape_eop[0 ] = part_0_size; + devip->tape_blocks[0 ]->fl_size =TAPE_BLOCK_EOD_FLAG ; + devip->tape_eop[1 ] = part_1_size; + devip->tape_blocks[1 ] = devip->tape_blocks[0 ] + + devip->tape_eop[0 ]; + devip->tape_blocks[1 ]->fl_size =TAPE_BLOCK_EOD_FLAG ; + +for (i =0 ; i <TAPE_MAX_PARTITIONS ; i++) + devip->tape_location[i] =0 ; + + devip->tape_nbr_partitions = nbr_partitions; + devip->tape_partition =0 ; + + partition_pg[3 ] = nbr_partitions -1 ; +put_unaligned_be16 (devip->tape_eop[0 ], partition_pg +8 ); +put_unaligned_be16 (devip->tape_eop[1 ], partition_pg +10 ); + +return nbr_partitions; +} +static inline bool sdebug_dev_is_zoned (struct sdebug_dev_info *devip) {return devip->nr_zones !=0 ;
@@ -4309,6 +4433,67 @@ static void unmap_region(struct sdeb_store_info *sip, sector_t lba, } } +static int resp_write_tape (struct scsi_cmnd *scp,struct sdebug_dev_info *devip) +{ +u32 i, num, transfer, size, written =0 ; +u8 *cmd = scp->cmnd; +struct scsi_data_buffer *sdb = &scp->sdb; +int partition = devip->tape_partition; +int pos = devip->tape_location[partition]; +struct tape_block *blp; +bool fixed, ew; + +if (cmd[0 ] !=WRITE_6 ) {/* Only Write(6) supported */ +mk_sense_invalid_opcode (scp); +return illegal_condition_result; + } + + fixed = (cmd[1 ] &1 ) !=0 ; + transfer =get_unaligned_be24 (cmd +2 ); +if (fixed) { + num = transfer; + size = devip->tape_blksize; + }else { +if (transfer <TAPE_MIN_BLKSIZE || + transfer >TAPE_MAX_BLKSIZE ) { +mk_sense_invalid_fld (scp,SDEB_IN_CDB ,2 ,-1 ); +return check_condition_result; + } + num =1 ; + size = transfer; + } + +scsi_set_resid (scp, num * transfer); +for (i =0 , blp = devip->tape_blocks[partition] + pos, ew = false; + i < num && pos < devip->tape_eop[partition] -1 ; i++, pos++, blp++) { + blp->fl_size = size; +sg_copy_buffer (sdb->table.sgl, sdb->table.nents, + &(blp->data),4 , i * size, true); + written += size; +scsi_set_resid (scp, num * transfer - written); + ew |= (pos == devip->tape_eop[partition] -TAPE_EW ); + } + + devip->tape_location[partition] = pos; + blp->fl_size =TAPE_BLOCK_EOD_FLAG ; +if (pos >= devip->tape_eop[partition] -1 ) { +mk_sense_info_tape (scp,VOLUME_OVERFLOW , +NO_ADDITIONAL_SENSE ,EOP_EOM_DETECTED_ASCQ , + fixed ? num - i : transfer, +SENSE_FLAG_EOM ); +return check_condition_result; + } +if (ew) {/* early warning */ +mk_sense_info_tape (scp,NO_SENSE , +NO_ADDITIONAL_SENSE ,EOP_EOM_DETECTED_ASCQ , + fixed ? num - i : transfer, +SENSE_FLAG_EOM ); +return check_condition_result; + } + +return 0 ; +} +static int resp_write_dt0 (struct scsi_cmnd *scp,struct sdebug_dev_info *devip) {bool check_prot;
@@ -4321,6 +4506,9 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)u8 *cmd = scp->cmnd;bool meta_data_locked = false; +if (sdebug_ptype ==TYPE_TAPE ) +return resp_write_tape (scp, devip); +switch (cmd[0 ]) {case WRITE_16 : ei_lba =0 ;
@@ -6093,6 +6281,20 @@ static int scsi_debug_slave_configure(struct scsi_device *sdp)if (devip ==NULL )return 1 ;/* no resources, will be marked offline */ } +if (sdebug_ptype ==TYPE_TAPE ) { +if (!devip->tape_blocks[0 ]) { + devip->tape_blocks[0 ] = +kcalloc (TAPE_UNITS ,sizeof (struct tape_block ), +GFP_KERNEL ); +if (!devip->tape_blocks[0 ]) +return 1 ; + } +if (partition_tape (devip,1 ,TAPE_UNITS ,0 ) <0 ) { +kfree (devip->tape_blocks[0 ]); + devip->tape_blocks[0 ] =NULL ; +return 1 ; + } + } sdp->hostdata = devip;if (sdebug_no_uld) sdp->no_uld_attach =1 ;
@@ -6138,6 +6340,11 @@ static void scsi_debug_slave_destroy(struct scsi_device *sdp)debugfs_remove (devip->debugfs_entry); +if (sdebug_ptype ==TYPE_TAPE ) { +kfree (devip->tape_blocks[0 ]); + devip->tape_blocks[0 ] =NULL ; + } +/* make this slot available for re-use */ devip->used = false; sdp->hostdata =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1249/1756 scsi: libsas: Add dev_parent_is_expander() helper
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit e5eb72c92eb724aa14c50c7d92d1a576dd50d7e6 ]
Many libsas drivers check if the parent of the device is an expander. Create a helper that the libsas drivers will use in follow up commits.
Stable-dep-of: 92821c2358c7 ("scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state")
--- drivers/scsi/libsas/sas_expander.c | 5 +---- include/scsi/libsas.h | 8 ++++++++ 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/scsi/libsas/sas_expander.c +1 -4
@@ -1317,10 +1317,7 @@ static int sas_check_parent_topology(struct domain_device *child)int i;int res =0 ; -if (!child->parent) -return 0 ; - -if (!dev_is_expander (child->parent->dev_type)) +if (!dev_parent_is_expander (child))return 0 ; parent_ex = &child->parent->ex_dev;
include/scsi/libsas.h +8 -0
@@ -203,6 +203,14 @@ static inline bool dev_is_expander(enum sas_device_type type) type ==SAS_FANOUT_EXPANDER_DEVICE ; } +static inline bool dev_parent_is_expander (struct domain_device *dev) +{ +if (!dev->parent) +return false; + +return dev_is_expander (dev->parent->dev_type); +} +static inline void INIT_SAS_WORK (struct sas_work *sw,void (*fn)(struct work_struct *)) {INIT_WORK (&sw->work, fn);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1250/1756 scsi: scsi_debug: move ASC and ASCQ definitions to scsi_proto.h
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 7c8b3f6578bb874ba9d334aef0e51fe931ce6c04 ]
The scsi_debug driver internally defines lots of SCSI additional sense codes (ASC) and additional sense code qualifiers (ASCQ). Move these definitions to include/scsi/scsi_proto.h so that they can be reused elsewhere in the SCSI and ATA code. This also makes the scsi_debug.c file a little smaller.
Stable-dep-of: 92821c2358c7 ("scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state")
--- drivers/scsi/scsi_debug.c | 46 ----------------------------------- include/scsi/scsi_proto.h | 51 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 46 deletions(-)
drivers/scsi/scsi_debug.c +0 -46
@@ -67,52 +67,6 @@ static const char *sdebug_version_date = "20210520";#define MY_NAME "scsi_debug" -/* Additional Sense Code (ASC) */ -#define NO_ADDITIONAL_SENSE 0x0 -#define OVERLAP_ATOMIC_COMMAND_ASC 0x0 -#define OVERLAP_ATOMIC_COMMAND_ASCQ 0x23 -#define FILEMARK_DETECTED_ASCQ 0x1 -#define EOP_EOM_DETECTED_ASCQ 0x2 -#define BEGINNING_OF_P_M_DETECTED_ASCQ 0x4 -#define EOD_DETECTED_ASCQ 0x5 -#define LOGICAL_UNIT_NOT_READY 0x4 -#define LOGICAL_UNIT_COMMUNICATION_FAILURE 0x8 -#define UNRECOVERED_READ_ERR 0x11 -#define PARAMETER_LIST_LENGTH_ERR 0x1a -#define INVALID_OPCODE 0x20 -#define LBA_OUT_OF_RANGE 0x21 -#define INVALID_FIELD_IN_CDB 0x24 -#define INVALID_FIELD_IN_PARAM_LIST 0x26 -#define WRITE_PROTECTED 0x27 -#define UA_READY_ASC 0x28 -#define UA_RESET_ASC 0x29 -#define UA_CHANGED_ASC 0x2a -#define TOO_MANY_IN_PARTITION_ASC 0x3b -#define TARGET_CHANGED_ASC 0x3f -#define LUNS_CHANGED_ASCQ 0x0e -#define INSUFF_RES_ASC 0x55 -#define INSUFF_RES_ASCQ 0x3 -#define POWER_ON_RESET_ASCQ 0x0 -#define POWER_ON_OCCURRED_ASCQ 0x1 -#define BUS_RESET_ASCQ 0x2/* scsi bus reset occurred */ -#define MODE_CHANGED_ASCQ 0x1/* mode parameters changed */ -#define CAPACITY_CHANGED_ASCQ 0x9 -#define SAVING_PARAMS_UNSUP 0x39 -#define TRANSPORT_PROBLEM 0x4b -#define THRESHOLD_EXCEEDED 0x5d -#define LOW_POWER_COND_ON 0x5e -#define MISCOMPARE_VERIFY_ASC 0x1d -#define MICROCODE_CHANGED_ASCQ 0x1/* with TARGET_CHANGED_ASC */ -#define MICROCODE_CHANGED_WO_RESET_ASCQ 0x16 -#define WRITE_ERROR_ASC 0xc -#define UNALIGNED_WRITE_ASCQ 0x4 -#define WRITE_BOUNDARY_ASCQ 0x5 -#define READ_INVDATA_ASCQ 0x6 -#define READ_BOUNDARY_ASCQ 0x7 -#define ATTEMPT_ACCESS_GAP 0x9 -#define INSUFF_ZONE_ASCQ 0xe -/* see drivers/scsi/sense_codes.h */ -/* Additional Sense Code Qualifier (ASCQ) */ #define ACK_NAK_TO 0x3
include/scsi/scsi_proto.h +51 -0
57 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1251/1756 scsi: core: Define all additional sense codes and their qualifiers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 72c54bd0cbb2e0c35f4acd056e91c596469edc5f ]
Introduce the file include/scsi/scsi_sense.h to define all existing additional sense codes and their combinations with additional sense code qualifiers, according to the most current T10 list available at
https://www.t10.org/lists/asc-num.txt.
Additional sense codes (ASCs) are individually defined as an 8-bit value with the ASC_ name prefix. The combination of all ASCs with T10 defined possible code qualifiers are defined as 16-bit values without any name prefix. The 16-bit value for ASCs with a zero ASCQ are defined together with the ASC 8-code using the ASC() macro. For names that may potentially create conflicts with other subsystems (e.g. WARNING or WRITE_ERROR), the SSC_ prefix is added to the sense code name.
The sense key macro definitions in include/scsi/scsi_proto.h are also moved into this new file and scsi_sense.h is included in scsi_proto.h. The helper function scsi_sense_code() is defined to facilitate generating a 16-bit sense code from the 8-bit ASC and ASCQ. The accessors scsi_sense_code_asc() and scsi_sense_code_ascq() are defined for the reverse operations, that is, to respectively extract an ASC and an ASCQ from a 16-bit sense code.
Stable-dep-of: 92821c2358c7 ("scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state")
--- include/scsi/scsi_proto.h | 20 +- include/scsi/scsi_sense.h | 950 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 951 insertions(+), 19 deletions(-) create mode 100644 include/scsi/scsi_sense.h
include/scsi/scsi_proto.h +1 -19
@@ -12,6 +12,7 @@#include <linux/build_bug.h> #include <linux/types.h> +#include <scsi/scsi_sense.h> /* * SCSI opcodes
@@ -214,25 +215,6 @@ enum sam_status {#define STATUS_MASK 0xfe -/* -* SENSE KEYS -*/ -#define NO_SENSE 0x00 -#define RECOVERED_ERROR 0x01 -#define NOT_READY 0x02 -#define MEDIUM_ERROR 0x03 -#define HARDWARE_ERROR 0x04 -#define ILLEGAL_REQUEST 0x05 -#define UNIT_ATTENTION 0x06 -#define DATA_PROTECT 0x07 -#define BLANK_CHECK 0x08 -#define VENDOR_SPECIFIC 0x09 -#define COPY_ABORTED 0x0a -#define ABORTED_COMMAND 0x0b -#define VOLUME_OVERFLOW 0x0d -#define MISCOMPARE 0x0e -#define COMPLETED 0x0f -/* * Additional Sense Codes (ASC). */
include/scsi/scsi_sense.h new file +950 -0
950 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1252/1756 scsi: core: Rename sense field of struct scsi_failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 45cdf8164237277e52af5d8aa4218c3cb6199bf2 ]
Rename the sense field of struct scsi_failure to sense_key. This makes it clear that this field stores the sense key, and also unifies this structure field names with the names used in struct scsi_sense_hdr.
To be consistent with this change, the macro SCMD_FAILURE_SENSE_ANY is renamed SCMD_FAILURE_SENSE_KEY_ANY.
Of note is that the definition of the array any_sense_failure_defs in scsi_lib_test_any_sense() is modified to change the initialization of the result field to use SCMD_FAILURE_RESULT_ANY and add the .sense_key field initialization to SCMD_FAILURE_SENSE_KEY_ANY to match the test target case.
Stable-dep-of: 92821c2358c7 ("scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state")
--- drivers/scsi/ch.c | 2 +- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 4 ++-- drivers/scsi/device_handler/scsi_dh_rdac.c | 10 ++++----- drivers/scsi/scsi_lib.c | 6 ++--- drivers/scsi/scsi_lib_test.c | 25 +++++++++++---------- drivers/scsi/scsi_scan.c | 8 +++---- drivers/scsi/scsi_transport_spi.c | 2 +- drivers/scsi/sd.c | 20 ++++++++--------- drivers/scsi/ses.c | 8 +++---- include/scsi/scsi_device.h | 12 +++++----- 10 files changed, 49 insertions(+), 48 deletions(-)
drivers/scsi/ch.c +1 -1
@@ -190,7 +190,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,struct scsi_sense_hdr sshdr;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =3 ,
drivers/scsi/device_handler/scsi_dh_hp_sw.c +2 -2
@@ -84,7 +84,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)REQ_FAILFAST_TRANSPORT |REQ_FAILFAST_DRIVER ;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SCMD_FAILURE_NO_LIMIT ,
@@ -138,7 +138,7 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)* * Switch-over in progress, retry. */ - .sense = NOT_READY, + .sense_key = NOT_READY, .asc = 0x04, .ascq = 0x03, .allowed = HP_SW_RETRIES,
drivers/scsi/device_handler/scsi_dh_rdac.c +5 -5
@@ -514,33 +514,33 @@ static void send_mode_select(struct work_struct *work)REQ_FAILFAST_TRANSPORT |REQ_FAILFAST_DRIVER ;struct scsi_failure failure_defs[] = { { - .sense =NO_SENSE , + .sense_key =NO_SENSE , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =ABORTED_COMMAND , + .sense_key =ABORTED_COMMAND , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* LUN Not Ready and is in the Process of Becoming Ready */ { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x04 , .ascq =0x01 , .result =SAM_STAT_CHECK_CONDITION , },/* Command Lock contention */ { - .sense =ILLEGAL_REQUEST , + .sense_key =ILLEGAL_REQUEST , .asc =0x91 , .ascq =0x36 , .allowed =SCMD_FAILURE_NO_LIMIT ,
drivers/scsi/scsi_lib.c +3 -3
@@ -237,13 +237,13 @@ static int scsi_check_passthrough(struct scsi_cmnd *scmd,continue ;if (status_byte (failure->result) !=SAM_STAT_CHECK_CONDITION || - failure->sense ==SCMD_FAILURE_SENSE_ANY ) + failure->sense_key ==SCMD_FAILURE_SENSE_KEY_ANY ) goto maybe_retry;if (!scsi_command_normalize_sense (scmd, &sshdr))return 0 ; -if (failure->sense != sshdr.sense_key) +if (failure->sense_key != sshdr.sense_key)continue ;if (failure->asc ==SCMD_FAILURE_ASC_ANY )
@@ -2304,7 +2304,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, int subpage,struct scsi_sense_hdr my_sshdr;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed = retries,
drivers/scsi/scsi_lib_test.c +13 -12
@@ -17,40 +17,40 @@ static void scsi_lib_test_multiple_sense(struct kunit *test) {struct scsi_failure multiple_sense_failure_defs[] = { { - .sense =DATA_PROTECT , + .sense_key =DATA_PROTECT , .asc =0x1 , .ascq =0x1 , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x11 , .ascq =0x0 , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x11 , .ascq =0x22 , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =ABORTED_COMMAND , + .sense_key =ABORTED_COMMAND , .asc =0x11 , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =HARDWARE_ERROR , + .sense_key =HARDWARE_ERROR , .asc =SCMD_FAILURE_ASC_ANY , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =ILLEGAL_REQUEST , + .sense_key =ILLEGAL_REQUEST , .asc =0x91 , .ascq =0x36 , .allowed =SCSI_LIB_TEST_MAX_ALLOWED ,
@@ -109,8 +109,9 @@ static void scsi_lib_test_any_sense(struct kunit *test) {struct scsi_failure any_sense_failure_defs[] = { { - .result =SCMD_FAILURE_SENSE_ANY , + .sense_key =SCMD_FAILURE_SENSE_KEY_ANY , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , + .result =SCMD_FAILURE_RESULT_ANY , }, {} };
@@ -122,7 +123,7 @@ static void scsi_lib_test_any_sense(struct kunit *test) .sense_buffer = sense, }; -/* Match using SCMD_FAILURE_SENSE_ANY */ +/* Match using SCMD_FAILURE_SENSE_KEY_ANY */ failures.failure_definitions = any_sense_failure_defs;scsi_build_sense (&sc,0 ,MEDIUM_ERROR ,0x11 ,0x22 );KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures));
@@ -208,14 +209,14 @@ static void scsi_lib_test_total_allowed(struct kunit *test) {struct scsi_failure total_allowed_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Fail all CCs except the UA above */ { - .sense =SCMD_FAILURE_SENSE_ANY , + .sense_key =SCMD_FAILURE_SENSE_KEY_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Retry any other errors not listed above */
@@ -252,12 +253,12 @@ static void scsi_lib_test_mixed_total(struct kunit *test) {struct scsi_failure mixed_total_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x28 , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .result =SAM_STAT_CHECK_CONDITION , },
drivers/scsi/scsi_scan.c +4 -4
@@ -653,12 +653,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,* so anyway. */ { - .sense = UNIT_ATTENTION, + .sense_key = UNIT_ATTENTION, .asc = 0x28, .result = SAM_STAT_CHECK_CONDITION, }, { - .sense = UNIT_ATTENTION, + .sense_key = UNIT_ATTENTION, .asc = 0x29, .result = SAM_STAT_CHECK_CONDITION, },
@@ -1426,14 +1426,14 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflagstruct Scsi_Host *shost =dev_to_shost (&starget->dev);struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Fail all CCs except the UA above */ { - .sense =SCMD_FAILURE_SENSE_ANY , + .sense_key =SCMD_FAILURE_SENSE_KEY_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Retry any other errors not listed above */
drivers/scsi/scsi_transport_spi.c +1 -1
@@ -112,7 +112,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,REQ_FAILFAST_DRIVER ;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =DV_RETRIES ,
drivers/scsi/sd.c +10 -10
@@ -1944,7 +1944,7 @@ static int sd_pr_in_command(struct block_device *bdev, u8 sa,u8 cmd[10 ] = {PERSISTENT_RESERVE_IN , sa };struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =5 ,
@@ -2046,7 +2046,7 @@ static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key,struct scsi_sense_hdr sshdr;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =5 ,
@@ -2410,13 +2410,13 @@ sd_spinup_disk(struct scsi_disk *sdkp)struct scsi_failure failure_defs[] = {/* Do not retry Medium Not Present */ { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x3A , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x3A , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION ,
@@ -2733,18 +2733,18 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,struct scsi_failure failure_defs[] = {/* Do not retry Medium Not Present */ { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x3A , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x3A , .result =SAM_STAT_CHECK_CONDITION , },/* Device reset might occur several times so retry a lot */ { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .allowed =READ_CAPACITY_RETRIES_ON_RESET , .result =SAM_STAT_CHECK_CONDITION ,
@@ -4107,21 +4107,21 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)struct scsi_failure failure_defs[] = { {/* Power on, reset, or bus device reset occurred */ - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =0 , .result =SAM_STAT_CHECK_CONDITION , }, {/* Power on occurred */ - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =1 , .result =SAM_STAT_CHECK_CONDITION , }, {/* SCSI bus reset */ - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =2 , .result =SAM_STAT_CHECK_CONDITION ,
drivers/scsi/ses.c +4 -4
@@ -89,14 +89,14 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,unsigned char recv_page_code;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES ,
@@ -146,14 +146,14 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code, };struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES ,
include/scsi/scsi_device.h +6 -6
@@ -500,18 +500,18 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);*/ #define SCMD_FAILURE_STAT_ANY 0xff/* -* The following can be set to the scsi_failure sense, asc and ascq fields to -* match on any sense, ASC, or ASCQ value. +* The following can be set to the scsi_failure sense key, asc and ascq fields +* to match any sense key, ASC, and ASCQ value. */ -#define SCMD_FAILURE_SENSE_ANY 0xff -#define SCMD_FAILURE_ASC_ANY 0xff -#define SCMD_FAILURE_ASCQ_ANY 0xff +#define SCMD_FAILURE_SENSE_KEY_ANY 0xff +#define SCMD_FAILURE_ASC_ANY 0xff +#define SCMD_FAILURE_ASCQ_ANY 0xff/* Always retry a matching failure. */ #define SCMD_FAILURE_NO_LIMIT -1struct scsi_failure {int result; -u8 sense; +u8 sense_key;u8 asc;u8 ascq;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1253/1756 scsi: core: Prepare for using combined sense codes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit ec5562d3ea803ec45831477129c626b2a22d2e2c ]
In preparation for handling sense codes and their qualifers as a single 16-bit sense code field, with the values defined as macros in include/scsi/scsi_sense.h, modify the definition of the structures scsi_failure and scsi_sense_hdr to introduce a 16-bit sense_code field as a union with the existing 8-bit asc and ascq fields.
This temporary modification allows accessing either the asc and ascq fields individually, or their combination as the 16-bit sense_code field.
The helper functions scsi_sense_asc(), scsi_sense_ascq() are defined to allow accessing the 8-bit ASC and ASCQ values from the sense_code filed of struct scsi_sense_hdr. The helper functions scsi_failure_asc() and scsi_failure_ascq() provide the same for the sense code field of struct scsi_failure.
The helper functions scsi_set_sense_buffer() and scsi_set_sense() are also added to wrap calls to scsi_build_sense_buffer() and scsi_build_sense() using a 16-bit sense code argument instead of the 8-bit ASC and ASCQ arguments.
Stable-dep-of: 92821c2358c7 ("scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state")
--- include/scsi/scsi_cmnd.h | 7 +++++++ include/scsi/scsi_common.h | 31 +++++++++++++++++++++++++++++-- include/scsi/scsi_device.h | 25 +++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 4 deletions(-)
include/scsi/scsi_cmnd.h +7 -0
@@ -394,6 +394,13 @@ static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)extern void scsi_build_sense (struct scsi_cmnd *scmd,int desc,u8 key,u8 asc,u8 ascq); +static inline void scsi_set_sense (struct scsi_cmnd *scmd,int desc, +u8 key,u16 code) +{ +scsi_build_sense (scmd, desc, key,scsi_sense_code_asc (code), +scsi_sense_code_ascq (code)); +} +struct request *scsi_alloc_request (struct request_queue *q,blk_opf_t opf,blk_mq_req_flags_t flags);
include/scsi/scsi_common.h +29 -2
@@ -63,8 +63,18 @@ extern u64 scsilun_to_int(struct scsi_lun *);struct scsi_sense_hdr {/* See SPC-3 section 4.5 */ u8 response_code;/* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */ u8 sense_key; -u8 asc; -u8 ascq; +union { +struct { +#if defined(__BIG_ENDIAN) +u8 asc; +u8 ascq; +#elif defined(__LITTLE_ENDIAN) +u8 ascq; +u8 asc; +#endif + }; +u16 sense_code; + };u8 byte4;u8 byte5;u8 byte6;
@@ -79,10 +89,27 @@ static inline bool scsi_sense_valid(const struct scsi_sense_hdr *sshdr)return (sshdr->response_code &0x70 ) ==0x70 ; } +static inline u8 scsi_sense_asc (const struct scsi_sense_hdr *sshdr) +{ +return scsi_sense_code_asc (sshdr->sense_code); +} + +static inline u8 scsi_sense_ascq (const struct scsi_sense_hdr *sshdr) +{ +return scsi_sense_code_ascq (sshdr->sense_code); +} +extern bool scsi_normalize_sense (const u8 *sense_buffer,int sb_len,struct scsi_sense_hdr *sshdr);extern void scsi_build_sense_buffer (int desc,u8 *buf,u8 key,u8 asc,u8 ascq); + +static inline void scsi_set_sense_buffer (int desc,u8 *buf,u8 key,u16 code) +{ +scsi_build_sense_buffer (desc, buf, key,scsi_sense_code_asc (code), +scsi_sense_code_ascq (code)); +} +int scsi_set_sense_information (u8 *buf,int buf_len,u64 info);int scsi_set_sense_field_pointer (u8 *buf,int buf_len,u16 fp,u8 bp,bool cd); extern const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len,
include/scsi/scsi_device.h +23 -2
@@ -504,6 +504,7 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);* to match any sense key, ASC, and ASCQ value. */ #define SCMD_FAILURE_SENSE_KEY_ANY 0xff +#define SCMD_FAILURE_SENSE_CODE_ANY 0xffff#define SCMD_FAILURE_ASC_ANY 0xff#define SCMD_FAILURE_ASCQ_ANY 0xff/* Always retry a matching failure. */
@@ -512,8 +513,18 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);struct scsi_failure {int result;u8 sense_key; -u8 asc; -u8 ascq; +union { +struct { +#if defined(__BIG_ENDIAN) +u8 asc; +u8 ascq; +#elif defined(__LITTLE_ENDIAN) +u8 ascq; +u8 asc; +#endif + }; +u16 sense_code; + };/* * Number of times scsi_execute_cmd will retry the failure. It does * not count for the total_allowed.
@@ -523,6 +534,16 @@ struct scsi_failure {s8 retries; }; +static inline u8 scsi_failure_asc (const struct scsi_failure *failure) +{ +return scsi_sense_code_asc (failure->sense_code); +} + +static inline u8 scsi_failure_ascq (const struct scsi_failure *failure) +{ +return scsi_sense_code_ascq (failure->sense_code); +} +struct scsi_failures {/* * If a scsi_failure does not have a retry limit setup this limit will
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1254/1756 scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
[ Upstream commit 92821c2358c78345909889793918af8763808bd4 ]
SAS HDDs powered up with RNOT=1 wait in Active_Wait state for a NOTIFY(ENABLE SPINUP) primitive and keep returning NOT_READY with ASC/ASCQ 0x04/0x11, causing endless mid-layer retries and spinup failure.
Parse the sense data in the slot completion path and, when LU_NOT_READY_NOTIFY_REQUIRED is returned by a directly-attached SSP device, queue work that sends the primitive from process context (sl_notify_ssp() contains msleep()). The work takes a runtime PM reference with pm_runtime_get_if_active(), pairing with pm_runtime_put_sync() in the work, so the controller stays resumed until the primitive is sent.
--- drivers/scsi/hisi_sas/hisi_sas.h | 3 ++ drivers/scsi/hisi_sas/hisi_sas_main.c | 43 ++++++++++++++++++++++++++ drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 4 +++ drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 4 +++ drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 4 +++ 5 files changed, 58 insertions(+)
drivers/scsi/hisi_sas/hisi_sas.h +3 -0
@@ -163,6 +163,7 @@ enum hisi_sas_phy_event {HISI_PHYE_PHY_UP =0U ,HISI_PHYE_LINK_RESET ,HISI_PHYE_PHY_UP_PM , +HISI_PHYE_SPINUP_NOTIFY , HISI_PHYES_NUM, };
@@ -690,4 +691,6 @@ extern void hisi_sas_sync_cqs(struct hisi_hba *hisi_hba);extern void hisi_sas_sync_poll_cqs (struct hisi_hba *hisi_hba);extern void hisi_sas_controller_reset_prepare (struct hisi_hba *hisi_hba);extern void hisi_sas_controller_reset_done (struct hisi_hba *hisi_hba); +extern void hisi_sas_spinup_notify (struct hisi_hba *hisi_hba, +struct sas_task *task);#endif
drivers/scsi/hisi_sas/hisi_sas_main.c +43 -0
59 lines not on this page · raw message
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +4 -0
@@ -1272,6 +1272,10 @@ static void slot_complete_v1_hw(struct hisi_hba *hisi_hba, &status_buffer->iu[0 ];sas_ssp_task_response (dev, task, iu); +if (unlikely (ts->stat ==SAS_SAM_STAT_CHECK_CONDITION && + !dev_parent_is_expander (device))) +hisi_sas_spinup_notify (hisi_hba, task); +break ; }case SAS_PROTOCOL_SMP :
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +4 -0
@@ -2428,6 +2428,10 @@ static void slot_complete_v2_hw(struct hisi_hba *hisi_hba, &status_buffer->iu[0 ];sas_ssp_task_response (dev, task, iu); +if (unlikely (ts->stat ==SAS_SAM_STAT_CHECK_CONDITION && + !dev_parent_is_expander (device))) +hisi_sas_spinup_notify (hisi_hba, task); +break ; }case SAS_PROTOCOL_SMP :
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +4 -0
@@ -2436,6 +2436,10 @@ static void slot_complete_v3_hw(struct hisi_hba *hisi_hba,sizeof (struct hisi_sas_err_record );sas_ssp_task_response (dev, task, iu); +if (unlikely (ts->stat ==SAS_SAM_STAT_CHECK_CONDITION && + !dev_parent_is_expander (device))) +hisi_sas_spinup_notify (hisi_hba, task); +break ; }case SAS_PROTOCOL_SMP : {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1255/1756 spmi: pmic-arb: return 0 in spmi_pmic_arb_register_buses() on success
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fenglin Wu <[email protected]>
[ Upstream commit 82f4c1948a4f951d7d501757a31c6a10eccd37ae ]
The "ret" could be returned with an uninitialized value. Fix it.
--- drivers/spmi/spmi-pmic-arb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spmi/spmi-pmic-arb.c +1 -1
@@ -1777,7 +1777,7 @@ static int spmi_pmic_arb_register_buses(struct spmi_pmic_arb *pmic_arb, } } -return ret; +return 0 ; }static void spmi_pmic_arb_deregister_buses (struct spmi_pmic_arb *pmic_arb)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1256/1756 dt-bindings: vendor-prefixes: add Ambarella
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Zhao <[email protected]>
[ Upstream commit 5ef299ffb56531b3a4f2b311000da76beed403ee ]
Document the Ambarella, Inc. vendor prefix so Ambarella DT bindings can be applied without waiting for the SoC series.
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -101,6 +101,8 @@ patternProperties: description: Amarula Solutions "^amazon,.*": description: Amazon.com, Inc. + "^ambarella,.*": + description: Ambarella, Inc. "^amcc,.*": description: Applied Micro Circuits Corporation (APM, formally AMCC) "^amd,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1257/1756 ata: libahci: re-enable FBS after error handling on a port multiplier
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyrylo Biryuk <[email protected]>
[ Upstream commit 23eab9e877497397a0e2394ee9174d576816209e ]
ahci_do_softreset() disables FBS before resetting a device behind a port multiplier, as required by AHCI 1.2 section 9.3.9, and re-enables it only when that softreset succeeds. If it fails, for example because a hot-plugged drive is still spinning up ("softreset failed (device not ready)"), EH escalates to a hardreset of the PMP link, and nothing turns FBS back on: only ahci_pmp_attach() does, which runs at the next boot. The port keeps working with command-based switching until then.
Seen on a Marvell 88SE9235 (1b4b:9235) with Marvell 88SM9705 port multipliers (1b4b:9705, in a Synology DX1222 expansion unit): after hot-plugging a drive, the kernel logged "FBS is disabled" followed by "softreset failed (device not ready)" and a PMP hardreset, and never "FBS is enabled" again (twice, on two different ports).
At the end of ahci_error_handler(), re-enable FBS if a PMP is still attached and FBS is supported but disabled.
--- drivers/ata/libahci.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/ata/libahci.c +15 -0
@@ -2236,6 +2236,21 @@ void ahci_error_handler(struct ata_port *ap)sata_pmp_error_handler (ap); +/* +* ahci_do_softreset() turns FBS off before resetting a fan-out link +* and turns it back on only if that reset succeeds. When it fails +* (e.g. a hot-plugged drive is still spinning up), EH escalates to a +* PMP hardreset, which never re-enables FBS, so the port would keep +* command-based switching until the PMP is attached again (reboot). +* Restore FBS once recovery is done and the PMP is still attached. +*/ +if (sata_pmp_attached (ap) &&ata_dev_enabled (ap->link.device)) { +struct ahci_port_priv *pp = ap->private_data; + +if (pp->fbs_supported && !pp->fbs_enabled) +ahci_enable_fbs (ap); + } +if (!ata_dev_enabled (ap->link.device)) hpriv->stop_engine (ap); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1258/1756 net: axienet: free outstanding TX buffers in axienet_dma_bd_release()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sagi Maimon <[email protected]>
[ Upstream commit 0c20cb4cfb40cf270d6c4c2c2ff5e5d72322644a ]
axienet_dma_bd_release() walks the RX ring to unmap and free every receive buffer before releasing it, but frees the TX descriptor ring with dma_free_coherent() alone. Any descriptor that axienet_free_tx_chain() had not yet reclaimed still holds its skb and its streaming DMA mapping, and both are lost.
axienet_stop() disables TX NAPI and stops the DMA engine before calling it, so nothing reclaims those descriptors afterwards. Bringing the interface down while frames are in flight therefore leaks up to lp->tx_bd_num skbs and mappings each time.
axienet_dma_err_handler() already walks the TX ring this way before it restarts the DMA engine: it unmaps every descriptor whose cntrl is still set - axienet_free_tx_chain() clears it on reclaim - frees any skb still attached, and clears the descriptor. Move that loop into a helper, axienet_free_tx_bufs(), and call it from axienet_dma_bd_release() too. This relies on axienet_stop() having stopped the DMA engine first, as the RX walk in the same function already does. The helper frees the skbs with dev_kfree_skb_any(), as drops: in the error handler, which runs from a workqueue, that frees them directly rather than deferring them to softirq as dev_kfree_skb_irq() did.
The walk must not run on a ring that is not there. axienet_open() does not check the result of the reset that runs axienet_dma_bd_init(), so when that reset fails tx_bd_v is either still NULL or, after an earlier close, points at the ring that close freed. Clear tx_bd_v and rx_bd_v once their rings are freed, and skip the walk when tx_bd_v is NULL. That also ends the second dma_free_coherent() of a stale ring which the same path already did. On the axienet_dma_bd_init() error path the TX ring has just been allocated zeroed, so the walk does nothing.
This was reported by the Sashiko AI review bot.
Tested on the AXI Ethernet MAC of an ADVA TimeCard X2 (PCIe card, with the built-in AXI DMA): traffic passes, and after each of ten down/up cycles and five module reloads, all made with traffic running and each running axienet_dma_bd_release(), traffic resumes and nothing is logged. The leak itself was not measured, and neither the failed-reset paths nor axienet_dma_err_handler() were exercised.
--- .../net/ethernet/xilinx/xilinx_axienet_main.c | 74 +++++++++++++------ 1 file changed, 50 insertions(+), 24 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +50 -24
@@ -173,6 +173,46 @@ static dma_addr_t desc_get_phys_addr(struct axienet_local *lp,return ret; } +/** +* axienet_free_tx_bufs - Release the buffers still held by the TX ring +* @lp: Pointer to the axienet_local structure +* +* Unmap every descriptor whose mapping is still live, free any skb still +* attached, and clear the descriptor for reuse. axienet_free_tx_chain() +* clears cntrl when it reclaims a descriptor, so a non-zero value means +* the mapping is live. The DMA engine must be stopped. +*/ +static void axienet_free_tx_bufs (struct axienet_local *lp) +{ +struct axidma_bd *cur_p; +u32 i; + +for (i =0 ; i < lp->tx_bd_num; i++) { + cur_p = &lp->tx_bd_v[i]; +if (cur_p->cntrl) { +dma_addr_t addr =desc_get_phys_addr (lp, cur_p); + +dma_unmap_single (lp->dev, addr, + (cur_p->cntrl & +XAXIDMA_BD_CTRL_LENGTH_MASK ), +DMA_TO_DEVICE ); + } +/* not reclaimed by axienet_free_tx_chain(), so a drop */ +if (cur_p->skb) +dev_kfree_skb_any (cur_p->skb); + cur_p->phys =0 ; + cur_p->phys_msb =0 ; + cur_p->cntrl =0 ; + cur_p->status =0 ; + cur_p->app0 =0 ; + cur_p->app1 =0 ; + cur_p->app2 =0 ; + cur_p->app3 =0 ; + cur_p->app4 =0 ; + cur_p->skb =NULL ; + } +} +/** * axienet_dma_bd_release - Release buffer descriptor rings * @ndev: Pointer to the net_device structure
@@ -186,11 +226,18 @@ static void axienet_dma_bd_release(struct net_device *ndev)int i;struct axienet_local *lp =netdev_priv (ndev); -/* If we end up here, tx_bd_v must have been DMA allocated. */ +/* tx_bd_v is NULL if axienet_dma_bd_init() did not get as far as +* allocating it, and is cleared below once the ring is freed; +* dma_free_coherent() accepts NULL. +*/ +if (lp->tx_bd_v) +axienet_free_tx_bufs (lp); +dma_free_coherent (lp->dev,sizeof (*lp->tx_bd_v) * lp->tx_bd_num, lp->tx_bd_v, lp->tx_bd_p); + lp->tx_bd_v =NULL ;if (!lp->rx_bd_v)return ;
@@ -221,6 +268,7 @@ static void axienet_dma_bd_release(struct net_device *ndev)sizeof (*lp->rx_bd_v) * lp->rx_bd_num, lp->rx_bd_v, lp->rx_bd_p); + lp->rx_bd_v =NULL ; }/**
@@ -2537,29 +2585,7 @@ static void axienet_dma_err_handler(struct work_struct *work)axienet_dma_stop (lp); -for (i =0 ; i < lp->tx_bd_num; i++) { - cur_p = &lp->tx_bd_v[i]; -if (cur_p->cntrl) { -dma_addr_t addr =desc_get_phys_addr (lp, cur_p); - -dma_unmap_single (lp->dev, addr, - (cur_p->cntrl & -XAXIDMA_BD_CTRL_LENGTH_MASK ), -DMA_TO_DEVICE ); - } -if (cur_p->skb) -dev_kfree_skb_irq (cur_p->skb); - cur_p->phys =0 ; - cur_p->phys_msb =0 ; - cur_p->cntrl =0 ; - cur_p->status =0 ; - cur_p->app0 =0 ; - cur_p->app1 =0 ; - cur_p->app2 =0 ; - cur_p->app3 =0 ; - cur_p->app4 =0 ; - cur_p->skb =NULL ; - } +axienet_free_tx_bufs (lp);for (i =0 ; i < lp->rx_bd_num; i++) { cur_p = &lp->rx_bd_v[i];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1259/1756 selftests/bpf: Expect at least one tp_recursion miss in missed
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiliang Yuan <[email protected]>
[ Upstream commit a5e144985d6855c84b56ea5443fd6333490ce8ec ]
missed_tp_recursion attaches its tp programs to bpf_trace_printk and expects each of them to miss exactly one run, the one that its kprobe program on bpf_fentry_test1 triggers by calling bpf_printk().
The test is not serial, so tests running in parallel can add misses to the tp programs while they are attached:
- The kprobe on bpf_fentry_test1 is global. Any other test that does bpf_prog_test_run() on a fentry/fexit program calls bpf_fentry_test1() and thereby fires the kprobe program, which calls bpf_printk() from kprobe context and makes the tp programs fail the bpf_prog_active check once more.
- Any other program that runs under the bpf_prog_active check, such as a kprobe program or the perf event tracepoint program in legacy_printk, and calls bpf_printk() hits bpf_trace_printk the same way.
Either way, test2_recursion_misses comes out as 2 instead of 1.
Expect at least one miss, as missed_kprobe_recursion does since commit 08a7078feacf ("selftests/bpf: Improve missed_kprobe_recursion test robustness").
--- tools/testing/selftests/bpf/prog_tests/missed.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/missed.c +3 -3
@@ -119,9 +119,9 @@ static void test_missed_tp_recursion(void)ASSERT_EQ (topts.retval,0 ,"test_run" );ASSERT_EQ (get_missed_count (bpf_program__fd (skel->progs.test1)),0 ,"test1_recursion_misses" ); -ASSERT_EQ (get_missed_count (bpf_program__fd (skel->progs.test2)),1 ,"test2_recursion_misses" ); -ASSERT_EQ (get_missed_count (bpf_program__fd (skel->progs.test3)),1 ,"test3_recursion_misses" ); -ASSERT_EQ (get_missed_count (bpf_program__fd (skel->progs.test4)),1 ,"test4_recursion_misses" ); +ASSERT_GE (get_missed_count (bpf_program__fd (skel->progs.test2)),1 ,"test2_recursion_misses" ); +ASSERT_GE (get_missed_count (bpf_program__fd (skel->progs.test3)),1 ,"test3_recursion_misses" ); +ASSERT_GE (get_missed_count (bpf_program__fd (skel->progs.test4)),1 ,"test4_recursion_misses" ); cleanup:missed_tp_recursion__destroy (skel);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1260/1756 veth: clear rx queue hint in veth_xmit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 1b1c0e87cfe78d731bbab99c9c018655980b6790 ]
With more tx queues on one end of a veth pair than rx queues on the other, and RPS or generic XDP enabled on the receiving end, we get:
veth1 received packet on queue 2, but number of RX queues is 2
WARNING: net/core/dev.c:5212 at get_rps_cpu+0x560/0x1360
Call Trace:
<TASK>
netif_rx_internal+0x1af/0x4c0
__netif_rx+0x99/0x350
veth_xmit+0x713/0xca0
dev_hard_start_xmit+0x166/0x5f0
__dev_queue_xmit+0x1797/0x42d0
ip_finish_output2+0xa34/0x1f40
__ip_finish_output+0x510/0x7e0
ip_finish_output+0x2f/0x320
ip_output+0x17a/0x3f0
ip_send_skb+0x1bc/0x220
......Easy to hit with "ethtool -L veth0 tx 4", "ethtool -L veth1 rx 2", rps_cpus set on veth1 and a few flows sent over the pair [1].
veth_xmit() uses skb->queue_mapping to pick the peer rq, but never clears it before veth_forward_skb(), so the rx side still sees the tx queue index. Everything on the rx side that goes through skb_get_rx_queue(), like get_rps_cpu() and netif_get_rxqueue() for generic XDP, takes it as a recorded rx queue and warns once it is out of range.
Clear it before handing the skb to the peer:
- It is the tx queue index of this device, it says nothing about the rx queue of the peer.
- The two sides don't even agree on the encoding. The tx side stores the index as is, the rx side stores index + 1 so that 0 can mean "not recorded". So tx queue k is read back as rx queue k - 1, and tx queue 0 as "not recorded".
- Commit 710ad98c363a ("veth: Do not record rx queue hint in veth_xmit") already decided that veth should not pass any queue hint to the peer. There is no tx->rx queue mapping to preserve, so nothing is lost by clearing it.
On NETDEV_TX_BUSY the skb goes back to the qdisc, which looks up the txq from skb->queue_mapping to decide when to retry, so restore it there, next to the existing __skb_push().
[1]: https://lore.kernel.org/netdev/[email protected]/
--- drivers/net/veth.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/veth.c +5 -0
@@ -375,6 +375,9 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)skb_tx_timestamp (skb); +/* tx queue index of this device, meaningless as rx queue of the peer */ +skb_set_queue_mapping (skb,0 ); + ret =veth_forward_skb (rcv, skb, rq, use_napi);switch (ret) {case NET_RX_SUCCESS :/* same as NETDEV_TX_OK */
@@ -395,6 +398,8 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev) }/* Restore Eth hdr pulled by dev_forward_skb/eth_type_trans */ __skb_push (skb,ETH_HLEN ); +/* qdisc requeues the skb on the txq it points to */ +skb_set_queue_mapping (skb, rxq);netif_tx_stop_queue (txq);/* Makes sure NAPI peer consumer runs. Consumer is responsible * for starting txq again, until then ndo_start_xmit (this
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1261/1756 IB/IPoIB: Cancel normal flush work on device stop
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carolina Jubran <[email protected]>
[ Upstream commit 66196a559be5963b1ced18418c876caf9bfb76e6 ]
ipoib_ib_dev_flush_normal() can race with ipoib_stop() because the normal flush work does not run under RTNL.
Before commit a77a57a1a22a ("IPoIB: Fix deadlock on RTNL in ipoib_stop()"), ipoib_stop() flushed ipoib_workqueue after clearing IPOIB_FLAG_ADMIN_UP and before calling ipoib_ib_dev_down(). This ensured that any in-flight flush work completed before ipoib_ib_dev_down() performed the final clear of IPOIB_FLAG_OPER_UP.
After that commit removed the workqueue flush to avoid a deadlock with workqueue tasks taking RTNL, a normal flush can continue running concurrently with ipoib_stop() after IPOIB_FLAG_ADMIN_UP has been cleared.
The flush may observe IPOIB_FLAG_ADMIN_UP set and continue running while ipoib_stop() clears IPOIB_FLAG_ADMIN_UP and brings the device down. The flush can then call ipoib_ib_dev_up() and set IPOIB_FLAG_OPER_UP again after the device has already been stopped:
flush_normal (ipoib_workqueue) ipoib_stop() (RTNL held)
------------------------------ ------------------------
test_bit(ADMIN_UP) == 1
clear_bit(ADMIN_UP)
ipoib_ib_dev_down()
clear_bit(OPER_UP) ipoib_ib_dev_up()
set_bit(OPER_UP)
This leaves the interface with ADMIN_UP clear and OPER_UP set. During device removal, ipoib_ndo_uninit() waits in destroy_workqueue() while holding RTNL, while ipoib_mcast_carrier_on_task() may keep retrying rtnl_trylock() as long as OPER_UP remains set, resulting in a deadlock.
Cancel the normal flush work from ipoib_stop() after clearing IPOIB_FLAG_ADMIN_UP and before bringing the device down. A pending normal flush is canceled, while an already running flush is allowed to finish before ipoib_ib_dev_down() performs the final transition to OPER_UP clear.
Only the normal flush needs this synchronization. The heavy flush is already serialized with ipoib_stop() by RTNL, while the light flush does not bring the device back up and therefore cannot recreate this race.
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/infiniband/ulp/ipoib/ipoib_main.c +7 -0
@@ -189,6 +189,13 @@ static int ipoib_stop(struct net_device *dev)clear_bit (IPOIB_FLAG_ADMIN_UP , &priv->flags); +/* Normal flush runs without RTNL and may bring the device back +* up. Cancel it before the device down transition. +* Heavy flush is already serialized by RTNL and must not be +* waited on here while RTNL is held. +*/ +cancel_work_sync (&priv->flush_normal); +netif_stop_queue (dev);ipoib_ib_dev_down (dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1262/1756 rxrpc: Revert "rxrpc: rxperf: Fix missing decoding of terminal magic cookie"
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 870143cfdac1cad166d1dc03fbef915fac0c229a ]
Revert commit c34d999ca3145d9fe858258cc3342ec493f47d2e:
The rxperf RPCs seem to have a magic cookie at the end of the request that was failing to be taken account of by the unmarshalling of the request. Fix the rxperf code to expect this.
Actually, this isn't true; it's just that other Rx implementations ignore the extra data in the request and so my test programs are sending too much data without noticeable consequence.
--- net/rxrpc/rxperf.c | 12 ------------ 1 file changed, 12 deletions(-)
net/rxrpc/rxperf.c +0 -12
@@ -494,18 +494,6 @@ static int rxperf_deliver_request(struct rxperf_call *call) call->unmarshal++; fallthrough;case 2 : - ret =rxperf_extract_data (call, true); -if (ret <0 ) -return ret; - -/* Deal with the terminal magic cookie. */ - call->iov_len =4 ; - call->kvec[0 ].iov_len = call->iov_len; - call->kvec[0 ].iov_base = call->tmp; -iov_iter_kvec (&call->iter,READ , call->kvec,1 , call->iov_len); - call->unmarshal++; - fallthrough; -case 3 : ret =rxperf_extract_data (call, false);if (ret <0 )return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1263/1756 irqchip/gic-v3-its: Clear vpt_page after freeing the pending table
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit 0d604b1e4617d18dbb5573290ba447d7369251d1 ]
its_vpe_teardown() frees vpt_page without clearing it, so its vpt_page == NULL guard only holds the first time it runs on a vPE. struct its_vpe outlives a failed KVM_DEV_ARM_VGIC_CTRL_INIT, so a retry that fails again frees the pending table and the vPE ID a second time.
--- drivers/irqchip/irq-gic-v3-its.c | 1 + 1 file changed, 1 insertion(+)
drivers/irqchip/irq-gic-v3-its.c +1 -0
@@ -4514,6 +4514,7 @@ static void its_vpe_teardown(struct its_vpe *vpe)its_vpe_db_proxy_unmap (vpe);its_vpe_id_free (vpe->vpe_id);its_free_pending_table (vpe->vpt_page); + vpe->vpt_page =NULL ; } static void its_vpe_irq_domain_free(struct irq_domain *domain,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1264/1756 irqchip/riscv-imsic: Reject overlapping group index fields
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 8caa8fcec8db5358437b9b7ca456bc3093d2a4d0 ]
The IMSIC address layout places the group index above the page offset, guest index and HART index. imsic_parse_fwnode() checks the individual field widths and the upper end of the group field, but does not check that its lower end is above the other fields.
Reject a nonzero group field whose shift overlaps the lower fields. Otherwise a firmware-supplied layout can assign the same address bit to different indices when MSI target addresses are constructed.
Keep the existing upper-bound check unchanged. The new lower-bound check applies only when group index bits are present.
The issue was found by our static-analysis tool.
--- drivers/irqchip/irq-riscv-imsic-state.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/irqchip/irq-riscv-imsic-state.c +8 -0
@@ -710,6 +710,14 @@ static int __init imsic_parse_fwnode(struct fwnode_handle *fwnode,return -EINVAL ; } +/* Group index bits must not overlap guest and HART index bits. */ + i =IMSIC_MMIO_PAGE_SHIFT + global->guest_index_bits + + global->hart_index_bits; +if (global->group_index_bits && global->group_index_shift < i) { +pr_err ("%pfwP: group index shift too small\n" , fwnode); +return -EINVAL ; + } +/* Sanity check group index shift */ i = global->group_index_bits + global->group_index_shift -1 ;if (i >=BITS_PER_LONG ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1265/1756 irqchip/gic-v3-its: Share ITS tables with a non-trusted hypervisor
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Price <[email protected]>
[ Upstream commit b08e2f42e86b5848add254da45b56fc672e2bced ]
Within a realm guest the ITS is emulated by the host. This means the allocations must have been made available to the host by a call to set_memory_decrypted(). Introduce an allocation function which performs this extra call.
For the ITT use a custom genpool-based allocator that calls set_memory_decrypted() for each page allocated, but then suballocates the size needed for each ITT. Note that there is no mechanism implemented to return pages from the genpool, but it is unlikely that the peak number of devices will be much larger than the normal level - so this isn't expected to be an issue.
Stable-dep-of: 32e056cc1d15 ("irqchip/gic-v3-its: Don't free a vPE table shared with another ITS")
--- drivers/irqchip/irq-gic-v3-its.c | 138 +++++++++++++++++++++++++------ 1 file changed, 115 insertions(+), 23 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +115 -23
@@ -12,12 +12,14 @@#include <linux/crash_dump.h> #include <linux/delay.h> #include <linux/efi.h> +#include <linux/genalloc.h> #include <linux/interrupt.h> #include <linux/iommu.h> #include <linux/iopoll.h> #include <linux/irqdomain.h> #include <linux/list.h> #include <linux/log2.h> +#include <linux/mem_encrypt.h> #include <linux/memblock.h> #include <linux/mm.h> #include <linux/msi.h>
@@ -27,6 +29,7 @@#include <linux/of_pci.h> #include <linux/of_platform.h> #include <linux/percpu.h> +#include <linux/set_memory.h> #include <linux/slab.h> #include <linux/syscore_ops.h>
@@ -166,6 +169,7 @@ struct its_device {struct its_node *its;struct event_lpi_map event_map;void *itt; +u32 itt_sz;u32 nr_ites;u32 device_id;bool shared;
@@ -201,6 +205,87 @@ static DEFINE_IDA(its_vpeid_ida);#define gic_data_rdist_rd_base () (gic_data_rdist()->rd_base)#define gic_data_rdist_vlpi_base () (gic_data_rdist_rd_base() + SZ_128K) +static struct page *its_alloc_pages_node (int node,gfp_t gfp, +unsigned int order) +{ +struct page *page; +int ret =0 ; + + page =alloc_pages_node (node, gfp, order); + +if (!page) +return NULL ; + + ret =set_memory_decrypted ((unsigned long )page_address (page), +1 << order); +/* +* If set_memory_decrypted() fails then we don't know what state the +* page is in, so we can't free it. Instead we leak it. +* set_memory_decrypted() will already have WARNed. +*/ +if (ret) +return NULL ; + +return page; +} + +static struct page *its_alloc_pages (gfp_t gfp,unsigned int order) +{ +return its_alloc_pages_node (NUMA_NO_NODE , gfp, order); +} + +static void its_free_pages (void *addr,unsigned int order) +{ +/* +* If the memory cannot be encrypted again then we must leak the pages. +* set_memory_encrypted() will already have WARNed. +*/ +if (set_memory_encrypted ((unsigned long )addr,1 << order)) +return ; +free_pages ((unsigned long )addr, order); +} + +static struct gen_pool *itt_pool; + +static void *itt_alloc_pool (int node,int size) +{ +unsigned long addr; +struct page *page; + +if (size >=PAGE_SIZE ) { + page =its_alloc_pages_node (node,GFP_KERNEL | __GFP_ZERO,get_order (size)); + +return page ?page_address (page) :NULL ; + } + +do { + addr =gen_pool_alloc (itt_pool, size); +if (addr) +break ; + + page =its_alloc_pages_node (node,GFP_KERNEL | __GFP_ZERO,1 ); +if (!page) +break ; + +gen_pool_add (itt_pool, (unsigned long )page_address (page),PAGE_SIZE , node); + }while (!addr); + +return (void *)addr; +} + +static void itt_free_pool (void *addr,int size) +{ +if (!addr) +return ; + +if (size >=PAGE_SIZE ) { +its_free_pages (addr,get_order (size)); +return ; + } + +gen_pool_free (itt_pool, (unsigned long )addr, size); +} +/* * Skip ITSs that have no vLPIs mapped, unless we're on GICv4.1, as we * always have vSGIs mapped.
@@ -2184,7 +2269,8 @@ static struct page *its_allocate_prop_table(gfp_t gfp_flags) {struct page *prop_page; - prop_page =alloc_pages (gfp_flags,get_order (LPI_PROPBASE_SZ )); + prop_page =its_alloc_pages (gfp_flags, +get_order (LPI_PROPBASE_SZ ));if (!prop_page)return NULL ;
@@ -2195,8 +2281,7 @@ static struct page *its_allocate_prop_table(gfp_t gfp_flags)static void its_free_prop_table (struct page *prop_page) { -free_pages ((unsigned long )page_address (prop_page), -get_order (LPI_PROPBASE_SZ )); +its_free_pages (page_address (prop_page),get_order (LPI_PROPBASE_SZ )); }static bool gic_check_reserved_range (phys_addr_t addr,unsigned long size)
@@ -2318,7 +2403,7 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, order =get_order (GITS_BASER_PAGES_MAX * psz); } - page =alloc_pages_node (its->numa_node,GFP_KERNEL | __GFP_ZERO, order); + page =its_alloc_pages_node (its->numa_node,GFP_KERNEL | __GFP_ZERO, order);if (!page)return -ENOMEM ;
@@ -2331,7 +2416,7 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser,/* 52bit PA is supported only when PageSize=64K */ if (psz !=SZ_64K ) {pr_err ("ITS: no 52bit PA support when psz=%d\n" , psz); -free_pages ((unsigned long )base, order); +its_free_pages (base, order);return -ENXIO ; }
@@ -2387,7 +2472,7 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser,pr_err ("ITS@%pa: %s doesn't stick: %llx %llx\n" , &its->phys_base, its_base_type_string[type], val, tmp); -free_pages ((unsigned long )base, order); +its_free_pages (base, order);return -ENXIO ; }
@@ -2526,8 +2611,7 @@ static void its_free_tables(struct its_node *its)for (i =0 ; i <GITS_BASER_NR_REGS ; i++) {if (its->tables[i].base) { -free_pages ((unsigned long )its->tables[i].base, - its->tables[i].order); +its_free_pages (its->tables[i].base, its->tables[i].order); its->tables[i].base =NULL ; } }
@@ -2793,7 +2877,7 @@ static bool allocate_vpe_l2_table(int cpu, u32 id)/* Allocate memory for 2nd level table */ if (!table[idx]) { - page =alloc_pages (GFP_KERNEL | __GFP_ZERO,get_order (psz)); + page =its_alloc_pages (GFP_KERNEL | __GFP_ZERO,get_order (psz));if (!page)return false;
@@ -2912,7 +2996,7 @@ static int allocate_vpe_l1_table(void)pr_debug ("np = %d, npg = %lld, psz = %d, epp = %d, esz = %d\n" , np, npg, psz, epp, esz); - page =alloc_pages (GFP_ATOMIC | __GFP_ZERO,get_order (np *PAGE_SIZE )); + page =its_alloc_pages (GFP_ATOMIC | __GFP_ZERO,get_order (np *PAGE_SIZE ));if (!page)return -ENOMEM ;
@@ -2958,8 +3042,7 @@ static struct page *its_allocate_pending_table(gfp_t gfp_flags) {struct page *pend_page; - pend_page =alloc_pages (gfp_flags | __GFP_ZERO, -get_order (LPI_PENDBASE_SZ )); + pend_page =its_alloc_pages (gfp_flags | __GFP_ZERO,get_order (LPI_PENDBASE_SZ ));if (!pend_page)return NULL ;
@@ -2971,7 +3054,7 @@ static struct page *its_allocate_pending_table(gfp_t gfp_flags)static void its_free_pending_table (struct page *pt) { -free_pages ((unsigned long )page_address (pt),get_order (LPI_PENDBASE_SZ )); +its_free_pages (page_address (pt),get_order (LPI_PENDBASE_SZ )); }/*
@@ -3304,8 +3387,8 @@ static bool its_alloc_table_entry(struct its_node *its,/* Allocate memory for 2nd level table */ if (!table[idx]) { - page =alloc_pages_node (its->numa_node,GFP_KERNEL | __GFP_ZERO, -get_order (baser->psz)); + page =its_alloc_pages_node (its->numa_node,GFP_KERNEL | __GFP_ZERO, +get_order (baser->psz));if (!page)return false;
@@ -3401,7 +3484,6 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,if (WARN_ON (!is_power_of_2 (nvecs))) nvecs =roundup_pow_of_two (nvecs); - dev =kzalloc (sizeof (*dev),GFP_KERNEL );/* * Even if the device wants a single LPI, the ITT must be * sized as a power of two (and you need at least one bit...).
@@ -3412,7 +3494,11 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, nr_ites =max (2 , nvecs); sz = nr_ites * (FIELD_GET (GITS_TYPER_ITT_ENTRY_SIZE , its->typer) +1 ); sz =max (sz,ITS_ITT_ALIGN ) +ITS_ITT_ALIGN -1 ; - itt =kzalloc_node (sz,GFP_KERNEL , its->numa_node); + + itt =itt_alloc_pool (its->numa_node, sz); + + dev =kzalloc (sizeof (*dev),GFP_KERNEL ); +if (alloc_lpis) { lpi_map =its_lpi_alloc (nvecs, &lpi_base, &nr_lpis);if (lpi_map)
@@ -3424,9 +3510,9 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, lpi_base =0 ; } -if (!dev || !itt || !col_map || (!lpi_map && alloc_lpis)) { +if (!dev || !itt || !col_map || (!lpi_map && alloc_lpis)) {kfree (dev); -kfree (itt); +itt_free_pool (itt, sz);bitmap_free (lpi_map);kfree (col_map);return NULL ;
@@ -3436,6 +3522,7 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, dev->its = its; dev->itt = itt; + dev->itt_sz = sz; dev->nr_ites = nr_ites; dev->event_map.lpi_map = lpi_map; dev->event_map.col_map = col_map;
@@ -3463,7 +3550,7 @@ static void its_free_device(struct its_device *its_dev)list_del (&its_dev->entry);raw_spin_unlock_irqrestore (&its_dev->its->lock, flags);kfree (its_dev->event_map.col_map); -kfree (its_dev->itt); +itt_free_pool (its_dev->itt, its_dev->itt_sz);kfree (its_dev); }
@@ -5177,8 +5264,9 @@ static int __init its_probe_one(struct its_node *its) } } - page =alloc_pages_node (its->numa_node,GFP_KERNEL | __GFP_ZERO, -get_order (ITS_CMD_QUEUE_SZ )); + page =its_alloc_pages_node (its->numa_node, +GFP_KERNEL | __GFP_ZERO, +get_order (ITS_CMD_QUEUE_SZ ));if (!page) { err = -ENOMEM ; goto out_unmap_sgir;
@@ -5244,7 +5332,7 @@ static int __init its_probe_one(struct its_node *its) out_free_tables:its_free_tables (its); out_free_cmd: -free_pages ((unsigned long )its->cmd_base,get_order (ITS_CMD_QUEUE_SZ )); +its_free_pages (its->cmd_base,get_order (ITS_CMD_QUEUE_SZ )); out_unmap_sgir:if (its->sgir_base)iounmap (its->sgir_base);
@@ -5734,6 +5822,10 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists,bool has_v4_1 = false;int err; + itt_pool =gen_pool_create (get_order (ITS_ITT_ALIGN ),-1 ); +if (!itt_pool) +return -ENOMEM ; + gic_rdists = rdists; lpi_prop_prio = irq_prio;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1266/1756 irqchip/gic-v3-its: Dont free a vPE table shared with another ITS
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit 32e056cc1d1582951f981113ca8b98914f29c32a ]
On GICv4.1, its_alloc_tables() copies a sibling's vPE table baser rather than allocating one, but its_free_tables() frees it like the rest. A probe failure on the copying ITS then frees pages the enabled sibling still points GITS_BASER2 at, and the kernel comes up running on that sibling.
Mark a shared table so its_free_tables() skips it.
--- drivers/irqchip/irq-gic-v3-its.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +5 -1
@@ -86,6 +86,8 @@ struct its_baser {u64 val;u32 order;u32 psz; +/* Inherited from a sibling ITS, not freed here */ +bool shared; };struct its_device ;
@@ -2611,7 +2613,8 @@ static void its_free_tables(struct its_node *its)for (i =0 ; i <GITS_BASER_NR_REGS ; i++) {if (its->tables[i].base) { -its_free_pages (its->tables[i].base, its->tables[i].order); +if (!its->tables[i].shared) +its_free_pages (its->tables[i].base, its->tables[i].order); its->tables[i].base =NULL ; } }
@@ -2710,6 +2713,7 @@ static int its_alloc_tables(struct its_node *its)WARN_ON (i !=2 );if ((sibling =find_sibling_its (its))) { *baser = sibling->tables[2 ]; + baser->shared = true;its_write_baser (its, baser, baser->val);continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1267/1756 irqchip/gic-v3-its: Dont free the tables of an enabled ITS
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit d09b36d8e0e60f35bd1cd7d63aadc6dfad61700c ]
its_probe_one() enables the ITS before its_init_domain(), the last step that can fail, and the unwind from there frees the tables and the command queue without disabling it. The kernel comes up with an enabled ITS pointing at freed pages.
Enable the ITS last. Nothing reaches the new domain before then: this runs from init_IRQ(), and the ITS joins its_nodes only after the enable.
--- drivers/irqchip/irq-gic-v3-its.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +6 -4
@@ -5315,16 +5315,18 @@ static int __init its_probe_one(struct its_node *its) }gits_write_cwriter (0 , its->base +GITS_CWRITER ); + + err =its_init_domain (its); +if (err) + goto out_free_collection; + +/* Enable last: the unwind frees memory an enabled ITS may access */ ctlr =readl_relaxed (its->base +GITS_CTLR ); ctlr |=GITS_CTLR_ENABLE ;if (is_v4 (its)) ctlr |= GITS_CTLR_ImDe;writel_relaxed (ctlr, its->base +GITS_CTLR ); - err =its_init_domain (its); -if (err) - goto out_free_collection; -raw_spin_lock (&its_lock);list_add (&its->entry, &its_nodes);raw_spin_unlock (&its_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1268/1756 irqchip/gic-v3: Dont register a redistributor that was never counted
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit 6a21693b97ee5cb0a21d04bfd051a05dde5aa783 ]
gic_acpi_match_gicc() counts only the enabled GICCs with a non-zero gicr_base_address, and that count sizes redist_regs[], but gic_acpi_parse_madt_gicc() registers every enabled one. On a MADT with no GICR entries, an enabled GICC with a zero GICR base therefore makes gic_acpi_register_redist() write a struct redist_region past the end of the array.
Commit fa2dabe57220e ("irqchip/gic-v3: Don't return errors from gic_acpi_match_gicc()") removed the check that kept the two consistent. Its message says such entries are still caught by gic_populate_rdist(), but that runs from gic_cpu_init(), after the write.
Skip the entry instead, and mark the CPU's redistributor broken as the online-capable path does, so that gic_check_rdist() rejects the CPU. gic_starting_cpu() runs past cpuhp's last failure point, so without the mark the CPU would come online with its redistributor and CPU interface unconfigured. With an ITS, its_cpu_init() would then dereference a NULL rd_base.
--- drivers/irqchip/irq-gic-v3.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/irqchip/irq-gic-v3.c +11 -0
@@ -2453,6 +2453,17 @@ gic_acpi_parse_madt_gicc(union acpi_subtable_headers *header,return 0 ; } +/* Not counted by gic_acpi_match_gicc(), so there is no slot for it */ +if (!gicc->gicr_base_address) { +int cpu =get_cpu_for_acpi_id (gicc->uid); + +pr_warn (FW_BUG "GICC entry with ACPI UID %u has no GICR base address, CPU kept offline\n" , + gicc->uid); +if (cpu >=0 ) +cpumask_set_cpu (cpu, &broken_rdists); +return 0 ; + } + redist_base =ioremap (gicc->gicr_base_address, size);if (!redist_base)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1269/1756 irqchip/gic: Fix UBSAN shift-out-of-bounds in GIC helpers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Ling <[email protected]>
[ Upstream commit 13ce14ca41a35f5ee90b77ffa57da91ce6048a2d ]
When running with UBSAN enabled, enabling a GPIO controller that uses a GIC interrupt as its parent triggers several shift-out-of-bounds warnings:
shift-out-of-bounds in drivers/irqchip/irq-gic-common.c:50:21 left shift of 2 by 30 places cannot be represented in type 'int'
Similar reports are emitted from gic_poke_irq() and gic_peek_irq() in drivers/irqchip/irq-gic-v3.c. The corresponding GICv2 helpers use the same signed-shift pattern. These masks are generated by shifting signed integer constants, which invokes undefined behavior when bit 31 is selected.
Use BIT() to generate the masks with an unsigned type and make their intent explicit.
--- drivers/irqchip/irq-gic-common.c | 2 +- drivers/irqchip/irq-gic-v3.c | 4 ++-- drivers/irqchip/irq-gic.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/irqchip/irq-gic-common.c +1 -1
@@ -48,7 +48,7 @@ void gic_enable_quirks(u32 iidr, const struct gic_quirk *quirks,int gic_configure_irq (unsigned int irq,unsigned int type,void __iomem *base) { -u32 confmask =0x2 << ((irq %16 ) *2 ); +u32 confmask =BIT (((irq %16 ) *2 ) +1 );u32 confoff = (irq /16 ) *4 ;u32 val, oldval;int ret =0 ;
drivers/irqchip/irq-gic-v3.c +2 -2
@@ -457,7 +457,7 @@ static int gic_peek_irq(struct irq_data *d, u32 offset)u32 index, mask; offset =convert_offset_index (d, offset, &index); - mask =1 << (index %32 ); + mask =BIT (index %32 );if (gic_irq_in_rdist (d)) base =gic_data_rdist_sgi_base ();
@@ -473,7 +473,7 @@ static void gic_poke_irq(struct irq_data *d, u32 offset)u32 index, mask; offset =convert_offset_index (d, offset, &index); - mask =1 << (index %32 ); + mask =BIT (index %32 );if (gic_irq_in_rdist (d)) base =gic_data_rdist_sgi_base ();
drivers/irqchip/irq-gic.c +2 -2
@@ -178,14 +178,14 @@ static inline bool cascading_gic_irq(struct irq_data *d)*/ static void gic_poke_irq (struct irq_data *d,u32 offset) { -u32 mask =1 << (irqd_to_hwirq (d) %32 ); +u32 mask =BIT (irqd_to_hwirq (d) %32 );writel_relaxed (mask,gic_dist_base (d) + offset + (irqd_to_hwirq (d) /32 ) *4 ); }static int gic_peek_irq (struct irq_data *d,u32 offset) { -u32 mask =1 << (irqd_to_hwirq (d) %32 ); +u32 mask =BIT (irqd_to_hwirq (d) %32 );return !!(readl_relaxed (gic_dist_base (d) + offset + (irqd_to_hwirq (d) /32 ) *4 ) & mask); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1270/1756 ALSA: Add simple refcount helper functions
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit dcca9b6064c33c84fbeb9f09814178a206321249 ]
There are many open-code to manage the same pattern for refcount + wakeup sync at closing. Let's provide the common helper functions to replace the open-code.
- The recount is kept in struct snd_refcount, where it's initialized by snd_refcount_init().
- The user can simply reference or unreference via snd_refcount_get() and snd_refcount_put() functions
- The user can wait for the all usages gone by snd_refcount_sync()
Note that here we use atomic_t instead of refcount_t since the current users allow reusing the refcount after sync again. The design of refcount_t prevents exactly this behavior, so it doesn't fit.
Stable-dep-of: 91d0048a97e0 ("ALSA: pcm: Add refcount for races between drain and unlink")
--- include/sound/core.h | 21 +++++++++++++++++++++ sound/core/misc.c | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
include/sound/core.h +21 -0
@@ -75,6 +75,27 @@ struct snd_device {#define snd_device (n) list_entry(n, struct snd_device, list) +/* +* A simple reference counter with a wait queue; +* typically used for usage counts, and you can synchronize at finishing +* via snd_refcount_sync(), which is woken up when the refcount reaches to +* zero again. +*/ +struct snd_refcount { +atomic_t count; +wait_queue_head_t waiter; +}; + +void snd_refcount_init (struct snd_refcount *ref); + +static inline void snd_refcount_get (struct snd_refcount *ref) +{ +atomic_inc (&ref->count); +} + +void snd_refcount_put (struct snd_refcount *ref); +void snd_refcount_sync (struct snd_refcount *ref); +/* main structure for soundcard */ struct snd_card {
sound/core/misc.c +24 -0
@@ -174,3 +174,27 @@ void snd_fasync_free(struct snd_fasync *fasync)kfree (fasync); }EXPORT_SYMBOL_GPL (snd_fasync_free); + +/* +* generic refcount helper +*/ + +void snd_refcount_init (struct snd_refcount *ref) +{ +atomic_set (&ref->count,0 ); +init_waitqueue_head (&ref->waiter); +} +EXPORT_SYMBOL_GPL (snd_refcount_init); + +void snd_refcount_put (struct snd_refcount *ref) +{ +if (atomic_dec_and_test (&ref->count)) +wake_up (&ref->waiter); +} +EXPORT_SYMBOL_GPL (snd_refcount_put); + +void snd_refcount_sync (struct snd_refcount *ref) +{ +wait_event (ref->waiter, !atomic_read (&ref->count)); +} +EXPORT_SYMBOL_GPL (snd_refcount_sync);
Signature · 1 line
2.53.0