5.10.80-rc1 review
Subsystems (12)
Greg Kroah-Hartman
maintainerPATCH 140/575 PCI: aardvark: Do not clear status bits of masked interrupts
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit a7ca6d7fa3c02c032db5440ff392d96c04684c21 upstream.
The PCIE_ISR1_REG says which interrupts are currently set / active, including those which are masked.
The driver currently reads this register and looks if some unmasked interrupts are active, and if not, it clears status bits of _all_ interrupts, including the masked ones.
This is incorrect, since, for example, some drivers may poll these bits.
Remove this clearing, and also remove this early return statement completely, since it does not change functionality in any way.
--- drivers/pci/controller/pci-aardvark.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/pci/controller/pci-aardvark.c +0 -6
@@ -1286,12 +1286,6 @@ static void advk_pcie_handle_int(struct isr1_mask =advk_readl (pcie,PCIE_ISR1_MASK_REG ); isr1_status = isr1_val & ((~isr1_mask) &PCIE_ISR1_ALL_MASK ); -if (!isr0_status && !isr1_status) { -advk_writel (pcie, isr0_val,PCIE_ISR0_REG ); -advk_writel (pcie, isr1_val,PCIE_ISR1_REG ); -return ; - } -/* Process MSI interrupts */ if (isr0_status &PCIE_ISR0_MSI_INT_PENDING )advk_pcie_handle_msi (pcie);
Greg Kroah-Hartman
maintainerPATCH 141/575 PCI: aardvark: Fix checking for link up via LTSSM state
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 661c399a651c11aaf83c45cbfe0b4a1fb7bc3179 upstream.
Current implementation of advk_pcie_link_up() is wrong as it marks also link disabled or hot reset states as link up.
Fix it by marking link up only to those states which are defined in PCIe Base specification 3.0, Table 4-14: Link Status Mapped to the LTSSM.
To simplify implementation, Define macros for every LTSSM state which aardvark hardware can return in CFG_REG register.
Fix also checking for link training according to the same Table 4-14. Define a new function advk_pcie_link_training() for this purpose.
--- drivers/pci/controller/pci-aardvark.c | 76 +++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 6 deletions(-)
drivers/pci/controller/pci-aardvark.c +70 -6
@@ -163,8 +163,50 @@#define CFG_REG (LMI_BASE_ADDR + 0x0)#define LTSSM_SHIFT 24#define LTSSM_MASK 0x3f -#define LTSSM_L0 0x10#define RC_BAR_CONFIG 0x300 + +/* LTSSM values in CFG_REG */ +enum { +LTSSM_DETECT_QUIET =0x0 , +LTSSM_DETECT_ACTIVE =0x1 , +LTSSM_POLLING_ACTIVE =0x2 , +LTSSM_POLLING_COMPLIANCE =0x3 , +LTSSM_POLLING_CONFIGURATION =0x4 , +LTSSM_CONFIG_LINKWIDTH_START =0x5 , +LTSSM_CONFIG_LINKWIDTH_ACCEPT =0x6 , +LTSSM_CONFIG_LANENUM_ACCEPT =0x7 , +LTSSM_CONFIG_LANENUM_WAIT =0x8 , +LTSSM_CONFIG_COMPLETE =0x9 , +LTSSM_CONFIG_IDLE =0xa , +LTSSM_RECOVERY_RCVR_LOCK =0xb , +LTSSM_RECOVERY_SPEED =0xc , +LTSSM_RECOVERY_RCVR_CFG =0xd , +LTSSM_RECOVERY_IDLE =0xe , +LTSSM_L0 =0x10 , +LTSSM_RX_L0S_ENTRY =0x11 , +LTSSM_RX_L0S_IDLE =0x12 , +LTSSM_RX_L0S_FTS =0x13 , +LTSSM_TX_L0S_ENTRY =0x14 , +LTSSM_TX_L0S_IDLE =0x15 , +LTSSM_TX_L0S_FTS =0x16 , +LTSSM_L1_ENTRY =0x17 , +LTSSM_L1_IDLE =0x18 , +LTSSM_L2_IDLE =0x19 , +LTSSM_L2_TRANSMIT_WAKE =0x1a , +LTSSM_DISABLED =0x20 , +LTSSM_LOOPBACK_ENTRY_MASTER =0x21 , +LTSSM_LOOPBACK_ACTIVE_MASTER =0x22 , +LTSSM_LOOPBACK_EXIT_MASTER =0x23 , +LTSSM_LOOPBACK_ENTRY_SLAVE =0x24 , +LTSSM_LOOPBACK_ACTIVE_SLAVE =0x25 , +LTSSM_LOOPBACK_EXIT_SLAVE =0x26 , +LTSSM_HOT_RESET =0x27 , +LTSSM_RECOVERY_EQUALIZATION_PHASE0 =0x28 , +LTSSM_RECOVERY_EQUALIZATION_PHASE1 =0x29 , +LTSSM_RECOVERY_EQUALIZATION_PHASE2 =0x2a , +LTSSM_RECOVERY_EQUALIZATION_PHASE3 =0x2b , +}; +#define VENDOR_ID_REG (LMI_BASE_ADDR + 0x44)/* PCIe core controller registers */
@@ -269,13 +311,35 @@ static inline u16 advk_read16(struct advreturn advk_readl (pcie, (reg & ~0x3 )) >> ((reg &0x3 ) *8 ); } -static int advk_pcie_link_up (struct advk_pcie *pcie) +static u8 advk_pcie_ltssm_state (struct advk_pcie *pcie) { -u32 val, ltssm_state; +u32 val; +u8 ltssm_state; val =advk_readl (pcie,CFG_REG ); ltssm_state = (val >>LTSSM_SHIFT ) <SSM_MASK ; -return ltssm_state >=LTSSM_L0 ; +return ltssm_state; +} + +static inline bool advk_pcie_link_up (struct advk_pcie *pcie) +{ +/* check if LTSSM is in normal operation - some L* state */ +u8 ltssm_state =advk_pcie_ltssm_state (pcie); +return ltssm_state >=LTSSM_L0 && ltssm_state <LTSSM_DISABLED ; +} + +static inline bool advk_pcie_link_training (struct advk_pcie *pcie) +{ +/* +* According to PCIe Base specification 3.0, Table 4-14: Link +* Status Mapped to the LTSSM is Link Training mapped to LTSSM +* Configuration and Recovery states. +*/ +u8 ltssm_state =advk_pcie_ltssm_state (pcie); +return ((ltssm_state >=LTSSM_CONFIG_LINKWIDTH_START && + ltssm_state <LTSSM_L0 ) || + (ltssm_state >=LTSSM_RECOVERY_EQUALIZATION_PHASE0 && + ltssm_state <=LTSSM_RECOVERY_EQUALIZATION_PHASE3 )); }static int advk_pcie_wait_for_link (struct advk_pcie *pcie)
@@ -298,7 +362,7 @@ static void advk_pcie_wait_for_retrain(ssize_t retries;for (retries =0 ; retries <RETRAIN_WAIT_MAX_RETRIES ; ++retries) { -if (!advk_pcie_link_up (pcie)) +if (advk_pcie_link_training (pcie))break ;udelay (RETRAIN_WAIT_USLEEP_US ); }
@@ -738,7 +802,7 @@ advk_pci_bridge_emul_pcie_conf_read(stru/* u32 contains both PCI_EXP_LNKCTL and PCI_EXP_LNKSTA */ u32 val =advk_readl (pcie,PCIE_CORE_PCIEXP_CAP + reg) & ~(PCI_EXP_LNKSTA_LT <<16 ); -if (!advk_pcie_link_up (pcie)) +if (advk_pcie_link_training (pcie)) val |= (PCI_EXP_LNKSTA_LT <<16 ); *value = val;return PCI_BRIDGE_EMUL_HANDLED ;
Greg Kroah-Hartman
maintainerPATCH 142/575 PCI: aardvark: Do not unmask unused interrupts
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 1fb95d7d3c7a926b002fe8a6bd27a1cb428b46dc upstream.
There are lot of undocumented interrupt bits. To prevent unwanted spurious interrupts, fix all *_ALL_MASK macros to define all interrupt bits, so that driver can properly mask all interrupts, including those which are undocumented.
--- drivers/pci/controller/pci-aardvark.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/controller/pci-aardvark.c +3 -3
@@ -105,13 +105,13 @@#define PCIE_ISR0_MSI_INT_PENDING BIT(24)#define PCIE_ISR0_INTX_ASSERT (val) BIT(16 + (val))#define PCIE_ISR0_INTX_DEASSERT (val) BIT(20 + (val)) -#define PCIE_ISR0_ALL_MASK GENMASK(26, 0) +#define PCIE_ISR0_ALL_MASK GENMASK(31, 0)#define PCIE_ISR1_REG (CONTROL_BASE_ADDR + 0x48)#define PCIE_ISR1_MASK_REG (CONTROL_BASE_ADDR + 0x4C)#define PCIE_ISR1_POWER_STATE_CHANGE BIT(4)#define PCIE_ISR1_FLUSH BIT(5)#define PCIE_ISR1_INTX_ASSERT (val) BIT(8 + (val)) -#define PCIE_ISR1_ALL_MASK GENMASK(11, 4) +#define PCIE_ISR1_ALL_MASK GENMASK(31, 0)#define PCIE_MSI_ADDR_LOW_REG (CONTROL_BASE_ADDR + 0x50)#define PCIE_MSI_ADDR_HIGH_REG (CONTROL_BASE_ADDR + 0x54)#define PCIE_MSI_STATUS_REG (CONTROL_BASE_ADDR + 0x58)
@@ -239,7 +239,7 @@ enum {#define PCIE_IRQ_MSI_INT2_DET BIT(21)#define PCIE_IRQ_RC_DBELL_DET BIT(22)#define PCIE_IRQ_EP_STATUS BIT(23) -#define PCIE_IRQ_ALL_MASK 0xfff0fb +#define PCIE_IRQ_ALL_MASK GENMASK(31, 0)#define PCIE_IRQ_ENABLE_INTS_MASK PCIE_IRQ_CORE_INT/* Transaction types */
Greg Kroah-Hartman
maintainerPATCH 143/575 PCI: aardvark: Fix reporting Data Link Layer Link Active
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 2b650b7ff20eb7ea8ef9031d20fb657286ab90cc upstream.
Add support for reporting PCI_EXP_LNKSTA_DLLLA bit in Link Control register on emulated bridge via current LTSSM state. Also correctly indicate DLLLA capability via PCI_EXP_LNKCAP_DLLLARC bit in Link Control Capability register.
--- drivers/pci/controller/pci-aardvark.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/pci/controller/pci-aardvark.c +28 -1
@@ -328,6 +328,20 @@ static inline bool advk_pcie_link_up(strreturn ltssm_state >=LTSSM_L0 && ltssm_state <LTSSM_DISABLED ; } +static inline bool advk_pcie_link_active (struct advk_pcie *pcie) +{ +/* +* According to PCIe Base specification 3.0, Table 4-14: Link +* Status Mapped to the LTSSM, and 4.2.6.3.6 Configuration.Idle +* is Link Up mapped to LTSSM Configuration.Idle, Recovery, L0, +* L0s, L1 and L2 states. And according to 3.2.1. Data Link +* Control and Management State Machine Rules is DL Up status +* reported in DL Active state. +*/ +u8 ltssm_state =advk_pcie_ltssm_state (pcie); +return ltssm_state >=LTSSM_CONFIG_IDLE && ltssm_state <LTSSM_DISABLED ; +} +static inline bool advk_pcie_link_training (struct advk_pcie *pcie) {/*
@@ -798,12 +812,26 @@ advk_pci_bridge_emul_pcie_conf_read(strureturn PCI_BRIDGE_EMUL_HANDLED ; } +case PCI_EXP_LNKCAP : { +u32 val =advk_readl (pcie,PCIE_CORE_PCIEXP_CAP + reg); +/* +* PCI_EXP_LNKCAP_DLLLARC bit is hardwired in aardvark HW to 0. +* But support for PCI_EXP_LNKSTA_DLLLA is emulated via ltssm +* state so explicitly enable PCI_EXP_LNKCAP_DLLLARC flag. +*/ + val |=PCI_EXP_LNKCAP_DLLLARC ; + *value = val; +return PCI_BRIDGE_EMUL_HANDLED ; + } +case PCI_EXP_LNKCTL : {/* u32 contains both PCI_EXP_LNKCTL and PCI_EXP_LNKSTA */ u32 val =advk_readl (pcie,PCIE_CORE_PCIEXP_CAP + reg) & ~(PCI_EXP_LNKSTA_LT <<16 );if (advk_pcie_link_training (pcie)) val |= (PCI_EXP_LNKSTA_LT <<16 ); +if (advk_pcie_link_active (pcie)) + val |= (PCI_EXP_LNKSTA_DLLLA <<16 ); *value = val;return PCI_BRIDGE_EMUL_HANDLED ; }
@@ -811,7 +839,6 @@ advk_pci_bridge_emul_pcie_conf_read(strucase PCI_CAP_LIST_ID :case PCI_EXP_DEVCAP :case PCI_EXP_DEVCTL : -case PCI_EXP_LNKCAP : *value =advk_readl (pcie,PCIE_CORE_PCIEXP_CAP + reg);return PCI_BRIDGE_EMUL_HANDLED ;default :
Greg Kroah-Hartman
maintainerPATCH 144/575 PCI: aardvark: Fix configuring Reference clock
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 46ef6090dbf590711cb12680b6eafde5fa21fe87 upstream.
Commit 366697018c9a ("PCI: aardvark: Add PHY support") introduced configuration of PCIe Reference clock via PCIE_CORE_REF_CLK_REG register, but did it incorrectly.
PCIe Reference clock differential pair is routed from system board to endpoint card, so on CPU side it has output direction. Therefore it is required to enable transmitting and disable receiving.
Default configuration according to Armada 3700 Functional Specifications is enabled receiver part and disabled transmitter.
We need this change because otherwise PCIe Reference clock is configured to some undefined state when differential pair is used for both transmitting and receiving.
Fix this by disabling receiver part.
--- drivers/pci/controller/pci-aardvark.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/pci/controller/pci-aardvark.c +8 -1
@@ -98,6 +98,7 @@#define PCIE_CORE_CTRL2_MSI_ENABLE BIT(10)#define PCIE_CORE_REF_CLK_REG (CONTROL_BASE_ADDR + 0x14)#define PCIE_CORE_REF_CLK_TX_ENABLE BIT(1) +#define PCIE_CORE_REF_CLK_RX_ENABLE BIT(2)#define PCIE_MSG_LOG_REG (CONTROL_BASE_ADDR + 0x30)#define PCIE_ISR0_REG (CONTROL_BASE_ADDR + 0x40)#define PCIE_MSG_PM_PME_MASK BIT(7)
@@ -529,9 +530,15 @@ static void advk_pcie_setup_hw(struct adu32 reg;int i; -/* Enable TX */ +/* +* Configure PCIe Reference clock. Direction is from the PCIe +* controller to the endpoint card, so enable transmitting of +* Reference clock differential signal off-chip and disable +* receiving off-chip differential signal. +*/ reg =advk_readl (pcie,PCIE_CORE_REF_CLK_REG ); reg |=PCIE_CORE_REF_CLK_TX_ENABLE ; + reg &= ~PCIE_CORE_REF_CLK_RX_ENABLE ;advk_writel (pcie, reg,PCIE_CORE_REF_CLK_REG );/* Set to Direct mode */
Greg Kroah-Hartman
maintainerPATCH 145/575 PCI: aardvark: Fix return value of MSI domain .alloc() method
In reply to Greg Kroah-HartmanFrom: Marek Behún <[email protected]>
commit e4313be1599d397625c14fb7826996813622decf upstream.
MSI domain callback .alloc() (implemented by advk_msi_irq_domain_alloc() function) should return zero on success, since non-zero value indicates failure.
When the driver was converted to generic MSI API in commit f21a8b1b6837 ("PCI: aardvark: Move to MSI handling using generic MSI support"), it was converted so that it returns hwirq number.
Fix this.
--- drivers/pci/controller/pci-aardvark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pci-aardvark.c +1 -1
@@ -1180,7 +1180,7 @@ static int advk_msi_irq_domain_alloc(str domain->host_data, handle_simple_irq, NULL, NULL); -return hwirq; +return 0 ; } static void advk_msi_irq_domain_free(struct irq_domain *domain,
Greg Kroah-Hartman
maintainerPATCH 146/575 PCI: aardvark: Read all 16-bits from PCIE_MSI_PAYLOAD_REG
In reply to Greg Kroah-HartmanFrom: Marek Behún <[email protected]>
commit 95997723b6402cd6c53e0f9e7ac640ec64eaaff8 upstream.
The PCIE_MSI_PAYLOAD_REG contains 16-bit MSI number, not only lower 8 bits. Fix reading content of this register and add a comment describing the access to this register.
--- drivers/pci/controller/pci-aardvark.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/pci/controller/pci-aardvark.c +6 -1
@@ -118,6 +118,7 @@#define PCIE_MSI_STATUS_REG (CONTROL_BASE_ADDR + 0x58)#define PCIE_MSI_MASK_REG (CONTROL_BASE_ADDR + 0x5C)#define PCIE_MSI_PAYLOAD_REG (CONTROL_BASE_ADDR + 0x9C) +#define PCIE_MSI_DATA_MASK GENMASK(15, 0)/* PCIe window configuration */ #define OB_WIN_BASE_ADDR 0x4c00
@@ -1361,8 +1362,12 @@ static void advk_pcie_handle_msi(structif (!(BIT (msi_idx) & msi_status))continue ; +/* +* msi_idx contains bits [4:0] of the msi_data and msi_data +* contains 16bit MSI interrupt number +*/ advk_writel (pcie,BIT (msi_idx),PCIE_MSI_STATUS_REG ); - msi_data =advk_readl (pcie,PCIE_MSI_PAYLOAD_REG ) &0xFF ; + msi_data =advk_readl (pcie,PCIE_MSI_PAYLOAD_REG ) &PCIE_MSI_DATA_MASK ;generic_handle_irq (msi_data); }
Greg Kroah-Hartman
maintainerPATCH 147/575 PCI: aardvark: Fix support for bus mastering and PCI_COMMAND on emulated bridge
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 771153fc884f566a89af2d30033b7f3bc6e24e84 upstream.
Quoted 1 line
From very vague, ambiguous and incomplete information from Marvell we
deduced that the 32-bit Aardvark register at address 0x4 (PCIE_CORE_CMD_STATUS_REG), which is not documented for Root Complex mode in the Functional Specification (only for Endpoint mode), controls two 16-bit PCIe registers: Command Register and Status Registers of PCIe Root Port.
This means that bit 2 controls bus mastering and forwarding of memory and I/O requests in the upstream direction. According to PCI specifications bits [0:2] of Command Register, this should be by default disabled on reset. So explicitly disable these bits at early setup of the Aardvark driver.
Remove code which unconditionally enables all 3 bits and let kernel code (via pci_set_master() function) to handle bus mastering of Root PCIe Bridge via emulated PCI_COMMAND on emulated bridge.
--- drivers/pci/controller/pci-aardvark.c | 54 +++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 16 deletions(-)
drivers/pci/controller/pci-aardvark.c +38 -16
@@ -30,9 +30,6 @@/* PCIe core registers */ #define PCIE_CORE_DEV_ID_REG 0x0#define PCIE_CORE_CMD_STATUS_REG 0x4 -#define PCIE_CORE_CMD_IO_ACCESS_EN BIT(0) -#define PCIE_CORE_CMD_MEM_ACCESS_EN BIT(1) -#define PCIE_CORE_CMD_MEM_IO_REQ_EN BIT(2)#define PCIE_CORE_DEV_REV_REG 0x8#define PCIE_CORE_PCIEXP_CAP 0xc0#define PCIE_CORE_ERR_CAPCTL_REG 0x118
@@ -563,6 +560,11 @@ static void advk_pcie_setup_hw(struct ad reg = (PCI_VENDOR_ID_MARVELL <<16 ) |PCI_VENDOR_ID_MARVELL ;advk_writel (pcie, reg,VENDOR_ID_REG ); +/* Disable Root Bridge I/O space, memory space and bus mastering */ + reg =advk_readl (pcie,PCIE_CORE_CMD_STATUS_REG ); + reg &= ~(PCI_COMMAND_IO |PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER ); +advk_writel (pcie, reg,PCIE_CORE_CMD_STATUS_REG ); +/* Set Advanced Error Capabilities and Control PF0 register */ reg =PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX | PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX_EN |
@@ -660,19 +662,6 @@ static void advk_pcie_setup_hw(struct adadvk_pcie_disable_ob_win (pcie, i);advk_pcie_train_link (pcie); - -/* -* FIXME: The following register update is suspicious. This register is -* applicable only when the PCI controller is configured for Endpoint -* mode, not as a Root Complex. But apparently when this code is -* removed, some cards stop working. This should be investigated and -* a comment explaining this should be put here. -*/ - reg =advk_readl (pcie,PCIE_CORE_CMD_STATUS_REG ); - reg |=PCIE_CORE_CMD_MEM_ACCESS_EN | -PCIE_CORE_CMD_IO_ACCESS_EN | -PCIE_CORE_CMD_MEM_IO_REQ_EN ; -advk_writel (pcie, reg,PCIE_CORE_CMD_STATUS_REG ); }static int advk_pcie_check_pio_status (struct advk_pcie *pcie,bool allow_crs,u32 *val)
@@ -793,6 +782,37 @@ static int advk_pcie_wait_pio(struct advreturn -ETIMEDOUT ; } +static pci_bridge_emul_read_status_t +advk_pci_bridge_emul_base_conf_read (struct pci_bridge_emul *bridge, +int reg,u32 *value) +{ +struct advk_pcie *pcie = bridge->data; + +switch (reg) { +case PCI_COMMAND : + *value =advk_readl (pcie,PCIE_CORE_CMD_STATUS_REG ); +return PCI_BRIDGE_EMUL_HANDLED ; + +default : +return PCI_BRIDGE_EMUL_NOT_HANDLED ; + } +} + +static void +advk_pci_bridge_emul_base_conf_write (struct pci_bridge_emul *bridge, +int reg,u32 old,u32 new,u32 mask) +{ +struct advk_pcie *pcie = bridge->data; + +switch (reg) { +case PCI_COMMAND : +advk_writel (pcie, new,PCIE_CORE_CMD_STATUS_REG ); +break ; + +default : +break ; + } +} static pci_bridge_emul_read_status_t advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge,
@@ -893,6 +913,8 @@ advk_pci_bridge_emul_pcie_conf_write(str }static struct pci_bridge_emul_ops advk_pci_bridge_emul_ops = { + .read_base = advk_pci_bridge_emul_base_conf_read, + .write_base = advk_pci_bridge_emul_base_conf_write, .read_pcie = advk_pci_bridge_emul_pcie_conf_read, .write_pcie = advk_pci_bridge_emul_pcie_conf_write, };
Greg Kroah-Hartman
maintainerPATCH 148/575 PCI: aardvark: Fix support for PCI_BRIDGE_CTL_BUS_RESET on emulated bridge
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit bc4fac42e5f8460af09c0a7f2f1915be09e20c71 upstream.
Aardvark supports PCIe Hot Reset via PCIE_CORE_CTRL1_REG.
Use it for implementing PCI_BRIDGE_CTL_BUS_RESET bit of PCI_BRIDGE_CONTROL register on emulated bridge.
With this, the function pci_reset_secondary_bus() starts working and can reset connected PCIe card. Custom userspace script [1] which uses setpci can trigger PCIe Hot Reset and reset the card manually.
[1] https://alexforencich.com/wiki/en/pcie/hot-reset-linux
--- drivers/pci/controller/pci-aardvark.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/pci/controller/pci-aardvark.c +27 -0
@@ -793,6 +793,22 @@ advk_pci_bridge_emul_base_conf_read(stru *value =advk_readl (pcie,PCIE_CORE_CMD_STATUS_REG );return PCI_BRIDGE_EMUL_HANDLED ; +case PCI_INTERRUPT_LINE : { +/* +* From the whole 32bit register we support reading from HW only +* one bit: PCI_BRIDGE_CTL_BUS_RESET. +* Other bits are retrieved only from emulated config buffer. +*/ +__le32 *cfgspace = (__le32 *)&bridge->conf; +u32 val =le32_to_cpu (cfgspace[PCI_INTERRUPT_LINE /4 ]); +if (advk_readl (pcie,PCIE_CORE_CTRL1_REG ) &HOT_RESET_GEN ) + val |=PCI_BRIDGE_CTL_BUS_RESET <<16 ; +else + val &= ~(PCI_BRIDGE_CTL_BUS_RESET <<16 ); + *value = val; +return PCI_BRIDGE_EMUL_HANDLED ; + } +default :return PCI_BRIDGE_EMUL_NOT_HANDLED ; }
@@ -809,6 +825,17 @@ advk_pci_bridge_emul_base_conf_write(stradvk_writel (pcie, new,PCIE_CORE_CMD_STATUS_REG );break ; +case PCI_INTERRUPT_LINE : +if (mask & (PCI_BRIDGE_CTL_BUS_RESET <<16 )) { +u32 val =advk_readl (pcie,PCIE_CORE_CTRL1_REG ); +if (new & (PCI_BRIDGE_CTL_BUS_RESET <<16 )) + val |=HOT_RESET_GEN ; +else + val &= ~HOT_RESET_GEN ; +advk_writel (pcie, val,PCIE_CORE_CTRL1_REG ); + } +break ; +default :break ; }
Greg Kroah-Hartman
maintainerPATCH 149/575 PCI: aardvark: Set PCI Bridge Class Code to PCI Bridge
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 84e1b4045dc887b78bdc87d92927093dc3a465aa upstream.
Aardvark controller has something like config space of a Root Port available at offset 0x0 of internal registers - these registers are used for implementation of the emulated bridge.
The default value of Class Code of this bridge corresponds to a RAID Mass storage controller, though. (This is probably intended for when the controller is used as Endpoint.)
Change the Class Code to correspond to a PCI Bridge.
Add comment explaining this change.
--- drivers/pci/controller/pci-aardvark.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/pci/controller/pci-aardvark.c +20 -0
@@ -560,6 +560,26 @@ static void advk_pcie_setup_hw(struct ad reg = (PCI_VENDOR_ID_MARVELL <<16 ) |PCI_VENDOR_ID_MARVELL ;advk_writel (pcie, reg,VENDOR_ID_REG ); +/* +* Change Class Code of PCI Bridge device to PCI Bridge (0x600400), +* because the default value is Mass storage controller (0x010400). +* +* Note that this Aardvark PCI Bridge does not have compliant Type 1 +* Configuration Space and it even cannot be accessed via Aardvark's +* PCI config space access method. Something like config space is +* available in internal Aardvark registers starting at offset 0x0 +* and is reported as Type 0. In range 0x10 - 0x34 it has totally +* different registers. +* +* Therefore driver uses emulation of PCI Bridge which emulates +* access to configuration space via internal Aardvark registers or +* emulated configuration buffer. +*/ + reg =advk_readl (pcie,PCIE_CORE_DEV_REV_REG ); + reg &= ~0xffffff00 ; + reg |= (PCI_CLASS_BRIDGE_PCI <<8 ) <<8 ; +advk_writel (pcie, reg,PCIE_CORE_DEV_REV_REG ); +/* Disable Root Bridge I/O space, memory space and bus mastering */ reg =advk_readl (pcie,PCIE_CORE_CMD_STATUS_REG ); reg &= ~(PCI_COMMAND_IO |PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER );
Greg Kroah-Hartman
maintainerPATCH 150/575 PCI: aardvark: Fix support for PCI_ROM_ADDRESS1 on emulated bridge
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 239edf686c14a9ff926dec2f350289ed7adfefe2 upstream.
This register is exported at address offset 0x30.
--- drivers/pci/controller/pci-aardvark.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/pci/controller/pci-aardvark.c +9 -0
@@ -31,6 +31,7 @@#define PCIE_CORE_DEV_ID_REG 0x0#define PCIE_CORE_CMD_STATUS_REG 0x4#define PCIE_CORE_DEV_REV_REG 0x8 +#define PCIE_CORE_EXP_ROM_BAR_REG 0x30#define PCIE_CORE_PCIEXP_CAP 0xc0#define PCIE_CORE_ERR_CAPCTL_REG 0x118#define PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX BIT(5)
@@ -813,6 +814,10 @@ advk_pci_bridge_emul_base_conf_read(stru *value =advk_readl (pcie,PCIE_CORE_CMD_STATUS_REG );return PCI_BRIDGE_EMUL_HANDLED ; +case PCI_ROM_ADDRESS1 : + *value =advk_readl (pcie,PCIE_CORE_EXP_ROM_BAR_REG ); +return PCI_BRIDGE_EMUL_HANDLED ; +case PCI_INTERRUPT_LINE : {/* * From the whole 32bit register we support reading from HW only
@@ -845,6 +850,10 @@ advk_pci_bridge_emul_base_conf_write(stradvk_writel (pcie, new,PCIE_CORE_CMD_STATUS_REG );break ; +case PCI_ROM_ADDRESS1 : +advk_writel (pcie, new,PCIE_CORE_EXP_ROM_BAR_REG ); +break ; +case PCI_INTERRUPT_LINE :if (mask & (PCI_BRIDGE_CTL_BUS_RESET <<16 )) {u32 val =advk_readl (pcie,PCIE_CORE_CTRL1_REG );
Greg Kroah-Hartman
maintainerPATCH 151/575 quota: check block number when reading the block in quota file
In reply to Greg Kroah-HartmanFrom: Zhang Yi <[email protected]>
commit 9bf3d20331295b1ecb81f4ed9ef358c51699a050 upstream.
The block number in the quota tree on disk should be smaller than the v2_disk_dqinfo.dqi_blocks. If the quota file was corrupted, we may be allocating an 'allocated' block and that would lead to a loop in a tree, which will probably trigger oops later. This patch adds a check for the block number in the quota tree to prevent such potential issue.
--- fs/quota/quota_tree.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/quota/quota_tree.c +14 -0
@@ -488,6 +488,13 @@ static int remove_tree(struct qtree_mem_ goto out_buf; } newblk =le32_to_cpu (ref[get_index (info, dquot->dq_id, depth)]); +if (newblk <QT_TREEOFF || newblk >= info->dqi_blocks) { +quota_error (dquot->dq_sb,"Getting block too big (%u >= %u)" , + newblk, info->dqi_blocks); + ret = -EUCLEAN ; + goto out_buf; + } +if (depth == info->dqi_qtree_depth -1 ) { ret =free_dqentry (info, dquot, newblk); newblk =0 ;
@@ -587,6 +594,13 @@ static loff_t find_tree_dqentry(struct q blk =le32_to_cpu (ref[get_index (info, dquot->dq_id, depth)]);if (!blk)/* No reference? */ goto out_buf; +if (blk <QT_TREEOFF || blk >= info->dqi_blocks) { +quota_error (dquot->dq_sb,"Getting block too big (%u >= %u)" , + blk, info->dqi_blocks); + ret = -EUCLEAN ; + goto out_buf; + } +if (depth < info->dqi_qtree_depth -1 ) ret =find_tree_dqentry (info, dquot, blk, depth+1 );else
Greg Kroah-Hartman
maintainerPATCH 152/575 quota: correct error number in free_dqentry()
In reply to Greg Kroah-HartmanFrom: Zhang Yi <[email protected]>
commit d0e36a62bd4c60c09acc40e06ba4831a4d0bc75b upstream.
Fix the error path in free_dqentry(), pass out the error number if the block to free is not correct.
--- fs/quota/quota_tree.c | 1 + 1 file changed, 1 insertion(+)
fs/quota/quota_tree.c +1 -0
@@ -423,6 +423,7 @@ static int free_dqentry(struct qtree_memquota_error (dquot->dq_sb,"Quota structure has offset to " "other block (%u) than it should (%u)" , blk, (uint)(dquot->dq_off >> info->dqi_blocksize_bits)); + ret = -EIO ; goto out_buf; } ret =read_blk (info, blk, buf);
Greg Kroah-Hartman
maintainerPATCH 153/575 pinctrl: core: fix possible memory leak in pinctrl_enable()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
commit c7892ae13e461ed20154321eb792e07ebe38f5b3 upstream.
I got memory leak as follows when doing fault injection test:
unreferenced object 0xffff888020a7a680 (size 64):
comm "i2c-mcp23018-41", pid 23090, jiffies 4295160544 (age 8.680s) hex dump (first 32 bytes):
00 48 d3 1e 80 88 ff ff 00 1a 56 c1 ff ff ff ff .H........V.....
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000083c79b35>] kmem_cache_alloc_trace+0x16d/0x360
[<0000000051803c95>] pinctrl_init_controller+0x6ed/0xb70
[<0000000064346707>] pinctrl_register+0x27/0x80
[<0000000029b0e186>] devm_pinctrl_register+0x5b/0xe0
[<00000000391f5a3e>] mcp23s08_probe_one+0x968/0x118a [pinctrl_mcp23s08]
[<000000006112c039>] mcp230xx_probe+0x266/0x560 [pinctrl_mcp23s08_i2c]If pinctrl_claim_hogs() fails, the 'pindesc' allocated in pinctrl_register_one_pin() need be freed.
--- drivers/pinctrl/core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/core.c +2 -0
@@ -2077,6 +2077,8 @@ int pinctrl_enable(struct pinctrl_dev *pif (error) {dev_err (pctldev->dev,"could not claim hogs: %i\n" , error); +pinctrl_free_pindescs (pctldev, pctldev->desc->pins, + pctldev->desc->npins);mutex_destroy (&pctldev->mutex);kfree (pctldev);
Greg Kroah-Hartman
maintainerPATCH 154/575 coresight: cti: Correct the parameter for pm_runtime_put
In reply to Greg Kroah-HartmanFrom: Tao Zhang <[email protected]>
commit 692c9a499b286ea478f41b23a91fe3873b9e1326 upstream.
The input parameter of the function pm_runtime_put should be the same in the function cti_enable_hw and cti_disable_hw. The correct parameter to use here should be dev->parent.
--- drivers/hwtracing/coresight/coresight-cti-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-cti-core.c +1 -1
@@ -174,7 +174,7 @@ static int cti_disable_hw(struct cti_drvcoresight_disclaim_device_unlocked (drvdata->base);CS_LOCK (drvdata->base);spin_unlock (&drvdata->spinlock); -pm_runtime_put (dev); +pm_runtime_put (dev->parent);return 0 ;/* not disabled this call */
Greg Kroah-Hartman
maintainerPATCH 155/575 iio: dac: ad5446: Fix ad5622_write() return value
In reply to Greg Kroah-HartmanFrom: Pekka Korpinen <[email protected]>
commit 558df982d4ead9cac628153d0d7b60feae05ddc8 upstream.
On success i2c_master_send() returns the number of bytes written. The call from iio_write_channel_info(), however, expects the return value to be zero on success.
This bug causes incorrect consumption of the sysfs buffer in iio_write_channel_info(). When writing more than two characters to out_voltage0_raw, the ad5446 write handler is called multiple times causing unexpected behavior.
--- drivers/iio/dac/ad5446.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/iio/dac/ad5446.c +8 -1
@@ -531,8 +531,15 @@ static int ad5622_write(struct ad5446_st {struct i2c_client *client =to_i2c_client (st->dev);__be16 data =cpu_to_be16 (val); +int ret; -return i2c_master_send (client, (char *)&data,sizeof (data)); + ret =i2c_master_send (client, (char *)&data,sizeof (data)); +if (ret <0 ) +return ret; +if (ret !=sizeof (data)) +return -EIO ; + +return 0 ; }/*
Greg Kroah-Hartman
maintainerPATCH 156/575 iio: ad5770r: make devicetree property reading consistent
In reply to Greg Kroah-HartmanFrom: Nuno Sá <[email protected]>
commit 26df977a909f818b7d346b3990735513e7e0bf93 upstream.
The bindings file for this driver is defining the property as 'reg' but the driver was reading it with the 'num' name. The bindings actually had the 'num' property when added in
commit ea52c21268e6 ("dt-bindings: iio: dac: Add docs for AD5770R DAC") and then changed it to 'reg' in
commit 2cf3818f18b2 ("dt-bindings: iio: dac: AD5570R fix bindings errors"). However, both these commits landed in v5.7 so the assumption is that either 'num' is not being used or if it is, the validations were not done.
Anyways, if someone comes back yelling about this, we might just support both of the properties in the future. Not ideal, but that's life...
--- drivers/iio/dac/ad5770r.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/ad5770r.c +1 -1
@@ -522,7 +522,7 @@ static int ad5770r_channel_config(structreturn -EINVAL ;device_for_each_child_node (&st->spi->dev, child) { - ret =fwnode_property_read_u32 (child,"num" , &num); + ret =fwnode_property_read_u32 (child,"reg" , &num);if (ret) goto err_child_out;if (num >=AD5770R_MAX_CHANNELS ) {
Greg Kroah-Hartman
maintainerPATCH 157/575 USB: serial: keyspan: fix memleak on probe errors
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
commit 910c996335c37552ee30fcb837375b808bb4f33b upstream.
I got memory leak as follows when doing fault injection test:
unreferenced object 0xffff888258228440 (size 64):
comm "kworker/7:2", pid 2005, jiffies 4294989509 (age 824.540s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8167939c>] slab_post_alloc_hook+0x9c/0x490
[<ffffffff8167f627>] kmem_cache_alloc_trace+0x1f7/0x470
[<ffffffffa02ac0e4>] keyspan_port_probe+0xa4/0x5d0 [keyspan]
[<ffffffffa0294c07>] usb_serial_device_probe+0x97/0x1d0 [usbserial]
[<ffffffff82b50ca7>] really_probe+0x167/0x460
[<ffffffff82b51099>] __driver_probe_device+0xf9/0x180
[<ffffffff82b51173>] driver_probe_device+0x53/0x130
[<ffffffff82b516f5>] __device_attach_driver+0x105/0x130
[<ffffffff82b4cfe9>] bus_for_each_drv+0x129/0x190
[<ffffffff82b50a69>] __device_attach+0x1c9/0x270
[<ffffffff82b518d0>] device_initial_probe+0x20/0x30
[<ffffffff82b4f062>] bus_probe_device+0x142/0x160
[<ffffffff82b4a4e9>] device_add+0x829/0x1300
[<ffffffffa0295fda>] usb_serial_probe.cold+0xc9b/0x14ac [usbserial]
[<ffffffffa02266aa>] usb_probe_interface+0x1aa/0x3c0 [usbcore]
[<ffffffff82b50ca7>] really_probe+0x167/0x460If keyspan_port_probe() fails to allocate memory for an out_buffer[i] or in_buffer[i], the previously allocated memory for out_buffer or in_buffer needs to be freed on the error handling path, otherwise a memory leak will result.
--- drivers/usb/serial/keyspan.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/usb/serial/keyspan.c +7 -8
@@ -2910,22 +2910,22 @@ static int keyspan_port_probe(struct usbfor (i =0 ; i <ARRAY_SIZE (p_priv->in_buffer); ++i) { p_priv->in_buffer[i] =kzalloc (IN_BUFLEN ,GFP_KERNEL );if (!p_priv->in_buffer[i]) - goto err_in_buffer; + goto err_free_in_buffer; }for (i =0 ; i <ARRAY_SIZE (p_priv->out_buffer); ++i) { p_priv->out_buffer[i] =kzalloc (OUT_BUFLEN ,GFP_KERNEL );if (!p_priv->out_buffer[i]) - goto err_out_buffer; + goto err_free_out_buffer; } p_priv->inack_buffer =kzalloc (INACK_BUFLEN ,GFP_KERNEL );if (!p_priv->inack_buffer) - goto err_inack_buffer; + goto err_free_out_buffer; p_priv->outcont_buffer =kzalloc (OUTCONT_BUFLEN ,GFP_KERNEL );if (!p_priv->outcont_buffer) - goto err_outcont_buffer; + goto err_free_inack_buffer; p_priv->device_details = d_details;
@@ -2971,15 +2971,14 @@ static int keyspan_port_probe(struct usbreturn 0 ; -err_outcont_buffer: +err_free_inack_buffer:kfree (p_priv->inack_buffer); -err_inack_buffer: +err_free_out_buffer:for (i =0 ; i <ARRAY_SIZE (p_priv->out_buffer); ++i)kfree (p_priv->out_buffer[i]); -err_out_buffer: +err_free_in_buffer:for (i =0 ; i <ARRAY_SIZE (p_priv->in_buffer); ++i)kfree (p_priv->in_buffer[i]); -err_in_buffer:kfree (p_priv);return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 158/575 serial: 8250: fix racy uartclk update
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 211cde4f5817dc88ef7f8f2fa286e57fbf14c8ee upstream.
Commit 868f3ee6e452 ("serial: 8250: Add 8250 port clock update method") added a hack to support SoCs where the UART reference clock can change behind the back of the driver but failed to add the proper locking.
First, make sure to take a reference to the tty struct to avoid dereferencing a NULL pointer if the clock change races with a hangup.
Second, the termios semaphore must be held during the update to prevent a racing termios change.
--- drivers/tty/serial/8250/8250_port.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_port.c +17 -4
@@ -2675,21 +2675,32 @@ static unsigned int serial8250_get_baud_void serial8250_update_uartclk (struct uart_port *port,unsigned int uartclk) {struct uart_8250_port *up =up_to_u8250p (port); +struct tty_port *tport = &port->state->port;unsigned int baud, quot, frac =0 ;struct ktermios *termios; +struct tty_struct *tty;unsigned long flags; -mutex_lock (&port->state->port.mutex); + tty =tty_port_tty_get (tport); +if (!tty) { +mutex_lock (&tport->mutex); + port->uartclk = uartclk; +mutex_unlock (&tport->mutex); +return ; + } + +down_write (&tty->termios_rwsem); +mutex_lock (&tport->mutex);if (port->uartclk == uartclk) goto out_lock; port->uartclk = uartclk; -if (!tty_port_initialized (&port->state->port)) +if (!tty_port_initialized (tport)) goto out_lock; - termios = &port->state->port.tty->termios; + termios = &tty->termios; baud =serial8250_get_baud_rate (port, termios,NULL ); quot =serial8250_get_divisor (port, baud, &frac);
@@ -2706,7 +2717,9 @@ void serial8250_update_uartclk(struct uaserial8250_rpm_put (up); out_lock: -mutex_unlock (&port->state->port.mutex); +mutex_unlock (&tport->mutex); +up_write (&tty->termios_rwsem); +tty_kref_put (tty); }EXPORT_SYMBOL_GPL (serial8250_update_uartclk);
Greg Kroah-Hartman
maintainerPATCH 159/575 most: fix control-message timeouts
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 63b3e810eff65fb8587fcb26fa0b56802be12dcf upstream.
USB control-message timeouts are specified in milliseconds and should specifically not vary with CONFIG_HZ.
Use the common control-message timeout defines for the five-second timeouts.
--- drivers/most/most_usb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/most/most_usb.c +3 -2
@@ -149,7 +149,8 @@ static inline int drci_rd_reg(struct usb retval =usb_control_msg (dev,usb_rcvctrlpipe (dev,0 ),DRCI_READ_REQ , req_type,0x0000 , - reg, dma_buf,sizeof (*dma_buf),5 *HZ ); + reg, dma_buf,sizeof (*dma_buf), +USB_CTRL_GET_TIMEOUT ); *buf =le16_to_cpu (*dma_buf);kfree (dma_buf);
@@ -176,7 +177,7 @@ static inline int drci_wr_reg(struct usb reg,NULL ,0 , - 5 * HZ); + USB_CTRL_SET_TIMEOUT); }static inline int start_sync_ep (struct usb_device *usb_dev,u16 ep)
Greg Kroah-Hartman
maintainerPATCH 160/575 USB: iowarrior: fix control-message timeouts
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 79a4479a17b83310deb0b1a2a274fe5be12d2318 upstream.
USB control-message timeouts are specified in milliseconds and should specifically not vary with CONFIG_HZ.
Use the common control-message timeout define for the five-second timeout and drop the driver-specific one.
--- drivers/usb/misc/iowarrior.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/usb/misc/iowarrior.c +2 -6
@@ -99,10 +99,6 @@ struct iowarrior {/* globals */ /*--------------*/ -/* -* USB spec identifies 5 second timeouts. -*/ -#define GET_TIMEOUT 5#define USB_REQ_GET_REPORT 0x01//#if 0 static int usb_get_report(struct usb_device *dev,
@@ -114,7 +110,7 @@ static int usb_get_report(struct usb_devUSB_DIR_IN |USB_TYPE_CLASS |USB_RECIP_INTERFACE , (type <<8 ) + id, inter->desc.bInterfaceNumber, buf, size, - GET_TIMEOUT*HZ); + USB_CTRL_GET_TIMEOUT); }//#endif
@@ -129,7 +125,7 @@ static int usb_set_report(struct usb_intUSB_TYPE_CLASS |USB_RECIP_INTERFACE , (type <<8 ) + id, intf->cur_altsetting->desc.bInterfaceNumber, buf, - size, HZ); + size, 1000); }/*---------------------*/
Greg Kroah-Hartman
maintainerPATCH 161/575 USB: chipidea: fix interrupt deadlock
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 9aaa81c3366e8393a62374e3a1c67c69edc07b8a upstream.
Chipidea core was calling the interrupt handler from non-IRQ context with interrupts enabled, something which can lead to a deadlock if there's an actual interrupt trying to take a lock that's already held (e.g. the controller lock in udc_irq()).
Add a wrapper that can be used to fake interrupts instead of calling the handler directly.
--- drivers/usb/chipidea/core.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
drivers/usb/chipidea/core.c +16 -7
@@ -509,7 +509,7 @@ int hw_device_reset(struct ci_hdrc *ci)return 0 ; } -static irqreturn_t ci_irq (int irq,void *data) +static irqreturn_t ci_irq_handler (int irq,void *data) {struct ci_hdrc *ci = data;irqreturn_t ret =IRQ_NONE ;
@@ -562,6 +562,15 @@ static irqreturn_t ci_irq(int irq, voidreturn ret; } +static void ci_irq (struct ci_hdrc *ci) +{ +unsigned long flags; + +local_irq_save (flags); +ci_irq_handler (ci->irq, ci); +local_irq_restore (flags); +} +static int ci_cable_notifier (struct notifier_block *nb,unsigned long event,void *ptr) {
@@ -571,7 +580,7 @@ static int ci_cable_notifier(struct noti cbl->connected = event; cbl->changed = true; -ci_irq (ci->irq, ci); +ci_irq (ci);return NOTIFY_DONE ; }
@@ -612,7 +621,7 @@ static int ci_usb_role_switch_set(structif (cable) { cable->changed = true; cable->connected = false; -ci_irq (ci->irq, ci); +ci_irq (ci);spin_unlock_irqrestore (&ci->lock, flags);if (ci->wq && role !=USB_ROLE_NONE )flush_workqueue (ci->wq);
@@ -630,7 +639,7 @@ static int ci_usb_role_switch_set(structif (cable) { cable->changed = true; cable->connected = true; -ci_irq (ci->irq, ci); +ci_irq (ci); }spin_unlock_irqrestore (&ci->lock, flags);pm_runtime_put_sync (ci->dev);
@@ -1166,7 +1175,7 @@ static int ci_hdrc_probe(struct platform } } - ret =devm_request_irq (dev, ci->irq, ci_irq,IRQF_SHARED , + ret =devm_request_irq (dev, ci->irq, ci_irq_handler,IRQF_SHARED , ci->platdata->name, ci);if (ret) goto stop;
@@ -1287,11 +1296,11 @@ static void ci_extcon_wakeup_int(structif (!IS_ERR (cable_id->edev) && ci->is_otg && (otgsc &OTGSC_IDIE ) && (otgsc &OTGSC_IDIS )) -ci_irq (ci->irq, ci); +ci_irq (ci);if (!IS_ERR (cable_vbus->edev) && ci->is_otg && (otgsc &OTGSC_BSVIE ) && (otgsc &OTGSC_BSVIS )) -ci_irq (ci->irq, ci); +ci_irq (ci); }static int ci_controller_resume (struct device *dev)
Greg Kroah-Hartman
maintainerPATCH 162/575 power: supply: max17042_battery: Clear status bits in interrupt handler
In reply to Greg Kroah-HartmanFrom: Sebastian Krzyszkowiak <[email protected]>
commit 0cf48167b87e388fa1268c9fe6d2443ae7f43d8a upstream.
The gauge requires us to clear the status bits manually for some alerts to be properly dismissed. Previously the IRQ was configured to react only on falling edge, which wasn't technically correct (the ALRT line is active low), but it had a happy side-effect of preventing interrupt storms on uncleared alerts from happening.
--- drivers/power/supply/max17042_battery.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/power/supply/max17042_battery.c +4 -0
@@ -875,6 +875,10 @@ static irqreturn_t max17042_thread_handlmax17042_set_soc_threshold (chip,1 ); } +/* we implicitly handle all alerts via power_supply_changed */ +regmap_clear_bits (chip->regmap,MAX17042_STATUS , +0xFFFF & ~(STATUS_POR_BIT |STATUS_BST_BIT )); +power_supply_changed (chip->battery);return IRQ_HANDLED ; }
Greg Kroah-Hartman
maintainerPATCH 163/575 dma-buf: WARN on dmabuf release with pending attachments
In reply to Greg Kroah-HartmanFrom: Charan Teja Reddy <[email protected]>
[ Upstream commit f492283b157053e9555787262f058ae33096f568 ]
It is expected from the clients to follow the below steps on an imported dmabuf fd:
a) dmabuf = dma_buf_get(fd) // Get the dmabuf from fd
b) dma_buf_attach(dmabuf); // Clients attach to the dmabuf
o Here the kernel does some slab allocations, say fordma_buf_attachment and may be some other slab allocation in the dmabuf->ops->attach().
c) Client may need to do dma_buf_map_attachment().
d) Accordingly dma_buf_unmap_attachment() should be called.
e) dma_buf_detach () // Clients detach to the dmabuf.
o Here the slab allocations made in b) are freed.
f) dma_buf_put(dmabuf) // Can free the dmabuf if it is the last reference.
Now say an erroneous client failed at step c) above thus it directly called dma_buf_put(), step f) above. Considering that it may be the last reference to the dmabuf, buffer will be freed with pending attachments left to the dmabuf which can show up as the 'memory leak'. This should at least be reported as the WARN().
--- drivers/dma-buf/dma-buf.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma-buf/dma-buf.c +1 -0
@@ -79,6 +79,7 @@ static void dma_buf_release(struct dentry *dentry)if (dmabuf->resv == (struct dma_resv *)&dmabuf[1 ])dma_resv_fini (dmabuf->resv); +WARN_ON (!list_empty (&dmabuf->attachments));module_put (dmabuf->owner);kfree (dmabuf->name);kfree (dmabuf);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 164/575 drm: panel-orientation-quirks: Update the Lenovo Ideapad D330 quirk (v2)
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 820a2ab23d5eab4ccfb82581eda8ad4acf18458f ]
2 improvements to the Lenovo Ideapad D330 panel-orientation quirks:
1. Some versions of the Lenovo Ideapad D330 have a DMI_PRODUCT_NAME of "81H3" and others have "81MD". Testing has shown that the "81MD" also has a 90 degree mounted panel. Drop the DMI_PRODUCT_NAME from the existing quirk so that the existing quirk matches both variants.
2. Some of the Lenovo Ideapad D330 models have a HD (800x1280) screen instead of a FHD (1200x1920) screen (both are mounted right-side-up) add a second Lenovo Ideapad D330 quirk for the HD version.
Changes in v2:
- Add a new quirk for Lenovo Ideapad D330 models with a HD screen instead of a FHD screen
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_panel_orientation_quirks.c +7 -2
@@ -223,10 +223,15 @@ static const struct dmi_system_id orientation_data[] = { DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"), }, .driver_data = (void *)&lcd800x1280_rightside_up, - }, { /* Lenovo Ideapad D330 */ + }, { /* Lenovo Ideapad D330-10IGM (HD) */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), + DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad D330-10IGM"), + }, + .driver_data = (void *)&lcd800x1280_rightside_up, + }, { /* Lenovo Ideapad D330-10IGM (FHD) */ .matches = {DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), -DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"81H3" ), DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad D330-10IGM"), }, .driver_data = (void *)&lcd1200x1920_rightside_up,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 165/575 drm: panel-orientation-quirks: Add quirk for KD Kurio Smart C15200 2-in-1
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit a53f1dd3ab9fec715c6c2e8e01bf4d3c07eef8e5 ]
The KD Kurio Smart C15200 2-in-1 uses a panel which has been mounted 90 degrees rotated. Add a quirk for this.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +7 -0
@@ -205,6 +205,13 @@ static const struct dmi_system_id orientation_data[] = { DMI_EXACT_MATCH(DMI_BOARD_NAME, "TW891"), }, .driver_data = (void *)&itworks_tw891, + }, { /* KD Kurio Smart C15200 2-in-1 */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"KD Interactive" ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"Kurio Smart" ), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "KDM960BCP"), + }, + .driver_data = (void *)&lcd800x1280_rightside_up, }, { /** Lenovo Ideapad Miix 310 laptop, only some production batches * have a portrait screen, the resolution checks makes the quirk
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 166/575 drm: panel-orientation-quirks: Add quirk for the Samsung Galaxy Book 10.6
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 88fa1fde918951c175ae5ea0f31efc4bb1736ab9 ]
The Samsung Galaxy Book 10.6 uses a panel which has been mounted 90 degrees rotated. Add a quirk for this.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +12 -0
@@ -109,6 +109,12 @@ static const struct drm_dmi_panel_orientation_data lcd1200x1920_rightside_up = { .orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP, }; +static const struct drm_dmi_panel_orientation_data lcd1280x1920_rightside_up = { + .width =1280 , + .height =1920 , + .orientation =DRM_MODE_PANEL_ORIENTATION_RIGHT_UP , +}; +static const struct dmi_system_id orientation_data[] = { {/* Acer One 10 (S1003) */ .matches = {
@@ -249,6 +255,12 @@ static const struct dmi_system_id orientation_data[] = { DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Default string"), }, .driver_data = (void *)&onegx1_pro, + }, { /* Samsung GalaxyBook 10.6 */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"SAMSUNG ELECTRONICS CO., LTD." ), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Galaxy Book 10.6"), + }, + .driver_data = (void *)&lcd1280x1920_rightside_up, }, { /* VIOS LTH17 */ .matches = { DMI_EXACT_MATCH(DMI_SYS_VENDOR, "VIOS"),
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 167/575 Bluetooth: sco: Fix lock_sock() blockage by memcpy_from_msg()
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit 99c23da0eed4fd20cae8243f2b51e10e66aa0951 ]
The sco_send_frame() also takes lock_sock() during memcpy_from_msg() call that may be endlessly blocked by a task with userfaultd technique, and this will result in a hung task watchdog trigger.
Just like the similar fix for hci_sock_sendmsg() in commit 92c685dc5de0 ("Bluetooth: reorganize functions..."), this patch moves the memcpy_from_msg() out of lock_sock() for addressing the hang.
This should be the last piece for fixing CVE-2021-3640 after a few already queued fixes.
--- net/bluetooth/sco.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
net/bluetooth/sco.c +16 -8
@@ -281,7 +281,8 @@ static int sco_connect(struct hci_dev *hdev, struct sock *sk)return err; } -static int sco_send_frame (struct sock *sk,struct msghdr *msg,int len) +static int sco_send_frame (struct sock *sk,void *buf,int len, +unsigned int msg_flags) {struct sco_conn *conn =sco_pi (sk)->conn;struct sk_buff *skb;
@@ -293,15 +294,11 @@ static int sco_send_frame(struct sock *sk, struct msghdr *msg, int len)BT_DBG ("sk %p len %d" , sk, len); - skb =bt_skb_send_alloc (sk, len, msg->msg_flags &MSG_DONTWAIT , &err); + skb =bt_skb_send_alloc (sk, len, msg_flags &MSG_DONTWAIT , &err);if (!skb)return err; -if (memcpy_from_msg (skb_put (skb, len), msg, len)) { -kfree_skb (skb); -return -EFAULT ; - } - +memcpy (skb_put (skb, len), buf, len);hci_send_sco (conn->hcon, skb);return len;
@@ -726,6 +723,7 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) {struct sock *sk = sock->sk; +void *buf;int err;BT_DBG ("sock %p, sk %p" , sock, sk);
@@ -737,14 +735,24 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,if (msg->msg_flags &MSG_OOB )return -EOPNOTSUPP ; + buf =kmalloc (len,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + +if (memcpy_from_msg (buf, msg, len)) { +kfree (buf); +return -EFAULT ; + } +lock_sock (sk);if (sk->sk_state ==BT_CONNECTED ) - err =sco_send_frame (sk, msg, len); + err =sco_send_frame (sk, buf, len, msg->msg_flags);else err = -ENOTCONN ;release_sock (sk); +kfree (buf);return err; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 168/575 Bluetooth: fix use-after-free error in lock_sock_nested()
In reply to Greg Kroah-HartmanFrom: Wang ShaoBo <[email protected]>
[ Upstream commit 1bff51ea59a9afb67d2dd78518ab0582a54a472c ]
use-after-free error in lock_sock_nested is reported:
[ 179.140137][ T3731] ===================================================== [ 179.142675][ T3731] BUG: KMSAN: use-after-free in lock_sock_nested+0x280/0x2c0 [ 179.145494][ T3731] CPU: 4 PID: 3731 Comm: kworker/4:2 Not tainted 5.12.0-rc6+ #54 [ 179.148432][ T3731] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 [ 179.151806][ T3731] Workqueue: events l2cap_chan_timeout [ 179.152730][ T3731] Call Trace: [ 179.153301][ T3731] dump_stack+0x24c/0x2e0 [ 179.154063][ T3731] kmsan_report+0xfb/0x1e0 [ 179.154855][ T3731] __msan_warning+0x5c/0xa0 [ 179.155579][ T3731] lock_sock_nested+0x280/0x2c0 [ 179.156436][ T3731] ? kmsan_get_metadata+0x116/0x180 [ 179.157257][ T3731] l2cap_sock_teardown_cb+0xb8/0x890 [ 179.158154][ T3731] ? __msan_metadata_ptr_for_load_8+0x10/0x20 [ 179.159141][ T3731] ? kmsan_get_metadata+0x116/0x180 [ 179.159994][ T3731] ? kmsan_get_shadow_origin_ptr+0x84/0xb0 [ 179.160959][ T3731] ? l2cap_sock_recv_cb+0x420/0x420 [ 179.161834][ T3731] l2cap_chan_del+0x3e1/0x1d50 [ 179.162608][ T3731] ? kmsan_get_metadata+0x116/0x180 [ 179.163435][ T3731] ? kmsan_get_shadow_origin_ptr+0x84/0xb0 [ 179.164406][ T3731] l2cap_chan_close+0xeea/0x1050 [ 179.165189][ T3731] ? kmsan_internal_unpoison_shadow+0x42/0x70 [ 179.166180][ T3731] l2cap_chan_timeout+0x1da/0x590 [ 179.167066][ T3731] ? __msan_metadata_ptr_for_load_8+0x10/0x20 [ 179.168023][ T3731] ? l2cap_chan_create+0x560/0x560 [ 179.168818][ T3731] process_one_work+0x121d/0x1ff0 [ 179.169598][ T3731] worker_thread+0x121b/0x2370 [ 179.170346][ T3731] kthread+0x4ef/0x610 [ 179.171010][ T3731] ? process_one_work+0x1ff0/0x1ff0 [ 179.171828][ T3731] ? kthread_blkcg+0x110/0x110 [ 179.172587][ T3731] ret_from_fork+0x1f/0x30 [ 179.173348][ T3731] [ 179.173752][ T3731] Uninit was created at: [ 179.174409][ T3731] kmsan_internal_poison_shadow+0x5c/0xf0 [ 179.175373][ T3731] kmsan_slab_free+0x76/0xc0 [ 179.176060][ T3731] kfree+0x3a5/0x1180 [ 179.176664][ T3731] __sk_destruct+0x8af/0xb80 [ 179.177375][ T3731] __sk_free+0x812/0x8c0 [ 179.178032][ T3731] sk_free+0x97/0x130 [ 179.178686][ T3731] l2cap_sock_release+0x3d5/0x4d0 [ 179.179457][ T3731] sock_close+0x150/0x450 [ 179.180117][ T3731] __fput+0x6bd/0xf00 [ 179.180787][ T3731] ____fput+0x37/0x40 [ 179.181481][ T3731] task_work_run+0x140/0x280 [ 179.182219][ T3731] do_exit+0xe51/0x3e60 [ 179.182930][ T3731] do_group_exit+0x20e/0x450 [ 179.183656][ T3731] get_signal+0x2dfb/0x38f0 [ 179.184344][ T3731] arch_do_signal_or_restart+0xaa/0xe10 [ 179.185266][ T3731] exit_to_user_mode_prepare+0x2d2/0x560 [ 179.186136][ T3731] syscall_exit_to_user_mode+0x35/0x60 [ 179.186984][ T3731] do_syscall_64+0xc5/0x140 [ 179.187681][ T3731] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 179.188604][ T3731] =====================================================
In our case, there are two Thread A and B:
Context: Thread A: Context: Thread B:
l2cap_chan_timeout() __se_sys_shutdown()
l2cap_chan_close() l2cap_sock_shutdown()
l2cap_chan_del() l2cap_chan_close()
l2cap_sock_teardown_cb() l2cap_sock_teardown_cb()
Once l2cap_sock_teardown_cb() excuted, this sock will be marked as SOCK_ZAPPED, and can be treated as killable in l2cap_sock_kill() if sock_orphan() has excuted, at this time we close sock through sock_close() which end to call l2cap_sock_kill() like Thread C:
Context: Thread C:
sock_close()
l2cap_sock_release()
sock_orphan()
l2cap_sock_kill() #free sock if refcnt is 1
If C completed, Once A or B reaches l2cap_sock_teardown_cb() again, use-after-free happened.
We should set chan->data to NULL if sock is destructed, for telling teardown operation is not allowed in l2cap_sock_teardown_cb(), and also we should avoid killing an already killed socket in l2cap_sock_close_cb().
--- net/bluetooth/l2cap_sock.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_sock.c +9 -1
@@ -1508,6 +1508,9 @@ static void l2cap_sock_close_cb(struct l2cap_chan *chan) {struct sock *sk = chan->data; +if (!sk) +return ; +l2cap_sock_kill (sk); }
@@ -1516,6 +1519,9 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err)struct sock *sk = chan->data;struct sock *parent; +if (!sk) +return ; +BT_DBG ("chan %p state %s" , chan,state_to_string (chan->state));/* This callback can be called both for server (BT_LISTEN)
@@ -1707,8 +1713,10 @@ static void l2cap_sock_destruct(struct sock *sk) {BT_DBG ("sk %p" , sk); -if (l2cap_pi (sk)->chan) +if (l2cap_pi (sk)->chan) { +l2cap_pi (sk)->chan->data =NULL ;l2cap_chan_put (l2cap_pi (sk)->chan); + }if (l2cap_pi (sk)->rx_busy_skb) {kfree_skb (l2cap_pi (sk)->rx_busy_skb);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 169/575 drm/panel-orientation-quirks: add Valve Steam Deck
In reply to Greg Kroah-HartmanFrom: Simon Ser <[email protected]>
[ Upstream commit 9eeb7b4e40bfd69d8aaa920c7e9df751c9e11dce ]
Valve's Steam Deck has a 800x1280 LCD screen.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +7 -0
@@ -261,6 +261,13 @@ static const struct dmi_system_id orientation_data[] = { DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Galaxy Book 10.6"), }, .driver_data = (void *)&lcd1280x1920_rightside_up, + }, { /* Valve Steam Deck */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"Valve" ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"Jupiter" ), + DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "1"), + }, + .driver_data = (void *)&lcd800x1280_rightside_up, }, { /* VIOS LTH17 */ .matches = { DMI_EXACT_MATCH(DMI_SYS_VENDOR, "VIOS"),
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 170/575 rcutorture: Avoid problematic critical section nesting on PREEMPT_RT
In reply to Greg Kroah-HartmanFrom: Scott Wood <[email protected]>
[ Upstream commit 71921a9606ddbcc1d98c00eca7ae82c373d1fecd ]
rcutorture is generating some nesting scenarios that are not compatible on PREEMPT_RT. For example:
preempt_disable(); rcu_read_lock_bh(); preempt_enable(); rcu_read_unlock_bh();
The problem here is that on PREEMPT_RT the bottom halves have to be disabled and enabled in preemptible context.
Reorder locking: start with BH locking and continue with then with disabling preemption or interrupts. In the unlocking do it reverse by first enabling interrupts and preemption and BH at the very end. Ensure that on PREEMPT_RT BH locking remains unchanged if in non-preemptible context.
[bigeasy: Drop ATOM_BH, make it only about changing BH in atomic context. Allow enabling RCU in IRQ-off section. Reword commit message.]
--- kernel/rcu/rcutorture.c | 48 ++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 12 deletions(-)
kernel/rcu/rcutorture.c +36 -12
@@ -1238,28 +1238,34 @@ static void rcutorture_one_extend(int *readstate, int newstate,/* First, put new protection in place to avoid critical-section gap. */ if (statesnew &RCUTORTURE_RDR_BH )local_bh_disable (); +if (statesnew &RCUTORTURE_RDR_RBH ) +rcu_read_lock_bh ();if (statesnew &RCUTORTURE_RDR_IRQ )local_irq_disable ();if (statesnew &RCUTORTURE_RDR_PREEMPT )preempt_disable (); -if (statesnew &RCUTORTURE_RDR_RBH ) -rcu_read_lock_bh ();if (statesnew &RCUTORTURE_RDR_SCHED )rcu_read_lock_sched ();if (statesnew &RCUTORTURE_RDR_RCU ) idxnew = cur_ops->readlock () <<RCUTORTURE_RDR_SHIFT ; -/* Next, remove old protection, irq first due to bh conflict. */ +/* +* Next, remove old protection, in decreasing order of strength +* to avoid unlock paths that aren't safe in the stronger +* context. Namely: BH can not be enabled with disabled interrupts. +* Additionally PREEMPT_RT requires that BH is enabled in preemptible +* context. +*/ if (statesold &RCUTORTURE_RDR_IRQ )local_irq_enable (); -if (statesold &RCUTORTURE_RDR_BH ) -local_bh_enable ();if (statesold &RCUTORTURE_RDR_PREEMPT )preempt_enable (); -if (statesold &RCUTORTURE_RDR_RBH ) -rcu_read_unlock_bh ();if (statesold &RCUTORTURE_RDR_SCHED )rcu_read_unlock_sched (); +if (statesold &RCUTORTURE_RDR_BH ) +local_bh_enable (); +if (statesold &RCUTORTURE_RDR_RBH ) +rcu_read_unlock_bh ();if (statesold &RCUTORTURE_RDR_RCU ) {bool lockit = !statesnew && !(torture_random (trsp) &0xffff );
@@ -1302,6 +1308,9 @@ rcutorture_extend_mask(int oldmask, struct torture_random_state *trsp)int mask =rcutorture_extend_mask_max ();unsigned long randmask1 =torture_random (trsp) >>8 ;unsigned long randmask2 = randmask1 >>3 ; +unsigned long preempts =RCUTORTURE_RDR_PREEMPT |RCUTORTURE_RDR_SCHED ; +unsigned long preempts_irq = preempts |RCUTORTURE_RDR_IRQ ; +unsigned long bhs =RCUTORTURE_RDR_BH |RCUTORTURE_RDR_RBH ;WARN_ON_ONCE (mask >>RCUTORTURE_RDR_SHIFT );/* Mostly only one bit (need preemption!), sometimes lots of bits. */
@@ -1309,11 +1318,26 @@ rcutorture_extend_mask(int oldmask, struct torture_random_state *trsp) mask = mask & randmask2; else mask = mask & (1 << (randmask2 %RCUTORTURE_RDR_NBITS )); -/* Can't enable bh w/irq disabled. */ -if ((mask &RCUTORTURE_RDR_IRQ ) && - ((!(mask &RCUTORTURE_RDR_BH ) && (oldmask &RCUTORTURE_RDR_BH )) || - (!(mask &RCUTORTURE_RDR_RBH ) && (oldmask &RCUTORTURE_RDR_RBH )))) - mask |=RCUTORTURE_RDR_BH |RCUTORTURE_RDR_RBH ; + +/* +* Can't enable bh w/irq disabled. +*/ +if (mask &RCUTORTURE_RDR_IRQ ) + mask |= oldmask & bhs; + +/* +* Ideally these sequences would be detected in debug builds +* (regardless of RT), but until then don't stop testing +* them on non-RT. +*/ +if (IS_ENABLED (CONFIG_PREEMPT_RT )) { +/* Can't modify BH in atomic context */ +if (oldmask & preempts_irq) + mask &= ~bhs; +if ((oldmask | mask) & preempts_irq) + mask |= oldmask & bhs; + } +return mask ?:RCUTORTURE_RDR_RCU ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 171/575 platform/x86: wmi: do not fail if disabling fails
In reply to Greg Kroah-HartmanFrom: Barnabás Pőcze <[email protected]>
[ Upstream commit 1975718c488a39128f1f515b23ae61a5a214cc3d ]
Previously, __query_block() would fail if the second WCxx method call failed. However, the WQxx method might have succeeded, and potentially allocated memory for the result. Instead of throwing away the result and potentially leaking memory, ignore the result of
the second WCxx call.
--- drivers/platform/x86/wmi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/platform/x86/wmi.c +8 -1
@@ -354,7 +354,14 @@ static acpi_status __query_block(struct wmi_block *wblock, u8 instance,* the WQxx method failed - we should disable collection anyway. */ if ((block->flags &ACPI_WMI_EXPENSIVE ) &&ACPI_SUCCESS (wc_status)) { - status =acpi_execute_simple_method (handle, wc_method,0 ); +/* +* Ignore whether this WCxx call succeeds or not since +* the previously executed WQxx method call might have +* succeeded, and returning the failing status code +* of this call would throw away the result of the WQxx +* call, potentially leaking memory. +*/ +acpi_execute_simple_method (handle, wc_method,0 ); }return status;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 172/575 MIPS: lantiq: dma: add small delay after reset
In reply to Greg Kroah-HartmanFrom: Aleksander Jan Bajkowski <[email protected]>
[ Upstream commit c12aa581f6d5e80c3c3675ab26a52c2b3b62f76e ]
Reading the DMA registers immediately after the reset causes Data Bus Error. Adding a small delay fixes this issue.
--- arch/mips/lantiq/xway/dma.c | 3 +++ 1 file changed, 3 insertions(+)
arch/mips/lantiq/xway/dma.c +3 -0
@@ -11,6 +11,7 @@#include <linux/export.h> #include <linux/spinlock.h> #include <linux/clk.h> +#include <linux/delay.h> #include <linux/err.h> #include <lantiq_soc.h>
@@ -221,6 +222,8 @@ ltq_dma_init(struct platform_device *pdev)clk_enable (clk);ltq_dma_w32_mask (0 ,DMA_RESET ,LTQ_DMA_CTRL ); +usleep_range (1 ,10 ); +/* disable all interrupts */ ltq_dma_w32 (0 ,LTQ_DMA_IRNEN );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 173/575 MIPS: lantiq: dma: reset correct number of channel
In reply to Greg Kroah-HartmanFrom: Aleksander Jan Bajkowski <[email protected]>
[ Upstream commit 5ca9ce2ba4d5884cd94d1a856c675ab1242cd242 ]
Different SoCs have a different number of channels, e.g .:
* amazon-se has 10 channels,
* danube+ar9 have 20 channels,
* vr9 has 28 channels,
* ar10 has 24 channels.
We can read the ID register and, depending on the reported number of channels, reset the appropriate number of channels.
--- arch/mips/lantiq/xway/dma.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
arch/mips/lantiq/xway/dma.c +6 -5
@@ -30,6 +30,7 @@#define LTQ_DMA_PCTRL 0x44#define LTQ_DMA_IRNEN 0xf4 +#define DMA_ID_CHNR GENMASK(26, 20)/* channel number */ #define DMA_DESCPT BIT(3)/* descriptor complete irq */ #define DMA_TX BIT(8)/* TX channel direction */ #define DMA_CHAN_ON BIT(0)/* channel on / off bit */
@@ -40,7 +41,6 @@#define DMA_POLL BIT(31)/* turn on channel polling */ #define DMA_CLK_DIV4 BIT(6)/* polling clock divider */ #define DMA_2W_BURST BIT(1)/* 2 word burst length */ -#define DMA_MAX_CHANNEL 20/* the soc has 20 channels */ #define DMA_ETOP_ENDIANNESS (0xf << 8)/* endianness swap etop channels */ #define DMA_WEIGHT (BIT(17) | BIT(16))/* default channel wheight */
@@ -206,7 +206,7 @@ ltq_dma_init(struct platform_device *pdev) {struct clk *clk;struct resource *res; -unsigned id; +unsigned int id, nchannels;int i; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -228,17 +228,18 @@ ltq_dma_init(struct platform_device *pdev)ltq_dma_w32 (0 ,LTQ_DMA_IRNEN );/* reset/configure each channel */ -for (i =0 ; i <DMA_MAX_CHANNEL ; i++) { + id =ltq_dma_r32 (LTQ_DMA_ID ); + nchannels = ((id &DMA_ID_CHNR ) >>20 ); +for (i =0 ; i < nchannels; i++) {ltq_dma_w32 (i,LTQ_DMA_CS );ltq_dma_w32 (DMA_CHAN_RST ,LTQ_DMA_CCTRL );ltq_dma_w32 (DMA_POLL |DMA_CLK_DIV4 ,LTQ_DMA_CPOLL );ltq_dma_w32_mask (DMA_CHAN_ON ,0 ,LTQ_DMA_CCTRL ); } - id =ltq_dma_r32 (LTQ_DMA_ID );dev_info (&pdev->dev,"Init done - hw rev: %X, ports: %d, channels: %d\n" , - id &0x1f , (id >>16 ) &0xf , id >>20 ); + id &0x1f , (id >>16 ) &0xf , nchannels);return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 174/575 locking/lockdep: Avoid RCU-induced noinstr fail
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit ce0b9c805dd66d5e49fd53ec5415ae398f4c56e6 ]
vmlinux.o: warning: objtool: look_up_lock_class()+0xc7: call to rcu_read_lock_any_held() leaves .noinstr.text section
--- kernel/locking/lockdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/lockdep.c +1 -1
@@ -887,7 +887,7 @@ look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass)if (DEBUG_LOCKS_WARN_ON (!irqs_disabled ()))return NULL ; -hlist_for_each_entry_rcu (class, hash_head, hash_entry) { +hlist_for_each_entry_rcu_notrace (class, hash_head, hash_entry) {if (class->key == key) {/* * Huh! same key, different name? Did someone trample
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 175/575 net: sched: update default qdisc visibility after Tx queue cnt changes
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 1e080f17750d1083e8a32f7b350584ae1cd7ff20 ]
mq / mqprio make the default child qdiscs visible. They only do so for the qdiscs which are within real_num_tx_queues when the device is registered. Depending on order of calls in the driver, or if user space changes config via ethtool -L the number of qdiscs visible under tc qdisc show will differ from the number of queues. This is confusing to users and potentially to system configuration scripts which try to make sure qdiscs have the right parameters.
Add a new Qdisc_ops callback and make relevant qdiscs TTRT.
Note that this uncovers the "shortcut" created by
commit 1f27cde313d7 ("net: sched: use pfifo_fast for non real queues") The default child qdiscs beyond initial real_num_tx are always pfifo_fast, no matter what the sysfs setting is. Fixing this gets a little tricky because we'd need to keep a reference on whatever the default qdisc was at the time of creation. In practice this is likely an non-issue the qdiscs likely have to be configured to non-default settings, so whatever user space is doing such configuration can replace the pfifos... now that it will see them.
--- include/net/sch_generic.h | 4 ++++ net/core/dev.c | 2 ++ net/sched/sch_generic.c | 9 +++++++++ net/sched/sch_mq.c | 24 ++++++++++++++++++++++++ net/sched/sch_mqprio.c | 23 +++++++++++++++++++++++ 5 files changed, 62 insertions(+)
include/net/sch_generic.h +4 -0
@@ -302,6 +302,8 @@ struct Qdisc_ops { struct netlink_ext_ack *extack);void (*attach)(struct Qdisc *sch);int (*change_tx_queue_len)(struct Qdisc *,unsigned int ); +void (*change_real_num_tx)(struct Qdisc *sch, +unsigned int new_real_tx);int (*dump)(struct Qdisc *,struct sk_buff *);int (*dump_stats)(struct Qdisc *,struct gnet_dump *);
@@ -683,6 +685,8 @@ void qdisc_class_hash_grow(struct Qdisc *, struct Qdisc_class_hash *);void qdisc_class_hash_destroy (struct Qdisc_class_hash *);int dev_qdisc_change_tx_queue_len (struct net_device *dev); +void dev_qdisc_change_real_num_tx (struct net_device *dev, +unsigned int new_real_tx);void dev_init_scheduler (struct net_device *dev);void dev_shutdown (struct net_device *dev);void dev_activate (struct net_device *dev);
net/core/dev.c +2 -0
@@ -2973,6 +2973,8 @@ int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)if (dev->num_tc)netif_setup_tc (dev, txq); +dev_qdisc_change_real_num_tx (dev, txq); + dev->real_num_tx_queues = txq;if (disabling) {
net/sched/sch_generic.c +9 -0
@@ -1303,6 +1303,15 @@ static int qdisc_change_tx_queue_len(struct net_device *dev,return 0 ; } +void dev_qdisc_change_real_num_tx (struct net_device *dev, +unsigned int new_real_tx) +{ +struct Qdisc *qdisc = dev->qdisc; + +if (qdisc->ops->change_real_num_tx) + qdisc->ops->change_real_num_tx (qdisc, new_real_tx); +} +int dev_qdisc_change_tx_queue_len (struct net_device *dev) {bool up = dev->flags &IFF_UP ;
net/sched/sch_mq.c +24 -0
@@ -125,6 +125,29 @@ static void mq_attach(struct Qdisc *sch) priv->qdiscs =NULL ; } +static void mq_change_real_num_tx (struct Qdisc *sch,unsigned int new_real_tx) +{ +#ifdef CONFIG_NET_SCHED +struct net_device *dev =qdisc_dev (sch); +struct Qdisc *qdisc; +unsigned int i; + +for (i = new_real_tx; i < dev->real_num_tx_queues; i++) { + qdisc =netdev_get_tx_queue (dev, i)->qdisc_sleeping; +/* Only update the default qdiscs we created, +* qdiscs with handles are always hashed. +*/ +if (qdisc != &noop_qdisc && !qdisc->handle) +qdisc_hash_del (qdisc); + } +for (i = dev->real_num_tx_queues; i < new_real_tx; i++) { + qdisc =netdev_get_tx_queue (dev, i)->qdisc_sleeping; +if (qdisc != &noop_qdisc && !qdisc->handle) +qdisc_hash_add (qdisc, false); + } +#endif +} +static int mq_dump (struct Qdisc *sch,struct sk_buff *skb) {struct net_device *dev =qdisc_dev (sch);
@@ -288,6 +311,7 @@ struct Qdisc_ops mq_qdisc_ops __read_mostly = { .init = mq_init, .destroy = mq_destroy, .attach = mq_attach, + .change_real_num_tx = mq_change_real_num_tx, .dump = mq_dump, .owner = THIS_MODULE, };
net/sched/sch_mqprio.c +23 -0
@@ -306,6 +306,28 @@ static void mqprio_attach(struct Qdisc *sch) priv->qdiscs =NULL ; } +static void mqprio_change_real_num_tx (struct Qdisc *sch, +unsigned int new_real_tx) +{ +struct net_device *dev =qdisc_dev (sch); +struct Qdisc *qdisc; +unsigned int i; + +for (i = new_real_tx; i < dev->real_num_tx_queues; i++) { + qdisc =netdev_get_tx_queue (dev, i)->qdisc_sleeping; +/* Only update the default qdiscs we created, +* qdiscs with handles are always hashed. +*/ +if (qdisc != &noop_qdisc && !qdisc->handle) +qdisc_hash_del (qdisc); + } +for (i = dev->real_num_tx_queues; i < new_real_tx; i++) { + qdisc =netdev_get_tx_queue (dev, i)->qdisc_sleeping; +if (qdisc != &noop_qdisc && !qdisc->handle) +qdisc_hash_add (qdisc, false); + } +} +static struct netdev_queue *mqprio_queue_get (struct Qdisc *sch,unsigned long cl) {
@@ -629,6 +651,7 @@ static struct Qdisc_ops mqprio_qdisc_ops __read_mostly = { .init = mqprio_init, .destroy = mqprio_destroy, .attach = mqprio_attach, + .change_real_num_tx = mqprio_change_real_num_tx, .dump = mqprio_dump, .owner = THIS_MODULE, };
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 176/575 rcu-tasks: Move RTGS_WAIT_CBS to beginning of rcu_tasks_kthread() loop
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit 0db7c32ad3160ae06f497d48a74bd46a2a35e6bf ]
Early in debugging, it made some sense to differentiate the first iteration from subsequent iterations, but now this just causes confusion. This commit therefore moves the "set_tasks_gp_state(rtp, RTGS_WAIT_CBS)" statement to the beginning of the "for" loop in rcu_tasks_kthread().
--- kernel/rcu/tasks.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/rcu/tasks.h +1 -2
@@ -197,6 +197,7 @@ static int __noreturn rcu_tasks_kthread(void *arg)* This loop is terminated by the system going down. ;-) */ for (;;) { +set_tasks_gp_state (rtp,RTGS_WAIT_CBS );/* Pick up any new callbacks. */ raw_spin_lock_irqsave (&rtp->cbs_lock, flags);
@@ -236,8 +237,6 @@ static int __noreturn rcu_tasks_kthread(void *arg) }/* Paranoid sleep to keep this from entering a tight loop */ schedule_timeout_idle (rtp->gp_sleep); - -set_tasks_gp_state (rtp,RTGS_WAIT_CBS ); } }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 177/575 smackfs: Fix use-after-free in netlbl_catmap_walk()
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
[ Upstream commit 0817534ff9ea809fac1322c5c8c574be8483ea57 ]
Syzkaller reported use-after-free bug as described in [1]. The bug is triggered when smk_set_cipso() tries to free stale category bitmaps while there are concurrent reader(s) using the same bitmaps.
Wait for RCU grace period to finish before freeing the category bitmaps in smk_set_cipso(). This makes sure that there are no more readers using the stale bitmaps and freeing them should be safe.
[1] https://lore.kernel.org/netdev/[email protected]/
--- security/smack/smackfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
security/smack/smackfs.c +4 -1
@@ -831,6 +831,7 @@ static int smk_open_cipso(struct inode *inode, struct file *file)static ssize_t smk_set_cipso (struct file *file,const char __user *buf,size_t count,loff_t *ppos,int format) { +struct netlbl_lsm_catmap *old_cat;struct smack_known *skp;struct netlbl_lsm_secattr ncats;char mapcatset[SMK_CIPSOLEN ];
@@ -920,9 +921,11 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf, rc =smk_netlbl_mls (maplevel, mapcatset, &ncats,SMK_CIPSOLEN );if (rc >=0 ) { -netlbl_catmap_free (skp->smk_netlabel.attr.mls.cat); + old_cat = skp->smk_netlabel.attr.mls.cat; skp->smk_netlabel.attr.mls.cat = ncats.attr.mls.cat; skp->smk_netlabel.attr.mls.lvl = ncats.attr.mls.lvl; +synchronize_rcu (); +netlbl_catmap_free (old_cat); rc = count;/* * This mapping may have been cached, so clear the cache.
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 178/575 ath11k: Align bss_chan_info structure with firmware
In reply to Greg Kroah-HartmanFrom: Seevalamuthu Mariappan <[email protected]>
[ Upstream commit feab5bb8f1d4621025dceae7eef62d5f92de34ac ]
pdev_id in structure 'wmi_pdev_bss_chan_info_event' is wrongly placed at the beginning. This causes invalid values in survey dump. Hence, align the structure with the firmware.
Note: The firmware releases follow this order since the feature was implemented. Also, it is not changing across the branches including QCA6390.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.1.0.1-01228-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/wmi.c | 1 + drivers/net/wireless/ath/ath11k/wmi.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/wmi.c +1 -0
@@ -1333,6 +1333,7 @@ int ath11k_wmi_pdev_bss_chan_info_request(struct ath11k *ar, WMI_TAG_PDEV_BSS_CHAN_INFO_REQUEST) |FIELD_PREP (WMI_TLV_LEN ,sizeof (*cmd) -TLV_HDR_SIZE ); cmd->req_type = type; + cmd->pdev_id = ar->pdev->pdev_id;ath11k_dbg (ar->ab,ATH11K_DBG_WMI ,"WMI bss chan info req type %d\n" , type);
drivers/net/wireless/ath/ath11k/wmi.h +2 -1
@@ -2935,6 +2935,7 @@ struct wmi_pdev_bss_chan_info_req_cmd {u32 tlv_header;/* ref wmi_bss_chan_info_req_type */ u32 req_type; +u32 pdev_id; } __packed;struct wmi_ap_ps_peer_cmd {
@@ -4028,7 +4029,6 @@ struct wmi_vdev_stopped_event { } __packed;struct wmi_pdev_bss_chan_info_event { -u32 pdev_id;u32 freq;/* Units in MHz */ u32 noise_floor;/* units are dBm */ /* rx clear - how often the channel was unused */
@@ -4046,6 +4046,7 @@ struct wmi_pdev_bss_chan_info_event {/*rx_cycle cnt for my bss in 64bits format */ u32 rx_bss_cycle_count_low;u32 rx_bss_cycle_count_high; +u32 pdev_id; } __packed;#define WMI_VDEV_INSTALL_KEY_COMPL_STATUS_SUCCESS 0
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 179/575 x86: Increase exception stack sizes
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 7fae4c24a2b84a66c7be399727aca11e7a888462 ]
It turns out that a single page of stack is trivial to overflow with all the tracing gunk enabled. Raise the exception stacks to 2 pages, which is still half the interrupt stacks, which are at 4 pages.
--- arch/x86/include/asm/page_64_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/page_64_types.h +1 -1
@@ -15,7 +15,7 @@#define THREAD_SIZE_ORDER (2 + KASAN_STACK_ORDER)#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) -#define EXCEPTION_STACK_ORDER (0 + KASAN_STACK_ORDER) +#define EXCEPTION_STACK_ORDER (1 + KASAN_STACK_ORDER)#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)#define IRQ_STACK_ORDER (2 + KASAN_STACK_ORDER)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 180/575 mwifiex: Run SET_BSS_MODE when changing from P2P to STATION vif-type
In reply to Greg Kroah-HartmanFrom: Jonas Dreßler <[email protected]>
[ Upstream commit c2e9666cdffd347460a2b17988db4cfaf2a68fb9 ]
We currently handle changing from the P2P to the STATION virtual interface type slightly different than changing from P2P to ADHOC: When changing to STATION, we don't send the SET_BSS_MODE command. We do send that command on all other type-changes though, and it probably makes sense to send the command since after all we just changed our BSS_MODE. Looking at prior changes to this part of the code, it seems that this is simply a leftover from old refactorings.
Since sending the SET_BSS_MODE command is the only difference between mwifiex_change_vif_to_sta_adhoc() and the current code, we can now use mwifiex_change_vif_to_sta_adhoc() for both switching to ADHOC and STATION interface type.
This does not fix any particular bug and just "looked right", so there's a small chance it might be a regression.
--- .../net/wireless/marvell/mwifiex/cfg80211.c | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-)
drivers/net/wireless/marvell/mwifiex/cfg80211.c +4 -18
@@ -1229,29 +1229,15 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,break ;case NL80211_IFTYPE_P2P_CLIENT :case NL80211_IFTYPE_P2P_GO : +if (mwifiex_cfg80211_deinit_p2p (priv)) +return -EFAULT ; +switch (type) { -case NL80211_IFTYPE_STATION : -if (mwifiex_cfg80211_deinit_p2p (priv)) -return -EFAULT ; - priv->adapter->curr_iface_comb.p2p_intf--; - priv->adapter->curr_iface_comb.sta_intf++; - dev->ieee80211_ptr->iftype = type; -if (mwifiex_deinit_priv_params (priv)) -return -1 ; -if (mwifiex_init_new_priv_params (priv, dev, type)) -return -1 ; -if (mwifiex_sta_init_cmd (priv, false, false)) -return -1 ; -break ;case NL80211_IFTYPE_ADHOC : -if (mwifiex_cfg80211_deinit_p2p (priv)) -return -EFAULT ; +case NL80211_IFTYPE_STATION :return mwifiex_change_vif_to_sta_adhoc (dev, curr_iftype, type, params); -break ;case NL80211_IFTYPE_AP : -if (mwifiex_cfg80211_deinit_p2p (priv)) -return -EFAULT ;return mwifiex_change_vif_to_ap (dev, curr_iftype, type, params);case NL80211_IFTYPE_UNSPECIFIED :
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 181/575 mwifiex: Properly initialize private structure on interface type changes
In reply to Greg Kroah-HartmanFrom: Jonas Dreßler <[email protected]>
[ Upstream commit c606008b70627a2fc485732a53cc22f0f66d0981 ]
When creating a new virtual interface in mwifiex_add_virtual_intf(), we update our internal driver states like bss_type, bss_priority, bss_role and bss_mode to reflect the mode the firmware will be set to.
When switching virtual interface mode using mwifiex_init_new_priv_params() though, we currently only update bss_mode and bss_role. In order for the interface mode switch to actually work, we also need to update bss_type to its proper value, so do that.
This fixes a crash of the firmware (because the driver tries to execute commands that are invalid in AP mode) when switching from station mode to AP mode.
--- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/wireless/marvell/mwifiex/cfg80211.c +7 -3
@@ -908,16 +908,20 @@ mwifiex_init_new_priv_params(struct mwifiex_private *priv,switch (type) {case NL80211_IFTYPE_STATION :case NL80211_IFTYPE_ADHOC : - priv->bss_role =MWIFIEX_BSS_ROLE_STA ; + priv->bss_role =MWIFIEX_BSS_ROLE_STA ; + priv->bss_type =MWIFIEX_BSS_TYPE_STA ;break ;case NL80211_IFTYPE_P2P_CLIENT : - priv->bss_role =MWIFIEX_BSS_ROLE_STA ; + priv->bss_role =MWIFIEX_BSS_ROLE_STA ; + priv->bss_type =MWIFIEX_BSS_TYPE_P2P ;break ;case NL80211_IFTYPE_P2P_GO : - priv->bss_role =MWIFIEX_BSS_ROLE_UAP ; + priv->bss_role =MWIFIEX_BSS_ROLE_UAP ; + priv->bss_type =MWIFIEX_BSS_TYPE_P2P ;break ;case NL80211_IFTYPE_AP : priv->bss_role =MWIFIEX_BSS_ROLE_UAP ; + priv->bss_type =MWIFIEX_BSS_TYPE_UAP ;break ;default : mwifiex_dbg(adapter, ERROR,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 182/575 fscrypt: allow 256-bit master keys with AES-256-XTS
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
[ Upstream commit 7f595d6a6cdc336834552069a2e0a4f6d4756ddf ]
fscrypt currently requires a 512-bit master key when AES-256-XTS is used, since AES-256-XTS keys are 512-bit and fscrypt requires that the master key be at least as long any key that will be derived from it.
However, this is overly strict because AES-256-XTS doesn't actually have a 512-bit security strength, but rather 256-bit. The fact that XTS takes twice the expected key size is a quirk of the XTS mode. It is sufficient to use 256 bits of entropy for AES-256-XTS, provided that it is first properly expanded into a 512-bit key, which HKDF-SHA512 does.
Therefore, relax the check of the master key size to use the security strength of the derived key rather than the size of the derived key (except for v1 encryption policies, which don't use HKDF).
Besides making things more flexible for userspace, this is needed in order for the use of a KDF which only takes a 256-bit key to be introduced into the fscrypt key hierarchy. This will happen with hardware-wrapped keys support, as all known hardware which supports that feature uses an SP800-108 KDF using AES-256-CMAC, so the wrapped keys are wrapped 256-bit AES keys. Moreover, there is interest in fscrypt supporting the same type of AES-256-CMAC based KDF in software as an alternative to HKDF-SHA512. There is no security problem with such features, so fix the key length check to work properly with them.
--- Documentation/filesystems/fscrypt.rst | 10 ++--- fs/crypto/fscrypt_private.h | 5 ++- fs/crypto/hkdf.c | 11 ++++-- fs/crypto/keysetup.c | 57 +++++++++++++++++++++------ 4 files changed, 61 insertions(+), 22 deletions(-)
Documentation/filesystems/fscrypt.rst +5 -5
@@ -176,11 +176,11 @@ Master Keys Each encrypted directory tree is protected by a *master key*. Master keys can be up to 64 bytes long, and must be at least as long as the -greater of the key length needed by the contents and filenames -encryption modes being used. For example, if AES-256-XTS is used for -contents encryption, the master key must be 64 bytes (512 bits). Note -that the XTS mode is defined to require a key twice as long as that -required by the underlying block cipher. +greater of the security strength of the contents and filenames +encryption modes being used. For example, if any AES-256 mode is +used, the master key must be at least 256 bits, i.e. 32 bytes. A +stricter requirement applies if the key is used by a v1 encryption +policy and AES-256-XTS is used; such keys must be 64 bytes. To "unlock" an encrypted directory tree, userspace must provide the appropriate master key. There can be any number of master keys, each
fs/crypto/fscrypt_private.h +3 -2
@@ -557,8 +557,9 @@ int __init fscrypt_init_keyring(void);struct fscrypt_mode {const char *friendly_name;const char *cipher_str; -int keysize; -int ivsize; +int keysize;/* key size in bytes */ +int security_strength;/* security strength in bytes */ +int ivsize;/* IV size in bytes */ int logged_impl_name;enum blk_crypto_mode_num blk_crypto_mode; };
fs/crypto/hkdf.c +8 -3
@@ -16,9 +16,14 @@/* * HKDF supports any unkeyed cryptographic hash algorithm, but fscrypt uses -* SHA-512 because it is reasonably secure and efficient; and since it produces -* a 64-byte digest, deriving an AES-256-XTS key preserves all 64 bytes of -* entropy from the master key and requires only one iteration of HKDF-Expand. +* SHA-512 because it is well-established, secure, and reasonably efficient. +* +* HKDF-SHA256 was also considered, as its 256-bit security strength would be +* sufficient here. A 512-bit security strength is "nice to have", though. +* Also, on 64-bit CPUs, SHA-512 is usually just as fast as SHA-256. In the +* common case of deriving an AES-256-XTS key (512 bits), that can result in +* HKDF-SHA512 being much faster than HKDF-SHA256, as the longer digest size of +* SHA-512 causes HKDF-Expand to only need to do one iteration rather than two. */ #define HKDF_HMAC_ALG "hmac(sha512)"#define HKDF_HASHLEN SHA512_DIGEST_SIZE
fs/crypto/keysetup.c +45 -12
99 lines not on this page · raw message
Signature · 1 line
2.33.0
Re: [PATCH 5.10 182/575] fscrypt: allow 256-bit master keys with AES-256-XTS
Hi!
Quoted 7 lines
From: Eric Biggers <[email protected]>
[ Upstream commit
7f595d6a6cdc336834552069a2e0a4f6d4756ddf]fscrypt currently requires a 512-bit master key when AES-256-XTS is used, since AES-256-XTS keys are 512-bit and fscrypt requires that the master key be at least as long any key that will be derived from it.
Quoting Eric Biggers <[email protected]>
I don't expect any problem with backporting this, but I don't see how this
follows the stable kernel rules (Documentation/process/stable-kernel-rules.rst).
I don't see what distinguishes this patch from ones that don't get picked up by
AUTOSEL; it seems pretty arbitrary to me.
- Eric
And I agree, this should not be in stable.
Best regards,
Pavel
Signature · 1 line
http://www.livejournal.com/~pavelmachek
Greg Kroah-Hartman
maintainerPATCH 183/575 drm/amdgpu: Fix MMIO access page fault
In reply to Greg Kroah-HartmanFrom: Andrey Grodzovsky <[email protected]>
[ Upstream commit c03509cbc01559549700e14c4a6239f2572ab4ba ]
Add more guards to MMIO access post device
unbind/unplug
--- drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c | 8 ++++++-- drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c | 17 +++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c +6 -2
@@ -22,6 +22,7 @@*/ #include <linux/firmware.h> +#include <drm/drm_drv.h> #include "amdgpu.h" #include "amdgpu_vcn.h"
@@ -192,11 +193,14 @@ static int vcn_v2_0_sw_init(void *handle)*/ static int vcn_v2_0_sw_fini (void *handle) { -int r; +int r, idx;struct amdgpu_device *adev = (struct amdgpu_device *)handle;volatile struct amdgpu_fw_shared *fw_shared = adev->vcn.inst->fw_shared_cpu_addr; - fw_shared->present_flag_0 =0 ; +if (drm_dev_enter (&adev->ddev, &idx)) { + fw_shared->present_flag_0 =0 ; +drm_dev_exit (idx); + }amdgpu_virt_free_mm_table (adev);
drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c +11 -6
@@ -22,6 +22,7 @@*/ #include <linux/firmware.h> +#include <drm/drm_drv.h> #include "amdgpu.h" #include "amdgpu_vcn.h"
@@ -233,17 +234,21 @@ static int vcn_v2_5_sw_init(void *handle)*/ static int vcn_v2_5_sw_fini (void *handle) { -int i, r; +int i, r, idx;struct amdgpu_device *adev = (struct amdgpu_device *)handle;volatile struct amdgpu_fw_shared *fw_shared; -for (i =0 ; i < adev->vcn.num_vcn_inst; i++) { -if (adev->vcn.harvest_config & (1 << i)) -continue ; - fw_shared = adev->vcn.inst[i].fw_shared_cpu_addr; - fw_shared->present_flag_0 =0 ; +if (drm_dev_enter (&adev->ddev, &idx)) { +for (i =0 ; i < adev->vcn.num_vcn_inst; i++) { +if (adev->vcn.harvest_config & (1 << i)) +continue ; + fw_shared = adev->vcn.inst[i].fw_shared_cpu_addr; + fw_shared->present_flag_0 =0 ; + } +drm_dev_exit (idx); } +if (amdgpu_sriov_vf (adev))amdgpu_virt_free_mm_table (adev);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 184/575 ath11k: Avoid reg rules update during firmware recovery
In reply to Greg Kroah-HartmanFrom: Sriram R <[email protected]>
[ Upstream commit 69a0fcf8a9f2273040d03e5ee77c9689c09e9d3a ]
During firmware recovery, the default reg rules which are received via WMI_REG_CHAN_LIST_CC_EVENT can overwrite the currently configured user regd.
See below snap for example,
root@OpenWrt:/# iw reg get | grep country country FR: DFS-ETSI country FR: DFS-ETSI country FR: DFS-ETSI country FR: DFS-ETSI
root@OpenWrt:/# echo assert > /sys/kernel/debug/ath11k/ipq8074\ hw2.0/simulate_f w_crash <snip> [ 5290.471696] ath11k c000000.wifi1: pdev 1 successfully recovered
root@OpenWrt:/# iw reg get | grep country country FR: DFS-ETSI country US: DFS-FCC country US: DFS-FCC country US: DFS-FCC
In the above, the user configured country 'FR' is overwritten when the rules of default country 'US' are received and updated during recovery. Hence avoid processing of these rules in general during firmware recovery as they have been already applied during driver registration or after last set user country is configured.
This scenario applies for both AP and STA devices basically because cfg80211 is not aware of the recovery and only the driver recovers, but changing or resetting of the reg domain during recovery is not needed so as to continue with the configured regdomain currently in use.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-01460-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/wmi.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/wireless/ath/ath11k/wmi.c +11 -0
@@ -5362,6 +5362,17 @@ static int ath11k_reg_chan_list_event(struct ath11k_base *ab, struct sk_buff *sk pdev_idx = reg_info->phy_id; +/* Avoid default reg rule updates sent during FW recovery if +* it is already available +*/ +spin_lock (&ab->base_lock); +if (test_bit (ATH11K_FLAG_RECOVERY , &ab->dev_flags) && + ab->default_regd[pdev_idx]) { +spin_unlock (&ab->base_lock); + goto mem_free; + } +spin_unlock (&ab->base_lock); +if (pdev_idx >= ab->num_radios) {/* Process the event for phy0 only if single_pdev_only * is true. If pdev_idx is valid but not 0, discard the
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 185/575 ath11k: add handler for scan event WMI_SCAN_EVENT_DEQUEUED
In reply to Greg Kroah-HartmanFrom: Wen Gong <[email protected]>
[ Upstream commit 441b3b5911f8ead7f2fe2336587b340a33044d58 ]
When wlan interface is up, 11d scan is sent to the firmware, and the firmware needs to spend couple of seconds to complete the 11d scan. If immediately a normal scan from user space arrives to ath11k, then the normal scan request is also sent to the firmware, but the scan started event will be reported to ath11k until the 11d scan complete. When timed out for the scan started in ath11k, ath11k stops the normal scan and the firmware reports WMI_SCAN_EVENT_DEQUEUED to ath11k for the normal scan. ath11k has no handler for the event and then timed out for the scan completed in ath11k_scan_stop(), and ath11k prints the following error message.
[ 1491.604750] ath11k_pci 0000:02:00.0: failed to receive scan abort comple: timed out [ 1491.604756] ath11k_pci 0000:02:00.0: failed to stop scan: -110 [ 1491.604758] ath11k_pci 0000:02:00.0: failed to start hw scan: -110
Add a handler for WMI_SCAN_EVENT_DEQUEUED and then complete the scan to get rid of the above error message.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
--- drivers/net/wireless/ath/ath11k/wmi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/ath/ath11k/wmi.c +2 -0
@@ -5856,6 +5856,8 @@ static void ath11k_scan_event(struct ath11k_base *ab, struct sk_buff *skb)ath11k_wmi_event_scan_start_failed (ar);break ;case WMI_SCAN_EVENT_DEQUEUED : +__ath11k_mac_scan_finish (ar); +break ;case WMI_SCAN_EVENT_PREEMPTED :case WMI_SCAN_EVENT_RESTARTED :case WMI_SCAN_EVENT_FOREIGN_CHAN_EXIT :
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 186/575 ath11k: Change DMA_FROM_DEVICE to DMA_TO_DEVICE when map reinjected packets
In reply to Greg Kroah-HartmanFrom: Baochen Qiang <[email protected]>
[ Upstream commit 86a03dad0f5ad8182ed5fcf7bf3eec71cd96577c ]
For fragmented packets, ath11k reassembles each fragment as a normal packet and then reinjects it into HW ring. In this case, the DMA direction should be DMA_TO_DEVICE, not DMA_FROM_DEVICE, otherwise invalid payload will be reinjected to HW and then delivered to host. What is more, since arbitrary memory could be allocated to the frame, we don't know what kind of data is contained in the buffer reinjected. Thus, as a bad result, private info may be leaked.
Note that this issue is only found on Intel platform.
Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1
--- drivers/net/wireless/ath/ath11k/dp_rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/dp_rx.c +2 -2
@@ -3273,7 +3273,7 @@ static int ath11k_dp_rx_h_defrag_reo_reinject(struct ath11k *ar, struct dp_rx_ti paddr =dma_map_single (ab->dev, defrag_skb->data, defrag_skb->len +skb_tailroom (defrag_skb), -DMA_FROM_DEVICE ); +DMA_TO_DEVICE );if (dma_mapping_error (ab->dev, paddr))return -ENOMEM ;
@@ -3338,7 +3338,7 @@ err_free_idr:spin_unlock_bh (&rx_refill_ring->idr_lock); err_unmap_dma:dma_unmap_single (ab->dev, paddr, defrag_skb->len +skb_tailroom (defrag_skb), -DMA_FROM_DEVICE ); +DMA_TO_DEVICE );return ret; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 187/575 ath10k: high latency fixes for beacon buffer
In reply to Greg Kroah-HartmanFrom: Alagu Sankar <[email protected]>
[ Upstream commit e263bdab9c0e8025fb7f41f153709a9cda51f6b6 ]
Beacon buffer for high latency devices does not use DMA. other similar buffer allocation methods in the driver have already been modified for high latency path. Fix the beacon buffer allocation left out in the earlier high latency changes.
--- drivers/net/wireless/ath/ath10k/mac.c | 31 ++++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-)
drivers/net/wireless/ath/ath10k/mac.c +23 -8
@@ -982,8 +982,12 @@ static void ath10k_mac_vif_beacon_cleanup(struct ath10k_vif *arvif)ath10k_mac_vif_beacon_free (arvif);if (arvif->beacon_buf) { -dma_free_coherent (ar->dev,IEEE80211_MAX_FRAME_LEN , - arvif->beacon_buf, arvif->beacon_paddr); +if (ar->bus_param.dev_type ==ATH10K_DEV_TYPE_HL ) +kfree (arvif->beacon_buf); +else +dma_free_coherent (ar->dev,IEEE80211_MAX_FRAME_LEN , + arvif->beacon_buf, + arvif->beacon_paddr); arvif->beacon_buf =NULL ; } }
@@ -5466,10 +5470,17 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,if (vif->type ==NL80211_IFTYPE_ADHOC || vif->type ==NL80211_IFTYPE_MESH_POINT || vif->type ==NL80211_IFTYPE_AP ) { - arvif->beacon_buf =dma_alloc_coherent (ar->dev, -IEEE80211_MAX_FRAME_LEN , - &arvif->beacon_paddr, -GFP_ATOMIC ); +if (ar->bus_param.dev_type ==ATH10K_DEV_TYPE_HL ) { + arvif->beacon_buf =kmalloc (IEEE80211_MAX_FRAME_LEN , +GFP_KERNEL ); + arvif->beacon_paddr = (dma_addr_t )arvif->beacon_buf; + }else { + arvif->beacon_buf = +dma_alloc_coherent (ar->dev, +IEEE80211_MAX_FRAME_LEN , + &arvif->beacon_paddr, +GFP_ATOMIC ); + }if (!arvif->beacon_buf) { ret = -ENOMEM ; ath10k_warn(ar, "failed to allocate beacon buffer: %d\n",
@@ -5684,8 +5695,12 @@ err_vdev_delete: err:if (arvif->beacon_buf) { -dma_free_coherent (ar->dev,IEEE80211_MAX_FRAME_LEN , - arvif->beacon_buf, arvif->beacon_paddr); +if (ar->bus_param.dev_type ==ATH10K_DEV_TYPE_HL ) +kfree (arvif->beacon_buf); +else +dma_free_coherent (ar->dev,IEEE80211_MAX_FRAME_LEN , + arvif->beacon_buf, + arvif->beacon_paddr); arvif->beacon_buf =NULL ; }
Signature · 1 line
2.33.0
Re: [PATCH 5.10 187/575] ath10k: high latency fixes for beacon buffer
Hi!
Quoted 8 lines
From: Alagu Sankar <[email protected]>
[ Upstream commit
e263bdab9c0e8025fb7f41f153709a9cda51f6b6]Beacon buffer for high latency devices does not use DMA. other similar buffer allocation methods in the driver have already been modified for high latency path. Fix the beacon buffer allocation left out in the earlier high latency changes.
There's GFP_KERNEL vs. GFP_ATOMIC confusion here:
Quoted 22 lines
drivers/net/wireless/ath/ath10k/mac.c +11
-4@@ -5466,10 +5470,17 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,if (vif->type ==NL80211_IFTYPE_ADHOC || vif->type ==NL80211_IFTYPE_MESH_POINT || vif->type ==NL80211_IFTYPE_AP ) { - arvif->beacon_buf =dma_alloc_coherent (ar->dev, -IEEE80211_MAX_FRAME_LEN , - &arvif->beacon_paddr, -GFP_ATOMIC ); +if (ar->bus_param.dev_type ==ATH10K_DEV_TYPE_HL ) { + arvif->beacon_buf =kmalloc (IEEE80211_MAX_FRAME_LEN , +GFP_KERNEL ); + arvif->beacon_paddr = (dma_addr_t )arvif->beacon_buf; + }else { + arvif->beacon_buf = +dma_alloc_coherent (ar->dev, +IEEE80211_MAX_FRAME_LEN , + &arvif->beacon_paddr, +GFP_ATOMIC ); + }if (!arvif->beacon_buf) { ret = -ENOMEM ; ath10k_warn(ar, "failed to allocate beacon
Quoted 1 line
buffer: %d\n",
I'd expect both allocations to use same GFP_ flags.
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Re: [PATCH 5.10 187/575] ath10k: high latency fixes for beacon buffer
Hi Pavel,
Quoted 20 lines · Pavel Machek
There's
GFP_KERNELvs.GFP_ATOMICconfusion here:Quoted 18 lines
drivers/net/wireless/ath/ath10k/mac.c +9
-4@@ -5466,10 +5470,17 @@ static int ath10k_add_interface(struct ieee80211_hw *hw, if (vif->type == NL80211_IFTYPE_ADHOC || vif->type ==NL80211_IFTYPE_MESH_POINT || vif->type == NL80211_IFTYPE_AP) { - arvif->beacon_buf =dma_alloc_coherent (ar->dev, -IEEE80211_MAX_FRAME_LEN , - &arvif->beacon_paddr, -GFP_ATOMIC ); +if (ar->bus_param.dev_type ==ATH10K_DEV_TYPE_HL ) { + arvif->beacon_buf =kmalloc (IEEE80211_MAX_FRAME_LEN , +GFP_KERNEL ); + arvif->beacon_paddr = (dma_addr_t )arvif->beacon_buf; + }else { + arvif->beacon_buf = + dma_alloc_coherent(ar->dev, + IEEE80211_MAX_FRAME_LEN, + &arvif->beacon_paddr,
Quoted 8 lines
Review
Quoted 6 lines
drivers/net/wireless/ath/ath10k/mac.c +2
-0+ GFP_ATOMIC); + }if (!arvif->beacon_buf) { ret = -ENOMEM ;(quoted diff) +0
-0ath10k_warn(ar, "failed to allocate beacon buffer: %d\n",I'd expect both allocations to use same
GFP_flags.
Good catch.
Let me prepare a patch, test it and submit it soon.
Thanks,
Fabio Estevam
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-60 Fax: (+49)-8142-66989-80 Email: [email protected]
Greg Kroah-Hartman
maintainerPATCH 188/575 media: mt9p031: Fix corrupted frame after restarting stream
In reply to Greg Kroah-HartmanFrom: Dirk Bender <[email protected]>
[ Upstream commit 0961ba6dd211a4a52d1dd4c2d59be60ac2dc08c7 ]
To prevent corrupted frames after starting and stopping the sensor its datasheet specifies a specific pause sequence to follow:
Stopping:
Set Pause_Restart Bit -> Set Restart Bit -> Set Chip_Enable Off
Restarting:
Set Chip_Enable On -> Clear Pause_Restart Bit
The Restart Bit is cleared automatically and must not be cleared manually as this would cause undefined behavior.
--- drivers/media/i2c/mt9p031.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/media/i2c/mt9p031.c +27 -1
@@ -78,7 +78,9 @@#define MT9P031_PIXEL_CLOCK_INVERT (1 << 15)#define MT9P031_PIXEL_CLOCK_SHIFT (n) ((n) << 8)#define MT9P031_PIXEL_CLOCK_DIVIDE (n) ((n) << 0) -#define MT9P031_FRAME_RESTART 0x0b +#define MT9P031_RESTART 0x0b +#define MT9P031_FRAME_PAUSE_RESTART (1 << 1) +#define MT9P031_FRAME_RESTART (1 << 0)#define MT9P031_SHUTTER_DELAY 0x0c#define MT9P031_RST 0x0d#define MT9P031_RST_ENABLE 1
@@ -445,9 +447,23 @@ static int mt9p031_set_params(struct mt9p031 *mt9p031)static int mt9p031_s_stream (struct v4l2_subdev *subdev,int enable) {struct mt9p031 *mt9p031 =to_mt9p031 (subdev); +struct i2c_client *client =v4l2_get_subdevdata (subdev); +int val;int ret;if (!enable) { +/* enable pause restart */ + val =MT9P031_FRAME_PAUSE_RESTART ; + ret =mt9p031_write (client,MT9P031_RESTART , val); +if (ret <0 ) +return ret; + +/* enable restart + keep pause restart set */ + val |=MT9P031_FRAME_RESTART ; + ret =mt9p031_write (client,MT9P031_RESTART , val); +if (ret <0 ) +return ret; +/* Stop sensor readout */ ret =mt9p031_set_output_control (mt9p031,MT9P031_OUTPUT_CONTROL_CEN ,0 );
@@ -467,6 +483,16 @@ static int mt9p031_s_stream(struct v4l2_subdev *subdev, int enable)if (ret <0 )return ret; +/* +* - clear pause restart +* - don't clear restart as clearing restart manually can cause +* undefined behavior +*/ + val =MT9P031_FRAME_RESTART ; + ret =mt9p031_write (client,MT9P031_RESTART , val); +if (ret <0 ) +return ret; +return mt9p031_pll_enable (mt9p031); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 189/575 media: netup_unidvb: handle interrupt properly according to the firmware
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit dbb4cfea6efe979ed153bd59a6a527a90d3d0ab3 ]
The interrupt handling should be related to the firmware version. If the driver matches an old firmware, then the driver should not handle interrupt such as i2c or dma, otherwise it will cause some errors.
This log reveals it:
[ 27.708641] INFO: trying to register non-static key. [ 27.710851] The code is fine but needs lockdep annotation, or maybe [ 27.712010] you didn't initialize this object before use? [ 27.712396] turning off the locking correctness validator. [ 27.712787] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 5.12.4-g70e7f0549188-dirty #169 [ 27.713349] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014 [ 27.714149] Call Trace: [ 27.714329] <IRQ> [ 27.714480] dump_stack+0xba/0xf5 [ 27.714737] register_lock_class+0x873/0x8f0 [ 27.715052] ? __lock_acquire+0x323/0x1930 [ 27.715353] __lock_acquire+0x75/0x1930 [ 27.715636] lock_acquire+0x1dd/0x3e0 [ 27.715905] ? netup_i2c_interrupt+0x19/0x310 [ 27.716226] _raw_spin_lock_irqsave+0x4b/0x60 [ 27.716544] ? netup_i2c_interrupt+0x19/0x310 [ 27.716863] netup_i2c_interrupt+0x19/0x310 [ 27.717178] netup_unidvb_isr+0xd3/0x160 [ 27.717467] __handle_irq_event_percpu+0x53/0x3e0 [ 27.717808] handle_irq_event_percpu+0x35/0x90 [ 27.718129] handle_irq_event+0x39/0x60 [ 27.718409] handle_fasteoi_irq+0xc2/0x1d0 [ 27.718707] __common_interrupt+0x7f/0x150 [ 27.719008] common_interrupt+0xb4/0xd0 [ 27.719289] </IRQ> [ 27.719446] asm_common_interrupt+0x1e/0x40 [ 27.719747] RIP: 0010:native_safe_halt+0x17/0x20 [ 27.720084] Code: 07 0f 00 2d 8b ee 4c 00 f4 5d c3 0f 1f 84 00 00 00 00 00 8b 05 72 95 17 02 55 48 89 e5 85 c0 7e 07 0f 00 2d 6b ee 4c 00 fb f4 <5d> c3 cc cc cc cc cc cc cc 55 48 89 e5 e8 67 53 ff ff 8b 0d 29 f6 [ 27.721386] RSP: 0018:ffffc9000008fe90 EFLAGS: 00000246 [ 27.721758] RAX: 0000000000000000 RBX: 0000000000000002 RCX: 0000000000000000 [ 27.722262] RDX: 0000000000000000 RSI: ffffffff85f7c054 RDI: ffffffff85ded4e6 [ 27.722770] RBP: ffffc9000008fe90 R08: 0000000000000001 R09: 0000000000000001 [ 27.723277] R10: 0000000000000000 R11: 0000000000000001 R12: ffffffff86a75408 [ 27.723781] R13: 0000000000000000 R14: 0000000000000000 R15: ffff888100260000 [ 27.724289] default_idle+0x9/0x10 [ 27.724537] arch_cpu_idle+0xa/0x10 [ 27.724791] default_idle_call+0x6e/0x250 [ 27.725082] do_idle+0x1f0/0x2d0 [ 27.725326] cpu_startup_entry+0x18/0x20 [ 27.725613] start_secondary+0x11f/0x160 [ 27.725902] secondary_startup_64_no_verify+0xb0/0xbb [ 27.726272] BUG: kernel NULL pointer dereference, address: 0000000000000002 [ 27.726768] #PF: supervisor read access in kernel mode [ 27.727138] #PF: error_code(0x0000) - not-present page [ 27.727507] PGD 8000000118688067 P4D 8000000118688067 PUD 10feab067 PMD 0 [ 27.727999] Oops: 0000 [#1] PREEMPT SMP PTI [ 27.728302] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 5.12.4-g70e7f0549188-dirty #169 [ 27.728861] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014 [ 27.729660] RIP: 0010:netup_i2c_interrupt+0x23/0x310 [ 27.730019] Code: 0f 1f 80 00 00 00 00 55 48 89 e5 41 55 41 54 53 48 89 fb e8 af 6e 95 fd 48 89 df e8 e7 9f 1c 01 49 89 c5 48 8b 83 48 08 00 00 <66> 44 8b 60 02 44 89 e0 48 8b 93 48 08 00 00 83 e0 f8 66 89 42 02 [ 27.731339] RSP: 0018:ffffc90000118e90 EFLAGS: 00010046 [ 27.731716] RAX: 0000000000000000 RBX: ffff88810803c4d8 RCX: 0000000000000000 [ 27.732223] RDX: 0000000000000001 RSI: ffffffff85d37b94 RDI: ffff88810803c4d8 [ 27.732727] RBP: ffffc90000118ea8 R08: 0000000000000000 R09: 0000000000000001 [ 27.733239] R10: ffff88810803c4f0 R11: 61646e6f63657320 R12: 0000000000000000 [ 27.733745] R13: 0000000000000046 R14: ffff888101041000 R15: ffff8881081b2400 [ 27.734251] FS: 0000000000000000(0000) GS:ffff88817bc80000(0000) knlGS:0000000000000000 [ 27.734821] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 27.735228] CR2: 0000000000000002 CR3: 0000000108194000 CR4: 00000000000006e0 [ 27.735735] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 27.736241] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 27.736744] Call Trace: [ 27.736924] <IRQ> [ 27.737074] netup_unidvb_isr+0xd3/0x160 [ 27.737363] __handle_irq_event_percpu+0x53/0x3e0 [ 27.737706] handle_irq_event_percpu+0x35/0x90 [ 27.738028] handle_irq_event+0x39/0x60 [ 27.738306] handle_fasteoi_irq+0xc2/0x1d0 [ 27.738602] __common_interrupt+0x7f/0x150 [ 27.738899] common_interrupt+0xb4/0xd0 [ 27.739176] </IRQ> [ 27.739331] asm_common_interrupt+0x1e/0x40 [ 27.739633] RIP: 0010:native_safe_halt+0x17/0x20 [ 27.739967] Code: 07 0f 00 2d 8b ee 4c 00 f4 5d c3 0f 1f 84 00 00 00 00 00 8b 05 72 95 17 02 55 48 89 e5 85 c0 7e 07 0f 00 2d 6b ee 4c 00 fb f4 <5d> c3 cc cc cc cc cc cc cc 55 48 89 e5 e8 67 53 ff ff 8b 0d 29 f6 [ 27.741275] RSP: 0018:ffffc9000008fe90 EFLAGS: 00000246 [ 27.741647] RAX: 0000000000000000 RBX: 0000000000000002 RCX: 0000000000000000 [ 27.742148] RDX: 0000000000000000 RSI: ffffffff85f7c054 RDI: ffffffff85ded4e6 [ 27.742652] RBP: ffffc9000008fe90 R08: 0000000000000001 R09: 0000000000000001 [ 27.743154] R10: 0000000000000000 R11: 0000000000000001 R12: ffffffff86a75408 [ 27.743652] R13: 0000000000000000 R14: 0000000000000000 R15: ffff888100260000 [ 27.744157] default_idle+0x9/0x10 [ 27.744405] arch_cpu_idle+0xa/0x10 [ 27.744658] default_idle_call+0x6e/0x250 [ 27.744948] do_idle+0x1f0/0x2d0 [ 27.745190] cpu_startup_entry+0x18/0x20 [ 27.745475] start_secondary+0x11f/0x160 [ 27.745761] secondary_startup_64_no_verify+0xb0/0xbb [ 27.746123] Modules linked in: [ 27.746348] Dumping ftrace buffer: [ 27.746596] (ftrace buffer empty) [ 27.746852] CR2: 0000000000000002 [ 27.747094] ---[ end trace ebafd46f83ab946d ]--- [ 27.747424] RIP: 0010:netup_i2c_interrupt+0x23/0x310 [ 27.747778] Code: 0f 1f 80 00 00 00 00 55 48 89 e5 41 55 41 54 53 48 89 fb e8 af 6e 95 fd 48 89 df e8 e7 9f 1c 01 49 89 c5 48 8b 83 48 08 00 00 <66> 44 8b 60 02 44 89 e0 48 8b 93 48 08 00 00 83 e0 f8 66 89 42 02 [ 27.749082] RSP: 0018:ffffc90000118e90 EFLAGS: 00010046 [ 27.749461] RAX: 0000000000000000 RBX: ffff88810803c4d8 RCX: 0000000000000000 [ 27.749966] RDX: 0000000000000001 RSI: ffffffff85d37b94 RDI: ffff88810803c4d8 [ 27.750471] RBP: ffffc90000118ea8 R08: 0000000000000000 R09: 0000000000000001 [ 27.750976] R10: ffff88810803c4f0 R11: 61646e6f63657320 R12: 0000000000000000 [ 27.751480] R13: 0000000000000046 R14: ffff888101041000 R15: ffff8881081b2400 [ 27.751986] FS: 0000000000000000(0000) GS:ffff88817bc80000(0000) knlGS:0000000000000000 [ 27.752560] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 27.752970] CR2: 0000000000000002 CR3: 0000000108194000 CR4: 00000000000006e0 [ 27.753481] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 27.753984] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 27.754487] Kernel panic - not syncing: Fatal exception in interrupt [ 27.755033] Dumping ftrace buffer: [ 27.755279] (ftrace buffer empty) [ 27.755534] Kernel Offset: disabled [ 27.755785] Rebooting in 1 seconds..
--- .../pci/netup_unidvb/netup_unidvb_core.c | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-)
drivers/media/pci/netup_unidvb/netup_unidvb_core.c +16 -11
@@ -258,19 +258,24 @@ static irqreturn_t netup_unidvb_isr(int irq, void *dev_id)if ((reg40 &AVL_IRQ_ASSERTED ) !=0 ) {/* IRQ is being signaled */ reg_isr =readw (ndev->bmmio0 +REG_ISR ); -if (reg_isr &NETUP_UNIDVB_IRQ_I2C0 ) { - iret =netup_i2c_interrupt (&ndev->i2c[0 ]); - }else if (reg_isr &NETUP_UNIDVB_IRQ_I2C1 ) { - iret =netup_i2c_interrupt (&ndev->i2c[1 ]); - }else if (reg_isr &NETUP_UNIDVB_IRQ_SPI ) { +if (reg_isr &NETUP_UNIDVB_IRQ_SPI ) iret =netup_spi_interrupt (ndev->spi); - }else if (reg_isr &NETUP_UNIDVB_IRQ_DMA1 ) { - iret =netup_dma_interrupt (&ndev->dma[0 ]); - }else if (reg_isr &NETUP_UNIDVB_IRQ_DMA2 ) { - iret =netup_dma_interrupt (&ndev->dma[1 ]); - }else if (reg_isr &NETUP_UNIDVB_IRQ_CI ) { - iret =netup_ci_interrupt (ndev); +else if (!ndev->old_fw) { +if (reg_isr &NETUP_UNIDVB_IRQ_I2C0 ) { + iret =netup_i2c_interrupt (&ndev->i2c[0 ]); + }else if (reg_isr &NETUP_UNIDVB_IRQ_I2C1 ) { + iret =netup_i2c_interrupt (&ndev->i2c[1 ]); + }else if (reg_isr &NETUP_UNIDVB_IRQ_DMA1 ) { + iret =netup_dma_interrupt (&ndev->dma[0 ]); + }else if (reg_isr &NETUP_UNIDVB_IRQ_DMA2 ) { + iret =netup_dma_interrupt (&ndev->dma[1 ]); + }else if (reg_isr &NETUP_UNIDVB_IRQ_CI ) { + iret =netup_ci_interrupt (ndev); + }else { + goto err; + } }else { +err:dev_err (&pci_dev->dev,"%s(): unknown interrupt 0x%x\n" , __func__, reg_isr);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 190/575 media: atomisp: Fix error handling in probe
In reply to Greg Kroah-HartmanFrom: Evgeny Novikov <[email protected]>
[ Upstream commit e16f5e39acd6d10cc63ae39bc0a77188ed828f22 ]
There were several issues with handling errors in lm3554_probe():
- Probe did not set the error code when v4l2_ctrl_handler_init() failed.
- It intermixed gotos for handling errors of v4l2_ctrl_handler_init() and media_entity_pads_init().
- It did not set the error code for failures of v4l2_ctrl_new_custom().
- Probe did not free resources in case of failures of atomisp_register_i2c_module().
The patch fixes all these issues.
Found by Linux Driver Verification project (linuxtesting.org).
--- .../media/atomisp/i2c/atomisp-lm3554.c | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-)
drivers/staging/media/atomisp/i2c/atomisp-lm3554.c +24 -13
@@ -836,7 +836,6 @@ static int lm3554_probe(struct i2c_client *client)int err =0 ;struct lm3554 *flash;unsigned int i; -int ret; flash =kzalloc (sizeof (*flash),GFP_KERNEL );if (!flash)
@@ -845,7 +844,7 @@ static int lm3554_probe(struct i2c_client *client) flash->pdata =lm3554_platform_data_func (client);if (IS_ERR (flash->pdata)) { err =PTR_ERR (flash->pdata); - goto fail1; + goto free_flash; }v4l2_i2c_subdev_init (&flash->sd, client, &lm3554_ops);
@@ -853,12 +852,12 @@ static int lm3554_probe(struct i2c_client *client) flash->sd.flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ; flash->mode =ATOMISP_FLASH_MODE_OFF ; flash->timeout =LM3554_MAX_TIMEOUT /LM3554_TIMEOUT_STEPSIZE -1 ; - ret = + err =v4l2_ctrl_handler_init (&flash->ctrl_handler,ARRAY_SIZE (lm3554_controls)); -if (ret) { +if (err) {dev_err (&client->dev,"error initialize a ctrl_handler.\n" ); - goto fail3; + goto unregister_subdev; }for (i =0 ; i <ARRAY_SIZE (lm3554_controls); i++)
@@ -867,14 +866,15 @@ static int lm3554_probe(struct i2c_client *client)if (flash->ctrl_handler.error) {dev_err (&client->dev,"ctrl_handler error.\n" ); - goto fail3; + err = flash->ctrl_handler.error; + goto free_handler; } flash->sd.ctrl_handler = &flash->ctrl_handler; err =media_entity_pads_init (&flash->sd.entity,0 ,NULL );if (err) {dev_err (&client->dev,"error initialize a media entity.\n" ); - goto fail2; + goto free_handler; } flash->sd.entity.function =MEDIA_ENT_F_FLASH ;
@@ -885,16 +885,27 @@ static int lm3554_probe(struct i2c_client *client) err =lm3554_gpio_init (client);if (err) { -dev_err (&client->dev,"gpio request/direction_output fail" ); - goto fail3; +dev_err (&client->dev,"gpio request/direction_output fail.\n" ); + goto cleanup_media; + } + + err =atomisp_register_i2c_module (&flash->sd,NULL ,LED_FLASH ); +if (err) { +dev_err (&client->dev,"fail to register atomisp i2c module.\n" ); + goto uninit_gpio; } -return atomisp_register_i2c_module (&flash->sd,NULL ,LED_FLASH ); -fail3: + +return 0 ; + +uninit_gpio: +lm3554_gpio_uninit (client); +cleanup_media:media_entity_cleanup (&flash->sd.entity); +free_handler:v4l2_ctrl_handler_free (&flash->ctrl_handler); -fail2: +unregister_subdev:v4l2_device_unregister_subdev (&flash->sd); -fail1: +free_flash:kfree (flash);return err;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 191/575 media: stm32: Potential NULL pointer dereference in dcmi_irq_thread()
In reply to Greg Kroah-HartmanFrom: Dmitriy Ulitin <[email protected]>
[ Upstream commit 548fa43a58696450c15b8f5564e99589c5144664 ]
At the moment of enabling irq handling:
1922 ret = devm_request_threaded_irq(&pdev->dev, irq, dcmi_irq_callback,
1923 dcmi_irq_thread, IRQF_ONESHOT,
1924 dev_name(&pdev->dev), dcmi);
there is still uninitialized field sd_format of struct stm32_dcmi *dcmi. If an interrupt occurs in the interval between the installation of the interrupt handler and the initialization of this field, NULL pointer dereference happens.
This field is dereferenced in the handler function without any check:
457 if (dcmi->sd_format->fourcc == V4L2_PIX_FMT_JPEG &&
458 dcmi->misr & IT_FRAME) {
The patch moves interrupt handler installation after initialization of the sd_format field that happens in dcmi_graph_notify_complete() via dcmi_set_default_fmt().
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/media/platform/stm32/stm32-dcmi.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/media/platform/stm32/stm32-dcmi.c +11 -8
@@ -135,6 +135,7 @@ struct stm32_dcmi {int sequence;struct list_head buffers;struct dcmi_buf *active; +int irq;struct v4l2_device v4l2_dev;struct video_device *vdev;
@@ -1720,6 +1721,14 @@ static int dcmi_graph_notify_complete(struct v4l2_async_notifier *notifier)return ret; } + ret =devm_request_threaded_irq (dcmi->dev, dcmi->irq, dcmi_irq_callback, + dcmi_irq_thread,IRQF_ONESHOT , +dev_name (dcmi->dev), dcmi); +if (ret) { +dev_err (dcmi->dev,"Unable to request irq %d\n" , dcmi->irq); +return ret; + } +return 0 ; }
@@ -1881,6 +1890,8 @@ static int dcmi_probe(struct platform_device *pdev)if (irq <=0 )return irq ? irq : -ENXIO ; + dcmi->irq = irq; + dcmi->res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!dcmi->res) {dev_err (&pdev->dev,"Could not get resource\n" );
@@ -1893,14 +1904,6 @@ static int dcmi_probe(struct platform_device *pdev)return PTR_ERR (dcmi->regs); } - ret =devm_request_threaded_irq (&pdev->dev, irq, dcmi_irq_callback, - dcmi_irq_thread,IRQF_ONESHOT , -dev_name (&pdev->dev), dcmi); -if (ret) { -dev_err (&pdev->dev,"Unable to request irq %d\n" , irq); -return ret; - } - mclk =devm_clk_get (&pdev->dev,"mclk" );if (IS_ERR (mclk)) {if (PTR_ERR (mclk) != -EPROBE_DEFER )
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 192/575 media: uvcvideo: Set capability in s_param
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 97a2777a96070afb7da5d587834086c0b586c8cc ]
Fixes v4l2-compliance:
Format ioctls (Input 0):
warn: v4l2-test-formats.cpp(1339): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME
fail: v4l2-test-formats.cpp(1241): node->has_frmintervals && !cap->capability
--- drivers/media/usb/uvc/uvc_v4l2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/media/usb/uvc/uvc_v4l2.c +5 -2
@@ -471,10 +471,13 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream,uvc_simplify_fraction (&timeperframe.numerator, &timeperframe.denominator,8 ,333 ); -if (parm->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE ) +if (parm->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE ) { parm->parm.capture.timeperframe = timeperframe; -else + parm->parm.capture.capability =V4L2_CAP_TIMEPERFRAME ; + }else { parm->parm.output.timeperframe = timeperframe; + parm->parm.output.capability =V4L2_CAP_TIMEPERFRAME ; + }return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 193/575 media: uvcvideo: Return -EIO for control errors
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit ffccdde5f0e17d2f0d788a9d831a027187890eaa ]
The device is doing something unexpected with the control. Either because the protocol is not properly implemented or there has been a HW error.
Fixes v4l2-compliance:
Control ioctls (Input 0):
fail: v4l2-test-controls.cpp(448): s_ctrl returned an error (22)
test VIDIOC_G/S_CTRL: FAIL
fail: v4l2-test-controls.cpp(698): s_ext_ctrls returned an error (22)
test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
--- drivers/media/usb/uvc/uvc_video.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/media/usb/uvc/uvc_video.c +5 -0
@@ -112,6 +112,11 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,case 5 :/* Invalid unit */ case 6 :/* Invalid control */ case 7 :/* Invalid Request */ +/* +* The firmware has not properly implemented +* the control or there has been a HW error. +*/ +return -EIO ;case 8 :/* Invalid value within range */ return -EINVAL ;default :/* reserved or unknown */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 194/575 media: uvcvideo: Set unique vdev name based in type
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit e3f60e7e1a2b451f538f9926763432249bcf39c4 ]
All the entities must have a unique name. We can have a descriptive and unique name by appending the function and the entity->id.
This is even resilent to multi chain devices.
Fixes v4l2-compliance:
Media Controller ioctls:
fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end()
test MEDIA_IOC_G_TOPOLOGY: FAIL
fail: v4l2-test-media.cpp(394): num_data_links != num_links
test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL
--- drivers/media/usb/uvc/uvc_driver.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/media/usb/uvc/uvc_driver.c +6 -1
@@ -2065,6 +2065,7 @@ int uvc_register_video_device(struct uvc_device *dev,const struct v4l2_file_operations *fops, const struct v4l2_ioctl_ops *ioctl_ops) { + const char *name;int ret;/* Initialize the video buffers queue. */
@@ -2093,16 +2094,20 @@ int uvc_register_video_device(struct uvc_device *dev,case V4L2_BUF_TYPE_VIDEO_CAPTURE :default : vdev->device_caps =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_STREAMING ; + name ="Video Capture" ;break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT : vdev->device_caps =V4L2_CAP_VIDEO_OUTPUT |V4L2_CAP_STREAMING ; + name ="Video Output" ;break ;case V4L2_BUF_TYPE_META_CAPTURE : vdev->device_caps =V4L2_CAP_META_CAPTURE |V4L2_CAP_STREAMING ; + name ="Metadata" ;break ; } -strscpy (vdev->name, dev->name,sizeof (vdev->name)); +snprintf (vdev->name,sizeof (vdev->name),"%s %u" , name, + stream->header.bTerminalLink);/* * Set the driver data before calling video_register_device, otherwise
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 195/575 media: s5p-mfc: fix possible null-pointer dereference in s5p_mfc_probe()
In reply to Greg Kroah-HartmanFrom: Tuo Li <[email protected]>
[ Upstream commit 8515965e5e33f4feb56134348c95953f3eadfb26 ]
The variable pdev is assigned to dev->plat_dev, and dev->plat_dev is checked in:
if (!dev->plat_dev)
This indicates both dev->plat_dev and pdev can be NULL. If so, the function dev_err() is called to print error information.
dev_err(&pdev->dev, "No platform data specified\n");
However, &pdev->dev is an illegal address, and it is dereferenced in dev_err().
To fix this possible null-pointer dereference, replace dev_err() with mfc_err().
--- drivers/media/platform/s5p-mfc/s5p_mfc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/s5p-mfc/s5p_mfc.c +1 -1
@@ -1283,7 +1283,7 @@ static int s5p_mfc_probe(struct platform_device *pdev)spin_lock_init (&dev->condlock); dev->plat_dev = pdev;if (!dev->plat_dev) { -dev_err (&pdev->dev,"No platform data specified\n" ); +mfc_err ("No platform data specified\n" );return -ENODEV ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 196/575 media: s5p-mfc: Add checking to s5p_mfc_probe().
In reply to Greg Kroah-HartmanFrom: Nadezda Lutovinova <[email protected]>
[ Upstream commit cdfaf4752e6915a4b455ad4400133e540e4dc965 ]
If of_device_get_match_data() return NULL,
then null pointer dereference occurs in s5p_mfc_init_pm(). The patch adds checking if dev->variant is NULL.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/media/platform/s5p-mfc/s5p_mfc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/platform/s5p-mfc/s5p_mfc.c +4 -0
@@ -1288,6 +1288,10 @@ static int s5p_mfc_probe(struct platform_device *pdev) } dev->variant =of_device_get_match_data (&pdev->dev); +if (!dev->variant) { +dev_err (&pdev->dev,"Failed to get device MFC hardware variant information\n" ); +return -ENOENT ; + } res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); dev->regs_base =devm_ioremap_resource (&pdev->dev, res);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 197/575 media: imx: set a media_device bus_info string
In reply to Greg Kroah-HartmanFrom: Martin Kepplinger <[email protected]>
[ Upstream commit 6d0d779b212c27293d9ccb4da092ff0ccb6efa39 ]
Some tools like v4l2-compliance let users select a media device based on the bus_info string which can be quite convenient. Use a unique string for that.
This also fixes the following v4l2-compliance warning:
warn: v4l2-test-media.cpp(52): empty bus_info
--- drivers/staging/media/imx/imx-media-dev-common.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/staging/media/imx/imx-media-dev-common.c +2 -0
@@ -363,6 +363,8 @@ struct imx_media_dev *imx_media_dev_init(struct device *dev, imxmd->v4l2_dev.notify = imx_media_notify;strscpy (imxmd->v4l2_dev.name,"imx-media" ,sizeof (imxmd->v4l2_dev.name)); +snprintf (imxmd->md.bus_info,sizeof (imxmd->md.bus_info), +"platform:%s" ,dev_name (imxmd->md.dev));media_device_init (&imxmd->md);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 198/575 media: mceusb: return without resubmitting URB in case of -EPROTO error.
In reply to Greg Kroah-HartmanFrom: Rajat Asthana <[email protected]>
[ Upstream commit 476db72e521983ecb847e4013b263072bb1110fc ]
Syzkaller reported a warning called "rcu detected stall in dummy_timer".
The error seems to be an error in mceusb_dev_recv(). In the case of -EPROTO error, the routine immediately resubmits the URB. Instead it should return without resubmitting URB.
--- drivers/media/rc/mceusb.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/rc/mceusb.c +1 -0
@@ -1386,6 +1386,7 @@ static void mceusb_dev_recv(struct urb *urb)case -ECONNRESET :case -ENOENT :case -EILSEQ : +case -EPROTO :case -ESHUTDOWN :usb_unlink_urb (urb);return ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 199/575 ia64: dont do IA64_CMPXCHG_DEBUG without CONFIG_PRINTK
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit c15b5fc054c3d6c97e953617605235c5cb8ce979 ]
When CONFIG_PRINTK is not set, the CMPXCHG_BUGCHECK() macro calls _printk(), but _printk() is a static inline function, not available as an extern.
Since the purpose of the macro is to print the BUGCHECK info, make this config option depend on PRINTK.
Fixes multiple occurrences of this build error:
../include/linux/printk.h:208:5: error: static declaration of '_printk' follows non-static declaration
208 | int _printk(const char *s, ...)
| ^~~~~~~
In file included from ../arch/ia64/include/asm/cmpxchg.h:5, ../arch/ia64/include/uapi/asm/cmpxchg.h:146:28: note: previous declaration of '_printk' with type 'int(const char *, ...)'
146 | extern int _printk(const char *fmt, ...);
--- arch/ia64/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/Kconfig.debug +1 -1
@@ -39,7 +39,7 @@ config DISABLE_VHPT config IA64_DEBUG_CMPXCHG bool "Turn on compare-and-exchange bug checking (slow!)" - depends on DEBUG_KERNEL + depends on DEBUG_KERNEL && PRINTK help Selecting this option turns on bug checking for the IA-64 compare-and-exchange instructions. This is slow! Itaniums
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 200/575 rtw88: fix RX clock gate setting while fifo dump
In reply to Greg Kroah-HartmanFrom: Zong-Zhe Yang <[email protected]>
[ Upstream commit c5a8e90730a322f236731fc347dd3afa5db5550e ]
When fw fifo dumps, RX clock gating should be disabled to avoid something unexpected. However, the register operation ran into a mistake. So, we fix it.
--- drivers/net/wireless/realtek/rtw88/fw.c | 7 +++---- drivers/net/wireless/realtek/rtw88/reg.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/realtek/rtw88/fw.c +3 -4
@@ -1421,12 +1421,10 @@ static void rtw_fw_read_fifo_page(struct rtw_dev *rtwdev, u32 offset, u32 size,u32 i;u16 idx =0 ;u16 ctl; -u8 rcr; - rcr =rtw_read8 (rtwdev,REG_RCR +2 ); ctl =rtw_read16 (rtwdev,REG_PKTBUF_DBG_CTRL ) &0xf000 ;/* disable rx clock gate */ -rtw_write8 (rtwdev,REG_RCR , rcr |BIT (3 )); +rtw_write32_set (rtwdev,REG_RCR ,BIT_DISGCLK ); do { rtw_write16(rtwdev, REG_PKTBUF_DBG_CTRL, start_pg | ctl);
@@ -1445,7 +1443,8 @@ static void rtw_fw_read_fifo_page(struct rtw_dev *rtwdev, u32 offset, u32 size, out:rtw_write16 (rtwdev,REG_PKTBUF_DBG_CTRL , ctl); -rtw_write8 (rtwdev,REG_RCR +2 , rcr); +/* restore rx clock gate */ +rtw_write32_clr (rtwdev,REG_RCR ,BIT_DISGCLK ); } static void rtw_fw_read_fifo(struct rtw_dev *rtwdev, enum rtw_fw_fifo_sel sel,
drivers/net/wireless/realtek/rtw88/reg.h +1 -0
@@ -400,6 +400,7 @@#define BIT_MFBEN BIT(22)#define BIT_DISCHKPPDLLEN BIT(21)#define BIT_PKTCTL_DLEN BIT(20) +#define BIT_DISGCLK BIT(19)#define BIT_TIM_PARSER_EN BIT(18)#define BIT_BC_MD_EN BIT(17)#define BIT_UC_MD_EN BIT(16)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 201/575 brcmfmac: Add DMI nvram filename quirk for Cyberbook T116 tablet
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 49c3eb3036e6359c5c20fe76c611a2c0e0d4710e ]
The Cyberbook T116 tablet contains quite generic names in the sys_vendor and product_name DMI strings, without this patch brcmfmac will try to load:
"brcmfmac43455-sdio.Default string-Default string.txt" as nvram file which is way too generic.
The nvram file shipped on the factory Android image contains the exact same settings as those used on the AcePC T8 mini PC, so point the new DMI nvram filename quirk to the acepc-t8 nvram file.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c +10 -0
@@ -75,6 +75,16 @@ static const struct dmi_system_id dmi_platform_data[] = { }, .driver_data = (void *)&acepc_t8_data, }, + { +/* Cyberbook T116 rugged tablet */ + .matches = { +DMI_EXACT_MATCH (DMI_BOARD_VENDOR ,"Default string" ), +DMI_EXACT_MATCH (DMI_BOARD_NAME ,"Cherry Trail CR" ), + DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "20170531"), + }, +/* The factory image nvram file is identical to the ACEPC T8 one */ + .driver_data = (void *)&acepc_t8_data, + }, {/* Match for the GPDwin which unfortunately uses somewhat * generic dmi strings, which is why we test for 4 strings.
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 202/575 media: rcar-csi2: Add checking to rcsi2_start_receiver()
In reply to Greg Kroah-HartmanFrom: Nadezda Lutovinova <[email protected]>
[ Upstream commit fc41665498332ad394b7db37f23e9394096ddc71 ]
If rcsi2_code_to_fmt() return NULL, then null pointer dereference occurs in the next cycle. That should not be possible now but adding checking protects from future bugs.
The patch adds checking if format is NULL.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/media/platform/rcar-vin/rcar-csi2.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/rcar-vin/rcar-csi2.c +2 -0
@@ -544,6 +544,8 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)/* Code is validated in set_fmt. */ format =rcsi2_code_to_fmt (priv->mf.code); +if (!format) +return -EINVAL ;/* * Enable all supported CSI-2 channels with virtual channel and
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 203/575 ipmi: Disable some operations during a panic
In reply to Greg Kroah-HartmanFrom: Corey Minyard <[email protected]>
[ Upstream commit b36eb5e7b75a756baa64909a176dd4269ee05a8b ]
Don't do kfree or other risky things when oops_in_progress is set. It's easy enough to avoid doing them
--- drivers/char/ipmi/ipmi_msghandler.c | 10 +++++++--- drivers/char/ipmi/ipmi_watchdog.c | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-)
drivers/char/ipmi/ipmi_msghandler.c +7 -3
@@ -4802,7 +4802,9 @@ static atomic_t recv_msg_inuse_count = ATOMIC_INIT(0);static void free_smi_msg (struct ipmi_smi_msg *msg) {atomic_dec (&smi_msg_inuse_count); -kfree (msg); +/* Try to keep as much stuff out of the panic path as possible. */ +if (!oops_in_progress) +kfree (msg); }struct ipmi_smi_msg *ipmi_alloc_smi_msg (void )
@@ -4821,7 +4823,9 @@ EXPORT_SYMBOL(ipmi_alloc_smi_msg);static void free_recv_msg (struct ipmi_recv_msg *msg) {atomic_dec (&recv_msg_inuse_count); -kfree (msg); +/* Try to keep as much stuff out of the panic path as possible. */ +if (!oops_in_progress) +kfree (msg); }static struct ipmi_recv_msg *ipmi_alloc_recv_msg (void )
@@ -4839,7 +4843,7 @@ static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void)void ipmi_free_recv_msg (struct ipmi_recv_msg *msg) { -if (msg->user) +if (msg->user && !oops_in_progress)kref_put (&msg->user->refcount, free_user); msg->done (msg); }
drivers/char/ipmi/ipmi_watchdog.c +12 -5
@@ -342,13 +342,17 @@ static atomic_t msg_tofree = ATOMIC_INIT(0);static DECLARE_COMPLETION (msg_wait);static void msg_free_smi (struct ipmi_smi_msg *msg) { -if (atomic_dec_and_test (&msg_tofree)) -complete (&msg_wait); +if (atomic_dec_and_test (&msg_tofree)) { +if (!oops_in_progress) +complete (&msg_wait); + } }static void msg_free_recv (struct ipmi_recv_msg *msg) { -if (atomic_dec_and_test (&msg_tofree)) -complete (&msg_wait); +if (atomic_dec_and_test (&msg_tofree)) { +if (!oops_in_progress) +complete (&msg_wait); + } }static struct ipmi_smi_msg smi_msg = { .done = msg_free_smi
@@ -434,8 +438,10 @@ static int _ipmi_set_timeout(int do_heartbeat) rv =__ipmi_set_timeout (&smi_msg, &recv_msg, &send_heartbeat_now); -if (rv) +if (rv) { +atomic_set (&msg_tofree,0 );return rv; + }wait_for_completion (&msg_wait);
@@ -580,6 +586,7 @@ restart: &recv_msg, 1);if (rv) { +atomic_set (&msg_tofree,0 );pr_warn ("heartbeat send failure: %d\n" , rv);return rv; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 204/575 fs/proc/uptime.c: Fix idle time reporting in /proc/uptime
In reply to Greg Kroah-HartmanFrom: Josh Don <[email protected]>
[ Upstream commit a130e8fbc7de796eb6e680724d87f4737a26d0ac ]
/proc/uptime reports idle time by reading the CPUTIME_IDLE field from the per-cpu kcpustats. However, on NO_HZ systems, idle time is not continually updated on idle cpus, leading this value to appear incorrectly small.
/proc/stat performs an accounting update when reading idle time; we can use the same approach for uptime.
With this patch, /proc/stat and /proc/uptime now agree on idle time. Additionally, the following shows idle time tick up consistently on an idle machine:
(while true; do cat /proc/uptime; sleep 1; done) | awk '{print $2-prev; prev=$2}'
--- fs/proc/stat.c | 4 ++-- fs/proc/uptime.c | 14 +++++++++----- include/linux/kernel_stat.h | 1 + 3 files changed, 12 insertions(+), 7 deletions(-)
fs/proc/stat.c +2 -2
@@ -23,7 +23,7 @@#ifdef arch_idle_time -static u64 get_idle_time (struct kernel_cpustat *kcs,int cpu) +u64 get_idle_time (struct kernel_cpustat *kcs,int cpu) {u64 idle;
@@ -45,7 +45,7 @@ static u64 get_iowait_time(struct kernel_cpustat *kcs, int cpu)#else -static u64 get_idle_time (struct kernel_cpustat *kcs,int cpu) +u64 get_idle_time (struct kernel_cpustat *kcs,int cpu) {u64 idle, idle_usecs =-1ULL ;
fs/proc/uptime.c +9 -5
@@ -12,18 +12,22 @@ static int uptime_proc_show(struct seq_file *m, void *v) {struct timespec64 uptime;struct timespec64 idle; -u64 nsec; +u64 idle_nsec;u32 rem;int i; - nsec =0 ; -for_each_possible_cpu (i) - nsec += (__force u64 )kcpustat_cpu (i).cpustat[CPUTIME_IDLE ]; + idle_nsec =0 ; +for_each_possible_cpu (i) { +struct kernel_cpustat kcs; + +kcpustat_cpu_fetch (&kcs, i); + idle_nsec +=get_idle_time (&kcs, i); + }ktime_get_boottime_ts64 (&uptime);timens_add_boottime (&uptime); - idle.tv_sec =div_u64_rem (nsec,NSEC_PER_SEC , &rem); + idle.tv_sec =div_u64_rem (idle_nsec,NSEC_PER_SEC , &rem); idle.tv_nsec = rem; seq_printf(m, "%lu.%02lu %lu.%02lu\n", (unsigned long) uptime.tv_sec,
include/linux/kernel_stat.h +1 -0
@@ -103,6 +103,7 @@ extern void account_system_index_time(struct task_struct *, u64, enum cpu_usage_stat);extern void account_steal_time (u64 );extern void account_idle_time (u64 ); +extern u64 get_idle_time (struct kernel_cpustat *kcs,int cpu);#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE static inline void account_process_tick (struct task_struct *tsk,int user)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 205/575 ACPICA: Avoid evaluating methods too early during system resume
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit d3c4b6f64ad356c0d9ddbcf73fa471e6a841cc5c ]
ACPICA commit 0762982923f95eb652cf7ded27356b247c9774de
During wakeup from system-wide sleep states, acpi_get_sleep_type_data() is called and it tries to get memory from the slab allocator in order to evaluate a control method, but if KFENCE is enabled in the kernel, the memory allocation attempt causes an IRQ work to be queued and a self-IPI to be sent to the CPU running the code which requires the memory controller to be ready, so if that happens too early in the wakeup path, it doesn't work.
Prevent that from taking place by calling acpi_get_sleep_type_data() for S0 upfront, when preparing to enter a given sleep state, and saving the data obtained by it for later use during system wakeup.
--- drivers/acpi/acpica/acglobal.h | 2 ++ drivers/acpi/acpica/hwesleep.c | 8 ++------ drivers/acpi/acpica/hwsleep.c | 11 ++++------- drivers/acpi/acpica/hwxfsleep.c | 7 +++++++ 4 files changed, 15 insertions(+), 13 deletions(-)
drivers/acpi/acpica/acglobal.h +2 -0
@@ -226,6 +226,8 @@ extern struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG ];ACPI_GLOBAL (u8, acpi_gbl_sleep_type_a);ACPI_GLOBAL (u8, acpi_gbl_sleep_type_b); +ACPI_GLOBAL (u8, acpi_gbl_sleep_type_a_s0); +ACPI_GLOBAL (u8, acpi_gbl_sleep_type_b_s0);/***************************************************************************** *
drivers/acpi/acpica/hwesleep.c +2 -6
@@ -147,17 +147,13 @@ acpi_status acpi_hw_extended_sleep(u8 sleep_state)acpi_status acpi_hw_extended_wake_prep (u8 sleep_state) { -acpi_status status;u8 sleep_type_value;ACPI_FUNCTION_TRACE (hw_extended_wake_prep); - status =acpi_get_sleep_type_data (ACPI_STATE_S0 , - &acpi_gbl_sleep_type_a, - &acpi_gbl_sleep_type_b); -if (ACPI_SUCCESS (status)) { +if (acpi_gbl_sleep_type_a_s0 !=ACPI_SLEEP_TYPE_INVALID ) { sleep_type_value = - ((acpi_gbl_sleep_type_a <<ACPI_X_SLEEP_TYPE_POSITION ) & + ((acpi_gbl_sleep_type_a_s0 <<ACPI_X_SLEEP_TYPE_POSITION ) &ACPI_X_SLEEP_TYPE_MASK ); (void)acpi_write((u64)(sleep_type_value | ACPI_X_SLEEP_ENABLE),
drivers/acpi/acpica/hwsleep.c +4 -7
@@ -179,7 +179,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state)acpi_status acpi_hw_legacy_wake_prep (u8 sleep_state) { -acpi_status status; +acpi_status status =AE_OK ;struct acpi_bit_register_info *sleep_type_reg_info;struct acpi_bit_register_info *sleep_enable_reg_info;u32 pm1a_control;
@@ -192,10 +192,7 @@ acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)* This is unclear from the ACPI Spec, but it is required * by some machines. */ - status =acpi_get_sleep_type_data (ACPI_STATE_S0 , - &acpi_gbl_sleep_type_a, - &acpi_gbl_sleep_type_b); -if (ACPI_SUCCESS (status)) { +if (acpi_gbl_sleep_type_a_s0 !=ACPI_SLEEP_TYPE_INVALID ) { sleep_type_reg_info =acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_TYPE ); sleep_enable_reg_info =
@@ -216,9 +213,9 @@ acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)/* Insert the SLP_TYP bits */ - pm1a_control |= (acpi_gbl_sleep_type_a << + pm1a_control |= (acpi_gbl_sleep_type_a_s0 << sleep_type_reg_info->bit_position); - pm1b_control |= (acpi_gbl_sleep_type_b << + pm1b_control |= (acpi_gbl_sleep_type_b_s0 << sleep_type_reg_info->bit_position);/* Write the control registers and ignore any errors */
drivers/acpi/acpica/hwxfsleep.c +7 -0
@@ -217,6 +217,13 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)return_ACPI_STATUS (status); } + status =acpi_get_sleep_type_data (ACPI_STATE_S0 , + &acpi_gbl_sleep_type_a_s0, + &acpi_gbl_sleep_type_b_s0); +if (ACPI_FAILURE (status)) { + acpi_gbl_sleep_type_a_s0 =ACPI_SLEEP_TYPE_INVALID ; + } +/* Execute the _PTS method (Prepare To Sleep) */ arg_list.count =1 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 206/575 media: ipu3-imgu: imgu_fmt: Handle properly try
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 553481e38045f349bb9aa596d03bebd020020c9c ]
For a try_fmt call, the node noes not need to be enabled.
Fixes v4l2-compliance
fail: v4l2-test-formats.cpp(717): Video Output Multiplanar is valid, but
no TRY_FMT was implemented
test VIDIOC_TRY_FMT: FAIL
--- drivers/staging/media/ipu3/ipu3-v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/ipu3/ipu3-v4l2.c +1 -1
@@ -696,7 +696,7 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,/* CSS expects some format on OUT queue */ if (i !=IPU3_CSS_QUEUE_OUT && - !imgu_pipe->nodes[inode].enabled) { + !imgu_pipe->nodes[inode].enabled && !try) { fmts[i] =NULL ;continue ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 207/575 media: ipu3-imgu: VIDIOC_QUERYCAP: Fix bus_info
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit ea2b9a33711604e91f8c826f4dcb3c12baa1990a ]
bus_info field had a different value for the media entity and the video device.
Fixes v4l2-compliance:
v4l2-compliance.cpp(637): media bus_info 'PCI:0000:00:05.0' differs from
V4L2 bus_info 'PCI:viewfinder'
--- drivers/staging/media/ipu3/ipu3-v4l2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/media/ipu3/ipu3-v4l2.c +3 -2
@@ -592,11 +592,12 @@ static const struct imgu_fmt *find_format(struct v4l2_format *f, u32 type)static int imgu_vidioc_querycap (struct file *file,void *fh,struct v4l2_capability *cap) { -struct imgu_video_device *node =file_to_intel_imgu_node (file); +struct imgu_device *imgu =video_drvdata (file);strscpy (cap->driver,IMGU_NAME ,sizeof (cap->driver));strscpy (cap->card,IMGU_NAME ,sizeof (cap->card)); -snprintf (cap->bus_info,sizeof (cap->bus_info),"PCI:%s" , node->name); +snprintf (cap->bus_info,sizeof (cap->bus_info),"PCI:%s" , +pci_name (imgu->pci_dev));return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 208/575 media: usb: dvd-usb: fix uninit-value bug in dibusb_read_eeprom_byte()
In reply to Greg Kroah-HartmanFrom: Anant Thazhemadam <[email protected]>
[ Upstream commit 899a61a3305d49e8a712e9ab20d0db94bde5929f ]
In dibusb_read_eeprom_byte(), if dibusb_i2c_msg() fails, val gets assigned an value that's not properly initialized.
Using kzalloc() in place of kmalloc() for the buffer fixes this issue, as the val can now be set to 0 in the event dibusb_i2c_msg() fails.
--- drivers/media/usb/dvb-usb/dibusb-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/dvb-usb/dibusb-common.c +1 -1
@@ -223,7 +223,7 @@ int dibusb_read_eeprom_byte(struct dvb_usb_device *d, u8 offs, u8 *val)u8 *buf;int rc; - buf =kmalloc (2 ,GFP_KERNEL ); + buf =kzalloc (2 ,GFP_KERNEL );if (!buf)return -ENOMEM ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 209/575 net-sysfs: try not to restart the syscall if it will fail eventually
In reply to Greg Kroah-HartmanFrom: Antoine Tenart <[email protected]>
[ Upstream commit 146e5e733310379f51924111068f08a3af0db830 ]
Due to deadlocks in the networking subsystem spotted 12 years ago[1], a workaround was put in place[2] to avoid taking the rtnl lock when it was not available and restarting the syscall (back to VFS, letting userspace spin). The following construction is found a lot in the net sysfs and sysctl code:
if (!rtnl_trylock())
return restart_syscall();This can be problematic when multiple userspace threads use such interfaces in a short period, making them to spin a lot. This happens for example when adding and moving virtual interfaces: userspace programs listening on events, such as systemd-udevd and NetworkManager, do trigger actions reading files in sysfs. It gets worse when a lot of virtual interfaces are created concurrently, say when creating containers at boot time.
Returning early without hitting the above pattern when the syscall will fail eventually does make things better. While it is not a fix for the issue, it does ease things.
[1] https://lore.kernel.org/netdev/[email protected]/
https://lore.kernel.org/netdev/[email protected]/ and https://lore.kernel.org/netdev/20090226084924.16cb3e08@nehalam/
[2] Rightfully, those deadlocks are *hard* to solve.
--- net/core/net-sysfs.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+)
net/core/net-sysfs.c +55 -0
@@ -175,6 +175,14 @@ static int change_carrier(struct net_device *dev, unsigned long new_carrier)static ssize_t carrier_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t len) { +struct net_device *netdev =to_net_dev (dev); + +/* The check is also done in change_carrier; this helps returning early +* without hitting the trylock/restart in netdev_store. +*/ +if (!netdev->netdev_ops->ndo_change_carrier) +return -EOPNOTSUPP ; +return netdev_store (dev, attr, buf, len, change_carrier); }
@@ -196,6 +204,12 @@ static ssize_t speed_show(struct device *dev,struct net_device *netdev =to_net_dev (dev);int ret = -EINVAL ; +/* The check is also done in __ethtool_get_link_ksettings; this helps +* returning early without hitting the trylock/restart below. +*/ +if (!netdev->ethtool_ops->get_link_ksettings) +return ret; +if (!rtnl_trylock ())return restart_syscall ();
@@ -216,6 +230,12 @@ static ssize_t duplex_show(struct device *dev,struct net_device *netdev =to_net_dev (dev);int ret = -EINVAL ; +/* The check is also done in __ethtool_get_link_ksettings; this helps +* returning early without hitting the trylock/restart below. +*/ +if (!netdev->ethtool_ops->get_link_ksettings) +return ret; +if (!rtnl_trylock ())return restart_syscall ();
@@ -468,6 +488,14 @@ static ssize_t proto_down_store(struct device *dev,struct device_attribute *attr, const char *buf, size_t len) { + struct net_device *netdev = to_net_dev(dev); + +/* The check is also done in change_proto_down; this helps returning +* early without hitting the trylock/restart in netdev_store. +*/ +if (!netdev->netdev_ops->ndo_change_proto_down) +return -EOPNOTSUPP ; +return netdev_store (dev, attr, buf, len, change_proto_down); }NETDEVICE_SHOW_RW (proto_down, fmt_dec);
@@ -478,6 +506,12 @@ static ssize_t phys_port_id_show(struct device *dev,struct net_device *netdev =to_net_dev (dev);ssize_t ret = -EINVAL ; +/* The check is also done in dev_get_phys_port_id; this helps returning +* early without hitting the trylock/restart below. +*/ +if (!netdev->netdev_ops->ndo_get_phys_port_id) +return -EOPNOTSUPP ; +if (!rtnl_trylock ())return restart_syscall ();
@@ -500,6 +534,13 @@ static ssize_t phys_port_name_show(struct device *dev,struct net_device *netdev =to_net_dev (dev);ssize_t ret = -EINVAL ; +/* The checks are also done in dev_get_phys_port_name; this helps +* returning early without hitting the trylock/restart below. +*/ +if (!netdev->netdev_ops->ndo_get_phys_port_name && + !netdev->netdev_ops->ndo_get_devlink_port) +return -EOPNOTSUPP ; +if (!rtnl_trylock ())return restart_syscall ();
@@ -522,6 +563,14 @@ static ssize_t phys_switch_id_show(struct device *dev,struct net_device *netdev =to_net_dev (dev);ssize_t ret = -EINVAL ; +/* The checks are also done in dev_get_phys_port_name; this helps +* returning early without hitting the trylock/restart below. This works +* because recurse is false when calling dev_get_port_parent_id. +*/ +if (!netdev->netdev_ops->ndo_get_port_parent_id && + !netdev->netdev_ops->ndo_get_devlink_port) +return -EOPNOTSUPP ; +if (!rtnl_trylock ())return restart_syscall ();
@@ -1179,6 +1228,12 @@ static ssize_t tx_maxrate_store(struct netdev_queue *queue,if (!capable (CAP_NET_ADMIN ))return -EPERM ; +/* The check is also done later; this helps returning early without +* hitting the trylock/restart below. +*/ +if (!dev->netdev_ops->ndo_set_tx_maxrate) +return -EOPNOTSUPP ; + err =kstrtou32 (buf,10 , &rate);if (err <0 )return err;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 210/575 tracefs: Have tracefs directories not set OTH permission bits by default
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (VMware) <[email protected]>
[ Upstream commit 49d67e445742bbcb03106b735b2ab39f6e5c56bc ]
The tracefs file system is by default mounted such that only root user can access it. But there are legitimate reasons to create a group and allow those added to the group to have access to tracing. By changing the permissions of the tracefs mount point to allow access, it will allow group access to the tracefs directory.
There should not be any real reason to allow all access to the tracefs directory as it contains sensitive information. Have the default permission of directories being created not have any OTH (other) bits set, such that an admin that wants to give permission to a group has to first disable all OTH bits in the file system.
--- fs/tracefs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/tracefs/inode.c +2 -1
@@ -430,7 +430,8 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent,if (unlikely (!inode))return failed_creating (dentry); - inode->i_mode =S_IFDIR |S_IRWXU |S_IRUGO |S_IXUGO ; +/* Do not set bits for OTH */ + inode->i_mode =S_IFDIR |S_IRWXU |S_IRUSR |S_IRGRP |S_IXUSR |S_IXGRP ; inode->i_op = ops; inode->i_fop = &simple_dir_operations;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 211/575 ath: dfs_pattern_detector: Fix possible null-pointer dereference in channel_detector_create()
In reply to Greg Kroah-HartmanFrom: Tuo Li <[email protected]>
[ Upstream commit 4b6012a7830b813799a7faf40daa02a837e0fd5b ]
kzalloc() is used to allocate memory for cd->detectors, and if it fails, channel_detector_exit() behind the label fail will be called:
channel_detector_exit(dpd, cd);
In channel_detector_exit(), cd->detectors is dereferenced through:
struct pri_detector *de = cd->detectors[i];
To fix this possible null-pointer dereference, check cd->detectors before the for loop to dereference cd->detectors.
--- drivers/net/wireless/ath/dfs_pattern_detector.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/dfs_pattern_detector.c +6 -4
@@ -182,10 +182,12 @@ static void channel_detector_exit(struct dfs_pattern_detector *dpd,if (cd ==NULL )return ;list_del (&cd->head); -for (i =0 ; i < dpd->num_radar_types; i++) { -struct pri_detector *de = cd->detectors[i]; -if (de !=NULL ) - de->exit (de); +if (cd->detectors) { +for (i =0 ; i < dpd->num_radar_types; i++) { +struct pri_detector *de = cd->detectors[i]; +if (de !=NULL ) + de->exit (de); + } }kfree (cd->detectors);kfree (cd);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 212/575 mmc: moxart: Fix reference count leaks in moxart_probe
In reply to Greg Kroah-HartmanFrom: Xin Xiong <[email protected]>
[ Upstream commit 8105c2abbf36296bf38ca44f55ee45d160db476a ]
The issue happens in several error handling paths on two refcounted object related to the object "host" (dma_chan_rx, dma_chan_tx). In these paths, the function forgets to decrement one or both objects' reference count increased earlier by dma_request_chan(), causing reference count leaks.
Fix it by balancing the refcounts of both objects in some error handling paths. In correspondence with the changes in moxart_probe(), IS_ERR() is replaced with IS_ERR_OR_NULL() in moxart_remove() as well.
--- drivers/mmc/host/moxart-mmc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/mmc/host/moxart-mmc.c +14 -2
@@ -624,6 +624,14 @@ static int moxart_probe(struct platform_device *pdev) ret = -EPROBE_DEFER ; goto out; } +if (!IS_ERR (host->dma_chan_tx)) { +dma_release_channel (host->dma_chan_tx); + host->dma_chan_tx =NULL ; + } +if (!IS_ERR (host->dma_chan_rx)) { +dma_release_channel (host->dma_chan_rx); + host->dma_chan_rx =NULL ; + }dev_dbg (dev,"PIO mode transfer enabled\n" ); host->have_dma = false; }else {
@@ -678,6 +686,10 @@ static int moxart_probe(struct platform_device *pdev)return 0 ; out: +if (!IS_ERR_OR_NULL (host->dma_chan_tx)) +dma_release_channel (host->dma_chan_tx); +if (!IS_ERR_OR_NULL (host->dma_chan_rx)) +dma_release_channel (host->dma_chan_rx);if (mmc)mmc_free_host (mmc);return ret;
@@ -690,9 +702,9 @@ static int moxart_remove(struct platform_device *pdev)dev_set_drvdata (&pdev->dev,NULL ); -if (!IS_ERR (host->dma_chan_tx)) +if (!IS_ERR_OR_NULL (host->dma_chan_tx))dma_release_channel (host->dma_chan_tx); -if (!IS_ERR (host->dma_chan_rx)) +if (!IS_ERR_OR_NULL (host->dma_chan_rx))dma_release_channel (host->dma_chan_rx);mmc_remove_host (mmc);mmc_free_host (mmc);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 213/575 iov_iter: Fix iov_iter_get_pages{,_alloc} page fault return value
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
[ Upstream commit 814a66741b9ffb5e1ba119e368b178edb0b7322d ]
Both iov_iter_get_pages and iov_iter_get_pages_alloc return the number of bytes of the iovec they could get the pages for. When they cannot get any pages, they're supposed to return 0, but when the start of the iovec isn't page aligned, the calculation goes wrong and they return a negative value. Fix both functions.
In addition, change iov_iter_get_pages_alloc to return NULL in that case to prevent resource leaks.
--- lib/iov_iter.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/iov_iter.c +3 -2
@@ -1343,7 +1343,7 @@ ssize_t iov_iter_get_pages(struct iov_iter *i, res =get_user_pages_fast (addr, n,iov_iter_rw (i) !=WRITE ?FOLL_WRITE :0 , pages); -if (unlikely (res <0 )) +if (unlikely (res <=0 ))return res;return (res == n ? len : res *PAGE_SIZE ) - *start; 0;}),({
@@ -1424,8 +1424,9 @@ ssize_t iov_iter_get_pages_alloc(struct iov_iter *i,return -ENOMEM ; res =get_user_pages_fast (addr, n,iov_iter_rw (i) !=WRITE ?FOLL_WRITE :0 , p); -if (unlikely (res <0 )) { +if (unlikely (res <=0 )) {kvfree (p); + *pages =NULL ;return res; } *pages = p;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 214/575 ACPI: battery: Accept charges over the design capacity as full
In reply to Greg Kroah-HartmanFrom: André Almeida <[email protected]>
[ Upstream commit 2835f327bd1240508db2c89fe94a056faa53c49a ]
Some buggy firmware and/or brand new batteries can support a charge that's slightly over the reported design capacity. In such cases, the kernel will report to userspace that the charging state of the battery is "Unknown", when in reality the battery charge is "Full", at least from the design capacity point of view. Make the fallback condition accepts capacities over the designed capacity so userspace knows that is full.
--- drivers/acpi/battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/battery.c +1 -1
@@ -174,7 +174,7 @@ static int acpi_battery_is_charged(struct acpi_battery *battery)return 1 ;/* fallback to using design values for broken batteries */ -if (battery->design_capacity == battery->capacity_now) +if (battery->design_capacity <= battery->capacity_now)return 1 ;/* we don't do any sort of metric based on percentages */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 215/575 drm/amdkfd: fix resume error when iommu disabled in Picasso
In reply to Greg Kroah-HartmanFrom: Yifan Zhang <[email protected]>
[ Upstream commit 6f4b590aae217da16cfa44039a2abcfb209137ab ]
When IOMMU disabled in sbios and kfd in iommuv2 path, IOMMU resume failure blocks system resume. Don't allow kfd to use iommu v2 when iommu is disabled.
--- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +1 -0
@@ -744,6 +744,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,kfd_double_confirm_iommu_support (kfd);if (kfd_iommu_device_init (kfd)) { + kfd->use_iommu_v2 = false;dev_err (kfd_device,"Error initializing iommuv2\n" ); goto device_iommu_error; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 216/575 net: phy: micrel: make *-skew-ps check more lenient
In reply to Greg Kroah-HartmanFrom: Matthias Schiffer <[email protected]>
[ Upstream commit 67ca5159dbe2edb5dae7544447b8677d2596933a ]
It seems reasonable to fine-tune only some of the skew values when using one of the rgmii-*id PHY modes, and even when all skew values are specified, using the correct ID PHY mode makes sense for documentation purposes. Such a configuration also appears in the binding docs in Documentation/devicetree/bindings/net/micrel-ksz90x1.txt, so the driver should not warn about it.
--- drivers/net/phy/micrel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/micrel.c +2 -2
@@ -732,9 +732,9 @@ static int ksz9031_config_init(struct phy_device *phydev)MII_KSZ9031RN_TX_DATA_PAD_SKEW ,4 , tx_data_skews, 4, &update); -if (update && phydev->interface !=PHY_INTERFACE_MODE_RGMII ) +if (update && !phy_interface_is_rgmii (phydev))phydev_warn (phydev, -"*-skew-ps values should be used only with phy-mode = \"rgmii\"\n" ); +"*-skew-ps values should be used only with RGMII PHY modes\n" );/* Silicon Errata Sheet (DS80000691D or DS80000692D): * When the device links in the 1000BASE-T slave mode only,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 217/575 leaking_addresses: Always print a trailing newline
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit cf2a85efdade117e2169d6e26641016cbbf03ef0 ]
For files that lack trailing newlines and match a leaking address (e.g. wchan[1]), the leaking_addresses.pl report would run together with the next line, making things look corrupted.
Unconditionally remove the newline on input, and write it back out on output.
[1] https://lore.kernel.org/all/20210103142726.GC30643@xsang-OptiPlex-9020/
--- scripts/leaking_addresses.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/leaking_addresses.pl +2 -1
@@ -455,8 +455,9 @@ sub parse_file open my $fh, "<", $file or return; while ( <$fh> ) { + chomp; if (may_leak_address($_)) { - print $file . ': ' . $_; + printf("$file: $_\n"); } } close $fh;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 218/575 drm/msm: prevent NULL dereference in msm_gpu_crashstate_capture()
In reply to Greg Kroah-HartmanFrom: Tim Gardner <[email protected]>
[ Upstream commit b220c154832c5cd0df34cbcbcc19d7135c16e823 ]
Coverity complains of a possible NULL dereference:
CID 120718 (#1 of 1): Dereference null return value (NULL_RETURNS)
23. dereference: Dereferencing a pointer that might be NULL state->bos when calling msm_gpu_crashstate_get_bo. [show details]
301 msm_gpu_crashstate_get_bo(state, submit->bos[i].obj,
302 submit->bos[i].iova, submit->bos[i].flags);
Fix this by employing the same state->bos NULL check as is used in the next for loop.
--- drivers/gpu/drm/msm/msm_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_gpu.c +1 -1
@@ -376,7 +376,7 @@ static void msm_gpu_crashstate_capture(struct msm_gpu *gpu, state->bos =kcalloc (nr,sizeof (struct msm_gpu_state_bo ),GFP_KERNEL ); -for (i =0 ; i < submit->nr_bos; i++) { +for (i =0 ; state->bos && i < submit->nr_bos; i++) {if (should_dump (submit, i)) {msm_gpu_crashstate_get_bo (state, submit->bos[i].obj, submit->bos[i].iova, submit->bos[i].flags);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 219/575 block: bump max plugged deferred size from 16 to 32
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
[ Upstream commit ba0ffdd8ce48ad7f7e85191cd29f9674caca3745 ]
Particularly for NVMe with efficient deferred submission for many requests, there are nice benefits to be seen by bumping the default max plug count from 16 to 32. This is especially true for virtualized setups, where the submit part is more expensive. But can be noticed even on native hardware.
Reduce the multiple queue factor from 4 to 2, since we're changing the default size.
While changing it, move the defines into the block layer private header. These aren't values that anyone outside of the block layer uses, or should use.
--- block/blk-mq.c | 4 ++-- block/blk.h | 6 ++++++ include/linux/blkdev.h | 2 -- 3 files changed, 8 insertions(+), 4 deletions(-)
block/blk-mq.c +2 -2
@@ -2116,14 +2116,14 @@ static void blk_add_rq_to_plug(struct blk_plug *plug, struct request *rq) }/* -* Allow 4x BLK_MAX_REQUEST_COUNT requests on plug queue for multiple +* Allow 2x BLK_MAX_REQUEST_COUNT requests on plug queue for multiple * queues. This is important for md arrays to benefit from merging * requests. */ static inline unsigned short blk_plug_max_rq_count (struct blk_plug *plug) {if (plug->multiple_queues) -return BLK_MAX_REQUEST_COUNT *4 ; +return BLK_MAX_REQUEST_COUNT *2 ;return BLK_MAX_REQUEST_COUNT ; }
block/blk.h +6 -0
@@ -188,6 +188,12 @@ bool blk_bio_list_merge(struct request_queue *q, struct list_head *list,void blk_account_io_start (struct request *req);void blk_account_io_done (struct request *req,u64 now); +/* +* Plug flush limits +*/ +#define BLK_MAX_REQUEST_COUNT 32 +#define BLK_PLUG_FLUSH_SIZE (128 * 1024) +/* * Internal elevator interface */
include/linux/blkdev.h +0 -2
@@ -1248,8 +1248,6 @@ struct blk_plug {bool multiple_queues;bool nowait; }; -#define BLK_MAX_REQUEST_COUNT 16 -#define BLK_PLUG_FLUSH_SIZE (128 * 1024)struct blk_plug_cb ;typedef void (*blk_plug_cb_fn )(struct blk_plug_cb *,bool );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 220/575 md: update superblock after changing rdev flags in state_store
In reply to Greg Kroah-HartmanFrom: Xiao Ni <[email protected]>
[ Upstream commit 8b9e2291e355a0eafdd5b1e21a94a6659f24b351 ]
When the in memory flag is changed, we need to persist the change in the rdev superblock flags. This is needed for "writemostly" and "failfast".
--- drivers/md/md.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/md/md.c +10 -1
@@ -3024,7 +3024,11 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)* -write_error - clears WriteErrorSeen * {,-}failfast - set/clear FailFast */ + +struct mddev *mddev = rdev->mddev;int err = -EINVAL ; +bool need_update_sb = false; +if (cmd_match (buf,"faulty" ) && rdev->mddev->pers) {md_error (rdev->mddev, rdev);if (test_bit (Faulty, &rdev->flags))
@@ -3039,7 +3043,6 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)if (rdev->raid_disk >=0 ) err = -EBUSY ;else { -struct mddev *mddev = rdev->mddev; err =0 ;if (mddev_is_clustered (mddev)) err = md_cluster_ops->remove_disk (mddev, rdev);
@@ -3056,10 +3059,12 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len) }else if (cmd_match (buf,"writemostly" )) {set_bit (WriteMostly, &rdev->flags);mddev_create_serial_pool (rdev->mddev, rdev, false); + need_update_sb = true; err =0 ; }else if (cmd_match (buf,"-writemostly" )) {mddev_destroy_serial_pool (rdev->mddev, rdev, false);clear_bit (WriteMostly, &rdev->flags); + need_update_sb = true; err =0 ; }else if (cmd_match (buf,"blocked" )) {set_bit (Blocked, &rdev->flags);
@@ -3085,9 +3090,11 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len) err =0 ; }else if (cmd_match (buf,"failfast" )) {set_bit (FailFast, &rdev->flags); + need_update_sb = true; err =0 ; }else if (cmd_match (buf,"-failfast" )) {clear_bit (FailFast, &rdev->flags); + need_update_sb = true; err =0 ; }else if (cmd_match (buf,"-insync" ) && rdev->raid_disk >=0 && !test_bit (Journal, &rdev->flags)) {
@@ -3166,6 +3173,8 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)clear_bit (ExternalBbl, &rdev->flags); err =0 ; } +if (need_update_sb) +md_update_sb (mddev,1 );if (!err)sysfs_notify_dirent_safe (rdev->sysfs_state);return err ? err : len;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 221/575 memstick: r592: Fix a UAF bug when removing the driver
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 738216c1953e802aa9f930c5d15b8f9092c847ff ]
In r592_remove(), the driver will free dma after freeing the host, which may cause a UAF bug.
The following log reveals it:
[ 45.361796 ] BUG: KASAN: use-after-free in r592_remove+0x269/0x350 [r592] [ 45.364286 ] Call Trace: [ 45.364472 ] dump_stack_lvl+0xa8/0xd1 [ 45.364751 ] print_address_description+0x87/0x3b0 [ 45.365137 ] kasan_report+0x172/0x1c0 [ 45.365415 ] ? r592_remove+0x269/0x350 [r592] [ 45.365834 ] ? r592_remove+0x269/0x350 [r592] [ 45.366168 ] __asan_report_load8_noabort+0x14/0x20 [ 45.366531 ] r592_remove+0x269/0x350 [r592] [ 45.378785 ] [ 45.378903 ] Allocated by task 4674: [ 45.379162 ] ____kasan_kmalloc+0xb5/0xe0 [ 45.379455 ] __kasan_kmalloc+0x9/0x10 [ 45.379730 ] __kmalloc+0x150/0x280 [ 45.379984 ] memstick_alloc_host+0x2a/0x190 [ 45.380664 ] [ 45.380781 ] Freed by task 5509: [ 45.381014 ] kasan_set_track+0x3d/0x70 [ 45.381293 ] kasan_set_free_info+0x23/0x40 [ 45.381635 ] ____kasan_slab_free+0x10b/0x140 [ 45.381950 ] __kasan_slab_free+0x11/0x20 [ 45.382241 ] slab_free_freelist_hook+0x81/0x150 [ 45.382575 ] kfree+0x13e/0x290 [ 45.382805 ] memstick_free+0x1c/0x20 [ 45.383070 ] device_release+0x9c/0x1d0 [ 45.383349 ] kobject_put+0x2ef/0x4c0 [ 45.383616 ] put_device+0x1f/0x30 [ 45.383865 ] memstick_free_host+0x24/0x30 [ 45.384162 ] r592_remove+0x242/0x350 [r592] [ 45.384473 ] pci_device_remove+0xa9/0x250
--- drivers/memstick/host/r592.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/memstick/host/r592.c +4 -4
@@ -837,15 +837,15 @@ static void r592_remove(struct pci_dev *pdev) }memstick_remove_host (dev->host); +if (dev->dummy_dma_page) +dma_free_coherent (&pdev->dev,PAGE_SIZE , dev->dummy_dma_page, + dev->dummy_dma_page_physical_address); +free_irq (dev->irq, dev);iounmap (dev->mmio);pci_release_regions (pdev);pci_disable_device (pdev);memstick_free_host (dev->host); - -if (dev->dummy_dma_page) -dma_free_coherent (&pdev->dev,PAGE_SIZE , dev->dummy_dma_page, - dev->dummy_dma_page_physical_address); }#ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 222/575 lib/xz: Avoid overlapping memcpy() with invalid input with in-place decompression
In reply to Greg Kroah-HartmanFrom: Lasse Collin <[email protected]>
[ Upstream commit 83d3c4f22a36d005b55f44628f46cc0d319a75e8 ]
With valid files, the safety margin described in lib/decompress_unxz.c ensures that these buffers cannot overlap. But if the uncompressed size of the input is larger than the caller thought, which is possible when the input file is invalid/corrupt, the buffers can overlap. Obviously the result will then be garbage (and usually the decoder will return an error too) but no other harm will happen when such an over-run occurs.
This change only affects uncompressed LZMA2 chunks and so this should have no effect on performance.
--- lib/decompress_unxz.c | 2 +- lib/xz/xz_dec_lzma2.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-)
lib/decompress_unxz.c +1 -1
@@ -167,7 +167,7 @@* memeq and memzero are not used much and any remotely sane implementation * is fast enough. memcpy/memmove speed matters in multi-call mode, but * the kernel image is decompressed in single-call mode, in which only -* memcpy speed can matter and only if there is a lot of uncompressible data +* memmove speed can matter and only if there is a lot of uncompressible data * (LZMA2 stores uncompressible chunks in uncompressed form). Thus, the * functions below should just be kept small; it's probably not worth * optimizing for speed.
lib/xz/xz_dec_lzma2.c +19 -2
@@ -387,7 +387,14 @@ static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b, *left -= copy_size; -memcpy (dict->buf + dict->pos, b->in + b->in_pos, copy_size); +/* +* If doing in-place decompression in single-call mode and the +* uncompressed size of the file is larger than the caller +* thought (i.e. it is invalid input!), the buffers below may +* overlap and cause undefined behavior with memcpy(). +* With valid inputs memcpy() would be fine here. +*/ +memmove (dict->buf + dict->pos, b->in + b->in_pos, copy_size); dict->pos += copy_size;if (dict->full < dict->pos)
@@ -397,7 +404,11 @@ static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b,if (dict->pos == dict->end) dict->pos =0 ; -memcpy (b->out + b->out_pos, b->in + b->in_pos, +/* +* Like above but for multi-call mode: use memmove() +* to avoid undefined behavior with invalid input. +*/ +memmove (b->out + b->out_pos, b->in + b->in_pos, copy_size); }
@@ -421,6 +432,12 @@ static uint32_t dict_flush(struct dictionary *dict, struct xz_buf *b)if (dict->pos == dict->end) dict->pos =0 ; +/* +* These buffers cannot overlap even if doing in-place +* decompression because in multi-call mode dict->buf +* has been allocated by us in this file; it's not +* provided by the caller like in single-call mode. +*/ memcpy (b->out + b->out_pos, dict->buf + dict->start, copy_size); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 223/575 lib/xz: Validate the value before assigning it to an enum variable
In reply to Greg Kroah-HartmanFrom: Lasse Collin <[email protected]>
[ Upstream commit 4f8d7abaa413c34da9d751289849dbfb7c977d05 ]
This might matter, for example, if the underlying type of enum xz_check was a signed char. In such a case the validation wouldn't have caught an unsupported header. I don't know if this problem can occur in the kernel on any arch but it's still good to fix it because some people might copy the XZ code to their own projects from Linux instead of the upstream XZ Embedded repository.
This change may increase the code size by a few bytes. An alternative would have been to use an unsigned int instead of enum xz_check but using an enumeration looks cleaner.
--- lib/xz/xz_dec_stream.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/xz/xz_dec_stream.c +3 -3
@@ -402,12 +402,12 @@ static enum xz_ret dec_stream_header(struct xz_dec *s)* we will accept other check types too, but then the check won't * be verified and a warning (XZ_UNSUPPORTED_CHECK) will be given. */ +if (s->temp.buf[HEADER_MAGIC_SIZE +1 ] >XZ_CHECK_MAX ) +return XZ_OPTIONS_ERROR ; + s->check_type = s->temp.buf[HEADER_MAGIC_SIZE +1 ];#ifdef XZ_DEC_ANY_CHECK -if (s->check_type >XZ_CHECK_MAX ) -return XZ_OPTIONS_ERROR ; -if (s->check_type >XZ_CHECK_CRC32 )return XZ_UNSUPPORTED_CHECK ;#else
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 224/575 workqueue: make sysfs of unbound kworker cpumask more clever
In reply to Greg Kroah-HartmanFrom: Menglong Dong <[email protected]>
[ Upstream commit d25302e46592c97d29f70ccb1be558df31a9a360 ]
Some unfriendly component, such as dpdk, write the same mask to unbound kworker cpumask again and again. Every time it write to this interface some work is queue to cpu, even though the mask is same with the original mask.
So, fix it by return success and do nothing if the cpumask is equal with the old one.
--- kernel/workqueue.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
kernel/workqueue.c +11 -4
@@ -5326,9 +5326,6 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)int ret = -EINVAL ;cpumask_var_t saved_cpumask; -if (!zalloc_cpumask_var (&saved_cpumask,GFP_KERNEL )) -return -ENOMEM ; -/* * Not excluding isolated cpus on purpose. * If the user wishes to include them, we allow that.
@@ -5336,6 +5333,15 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)cpumask_and (cpumask, cpumask, cpu_possible_mask);if (!cpumask_empty (cpumask)) {apply_wqattrs_lock (); +if (cpumask_equal (cpumask, wq_unbound_cpumask)) { + ret =0 ; + goto out_unlock; + } + +if (!zalloc_cpumask_var (&saved_cpumask,GFP_KERNEL )) { + ret = -ENOMEM ; + goto out_unlock; + }/* save the old wq_unbound_cpumask. */ cpumask_copy (saved_cpumask, wq_unbound_cpumask);
@@ -5348,10 +5354,11 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)if (ret <0 )cpumask_copy (wq_unbound_cpumask, saved_cpumask); +free_cpumask_var (saved_cpumask); +out_unlock:apply_wqattrs_unlock (); } -free_cpumask_var (saved_cpumask);return ret; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 225/575 tracing/cfi: Fix cmp_entries_* functions signature mismatch
In reply to Greg Kroah-HartmanFrom: Kalesh Singh <[email protected]>
[ Upstream commit 7ce1bb83a14019f8c396d57ec704d19478747716 ]
If CONFIG_CFI_CLANG=y, attempting to read an event histogram will cause the kernel to panic due to failed CFI check.
1. echo 'hist:keys=common_pid' >> events/sched/sched_switch/trigger
2. cat events/sched/sched_switch/hist
3. kernel panics on attempting to read hist
This happens because the sort() function expects a generic int (*)(const void *, const void *) pointer for the compare function. To prevent this CFI failure, change tracing map cmp_entries_* function signatures to match this.
Also, fix the build error reported by the kernel test robot [1].
[1] https://lore.kernel.org/r/[email protected]/
--- kernel/trace/tracing_map.c | 40 ++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-)
kernel/trace/tracing_map.c +23 -17
@@ -834,29 +834,35 @@ int tracing_map_init(struct tracing_map *map)return err; } -static int cmp_entries_dup (const struct tracing_map_sort_entry **a, -const struct tracing_map_sort_entry **b) +static int cmp_entries_dup (const void *A ,const void *B ) { +const struct tracing_map_sort_entry *a, *b;int ret =0 ; -if (memcmp ((*a)->key, (*b)->key, (*a)->elt->map->key_size)) + a = *(const struct tracing_map_sort_entry **)A ; + b = *(const struct tracing_map_sort_entry **)B ; + +if (memcmp (a->key, b->key, a->elt->map->key_size)) ret =1 ;return ret; } -static int cmp_entries_sum (const struct tracing_map_sort_entry **a, -const struct tracing_map_sort_entry **b) +static int cmp_entries_sum (const void *A ,const void *B ) {const struct tracing_map_elt *elt_a, *elt_b; +const struct tracing_map_sort_entry *a, *b;struct tracing_map_sort_key *sort_key;struct tracing_map_field *field;tracing_map_cmp_fn_t cmp_fn;void *val_a, *val_b;int ret =0 ; - elt_a = (*a)->elt; - elt_b = (*b)->elt; + a = *(const struct tracing_map_sort_entry **)A ; + b = *(const struct tracing_map_sort_entry **)B ; + + elt_a = a->elt; + elt_b = b->elt; sort_key = &elt_a->map->sort_key;
@@ -873,18 +879,21 @@ static int cmp_entries_sum(const struct tracing_map_sort_entry **a,return ret; } -static int cmp_entries_key (const struct tracing_map_sort_entry **a, -const struct tracing_map_sort_entry **b) +static int cmp_entries_key (const void *A ,const void *B ) {const struct tracing_map_elt *elt_a, *elt_b; +const struct tracing_map_sort_entry *a, *b;struct tracing_map_sort_key *sort_key;struct tracing_map_field *field;tracing_map_cmp_fn_t cmp_fn;void *val_a, *val_b;int ret =0 ; - elt_a = (*a)->elt; - elt_b = (*b)->elt; + a = *(const struct tracing_map_sort_entry **)A ; + b = *(const struct tracing_map_sort_entry **)B ; + + elt_a = a->elt; + elt_b = b->elt; sort_key = &elt_a->map->sort_key;
@@ -989,10 +998,8 @@ static void sort_secondary(struct tracing_map *map, struct tracing_map_sort_key *primary_key, struct tracing_map_sort_key *secondary_key) { -int (*primary_fn)(const struct tracing_map_sort_entry **, -const struct tracing_map_sort_entry **); -int (*secondary_fn)(const struct tracing_map_sort_entry **, -const struct tracing_map_sort_entry **); +int (*primary_fn)(const void *,const void *); +int (*secondary_fn)(const void *,const void *);unsigned i, start =0 , n_sub =1 ;if (is_key (map, primary_key->field_idx))
@@ -1061,8 +1068,7 @@ int tracing_map_sort_entries(struct tracing_map *map, unsigned int n_sort_keys, struct tracing_map_sort_entry ***sort_entries) { -int (*cmp_entries_fn)(const struct tracing_map_sort_entry **, -const struct tracing_map_sort_entry **); +int (*cmp_entries_fn)(const void *,const void *);struct tracing_map_sort_entry *sort_entry, **entries;int i, n_entries, ret;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 226/575 mt76: mt7915: fix an off-by-one bound check
In reply to Greg Kroah-HartmanFrom: Ryder Lee <[email protected]>
[ Upstream commit d45dac0732a287fc371a23f257cce04e65627947 ]
The bounds check on datalen is off-by-one, so fix it.
--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +1 -1
@@ -830,7 +830,7 @@ static void mt7915_check_he_obss_narrow_bw_ru_iter(struct wiphy *wiphy, elem =ieee80211_bss_get_elem (bss,WLAN_EID_EXT_CAPABILITY ); -if (!elem || elem->datalen <10 || +if (!elem || elem->datalen <=10 || !(elem->data[10 ] &WLAN_EXT_CAPA10_OBSS_NARROW_BW_RU_TOLERANCE_SUPPORT )) data->tolerated = false;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 227/575 mwl8k: Fix use-after-free in mwl8k_fw_state_machine()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 257051a235c17e33782b6e24a4b17f2d7915aaec ]
When the driver fails to request the firmware, it calls its error handler. In the error handler, the driver detaches device from driver first before releasing the firmware, which can cause a use-after-free bug.
Fix this by releasing firmware first.
The following log reveals it:
[ 9.007301 ] BUG: KASAN: use-after-free in mwl8k_fw_state_machine+0x320/0xba0 [ 9.010143 ] Workqueue: events request_firmware_work_func [ 9.010830 ] Call Trace: [ 9.010830 ] dump_stack_lvl+0xa8/0xd1 [ 9.010830 ] print_address_description+0x87/0x3b0 [ 9.010830 ] kasan_report+0x172/0x1c0 [ 9.010830 ] ? mutex_unlock+0xd/0x10 [ 9.010830 ] ? mwl8k_fw_state_machine+0x320/0xba0 [ 9.010830 ] ? mwl8k_fw_state_machine+0x320/0xba0 [ 9.010830 ] __asan_report_load8_noabort+0x14/0x20 [ 9.010830 ] mwl8k_fw_state_machine+0x320/0xba0 [ 9.010830 ] ? mwl8k_load_firmware+0x5f0/0x5f0 [ 9.010830 ] request_firmware_work_func+0x172/0x250 [ 9.010830 ] ? read_lock_is_recursive+0x20/0x20 [ 9.010830 ] ? process_one_work+0x7a1/0x1100 [ 9.010830 ] ? request_firmware_nowait+0x460/0x460 [ 9.010830 ] ? __this_cpu_preempt_check+0x13/0x20 [ 9.010830 ] process_one_work+0x9bb/0x1100
--- drivers/net/wireless/marvell/mwl8k.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/marvell/mwl8k.c +1 -1
@@ -5796,8 +5796,8 @@ static void mwl8k_fw_state_machine(const struct firmware *fw, void *context) fail: priv->fw_state =FW_STATE_ERROR ;complete (&priv->firmware_loading_complete); -device_release_driver (&priv->pdev->dev);mwl8k_release_firmware (priv); +device_release_driver (&priv->pdev->dev); }#define MAX_RESTART_ATTEMPTS 1
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 228/575 block: remove inaccurate requeue check
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
[ Upstream commit 037057a5a979c7eeb2ee5d12cf4c24b805192c75 ]
This check is meant to catch cases where a requeue is attempted on a request that is still inserted. It's never really been useful to catch any misuse, and now it's actively wrong. Outside of that, this should not be a BUG_ON() to begin with.
Remove the check as it's now causing active harm, as requeue off the plug path will trigger it even though the request state is just fine.
--- block/blk-mq.c | 1 - 1 file changed, 1 deletion(-)
block/blk-mq.c +0 -1
@@ -774,7 +774,6 @@ void blk_mq_requeue_request(struct request *rq, bool kick_requeue_list)/* this request will be re-inserted to io scheduler queue */ blk_mq_sched_requeue_request (rq); -BUG_ON (!list_empty (&rq->queuelist));blk_mq_add_to_requeue_list (rq, true, kick_requeue_list); }EXPORT_SYMBOL (blk_mq_requeue_request);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 229/575 media: allegro: ignore interrupt if mailbox is not initialized
In reply to Greg Kroah-HartmanFrom: Michael Tretter <[email protected]>
[ Upstream commit 1ecda6393db4be44aba27a243e648dc98c9b92e3 ]
The mailbox is initialized after the interrupt handler is installed. As the firmware is loaded and started even later, it should not happen that the interrupt occurs without the mailbox being initialized.
As the Linux Driver Verification project (linuxtesting.org) keeps reporting this as an error, add a check to ignore interrupts before the mailbox is initialized to fix this potential null pointer dereference.
--- drivers/staging/media/allegro-dvt/allegro-core.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/staging/media/allegro-dvt/allegro-core.c +9 -0
@@ -1802,6 +1802,15 @@ static irqreturn_t allegro_irq_thread(int irq, void *data) {struct allegro_dev *dev = data; +/* +* The firmware is initialized after the mailbox is setup. We further +* check the AL5_ITC_CPU_IRQ_STA register, if the firmware actually +* triggered the interrupt. Although this should not happen, make sure +* that we ignore interrupts, if the mailbox is not initialized. +*/ +if (!dev->mbox_status) +return IRQ_NONE ; +allegro_mbox_notify (dev->mbox_status);return IRQ_HANDLED ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 230/575 nvmet: fix use-after-free when a port is removed
In reply to Greg Kroah-HartmanFrom: Israel Rukshin <[email protected]>
[ Upstream commit e3e19dcc4c416d65f99f13d55be2b787f8d0050e ]
When a port is removed through configfs, any connected controllers are starting teardown flow asynchronously and can still send commands. This causes a use-after-free bug for any command that dereferences req->port (like in nvmet_parse_io_cmd).
To fix this, wait for all the teardown scheduled works to complete (like release_work at rdma/tcp drivers). This ensures there are no active controllers when the port is eventually removed.
--- drivers/nvme/target/configfs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/target/configfs.c +2 -0
@@ -1462,6 +1462,8 @@ static void nvmet_port_release(struct config_item *item) {struct nvmet_port *port =to_nvmet_port (item); +/* Let inflight controllers teardown complete */ +flush_scheduled_work ();list_del (&port->global_entry);kfree (port->ana_state);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 231/575 nvmet-rdma: fix use-after-free when a port is removed
In reply to Greg Kroah-HartmanFrom: Israel Rukshin <[email protected]>
[ Upstream commit fcf73a804c7d6bbf0ea63531c6122aa363852e04 ]
When removing a port, all its controllers are being removed, but there are queues on the port that doesn't belong to any controller (during connection time). This causes a use-after-free bug for any command that dereferences req->port (like in nvmet_alloc_ctrl). Those queues should be destroyed before freeing the port via configfs. Destroy the remaining queues after the RDMA-CM was destroyed guarantees that no new queue will be created.
--- drivers/nvme/target/rdma.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/nvme/target/rdma.c +24 -0
@@ -1819,12 +1819,36 @@ restart:mutex_unlock (&nvmet_rdma_queue_mutex); } +static void nvmet_rdma_destroy_port_queues (struct nvmet_rdma_port *port) +{ +struct nvmet_rdma_queue *queue, *tmp; +struct nvmet_port *nport = port->nport; + +mutex_lock (&nvmet_rdma_queue_mutex); +list_for_each_entry_safe (queue, tmp, &nvmet_rdma_queue_list, + queue_list) { +if (queue->port != nport) +continue ; + +list_del_init (&queue->queue_list); +__nvmet_rdma_queue_disconnect (queue); + } +mutex_unlock (&nvmet_rdma_queue_mutex); +} +static void nvmet_rdma_disable_port (struct nvmet_rdma_port *port) {struct rdma_cm_id *cm_id =xchg (&port->cm_id,NULL );if (cm_id)rdma_destroy_id (cm_id); + +/* +* Destroy the remaining queues, which are not belong to any +* controller yet. Do it here after the RDMA-CM was destroyed +* guarantees that no new queue will be created. +*/ +nvmet_rdma_destroy_port_queues (port); }static int nvmet_rdma_enable_port (struct nvmet_rdma_port *port)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 232/575 nvmet-tcp: fix use-after-free when a port is removed
In reply to Greg Kroah-HartmanFrom: Israel Rukshin <[email protected]>
[ Upstream commit 2351ead99ce9164fb42555aee3f96af84c4839e9 ]
When removing a port, all its controllers are being removed, but there are queues on the port that doesn't belong to any controller (during connection time). This causes a use-after-free bug for any command that dereferences req->port (like in nvmet_alloc_ctrl). Those queues should be destroyed before freeing the port via configfs. Destroy the remaining queues after the accept_work was cancelled guarantees that no new queue will be created.
--- drivers/nvme/target/tcp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/nvme/target/tcp.c +16 -0
@@ -1708,6 +1708,17 @@ err_port:return ret; } +static void nvmet_tcp_destroy_port_queues (struct nvmet_tcp_port *port) +{ +struct nvmet_tcp_queue *queue; + +mutex_lock (&nvmet_tcp_queue_mutex); +list_for_each_entry (queue, &nvmet_tcp_queue_list, queue_list) +if (queue->port == port) +kernel_sock_shutdown (queue->sock,SHUT_RDWR ); +mutex_unlock (&nvmet_tcp_queue_mutex); +} +static void nvmet_tcp_remove_port (struct nvmet_port *nport) {struct nvmet_tcp_port *port = nport->priv;
@@ -1717,6 +1728,11 @@ static void nvmet_tcp_remove_port(struct nvmet_port *nport) port->sock->sk->sk_user_data =NULL ;write_unlock_bh (&port->sock->sk->sk_callback_lock);cancel_work_sync (&port->accept_work); +/* +* Destroy the remaining queues, which are not belong to any +* controller yet. +*/ +nvmet_tcp_destroy_port_queues (port);sock_release (port->sock);kfree (port);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 233/575 nvme: drop scan_lock and always kick requeue list when removing namespaces
In reply to Greg Kroah-HartmanFrom: Hannes Reinecke <[email protected]>
[ Upstream commit 2b81a5f015199f3d585ce710190a9e87714d3c1e ]
When reading the partition table on initial scan hits an I/O error the I/O will hang with the scan_mutex held:
[<0>] do_read_cache_page+0x49b/0x790 [<0>] read_part_sector+0x39/0xe0 [<0>] read_lba+0xf9/0x1d0 [<0>] efi_partition+0xf1/0x7f0 [<0>] bdev_disk_changed+0x1ee/0x550 [<0>] blkdev_get_whole+0x81/0x90 [<0>] blkdev_get_by_dev+0x128/0x2e0 [<0>] device_add_disk+0x377/0x3c0 [<0>] nvme_mpath_set_live+0x130/0x1b0 [nvme_core] [<0>] nvme_mpath_add_disk+0x150/0x160 [nvme_core] [<0>] nvme_alloc_ns+0x417/0x950 [nvme_core] [<0>] nvme_validate_or_alloc_ns+0xe9/0x1e0 [nvme_core] [<0>] nvme_scan_work+0x168/0x310 [nvme_core] [<0>] process_one_work+0x231/0x420
and trying to delete the controller will deadlock as it tries to grab the scan mutex:
[<0>] nvme_mpath_clear_ctrl_paths+0x25/0x80 [nvme_core] [<0>] nvme_remove_namespaces+0x31/0xf0 [nvme_core] [<0>] nvme_do_delete_ctrl+0x4b/0x80 [nvme_core]
As we're now properly ordering the namespace list there is no need to hold the scan_mutex in nvme_mpath_clear_ctrl_paths() anymore. And we always need to kick the requeue list as the path will be marked as unusable and I/O will be requeued _without_ a current path.
--- drivers/nvme/host/multipath.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/nvme/host/multipath.c +4 -5
@@ -135,13 +135,12 @@ void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl) {struct nvme_ns *ns; -mutex_lock (&ctrl->scan_lock);down_read (&ctrl->namespaces_rwsem); -list_for_each_entry (ns, &ctrl->namespaces, list) -if (nvme_mpath_clear_current_path (ns)) -kblockd_schedule_work (&ns->head->requeue_work); +list_for_each_entry (ns, &ctrl->namespaces, list) { +nvme_mpath_clear_current_path (ns); +kblockd_schedule_work (&ns->head->requeue_work); + }up_read (&ctrl->namespaces_rwsem); -mutex_unlock (&ctrl->scan_lock); }static bool nvme_path_is_disabled (struct nvme_ns *ns)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 234/575 PM: hibernate: Get block device exclusively in swsusp_check()
In reply to Greg Kroah-HartmanFrom: Ye Bin <[email protected]>
[ Upstream commit 39fbef4b0f77f9c89c8f014749ca533643a37c9f ]
The following kernel crash can be triggered:
[ 89.266592] ------------[ cut here ]------------ [ 89.267427] kernel BUG at fs/buffer.c:3020! [ 89.268264] invalid opcode: 0000 [#1] SMP KASAN PTI [ 89.269116] CPU: 7 PID: 1750 Comm: kmmpd-loop0 Not tainted 5.10.0-862.14.0.6.x86_64-08610-gc932cda3cef4-dirty #20 [ 89.273169] RIP: 0010:submit_bh_wbc.isra.0+0x538/0x6d0 [ 89.277157] RSP: 0018:ffff888105ddfd08 EFLAGS: 00010246 [ 89.278093] RAX: 0000000000000005 RBX: ffff888124231498 RCX: ffffffffb2772612 [ 89.279332] RDX: 1ffff11024846293 RSI: 0000000000000008 RDI: ffff888124231498 [ 89.280591] RBP: ffff8881248cc000 R08: 0000000000000001 R09: ffffed1024846294 [ 89.281851] R10: ffff88812423149f R11: ffffed1024846293 R12: 0000000000003800 [ 89.283095] R13: 0000000000000001 R14: 0000000000000000 R15: ffff8881161f7000 [ 89.284342] FS: 0000000000000000(0000) GS:ffff88839b5c0000(0000) knlGS:0000000000000000 [ 89.285711] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 89.286701] CR2: 00007f166ebc01a0 CR3: 0000000435c0e000 CR4: 00000000000006e0 [ 89.287919] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 89.289138] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 89.290368] Call Trace: [ 89.290842] write_mmp_block+0x2ca/0x510 [ 89.292218] kmmpd+0x433/0x9a0 [ 89.294902] kthread+0x2dd/0x3e0 [ 89.296268] ret_from_fork+0x22/0x30 [ 89.296906] Modules linked in:
by running the following commands:
1. mkfs.ext4 -O mmp /dev/sda -b 1024
2. mount /dev/sda /home/test
3. echo "/dev/sda" > /sys/power/resume
That happens because swsusp_check() calls set_blocksize() on the target partition which confuses the file system:
Thread1 Thread2
mount /dev/sda /home/test
get s_mmp_bh --> has mapped flag
start kmmpd thread
echo "/dev/sda" > /sys/power/resume
resume_store
software_resume
swsusp_check
set_blocksize
truncate_inode_pages_range
truncate_cleanup_page
block_invalidatepage
discard_buffer --> clean mapped flag
write_mmp_block
submit_bh
submit_bh_wbc
BUG_ON(!buffer_mapped(bh))To address this issue, modify swsusp_check() to open the target block device with exclusive access.
--- kernel/power/swap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/power/swap.c +3 -2
@@ -1521,9 +1521,10 @@ end:int swsusp_check (void ) {int error; +void *holder; hib_resume_bdev =blkdev_get_by_dev (swsusp_resume_device, -FMODE_READ ,NULL ); +FMODE_READ |FMODE_EXCL , &holder);if (!IS_ERR (hib_resume_bdev)) {set_blocksize (hib_resume_bdev,PAGE_SIZE );clear_page (swsusp_header);
@@ -1545,7 +1546,7 @@ int swsusp_check(void) put:if (error) -blkdev_put (hib_resume_bdev,FMODE_READ ); +blkdev_put (hib_resume_bdev,FMODE_READ |FMODE_EXCL );else pr_debug ("Image signature found, resuming\n" ); }else {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 235/575 selftests: kvm: fix mismatched fclose() after popen()
In reply to Greg Kroah-HartmanFrom: Shuah Khan <[email protected]>
[ Upstream commit c3867ab5924b7a9a0b4a117902a08669d8be7c21 ]
get_warnings_count() does fclose() using File * returned from popen(). Fix it to call pclose() as it should.
tools/testing/selftests/kvm/x86_64/mmio_warning_testx86_64/mmio_warning_test.c: In function ‘get_warnings_count’:x86_64/mmio_warning_test.c:87:9: warning: ‘fclose’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
87 | fclose(f);
| ^~~~~~~~~
x86_64/mmio_warning_test.c:84:13: note: returned from ‘popen’
84 | f = popen("dmesg | grep \"WARNING:\" | wc -l", "r");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--- tools/testing/selftests/kvm/x86_64/mmio_warning_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/x86_64/mmio_warning_test.c +1 -1
@@ -84,7 +84,7 @@ int get_warnings_count(void) f =popen ("dmesg | grep \"WARNING:\" | wc -l" ,"r" );if (fscanf (f,"%d" , &warnings) <1 ) warnings =0 ; -fclose (f); +pclose (f);return warnings; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 236/575 selftests/bpf: Fix perf_buffer test on system with offline cpus
In reply to Greg Kroah-HartmanFrom: Jiri Olsa <[email protected]>
[ Upstream commit d4121376ac7a9c81a696d7558789b2f29ef3574e ]
The perf_buffer fails on system with offline cpus:
# test_progs -t perf_buffer test_perf_buffer:PASS:nr_cpus 0 nsec test_perf_buffer:PASS:nr_on_cpus 0 nsec test_perf_buffer:PASS:skel_load 0 nsec test_perf_buffer:PASS:attach_kprobe 0 nsec test_perf_buffer:PASS:perf_buf__new 0 nsec test_perf_buffer:PASS:epoll_fd 0 nsec skipping offline CPU #24 skipping offline CPU #25 skipping offline CPU #26 skipping offline CPU #27 skipping offline CPU #28 skipping offline CPU #29 skipping offline CPU #30 skipping offline CPU #31 test_perf_buffer:PASS:perf_buffer__poll 0 nsec test_perf_buffer:PASS:seen_cpu_cnt 0 nsec test_perf_buffer:FAIL:buf_cnt got 24, expected 32 Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED
Changing the test to check online cpus instead of possible.
--- tools/testing/selftests/bpf/prog_tests/perf_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/perf_buffer.c +2 -2
@@ -107,8 +107,8 @@ void test_perf_buffer(void) "expect %d, seen %d\n", nr_on_cpus, CPU_COUNT(&cpu_seen))) goto out_free_pb; -if (CHECK (perf_buffer__buffer_cnt (pb) != nr_cpus,"buf_cnt" , -"got %zu, expected %d\n" ,perf_buffer__buffer_cnt (pb), nr_cpus)) +if (CHECK (perf_buffer__buffer_cnt (pb) != nr_on_cpus,"buf_cnt" , +"got %zu, expected %d\n" ,perf_buffer__buffer_cnt (pb), nr_on_cpus)) goto out_close;for (i =0 ; i < nr_cpus; i++) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 237/575 iwlwifi: mvm: disable RX-diversity in powersave
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit e5322b9ab5f63536c41301150b7ce64605ce52cc ]
Just like we have default SMPS mode as dynamic in powersave, we should not enable RX-diversity in powersave, to reduce power consumption when connected to a non-MIMO AP.
--- drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/utils.c +3 -0
@@ -741,6 +741,9 @@ bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm)lockdep_assert_held (&mvm->mutex); +if (iwlmvm_mod_params.power_scheme !=IWL_POWER_SCHEME_CAM ) +return false; +if (num_of_ant (iwl_mvm_get_valid_rx_ant (mvm)) ==1 )return false;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 238/575 smackfs: use __GFP_NOFAIL for smk_cipso_doi()
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
[ Upstream commit f91488ee15bd3cac467e2d6a361fc2d34d1052ae ]
syzbot is reporting kernel panic at smk_cipso_doi() due to memory allocation fault injection [1]. The reason for need to use panic() was not explained. But since no fix was proposed for 18 months, for now let's use __GFP_NOFAIL for utilizing syzbot resource on other bugs.
--- security/smack/smackfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
security/smack/smackfs.c +1 -3
@@ -693,9 +693,7 @@ static void smk_cipso_doi(void)printk (KERN_WARNING "%s:%d remove rc = %d\n" , __func__, __LINE__, rc); - doip =kmalloc (sizeof (struct cipso_v4_doi ),GFP_KERNEL ); -if (doip ==NULL ) -panic ("smack: Failed to initialize cipso DOI.\n" ); + doip =kmalloc (sizeof (struct cipso_v4_doi ),GFP_KERNEL | __GFP_NOFAIL); doip->map.std =NULL ; doip->doi = smk_cipso_doi_value; doip->type =CIPSO_V4_MAP_PASS ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 239/575 ARM: clang: Do not rely on lr register for stacktrace
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit b3ea5d56f212ad81328c82454829a736197ebccc ]
Currently the stacktrace on clang compiled arm kernel uses the 'lr' register to find the first frame address from pt_regs. However, that is wrong after calling another function, because the 'lr' register is used by 'bl' instruction and never be recovered.
As same as gcc arm kernel, directly use the frame pointer (r11) of the pt_regs to find the first frame address.
Note that this fixes kretprobe stacktrace issue only with CONFIG_UNWINDER_FRAME_POINTER=y. For the CONFIG_UNWINDER_ARM, we need another fix.
--- arch/arm/kernel/stacktrace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/kernel/stacktrace.c +1 -2
@@ -54,8 +54,7 @@ int notrace unwind_frame(struct stackframe *frame) frame->sp = frame->fp; frame->fp = *(unsigned long *)(fp); - frame->pc = frame->lr; - frame->lr = *(unsigned long *)(fp +4 ); + frame->pc = *(unsigned long *)(fp +4 );#else /* check current frame pointer is within bounds */ if (fp < low +12 || fp > high -4 )
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 240/575 gre/sit: Dont generate link-local addr if addr_gen_mode is IN6_ADDR_GEN_MODE_NONE
In reply to Greg Kroah-HartmanFrom: Stephen Suryaputra <[email protected]>
[ Upstream commit 61e18ce7348bfefb5688a8bcd4b4d6b37c0f9b2a ]
When addr_gen_mode is set to IN6_ADDR_GEN_MODE_NONE, the link-local addr should not be generated. But it isn't the case for GRE (as well as GRE6) and SIT tunnels. Make it so that tunnels consider the addr_gen_mode, especially for IN6_ADDR_GEN_MODE_NONE.
Do this in add_v4_addrs() to cover both GRE and SIT only if the addr scope is link.
--- net/ipv6/addrconf.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/addrconf.c +3 -0
@@ -3097,6 +3097,9 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)memcpy (&addr.s6_addr32[3 ], idev->dev->dev_addr,4 );if (idev->dev->flags&IFF_POINTOPOINT ) { +if (idev->cnf.addr_gen_mode ==IN6_ADDR_GEN_MODE_NONE ) +return ; + addr.s6_addr32[0 ] =htonl (0xfe800000 ); scope =IFA_LINK ; plen =64 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 241/575 net: dsa: lantiq_gswip: serialize access to the PCE table
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 49753a75b9a32de4c0393bb8d1e51ea223fda8e4 ]
Looking at the code, the GSWIP switch appears to hold bridging service structures (VLANs, FDBs, forwarding rules) in PCE table entries. Hardware access to the PCE table is non-atomic, and is comprised of several register reads and writes.
These accesses are currently serialized by the rtnl_lock, but DSA is changing its driver API and that lock will no longer be held when calling ->port_fdb_add() and ->port_fdb_del().
So this driver needs to serialize the access to the PCE table using its own locking scheme. This patch adds that.
--- drivers/net/dsa/lantiq_gswip.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
drivers/net/dsa/lantiq_gswip.c +23 -5
@@ -274,6 +274,7 @@ struct gswip_priv {int num_gphy_fw;struct gswip_gphy_fw *gphy_fw;u32 port_vlan_filter; +struct mutex pce_table_lock; };struct gswip_pce_table_entry {
@@ -521,10 +522,14 @@ static int gswip_pce_table_entry_read(struct gswip_priv *priv,u16 addr_mode = tbl->key_mode ?GSWIP_PCE_TBL_CTRL_OPMOD_KSRD :GSWIP_PCE_TBL_CTRL_OPMOD_ADRD ; +mutex_lock (&priv->pce_table_lock); + err =gswip_switch_r_timeout (priv,GSWIP_PCE_TBL_CTRL ,GSWIP_PCE_TBL_CTRL_BAS ); -if (err) +if (err) { +mutex_unlock (&priv->pce_table_lock);return err; + }gswip_switch_w (priv, tbl->index,GSWIP_PCE_TBL_ADDR ); gswip_switch_mask(priv, GSWIP_PCE_TBL_CTRL_ADDR_MASK |
@@ -534,8 +539,10 @@ static int gswip_pce_table_entry_read(struct gswip_priv *priv, err =gswip_switch_r_timeout (priv,GSWIP_PCE_TBL_CTRL ,GSWIP_PCE_TBL_CTRL_BAS ); -if (err) +if (err) { +mutex_unlock (&priv->pce_table_lock);return err; + }for (i =0 ; i <ARRAY_SIZE (tbl->key); i++) tbl->key[i] =gswip_switch_r (priv,GSWIP_PCE_TBL_KEY (i));
@@ -551,6 +558,8 @@ static int gswip_pce_table_entry_read(struct gswip_priv *priv, tbl->valid = !!(crtl &GSWIP_PCE_TBL_CTRL_VLD ); tbl->gmap = (crtl &GSWIP_PCE_TBL_CTRL_GMAP_MASK ) >>7 ; +mutex_unlock (&priv->pce_table_lock); +return 0 ; }
@@ -563,10 +572,14 @@ static int gswip_pce_table_entry_write(struct gswip_priv *priv,u16 addr_mode = tbl->key_mode ?GSWIP_PCE_TBL_CTRL_OPMOD_KSWR :GSWIP_PCE_TBL_CTRL_OPMOD_ADWR ; +mutex_lock (&priv->pce_table_lock); + err =gswip_switch_r_timeout (priv,GSWIP_PCE_TBL_CTRL ,GSWIP_PCE_TBL_CTRL_BAS ); -if (err) +if (err) { +mutex_unlock (&priv->pce_table_lock);return err; + }gswip_switch_w (priv, tbl->index,GSWIP_PCE_TBL_ADDR ); gswip_switch_mask(priv, GSWIP_PCE_TBL_CTRL_ADDR_MASK |
@@ -598,8 +611,12 @@ static int gswip_pce_table_entry_write(struct gswip_priv *priv, crtl |=GSWIP_PCE_TBL_CTRL_BAS ;gswip_switch_w (priv, crtl,GSWIP_PCE_TBL_CTRL ); -return gswip_switch_r_timeout (priv,GSWIP_PCE_TBL_CTRL , -GSWIP_PCE_TBL_CTRL_BAS ); + err =gswip_switch_r_timeout (priv,GSWIP_PCE_TBL_CTRL , +GSWIP_PCE_TBL_CTRL_BAS ); + +mutex_unlock (&priv->pce_table_lock); + +return err; }/* Add the LAN port into a bridge with the CPU port by
@@ -2040,6 +2057,7 @@ static int gswip_probe(struct platform_device *pdev) priv->ds->priv = priv; priv->ds->ops = &gswip_switch_ops; priv->dev = dev; +mutex_init (&priv->pce_table_lock); version =gswip_switch_r (priv,GSWIP_VERSION );/* bring up the mdio bus */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 242/575 gfs2: Cancel remote delete work asynchronously
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
[ Upstream commit 486408d690e130c3adacf816754b97558d715f46 ]
In gfs2_inode_lookup and gfs2_create_inode, we're calling gfs2_cancel_delete_work which currently cancels any remote delete work (delete_work_func) synchronously. This means that if the work is currently running, it will wait for it to finish. We're doing this to pevent a previous instance of an inode from having any influence on the next instance.
However, delete_work_func uses gfs2_inode_lookup internally, and we can end up in a deadlock when delete_work_func gets interrupted at the wrong time. For example,
(1) An inode's iopen glock has delete work queued, but the inode itself has been evicted from the inode cache.
(2) The delete work is preempted before reaching gfs2_inode_lookup.
(3) Another process recreates the inode (gfs2_create_inode). It tries to cancel any outstanding delete work, which blocks waiting for the ongoing delete work to finish.
(4) The delete work calls gfs2_inode_lookup, which blocks waiting for gfs2_create_inode to instantiate and unlock the new inode => deadlock.
It turns out that when the delete work notices that its inode has been re-instantiated, it will do nothing. This means that it's safe to cancel the delete work asynchronously. This prevents the kind of deadlock described above.
--- fs/gfs2/glock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/glock.c +1 -1
@@ -1911,7 +1911,7 @@ bool gfs2_queue_delete_work(struct gfs2_glock *gl, unsigned long delay)void gfs2_cancel_delete_work (struct gfs2_glock *gl) { -if (cancel_delayed_work_sync (&gl->gl_delete)) { +if (cancel_delayed_work (&gl->gl_delete)) {clear_bit (GLF_PENDING_DELETE , &gl->gl_flags);gfs2_glock_put (gl); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 243/575 gfs2: Fix glock_hash_walk bugs
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
[ Upstream commit 7427f3bb49d81525b7dd1d0f7c5f6bbc752e6f0e ]
So far, glock_hash_walk took a reference on each glock it iterated over, and it was the examiner's responsibility to drop those references. Dropping the final reference to a glock can sleep and the examiners are called in a RCU critical section with spin locks held, so examiners that didn't need the extra reference had to drop it asynchronously via gfs2_glock_queue_put or similar. This wasn't done correctly in thaw_glock which did call gfs2_glock_put, and not at all in dump_glock_func.
Change glock_hash_walk to not take glock references at all. That way, the examiners that don't need them won't have to bother with slow asynchronous puts, and the examiners that do need references can take them themselves.
--- fs/gfs2/glock.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
fs/gfs2/glock.c +12 -10
@@ -1885,10 +1885,10 @@ static void glock_hash_walk(glock_examiner examiner, const struct gfs2_sbd *sdp)do {rhashtable_walk_start (&iter); -while ((gl =rhashtable_walk_next (&iter)) && !IS_ERR (gl)) -if (gl->gl_name.ln_sbd == sdp && -lockref_get_not_dead (&gl->gl_lockref)) +while ((gl =rhashtable_walk_next (&iter)) && !IS_ERR (gl)) { +if (gl->gl_name.ln_sbd == sdp)examiner (gl); + }rhashtable_walk_stop (&iter); }while (cond_resched (), gl ==ERR_PTR (-EAGAIN ));
@@ -1930,7 +1930,6 @@ static void flush_delete_work(struct gfs2_glock *gl) &gl->gl_delete, 0); } } -gfs2_glock_queue_work (gl,0 ); }void gfs2_flush_delete_work (struct gfs2_sbd *sdp)
@@ -1947,10 +1946,10 @@ void gfs2_flush_delete_work(struct gfs2_sbd *sdp)static void thaw_glock (struct gfs2_glock *gl) { -if (!test_and_clear_bit (GLF_FROZEN , &gl->gl_flags)) { -gfs2_glock_put (gl); +if (!test_and_clear_bit (GLF_FROZEN , &gl->gl_flags)) +return ; +if (!lockref_get_not_dead (&gl->gl_lockref))return ; - }set_bit (GLF_REPLY_PENDING , &gl->gl_flags);gfs2_glock_queue_work (gl,0 ); }
@@ -1966,9 +1965,12 @@ static void clear_glock(struct gfs2_glock *gl)gfs2_glock_remove_from_lru (gl);spin_lock (&gl->gl_lockref.lock); -if (gl->gl_state !=LM_ST_UNLOCKED ) -handle_callback (gl,LM_ST_UNLOCKED ,0 , false); -__gfs2_glock_queue_work (gl,0 ); +if (!__lockref_is_dead (&gl->gl_lockref)) { + gl->gl_lockref.count++; +if (gl->gl_state !=LM_ST_UNLOCKED ) +handle_callback (gl,LM_ST_UNLOCKED ,0 , false); +__gfs2_glock_queue_work (gl,0 ); + }spin_unlock (&gl->gl_lockref.lock); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 244/575 ARM: 9136/1: ARMv7-M uses BE-8, not BE-32
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 345dac33f58894a56d17b92a41be10e16585ceff ]
When configuring the kernel for big-endian, we set either BE-8 or BE-32 based on the CPU architecture level. Until linux-4.4, we did not have any ARMv7-M platform allowing big-endian builds, but now i.MX/Vybrid is in that category, adn we get a build error because of this:
arch/arm/kernel/module-plts.c: In function 'get_module_plt':arch/arm/kernel/module-plts.c:60:46: error: implicit declaration of function '__opcode_to_mem_thumb32' [-Werror=implicit-function-declaration]
This comes down to picking the wrong default, ARMv7-M uses BE8 like ARMv7-A does. Changing the default gets the kernel to compile and presumably works.
https://lore.kernel.org/all/[email protected]/
--- arch/arm/mm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mm/Kconfig +1 -1
@@ -753,7 +753,7 @@ config CPU_BIG_ENDIAN config CPU_ENDIAN_BE8 bool depends on CPU_BIG_ENDIAN - default CPU_V6 || CPU_V6K || CPU_V7 + default CPU_V6 || CPU_V6K || CPU_V7 || CPU_V7M help Support for the BE-8 (big-endian) mode on ARMv6 and ARMv7 processors.
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 245/575 vrf: run conntrack only in context of lower/physdev for locally generated packets
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit 8c9c296adfae9ea05f655d69e9f6e13daa86fb4a ]
The VRF driver invokes netfilter for output+postrouting hooks so that users can create rules that check for 'oif $vrf' rather than lower device name.
This is a problem when NAT rules are configured.
To avoid any conntrack involvement in round 1, tag skbs as 'untracked' to prevent conntrack from picking them up.
This gets cleared before the packet gets handed to the ip stack so conntrack will be active on the second iteration.
One remaining issue is that a rule like
output ... oif $vrfname notrack
won't propagate to the second round because we can't tell 'notrack set via ruleset' and 'notrack set by vrf driver' apart. However, this isn't a regression: the 'notrack' removal happens instead of unconditional nf_reset_ct().
I'd also like to avoid leaking more vrf specific conditionals into the netfilter infra.
For ingress, conntrack has already been done before the packet makes it to the vrf driver, with this patch egress does connection tracking with lower/physical device as well.
--- drivers/net/vrf.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)
drivers/net/vrf.c +24 -4
@@ -34,6 +34,7 @@#include <net/l3mdev.h> #include <net/fib_rules.h> #include <net/netns/generic.h> +#include <net/netfilter/nf_conntrack.h> #define DRV_NAME "vrf"#define DRV_VERSION "1.1"
@@ -423,12 +424,26 @@ static int vrf_local_xmit(struct sk_buff *skb, struct net_device *dev,return NETDEV_TX_OK ; } +static void vrf_nf_set_untracked (struct sk_buff *skb) +{ +if (skb_get_nfct (skb) ==0 ) +nf_ct_set (skb,NULL ,IP_CT_UNTRACKED ); +} + +static void vrf_nf_reset_ct (struct sk_buff *skb) +{ +if (skb_get_nfct (skb) ==IP_CT_UNTRACKED ) +nf_reset_ct (skb); +} +#if IS_ENABLED (CONFIG_IPV6 )static int vrf_ip6_local_out (struct net *net,struct sock *sk,struct sk_buff *skb) {int err; +vrf_nf_reset_ct (skb); + err =nf_hook (NFPROTO_IPV6 ,NF_INET_LOCAL_OUT , net, sk, skb,NULL ,skb_dst (skb)->dev, dst_output);
@@ -508,6 +523,8 @@ static int vrf_ip_local_out(struct net *net, struct sock *sk, {int err; +vrf_nf_reset_ct (skb); + err =nf_hook (NFPROTO_IPV4 ,NF_INET_LOCAL_OUT , net, sk, skb,NULL ,skb_dst (skb)->dev, dst_output);if (likely (err ==1 ))
@@ -627,8 +644,7 @@ static void vrf_finish_direct(struct sk_buff *skb)skb_pull (skb,ETH_HLEN ); } -/* reset skb device */ -nf_reset_ct (skb); +vrf_nf_reset_ct (skb); }#if IS_ENABLED (CONFIG_IPV6 )
@@ -642,7 +658,7 @@ static int vrf_finish_output6(struct net *net, struct sock *sk,struct neighbour *neigh;int ret; -nf_reset_ct (skb); +vrf_nf_reset_ct (skb); skb->protocol =htons (ETH_P_IPV6 ); skb->dev = dev;
@@ -753,6 +769,8 @@ static struct sk_buff *vrf_ip6_out_direct(struct net_device *vrf_dev, skb->dev = vrf_dev; +vrf_nf_set_untracked (skb); + err =nf_hook (NFPROTO_IPV6 ,NF_INET_LOCAL_OUT , net, sk, skb,NULL , vrf_dev, vrf_ip6_out_direct_finish);
@@ -860,7 +878,7 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *sbool is_v6gw = false;int ret = -EINVAL ; -nf_reset_ct (skb); +vrf_nf_reset_ct (skb);/* Be paranoid, rather than too clever. */ if (unlikely (skb_headroom (skb) < hh_len && dev->header_ops)) {
@@ -988,6 +1006,8 @@ static struct sk_buff *vrf_ip_out_direct(struct net_device *vrf_dev, skb->dev = vrf_dev; +vrf_nf_set_untracked (skb); + err =nf_hook (NFPROTO_IPV4 ,NF_INET_LOCAL_OUT , net, sk, skb,NULL , vrf_dev, vrf_ip_out_direct_finish);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 246/575 net: annotate data-race in neigh_output()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit d18785e213866935b4c3dc0c33c3e18801ce0ce8 ]
neigh_output() reads n->nud_state and hh->hh_len locklessly.
This is fine, but we need to add annotations and document this.
We evaluate skip_cache first to avoid reading these fields if the cache has to by bypassed.
syzbot report:
BUG: KCSAN: data-race in __neigh_event_send / ip_finish_output2
write to 0xffff88810798a885 of 1 bytes by interrupt on cpu 1:
__neigh_event_send+0x40d/0xac0 net/core/neighbour.c:1128 neigh_event_send include/net/neighbour.h:444 [inline] neigh_resolve_output+0x104/0x410 net/core/neighbour.c:1476 neigh_output include/net/neighbour.h:510 [inline] ip_finish_output2+0x80a/0xaa0 net/ipv4/ip_output.c:221 ip_finish_output+0x3b5/0x510 net/ipv4/ip_output.c:309 NF_HOOK_COND include/linux/netfilter.h:296 [inline] ip_output+0xf3/0x1a0 net/ipv4/ip_output.c:423 dst_output include/net/dst.h:450 [inline] ip_local_out+0x164/0x220 net/ipv4/ip_output.c:126 __ip_queue_xmit+0x9d3/0xa20 net/ipv4/ip_output.c:525 ip_queue_xmit+0x34/0x40 net/ipv4/ip_output.c:539 __tcp_transmit_skb+0x142a/0x1a00 net/ipv4/tcp_output.c:1405 tcp_transmit_skb net/ipv4/tcp_output.c:1423 [inline] tcp_xmit_probe_skb net/ipv4/tcp_output.c:4011 [inline] tcp_write_wakeup+0x4a9/0x810 net/ipv4/tcp_output.c:4064 tcp_send_probe0+0x2c/0x2b0 net/ipv4/tcp_output.c:4079 tcp_probe_timer net/ipv4/tcp_timer.c:398 [inline] tcp_write_timer_handler+0x394/0x520 net/ipv4/tcp_timer.c:626 tcp_write_timer+0xb9/0x180 net/ipv4/tcp_timer.c:642 call_timer_fn+0x2e/0x1d0 kernel/time/timer.c:1421 expire_timers+0x135/0x240 kernel/time/timer.c:1466 __run_timers+0x368/0x430 kernel/time/timer.c:1734 run_timer_softirq+0x19/0x30 kernel/time/timer.c:1747 __do_softirq+0x12c/0x26e kernel/softirq.c:558 invoke_softirq kernel/softirq.c:432 [inline] __irq_exit_rcu kernel/softirq.c:636 [inline] irq_exit_rcu+0x4e/0xa0 kernel/softirq.c:648 sysvec_apic_timer_interrupt+0x69/0x80 arch/x86/kernel/apic/apic.c:1097 asm_sysvec_apic_timer_interrupt+0x12/0x20 native_safe_halt arch/x86/include/asm/irqflags.h:51 [inline] arch_safe_halt arch/x86/include/asm/irqflags.h:89 [inline] acpi_safe_halt drivers/acpi/processor_idle.c:109 [inline] acpi_idle_do_entry drivers/acpi/processor_idle.c:553 [inline] acpi_idle_enter+0x258/0x2e0 drivers/acpi/processor_idle.c:688 cpuidle_enter_state+0x2b4/0x760 drivers/cpuidle/cpuidle.c:237 cpuidle_enter+0x3c/0x60 drivers/cpuidle/cpuidle.c:351 call_cpuidle kernel/sched/idle.c:158 [inline] cpuidle_idle_call kernel/sched/idle.c:239 [inline] do_idle+0x1a3/0x250 kernel/sched/idle.c:306 cpu_startup_entry+0x15/0x20 kernel/sched/idle.c:403 secondary_startup_64_no_verify+0xb1/0xbb
read to 0xffff88810798a885 of 1 bytes by interrupt on cpu 0:
neigh_output include/net/neighbour.h:507 [inline] ip_finish_output2+0x79a/0xaa0 net/ipv4/ip_output.c:221 ip_finish_output+0x3b5/0x510 net/ipv4/ip_output.c:309 NF_HOOK_COND include/linux/netfilter.h:296 [inline] ip_output+0xf3/0x1a0 net/ipv4/ip_output.c:423 dst_output include/net/dst.h:450 [inline] ip_local_out+0x164/0x220 net/ipv4/ip_output.c:126 __ip_queue_xmit+0x9d3/0xa20 net/ipv4/ip_output.c:525 ip_queue_xmit+0x34/0x40 net/ipv4/ip_output.c:539 __tcp_transmit_skb+0x142a/0x1a00 net/ipv4/tcp_output.c:1405 tcp_transmit_skb net/ipv4/tcp_output.c:1423 [inline] tcp_xmit_probe_skb net/ipv4/tcp_output.c:4011 [inline] tcp_write_wakeup+0x4a9/0x810 net/ipv4/tcp_output.c:4064 tcp_send_probe0+0x2c/0x2b0 net/ipv4/tcp_output.c:4079 tcp_probe_timer net/ipv4/tcp_timer.c:398 [inline] tcp_write_timer_handler+0x394/0x520 net/ipv4/tcp_timer.c:626 tcp_write_timer+0xb9/0x180 net/ipv4/tcp_timer.c:642 call_timer_fn+0x2e/0x1d0 kernel/time/timer.c:1421 expire_timers+0x135/0x240 kernel/time/timer.c:1466 __run_timers+0x368/0x430 kernel/time/timer.c:1734 run_timer_softirq+0x19/0x30 kernel/time/timer.c:1747 __do_softirq+0x12c/0x26e kernel/softirq.c:558 invoke_softirq kernel/softirq.c:432 [inline] __irq_exit_rcu kernel/softirq.c:636 [inline] irq_exit_rcu+0x4e/0xa0 kernel/softirq.c:648 sysvec_apic_timer_interrupt+0x69/0x80 arch/x86/kernel/apic/apic.c:1097 asm_sysvec_apic_timer_interrupt+0x12/0x20 native_safe_halt arch/x86/include/asm/irqflags.h:51 [inline] arch_safe_halt arch/x86/include/asm/irqflags.h:89 [inline] acpi_safe_halt drivers/acpi/processor_idle.c:109 [inline] acpi_idle_do_entry drivers/acpi/processor_idle.c:553 [inline] acpi_idle_enter+0x258/0x2e0 drivers/acpi/processor_idle.c:688 cpuidle_enter_state+0x2b4/0x760 drivers/cpuidle/cpuidle.c:237 cpuidle_enter+0x3c/0x60 drivers/cpuidle/cpuidle.c:351 call_cpuidle kernel/sched/idle.c:158 [inline] cpuidle_idle_call kernel/sched/idle.c:239 [inline] do_idle+0x1a3/0x250 kernel/sched/idle.c:306 cpu_startup_entry+0x15/0x20 kernel/sched/idle.c:403 rest_init+0xee/0x100 init/main.c:734 arch_call_rest_init+0xa/0xb start_kernel+0x5e4/0x669 init/main.c:1142 secondary_startup_64_no_verify+0xb1/0xbb
value changed: 0x20 -> 0x01
Reported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.15.0-rc6-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
--- include/net/neighbour.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
include/net/neighbour.h +8 -3
@@ -504,10 +504,15 @@ static inline int neigh_output(struct neighbour *n, struct sk_buff *skb, {const struct hh_cache *hh = &n->hh; -if ((n->nud_state &NUD_CONNECTED ) && hh->hh_len && !skip_cache) +/* n->nud_state and hh->hh_len could be changed under us. +* neigh_hh_output() is taking care of the race later. +*/ +if (!skip_cache && + (READ_ONCE (n->nud_state) &NUD_CONNECTED ) && +READ_ONCE (hh->hh_len))return neigh_hh_output (hh, skb); -else -return n->output (n, skb); + +return n->output (n, skb); } static inline struct neighbour *
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 247/575 ACPI: AC: Quirk GK45 to skip reading _PSR
In reply to Greg Kroah-HartmanFrom: Stefan Schaeckeler <[email protected]>
[ Upstream commit 3d730ee686800d71ecc5c3cb8460dcdcdeaf38a3 ]
Let GK45 not go into BIOS for determining the AC power state.
The BIOS wrongly returns 0, so hardcode the power state to 1.
The mini PC GK45 by Besstar Tech Lld. (aka Kodlix) just runs off AC. It does not include any batteries. Nevertheless BIOS reports AC off:
root@kodlix:/usr/src/linux# cat /sys/class/power_supply/ADP1/online 0
root@kodlix:/usr/src/linux# modprobe acpi_dbg root@kodlix:/usr/src/linux# tools/power/acpi/acpidbg
- find _PSR
\_SB.PCI0.SBRG.H_EC.ADP1._PSR Method 000000009283cee8 001 Args 0 Len 001C Aml 00000000f54e5f67
- execute \_SB.PCI0.SBRG.H_EC.ADP1._PSR
Evaluating \_SB.PCI0.SBRG.H_EC.ADP1._PSR
Evaluation of \_SB.PCI0.SBRG.H_EC.ADP1._PSR returned object 00000000dc08c187, external buffer length 18
[Integer] = 0000000000000000
that should be
[Integer] = 0000000000000001
--- drivers/acpi/ac.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/acpi/ac.c +19 -0
@@ -64,6 +64,7 @@ static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);static int ac_sleep_before_get_state_ms;static int ac_check_pmic =1 ; +static int ac_only;static struct acpi_driver acpi_ac_driver = { .name ="ac" ,
@@ -99,6 +100,11 @@ static int acpi_ac_get_state(struct acpi_ac *ac)if (!ac)return -EINVAL ; +if (ac_only) { + ac->state =1 ; +return 0 ; + } + status =acpi_evaluate_integer (ac->device->handle,"_PSR" ,NULL , &ac->state);if (ACPI_FAILURE (status)) {
@@ -212,6 +218,12 @@ static int __init ac_do_not_check_pmic_quirk(const struct dmi_system_id *d)return 0 ; } +static int __init ac_only_quirk (const struct dmi_system_id *d) +{ + ac_only =1 ; +return 0 ; +} +/* Please keep this list alphabetically sorted */ static const struct dmi_system_id ac_dmi_table[]__initconst = { {
@@ -221,6 +233,13 @@ static const struct dmi_system_id ac_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"), }, }, + { +/* Kodlix GK45 returning incorrect state */ + .callback = ac_only_quirk, + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "GK45"), + }, + }, {/* Lenovo Ideapad Miix 320, AXP288 PMIC, separate fuel-gauge */ .callback = ac_do_not_check_pmic_quirk,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 248/575 btrfs: reflink: initialize return value to 0 in btrfs_extent_same()
In reply to Greg Kroah-HartmanFrom: Sidong Yang <[email protected]>
[ Upstream commit 44bee215f72f13874c0e734a0712c2e3264c0108 ]
Fix a warning reported by smatch that ret could be returned without initialized. The dedupe operations are supposed to to return 0 for a 0 length range but the caller does not pass olen == 0. To keep this behaviour and also fix the warning initialize ret to 0.
--- fs/btrfs/reflink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/reflink.c +1 -1
@@ -634,7 +634,7 @@ static int btrfs_extent_same_range(struct inode *src, u64 loff, u64 len,static int btrfs_extent_same (struct inode *src,u64 loff,u64 olen,struct inode *dst,u64 dst_loff) { -int ret; +int ret =0 ;u64 i, tail_len, chunk_count;struct btrfs_root *root_dst =BTRFS_I (dst)->root;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 249/575 btrfs: do not take the uuid_mutex in btrfs_rm_device
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit 8ef9dc0f14ba6124c62547a4fdc59b163d8b864e ]
We got the following lockdep splat while running fstests (specifically btrfs/003 and btrfs/020 in a row) with the new rc. This was uncovered by 87579e9b7d8d ("loop: use worker per cgroup instead of kworker") which converted loop to using workqueues, which comes with lockdep annotations that don't exist with kworkers. The lockdep splat is as follows:
WARNING: possible circular locking dependency detected 5.14.0-rc2-custom+ #34 Not tainted
------------------------------------------------------
losetup/156417 is trying to acquire lock:
ffff9c7645b02d38 ((wq_completion)loop0){+.+.}-{0:0}, at: flush_workqueue+0x84/0x600
but task is already holding lock:
ffff9c7647395468 (&lo->lo_mutex){+.+.}-{3:3}, at: __loop_clr_fd+0x41/0x650 [loop]
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #5 (&lo->lo_mutex){+.+.}-{3:3}:
__mutex_lock+0xba/0x7c0 lo_open+0x28/0x60 [loop] blkdev_get_whole+0x28/0xf0 blkdev_get_by_dev.part.0+0x168/0x3c0 blkdev_open+0xd2/0xe0 do_dentry_open+0x163/0x3a0 path_openat+0x74d/0xa40 do_filp_open+0x9c/0x140 do_sys_openat2+0xb1/0x170 __x64_sys_openat+0x54/0x90 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae
-> #4 (&disk->open_mutex){+.+.}-{3:3}:
__mutex_lock+0xba/0x7c0 blkdev_get_by_dev.part.0+0xd1/0x3c0 blkdev_get_by_path+0xc0/0xd0 btrfs_scan_one_device+0x52/0x1f0 [btrfs] btrfs_control_ioctl+0xac/0x170 [btrfs] __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae
-> #3 (uuid_mutex){+.+.}-{3:3}:
__mutex_lock+0xba/0x7c0 btrfs_rm_device+0x48/0x6a0 [btrfs] btrfs_ioctl+0x2d1c/0x3110 [btrfs] __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae
-> #2 (sb_writers#11){.+.+}-{0:0}:
lo_write_bvec+0x112/0x290 [loop] loop_process_work+0x25f/0xcb0 [loop] process_one_work+0x28f/0x5d0 worker_thread+0x55/0x3c0 kthread+0x140/0x170 ret_from_fork+0x22/0x30
-> #1 ((work_completion)(&lo->rootcg_work)){+.+.}-{0:0}:
process_one_work+0x266/0x5d0 worker_thread+0x55/0x3c0 kthread+0x140/0x170 ret_from_fork+0x22/0x30
-> #0 ((wq_completion)loop0){+.+.}-{0:0}:
__lock_acquire+0x1130/0x1dc0 lock_acquire+0xf5/0x320 flush_workqueue+0xae/0x600 drain_workqueue+0xa0/0x110 destroy_workqueue+0x36/0x250 __loop_clr_fd+0x9a/0x650 [loop] lo_ioctl+0x29d/0x780 [loop] block_ioctl+0x3f/0x50 __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae
other info that might help us debug this:
Chain exists of:
(wq_completion)loop0 --> &disk->open_mutex --> &lo->lo_mutex
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&lo->lo_mutex);
lock(&disk->open_mutex);
lock(&lo->lo_mutex);
lock((wq_completion)loop0); *** DEADLOCK ***
1 lock held by losetup/156417:
#0: ffff9c7647395468 (&lo->lo_mutex){+.+.}-{3:3}, at: __loop_clr_fd+0x41/0x650 [loop]
stack backtrace: CPU: 8 PID: 156417 Comm: losetup Not tainted 5.14.0-rc2-custom+ #34 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 Call Trace: dump_stack_lvl+0x57/0x72 check_noncircular+0x10a/0x120 __lock_acquire+0x1130/0x1dc0 lock_acquire+0xf5/0x320 ? flush_workqueue+0x84/0x600 flush_workqueue+0xae/0x600 ? flush_workqueue+0x84/0x600 drain_workqueue+0xa0/0x110 destroy_workqueue+0x36/0x250 __loop_clr_fd+0x9a/0x650 [loop] lo_ioctl+0x29d/0x780 [loop] ? __lock_acquire+0x3a0/0x1dc0 ? update_dl_rq_load_avg+0x152/0x360 ? lock_is_held_type+0xa5/0x120 ? find_held_lock.constprop.0+0x2b/0x80 block_ioctl+0x3f/0x50 __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f645884de6b
Usually the uuid_mutex exists to protect the fs_devices that map together all of the devices that match a specific uuid. In rm_device we're messing with the uuid of a device, so it makes sense to protect that here.
However in doing that it pulls in a whole host of lockdep dependencies, as we call mnt_may_write() on the sb before we grab the uuid_mutex, thus we end up with the dependency chain under the uuid_mutex being added under the normal sb write dependency chain, which causes problems with loop devices.
We don't need the uuid mutex here however. If we call btrfs_scan_one_device() before we scratch the super block we will find the fs_devices and not find the device itself and return EBUSY because the fs_devices is open. If we call it after the scratch happens it will not appear to be a valid btrfs file system.
We do not need to worry about other fs_devices modifying operations here because we're protected by the exclusive operations locking.
So drop the uuid_mutex here in order to fix the lockdep splat.
A more detailed explanation from the discussion:
We are worried about rm and scan racing with each other, before this change we'll zero the device out under the UUID mutex so when scan does run it'll make sure that it can go through the whole device scan thing without rm messing with us.
We aren't worried if the scratch happens first, because the result is we don't think this is a btrfs device and we bail out.
The only case we are concerned with is we scratch _after_ scan is able to read the superblock and gets a seemingly valid super block, so lets consider this case.
Scan will call device_list_add() with the device we're removing. We'll call find_fsid_with_metadata_uuid() and get our fs_devices for this UUID. At this point we lock the fs_devices->device_list_mutex. This is what protects us in this case, but we have two cases here.
1. We aren't to the device removal part of the RM. We found our device, and device name matches our path, we go down and we set total_devices to our super number of devices, which doesn't affect anything because we haven't done the remove yet.
2. We are past the device removal part, which is protected by the device_list_mutex. Scan doesn't find the device, it goes down and does the
if (fs_devices->opened)
return -EBUSY;
check and we bail out.
Nothing about this situation is ideal, but the lockdep splat is real, and the fix is safe, tho admittedly a bit scary looking.
--- fs/btrfs/volumes.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/volumes.c +5 -5
@@ -2069,8 +2069,11 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,u64 num_devices;int ret =0 ; -mutex_lock (&uuid_mutex); - +/* +* The device list in fs_devices is accessed without locks (neither +* uuid_mutex nor device_list_mutex) as it won't change on a mounted +* filesystem and another device rm cannot run. +*/ num_devices =btrfs_num_devices (fs_info); ret =btrfs_check_raid_min_devices (fs_info, num_devices -1 );
@@ -2114,11 +2117,9 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,mutex_unlock (&fs_info->chunk_mutex); } -mutex_unlock (&uuid_mutex); ret =btrfs_shrink_device (device,0 );if (!ret)btrfs_reada_remove_dev (device); -mutex_lock (&uuid_mutex);if (ret) goto error_undo;
@@ -2194,7 +2195,6 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path, } out: -mutex_unlock (&uuid_mutex);return ret; error_undo:
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 250/575 spi: bcm-qspi: Fix missing clk_disable_unprepare() on error in bcm_qspi_probe()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit ca9b8f56ec089d3a436050afefd17b7237301f47 ]
Fix the missing clk_disable_unprepare() before return from bcm_qspi_probe() in the error handling case.
--- drivers/spi/spi-bcm-qspi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/spi-bcm-qspi.c +3 -2
@@ -1460,7 +1460,7 @@ int bcm_qspi_probe(struct platform_device *pdev, &qspi->dev_ids[val]);if (ret <0 ) {dev_err (&pdev->dev,"IRQ %s not found\n" , name); - goto qspi_probe_err; + goto qspi_unprepare_err; } qspi->dev_ids[val].dev = qspi;
@@ -1475,7 +1475,7 @@ int bcm_qspi_probe(struct platform_device *pdev,if (!num_ints) {dev_err (&pdev->dev,"no IRQs registered, cannot init driver\n" ); ret = -EINVAL ; - goto qspi_probe_err; + goto qspi_unprepare_err; }bcm_qspi_hw_init (qspi);
@@ -1499,6 +1499,7 @@ int bcm_qspi_probe(struct platform_device *pdev, qspi_reg_err:bcm_qspi_hw_uninit (qspi); +qspi_unprepare_err:clk_disable_unprepare (qspi->clk); qspi_probe_err:kfree (qspi->dev_ids);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 251/575 wcn36xx: Correct band/freq reporting on RX
In reply to Greg Kroah-HartmanFrom: Loic Poulain <[email protected]>
[ Upstream commit 8a27ca39478270e07baf9c09aa0c99709769ba03 ]
For packets originating from hardware scan, the channel and band is included in the buffer descriptor (bd->rf_band & bd->rx_ch).
For 2Ghz band the channel value is directly reported in the 4-bit rx_ch field. For 5Ghz band, the rx_ch field contains a mapping index (given the 4-bit limitation).
The reserved0 value field is also used to extend 4-bit mapping to 5-bit mapping to support more than 16 5Ghz channels.
This change adds correct reporting of the frequency/band, that is used in scan mechanism. And is required for 5Ghz hardware scan support.
--- drivers/net/wireless/ath/wcn36xx/txrx.c | 23 +++++++++++++++++++++++ drivers/net/wireless/ath/wcn36xx/txrx.h | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/wcn36xx/txrx.c +23 -0
@@ -31,6 +31,13 @@ struct wcn36xx_rate {enum rate_info_bw bw; }; +/* Buffer descriptor rx_ch field is limited to 5-bit (4+1), a mapping is used +* for 11A Channels. +*/ +static const u8 ab_rx_ch_map[] = {36 ,40 ,44 ,48 ,52 ,56 ,60 ,64 ,100 ,104 , +108 ,112 ,116 ,120 ,124 ,128 ,132 ,136 ,140 , +149 ,153 ,157 ,161 ,165 ,144 }; +static const struct wcn36xx_rate wcn36xx_rate_table[] = {/* 11b rates */ {10 ,0 ,RX_ENC_LEGACY ,0 ,RATE_INFO_BW_20 },
@@ -291,6 +298,22 @@ int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb) ieee80211_is_probe_resp(hdr->frame_control)) status.boottime_ns = ktime_get_boottime_ns(); +if (bd->scan_learn) { +/* If packet originates from hardware scanning, extract the +* band/channel from bd descriptor. +*/ +u8 hwch = (bd->reserved0 <<4 ) + bd->rx_ch; + +if (bd->rf_band !=1 && hwch <=sizeof (ab_rx_ch_map) && hwch >=1 ) { + status.band =NL80211_BAND_5GHZ ; + status.freq =ieee80211_channel_to_frequency (ab_rx_ch_map[hwch -1 ], + status.band); + }else { + status.band =NL80211_BAND_2GHZ ; + status.freq =ieee80211_channel_to_frequency (hwch, status.band); + } + } +memcpy (IEEE80211_SKB_RXCB (skb), &status,sizeof (status));if (ieee80211_is_beacon (hdr->frame_control)) {
drivers/net/wireless/ath/wcn36xx/txrx.h +2 -1
@@ -110,7 +110,8 @@ struct wcn36xx_rx_bd {/* 0x44 */ u32 exp_seq_num:12; u32 cur_seq_num:12; - u32 fr_type_subtype:8; + u32 rf_band:2; + u32 fr_type_subtype:6;/* 0x48 */ u32 msdu_size:16;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 252/575 x86/hyperv: Protect set_hv_tscchange_cb() against getting preempted
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
[ Upstream commit 285f68afa8b20f752b0b7194d54980b5e0e27b75 ]
The following issue is observed with CONFIG_DEBUG_PREEMPT when KVM loads:
KVM: vmx: using Hyper-V Enlightened VMCS
BUG: using smp_processor_id() in preemptible [00000000] code: systemd-udevd/488 caller is set_hv_tscchange_cb+0x16/0x80 CPU: 1 PID: 488 Comm: systemd-udevd Not tainted 5.15.0-rc5+ #396 Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS Hyper-V UEFI Release v4.0 12/17/2019 Call Trace: dump_stack_lvl+0x6a/0x9a check_preemption_disabled+0xde/0xe0 ? kvm_gen_update_masterclock+0xd0/0xd0 [kvm] set_hv_tscchange_cb+0x16/0x80 kvm_arch_init+0x23f/0x290 [kvm] kvm_init+0x30/0x310 [kvm] vmx_init+0xaf/0x134 [kvm_intel] ...
set_hv_tscchange_cb() can get preempted in between acquiring smp_processor_id() and writing to HV_X64_MSR_REENLIGHTENMENT_CONTROL. This is not an issue by itself: HV_X64_MSR_REENLIGHTENMENT_CONTROL is a partition-wide MSR and it doesn't matter which particular CPU will be used to receive reenlightenment notifications. The only real problem can (in theory) be observed if the CPU whose id was acquired with smp_processor_id() goes offline before we manage to write to the MSR, the logic in hv_cpu_die() won't be able to reassign it correctly.
--- arch/x86/hyperv/hv_init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/hyperv/hv_init.c +4 -1
@@ -168,7 +168,6 @@ void set_hv_tscchange_cb(void (*cb)(void))struct hv_reenlightenment_control re_ctrl = { .vector =HYPERV_REENLIGHTENMENT_VECTOR , .enabled =1 , - .target_vp = hv_vp_index[smp_processor_id ()] };struct hv_tsc_emulation_control emu_ctrl = {.enabled =1 };
@@ -182,8 +181,12 @@ void set_hv_tscchange_cb(void (*cb)(void))/* Make sure callback is registered before we write to MSRs */ wmb (); + re_ctrl.target_vp = hv_vp_index[get_cpu ()]; +wrmsrl (HV_X64_MSR_REENLIGHTENMENT_CONTROL , *((u64 *)&re_ctrl));wrmsrl (HV_X64_MSR_TSC_EMULATION_CONTROL , *((u64 *)&emu_ctrl)); + +put_cpu (); }EXPORT_SYMBOL_GPL (set_hv_tscchange_cb);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 253/575 drm/amd/display: dcn20_resource_construct reduce scope of FPU enabled
In reply to Greg Kroah-HartmanFrom: Anson Jacob <[email protected]>
[ Upstream commit bc39a69a2ac484e6575a958567c162ef56c9f278 ]
Limit when FPU is enabled to only functions that does FPU operations for dcn20_resource_construct, which gets called during driver initialization.
Enabling FPU operation disables preemption. Sleeping functions(mutex (un)lock, memory allocation using GFP_KERNEL, etc.) should not be called when preemption is disabled.
Fixes the following case caught by enablingCONFIG_DEBUG_ATOMIC_SLEEP in kernel config
[ 1.338434] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:281 [ 1.347395] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 197, name: systemd-udevd [ 1.356356] CPU: 7 PID: 197 Comm: systemd-udevd Not tainted 5.13.0+ #3 [ 1.356358] Hardware name: System manufacturer System Product Name/PRIME X570-PRO, BIOS 3405 02/01/2021 [ 1.356360] Call Trace: [ 1.356361] dump_stack+0x6b/0x86 [ 1.356366] ___might_sleep.cold+0x87/0x98 [ 1.356370] __might_sleep+0x4b/0x80 [ 1.356372] mutex_lock+0x21/0x50 [ 1.356376] smu_get_uclk_dpm_states+0x3f/0x80 [amdgpu] [ 1.356538] pp_nv_get_uclk_dpm_states+0x35/0x50 [amdgpu] [ 1.356711] init_soc_bounding_box+0xf9/0x210 [amdgpu] [ 1.356892] ? create_object+0x20d/0x340 [ 1.356897] ? dcn20_resource_construct+0x46f/0xd30 [amdgpu] [ 1.357077] dcn20_resource_construct+0x4b1/0xd30 [amdgpu]
...
Tested on: 5700XT (NAVI10 0x1002:0x731F 0x1DA2:0xE410 0xC1)
--- .../drm/amd/display/dc/dcn20/dcn20_resource.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +9 -7
@@ -3754,16 +3754,22 @@ static bool init_soc_bounding_box(struct dc *dc, clock_limits_available = (status ==PP_SMU_RESULT_OK ); } -if (clock_limits_available && uclk_states_available && num_states) +if (clock_limits_available && uclk_states_available && num_states) { +DC_FP_START ();dcn20_update_bounding_box (dc, loaded_bb, &max_clocks, uclk_states, num_states); -else if (clock_limits_available) +DC_FP_END (); + }else if (clock_limits_available) { +DC_FP_START ();dcn20_cap_soc_clocks (loaded_bb, max_clocks); +DC_FP_END (); + } } loaded_ip->max_num_otg = pool->base.res_cap->num_timing_generator; loaded_ip->max_num_dpp = pool->base.pipe_count; +DC_FP_START ();dcn20_patch_bounding_box (dc, loaded_bb); - +DC_FP_END ();return true; }
@@ -3783,8 +3789,6 @@ static bool dcn20_resource_construct(enum dml_project dml_project_version =get_dml_project_version (ctx->asic_id.hw_internal_rev); -DC_FP_START (); - ctx->dc_bios->regs = &bios_regs; pool->base.funcs = &dcn20_res_pool_funcs;
@@ -4128,12 +4132,10 @@ static bool dcn20_resource_construct( pool->base.oem_device =NULL ; } -DC_FP_END ();return true; create_fail: -DC_FP_END ();dcn20_resource_destruct (pool);return false;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 254/575 selftests/core: fix conflicting types compile error for close_range()
In reply to Greg Kroah-HartmanFrom: Shuah Khan <[email protected]>
[ Upstream commit f35dcaa0a8a29188ed61083d153df1454cf89d08 ]
close_range() test type conflicts with close_range() library call in x86_64-linux-gnu/bits/unistd_ext.h. Fix it by changing the name to core_close_range().
gcc -g -I../../../../usr/include/ close_range_test.c -o ../tools/testing/selftests/core/close_range_test
In file included from close_range_test.c:16:
close_range_test.c:57:6: error: conflicting types for ‘close_range’; have ‘void(struct __test_metadata *)’
57 | TEST(close_range)
| ^~~~~~~~~~~
../kselftest_harness.h:181:21: note: in definition of macro ‘__TEST_IMPL’
181 | static void test_name(struct __test_metadata *_metadata); \
| ^~~~~~~~~
close_range_test.c:57:1: note: in expansion of macro ‘TEST’
57 | TEST(close_range)
| ^~~~
In file included from /usr/include/unistd.h:1204,
from close_range_test.c:13:
/usr/include/x86_64-linux-gnu/bits/unistd_ext.h:56:12: note: previous declaration of ‘close_range’ with type ‘int(unsigned int, unsigned int, int)’
56 | extern int close_range (unsigned int __fd, unsigned int __max_fd,
| ^~~~~~~~~~~--- tools/testing/selftests/core/close_range_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/core/close_range_test.c +1 -1
@@ -33,7 +33,7 @@ static inline int sys_close_range(unsigned int fd, unsigned int max_fd,#define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0]))#endif -TEST (close_range) +TEST (core_close_range) {int i, ret;int open_fds[101 ];
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 255/575 parisc: fix warning in flush_tlb_all
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
[ Upstream commit 1030d681319b43869e0d5b568b9d0226652d1a6f ]
I've got the following splat after enabling preemption:
[ 3.724721] BUG: using __this_cpu_add() in preemptible [00000000] code: swapper/0/1 [ 3.734630] caller is __this_cpu_preempt_check+0x38/0x50 [ 3.740635] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.15.0-rc4-64bit+ #324 [ 3.744605] Hardware name: 9000/785/C8000 [ 3.744605] Backtrace: [ 3.744605] [<00000000401d9d58>] show_stack+0x74/0xb0 [ 3.744605] [<0000000040c27bd4>] dump_stack_lvl+0x10c/0x188 [ 3.744605] [<0000000040c27c84>] dump_stack+0x34/0x48 [ 3.744605] [<0000000040c33438>] check_preemption_disabled+0x178/0x1b0 [ 3.744605] [<0000000040c334f8>] __this_cpu_preempt_check+0x38/0x50 [ 3.744605] [<00000000401d632c>] flush_tlb_all+0x58/0x2e0 [ 3.744605] [<00000000401075c0>] 0x401075c0 [ 3.744605] [<000000004010b8fc>] 0x4010b8fc [ 3.744605] [<00000000401080fc>] 0x401080fc [ 3.744605] [<00000000401d5224>] do_one_initcall+0x128/0x378 [ 3.744605] [<0000000040102de8>] 0x40102de8 [ 3.744605] [<0000000040c33864>] kernel_init+0x60/0x3a8 [ 3.744605] [<00000000401d1020>] ret_from_kernel_thread+0x20/0x28 [ 3.744605]
Fix this by moving the __inc_irq_stat() into the locked section.
--- arch/parisc/mm/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/parisc/mm/init.c +2 -2
@@ -844,9 +844,9 @@ void flush_tlb_all(void) {int do_recycle; -__inc_irq_stat (irq_tlb_count); do_recycle =0 ;spin_lock (&sid_lock); +__inc_irq_stat (irq_tlb_count);if (dirty_space_ids >RECYCLE_THRESHOLD ) {BUG_ON (recycle_inuse);/* FIXME: Use a semaphore/wait queue here */ get_dirty_sids (&recycle_ndirty,recycle_dirty_array);
@@ -865,8 +865,8 @@ void flush_tlb_all(void)#else void flush_tlb_all (void ) { -__inc_irq_stat (irq_tlb_count);spin_lock (&sid_lock); +__inc_irq_stat (irq_tlb_count);flush_tlb_all_local (NULL );recycle_sids ();spin_unlock (&sid_lock);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 256/575 task_stack: Fix end_of_stack() for architectures with upwards-growing stack
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
[ Upstream commit 9cc2fa4f4a92ccc6760d764e7341be46ee8aaaa1 ]
The function end_of_stack() returns a pointer to the last entry of a stack. For architectures like parisc where the stack grows upwards return the pointer to the highest address in the stack.
Without this change I faced a crash on parisc, because the stackleak functionality wrote STACKLEAK_POISON to the lowest address and thus overwrote the first 4 bytes of the task_struct which included the TIF_FLAGS.
--- include/linux/sched/task_stack.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/sched/task_stack.h +4 -0
@@ -25,7 +25,11 @@ static inline void *task_stack_page(const struct task_struct *task)static inline unsigned long *end_of_stack (const struct task_struct *task) { +#ifdef CONFIG_STACK_GROWSUP +return (unsigned long *)((unsigned long )task->stack +THREAD_SIZE ) -1 ; +#else return task->stack; +#endif }#elif !defined(__HAVE_THREAD_FUNCTIONS)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 257/575 erofs: dont trigger WARN() when decompression fails
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
[ Upstream commit a0961f351d82d43ab0b845304caa235dfe249ae9 ]
syzbot reported a WARNING [1] due to corrupted compressed data.
As Dmitry said, "If this is not a kernel bug, then the code should not use WARN. WARN if for kernel bugs and is recognized as such by all testing systems and humans."
[1] https://lore.kernel.org/r/[email protected]
--- fs/erofs/decompressor.c | 1 - 1 file changed, 1 deletion(-)
fs/erofs/decompressor.c +0 -1
@@ -170,7 +170,6 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)erofs_err (rq->sb,"failed to decompress %d in[%u, %u] out[%u]" , ret, inlen, inputmargin, rq->outputsize); -WARN_ON (1 );print_hex_dump (KERN_DEBUG ,"[ in]: " ,DUMP_PREFIX_OFFSET ,16 ,1 , src + inputmargin, inlen, true); print_hex_dump(KERN_DEBUG, "[out]: ", DUMP_PREFIX_OFFSET,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 258/575 parisc/unwind: fix unwinder when CONFIG_64BIT is enabled
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
[ Upstream commit 8e0ba125c2bf1030af3267058019ba86da96863f ]
With 64 bit kernels unwind_special() is not working because it compares the pc to the address of the function descriptor. Add a helper function that compares pc with the dereferenced address. This fixes all of the backtraces on my c8000. Without this changes, a lot of backtraces are missing in kdb or the show-all-tasks command from /proc/sysrq-trigger.
--- arch/parisc/kernel/unwind.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
arch/parisc/kernel/unwind.c +14 -7
@@ -21,6 +21,8 @@#include <asm/ptrace.h> #include <asm/unwind.h> +#include <asm/switch_to.h> +#include <asm/sections.h> /* #define DEBUG 1 */ #ifdef DEBUG
@@ -203,6 +205,11 @@ int __init unwind_init(void)return 0 ; } +static bool pc_is_kernel_fn (unsigned long pc,void *fn) +{ +return (unsigned long )dereference_kernel_function_descriptor (fn) == pc; +} +static int unwind_special (struct unwind_frame_info *info,unsigned long pc,int frame_size) {/*
@@ -221,7 +228,7 @@ static int unwind_special(struct unwind_frame_info *info, unsigned long pc, intextern void *const _call_on_stack;#endif /* CONFIG_IRQSTACKS */ -if (pc == (unsigned long ) &handle_interruption) { +if (pc_is_kernel_fn (pc, handle_interruption)) {struct pt_regs *regs = (struct pt_regs *)(info->sp - frame_size -PT_SZ_ALGN );dbg ("Unwinding through handle_interruption()\n" ); info->prev_sp = regs->gr[30 ];
@@ -229,13 +236,13 @@ static int unwind_special(struct unwind_frame_info *info, unsigned long pc, intreturn 1 ; } -if (pc == (unsigned long ) &ret_from_kernel_thread || - pc == (unsigned long ) &syscall_exit) { +if (pc_is_kernel_fn (pc, ret_from_kernel_thread) || +pc_is_kernel_fn (pc, syscall_exit)) { info->prev_sp = info->prev_ip =0 ;return 1 ; } -if (pc == (unsigned long ) &intr_return) { +if (pc_is_kernel_fn (pc, intr_return)) {struct pt_regs *regs;dbg ("Found intr_return()\n" );
@@ -246,20 +253,20 @@ static int unwind_special(struct unwind_frame_info *info, unsigned long pc, intreturn 1 ; } -if (pc == (unsigned long ) &_switch_to_ret) { +if (pc_is_kernel_fn (pc, _switch_to) || +pc_is_kernel_fn (pc, _switch_to_ret)) { info->prev_sp = info->sp -CALLEE_SAVE_FRAME_SIZE ; info->prev_ip = *(unsigned long *)(info->prev_sp -RP_OFFSET );return 1 ; }#ifdef CONFIG_IRQSTACKS -if (pc == (unsigned long ) &_call_on_stack) { +if (pc_is_kernel_fn (pc, _call_on_stack)) { info->prev_sp = *(unsigned long *)(info->sp -FRAME_SIZE -REG_SZ ); info->prev_ip = *(unsigned long *)(info->sp -FRAME_SIZE -RP_OFFSET );return 1 ; }#endif -return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 259/575 parisc/kgdb: add kgdb_roundup() to make kgdb work with idle polling
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
[ Upstream commit 66e29fcda1824f0427966fbee2bd2c85bf362c82 ]
With idle polling, IPIs are not sent when a CPU idle, but queued and run later from do_idle(). The default kgdb_call_nmi_hook() implementation gets the pointer to struct pt_regs from get_irq_reqs(), which doesn't work in that case because it was not called from the IPI interrupt handler. Fix it by defining our own kgdb_roundup() function which sents an IPI_ENTER_KGDB. When that IPI is received on the target CPU kgdb_nmicallback() is called.
--- arch/parisc/kernel/smp.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
arch/parisc/kernel/smp.c +17 -2
@@ -29,6 +29,7 @@#include <linux/bitops.h> #include <linux/ftrace.h> #include <linux/cpu.h> +#include <linux/kgdb.h> #include <linux/atomic.h> #include <asm/current.h>
@@ -69,7 +70,10 @@ enum ipi_message_type {IPI_CALL_FUNC ,IPI_CPU_START ,IPI_CPU_STOP , - IPI_CPU_TEST +IPI_CPU_TEST , +#ifdef CONFIG_KGDB + IPI_ENTER_KGDB, +#endif };
@@ -167,7 +171,12 @@ ipi_interrupt(int irq, void *dev_id)case IPI_CPU_TEST :smp_debug (100 ,KERN_DEBUG "CPU%d is alive!\n" , this_cpu);break ; - +#ifdef CONFIG_KGDB +case IPI_ENTER_KGDB : +smp_debug (100 ,KERN_DEBUG "CPU%d ENTER_KGDB\n" , this_cpu); +kgdb_nmicallback (raw_smp_processor_id (),get_irq_regs ()); +break ; +#endif default :printk (KERN_CRIT "Unknown IPI num on CPU%d: %lu\n" , this_cpu, which);
@@ -226,6 +235,12 @@ send_IPI_allbutself(enum ipi_message_type op) } } +#ifdef CONFIG_KGDB +void kgdb_roundup_cpus (void ) +{ +send_IPI_allbutself (IPI_ENTER_KGDB ); +} +#endif inline void smp_send_stop (void ) {send_IPI_allbutself (IPI_CPU_STOP ); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 260/575 netfilter: conntrack: set on IPS_ASSURED if flows enters internal stream state
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit b7b1d02fc43925a4d569ec221715db2dfa1ce4f5 ]
The internal stream state sets the timeout to 120 seconds 2 seconds after the creation of the flow, attach this internal stream state to the IPS_ASSURED flag for consistent event reporting.
Before this patch:
[NEW] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 [UNREPLIED] src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [UPDATE] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [UPDATE] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [ASSURED] [DESTROY] udp 17 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [ASSURED]
Note IPS_ASSURED for the flow not yet in the internal stream state.
after this update:
[NEW] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 [UNREPLIED] src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [UPDATE] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [UPDATE] udp 17 120 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [ASSURED] [DESTROY] udp 17 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [ASSURED]
Before this patch, short-lived UDP flows never entered IPS_ASSURED, so they were already candidate flow to be deleted by early_drop under stress.
Before this patch, IPS_ASSURED is set on regardless the internal stream state, attach this internal stream state to IPS_ASSURED.
packet #1 (original direction) enters NEW state
packet #2 (reply direction) enters ESTABLISHED state, sets on IPS_SEEN_REPLY paclet #3 (any direction) sets on IPS_ASSURED (if 2 seconds since the
creation has passed by).
--- net/netfilter/nf_conntrack_proto_udp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_proto_udp.c +5 -2
@@ -105,10 +105,13 @@ int nf_conntrack_udp_packet(struct nf_conn *ct,*/ if (test_bit (IPS_SEEN_REPLY_BIT , &ct->status)) {unsigned long extra = timeouts[UDP_CT_UNREPLIED ]; +bool stream = false;/* Still active after two seconds? Extend timeout. */ -if (time_after (jiffies, ct->proto.udp.stream_ts)) +if (time_after (jiffies, ct->proto.udp.stream_ts)) { extra = timeouts[UDP_CT_REPLIED ]; + stream = true; + }nf_ct_refresh_acct (ct, ctinfo, skb, extra);
@@ -117,7 +120,7 @@ int nf_conntrack_udp_packet(struct nf_conn *ct,return NF_ACCEPT ;/* Also, more likely to be important, and not a probe */ -if (!test_and_set_bit (IPS_ASSURED_BIT , &ct->status)) +if (stream && !test_and_set_bit (IPS_ASSURED_BIT , &ct->status))nf_conntrack_event_cache (IPCT_ASSURED , ct); }else {nf_ct_refresh_acct (ct, ctinfo, skb, timeouts[UDP_CT_UNREPLIED ]);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 261/575 selftests/bpf: Fix strobemeta selftest regression
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 0133c20480b14820d43c37c0e9502da4bffcad3a ]
After most recent nightly Clang update strobemeta selftests started failing with the following error (relevant portion of assembly included):
1624: (85) call bpf_probe_read_user_str#114
1625: (bf) r1 = r0
1626: (18) r2 = 0xfffffffe
1628: (5f) r1 &= r2
1629: (55) if r1 != 0x0 goto pc+7
1630: (07) r9 += 104
1631: (6b) *(u16 *)(r9 +0) = r0
1632: (67) r0 <<= 32
1633: (77) r0 >>= 32
1634: (79) r1 = *(u64 *)(r10 -456)
1635: (0f) r1 += r0
1636: (7b) *(u64 *)(r10 -456) = r1
1637: (79) r1 = *(u64 *)(r10 -368)
1638: (c5) if r1 s< 0x1 goto pc+778
1639: (bf) r6 = r8
1640: (0f) r6 += r7
1641: (b4) w1 = 0
1642: (6b) *(u16 *)(r6 +108) = r1
1643: (79) r3 = *(u64 *)(r10 -352)
1644: (79) r9 = *(u64 *)(r10 -456)
1645: (bf) r1 = r9
1646: (b4) w2 = 1
1647: (85) call bpf_probe_read_user_str#114
R1 unbounded memory access, make sure to bounds check any such access
In the above code r0 and r1 are implicitly related. Clang knows that, but verifier isn't able to infer this relationship.
Yonghong Song narrowed down this "regression" in code generation to a recent Clang optimization change ([0]), which for BPF target generates code pattern that BPF verifier can't handle and loses track of register boundaries.
This patch works around the issue by adding an BPF assembly-based helper that helps to prove to the verifier that upper bound of the register is a given constant by controlling the exact share of generated BPF instruction sequence. This fixes the immediate issue for strobemeta selftest.
[0] https://github.com/llvm/llvm-project/commit/acabad9ff6bf13e00305d9d8621ee8eafc1f8b08
--- tools/testing/selftests/bpf/progs/strobemeta.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
tools/testing/selftests/bpf/progs/strobemeta.h +11 -0
@@ -10,6 +10,14 @@#include <linux/types.h> #include <bpf/bpf_helpers.h> +#define bpf_clamp_umax (VAR ,UMAX ) \ + asm volatile ( \ + "if %0 <= %[max] goto +1\n" \ + "%0 = %[max]\n" \ + : "+r"(VAR) \ + : [max]"i"(UMAX) \ + ) +typedef uint32_t pid_t ;struct task_struct {};
@@ -413,6 +421,7 @@ static __always_inline void *read_map_var(struct strobemeta_cfg *cfg, len =bpf_probe_read_user_str (payload,STROBE_MAX_STR_LEN , map.tag);if (len <=STROBE_MAX_STR_LEN ) { +bpf_clamp_umax (len,STROBE_MAX_STR_LEN ); descr->tag_len = len; payload += len; }
@@ -430,6 +439,7 @@ static __always_inline void *read_map_var(struct strobemeta_cfg *cfg, len =bpf_probe_read_user_str (payload,STROBE_MAX_STR_LEN , map.entries[i].key);if (len <=STROBE_MAX_STR_LEN ) { +bpf_clamp_umax (len,STROBE_MAX_STR_LEN ); descr->key_lens[i] = len; payload += len; }
@@ -437,6 +447,7 @@ static __always_inline void *read_map_var(struct strobemeta_cfg *cfg, len =bpf_probe_read_user_str (payload,STROBE_MAX_STR_LEN , map.entries[i].val);if (len <=STROBE_MAX_STR_LEN ) { +bpf_clamp_umax (len,STROBE_MAX_STR_LEN ); descr->val_lens[i] = len; payload += len; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 262/575 Bluetooth: fix init and cleanup of sco_conn.timeout_work
In reply to Greg Kroah-HartmanFrom: Desmond Cheong Zhi Xi <[email protected]>
[ Upstream commit 49d8a5606428ca0962d09050a5af81461ff90fbb ]
Before freeing struct sco_conn, all delayed timeout work should be cancelled. Otherwise, sco_sock_timeout could potentially use the sco_conn after it has been freed.
Additionally, sco_conn.timeout_work should be initialized when the connection is allocated, not when the channel is added. This is because an sco_conn can create channels with multiple sockets over its lifetime, which happens if sockets are released but the connection isn't deleted.
--- net/bluetooth/sco.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
net/bluetooth/sco.c +4 -5
@@ -134,6 +134,7 @@ static struct sco_conn *sco_conn_add(struct hci_conn *hcon)return NULL ;spin_lock_init (&conn->lock); +INIT_DELAYED_WORK (&conn->timeout_work, sco_sock_timeout); hcon->sco_data = conn; conn->hcon = hcon;
@@ -197,11 +198,11 @@ static void sco_conn_del(struct hci_conn *hcon, int err)sco_chan_del (sk, err);bh_unlock_sock (sk);sock_put (sk); - -/* Ensure no more work items will run before freeing conn. */ -cancel_delayed_work_sync (&conn->timeout_work); } +/* Ensure no more work items will run before freeing conn. */ +cancel_delayed_work_sync (&conn->timeout_work); + hcon->sco_data =NULL ;kfree (conn); }
@@ -214,8 +215,6 @@ static void __sco_chan_add(struct sco_conn *conn, struct sock *sk,sco_pi (sk)->conn = conn; conn->sk = sk; -INIT_DELAYED_WORK (&conn->timeout_work, sco_sock_timeout); -if (parent)bt_accept_enqueue (parent, sk, true); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 263/575 rcu: Fix existing exp request check in sync_sched_exp_online_cleanup()
In reply to Greg Kroah-HartmanFrom: Neeraj Upadhyay <[email protected]>
[ Upstream commit f0b2b2df5423fb369ac762c77900bc7765496d58 ]
The sync_sched_exp_online_cleanup() checks to see if RCU needs an expedited quiescent state from the incoming CPU, sending it an IPI if so. Before sending IPI, it checks whether expedited qs need has been already requested for the incoming CPU, by checking rcu_data.cpu_no_qs.b.exp for the current cpu, on which sync_sched_exp_online_cleanup() is running. This works for the case where incoming CPU is same as self. However, for the case where incoming CPU is different from self, expedited request won't get marked, which can potentially delay reporting of expedited quiescent state for the incoming CPU.
--- kernel/rcu/tree_exp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree_exp.h +1 -1
@@ -759,7 +759,7 @@ static void sync_sched_exp_online_cleanup(int cpu) my_cpu =get_cpu ();/* Quiescent state either not needed or already requested, leave. */ if (!(READ_ONCE (rnp->expmask) & rdp->grpmask) || -__this_cpu_read (rcu_data.cpu_no_qs.b.exp)) { + rdp->cpu_no_qs.b.exp) {put_cpu ();return ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 264/575 MIPS: lantiq: dma: fix burst length for DEU
In reply to Greg Kroah-HartmanFrom: Aleksander Jan Bajkowski <[email protected]>
[ Upstream commit 5ad74d39c51dd41b3c819f4f5396655f0629b4fd ]
The current definition of 2W burst length is invalid. This patch fixes it. Current downstream DEU driver doesn't use DMA. An incorrect burst length value doesn't cause any errors. This patch also adds other burst length values.
--- arch/mips/lantiq/xway/dma.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/mips/lantiq/xway/dma.c +7 -2
@@ -40,7 +40,11 @@#define DMA_IRQ_ACK 0x7e/* IRQ status register */ #define DMA_POLL BIT(31)/* turn on channel polling */ #define DMA_CLK_DIV4 BIT(6)/* polling clock divider */ -#define DMA_2W_BURST BIT(1)/* 2 word burst length */ +#define DMA_PCTRL_2W_BURST 0x1/* 2 word burst length */ +#define DMA_PCTRL_4W_BURST 0x2/* 4 word burst length */ +#define DMA_PCTRL_8W_BURST 0x3/* 8 word burst length */ +#define DMA_TX_BURST_SHIFT 4/* tx burst shift */ +#define DMA_RX_BURST_SHIFT 2/* rx burst shift */ #define DMA_ETOP_ENDIANNESS (0xf << 8)/* endianness swap etop channels */ #define DMA_WEIGHT (BIT(17) | BIT(16))/* default channel wheight */
@@ -191,7 +195,8 @@ ltq_dma_init_port(int p)break ;case DMA_PORT_DEU : -ltq_dma_w32 ((DMA_2W_BURST <<4 ) | (DMA_2W_BURST <<2 ), +ltq_dma_w32 ((DMA_PCTRL_2W_BURST <<DMA_TX_BURST_SHIFT ) | + (DMA_PCTRL_2W_BURST <<DMA_RX_BURST_SHIFT ),LTQ_DMA_PCTRL );break ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 265/575 objtool: Add xen_start_kernel() to noreturn list
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit c26acfbbfbc2ae4167e33825793e85e1a53058d8 ]
xen_start_kernel() doesn't return. Annotate it as such so objtool can follow the code flow.
--- tools/objtool/check.c | 1 + 1 file changed, 1 insertion(+)
tools/objtool/check.c +1 -0
@@ -156,6 +156,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"machine_real_restart" ,"rewind_stack_do_exit" ,"kunit_try_catch_throw" , + "xen_start_kernel", };if (!func)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 266/575 x86/xen: Mark cpu_bringup_and_idle() as dead_end_function
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 9af9dcf11bda3e2c0e24c1acaacb8685ad974e93 ]
The asm_cpu_bringup_and_idle() function is required to push the return value on the stack in order to make ORC happy, but the only reason objtool doesn't complain is because of a happy accident.
The thing is that asm_cpu_bringup_and_idle() doesn't return, so validate_branch() never terminates and falls through to the next function, which in the normal case is the hypercall_page. And that, as it happens, is 4095 NOPs and a RET.
Make asm_cpu_bringup_and_idle() terminate on it's own, by making the function it calls as a dead-end. This way we no longer rely on what code happens to come after.
--- tools/objtool/check.c | 1 + 1 file changed, 1 insertion(+)
tools/objtool/check.c +1 -0
@@ -157,6 +157,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"rewind_stack_do_exit" ,"kunit_try_catch_throw" ,"xen_start_kernel" , + "cpu_bringup_and_idle", };if (!func)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 267/575 objtool: Fix static_call list generation
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit a958c4fea768d2c378c89032ab41d38da2a24422 ]
Currently, objtool generates tail call entries in add_jump_destination() but waits until validate_branch() to generate the regular call entries. Move these to add_call_destination() for consistency.
--- tools/objtool/check.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
tools/objtool/check.c +12 -5
@@ -954,6 +954,11 @@ static int add_call_destinations(struct objtool_file *file) }else insn->call_dest = reloc->sym; +if (insn->call_dest && insn->call_dest->static_call_tramp) { +list_add_tail (&insn->static_call_node, + &file->static_call_list); + } +/* * Many compilers cannot disable KCOV with a function attribute * so they need a little help, NOP out any KCOV calls from noinstr
@@ -1668,6 +1673,9 @@ static int decode_sections(struct objtool_file *file)if (ret)return ret; +/* +* Must be before add_{jump_call}_destination. +*/ ret =read_static_call_tramps (file);if (ret)return ret;
@@ -1680,6 +1688,10 @@ static int decode_sections(struct objtool_file *file)if (ret)return ret; +/* +* Must be before add_call_destination(); it changes INSN_CALL to +* INSN_JUMP. +*/ ret =read_intra_function_calls (file);if (ret)return ret;
@@ -2534,11 +2546,6 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,if (dead_end_function (file, insn->call_dest))return 0 ; -if (insn->type ==INSN_CALL && insn->call_dest->static_call_tramp) { -list_add_tail (&insn->static_call_node, - &file->static_call_list); - } -break ;case INSN_JUMP_CONDITIONAL :
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 268/575 drm/v3d: fix wait for TMU write combiner flush
In reply to Greg Kroah-HartmanFrom: Iago Toral Quiroga <[email protected]>
[ Upstream commit e4f868191138975f2fdf2f37c11318b47db4acc9 ]
The hardware sets the TMUWCF bit back to 0 when the TMU write combiner flush completes so we should be checking for that instead of the L2TFLS bit.
v2 (Melissa Wen):
- Add Signed-off-by and Fixes tags.
- Change the error message for the timeout to be more clear.
Fixes spurious Vulkan CTS failures in:
dEQP-VK.binding_model.descriptorset_random.*
--- drivers/gpu/drm/v3d/v3d_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/v3d/v3d_gem.c +2 -2
@@ -195,8 +195,8 @@ v3d_clean_caches(struct v3d_dev *v3d)V3D_CORE_WRITE (core,V3D_CTL_L2TCACTL ,V3D_L2TCACTL_TMUWCF );if (wait_for (!(V3D_CORE_READ (core,V3D_CTL_L2TCACTL ) & -V3D_L2TCACTL_L2TFLS ),100 )) { -DRM_ERROR ("Timeout waiting for L1T write combiner flush\n" ); +V3D_L2TCACTL_TMUWCF ),100 )) { +DRM_ERROR ("Timeout waiting for TMU write combiner flush\n" ); }mutex_lock (&v3d->cache_clean_lock);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 269/575 virtio-gpu: fix possible memory allocation failure
In reply to Greg Kroah-HartmanFrom: liuyuntao <[email protected]>
[ Upstream commit 5bd4f20de8acad37dbb3154feb34dbc36d506c02 ]
When kmem_cache_zalloc in virtio_gpu_get_vbuf fails, it will return an error code. But none of its callers checks this error code, and a core dump will take place.
Considering many of its callers can't handle such error, I add a __GFP_NOFAIL flag when calling kmem_cache_zalloc to make sure it won't fail, and delete those unused error handlings.
--- drivers/gpu/drm/virtio/virtgpu_vq.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/gpu/drm/virtio/virtgpu_vq.c +1 -7
@@ -91,9 +91,7 @@ virtio_gpu_get_vbuf(struct virtio_gpu_device *vgdev, {struct virtio_gpu_vbuffer *vbuf; - vbuf =kmem_cache_zalloc (vgdev->vbufs,GFP_KERNEL ); -if (!vbuf) -return ERR_PTR (-ENOMEM ); + vbuf =kmem_cache_zalloc (vgdev->vbufs,GFP_KERNEL | __GFP_NOFAIL);BUG_ON (size >MAX_INLINE_CMD_SIZE || size <sizeof (struct virtio_gpu_ctrl_hdr ));
@@ -147,10 +145,6 @@ static void *virtio_gpu_alloc_cmd_resp(struct virtio_gpu_device *vgdev, vbuf =virtio_gpu_get_vbuf (vgdev, cmd_size, resp_size, resp_buf, cb); -if (IS_ERR (vbuf)) { - *vbuffer_p =NULL ; -return ERR_CAST (vbuf); - } *vbuffer_p = vbuf;return (struct virtio_gpu_command *)vbuf->buf; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 270/575 lockdep: Let lock_is_held_type() detect recursive read as read
In reply to Greg Kroah-HartmanFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 2507003a1d10917c9158077bf6030719d02c941e ]
lock_is_held_type(, 1) detects acquired read locks. It only recognized locks acquired with lock_acquire_shared(). Read locks acquired with lock_acquire_shared_recursive() are not recognized because a `2' is stored as the read value.
Rework the check to additionally recognise lock's read value one and two as a read held lock.
--- kernel/locking/lockdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/lockdep.c +1 -1
@@ -5303,7 +5303,7 @@ int __lock_is_held(const struct lockdep_map *lock, int read)struct held_lock *hlock = curr->held_locks + i;if (match_held_lock (hlock, lock)) { -if (read ==-1 || hlock->read == read) +if (read ==-1 || !!hlock->read == read)return 1 ;return 0 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 271/575 net: net_namespace: Fix undefined member in key_remove_domain()
In reply to Greg Kroah-HartmanFrom: Yajun Deng <[email protected]>
[ Upstream commit aed0826b0cf2e488900ab92193893e803d65c070 ]
The key_domain member in struct net only exists if we define CONFIG_KEYS. So we should add the define when we used key_domain.
--- net/core/net_namespace.c | 4 ++++ 1 file changed, 4 insertions(+)
net/core/net_namespace.c +4 -0
@@ -486,7 +486,9 @@ struct net *copy_net_ns(unsigned long flags,if (rv <0 ) { put_userns: +#ifdef CONFIG_KEYS key_remove_domain (net->key_domain); +#endif put_user_ns (user_ns);net_drop_ns (net); dec_ucounts:
@@ -618,7 +620,9 @@ static void cleanup_net(struct work_struct *work)list_for_each_entry_safe (net, tmp, &net_exit_list, exit_list) {list_del_init (&net->exit_list);dec_net_namespaces (net->ucounts); +#ifdef CONFIG_KEYS key_remove_domain (net->key_domain); +#endif put_user_ns (net->user_ns);net_drop_ns (net); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 272/575 cgroup: Make rebind_subsystems() disable v2 controllers all at once
In reply to Greg Kroah-HartmanFrom: Waiman Long <[email protected]>
[ Upstream commit 7ee285395b211cad474b2b989db52666e0430daf ]
It was found that the following warning was displayed when remounting controllers from cgroup v2 to v1:
[ 8042.997778] WARNING: CPU: 88 PID: 80682 at kernel/cgroup/cgroup.c:3130 cgroup_apply_control_disable+0x158/0x190 : [ 8043.091109] RIP: 0010:cgroup_apply_control_disable+0x158/0x190 [ 8043.096946] Code: ff f6 45 54 01 74 39 48 8d 7d 10 48 c7 c6 e0 46 5a a4 e8 7b 67 33 00 e9 41 ff ff ff 49 8b 84 24 e8 01 00 00 0f b7 40 08 eb 95 <0f> 0b e9 5f ff ff ff 48 83 c4 08 5b 5d 41 5c 41 5d 41 5e 41 5f c3 [ 8043.115692] RSP: 0018:ffffba8a47c23d28 EFLAGS: 00010202 [ 8043.120916] RAX: 0000000000000036 RBX: ffffffffa624ce40 RCX: 000000000000181a [ 8043.128047] RDX: ffffffffa63c43e0 RSI: ffffffffa63c43e0 RDI: ffff9d7284ee1000 [ 8043.135180] RBP: ffff9d72874c5800 R08: ffffffffa624b090 R09: 0000000000000004 [ 8043.142314] R10: ffffffffa624b080 R11: 0000000000002000 R12: ffff9d7284ee1000 [ 8043.149447] R13: ffff9d7284ee1000 R14: ffffffffa624ce70 R15: ffffffffa6269e20 [ 8043.156576] FS: 00007f7747cff740(0000) GS:ffff9d7a5fc00000(0000) knlGS:0000000000000000 [ 8043.164663] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 8043.170409] CR2: 00007f7747e96680 CR3: 0000000887d60001 CR4: 00000000007706e0 [ 8043.177539] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 8043.184673] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 8043.191804] PKRU: 55555554 [ 8043.194517] Call Trace: [ 8043.196970] rebind_subsystems+0x18c/0x470 [ 8043.201070] cgroup_setup_root+0x16c/0x2f0 [ 8043.205177] cgroup1_root_to_use+0x204/0x2a0 [ 8043.209456] cgroup1_get_tree+0x3e/0x120 [ 8043.213384] vfs_get_tree+0x22/0xb0 [ 8043.216883] do_new_mount+0x176/0x2d0 [ 8043.220550] __x64_sys_mount+0x103/0x140 [ 8043.224474] do_syscall_64+0x38/0x90 [ 8043.228063] entry_SYSCALL_64_after_hwframe+0x44/0xae
It was caused by the fact that rebind_subsystem() disables controllers to be rebound one by one. If more than one disabled controllers are originally from the default hierarchy, it means that cgroup_apply_control_disable() will be called multiple times for the same default hierarchy. A controller may be killed by css_kill() in the first round. In the second round, the killed controller may not be completely dead yet leading to the warning.
To avoid this problem, we collect all the ssid's of controllers that needed to be disabled from the default hierarchy and then disable them in one go instead of one by one.
--- kernel/cgroup/cgroup.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)
kernel/cgroup/cgroup.c +27 -4
@@ -1711,6 +1711,7 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)struct cgroup *dcgrp = &dst_root->cgrp;struct cgroup_subsys *ss;int ssid, i, ret; +u16 dfl_disable_ss_mask =0 ;lockdep_assert_held (&cgroup_mutex);
@@ -1727,8 +1728,28 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)/* can't move between two non-dummy roots either */ if (ss->root != &cgrp_dfl_root && dst_root != &cgrp_dfl_root)return -EBUSY ; + +/* +* Collect ssid's that need to be disabled from default +* hierarchy. +*/ +if (ss->root == &cgrp_dfl_root) + dfl_disable_ss_mask |=1 << ssid; + }while_each_subsys_mask (); +if (dfl_disable_ss_mask) { +struct cgroup *scgrp = &cgrp_dfl_root.cgrp; + +/* +* Controllers from default hierarchy that need to be rebound +* are all disabled together in one go. +*/ + cgrp_dfl_root.subsys_mask &= ~dfl_disable_ss_mask; +WARN_ON (cgroup_apply_control (scgrp)); +cgroup_finalize_control (scgrp,0 ); + } + do_each_subsys_mask(ss, ssid, ss_mask) {struct cgroup_root *src_root = ss->root;struct cgroup *scgrp = &src_root->cgrp;
@@ -1737,10 +1758,12 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)WARN_ON (!css ||cgroup_css (dcgrp, ss)); -/* disable from the source */ - src_root->subsys_mask &= ~(1 << ssid); -WARN_ON (cgroup_apply_control (scgrp)); -cgroup_finalize_control (scgrp,0 ); +if (src_root != &cgrp_dfl_root) { +/* disable from the source */ + src_root->subsys_mask &= ~(1 << ssid); +WARN_ON (cgroup_apply_control (scgrp)); +cgroup_finalize_control (scgrp,0 ); + }/* rebind */ RCU_INIT_POINTER (scgrp->subsys[ssid],NULL );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 273/575 wcn36xx: Fix Antenna Diversity Switching
In reply to Greg Kroah-HartmanFrom: Bryan O'Donoghue <[email protected]>
[ Upstream commit 701668d3bfa03dabc5095fc383d5315544ee5b31 ]
We have been tracking a strange bug with Antenna Diversity Switching (ADS) on wcn3680b for a while.
ADS is configured like this:
A. Via a firmware configuration table baked into the NV area.
1. Defines if ADS is enabled.
2. Defines which GPIOs are connected to which antenna enable pin.
3. Defines which antenna/GPIO is primary and which is secondary.
B. WCN36XX_CFG_VAL(ANTENNA_DIVERSITY, N)
N is a bitmask of available antenna.
Setting N to 3 indicates a bitmask of enabled antenna (1 | 2).
Obviously then we can set N to 1 or N to 2 to fix to a particular antenna and disable antenna diversity.
C. WCN36XX_CFG_VAL(ASD_PROBE_INTERVAL, XX)
XX is the number of beacons between each antenna RSSI check. Setting this value to 50 means, every 50 received beacons, run the ADS algorithm.
D. WCN36XX_CFG_VAL(ASD_TRIGGER_THRESHOLD, YY)
YY is a two's complement integer which specifies the RSSI decibel threshold below which ADS will run.
We default to -60db here, meaning a measured RSSI <= -60db will trigger an ADS probe.
E. WCN36XX_CFG_VAL(ASD_RTT_RSSI_HYST_THRESHOLD, Z)
Z is a hysteresis value, indicating a delta which the RSSI must exceed for the antenna switch to be valid.
For example if HYST_THRESHOLD == 3 AntennaId1-RSSI == -60db and AntennaId-2-RSSI == -58db then firmware will not switch antenna. The threshold needs to be -57db or better to satisfy the criteria.
F. A firmware feature bit also exists ANTENNA_DIVERSITY_SELECTION.
This feature bit is used by the firmware to report if ANTENNA_DIVERSITY_SELECTION is supported. The host is not required to toggle this bit to enable or disable ADS.
ADS works like this:
A. Every XX beacons the firmware switches to or remains on the primary
antenna.
B. The firmware then sends a Request-To-Send (RTS) packet to the AP.
C. The firmware waits for a Clear-To-Send (CTS) response from the AP.
D. The firmware then notes the received RSSI on the CTS packet.
E. The firmware then repeats steps A-D on the secondary antenna.
F. Subsequently if the RSSI on the measured antenna is better than
ASD_TRIGGER_THRESHOLD + the active antenna's RSSI then the measured antenna becomes the active antenna.
G. If RSSI rises past ASD_TRIGGER_THRESHOLD then ADS doesn't run at
all even if there is a substantially better RSSI on the alternative antenna.
What we have been observing is that the RTS packet is being sent but the MAC address is a byte-swapped version of the target MAC. The ADS/RTS MAC is corrupted only when the link is encrypted, if the AP is open the RTS MAC is correct. Similarly if we configure the firmware to an RTS/CTS sequence for regular data - the transmitted RTS MAC is correctly formatted.
Internally the wcn36xx firmware uses the indexes in the SMD commands to populate and extract data from specific entries in an STA lookup table. The AP's MAC appears a number of times in different indexes within this lookup table, so the MAC address extracted for the data-transmit RTS and the MAC address extracted for the ADS/RTS packet are not the same STA table index.
Our analysis indicates the relevant firmware STA table index is "bssSelfStaIdx".
There is an STA populate function responsible for formatting the MAC address of the bssSelfStaIdx including byte-swapping the MAC address.
Its clear then that the required STA populate command did not run for bssSelfStaIdx.
So taking a look at the sequence of SMD commands sent to the firmware we see the following downstream when moving from an unencrypted to encrypted BSS setup.
- WLAN_HAL_CONFIG_BSS_REQ
- WLAN_HAL_CONFIG_STA_REQ
- WLAN_HAL_SET_STAKEY_REQ
Upstream in wcn36xx we have
- WLAN_HAL_CONFIG_BSS_REQ
- WLAN_HAL_SET_STAKEY_REQ
The solution then is to add the missing WLAN_HAL_CONFIG_STA_REQ between WLAN_HAL_CONFIG_BSS_REQ and WLAN_HAL_SET_STAKEY_REQ.
No surprise WLAN_HAL_CONFIG_STA_REQ is the routine responsible for populating the STA lookup table in the firmware and once done the MAC sent by the ADS routine is in the correct byte-order.
This bug is apparent with ADS but it is also the case that any other firmware routine that depends on the "bssSelfStaIdx" would retrieve malformed data on an encrypted link.
--- drivers/net/wireless/ath/wcn36xx/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/wcn36xx/main.c +3 -1
@@ -568,12 +568,14 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,if (IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags) { sta_priv->is_data_encrypted = true;/* Reconfigure bss with encrypt_type */ -if (NL80211_IFTYPE_STATION == vif->type) +if (NL80211_IFTYPE_STATION == vif->type) {wcn36xx_smd_config_bss (wcn, vif, sta, sta->addr, true); +wcn36xx_smd_config_sta (wcn, vif, sta); + } wcn36xx_smd_set_stakey(wcn, vif_priv->encrypt_type,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 274/575 wilc1000: fix possible memory leak in cfg_scan_result()
In reply to Greg Kroah-HartmanFrom: Ajay Singh <[email protected]>
[ Upstream commit 3c719fed0f3a5e95b1d164609ecc81c4191ade70 ]
When the BSS reference holds a valid reference, it is not freed. The 'if' condition is wrong. Instead of the 'if (bss)' check, the 'if (!bss)' check is used.
The issue is solved by removing the unnecessary 'if' check because cfg80211_put_bss() already performs the NULL validation.
--- drivers/net/wireless/microchip/wilc1000/cfg80211.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/microchip/wilc1000/cfg80211.c +1 -2
@@ -129,8 +129,7 @@ static void cfg_scan_result(enum scan_event scan_event, info->frame_len, (s32 )info->rssi *100 , GFP_KERNEL); -if (!bss) -cfg80211_put_bss (wiphy, bss); +cfg80211_put_bss (wiphy, bss); }else if (scan_event ==SCAN_EVENT_DONE ) {mutex_lock (&priv->scan_req_lock);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 275/575 Bluetooth: btmtkuart: fix a memleak in mtk_hci_wmt_sync
In reply to Greg Kroah-HartmanFrom: Dinghao Liu <[email protected]>
[ Upstream commit 3e5f2d90c28f9454e421108554707620bc23269d ]
bdev->evt_skb will get freed in the normal path and one error path of mtk_hci_wmt_sync, while the other error paths do not free it, which may cause a memleak. This bug is suggested by a static analysis tool, please advise.
--- drivers/bluetooth/btmtkuart.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/bluetooth/btmtkuart.c +8 -5
@@ -158,8 +158,10 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev,int err; hlen =sizeof (*hdr) + wmt_params->dlen; -if (hlen >255 ) -return -EINVAL ; +if (hlen >255 ) { + err = -EINVAL ; + goto err_free_skb; + } hdr = (struct mtk_wmt_hdr *)&wc; hdr->dir =1 ;
@@ -173,7 +175,7 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev, err =__hci_cmd_send (hdev,0xfc6f , hlen, &wc);if (err <0 ) {clear_bit (BTMTKUART_TX_WAIT_VND_EVT , &bdev->tx_state); -return err; + goto err_free_skb; }/* The vendor specific WMT commands are all answered by a vendor
@@ -190,13 +192,14 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev,if (err == -EINTR ) {bt_dev_err (hdev,"Execution of wmt command interrupted" );clear_bit (BTMTKUART_TX_WAIT_VND_EVT , &bdev->tx_state); -return err; + goto err_free_skb; }if (err) {bt_dev_err (hdev,"Execution of wmt command timed out" );clear_bit (BTMTKUART_TX_WAIT_VND_EVT , &bdev->tx_state); -return -ETIMEDOUT ; + err = -ETIMEDOUT ; + goto err_free_skb; }/* Parse and handle the return WMT event */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 276/575 crypto: caam - disable pkc for non-E SoCs
In reply to Greg Kroah-HartmanFrom: Michael Walle <[email protected]>
[ Upstream commit f20311cc9c58052e0b215013046cbf390937910c ]
On newer CAAM versions, not all accelerators are disabled if the SoC is a non-E variant. While the driver checks most of the modules for availability, there is one - PKHA - which sticks out. On non-E variants it is still reported as available, that is the number of instances is non-zero, but it has limited functionality. In particular it doesn't support encryption and decryption, but just signing and verifying. This is indicated by a bit in the PKHA_MISC field. Take this bit into account if we are checking for availability.
This will the following error:
[ 8.167817] caam_jr 8020000.jr: 20000b0f: CCB: desc idx 11: : Invalid CHA selected.
Tested on an NXP LS1028A (non-E) SoC.
--- drivers/crypto/caam/caampkc.c | 19 +++++++++++++++---- drivers/crypto/caam/regs.h | 3 +++ 2 files changed, 18 insertions(+), 4 deletions(-)
drivers/crypto/caam/caampkc.c +15 -4
@@ -1152,16 +1152,27 @@ static struct caam_akcipher_alg caam_rsa = {int caam_pkc_init (struct device *ctrldev) {struct caam_drv_private *priv =dev_get_drvdata (ctrldev); -u32 pk_inst; +u32 pk_inst, pkha;int err; init_done = false;/* Determine public key hardware accelerator presence. */ -if (priv->era <10 ) +if (priv->era <10 ) { pk_inst = (rd_reg32 (&priv->ctrl->perfmon.cha_num_ls) &CHA_ID_LS_PK_MASK ) >>CHA_ID_LS_PK_SHIFT ; -else - pk_inst =rd_reg32 (&priv->ctrl->vreg.pkha) &CHA_VER_NUM_MASK ; + }else { + pkha =rd_reg32 (&priv->ctrl->vreg.pkha); + pk_inst = pkha &CHA_VER_NUM_MASK ; + +/* +* Newer CAAMs support partially disabled functionality. If this is the +* case, the number is non-zero, but this bit is set to indicate that +* no encryption or decryption is supported. Only signing and verifying +* is supported. +*/ +if (pkha &CHA_VER_MISC_PKHA_NO_CRYPT ) + pk_inst =0 ; + }/* Do not register algorithms if PKHA is not present. */ if (!pk_inst)
drivers/crypto/caam/regs.h +3 -0
@@ -322,6 +322,9 @@ struct version_regs {/* CHA Miscellaneous Information - AESA_MISC specific */ #define CHA_VER_MISC_AES_GCM BIT(1 + CHA_VER_MISC_SHIFT) +/* CHA Miscellaneous Information - PKHA_MISC specific */ +#define CHA_VER_MISC_PKHA_NO_CRYPT BIT(7 + CHA_VER_MISC_SHIFT) +/* * caam_perfmon - Performance Monitor/Secure Memory Status/ * CAAM Global Status/Component Version IDs
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 277/575 rxrpc: Fix _usecs_to_jiffies() by using usecs_to_jiffies()
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit acde891c243c1ed85b19d4d5042bdf00914f5739 ]
Directly using _usecs_to_jiffies() might be unsafe, so it's better to use usecs_to_jiffies() instead.
Because we can see that the result of _usecs_to_jiffies() could be larger than MAX_JIFFY_OFFSET values without the check of the input.
--- net/rxrpc/rtt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rxrpc/rtt.c +1 -1
@@ -22,7 +22,7 @@ static u32 rxrpc_rto_min_us(struct rxrpc_peer *peer)static u32 __rxrpc_set_rto (const struct rxrpc_peer *peer) { -return _usecs_to_jiffies ((peer->srtt_us >>3 ) + peer->rttvar_us); +return usecs_to_jiffies ((peer->srtt_us >>3 ) + peer->rttvar_us); }static u32 rxrpc_bound_rto (u32 rto)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 278/575 net: dsa: rtl8366rb: Fix off-by-one bug
In reply to Greg Kroah-HartmanFrom: Linus Walleij <[email protected]>
[ Upstream commit 5f5f12f5d4b108399130bb5c11f07765851d9cdb ]
The max VLAN number with non-4K VLAN activated is 15, and the range is 0..15. Not 16.
The impact should be low since we by default have 4K VLAN and thus have 4095 VLANs to play with in this switch. There will not be a problem unless the code is rewritten to only use 16 VLANs.
--- drivers/net/dsa/rtl8366rb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/rtl8366rb.c +1 -1
@@ -1343,7 +1343,7 @@ static int rtl8366rb_set_mc_index(struct realtek_smi *smi, int port, int index)static bool rtl8366rb_is_vlan_valid (struct realtek_smi *smi,unsigned int vlan) { -unsigned int max =RTL8366RB_NUM_VLANS ; +unsigned int max =RTL8366RB_NUM_VLANS -1 ;if (smi->vlan4k_enabled) max =RTL8366RB_NUM_VIDS -1 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 279/575 ath11k: fix some sleeping in atomic bugs
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit aadf7c81a0771b8f1c97dabca6a48bae1b387779 ]
The ath11k_dbring_bufs_replenish() and ath11k_dbring_fill_bufs() take a "gfp" parameter but they since they take spinlocks, the allocations they do have to be atomic. This causes a bug because ath11k_dbring_buf_setup passes GFP_KERNEL for the gfp flags.
The fix is to use GFP_ATOMIC and remove the unused parameters.
--- drivers/net/wireless/ath/ath11k/dbring.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath11k/dbring.c +7 -9
@@ -8,8 +8,7 @@static int ath11k_dbring_bufs_replenish (struct ath11k *ar,struct ath11k_dbring *ring, -struct ath11k_dbring_element *buff, -gfp_t gfp) +struct ath11k_dbring_element *buff) {struct ath11k_base *ab = ar->ab;struct hal_srng *srng;
@@ -35,7 +34,7 @@ static int ath11k_dbring_bufs_replenish(struct ath11k *ar, goto err;spin_lock_bh (&ring->idr_lock); - buf_id =idr_alloc (&ring->bufs_idr, buff,0 , ring->bufs_max, gfp); + buf_id =idr_alloc (&ring->bufs_idr, buff,0 , ring->bufs_max,GFP_ATOMIC );spin_unlock_bh (&ring->idr_lock);if (buf_id <0 ) { ret = -ENOBUFS ;
@@ -72,8 +71,7 @@ err: }static int ath11k_dbring_fill_bufs (struct ath11k *ar, -struct ath11k_dbring *ring, -gfp_t gfp) +struct ath11k_dbring *ring) {struct ath11k_dbring_element *buff;struct hal_srng *srng;
@@ -92,11 +90,11 @@ static int ath11k_dbring_fill_bufs(struct ath11k *ar, size =sizeof (*buff) + ring->buf_sz + align -1 ;while (num_remain >0 ) { - buff =kzalloc (size, gfp); + buff =kzalloc (size,GFP_ATOMIC );if (!buff)break ; - ret =ath11k_dbring_bufs_replenish (ar, ring, buff, gfp); + ret =ath11k_dbring_bufs_replenish (ar, ring, buff);if (ret) {ath11k_warn (ar->ab,"failed to replenish db ring num_remain %d req_ent %d\n" , num_remain, req_entries);
@@ -176,7 +174,7 @@ int ath11k_dbring_buf_setup(struct ath11k *ar, ring->hp_addr =ath11k_hal_srng_get_hp_addr (ar->ab, srng); ring->tp_addr =ath11k_hal_srng_get_tp_addr (ar->ab, srng); - ret =ath11k_dbring_fill_bufs (ar, ring,GFP_KERNEL ); + ret =ath11k_dbring_fill_bufs (ar, ring);return ret; }
@@ -322,7 +320,7 @@ int ath11k_dbring_buffer_release_event(struct ath11k_base *ab, }memset (buff,0 , size); -ath11k_dbring_bufs_replenish (ar, ring, buff,GFP_ATOMIC ); +ath11k_dbring_bufs_replenish (ar, ring, buff); }spin_unlock_bh (&srng->lock);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 280/575 ath11k: Avoid race during regd updates
In reply to Greg Kroah-HartmanFrom: Sriram R <[email protected]>
[ Upstream commit 1db2b0d0a39102238fcbf9092cefa65a710642e9 ]
Whenever ath11k is bootup with a user country already set, cfg80211 notifies this country info to ath11k soon after registration, where the notification is sent to the firmware for fetching the rules of this user country input.
Multiple race conditions could be seen in this scenario where a new request is either lost as pointed in [1] or a new regd overwrites the default regd provided by the firmware during bootup. Note that, the default regd is used for intersection purpose and hence it should not be overwritten.
The main reason as pointed by [1] is the usage of ATH11K_FLAG_REGISTERED flag which is updated after completion of core registration, whereas the reg notification from cfg80211 and wmi events for the corresponding request can happen much before that. Since the ATH11K_FLAG_REGISTERED is currently used to determine if the event containing reg rules belong to default regd or for user request, there is a possibility of the default regd getting overwritten.
Since the default reg rules will be received only once per pdev on firmware load, the above flag based check can be replaced with a check to see if default_regd is already set, so that we can now always update the new_regd. Also if the new_regd is set, this will be always used to update the reg rules for the registered phy.
[1] https://patchwork.kernel.org/project/linux-wireless/patch/1829665.1PRlr7bOQj@ripper/
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-01460-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/mac.c | 2 +- drivers/net/wireless/ath/ath11k/reg.c | 11 ++++++----- drivers/net/wireless/ath/ath11k/reg.h | 2 +- drivers/net/wireless/ath/ath11k/wmi.c | 16 ++++++---------- 4 files changed, 14 insertions(+), 17 deletions(-)
drivers/net/wireless/ath/ath11k/mac.c +1 -1
@@ -6320,7 +6320,7 @@ static int __ath11k_mac_register(struct ath11k *ar) ar->hw->wiphy->interface_modes &= ~BIT (NL80211_IFTYPE_MONITOR );/* Apply the regd received during initialization */ - ret =ath11k_regd_update (ar, true); + ret =ath11k_regd_update (ar);if (ret) {ath11k_err (ar->ab,"ath11k regd update failed: %d\n" , ret); goto err_unregister_hw;
drivers/net/wireless/ath/ath11k/reg.c +6 -5
@@ -198,7 +198,7 @@ static void ath11k_copy_regd(struct ieee80211_regdomain *regd_orig, sizeof(struct ieee80211_reg_rule)); } -int ath11k_regd_update (struct ath11k *ar,bool init) +int ath11k_regd_update (struct ath11k *ar) {struct ieee80211_regdomain *regd, *regd_copy =NULL ;int ret, regd_len, pdev_id;
@@ -209,7 +209,10 @@ int ath11k_regd_update(struct ath11k *ar, bool init)spin_lock_bh (&ab->base_lock); -if (init) { +/* Prefer the latest regd update over default if it's available */ +if (ab->new_regd[pdev_id]) { + regd = ab->new_regd[pdev_id]; + }else {/* Apply the regd received during init through * WMI_REG_CHAN_LIST_CC event. In case of failure to * receive the regd, initialize with a default world
@@ -222,8 +225,6 @@ int ath11k_regd_update(struct ath11k *ar, bool init) "failed to receive default regd during init\n"); regd = (struct ieee80211_regdomain *)&ath11k_world_regd; } - }else { - regd = ab->new_regd[pdev_id]; }if (!regd) {
@@ -680,7 +681,7 @@ void ath11k_regd_update_work(struct work_struct *work) regd_update_work);int ret; - ret =ath11k_regd_update (ar, false); + ret =ath11k_regd_update (ar);if (ret) {/* Firmware has already moved to the new regd. We need * to maintain channel consistency across FW, Host driver
drivers/net/wireless/ath/ath11k/reg.h +1 -1
@@ -30,6 +30,6 @@ void ath11k_regd_update_work(struct work_struct *work);struct ieee80211_regdomain *ath11k_reg_build_regd (struct ath11k_base *ab,struct cur_regulatory_info *reg_info,bool intersect); -int ath11k_regd_update (struct ath11k *ar,bool init); +int ath11k_regd_update (struct ath11k *ar);int ath11k_reg_update_chan_list (struct ath11k *ar);#endif
drivers/net/wireless/ath/ath11k/wmi.c +6 -10
@@ -5410,10 +5410,10 @@ static int ath11k_reg_chan_list_event(struct ath11k_base *ab, struct sk_buff *sk }spin_lock (&ab->base_lock); -if (test_bit (ATH11K_FLAG_REGISTERED , &ab->dev_flags)) { -/* Once mac is registered, ar is valid and all CC events from -* fw is considered to be received due to user requests -* currently. +if (ab->default_regd[pdev_idx]) { +/* The initial rules from FW after WMI Init is to build +* the default regd. From then on, any rules updated for +* the pdev could be due to user reg changes. * Free previously built regd before assigning the newly * generated regd to ar. NULL pointer handling will be * taken care by kfree itself.
@@ -5423,13 +5423,9 @@ static int ath11k_reg_chan_list_event(struct ath11k_base *ab, struct sk_buff *sk ab->new_regd[pdev_idx] = regd;ieee80211_queue_work (ar->hw, &ar->regd_update_work); }else { -/* Multiple events for the same *ar is not expected. But we -* can still clear any previously stored default_regd if we -* are receiving this event for the same radio by mistake. -* NULL pointer handling will be taken care by kfree itself. +/* This regd would be applied during mac registration and is +* held constant throughout for regd intersection purpose */ -kfree (ab->default_regd[pdev_idx]); -/* This regd would be applied during mac registration */ ab->default_regd[pdev_idx] = regd; } ab->dfs_region = reg_info->dfs_region;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 281/575 ath11k: fix packet drops due to incorrect 6 GHz freq value in rx status
In reply to Greg Kroah-HartmanFrom: Pradeep Kumar Chitrapu <[email protected]>
[ Upstream commit 9d6ae1f5cf733c0e8d7f904c501fd015c4b9f0f4 ]
Frequency in rx status is being filled incorrectly in the 6 GHz band as channel number received is invalid in this case which is causing packet drops. So fix that.
--- drivers/net/wireless/ath/ath11k/dp_rx.c | 9 ++++++--- drivers/net/wireless/ath/ath11k/wmi.c | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath11k/dp_rx.c +6 -3
@@ -2303,8 +2303,10 @@ static void ath11k_dp_rx_h_ppdu(struct ath11k *ar, struct hal_rx_desc *rx_desc, channel_num =ath11k_dp_rx_h_msdu_start_freq (rx_desc); center_freq =ath11k_dp_rx_h_msdu_start_freq (rx_desc) >>16 ; -if (center_freq >=5935 && center_freq <=7105 ) { +if (center_freq >=ATH11K_MIN_6G_FREQ && + center_freq <=ATH11K_MAX_6G_FREQ ) { rx_status->band =NL80211_BAND_6GHZ ; + rx_status->freq = center_freq; }else if (channel_num >=1 && channel_num <=14 ) { rx_status->band =NL80211_BAND_2GHZ ; }else if (channel_num >=36 && channel_num <=173 ) {
@@ -2322,8 +2324,9 @@ static void ath11k_dp_rx_h_ppdu(struct ath11k *ar, struct hal_rx_desc *rx_desc, rx_desc, sizeof(struct hal_rx_desc)); } - rx_status->freq =ieee80211_channel_to_frequency (channel_num, - rx_status->band); +if (rx_status->band !=NL80211_BAND_6GHZ ) + rx_status->freq =ieee80211_channel_to_frequency (channel_num, + rx_status->band);ath11k_dp_rx_h_rate (ar, rx_desc, rx_status); }
drivers/net/wireless/ath/ath11k/wmi.c +7 -3
@@ -5668,8 +5668,10 @@ static void ath11k_mgmt_rx_event(struct ath11k_base *ab, struct sk_buff *skb)if (rx_ev.status &WMI_RX_STATUS_ERR_MIC ) status->flag |=RX_FLAG_MMIC_ERROR ; -if (rx_ev.chan_freq >=ATH11K_MIN_6G_FREQ ) { +if (rx_ev.chan_freq >=ATH11K_MIN_6G_FREQ && + rx_ev.chan_freq <=ATH11K_MAX_6G_FREQ ) { status->band =NL80211_BAND_6GHZ ; + status->freq = rx_ev.chan_freq; }else if (rx_ev.channel >=1 && rx_ev.channel <=14 ) { status->band =NL80211_BAND_2GHZ ; }else if (rx_ev.channel >=36 && rx_ev.channel <=ATH11K_MAX_5G_CHAN ) {
@@ -5690,8 +5692,10 @@ static void ath11k_mgmt_rx_event(struct ath11k_base *ab, struct sk_buff *skb) sband = &ar->mac.sbands[status->band]; - status->freq =ieee80211_channel_to_frequency (rx_ev.channel, - status->band); +if (status->band !=NL80211_BAND_6GHZ ) + status->freq =ieee80211_channel_to_frequency (rx_ev.channel, + status->band); + status->signal = rx_ev.snr +ATH11K_DEFAULT_NOISE_FLOOR ; status->rate_idx =ath11k_mac_bitrate_to_idx (sband, rx_ev.rate /100 );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 282/575 ath11k: Fix memory leak in ath11k_qmi_driver_event_work
In reply to Greg Kroah-HartmanFrom: Baochen Qiang <[email protected]>
[ Upstream commit 72de799aa9e3e064b35238ef053d2f0a49db055a ]
The buffer pointed to by event is not freed in case ATH11K_FLAG_UNREGISTERING bit is set, resulting in memory leak, so fix it.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
--- drivers/net/wireless/ath/ath11k/qmi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/qmi.c +3 -1
@@ -2616,8 +2616,10 @@ static void ath11k_qmi_driver_event_work(struct work_struct *work)list_del (&event->list);spin_unlock (&qmi->event_lock); -if (test_bit (ATH11K_FLAG_UNREGISTERING , &ab->dev_flags)) +if (test_bit (ATH11K_FLAG_UNREGISTERING , &ab->dev_flags)) { +kfree (event);return ; + }switch (event->type) {case ATH11K_QMI_EVENT_SERVER_ARRIVE :
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 283/575 ath10k: Fix missing frame timestamp for beacon/probe-resp
In reply to Greg Kroah-HartmanFrom: Loic Poulain <[email protected]>
[ Upstream commit e6dfbc3ba90cc2b619229be56b485f085a0a8e1c ]
When receiving a beacon or probe response, we should update the boottime_ns field which is the timestamp the frame was received at. (cf mac80211.h)
This fixes a scanning issue with Android since it relies on this timestamp to determine when the AP has been seen for the last time (via the nl80211 BSS_LAST_SEEN_BOOTTIME parameter).
--- drivers/net/wireless/ath/ath10k/wmi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath10k/wmi.c +4 -0
@@ -2610,6 +2610,10 @@ int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)if (ieee80211_is_beacon (hdr->frame_control))ath10k_mac_handle_beacon (ar, skb); +if (ieee80211_is_beacon (hdr->frame_control) || +ieee80211_is_probe_resp (hdr->frame_control)) + status->boottime_ns =ktime_get_boottime_ns (); + ath10k_dbg(ar, ATH10K_DBG_MGMT, "event mgmt rx skb %pK len %d ftype %02x stype %02x\n", skb, skb->len,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 284/575 ath10k: sdio: Add missing BH locking around napi_schdule()
In reply to Greg Kroah-HartmanFrom: Fabio Estevam <[email protected]>
[ Upstream commit 019edd01d174ce4bb2e517dd332922514d176601 ]
On a i.MX-based board with a QCA9377 Wifi chip, the following errors are seen after launching the 'hostapd' application:
hostapd /etc/wifi.conf
Configuration file: /etc/wifi.conf
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! Using interface wlan0 with hwaddr 00:1f:7b:31:04:a0 and ssid "thessid"
IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
wlan0: interface state COUNTRY_UPDATE->ENABLED
wlan0: AP-ENABLED
NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!!
...
Fix this problem by adding the BH locking around napi-schedule(), in the same way it was done in commit e63052a5dd3c ("mlx5e: add add missing BH locking around napi_schdule()").
Its commit log provides the following explanation:
"It's not correct to call napi_schedule() in pure process context. Because we use __raise_softirq_irqoff() we require callers to be in a context which will eventually lead to softirq handling (hardirq, bh disabled, etc.).
With code as is users will see:
NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! "
--- drivers/net/wireless/ath/ath10k/sdio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/sdio.c +4 -1
@@ -1363,8 +1363,11 @@ static void ath10k_rx_indication_async_work(struct work_struct *work) ep->ep_ops.ep_rx_complete (ar, skb); } -if (test_bit (ATH10K_FLAG_CORE_REGISTERED , &ar->dev_flags)) +if (test_bit (ATH10K_FLAG_CORE_REGISTERED , &ar->dev_flags)) { +local_bh_disable ();napi_schedule (&ar->napi); +local_bh_enable (); + } }static int ath10k_sdio_read_rtc_state (struct ath10k_sdio *ar_sdio,unsigned char *state)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 285/575 drm/ttm: stop calling tt_swapin in vm_access
In reply to Greg Kroah-HartmanFrom: Matthew Auld <[email protected]>
[ Upstream commit f5d28856b89baab4232a9f841e565763fcebcdf9 ]
In commit:
commit 09ac4fcb3f255e9225967c75f5893325c116cdbe
Author: Felix Kuehling <[email protected]> Date: Thu Jul 13 17:01:16 2017 -0400
drm/ttm: Implement vm_operations_struct.access v2
we added the vm_access hook, where we also directly call tt_swapin for some reason. If something is swapped-out then the ttm_tt must also be unpopulated, and since access_kmap should also call tt_populate, if needed, then swapping-in will already be handled there.
If anything, calling tt_swapin directly here would likely always fail since the tt->pages won't yet be populated, or worse since the tt->pages array is never actually cleared in unpopulate this might lead to a nasty uaf.
--- drivers/gpu/drm/ttm/ttm_bo_vm.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +0 -5
@@ -500,11 +500,6 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,switch (bo->mem.mem_type) {case TTM_PL_SYSTEM : -if (unlikely (bo->ttm->page_flags &TTM_PAGE_FLAG_SWAPPED )) { - ret =ttm_tt_swapin (bo->ttm); -if (unlikely (ret !=0 )) -return ret; - } fallthrough;case TTM_PL_TT : ret =ttm_bo_vm_access_kmap (bo, offset, buf, len, write);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 286/575 arm64: mm: update max_pfn after memory hotplug
In reply to Greg Kroah-HartmanFrom: Sudarshan Rajagopalan <[email protected]>
[ Upstream commit 8fac67ca236b961b573355e203dbaf62a706a2e5 ]
After new memory blocks have been hotplugged, max_pfn and max_low_pfn needs updating to reflect on new PFNs being hot added to system. Without this patch, debug-related functions that use max_pfn such as get_max_dump_pfn() or read_page_owner() will not work with any page in memory that is hot-added after boot.
--- arch/arm64/mm/mmu.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/mm/mmu.c +5 -0
@@ -1492,6 +1492,11 @@ int arch_add_memory(int nid, u64 start, u64 size,if (ret)__remove_pgd_mapping (swapper_pg_dir,__phys_to_virt (start), size); +else { + max_pfn =PFN_UP (start + size); + max_low_pfn = max_pfn; + } +return ret; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 287/575 drm/amdgpu: fix warning for overflow check
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 335aea75b0d95518951cad7c4c676e6f1c02c150 ]
The overflow check in amdgpu_bo_list_create() causes a warning with clang-14 on 64-bit architectures, since the limit can never be exceeded.
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c:74:18: error: result of comparison of constant 256204778801521549 with expression of type 'unsigned int' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if (num_entries > (SIZE_MAX - sizeof(struct amdgpu_bo_list))
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The check remains useful for 32-bit architectures, so just avoid the warning by using size_t as the type for the count.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +1 -1
@@ -61,7 +61,7 @@ static void amdgpu_bo_list_free(struct kref *ref)int amdgpu_bo_list_create (struct amdgpu_device *adev,struct drm_file *filp,struct drm_amdgpu_bo_list_entry *info, -unsigned num_entries,struct amdgpu_bo_list **result) +size_t num_entries,struct amdgpu_bo_list **result) {unsigned last_entry =0 , first_userptr = num_entries;struct amdgpu_bo_list_entry *array;
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h +1 -1
@@ -60,7 +60,7 @@ int amdgpu_bo_create_list_entry_array(struct drm_amdgpu_bo_list_in *in,int amdgpu_bo_list_create (struct amdgpu_device *adev,struct drm_file *filp,struct drm_amdgpu_bo_list_entry *info, -unsigned num_entries, +size_t num_entries,struct amdgpu_bo_list **list); static inline struct amdgpu_bo_list_entry *
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 288/575 media: em28xx: add missing em28xx_close_extension
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
[ Upstream commit 2c98b8a3458df03abdc6945bbef67ef91d181938 ]
If em28xx dev has ->dev_next pointer, we need to delete ->dev_next list node from em28xx_extension_devlist on disconnect to avoid UAF bugs and corrupted list bugs, since driver frees this pointer on disconnect.
--- drivers/media/usb/em28xx/em28xx-cards.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/usb/em28xx/em28xx-cards.c +4 -1
@@ -4089,8 +4089,11 @@ static void em28xx_usb_disconnect(struct usb_interface *intf)em28xx_close_extension (dev); -if (dev->dev_next) +if (dev->dev_next) { +em28xx_close_extension (dev->dev_next);em28xx_release_resources (dev->dev_next); + } +em28xx_release_resources (dev);if (dev->dev_next) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 289/575 media: cxd2880-spi: Fix a null pointer dereference on error handling path
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
[ Upstream commit 11b982e950d2138e90bd120501df10a439006ff8 ]
Currently the null pointer check on dvb_spi->vcc_supply is inverted and this leads to only null values of the dvb_spi->vcc_supply being passed to the call of regulator_disable causing null pointer dereferences. Fix this by only calling regulator_disable if dvb_spi->vcc_supply is not null.
Addresses-Coverity: ("Dereference after null check")
--- drivers/media/spi/cxd2880-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/spi/cxd2880-spi.c +1 -1
@@ -618,7 +618,7 @@ fail_frontend: fail_attach:dvb_unregister_adapter (&dvb_spi->adapter); fail_adapter: -if (!dvb_spi->vcc_supply) +if (dvb_spi->vcc_supply)regulator_disable (dvb_spi->vcc_supply); fail_regulator:kfree (dvb_spi);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 290/575 media: dvb-usb: fix ununit-value in az6027_rc_query
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
[ Upstream commit afae4ef7d5ad913cab1316137854a36bea6268a5 ]
Syzbot reported ununit-value bug in az6027_rc_query(). The problem was in missing state pointer initialization. Since this function does nothing we can simply initialize state to REMOTE_NO_KEY_PRESSED.
--- drivers/media/usb/dvb-usb/az6027.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/usb/dvb-usb/az6027.c +1 -0
@@ -391,6 +391,7 @@ static struct rc_map_table rc_map_az6027_table[] = {/* remote control stuff (does not work with my box) */ static int az6027_rc_query (struct dvb_usb_device *d,u32 *event,int *state) { + *state =REMOTE_NO_KEY_PRESSED ;return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 291/575 media: v4l2-ioctl: S_CTRL output the right value
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit c87ed93574e3cd8346c05bd934c617596c12541b ]
If the driver does not implement s_ctrl, but it does implement s_ext_ctrls, we convert the call.
When that happens we have also to convert back the response from s_ext_ctrls.
Fixes v4l2_compliance:
Control ioctls (Input 0):
fail: v4l2-test-controls.cpp(411): returned control value out of range
fail: v4l2-test-controls.cpp(507): invalid control 00980900
test VIDIOC_G/S_CTRL: FAIL
--- drivers/media/v4l2-core/v4l2-ioctl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +6 -3
@@ -2263,6 +2263,7 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops,test_bit (V4L2_FL_USES_V4L2_FH , &vfd->flags) ? fh :NULL ;struct v4l2_ext_controls ctrls;struct v4l2_ext_control ctrl; +int ret;if (vfh && vfh->ctrl_handler)return v4l2_s_ctrl (vfh, vfh->ctrl_handler, p);
@@ -2278,9 +2279,11 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops, ctrls.controls = &ctrl; ctrl.id = p->id; ctrl.value = p->value; -if (check_ext_ctrls (&ctrls,VIDIOC_S_CTRL )) -return ops->vidioc_s_ext_ctrls (file, fh, &ctrls); -return -EINVAL ; +if (!check_ext_ctrls (&ctrls,VIDIOC_S_CTRL )) +return -EINVAL ; + ret = ops->vidioc_s_ext_ctrls (file, fh, &ctrls); + p->value = ctrl.value; +return ret; } static int v4l_g_ext_ctrls(const struct v4l2_ioctl_ops *ops,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 292/575 media: TDA1997x: handle short reads of hdmi info frame.
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
[ Upstream commit 48d219f9cc667bc6fbc3e3af0b1bfd75db94fce4 ]
Static analysis reports this representative problem
tda1997x.c:1939: warning: 7th function call argument is an uninitialized value
The 7th argument is buffer[0], which is set in the earlier call to io_readn(). When io_readn() call to io_read() fails with the first read, buffer[0] is not set and 0 is returned and stored in len.
The later call to hdmi_infoframe_unpack()'s size parameter is the static size of buffer, always 40, so a short read is not caught in hdmi_infoframe_unpacks()'s checking. The variable len should be used instead.
Zero initialize buffer to 0 so it is in a known start state.
--- drivers/media/i2c/tda1997x.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/i2c/tda1997x.c +4 -4
@@ -1247,13 +1247,13 @@ tda1997x_parse_infoframe(struct tda1997x_state *state, u16 addr) {struct v4l2_subdev *sd = &state->sd;union hdmi_infoframe frame; -u8 buffer[40 ]; +u8 buffer[40 ] = {0 };u8 reg;int len, err;/* read data */ len =io_readn (sd, addr,sizeof (buffer), buffer); - err =hdmi_infoframe_unpack (&frame, buffer,sizeof (buffer)); + err =hdmi_infoframe_unpack (&frame, buffer, len);if (err) { v4l_err(state->client, "failed parsing %d byte infoframe: 0x%04x/0x%02x\n",
@@ -1927,13 +1927,13 @@ static int tda1997x_log_infoframe(struct v4l2_subdev *sd, int addr) {struct tda1997x_state *state =to_state (sd);union hdmi_infoframe frame; -u8 buffer[40 ]; +u8 buffer[40 ] = {0 };int len, err;/* read data */ len =io_readn (sd, addr,sizeof (buffer), buffer);v4l2_dbg (1 , debug, sd,"infoframe: addr=%d len=%d\n" , addr, len); - err =hdmi_infoframe_unpack (&frame, buffer,sizeof (buffer)); + err =hdmi_infoframe_unpack (&frame, buffer, len);if (err) { v4l_err(state->client, "failed parsing %d byte infoframe: 0x%04x/0x%02x\n",
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 293/575 media: mtk-vpu: Fix a resource leak in the error handling path of mtk_vpu_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 2143ad413c05c7be24c3a92760e367b7f6aaac92 ]
A successful 'clk_prepare()' call should be balanced by a corresponding 'clk_unprepare()' call in the error handling path of the probe, as already done in the remove function.
Update the error handling path accordingly.
--- drivers/media/platform/mtk-vpu/mtk_vpu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/mtk-vpu/mtk_vpu.c +4 -1
@@ -820,7 +820,8 @@ static int mtk_vpu_probe(struct platform_device *pdev) vpu->wdt.wq =create_singlethread_workqueue ("vpu_wdt" );if (!vpu->wdt.wq) {dev_err (dev,"initialize wdt workqueue failed\n" ); -return -ENOMEM ; + ret = -ENOMEM ; + goto clk_unprepare; }INIT_WORK (&vpu->wdt.ws, vpu_wdt_reset_func);mutex_init (&vpu->vpu_mutex);
@@ -914,6 +915,8 @@ disable_vpu_clk:vpu_clock_disable (vpu); workqueue_destroy:destroy_workqueue (vpu->wdt.wq); +clk_unprepare: +clk_unprepare (vpu->clk);return ret; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 294/575 media: i2c: ths8200 needs V4L2_ASYNC
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit e4625044d656f3c33ece0cc9da22577bc10ca5d3 ]
Fix the build errors reported by the kernel test robot by selecting V4L2_ASYNC:
mips-linux-ld: drivers/media/i2c/ths8200.o: in function `ths8200_remove':
ths8200.c:(.text+0x1ec): undefined reference to `v4l2_async_unregister_subdev'
mips-linux-ld: drivers/media/i2c/ths8200.o: in function `ths8200_probe':
ths8200.c:(.text+0x404): undefined reference to `v4l2_async_register_subdev'
--- drivers/media/i2c/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/Kconfig +1 -0
@@ -595,6 +595,7 @@ config VIDEO_AK881X config VIDEO_THS8200 tristate "Texas Instruments THS8200 video encoder" depends on VIDEO_V4L2 && I2C + select V4L2_ASYNC help Support for the Texas Instruments THS8200 video encoder.
Signature · 1 line
2.33.0
Re: [PATCH 5.10 294/575] media: i2c: ths8200 needs V4L2_ASYNC
Hi!
Quoted 10 lines
[ Upstream commit
e4625044d656f3c33ece0cc9da22577bc10ca5d3]Fix the build errors reported by the kernel test robot by selecting
V4L2_ASYNC:mips-linux-ld:
drivers/media/i2c/ths8200.o: in function `ths8200_remove':
ths8200.c:(.text+0x1ec): undefined reference to `v4l2_async_unregister_subdev'
mips-linux-ld:drivers/media/i2c/ths8200.o: in function `ths8200_probe':
ths8200.c:(.text+0x404): undefined reference to
`v4l2_async_register_subdev'
CONFIG_V4L2_ASYNC is not present in 5.10 kernel, this is should not be applied here.
Best regards,
Pavel
Quoted 9 lines
+++ b/drivers/media/i2c/Kconfig
drivers/media/i2c/Kconfig +1
-0@@ -595,6 +595,7 @@ config VIDEO_AK881X config VIDEO_THS8200 tristate "Texas Instruments THS8200 video encoder" depends on VIDEO_V4L2 && I2C + select V4L2_ASYNC help Support for the Texas Instruments THS8200 video encoder.
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Greg Kroah-Hartman
maintainerRe: [PATCH 5.10 294/575] media: i2c: ths8200 needs V4L2_ASYNC
Quoted 7 lines · Pavel Machek
Hi!
Quoted 6 lines
[ Upstream commit
e4625044d656f3c33ece0cc9da22577bc10ca5d3]Fix the build errors reported by the kernel test robot by selecting
V4L2_ASYNC:
Quoted 8 lines
Quoted 4 lines
mips-linux-ld:
drivers/media/i2c/ths8200.o: in function `ths8200_remove':
ths8200.c:(.text+0x1ec): undefined reference to `v4l2_async_unregister_subdev'
mips-linux-ld:drivers/media/i2c/ths8200.o: in function `ths8200_probe':
ths8200.c:(.text+0x404): undefined reference to`v4l2_async_register_subdev'
CONFIG_V4L2_ASYNCis not present in 5.10 kernel, this is should not be applied here.
Dropped from 5.4.y and 5.10.y now, thanks.
greg k-h
Greg Kroah-Hartman
maintainerPATCH 295/575 media: radio-wl1273: Avoid card name truncation
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit dfadec236aa99f6086141949c9dc3ec50f3ff20d ]
The "card" string only holds 31 characters (and the terminating NUL). In order to avoid truncation, use a shorter card description instead of the current result, "Texas Instruments Wl1273 FM Rad".
--- drivers/media/radio/radio-wl1273.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/radio/radio-wl1273.c +1 -1
@@ -1279,7 +1279,7 @@ static int wl1273_fm_vidioc_querycap(struct file *file, void *priv,strscpy (capability->driver,WL1273_FM_DRIVER_NAME ,sizeof (capability->driver)); -strscpy (capability->card,"Texas Instruments Wl1273 FM Radio" , +strscpy (capability->card,"TI Wl1273 FM Radio" ,sizeof (capability->card));strscpy (capability->bus_info, radio->bus_type,sizeof (capability->bus_info));
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 296/575 media: si470x: Avoid card name truncation
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit 2908249f3878a591f7918368fdf0b7b0a6c3158c ]
The "card" string only holds 31 characters (and the terminating NUL). In order to avoid truncation, use a shorter card description instead of the current result, "Silicon Labs Si470x FM Radio Re".
--- drivers/media/radio/si470x/radio-si470x-i2c.c | 2 +- drivers/media/radio/si470x/radio-si470x-usb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/radio/si470x/radio-si470x-i2c.c +1 -1
@@ -11,7 +11,7 @@/* driver definitions */ #define DRIVER_AUTHOR "Joonyoung Shim <[email protected]>"; -#define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver" +#define DRIVER_CARD "Silicon Labs Si470x FM Radio"#define DRIVER_DESC "I2C radio driver for Si470x FM Radio Receivers"#define DRIVER_VERSION "1.0.2"
drivers/media/radio/si470x/radio-si470x-usb.c +1 -1
@@ -16,7 +16,7 @@/* driver definitions */ #define DRIVER_AUTHOR "Tobias Lorenz <[email protected]>" -#define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver" +#define DRIVER_CARD "Silicon Labs Si470x FM Radio"#define DRIVER_DESC "USB radio driver for Si470x FM Radio Receivers"#define DRIVER_VERSION "1.0.10"
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 297/575 media: tm6000: Avoid card name truncation
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit 42bb98e420d454fef3614b70ea11cc59068395f6 ]
The "card" string only holds 31 characters (and the terminating NUL). In order to avoid truncation, use a shorter card description instead of the current result, "Trident TVMaster TM5600/6000/60".
--- drivers/media/usb/tm6000/tm6000-video.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/usb/tm6000/tm6000-video.c +1 -2
@@ -854,8 +854,7 @@ static int vidioc_querycap(struct file *file, void *priv,struct tm6000_core *dev = ((struct tm6000_fh *)priv)->dev;strscpy (cap->driver,"tm6000" ,sizeof (cap->driver)); -strscpy (cap->card,"Trident TVMaster TM5600/6000/6010" , -sizeof (cap->card)); +strscpy (cap->card,"Trident TM5600/6000/6010" ,sizeof (cap->card));usb_make_path (dev->udev, cap->bus_info,sizeof (cap->bus_info)); cap->capabilities =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_READWRITE |V4L2_CAP_DEVICE_CAPS ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 298/575 media: cx23885: Fix snd_card_free call on null card pointer
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
[ Upstream commit 7266dda2f1dfe151b12ef0c14eb4d4e622fb211c ]
Currently a call to snd_card_new that fails will set card with a NULL pointer, this causes a null pointer dereference on the error cleanup path when card it passed to snd_card_free. Fix this by adding a new error exit path that does not call snd_card_free and exiting via this new path.
Addresses-Coverity: ("Explicit null dereference")
--- drivers/media/pci/cx23885/cx23885-alsa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/pci/cx23885/cx23885-alsa.c +2 -1
@@ -550,7 +550,7 @@ struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev)SNDRV_DEFAULT_IDX1 ,SNDRV_DEFAULT_STR1 , THIS_MODULE, sizeof(struct cx23885_audio_dev), &card);if (err <0 ) - goto error; + goto error_msg; chip = (struct cx23885_audio_dev *) card->private_data; chip->dev = dev;
@@ -576,6 +576,7 @@ struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev) error:snd_card_free (card); +error_msg:pr_err ("%s(): Failed to register analog audio adapter\n" , __func__);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 299/575 kprobes: Do not use local variable when creating debugfs file
In reply to Greg Kroah-HartmanFrom: Punit Agrawal <[email protected]>
[ Upstream commit 8f7262cd66699a4b02eb7549b35c81b2116aad95 ]
debugfs_create_file() takes a pointer argument that can be used during file operation callbacks (accessible via i_private in the inode structure). An obvious requirement is for the pointer to refer to valid memory when used.
When creating the debugfs file to dynamically enable / disable kprobes, a pointer to local variable is passed to debugfs_create_file(); which will go out of scope when the init function returns. The reason this hasn't triggered random memory corruption is because the pointer is not accessed during the debugfs file callbacks.
Since the enabled state is managed by the kprobes_all_disabled global variable, the local variable is not needed. Fix the incorrect (and unnecessary) usage of local variable during debugfs_file_create() by passing NULL instead.
--- kernel/kprobes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/kprobes.c +1 -2
@@ -2943,13 +2943,12 @@ static const struct file_operations fops_kp = {static int __init debugfs_kprobe_init (void ) {struct dentry *dir; -unsigned int value =1 ; dir =debugfs_create_dir ("kprobes" ,NULL );debugfs_create_file ("list" ,0400 , dir,NULL , &kprobes_fops); -debugfs_create_file ("enabled" ,0600 , dir, &value, &fops_kp); +debugfs_create_file ("enabled" ,0600 , dir,NULL , &fops_kp);debugfs_create_file ("blacklist" ,0400 , dir,NULL , &kprobe_blacklist_fops);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 300/575 crypto: ecc - fix CRYPTO_DEFAULT_RNG dependency
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 38aa192a05f22f9778f9420e630f0322525ef12e ]
The ecc.c file started out as part of the ECDH algorithm but got moved out into a standalone module later. It does not build without CRYPTO_DEFAULT_RNG, so now that other modules are using it as well we can run into this link error:
aarch64-linux-ld: ecc.c:(.text+0xfc8): undefined reference to `crypto_default_rng'
aarch64-linux-ld: ecc.c:(.text+0xff4): undefined reference to `crypto_put_default_rng'
Move the 'select CRYPTO_DEFAULT_RNG' statement into the correct symbol.
--- crypto/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/Kconfig +1 -1
@@ -238,12 +238,12 @@ config CRYPTO_DH config CRYPTO_ECC tristate + select CRYPTO_RNG_DEFAULT config CRYPTO_ECDH tristate "ECDH algorithm" select CRYPTO_ECC select CRYPTO_KPP - select CRYPTO_RNG_DEFAULT help Generic implementation of the ECDH algorithm
Signature · 1 line
2.33.0