5.17.3-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 135/343 riscv: Fixed misaligned memory access. Fixed pointer comparison.
In reply to Greg Kroah-HartmanFrom: Michael T. Kloos <[email protected]>
[ Upstream commit 9d1f0ec9f71780e69ceb9d91697600c747d6e02e ]
Rewrote the RISC-V memmove() assembly implementation. The previous implementation did not check memory alignment and it compared 2 pointers with a signed comparison. The misaligned memory access would cause the kernel to crash on systems that did not emulate it in firmware and did not support it in hardware. Firmware emulation is slow and may not exist. The RISC-V spec does not guarantee that support for misaligned memory accesses will exist. It should not be depended on.
This patch now checks for XLEN granularity of co-alignment between the pointers. Failing that, copying is done by loading from the 2 contiguous and naturally aligned XLEN memory locations containing the overlapping XLEN sized data to be copied. The data is shifted into the correct place and binary or'ed together on each iteration. The result is then stored into the corresponding naturally aligned XLEN sized location in the destination. For unaligned data at the terminations of the regions to be copied or for copies less than (2 * XLEN) in size, byte copy is used.
This patch also now uses unsigned comparison for the pointers and migrates to the newer assembler annotations from the now deprecated ones.
--- arch/riscv/lib/memmove.S | 368 +++++++++++++++++++++++++++++++++------ 1 file changed, 310 insertions(+), 58 deletions(-)
arch/riscv/lib/memmove.S +310 -58
@@ -1,64 +1,316 @@ -/* SPDX-License-Identifier: GPL-2.0 */ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2022 Michael T. Kloos <[email protected]> + */ #include <linux/linkage.h> #include <asm/asm.h> -ENTRY(__memmove) -WEAK(memmove) - move t0, a0 - move t1, a1 - - beq a0, a1, exit_memcpy - beqz a2, exit_memcpy - srli t2, a2, 0x2 - - slt t3, a0, a1 - beqz t3, do_reverse - - andi a2, a2, 0x3 - li t4, 1 - beqz t2, byte_copy - -word_copy: - lw t3, 0(a1) - addi t2, t2, -1 - addi a1, a1, 4 - sw t3, 0(a0) - addi a0, a0, 4 - bnez t2, word_copy - beqz a2, exit_memcpy - j byte_copy - -do_reverse: - add a0, a0, a2 - add a1, a1, a2 - andi a2, a2, 0x3 - li t4, -1 - beqz t2, reverse_byte_copy - -reverse_word_copy: - addi a1, a1, -4 - addi t2, t2, -1 - lw t3, 0(a1) - addi a0, a0, -4 - sw t3, 0(a0) - bnez t2, reverse_word_copy - beqz a2, exit_memcpy - -reverse_byte_copy: - addi a0, a0, -1 - addi a1, a1, -1 +SYM_FUNC_START(__memmove) +SYM_FUNC_START_WEAK(memmove) + /* + * Returns + * a0 - dest + * + * Parameters + * a0 - Inclusive first byte of dest + * a1 - Inclusive first byte of src + * a2 - Length of copy n + * + * Because the return matches the parameter register a0, + * we will not clobber or modify that register. + * + * Note: This currently only works on little-endian. + * To port to big-endian, reverse the direction of shifts + * in the 2 misaligned fixup copy loops. + */ + /* Return if nothing to do */ + beq a0, a1, return_from_memmove + beqz a2, return_from_memmove + + /* + * Register Uses + * Forward Copy: a1 - Index counter of src + * Reverse Copy: a4 - Index counter of src + * Forward Copy: t3 - Index counter of dest + * Reverse Copy: t4 - Index counter of dest + * Both Copy Modes: t5 - Inclusive first multibyte/aligned of dest + * Both Copy Modes: t6 - Non-Inclusive last multibyte/aligned of dest + * Both Copy Modes: t0 - Link / Temporary for load-store + * Both Copy Modes: t1 - Temporary for load-store + * Both Copy Modes: t2 - Temporary for load-store + * Both Copy Modes: a5 - dest to src alignment offset + * Both Copy Modes: a6 - Shift ammount + * Both Copy Modes: a7 - Inverse Shift ammount + * Both Copy Modes: a2 - Alternate breakpoint for unrolled loops + */ + + /* + * Solve for some register values now. + * Byte copy does not need t5 or t6. + */ + mv t3, a0 + add t4, a0, a2 + add a4, a1, a2 + + /* + * Byte copy if copying less than (2 * SZREG) bytes. This can + * cause problems with the bulk copy implementation and is + * small enough not to bother. + */ + andi t0, a2, -(2 * SZREG) + beqz t0, byte_copy + + /* + * Now solve for t5 and t6. + */ + andi t5, t3, -SZREG + andi t6, t4, -SZREG + /* + * If dest(Register t3) rounded down to the nearest naturally + * aligned SZREG address, does not equal dest, then add SZREG + * to find the low-bound of SZREG alignment in the dest memory + * region. Note that this could overshoot the dest memory + * region if n is less than SZREG. This is one reason why + * we always byte copy if n is less than SZREG. + * Otherwise, dest is already naturally aligned to SZREG. + */ + beq t5, t3, 1f + addi t5, t5, SZREG + 1: + + /* + * If the dest and src are co-aligned to SZREG, then there is + * no need for the full rigmarole of a full misaligned fixup copy. + * Instead, do a simpler co-aligned copy. + */ + xor t0, a0, a1 + andi t1, t0, (SZREG - 1) + beqz t1, coaligned_copy + /* Fall through to misaligned fixup copy */ + +misaligned_fixup_copy: + bltu a1, a0, misaligned_fixup_copy_reverse + +misaligned_fixup_copy_forward: + jal t0, byte_copy_until_aligned_forward + + andi a5, a1, (SZREG - 1) /* Find the alignment offset of src (a1) */ + slli a6, a5, 3 /* Multiply by 8 to convert that to bits to shift */ + sub a5, a1, t3 /* Find the difference between src and dest */ + andi a1, a1, -SZREG /* Align the src pointer */ + addi a2, t6, SZREG /* The other breakpoint for the unrolled loop*/ + + /* + * Compute The Inverse Shift + * a7 = XLEN - a6 = XLEN + -a6 + * 2s complement negation to find the negative: -a6 = ~a6 + 1 + * Add that to XLEN. XLEN = SZREG * 8. + */ + not a7, a6 + addi a7, a7, (SZREG * 8 + 1) + + /* + * Fix Misalignment Copy Loop - Forward + * load_val0 = load_ptr[0]; + * do { + * load_val1 = load_ptr[1]; + * store_ptr += 2; + * store_ptr[0 - 2] = (load_val0 >> {a6}) | (load_val1 << {a7}); + * + * if (store_ptr == {a2}) + * break; + * + * load_val0 = load_ptr[2]; + * load_ptr += 2; + * store_ptr[1 - 2] = (load_val1 >> {a6}) | (load_val0 << {a7}); + * + * } while (store_ptr != store_ptr_end); + * store_ptr = store_ptr_end; + */ + + REG_L t0, (0 * SZREG)(a1) + 1: + REG_L t1, (1 * SZREG)(a1) + addi t3, t3, (2 * SZREG) + srl t0, t0, a6 + sll t2, t1, a7 + or t2, t0, t2 + REG_S t2, ((0 * SZREG) - (2 * SZREG))(t3) + + beq t3, a2, 2f + + REG_L t0, (2 * SZREG)(a1) + addi a1, a1, (2 * SZREG) + srl t1, t1, a6 + sll t2, t0, a7 + or t2, t1, t2 + REG_S t2, ((1 * SZREG) - (2 * SZREG))(t3) + + bne t3, t6, 1b + 2: + mv t3, t6 /* Fix the dest pointer in case the loop was broken */ + + add a1, t3, a5 /* Restore the src pointer */ + j byte_copy_forward /* Copy any remaining bytes */ + +misaligned_fixup_copy_reverse: + jal t0, byte_copy_until_aligned_reverse + + andi a5, a4, (SZREG - 1) /* Find the alignment offset of src (a4) */ + slli a6, a5, 3 /* Multiply by 8 to convert that to bits to shift */ + sub a5, a4, t4 /* Find the difference between src and dest */ + andi a4, a4, -SZREG /* Align the src pointer */ + addi a2, t5, -SZREG /* The other breakpoint for the unrolled loop*/ + + /* + * Compute The Inverse Shift + * a7 = XLEN - a6 = XLEN + -a6 + * 2s complement negation to find the negative: -a6 = ~a6 + 1 + * Add that to XLEN. XLEN = SZREG * 8. + */ + not a7, a6 + addi a7, a7, (SZREG * 8 + 1) + + /* + * Fix Misalignment Copy Loop - Reverse + * load_val1 = load_ptr[0]; + * do { + * load_val0 = load_ptr[-1]; + * store_ptr -= 2; + * store_ptr[1] = (load_val0 >> {a6}) | (load_val1 << {a7}); + * + * if (store_ptr == {a2}) + * break; + * + * load_val1 = load_ptr[-2]; + * load_ptr -= 2; + * store_ptr[0] = (load_val1 >> {a6}) | (load_val0 << {a7}); + * + * } while (store_ptr != store_ptr_end); + * store_ptr = store_ptr_end; + */ + + REG_L t1, ( 0 * SZREG)(a4) + 1: + REG_L t0, (-1 * SZREG)(a4) + addi t4, t4, (-2 * SZREG) + sll t1, t1, a7 + srl t2, t0, a6 + or t2, t1, t2 + REG_S t2, ( 1 * SZREG)(t4) + + beq t4, a2, 2f + + REG_L t1, (-2 * SZREG)(a4) + addi a4, a4, (-2 * SZREG) + sll t0, t0, a7 + srl t2, t1, a6 + or t2, t0, t2 + REG_S t2, ( 0 * SZREG)(t4) + + bne t4, t5, 1b + 2: + mv t4, t5 /* Fix the dest pointer in case the loop was broken */ + + add a4, t4, a5 /* Restore the src pointer */ + j byte_copy_reverse /* Copy any remaining bytes */ + +/* + * Simple copy loops for SZREG co-aligned memory locations. + * These also make calls to do byte copies for any unaligned + * data at their terminations. + */ +coaligned_copy: + bltu a1, a0, coaligned_copy_reverse + +coaligned_copy_forward: + jal t0, byte_copy_until_aligned_forward + + 1: + REG_L t1, ( 0 * SZREG)(a1) + addi a1, a1, SZREG + addi t3, t3, SZREG + REG_S t1, (-1 * SZREG)(t3) + bne t3, t6, 1b + + j byte_copy_forward /* Copy any remaining bytes */ + +coaligned_copy_reverse: + jal t0, byte_copy_until_aligned_reverse + + 1: + REG_L t1, (-1 * SZREG)(a4) + addi a4, a4, -SZREG + addi t4, t4, -SZREG + REG_S t1, ( 0 * SZREG)(t4) + bne t4, t5, 1b + + j byte_copy_reverse /* Copy any remaining bytes */ + +/* + * These are basically sub-functions within the function. They + * are used to byte copy until the dest pointer is in alignment. + * At which point, a bulk copy method can be used by the + * calling code. These work on the same registers as the bulk + * copy loops. Therefore, the register values can be picked + * up from where they were left and we avoid code duplication + * without any overhead except the call in and return jumps. + */ +byte_copy_until_aligned_forward: + beq t3, t5, 2f + 1: + lb t1, 0(a1) + addi a1, a1, 1 + addi t3, t3, 1 + sb t1, -1(t3) + bne t3, t5, 1b + 2: + jalr zero, 0x0(t0) /* Return to multibyte copy loop */ + +byte_copy_until_aligned_reverse: + beq t4, t6, 2f + 1: + lb t1, -1(a4) + addi a4, a4, -1 + addi t4, t4, -1 + sb t1, 0(t4) + bne t4, t6, 1b + 2: + jalr zero, 0x0(t0) /* Return to multibyte copy loop */ + +/* + * Simple byte copy loops. + * These will byte copy until they reach the end of data to copy. + * At that point, they will call to return from memmove. + */ byte_copy: - lb t3, 0(a1) - addi a2, a2, -1 - sb t3, 0(a0) - add a1, a1, t4 - add a0, a0, t4 - bnez a2, byte_copy - -exit_memcpy: - move a0, t0 - move a1, t1 - ret -END(__memmove) + bltu a1, a0, byte_copy_reverse + +byte_copy_forward: + beq t3, t4, 2f + 1: + lb t1, 0(a1) + addi a1, a1, 1 + addi t3, t3, 1 + sb t1, -1(t3) + bne t3, t4, 1b + 2: + ret + +byte_copy_reverse: + beq t4, t3, 2f + 1: + lb t1, -1(a4) + addi a4, a4, -1 + addi t4, t4, -1 + sb t1, 0(t4) + bne t4, t3, 1b + 2: + +return_from_memmove: + ret + +SYM_FUNC_END(memmove) +SYM_FUNC_END(__memmove)
Signature · 1 line
2.35.1
Re: [PATCH 5.17 135/343] riscv: Fixed misaligned memory access. Fixed pointer comparison.
Backporting to 5.17 looks good to me.
Michael
Quoted 413 lines · Greg Kroah-Hartman
From: Michael T. Kloos <[email protected]>
[ Upstream commit
9d1f0ec9f71780e69ceb9d91697600c747d6e02e]Rewrote the RISC-V
memmove()assembly implementation. The previous implementation did not check memory alignment and it compared 2 pointers with a signed comparison. The misaligned memory access would cause the kernel to crash on systems that did not emulate it in firmware and did not support it in hardware. Firmware emulation is slow and may not exist. The RISC-V spec does not guarantee that support for misaligned memory accesses will exist. It should not be depended on.This patch now checks for XLEN granularity of co-alignment between the pointers. Failing that, copying is done by loading from the 2 contiguous and naturally aligned XLEN memory locations containing the overlapping XLEN sized data to be copied. The data is shifted into the correct place and binary or'ed together on each iteration. The result is then stored into the corresponding naturally aligned XLEN sized location in the destination. For unaligned data at the terminations of the regions to be copied or for copies less than (2 * XLEN) in size, byte copy is used.
This patch also now uses unsigned comparison for the pointers and migrates to the newer assembler annotations from the now deprecated ones.
Signed-off-by Michael T. Kloos <[email protected]>Signed-off-by Palmer Dabbelt <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- arch/riscv/lib/memmove.S | 368 +++++++++++++++++++++++++++++++++------ 1 file changed, 310 insertions(+), 58 deletions(-)arch/riscv/lib/memmove.S +310
-58@@ -1,64 +1,316 @@ -/* SPDX-License-Identifier: GPL-2.0 */ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2022 Michael T. Kloos <[email protected]> + */ #include <linux/linkage.h> #include <asm/asm.h> -ENTRY(__memmove) -WEAK(memmove) - move t0, a0 - move t1, a1 - - beq a0, a1, exit_memcpy - beqz a2, exit_memcpy - srli t2, a2, 0x2 - - slt t3, a0, a1 - beqz t3, do_reverse - - andi a2, a2, 0x3 - li t4, 1 - beqz t2, byte_copy - -word_copy: - lw t3, 0(a1) - addi t2, t2, -1 - addi a1, a1, 4 - sw t3, 0(a0) - addi a0, a0, 4 - bnez t2, word_copy - beqz a2, exit_memcpy - j byte_copy - -do_reverse: - add a0, a0, a2 - add a1, a1, a2 - andi a2, a2, 0x3 - li t4, -1 - beqz t2, reverse_byte_copy - -reverse_word_copy: - addi a1, a1, -4 - addi t2, t2, -1 - lw t3, 0(a1) - addi a0, a0, -4 - sw t3, 0(a0) - bnez t2, reverse_word_copy - beqz a2, exit_memcpy - -reverse_byte_copy: - addi a0, a0, -1 - addi a1, a1, -1 +SYM_FUNC_START(__memmove) +SYM_FUNC_START_WEAK(memmove) + /* + * Returns + * a0 - dest + * + * Parameters + * a0 - Inclusive first byte of dest + * a1 - Inclusive first byte of src + * a2 - Length of copy n + * + * Because the return matches the parameter register a0, + * we will not clobber or modify that register. + * + * Note: This currently only works on little-endian. + * To port to big-endian, reverse the direction of shifts + * in the 2 misaligned fixup copy loops. + */ + /* Return if nothing to do */ + beq a0, a1, return_from_memmove + beqz a2, return_from_memmove + + /* + * Register Uses + * Forward Copy: a1 - Index counter of src + * Reverse Copy: a4 - Index counter of src + * Forward Copy: t3 - Index counter of dest + * Reverse Copy: t4 - Index counter of dest + * Both Copy Modes: t5 - Inclusive first multibyte/aligned of dest + * Both Copy Modes: t6 - Non-Inclusive last multibyte/aligned of dest + * Both Copy Modes: t0 - Link / Temporary for load-store + * Both Copy Modes: t1 - Temporary for load-store + * Both Copy Modes: t2 - Temporary for load-store + * Both Copy Modes: a5 - dest to src alignment offset + * Both Copy Modes: a6 - Shift ammount + * Both Copy Modes: a7 - Inverse Shift ammount + * Both Copy Modes: a2 - Alternate breakpoint for unrolled loops + */ + + /* + * Solve for some register values now. + * Byte copy does not need t5 or t6. + */ + mv t3, a0 + add t4, a0, a2 + add a4, a1, a2 + + /* + * Byte copy if copying less than (2 * SZREG) bytes. This can + * cause problems with the bulk copy implementation and is + * small enough not to bother. + */ + andi t0, a2, -(2 * SZREG) + beqz t0, byte_copy + + /* + * Now solve for t5 and t6. + */ + andi t5, t3, -SZREG + andi t6, t4, -SZREG + /* + * If dest(Register t3) rounded down to the nearest naturally + * aligned SZREG address, does not equal dest, then add SZREG + * to find the low-bound of SZREG alignment in the dest memory + * region. Note that this could overshoot the dest memory + * region if n is less than SZREG. This is one reason why + * we always byte copy if n is less than SZREG. + * Otherwise, dest is already naturally aligned to SZREG. + */ + beq t5, t3, 1f + addi t5, t5, SZREG + 1: + + /* + * If the dest and src are co-aligned to SZREG, then there is + * no need for the full rigmarole of a full misaligned fixup copy. + * Instead, do a simpler co-aligned copy. + */ + xor t0, a0, a1 + andi t1, t0, (SZREG - 1) + beqz t1, coaligned_copy + /* Fall through to misaligned fixup copy */ + +misaligned_fixup_copy: + bltu a1, a0, misaligned_fixup_copy_reverse + +misaligned_fixup_copy_forward: + jal t0, byte_copy_until_aligned_forward + + andi a5, a1, (SZREG - 1) /* Find the alignment offset of src (a1) */ + slli a6, a5, 3 /* Multiply by 8 to convert that to bits to shift */ + sub a5, a1, t3 /* Find the difference between src and dest */ + andi a1, a1, -SZREG /* Align the src pointer */ + addi a2, t6, SZREG /* The other breakpoint for the unrolled loop*/ + + /* + * Compute The Inverse Shift + * a7 = XLEN - a6 = XLEN + -a6 + * 2s complement negation to find the negative: -a6 = ~a6 + 1 + * Add that to XLEN. XLEN = SZREG * 8. + */ + not a7, a6 + addi a7, a7, (SZREG * 8 + 1) + + /* + * Fix Misalignment Copy Loop - Forward + * load_val0 = load_ptr[0]; + * do { + * load_val1 = load_ptr[1]; + * store_ptr += 2; + * store_ptr[0 - 2] = (load_val0 >> {a6}) | (load_val1 << {a7}); + * + * if (store_ptr == {a2}) + * break; + * + * load_val0 = load_ptr[2]; + * load_ptr += 2; + * store_ptr[1 - 2] = (load_val1 >> {a6}) | (load_val0 << {a7}); + * + * } while (store_ptr != store_ptr_end); + * store_ptr = store_ptr_end; + */ + + REG_L t0, (0 * SZREG)(a1) + 1: + REG_L t1, (1 * SZREG)(a1) + addi t3, t3, (2 * SZREG) + srl t0, t0, a6 + sll t2, t1, a7 + or t2, t0, t2 + REG_S t2, ((0 * SZREG) - (2 * SZREG))(t3) + + beq t3, a2, 2f + + REG_L t0, (2 * SZREG)(a1) + addi a1, a1, (2 * SZREG) + srl t1, t1, a6 + sll t2, t0, a7 + or t2, t1, t2 + REG_S t2, ((1 * SZREG) - (2 * SZREG))(t3) + + bne t3, t6, 1b + 2: + mv t3, t6 /* Fix the dest pointer in case the loop was broken */ + + add a1, t3, a5 /* Restore the src pointer */ + j byte_copy_forward /* Copy any remaining bytes */ + +misaligned_fixup_copy_reverse: + jal t0, byte_copy_until_aligned_reverse + + andi a5, a4, (SZREG - 1) /* Find the alignment offset of src (a4) */ + slli a6, a5, 3 /* Multiply by 8 to convert that to bits to shift */ + sub a5, a4, t4 /* Find the difference between src and dest */ + andi a4, a4, -SZREG /* Align the src pointer */ + addi a2, t5, -SZREG /* The other breakpoint for the unrolled loop*/ + + /* + * Compute The Inverse Shift + * a7 = XLEN - a6 = XLEN + -a6 + * 2s complement negation to find the negative: -a6 = ~a6 + 1 + * Add that to XLEN. XLEN = SZREG * 8. + */ + not a7, a6 + addi a7, a7, (SZREG * 8 + 1) + + /* + * Fix Misalignment Copy Loop - Reverse + * load_val1 = load_ptr[0]; + * do { + * load_val0 = load_ptr[-1]; + * store_ptr -= 2; + * store_ptr[1] = (load_val0 >> {a6}) | (load_val1 << {a7}); + * + * if (store_ptr == {a2}) + * break; + * + * load_val1 = load_ptr[-2]; + * load_ptr -= 2; + * store_ptr[0] = (load_val1 >> {a6}) | (load_val0 << {a7}); + * + * } while (store_ptr != store_ptr_end); + * store_ptr = store_ptr_end; + */ + + REG_L t1, ( 0 * SZREG)(a4) + 1: + REG_L t0, (-1 * SZREG)(a4) + addi t4, t4, (-2 * SZREG) + sll t1, t1, a7 + srl t2, t0, a6 + or t2, t1, t2 + REG_S t2, ( 1 * SZREG)(t4) + + beq t4, a2, 2f + + REG_L t1, (-2 * SZREG)(a4) + addi a4, a4, (-2 * SZREG) + sll t0, t0, a7 + srl t2, t1, a6 + or t2, t0, t2 + REG_S t2, ( 0 * SZREG)(t4) + + bne t4, t5, 1b + 2: + mv t4, t5 /* Fix the dest pointer in case the loop was broken */ + + add a4, t4, a5 /* Restore the src pointer */ + j byte_copy_reverse /* Copy any remaining bytes */ + +/* + * Simple copy loops for SZREG co-aligned memory locations. + * These also make calls to do byte copies for any unaligned + * data at their terminations. + */ +coaligned_copy: + bltu a1, a0, coaligned_copy_reverse + +coaligned_copy_forward: + jal t0, byte_copy_until_aligned_forward + + 1: + REG_L t1, ( 0 * SZREG)(a1) + addi a1, a1, SZREG + addi t3, t3, SZREG + REG_S t1, (-1 * SZREG)(t3) + bne t3, t6, 1b + + j byte_copy_forward /* Copy any remaining bytes */ + +coaligned_copy_reverse: + jal t0, byte_copy_until_aligned_reverse + + 1: + REG_L t1, (-1 * SZREG)(a4) + addi a4, a4, -SZREG + addi t4, t4, -SZREG + REG_S t1, ( 0 * SZREG)(t4) + bne t4, t5, 1b + + j byte_copy_reverse /* Copy any remaining bytes */ + +/* + * These are basically sub-functions within the function. They + * are used to byte copy until the dest pointer is in alignment. + * At which point, a bulk copy method can be used by the + * calling code. These work on the same registers as the bulk + * copy loops. Therefore, the register values can be picked + * up from where they were left and we avoid code duplication + * without any overhead except the call in and return jumps. + */ +byte_copy_until_aligned_forward: + beq t3, t5, 2f + 1: + lb t1, 0(a1) + addi a1, a1, 1 + addi t3, t3, 1 + sb t1, -1(t3) + bne t3, t5, 1b + 2: + jalr zero, 0x0(t0) /* Return to multibyte copy loop */ + +byte_copy_until_aligned_reverse: + beq t4, t6, 2f + 1: + lb t1, -1(a4) + addi a4, a4, -1 + addi t4, t4, -1 + sb t1, 0(t4) + bne t4, t6, 1b + 2: + jalr zero, 0x0(t0) /* Return to multibyte copy loop */ + +/* + * Simple byte copy loops. + * These will byte copy until they reach the end of data to copy. + * At that point, they will call to return from memmove. + */ byte_copy: - lb t3, 0(a1) - addi a2, a2, -1 - sb t3, 0(a0) - add a1, a1, t4 - add a0, a0, t4 - bnez a2, byte_copy - -exit_memcpy: - move a0, t0 - move a1, t1 - ret -END(__memmove) + bltu a1, a0, byte_copy_reverse + +byte_copy_forward: + beq t3, t4, 2f + 1: + lb t1, 0(a1) + addi a1, a1, 1 + addi t3, t3, 1 + sb t1, -1(t3) + bne t3, t4, 1b + 2: + ret + +byte_copy_reverse: + beq t4, t3, 2f + 1: + lb t1, -1(a4) + addi a4, a4, -1 + addi t4, t4, -1 + sb t1, 0(t4) + bne t4, t3, 1b + 2: + +return_from_memmove: + ret + +SYM_FUNC_END(memmove) +SYM_FUNC_END(__memmove)
Greg Kroah-Hartman
maintainerPATCH 136/343 net: account alternate interface name memory
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 5d26cff5bdbebdf98ba48217c078ff102536f134 ]
George reports that altnames can eat up kernel memory. We should charge that memory appropriately.
--- net/core/rtnetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/rtnetlink.c +1 -1
@@ -3658,7 +3658,7 @@ static int rtnl_alt_ifname(int cmd, struct net_device *dev, struct nlattr *attr,if (err)return err; - alt_ifname =nla_strdup (attr,GFP_KERNEL ); + alt_ifname =nla_strdup (attr,GFP_KERNEL_ACCOUNT );if (!alt_ifname)return -ENOMEM ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 137/343 net: limit altnames to 64k total
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 155fb43b70b5fce341347a77d1af2765d1e8fbb8 ]
Property list (altname is a link "property") is wrapped in a nlattr. nlattrs length is 16bit so practically speaking the list of properties can't be longer than that, otherwise user space would have to interpret broken netlink messages.
Prevent the problem from occurring by checking the length of the property list before adding new entries.
--- net/core/rtnetlink.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
net/core/rtnetlink.c +11 -0
@@ -3652,12 +3652,23 @@ static int rtnl_alt_ifname(int cmd, struct net_device *dev, struct nlattr *attr, bool *changed, struct netlink_ext_ack *extack) { char *alt_ifname; +size_t size;int err; err =nla_validate (attr, attr->nla_len,IFLA_MAX , ifla_policy, extack);if (err)return err; +if (cmd ==RTM_NEWLINKPROP ) { + size =rtnl_prop_list_size (dev); + size +=nla_total_size (ALTIFNAMSIZ ); +if (size >=U16_MAX ) { +NL_SET_ERR_MSG (extack, +"effective property list too long" ); +return -EINVAL ; + } + } + alt_ifname =nla_strdup (attr,GFP_KERNEL_ACCOUNT );if (!alt_ifname)return -ENOMEM ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 138/343 net/mlx5e: Remove overzealous validations in netlink EEPROM query
In reply to Greg Kroah-HartmanFrom: Gal Pressman <[email protected]>
[ Upstream commit 970adfb76095fa719778d70a6b86030d2feb88dd ]
Unlike the legacy EEPROM callbacks, when using the netlink EEPROM query (get_module_eeprom_by_page) the driver should not try to validate the query parameters, but just perform the read requested by the userspace.
Recent discussion in the mailing list:
https://lore.kernel.org/netdev/20220120093051.70845141@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net/
--- .../net/ethernet/mellanox/mlx5/core/port.c | 23 ------------------- 1 file changed, 23 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/port.c +0 -23
@@ -433,35 +433,12 @@ int mlx5_query_module_eeprom_by_page(struct mlx5_core_dev *dev,struct mlx5_module_eeprom_query_params *params, u8 *data) { - u8 module_id; int err; err =mlx5_query_module_num (dev, ¶ms->module_number);if (err)return err; - err =mlx5_query_module_id (dev, params->module_number, &module_id); -if (err) -return err; - -switch (module_id) { -case MLX5_MODULE_ID_SFP : -if (params->page >0 ) -return -EINVAL ; -break ; -case MLX5_MODULE_ID_QSFP : -case MLX5_MODULE_ID_QSFP28 : -case MLX5_MODULE_ID_QSFP_PLUS : -if (params->page >3 ) -return -EINVAL ; -break ; -case MLX5_MODULE_ID_DSFP : -break ; -default : -mlx5_core_err (dev,"Module ID not recognized: 0x%x\n" , module_id); -return -EINVAL ; - } -if (params->i2c_address !=MLX5_I2C_ADDR_HIGH && params->i2c_address !=MLX5_I2C_ADDR_LOW ) {mlx5_core_err (dev,"I2C address not recognized: 0x%x\n" , params->i2c_address);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 139/343 platform/x86: hp-wmi: Fix SW_TABLET_MODE detection method
In reply to Greg Kroah-HartmanFrom: Jorge Lopez <[email protected]>
[ Upstream commit 520ee4ea1cc60251a6e3c911cf0336278aa52634 ]
The purpose of this patch is to introduce a fix and removal of the current hack when determining tablet mode status.
Determining the tablet mode status requires reading Byte 0 bit 2 as reported by HPWMI_HARDWARE_QUERY. The investigation identified the failure was rooted in two areas: HPWMI_HARDWARE_QUERY failure (0x05) and reading Byte 0, bit 2 only to determine the table mode status. HPWMI_HARDWARE_QUERY WMI failure also rendered the dock state value invalid.
The latest changes use SMBIOS Type 3 (chassis type) and WMI Command 0x40 (device_mode_status) information to determine if the device is in tablet mode or not.
hp_wmi_hw_state function was split into two functions; hp_wmi_get_dock_state and hp_wmi_get_tablet_mode. The new functions separate how dock_state and tablet_mode is handled in a cleaner manner.
All changes were validated on a HP ZBook Workstation notebook, HP EliteBook x360, and HP EliteBook 850 G8.
--- drivers/platform/x86/hp-wmi.c | 71 +++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 19 deletions(-)
drivers/platform/x86/hp-wmi.c +52 -19
@@ -35,10 +35,6 @@ MODULE_LICENSE("GPL");MODULE_ALIAS ("wmi:95F24279-4D7B-4334-9387-ACCDC67EF61C" );MODULE_ALIAS ("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4" ); -static int enable_tablet_mode_sw =-1 ; -module_param (enable_tablet_mode_sw, int,0444 ); -MODULE_PARM_DESC (enable_tablet_mode_sw,"Enable SW_TABLET_MODE reporting (-1=auto, 0=no, 1=yes)" ); -#define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C"#define HPWMI_BIOS_GUID "5FB7F034-2C63-45e9-BE91-3D44E2C707E4"#define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95
@@ -107,6 +103,7 @@ enum hp_wmi_commandtype {HPWMI_FEATURE2_QUERY =0x0d ,HPWMI_WIRELESS2_QUERY =0x1b ,HPWMI_POSTCODEERROR_QUERY =0x2a , +HPWMI_SYSTEM_DEVICE_MODE =0x40 , HPWMI_THERMAL_PROFILE_QUERY = 0x4c, };
@@ -217,6 +214,19 @@ struct rfkill2_device {static int rfkill2_count;static struct rfkill2_device rfkill2[HPWMI_MAX_RFKILL2_DEVICES ]; +/* +* Chassis Types values were obtained from SMBIOS reference +* specification version 3.00. A complete list of system enclosures +* and chassis types is available on Table 17. +*/ +static const char *const tablet_chassis_types[] = { +"30" ,/* Tablet*/ +"31" ,/* Convertible */ +"32" /* Detachable */ +}; + +#define DEVICE_MODE_TABLET 0x06 +/* map output size to the corresponding WMI method id */ static inline int encode_outsize_for_pvsz (int outsize) {
@@ -345,14 +355,39 @@ static int hp_wmi_read_int(int query)return val; } -static int hp_wmi_hw_state (int mask) +static int hp_wmi_get_dock_state (void ) {int state =hp_wmi_read_int (HPWMI_HARDWARE_QUERY );if (state <0 )return state; -return !!(state & mask); +return !!(state &HPWMI_DOCK_MASK ); +} + +static int hp_wmi_get_tablet_mode (void ) +{ +char system_device_mode[4 ] = {0 }; +const char *chassis_type; +bool tablet_found; +int ret; + + chassis_type =dmi_get_system_info (DMI_CHASSIS_TYPE ); +if (!chassis_type) +return -ENODEV ; + + tablet_found =match_string (tablet_chassis_types, +ARRAY_SIZE (tablet_chassis_types), + chassis_type) >=0 ; +if (!tablet_found) +return -ENODEV ; + + ret =hp_wmi_perform_query (HPWMI_SYSTEM_DEVICE_MODE ,HPWMI_READ , + system_device_mode,0 ,sizeof (system_device_mode)); +if (ret <0 ) +return ret; + +return system_device_mode[0 ] ==DEVICE_MODE_TABLET ; }static int omen_thermal_profile_set (int mode)
@@ -568,7 +603,7 @@ static ssize_t als_show(struct device *dev, struct device_attribute *attr,static ssize_t dock_show (struct device *dev,struct device_attribute *attr,char *buf) { -int value =hp_wmi_hw_state (HPWMI_DOCK_MASK ); +int value =hp_wmi_get_dock_state ();if (value <0 )return value;return sprintf (buf,"%d\n" , value);
@@ -577,7 +612,7 @@ static ssize_t dock_show(struct device *dev, struct device_attribute *attr,static ssize_t tablet_show (struct device *dev,struct device_attribute *attr,char *buf) { -int value =hp_wmi_hw_state (HPWMI_TABLET_MASK ); +int value =hp_wmi_get_tablet_mode ();if (value <0 )return value;return sprintf (buf,"%d\n" , value);
@@ -699,10 +734,10 @@ static void hp_wmi_notify(u32 value, void *context)case HPWMI_DOCK_EVENT :if (test_bit (SW_DOCK , hp_wmi_input_dev->swbit))input_report_switch (hp_wmi_input_dev,SW_DOCK , -hp_wmi_hw_state (HPWMI_DOCK_MASK )); +hp_wmi_get_dock_state ());if (test_bit (SW_TABLET_MODE , hp_wmi_input_dev->swbit))input_report_switch (hp_wmi_input_dev,SW_TABLET_MODE , -hp_wmi_hw_state (HPWMI_TABLET_MASK )); +hp_wmi_get_tablet_mode ());input_sync (hp_wmi_input_dev);break ;case HPWMI_PARK_HDD :
@@ -780,19 +815,17 @@ static int __init hp_wmi_input_setup(void)__set_bit (EV_SW , hp_wmi_input_dev->evbit);/* Dock */ - val =hp_wmi_hw_state (HPWMI_DOCK_MASK ); + val =hp_wmi_get_dock_state ();if (!(val <0 )) {__set_bit (SW_DOCK , hp_wmi_input_dev->swbit);input_report_switch (hp_wmi_input_dev,SW_DOCK , val); }/* Tablet mode */ -if (enable_tablet_mode_sw >0 ) { - val =hp_wmi_hw_state (HPWMI_TABLET_MASK ); -if (val >=0 ) { -__set_bit (SW_TABLET_MODE , hp_wmi_input_dev->swbit); -input_report_switch (hp_wmi_input_dev,SW_TABLET_MODE , val); - } + val =hp_wmi_get_tablet_mode (); +if (!(val <0 )) { +__set_bit (SW_TABLET_MODE , hp_wmi_input_dev->swbit); +input_report_switch (hp_wmi_input_dev,SW_TABLET_MODE , val); } err =sparse_keymap_setup (hp_wmi_input_dev, hp_wmi_keymap,NULL );
@@ -1227,10 +1260,10 @@ static int hp_wmi_resume_handler(struct device *device)if (hp_wmi_input_dev) {if (test_bit (SW_DOCK , hp_wmi_input_dev->swbit))input_report_switch (hp_wmi_input_dev,SW_DOCK , -hp_wmi_hw_state (HPWMI_DOCK_MASK )); +hp_wmi_get_dock_state ());if (test_bit (SW_TABLET_MODE , hp_wmi_input_dev->swbit))input_report_switch (hp_wmi_input_dev,SW_TABLET_MODE , -hp_wmi_hw_state (HPWMI_TABLET_MASK )); +hp_wmi_get_tablet_mode ());input_sync (hp_wmi_input_dev); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 140/343 platform/x86: hp-wmi: Fix 0x05 error code reported by several WMI calls
In reply to Greg Kroah-HartmanFrom: Jorge Lopez <[email protected]>
[ Upstream commit be9d73e64957bbd31ee9a0d11adc0f720974c558 ]
Several WMI queries leverage hp_wmi_read_int function to read their data. hp_wmi_read_int function was corrected in a previous patch. Now, this function invokes hp_wmi_perform_query with input parameter of size zero and the output buffer of size 4.
WMI commands calling hp_wmi_perform_query with input buffer size value of zero are listed below.
HPWMI_DISPLAY_QUERYHPWMI_HDDTEMP_QUERYHPWMI_ALS_QUERYHPWMI_HARDWARE_QUERYHPWMI_WIRELESS_QUERYHPWMI_BIOS_QUERYHPWMI_FEATURE_QUERYHPWMI_HOTKEY_QUERYHPWMI_FEATURE2_QUERYHPWMI_WIRELESS2_QUERYHPWMI_POSTCODEERROR_QUERYHPWMI_THERMAL_PROFILE_QUERYHPWMI_FAN_SPEED_MAX_GET_QUERY
Invoking those WMI commands with an input buffer size greater than zero will cause error 0x05 to be returned.
All WMI commands executed by the driver were reviewed and changes were made to ensure the expected input and output buffer size match the WMI specification.
Changes were validated on a HP ZBook Workstation notebook, HP EliteBook x360, and HP EliteBook 850 G8. Additional validation was included in the test process to ensure no other commands were incorrectly handled.
--- drivers/platform/x86/hp-wmi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/platform/x86/hp-wmi.c +11 -11
@@ -330,7 +330,7 @@ static int hp_wmi_get_fan_speed(int fan)char fan_data[4 ] = { fan,0 ,0 ,0 };int ret =hp_wmi_perform_query (HPWMI_FAN_SPEED_GET_QUERY ,HPWMI_GM , - &fan_data,sizeof (fan_data), + &fan_data,sizeof (char ),sizeof (fan_data));if (ret !=0 )
@@ -399,7 +399,7 @@ static int omen_thermal_profile_set(int mode)return -EINVAL ; ret =hp_wmi_perform_query (HPWMI_SET_PERFORMANCE_MODE ,HPWMI_GM , - &buffer,sizeof (buffer),sizeof (buffer)); + &buffer,sizeof (buffer),0 );if (ret)return ret <0 ? ret : -EINVAL ;
@@ -436,7 +436,7 @@ static int hp_wmi_fan_speed_max_set(int enabled)int ret; ret =hp_wmi_perform_query (HPWMI_FAN_SPEED_MAX_SET_QUERY ,HPWMI_GM , - &enabled,sizeof (enabled),sizeof (enabled)); + &enabled,sizeof (enabled),0 );if (ret)return ret <0 ? ret : -EINVAL ;
@@ -449,7 +449,7 @@ static int hp_wmi_fan_speed_max_get(void)int val =0 , ret; ret =hp_wmi_perform_query (HPWMI_FAN_SPEED_MAX_GET_QUERY ,HPWMI_GM , - &val,sizeof (val),sizeof (val)); + &val,0 ,sizeof (val));if (ret)return ret <0 ? ret : -EINVAL ;
@@ -461,7 +461,7 @@ static int __init hp_wmi_bios_2008_later(void) {int state =0 ;int ret =hp_wmi_perform_query (HPWMI_FEATURE_QUERY ,HPWMI_READ , &state, -sizeof (state),sizeof (state)); +0 ,sizeof (state));if (!ret)return 1 ;
@@ -472,7 +472,7 @@ static int __init hp_wmi_bios_2009_later(void) {u8 state[128 ];int ret =hp_wmi_perform_query (HPWMI_FEATURE2_QUERY ,HPWMI_READ , &state, -sizeof (state),sizeof (state)); +0 ,sizeof (state));if (!ret)return 1 ;
@@ -550,7 +550,7 @@ static int hp_wmi_rfkill2_refresh(void)int err, i; err =hp_wmi_perform_query (HPWMI_WIRELESS2_QUERY ,HPWMI_READ , &state, -sizeof (state),sizeof (state)); +0 ,sizeof (state));if (err)return err;
@@ -639,7 +639,7 @@ static ssize_t als_store(struct device *dev, struct device_attribute *attr,return ret; ret =hp_wmi_perform_query (HPWMI_ALS_QUERY ,HPWMI_WRITE , &tmp, -sizeof (tmp),sizeof (tmp)); +sizeof (tmp),0 );if (ret)return ret <0 ? ret : -EINVAL ;
@@ -660,9 +660,9 @@ static ssize_t postcode_store(struct device *dev, struct device_attribute *attr,if (clear == false)return -EINVAL ; -/* Clear the POST error code. It is kept until until cleared. */ +/* Clear the POST error code. It is kept until cleared. */ ret =hp_wmi_perform_query (HPWMI_POSTCODEERROR_QUERY ,HPWMI_WRITE , &tmp, -sizeof (tmp),sizeof (tmp)); +sizeof (tmp),0 );if (ret)return ret <0 ? ret : -EINVAL ;
@@ -952,7 +952,7 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device)int err, i; err =hp_wmi_perform_query (HPWMI_WIRELESS2_QUERY ,HPWMI_READ , &state, -sizeof (state),sizeof (state)); +0 ,sizeof (state));if (err)return err <0 ? err : -EINVAL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 141/343 net: sfp: add 2500base-X quirk for Lantech SFP module
In reply to Greg Kroah-HartmanFrom: Michael Walle <[email protected]>
[ Upstream commit 00eec9fe4f3b9588b4bfa8ef9dd0aae96407d5d7 ]
The Lantech 8330-262D-E module is 2500base-X capable, but it reports the nominal bitrate as 2500MBd instead of 3125MBd. Add a quirk for the module.
The following in an EEPROM dump of such a SFP with the serial number redacted:
00: 03 04 07 00 00 00 01 20 40 0c 05 01 19 00 00 00 ???...? @????...
10: 1e 0f 00 00 4c 61 6e 74 65 63 68 20 20 20 20 20 ??..Lantech
20: 20 20 20 20 00 00 00 00 38 33 33 30 2d 32 36 32 ....8330-262
30: 44 2d 45 20 20 20 20 20 56 31 2e 30 03 52 00 cb D-E V1.0?R.?
40: 00 1a 00 00 46 43 XX XX XX XX XX XX XX XX XX XX .?..FCXXXXXXXXXX
50: 20 20 20 20 32 32 30 32 31 34 20 20 68 b0 01 98 220214 h???
60: 45 58 54 52 45 4d 45 4c 59 20 43 4f 4d 50 41 54 EXTREMELY COMPAT
70: 49 42 4c 45 20 20 20 20 20 20 20 20 20 20 20 20 IBLE
--- drivers/net/phy/sfp-bus.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/phy/sfp-bus.c +6 -0
@@ -74,6 +74,12 @@ static const struct sfp_quirk sfp_quirks[] = { .vendor = "HUAWEI", .part = "MA5671A", .modes = sfp_quirk_2500basex, + }, { +// Lantech 8330-262D-E can operate at 2500base-X, but +// incorrectly report 2500MBd NRZ in their EEPROM + .vendor = "Lantech", + .part = "8330-262D-E", + .modes = sfp_quirk_2500basex, }, { .vendor = "UBNT", .part = "UF-INSTANT",
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 142/343 usb: dwc3: omap: fix "unbalanced disables for smps10_out1" on omap5evm
In reply to Greg Kroah-HartmanFrom: H. Nikolaus Schaller <[email protected]>
[ Upstream commit ac01df343e5a6c6bcead2ed421af1fde30f73e7e ]
Usually, the vbus_regulator (smps10 on omap5evm) boots up disabled.
Hence calling regulator_disable() indirectly through dwc3_omap_set_mailbox() during probe leads to:
[ 10.332764] WARNING: CPU: 0 PID: 1628 at drivers/regulator/core.c:2853 _regulator_disable+0x40/0x164 [ 10.351919] unbalanced disables for smps10_out1 [ 10.361298] Modules linked in: dwc3_omap(+) clk_twl6040 at24 gpio_twl6040 palmas_gpadc palmas_pwrbutton industrialio snd_soc_omap_mcbsp(+) snd_soc_ti_sdma display_connector ti_tpd12s015 drm leds_gpio drm_panel_orientation_quirks ip_tables x_tables ipv6 autofs4 [ 10.387818] CPU: 0 PID: 1628 Comm: systemd-udevd Not tainted 5.17.0-rc1-letux-lpae+ #8139 [ 10.405129] Hardware name: Generic OMAP5 (Flattened Device Tree) [ 10.411455] unwind_backtrace from show_stack+0x10/0x14 [ 10.416970] show_stack from dump_stack_lvl+0x40/0x4c [ 10.422313] dump_stack_lvl from __warn+0xb8/0x170 [ 10.427377] __warn from warn_slowpath_fmt+0x70/0x9c [ 10.432595] warn_slowpath_fmt from _regulator_disable+0x40/0x164 [ 10.439037] _regulator_disable from regulator_disable+0x30/0x64 [ 10.445382] regulator_disable from dwc3_omap_set_mailbox+0x8c/0xf0 [dwc3_omap] [ 10.453116] dwc3_omap_set_mailbox [dwc3_omap] from dwc3_omap_probe+0x2b8/0x394 [dwc3_omap] [ 10.467021] dwc3_omap_probe [dwc3_omap] from platform_probe+0x58/0xa8 [ 10.481762] platform_probe from really_probe+0x168/0x2fc [ 10.481782] really_probe from __driver_probe_device+0xc4/0xd8 [ 10.481782] __driver_probe_device from driver_probe_device+0x24/0xa4 [ 10.503762] driver_probe_device from __driver_attach+0xc4/0xd8 [ 10.510018] __driver_attach from bus_for_each_dev+0x64/0xa0 [ 10.516001] bus_for_each_dev from bus_add_driver+0x148/0x1a4 [ 10.524880] bus_add_driver from driver_register+0xb4/0xf8 [ 10.530678] driver_register from do_one_initcall+0x90/0x1c4 [ 10.536661] do_one_initcall from do_init_module+0x4c/0x200 [ 10.536683] do_init_module from load_module+0x13dc/0x1910 [ 10.551159] load_module from sys_finit_module+0xc8/0xd8 [ 10.561319] sys_finit_module from __sys_trace_return+0x0/0x18 [ 10.561336] Exception stack(0xc344bfa8 to 0xc344bff0) [ 10.561341] bfa0: b6fb5778 b6fab8d8 00000007 b6ecfbb8 00000000 b6ed0398 [ 10.561341] bfc0: b6fb5778 b6fab8d8 855c0500 0000017b 00020000 b6f9a3cc 00000000 b6fb5778 [ 10.595500] bfe0: bede18f8 bede18e8 b6ec9aeb b6dda1c2 [ 10.601345] ---[ end trace 0000000000000000 ]---
Fix this unnecessary warning by checking if the regulator is enabled.
--- drivers/usb/dwc3/dwc3-omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-omap.c +1 -1
@@ -242,7 +242,7 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,break ;case OMAP_DWC3_ID_FLOAT : -if (omap->vbus_reg) +if (omap->vbus_reg &®ulator_is_enabled (omap->vbus_reg))regulator_disable (omap->vbus_reg); val =dwc3_omap_read_utmi_ctrl (omap); val |=USBOTGSS_UTMI_OTG_CTRL_IDDIG ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 143/343 xen/usb: harden xen_hcd against malicious backends
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
[ Upstream commit aff477cb8f94613f501d386d10f20019e294bc35 ]
Make sure a malicious backend can't cause any harm other than wrong I/O data.
Missing are verification of the request id in a response, sanitizing the reported actual I/O length, and protection against interrupt storms from the backend.
--- drivers/usb/host/xen-hcd.c | 57 ++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 14 deletions(-)
drivers/usb/host/xen-hcd.c +43 -14
@@ -51,6 +51,7 @@ struct vdevice_status {struct usb_shadow {struct xenusb_urb_request req;struct urb *urb; +bool in_flight; };struct xenhcd_info {
@@ -722,6 +723,12 @@ static void xenhcd_gnttab_done(struct xenhcd_info *info, unsigned int id)int nr_segs =0 ;int i; +if (!shadow->in_flight) { +xenhcd_set_error (info,"Illegal request id" ); +return ; + } + shadow->in_flight = false; + nr_segs = shadow->req.nr_buffer_segs;if (xenusb_pipeisoc (shadow->req.pipe))
@@ -805,6 +812,7 @@ static int xenhcd_do_request(struct xenhcd_info *info, struct urb_priv *urbp) info->urb_ring.req_prod_pvt++; info->shadow[id].urb = urb; + info->shadow[id].in_flight = true;RING_PUSH_REQUESTS_AND_CHECK_NOTIFY (&info->urb_ring, notify);if (notify)
@@ -933,10 +941,27 @@ static int xenhcd_unlink_urb(struct xenhcd_info *info, struct urb_priv *urbp)return ret; } -static int xenhcd_urb_request_done (struct xenhcd_info *info) +static void xenhcd_res_to_urb (struct xenhcd_info *info, +struct xenusb_urb_response *res,struct urb *urb) +{ +if (unlikely (!urb)) +return ; + +if (res->actual_length > urb->transfer_buffer_length) + urb->actual_length = urb->transfer_buffer_length; +else if (res->actual_length <0 ) + urb->actual_length =0 ; +else + urb->actual_length = res->actual_length; + urb->error_count = res->error_count; + urb->start_frame = res->start_frame; +xenhcd_giveback_urb (info, urb, res->status); +} + +static int xenhcd_urb_request_done (struct xenhcd_info *info, +unsigned int *eoiflag) {struct xenusb_urb_response res; -struct urb *urb;RING_IDX i, rp;__u16 id;int more_to_do =0 ;
@@ -963,16 +988,12 @@ static int xenhcd_urb_request_done(struct xenhcd_info *info)xenhcd_gnttab_done (info, id);if (info->error) goto err; - urb = info->shadow[id].urb; -if (likely (urb)) { - urb->actual_length = res.actual_length; - urb->error_count = res.error_count; - urb->start_frame = res.start_frame; -xenhcd_giveback_urb (info, urb, res.status); - } +xenhcd_res_to_urb (info, &res, info->shadow[id].urb); }xenhcd_add_id_to_freelist (info, id); + + *eoiflag =0 ; } info->urb_ring.rsp_cons = i;
@@ -990,7 +1011,7 @@ static int xenhcd_urb_request_done(struct xenhcd_info *info)return 0 ; } -static int xenhcd_conn_notify (struct xenhcd_info *info) +static int xenhcd_conn_notify (struct xenhcd_info *info,unsigned int *eoiflag) {struct xenusb_conn_response res;struct xenusb_conn_request *req;
@@ -1035,6 +1056,8 @@ static int xenhcd_conn_notify(struct xenhcd_info *info) info->conn_ring.req_prod_pvt); req->id = id; info->conn_ring.req_prod_pvt++; + + *eoiflag =0 ; }if (rc != info->conn_ring.req_prod_pvt)
@@ -1057,14 +1080,19 @@ static int xenhcd_conn_notify(struct xenhcd_info *info)static irqreturn_t xenhcd_int (int irq,void *dev_id) {struct xenhcd_info *info = (struct xenhcd_info *)dev_id; +unsigned int eoiflag =XEN_EOI_FLAG_SPURIOUS ; -if (unlikely (info->error)) +if (unlikely (info->error)) { +xen_irq_lateeoi (irq,XEN_EOI_FLAG_SPURIOUS );return IRQ_HANDLED ; + } -while (xenhcd_urb_request_done (info) |xenhcd_conn_notify (info)) +while (xenhcd_urb_request_done (info, &eoiflag) | +xenhcd_conn_notify (info, &eoiflag))/* Yield point for this unbounded loop. */ cond_resched (); +xen_irq_lateeoi (irq, eoiflag);return IRQ_HANDLED ; }
@@ -1141,9 +1169,9 @@ static int xenhcd_setup_rings(struct xenbus_device *dev, goto fail; } - err =bind_evtchn_to_irq (info->evtchn); + err =bind_evtchn_to_irq_lateeoi (info->evtchn);if (err <=0 ) { -xenbus_dev_fatal (dev, err,"bind_evtchn_to_irq" ); +xenbus_dev_fatal (dev, err,"bind_evtchn_to_irq_lateeoi" ); goto fail; }
@@ -1496,6 +1524,7 @@ static struct usb_hcd *xenhcd_create_hcd(struct xenbus_device *dev)for (i =0 ; i <XENUSB_URB_RING_SIZE ; i++) { info->shadow[i].req.id = i +1 ; info->shadow[i].urb =NULL ; + info->shadow[i].in_flight = false; } info->shadow[XENUSB_URB_RING_SIZE -1 ].req.id =0x0fff ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 144/343 mt76: fix monitor mode crash with sdio driver
In reply to Greg Kroah-HartmanFrom: Deren Wu <[email protected]>
[ Upstream commit 123bc712b1de0805f9d683687e17b1ec2aba0b68 ]
mt7921s driver may receive frames with fragment buffers. If there is a CTS packet received in monitor mode, the payload is 10 bytes only and need 6 bytes header padding after RXD buffer. However, only RXD in the first linear buffer, if we pull buffer size RXD-size+6 bytes with skb_pull(), that would trigger "BUG_ON(skb->len < skb->data_len)" in __skb_pull().
To avoid the nonlinear buffer issue, enlarge the RXD size from 128 to 256 to make sure all MCU operation in linear buffer.
[ 52.007562] kernel BUG at include/linux/skbuff.h:2313! [ 52.007578] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP [ 52.007987] pc : skb_pull+0x48/0x4c [ 52.008015] lr : mt7921_queue_rx_skb+0x494/0x890 [mt7921_common] [ 52.008361] Call trace: [ 52.008377] skb_pull+0x48/0x4c [ 52.008400] mt76s_net_worker+0x134/0x1b0 [mt76_sdio 35339a92c6eb7d4bbcc806a1d22f56365565135c] [ 52.008431] __mt76_worker_fn+0xe8/0x170 [mt76 ef716597d11a77150bc07e3fdd68eeb0f9b56917] [ 52.008449] kthread+0x148/0x3ac [ 52.008466] ret_from_fork+0x10/0x30
--- drivers/net/wireless/mediatek/mt76/mt76.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76.h +1 -1
@@ -19,7 +19,7 @@#define MT_MCU_RING_SIZE 32#define MT_RX_BUF_SIZE 2048 -#define MT_SKB_HEAD_LEN 128 +#define MT_SKB_HEAD_LEN 256#define MT_MAX_NON_AQL_PKT 16#define MT_TXQ_FREE_THR 32
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 145/343 xtensa: fix DTC warning unit_address_format
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
[ Upstream commit e85d29ba4b24f68e7a78cb85c55e754362eeb2de ]
DTC issues the following warnings when building xtfpga device trees:
/soc/flash@00000000/partition@0x0: unit name should not have leading "0x" /soc/flash@00000000/partition@0x6000000: unit name should not have leading "0x" /soc/flash@00000000/partition@0x6800000: unit name should not have leading "0x" /soc/flash@00000000/partition@0x7fe0000: unit name should not have leading "0x"
Drop leading 0x from flash partition unit names.
--- arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi | 8 ++++---- arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi | 8 ++++---- arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-)
arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi +4 -4
@@ -8,19 +8,19 @@ reg = <0x00000000 0x08000000>; bank-width = <2>; device-width = <2>; - partition@0x0 { + partition@0 { label = "data"; reg = <0x00000000 0x06000000>; }; - partition@0x6000000 { + partition@6000000 { label = "boot loader area"; reg = <0x06000000 0x00800000>; }; - partition@0x6800000 { + partition@6800000 { label = "kernel image"; reg = <0x06800000 0x017e0000>; }; - partition@0x7fe0000 { + partition@7fe0000 { label = "boot environment"; reg = <0x07fe0000 0x00020000>; };
arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi +4 -4
@@ -8,19 +8,19 @@ reg = <0x08000000 0x01000000>; bank-width = <2>; device-width = <2>; - partition@0x0 { + partition@0 { label = "boot loader area"; reg = <0x00000000 0x00400000>; }; - partition@0x400000 { + partition@400000 { label = "kernel image"; reg = <0x00400000 0x00600000>; }; - partition@0xa00000 { + partition@a00000 { label = "data"; reg = <0x00a00000 0x005e0000>; }; - partition@0xfe0000 { + partition@fe0000 { label = "boot environment"; reg = <0x00fe0000 0x00020000>; };
arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi +2 -2
@@ -8,11 +8,11 @@ reg = <0x08000000 0x00400000>; bank-width = <2>; device-width = <2>; - partition@0x0 { + partition@0 { label = "boot loader area"; reg = <0x00000000 0x003f0000>; }; - partition@0x3f0000 { + partition@3f0000 { label = "boot environment"; reg = <0x003f0000 0x00010000>; };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 146/343 iwlwifi: mei: fix building iwlmei
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 066291bec0c55315e568ead501bebdefcb8453d2 ]
Building iwlmei without CONFIG_CFG80211 causes a link-time warning:
ld.lld: error: undefined symbol: ieee80211_hdrlen
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
referenced by
net.c
net/wireless/intel/iwlwifi/mei/net.o:(iwl_mei_tx_copy_to_csme) in archivedrivers/built-in.a
Add an explicit dependency to avoid this. In theory it should not be needed here, but it also seems pointless to allow IWLMEI for configurations without CFG80211.
--- drivers/net/wireless/intel/iwlwifi/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/intel/iwlwifi/Kconfig +1 -0
@@ -139,6 +139,7 @@ config IWLMEI tristate "Intel Management Engine communication over WLAN" depends on INTEL_MEI depends on PM + depends on CFG80211 help Enables the iwlmei kernel module.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 147/343 MIPS: ingenic: correct unit node address
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 8931ddd8d6a55fcefb20f44a38ba42bb746f0b62 ]
Unit node addresses should not have leading 0x:
Warning (unit_address_format): /nemc@13410000/efuse@d0/eth-mac-addr@0x22: unit name should not have leading "0x"
--- arch/mips/boot/dts/ingenic/jz4780.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/boot/dts/ingenic/jz4780.dtsi +1 -1
@@ -510,7 +510,7 @@ #address-cells = <1>; #size-cells = <1>; - eth0_addr: eth-mac-addr@0x22 { + eth0_addr: eth-mac-addr@22 { reg = <0x22 0x6>; }; };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 148/343 Bluetooth: Fix use after free in hci_send_acl
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit f63d24baff787e13b723d86fe036f84bdbc35045 ]
This fixes the following trace caused by receiving HCI_EV_DISCONN_PHY_LINK_COMPLETE which does call hci_conn_del without first checking if conn->type is in fact AMP_LINK and in case it is do properly cleanup upper layers with hci_disconn_cfm:
==================================================================
BUG: KASAN: use-after-free in hci_send_acl+0xaba/0xc50
Read of size 8 at addr ffff88800e404818 by task bluetoothd/142
CPU: 0 PID: 142 Comm: bluetoothd Not tainted
5.17.0-rc5-00006-gda4022eeac1a #7
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x45/0x59
print_address_description.constprop.0+0x1f/0x150
kasan_report.cold+0x7f/0x11b
hci_send_acl+0xaba/0xc50
l2cap_do_send+0x23f/0x3d0
l2cap_chan_send+0xc06/0x2cc0
l2cap_sock_sendmsg+0x201/0x2b0
sock_sendmsg+0xdc/0x110
sock_write_iter+0x20f/0x370
do_iter_readv_writev+0x343/0x690
do_iter_write+0x132/0x640
vfs_writev+0x198/0x570
do_writev+0x202/0x280
do_syscall_64+0x38/0x90
entry_SYSCALL_64_after_hwframe+0x44/0xae
RSP: 002b:00007ffce8a099b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000014
Code: 0f 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b8 0f 1f 00 f3
0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 14 00 00 00 0f 05
<48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 89 54 24 1c 48 89 74 24 10
RDX: 0000000000000001 RSI: 00007ffce8a099e0 RDI: 0000000000000015
RAX: ffffffffffffffda RBX: 00007ffce8a099e0 RCX: 00007f788fc3cf77
R10: 00007ffce8af7080 R11: 0000000000000246 R12: 000055e4ccf75580
RBP: 0000000000000015 R08: 0000000000000002 R09: 0000000000000001
</TASK>
R13: 000055e4ccf754a0 R14: 000055e4ccf75cd0 R15: 000055e4ccf4a6b0
Allocated by task 45:
kasan_save_stack+0x1e/0x40
__kasan_kmalloc+0x81/0xa0
hci_chan_create+0x9a/0x2f0
l2cap_conn_add.part.0+0x1a/0xdc0
l2cap_connect_cfm+0x236/0x1000
le_conn_complete_evt+0x15a7/0x1db0
hci_le_conn_complete_evt+0x226/0x2c0
hci_le_meta_evt+0x247/0x450
hci_event_packet+0x61b/0xe90
hci_rx_work+0x4d5/0xc50
process_one_work+0x8fb/0x15a0
worker_thread+0x576/0x1240
kthread+0x29d/0x340
ret_from_fork+0x1f/0x30
Freed by task 45:
kasan_save_stack+0x1e/0x40
kasan_set_track+0x21/0x30
kasan_set_free_info+0x20/0x30
__kasan_slab_free+0xfb/0x130
kfree+0xac/0x350
hci_conn_cleanup+0x101/0x6a0
hci_conn_del+0x27e/0x6c0
hci_disconn_phylink_complete_evt+0xe0/0x120
hci_event_packet+0x812/0xe90
hci_rx_work+0x4d5/0xc50
process_one_work+0x8fb/0x15a0
worker_thread+0x576/0x1240
kthread+0x29d/0x340
ret_from_fork+0x1f/0x30
The buggy address belongs to the object at ffff88800c0f0500
The buggy address is located 24 bytes inside of
which belongs to the cache kmalloc-128 of size 128
The buggy address belongs to the page:
128-byte region [ffff88800c0f0500, ffff88800c0f0580)
flags: 0x100000000000200(slab|node=0|zone=1)
page:00000000fe45cd86 refcount:1 mapcount:0
mapping:0000000000000000 index:0x0 pfn:0xc0f0
raw: 0000000000000000 0000000080100010 00000001ffffffff
0000000000000000
raw: 0100000000000200 ffffea00003a2c80 dead000000000004
ffff8880078418c0
page dumped because: kasan: bad access detected
ffff88800c0f0400: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc
Memory state around the buggy address:
>ffff88800c0f0500: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88800c0f0480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88800c0f0580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
==================================================================
ffff88800c0f0600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb--- net/bluetooth/hci_event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/hci_event.c +2 -1
@@ -5453,8 +5453,9 @@ static void hci_disconn_phylink_complete_evt(struct hci_dev *hdev, void *data,hci_dev_lock (hdev); hcon =hci_conn_hash_lookup_handle (hdev, ev->phy_handle); -if (hcon) { +if (hcon && hcon->type ==AMP_LINK ) { hcon->state =BT_CLOSED ; +hci_disconn_cfm (hcon, ev->reason);hci_conn_del (hcon); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 149/343 netfilter: conntrack: revisit gc autotuning
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit 2cfadb761d3d0219412fd8150faea60c7e863833 ]
as of commit 4608fdfc07e1
("netfilter: conntrack: collect all entries in one cycle") conntrack gc was changed to run every 2 minutes.
On systems where conntrack hash table is set to large value, most evictions happen from gc worker rather than the packet path due to hash table distribution.
This causes netlink event overflows when events are collected.
This change collects average expiry of scanned entries and reschedules to the average remaining value, within 1 to 60 second interval.
To avoid event overflows, reschedule after each bucket and add a limit for both run time and number of evictions per run.
If more entries have to be evicted, reschedule and restart 1 jiffy into the future.
--- net/netfilter/nf_conntrack_core.c | 85 ++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 17 deletions(-)
net/netfilter/nf_conntrack_core.c +68 -17
@@ -67,6 +67,8 @@ EXPORT_SYMBOL_GPL(nf_conntrack_hash);struct conntrack_gc_work {struct delayed_work dwork;u32 next_bucket; +u32 avg_timeout; +u32 start_time;bool exiting;bool early_drop; };
@@ -78,8 +80,19 @@ static __read_mostly bool nf_conntrack_locks_all;/* serialize hash resizes and nf_ct_iterate_cleanup */ static DEFINE_MUTEX (nf_conntrack_mutex); -#define GC_SCAN_INTERVAL (120u * HZ) +#define GC_SCAN_INTERVAL_MAX (60ul * HZ) +#define GC_SCAN_INTERVAL_MIN (1ul * HZ) + +/* clamp timeouts to this value (TCP unacked) */ +#define GC_SCAN_INTERVAL_CLAMP (300ul * HZ) + +/* large initial bias so that we don't scan often just because we have +* three entries with a 1s timeout. +*/ +#define GC_SCAN_INTERVAL_INIT INT_MAX +#define GC_SCAN_MAX_DURATION msecs_to_jiffies(10) +#define GC_SCAN_EXPIRED_MAX (64000u / HZ)#define MIN_CHAINLEN 8u#define MAX_CHAINLEN (32u - MIN_CHAINLEN)
@@ -1421,16 +1434,28 @@ static bool gc_worker_can_early_drop(const struct nf_conn *ct)static void gc_worker (struct work_struct *work) { -unsigned long end_time = jiffies +GC_SCAN_MAX_DURATION ;unsigned int i, hashsz, nf_conntrack_max95 =0 ; -unsigned long next_run =GC_SCAN_INTERVAL ; +u32 end_time, start_time = nfct_time_stamp;struct conntrack_gc_work *gc_work; +unsigned int expired_count =0 ; +unsigned long next_run; +s32 delta_time; + gc_work = container_of(work, struct conntrack_gc_work, dwork.work); i = gc_work->next_bucket;if (gc_work->early_drop) nf_conntrack_max95 = nf_conntrack_max /100u *95u ; +if (i ==0 ) { + gc_work->avg_timeout =GC_SCAN_INTERVAL_INIT ; + gc_work->start_time = start_time; + } + + next_run = gc_work->avg_timeout; + + end_time = start_time +GC_SCAN_MAX_DURATION ; + do { struct nf_conntrack_tuple_hash *h; struct hlist_nulls_head *ct_hash;
@@ -1447,6 +1472,7 @@ static void gc_worker(struct work_struct *work)hlist_nulls_for_each_entry_rcu (h, n, &ct_hash[i], hnnode) {struct nf_conntrack_net *cnet; +unsigned long expires;struct net *net; tmp =nf_ct_tuplehash_to_ctrack (h);
@@ -1456,11 +1482,29 @@ static void gc_worker(struct work_struct *work)continue ; } +if (expired_count >GC_SCAN_EXPIRED_MAX ) { +rcu_read_unlock (); + + gc_work->next_bucket = i; + gc_work->avg_timeout = next_run; + + delta_time = nfct_time_stamp - gc_work->start_time; + +/* re-sched immediately if total cycle time is exceeded */ + next_run = delta_time < (s32 )GC_SCAN_INTERVAL_MAX ; + goto early_exit; + } +if (nf_ct_is_expired (tmp)) {nf_ct_gc_expired (tmp); + expired_count++;continue ; } + expires =clamp (nf_ct_expires (tmp),GC_SCAN_INTERVAL_MIN ,GC_SCAN_INTERVAL_CLAMP ); + next_run += expires; + next_run /=2u ; +if (nf_conntrack_max95 ==0 ||gc_worker_skip_ct (tmp))continue ;
@@ -1478,8 +1522,10 @@ static void gc_worker(struct work_struct *work)continue ; } -if (gc_worker_can_early_drop (tmp)) +if (gc_worker_can_early_drop (tmp)) {nf_ct_kill (tmp); + expired_count++; + }nf_ct_put (tmp); }
@@ -1492,33 +1538,38 @@ static void gc_worker(struct work_struct *work)cond_resched (); i++; -if (time_after (jiffies, end_time) && i < hashsz) { + delta_time = nfct_time_stamp - end_time; +if (delta_time >0 && i < hashsz) { + gc_work->avg_timeout = next_run; gc_work->next_bucket = i; next_run =0 ; -break ; + goto early_exit; } }while (i < hashsz); + gc_work->next_bucket =0 ; + + next_run =clamp (next_run,GC_SCAN_INTERVAL_MIN ,GC_SCAN_INTERVAL_MAX ); + + delta_time =max_t (s32, nfct_time_stamp - gc_work->start_time,1 ); +if (next_run > (unsigned long )delta_time) + next_run -= delta_time; +else + next_run =1 ; + +early_exit:if (gc_work->exiting)return ; -/* -* Eviction will normally happen from the packet path, and not -* from this gc worker. -* -* This worker is only here to reap expired entries when system went -* idle after a busy period. -*/ -if (next_run) { +if (next_run) gc_work->early_drop = false; - gc_work->next_bucket =0 ; - } +queue_delayed_work (system_power_efficient_wq, &gc_work->dwork, next_run); }static void conntrack_gc_work_init (struct conntrack_gc_work *gc_work) { -INIT_DEFERRABLE_WORK (&gc_work->dwork, gc_worker); +INIT_DELAYED_WORK (&gc_work->dwork, gc_worker); gc_work->exiting = false; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 150/343 netlabel: fix out-of-bounds memory accesses
In reply to Greg Kroah-HartmanFrom: Wang Yufen <[email protected]>
[ Upstream commit f22881de730ebd472e15bcc2c0d1d46e36a87b9c ]
In calipso_map_cat_ntoh(), in the for loop, if the return value of netlbl_bitmap_walk() is equal to (net_clen_bits - 1), when netlbl_bitmap_walk() is called next time, out-of-bounds memory accesses of bitmap[byte_offset] occurs.
The bug was found during fuzzing. The following is the fuzzing report
BUG: KASAN: slab-out-of-bounds in netlbl_bitmap_walk+0x3c/0xd0 Read of size 1 at addr ffffff8107bf6f70 by task err_OH/252 CPU: 7 PID: 252 Comm: err_OH Not tainted 5.17.0-rc7+ #17 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace+0x21c/0x230 show_stack+0x1c/0x60 dump_stack_lvl+0x64/0x7c print_address_description.constprop.0+0x70/0x2d0 __kasan_report+0x158/0x16c kasan_report+0x74/0x120 __asan_load1+0x80/0xa0 netlbl_bitmap_walk+0x3c/0xd0 calipso_opt_getattr+0x1a8/0x230 calipso_sock_getattr+0x218/0x340 calipso_sock_getattr+0x44/0x60 netlbl_sock_getattr+0x44/0x80 selinux_netlbl_socket_setsockopt+0x138/0x170 selinux_socket_setsockopt+0x4c/0x60 security_socket_setsockopt+0x4c/0x90 __sys_setsockopt+0xbc/0x2b0 __arm64_sys_setsockopt+0x6c/0x84 invoke_syscall+0x64/0x190 el0_svc_common.constprop.0+0x88/0x200 do_el0_svc+0x88/0xa0 el0_svc+0x128/0x1b0 el0t_64_sync_handler+0x9c/0x120 el0t_64_sync+0x16c/0x170
--- net/netlabel/netlabel_kapi.c | 2 ++ 1 file changed, 2 insertions(+)
net/netlabel/netlabel_kapi.c +2 -0
@@ -885,6 +885,8 @@ int netlbl_bitmap_walk(const unsigned char *bitmap, u32 bitmap_len,unsigned char bitmask;unsigned char byte; +if (offset >= bitmap_len) +return -1 ; byte_offset = offset /8 ; byte = bitmap[byte_offset]; bit_spot = offset;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 151/343 ceph: fix inode reference leakage in ceph_get_snapdir()
In reply to Greg Kroah-HartmanFrom: Xiubo Li <[email protected]>
[ Upstream commit 322794d3355c33adcc4feace0045d85a8e4ed813 ]
The ceph_get_inode() will search for or insert a new inode into the hash for the given vino, and return a reference to it. If new is non-NULL, its reference is consumed.
We should release the reference when in error handing cases.
--- fs/ceph/inode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/ceph/inode.c +8 -2
@@ -87,13 +87,13 @@ struct inode *ceph_get_snapdir(struct inode *parent)if (!S_ISDIR (parent->i_mode)) {pr_warn_once ("bad snapdir parent type (mode=0%o)\n" , parent->i_mode); -return ERR_PTR (-ENOTDIR ); + goto err; }if (!(inode->i_state &I_NEW ) && !S_ISDIR (inode->i_mode)) {pr_warn_once ("bad snapdir inode type (mode=0%o)\n" , inode->i_mode); -return ERR_PTR (-ENOTDIR ); + goto err; } inode->i_mode = parent->i_mode;
@@ -113,6 +113,12 @@ struct inode *ceph_get_snapdir(struct inode *parent) }return inode; +err: +if ((inode->i_state &I_NEW )) +discard_new_inode (inode); +else +iput (inode); +return ERR_PTR (-ENOTDIR ); }const struct inode_operations ceph_file_iops = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 152/343 ceph: fix memory leak in ceph_readdir when note_last_dentry returns error
In reply to Greg Kroah-HartmanFrom: Xiubo Li <[email protected]>
[ Upstream commit f639d9867eea647005dc824e0e24f39ffc50d4e4 ]
Reset the last_readdir at the same time, and add a comment explaining why we don't free last_readdir when dir_emit returns false.
--- fs/ceph/dir.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
fs/ceph/dir.c +10 -1
@@ -478,8 +478,11 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx) 2 : (fpos_off(rde->offset) + 1); err =note_last_dentry (dfi, rde->name, rde->name_len, next_offset); -if (err) +if (err) { +ceph_mdsc_put_request (dfi->last_readdir); + dfi->last_readdir =NULL ;return err; + } }else if (req->r_reply_info.dir_end) { dfi->next_offset =2 ;/* keep last name */
@@ -520,6 +523,12 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)if (!dir_emit (ctx, rde->name, rde->name_len,ceph_present_ino (inode->i_sb,le64_to_cpu (rde->inode.in->ino)),le32_to_cpu (rde->inode.in->mode) >>12 )) { +/* +* NOTE: Here no need to put the 'dfi->last_readdir', +* because when dir_emit stops us it's most likely +* doesn't have enough memory, etc. So for next readdir +* it will continue. +*/ dout ("filldir stopping us...\n" );return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 153/343 lib/Kconfig.debug: add ARCH dependency for FUNCTION_ALIGN option
In reply to Greg Kroah-HartmanFrom: Feng Tang <[email protected]>
[ Upstream commit 1bf18da62106225dbc47aab41efee2aeb99caccd ]
0Day robots reported there is compiling issue for 'csky' ARCH when CONFIG_DEBUG_FORCE_DATA_SECTION_ALIGNED is enabled [1]:
All errors (new ones prefixed by >>):
{standard input}: Assembler messages:
Quoted 1 line
Quoted 1 line
{standard input}:2277: Error: pcrel offset for branch to .LS000B too far (
0x3c)
Which was discussed in [2]. And as there is no solution for csky yet, add some dependency for this config to limit it to several ARCHs which have no compiling issue so far.
[1]. https://lore.kernel.org/lkml/[email protected]/
[2]. https://www.spinics.net/lists/linux-kbuild/msg30298.html
--- lib/Kconfig.debug | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/Kconfig.debug +2 -1
@@ -416,7 +416,8 @@ config SECTION_MISMATCH_WARN_ONLY If unsure, say Y. config DEBUG_FORCE_FUNCTION_ALIGN_64B - bool "Force all function address 64B aligned" if EXPERT + bool "Force all function address 64B aligned" + depends on EXPERT && (X86_64 || ARM64 || PPC32 || PPC64 || ARC) help There are cases that a commit from one domain changes the function address alignment of other domains, and cause magic performance
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 154/343 init/main.c: return 1 from handled __setup() functions
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit f9a40b0890658330c83c95511f9d6b396610defc ]
initcall_blacklist() should return 1 to indicate that it handled its cmdline arguments.
set_debug_rodata() should return 1 to indicate that it handled its cmdline arguments. Print a warning if the option string is invalid.
This prevents these strings from being added to the 'init' program's environment as they are not init arguments/parameters.
--- init/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
init/main.c +4 -2
@@ -1192,7 +1192,7 @@ static int __init initcall_blacklist(char *str) } }while (str_entry); -return 0 ; +return 1 ; } static bool __init_or_module initcall_blacklisted(initcall_t fn)
@@ -1454,7 +1454,9 @@ static noinline void __init kernel_init_freeable(void);bool rodata_enabled__ro_after_init = true;static int __init set_debug_rodata (char *str) { -return strtobool (str, &rodata_enabled); +if (strtobool (str, &rodata_enabled)) +pr_warn ("Invalid option string for rodata: '%s'\n" , str); +return 1 ; }__setup ("rodata=" , set_debug_rodata);#endif
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 155/343 minix: fix bug when opening a file with O_DIRECT
In reply to Greg Kroah-HartmanFrom: Qinghua Jin <[email protected]>
[ Upstream commit 9ce3c0d26c42d279b6c378a03cd6a61d828f19ca ]
Testcase:
1. create a minix file system and mount it
2. open a file on the file system with O_RDWR|O_CREAT|O_TRUNC|O_DIRECT
3. open fails with -EINVAL but leaves an empty file behind. All other open() failures don't leave the failed open files behind.
It is hard to check the direct_IO op before creating the inode. Just as ext4 and btrfs do, this patch will resolve the issue by allowing to create the file with O_DIRECT but returning error when writing the file.
--- fs/minix/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/minix/inode.c +2 -1
@@ -447,7 +447,8 @@ static const struct address_space_operations minix_aops = { .writepage = minix_writepage, .write_begin = minix_write_begin, .write_end = generic_write_end, - .bmap = minix_bmap + .bmap = minix_bmap, + .direct_IO = noop_direct_IO };static const struct inode_operations minix_symlink_inode_operations = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 156/343 clk: si5341: fix reported clk_rate when output divider is 2
In reply to Greg Kroah-HartmanFrom: Adam Wujek <[email protected]>
[ Upstream commit 2a8b539433e111c4de364237627ef219d2f6350a ]
SI5341_OUT_CFG_RDIV_FORCE2 shall be checked first to distinguish whether a divider for a given output is set to 2 (SI5341_OUT_CFG_RDIV_FORCE2 is set) or the output is disabled (SI5341_OUT_CFG_RDIV_FORCE2 not set, SI5341_OUT_R_REG is set 0).
Before the change, divider set to 2 (SI5341_OUT_R_REG set to 0) was interpreted as output is disabled.
--- drivers/clk/clk-si5341.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/clk/clk-si5341.c +9 -7
@@ -798,6 +798,15 @@ static unsigned long si5341_output_clk_recalc_rate(struct clk_hw *hw,u32 r_divider;u8 r[3 ]; + err =regmap_read (output->data->regmap, +SI5341_OUT_CONFIG (output), &val); +if (err <0 ) +return err; + +/* If SI5341_OUT_CFG_RDIV_FORCE2 is set, r_divider is 2 */ +if (val &SI5341_OUT_CFG_RDIV_FORCE2 ) +return parent_rate /2 ; + err =regmap_bulk_read (output->data->regmap,SI5341_OUT_R_REG (output), r,3 );if (err <0 )
@@ -814,13 +823,6 @@ static unsigned long si5341_output_clk_recalc_rate(struct clk_hw *hw, r_divider +=1 ; r_divider <<=1 ; - err =regmap_read (output->data->regmap, -SI5341_OUT_CONFIG (output), &val); -if (err <0 ) -return err; - -if (val &SI5341_OUT_CFG_RDIV_FORCE2 ) - r_divider =2 ;return parent_rate / r_divider; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 157/343 clk: mediatek: Fix memory leaks on probe
In reply to Greg Kroah-HartmanFrom: José Expósito <[email protected]>
[ Upstream commit 7a688c91d3fd54c53e7a9edd6052cdae98dd99d8 ]
Handle the error branches to free memory where required.
Addresses-Coverity-ID: 1491825 ("Resource leak")
--- drivers/clk/mediatek/clk-mt8192.c | 36 +++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-)
drivers/clk/mediatek/clk-mt8192.c +30 -6
@@ -1236,9 +1236,17 @@ static int clk_mt8192_infra_probe(struct platform_device *pdev) r =mtk_clk_register_gates (node, infra_clks,ARRAY_SIZE (infra_clks), clk_data);if (r) -return r; + goto free_clk_data; + + r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); +if (r) + goto free_clk_data; + +return r; -return of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); +free_clk_data: +mtk_free_clk_data (clk_data); +return r; }static int clk_mt8192_peri_probe (struct platform_device *pdev)
@@ -1253,9 +1261,17 @@ static int clk_mt8192_peri_probe(struct platform_device *pdev) r =mtk_clk_register_gates (node, peri_clks,ARRAY_SIZE (peri_clks), clk_data);if (r) -return r; + goto free_clk_data; + + r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); +if (r) + goto free_clk_data; -return of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); +return r; + +free_clk_data: +mtk_free_clk_data (clk_data); +return r; }static int clk_mt8192_apmixed_probe (struct platform_device *pdev)
@@ -1271,9 +1287,17 @@ static int clk_mt8192_apmixed_probe(struct platform_device *pdev)mtk_clk_register_plls (node, plls,ARRAY_SIZE (plls), clk_data); r =mtk_clk_register_gates (node, apmixed_clks,ARRAY_SIZE (apmixed_clks), clk_data);if (r) -return r; + goto free_clk_data; -return of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); + r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); +if (r) + goto free_clk_data; + +return r; + +free_clk_data: +mtk_free_clk_data (clk_data); +return r; }static const struct of_device_id of_match_clk_mt8192[] = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 158/343 staging: vchiq_arm: Avoid NULL ptr deref in vchiq_dump_platform_instances
In reply to Greg Kroah-HartmanFrom: Stefan Wahren <[email protected]>
[ Upstream commit aa899e686d442c63d50f4d369cc02dbbf0941cb0 ]
vchiq_get_state() can return a NULL pointer. So handle this cases and avoid a NULL pointer derefence in vchiq_dump_platform_instances.
--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +3 -0
@@ -1209,6 +1209,9 @@ int vchiq_dump_platform_instances(void *dump_context)int len;int i; +if (!state) +return -ENOTCONN ; +/* * There is no list of instances, so instead scan all services, * marking those that have been dumped.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 159/343 staging: vchiq_core: handle NULL result of find_service_by_handle
In reply to Greg Kroah-HartmanFrom: Stefan Wahren <[email protected]>
[ Upstream commit ca225857faf237234d2fffe5d1919467dfadd822 ]
In case of an invalid handle the function find_servive_by_handle returns NULL. So take care of this and avoid a NULL pointer dereference.
--- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +6 -0
@@ -2306,6 +2306,9 @@ void vchiq_msg_queue_push(unsigned int handle, struct vchiq_header *header)struct vchiq_service *service =find_service_by_handle (handle);int pos; +if (!service) +return ; +while (service->msg_queue_write == service->msg_queue_read +VCHIQ_MAX_SLOTS ) {if (wait_for_completion_interruptible (&service->msg_queue_pop))
@@ -2326,6 +2329,9 @@ struct vchiq_header *vchiq_msg_hold(unsigned int handle)struct vchiq_header *header;int pos; +if (!service) +return NULL ; +if (service->msg_queue_write == service->msg_queue_read)return NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 160/343 phy: amlogic: phy-meson-gxl-usb2: fix shared reset controller use
In reply to Greg Kroah-HartmanFrom: Amjad Ouled-Ameur <[email protected]>
[ Upstream commit 2f87727130ce17ffefecd0895eeebf22d5a36f6f ]
Use reset_control_rearm() call if an error occurs in case phy_meson_gxl_usb2_init() fails after reset() has been called ; or in case phy_meson_gxl_usb2_exit() is called i.e the resource is no longer used and the reset line may be triggered again by other devices.
reset_control_rearm() keeps use of triggered_count sane in the reset framework. Therefore, use of reset_control_reset() on shared reset line should be balanced with reset_control_rearm().
--- drivers/phy/amlogic/phy-meson-gxl-usb2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/phy/amlogic/phy-meson-gxl-usb2.c +4 -1
@@ -114,8 +114,10 @@ static int phy_meson_gxl_usb2_init(struct phy *phy)return ret; ret =clk_prepare_enable (priv->clk); -if (ret) +if (ret) { +reset_control_rearm (priv->reset);return ret; + }return 0 ; }
@@ -125,6 +127,7 @@ static int phy_meson_gxl_usb2_exit(struct phy *phy)struct phy_meson_gxl_usb2_priv *priv =phy_get_drvdata (phy);clk_disable_unprepare (priv->clk); +reset_control_rearm (priv->reset);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 161/343 phy: amlogic: meson8b-usb2: Use dev_err_probe()
In reply to Greg Kroah-HartmanFrom: Amjad Ouled-Ameur <[email protected]>
[ Upstream commit 6466ba1898d415b527e1013bd8551a6fdfece94c ]
Use the existing dev_err_probe() helper instead of open-coding the same operation.
--- drivers/phy/amlogic/phy-meson8b-usb2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/phy/amlogic/phy-meson8b-usb2.c +3 -2
@@ -265,8 +265,9 @@ static int phy_meson8b_usb2_probe(struct platform_device *pdev)return PTR_ERR (priv->clk_usb); priv->reset =devm_reset_control_get_optional_shared (&pdev->dev,NULL ); -if (PTR_ERR (priv->reset) == -EPROBE_DEFER ) -return PTR_ERR (priv->reset); +if (IS_ERR (priv->reset)) +return dev_err_probe (&pdev->dev,PTR_ERR (priv->reset), +"Failed to get the reset line" ); priv->dr_mode =of_usb_get_dr_mode_by_phy (pdev->dev.of_node,-1 );if (priv->dr_mode ==USB_DR_MODE_UNKNOWN ) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 162/343 phy: amlogic: meson8b-usb2: fix shared reset control use
In reply to Greg Kroah-HartmanFrom: Amjad Ouled-Ameur <[email protected]>
[ Upstream commit 6f1dedf089ab1a4f03ea7aadc3c4a99885b4b4a0 ]
Use reset_control_rearm() call if an error occurs in case phy_meson8b_usb2_power_on() fails after reset() has been called, or in case phy_meson8b_usb2_power_off() is called i.e the resource is no longer used and the reset line may be triggered again by other devices.
reset_control_rearm() keeps use of triggered_count sane in the reset framework, use of reset_control_reset() on shared reset line should be balanced with reset_control_rearm().
--- drivers/phy/amlogic/phy-meson8b-usb2.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/phy/amlogic/phy-meson8b-usb2.c +4 -0
@@ -154,6 +154,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy) ret =clk_prepare_enable (priv->clk_usb_general);if (ret) {dev_err (&phy->dev,"Failed to enable USB general clock\n" ); +reset_control_rearm (priv->reset);return ret; }
@@ -161,6 +162,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)if (ret) {dev_err (&phy->dev,"Failed to enable USB DDR clock\n" );clk_disable_unprepare (priv->clk_usb_general); +reset_control_rearm (priv->reset);return ret; }
@@ -199,6 +201,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)dev_warn (&phy->dev,"USB ID detect failed!\n" );clk_disable_unprepare (priv->clk_usb);clk_disable_unprepare (priv->clk_usb_general); +reset_control_rearm (priv->reset);return -EINVAL ; } }
@@ -218,6 +221,7 @@ static int phy_meson8b_usb2_power_off(struct phy *phy)clk_disable_unprepare (priv->clk_usb);clk_disable_unprepare (priv->clk_usb_general); +reset_control_rearm (priv->reset);/* power off the PHY by putting it into reset mode */ regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 163/343 clk: rockchip: drop CLK_SET_RATE_PARENT from dclk_vop* on rk3568
In reply to Greg Kroah-HartmanFrom: Sascha Hauer <[email protected]>
[ Upstream commit ff3187eabb5ce478d15b6ed62eb286756adefac3 ]
The pixel clocks dclk_vop[012] can be clocked from hpll, vpll, gpll or cpll. gpll and cpll also drive many other clocks, so changing the dclk_vop[012] clocks could change these other clocks as well. Drop CLK_SET_RATE_PARENT to fix that. With this change the VOP2 driver can only adjust the pixel clocks with the divider between the PLL and the dclk_vop[012] which means the user may have to adjust the PLL clock to a suitable rate using the assigned-clock-rate device tree property.
--- drivers/clk/rockchip/clk-rk3568.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/rockchip/clk-rk3568.c +3 -3
@@ -1038,13 +1038,13 @@ static struct rockchip_clk_branch rk3568_clk_branches[] __initdata = { RK3568_CLKGATE_CON(20), 8, GFLAGS),GATE (HCLK_VOP ,"hclk_vop" ,"hclk_vo" ,0 ,RK3568_CLKGATE_CON (20 ),9 ,GFLAGS ), -COMPOSITE (DCLK_VOP0 ,"dclk_vop0" , hpll_vpll_gpll_cpll_p,CLK_SET_RATE_PARENT |CLK_SET_RATE_NO_REPARENT , +COMPOSITE (DCLK_VOP0 ,"dclk_vop0" , hpll_vpll_gpll_cpll_p,CLK_SET_RATE_NO_REPARENT ,RK3568_CLKSEL_CON (39 ),10 ,2 ,MFLAGS ,0 ,8 ,DFLAGS ,RK3568_CLKGATE_CON (20 ),10 ,GFLAGS ), -COMPOSITE (DCLK_VOP1 ,"dclk_vop1" , hpll_vpll_gpll_cpll_p,CLK_SET_RATE_PARENT |CLK_SET_RATE_NO_REPARENT , +COMPOSITE (DCLK_VOP1 ,"dclk_vop1" , hpll_vpll_gpll_cpll_p,CLK_SET_RATE_NO_REPARENT ,RK3568_CLKSEL_CON (40 ),10 ,2 ,MFLAGS ,0 ,8 ,DFLAGS ,RK3568_CLKGATE_CON (20 ),11 ,GFLAGS ), -COMPOSITE (DCLK_VOP2 ,"dclk_vop2" , hpll_vpll_gpll_cpll_p,0 , +COMPOSITE (DCLK_VOP2 ,"dclk_vop2" , hpll_vpll_gpll_cpll_p,CLK_SET_RATE_NO_REPARENT ,RK3568_CLKSEL_CON (41 ),10 ,2 ,MFLAGS ,0 ,8 ,DFLAGS ,RK3568_CLKGATE_CON (20 ),12 ,GFLAGS ), GATE(CLK_VOP_PWM, "clk_vop_pwm", "xin24m", 0,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 164/343 cpufreq: CPPC: Fix performance/frequency conversion
In reply to Greg Kroah-HartmanFrom: Pierre Gondois <[email protected]>
[ Upstream commit ec1c7ad47664f964c1101fe555b6fde0cb124b38 ]
CPUfreq governors request CPU frequencies using information on current CPU usage. The CPPC driver converts them to performance requests. Frequency targets are computed as:
target_freq = (util / cpu_capacity) * max_freqtarget_freq is then clamped between [policy->min, policy->max].
The CPPC driver converts performance values to frequencies (and vice-versa) using cppc_cpufreq_perf_to_khz() and cppc_cpufreq_khz_to_perf(). These functions both use two different factors depending on the range of the input value. For cppc_cpufreq_khz_to_perf():
- (NOMINAL_PERF / NOMINAL_FREQ) or
- (LOWEST_PERF / LOWEST_FREQ)
and for cppc_cpufreq_perf_to_khz():
- (NOMINAL_FREQ / NOMINAL_PERF) or
- ((NOMINAL_PERF - LOWEST_FREQ) / (NOMINAL_PERF - LOWEST_PERF))
This means:
1- the functions are not inverse for some values:
(perf_to_khz(khz_to_perf(x)) != x)
2- cppc_cpufreq_perf_to_khz(LOWEST_PERF) can sometimes give
a different value from LOWEST_FREQ due to integer approximation
3- it is implied that performance and frequency are proportional
(NOMINAL_FREQ / NOMINAL_PERF) == (LOWEST_PERF / LOWEST_FREQ)
This patch changes the conversion functions to an affine function. This fixes the 3 points above.
--- drivers/cpufreq/cppc_cpufreq.c | 43 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 22 deletions(-)
drivers/cpufreq/cppc_cpufreq.c +21 -22
@@ -303,52 +303,48 @@ static u64 cppc_get_dmi_max_khz(void)/* * If CPPC lowest_freq and nominal_freq registers are exposed then we can -* use them to convert perf to freq and vice versa -* -* If the perf/freq point lies between Nominal and Lowest, we can treat -* (Low perf, Low freq) and (Nom Perf, Nom freq) as 2D co-ordinates of a line -* and extrapolate the rest -* For perf/freq > Nominal, we use the ratio perf:freq at Nominal for conversion +* use them to convert perf to freq and vice versa. The conversion is +* extrapolated as an affine function passing by the 2 points: +* - (Low perf, Low freq) +* - (Nominal perf, Nominal perf) */ static unsigned int cppc_cpufreq_perf_to_khz (struct cppc_cpudata *cpu_data,unsigned int perf) {struct cppc_perf_caps *caps = &cpu_data->perf_caps; +s64 retval, offset =0 ;static u64 max_khz;u64 mul, div;if (caps->lowest_freq && caps->nominal_freq) { -if (perf >= caps->nominal_perf) { - mul = caps->nominal_freq; - div = caps->nominal_perf; - }else { - mul = caps->nominal_freq - caps->lowest_freq; - div = caps->nominal_perf - caps->lowest_perf; - } + mul = caps->nominal_freq - caps->lowest_freq; + div = caps->nominal_perf - caps->lowest_perf; + offset = caps->nominal_freq -div64_u64 (caps->nominal_perf * mul, div); }else {if (!max_khz) max_khz =cppc_get_dmi_max_khz (); mul = max_khz; div = caps->highest_perf; } -return (u64 )perf * mul / div; + + retval = offset +div64_u64 (perf * mul, div); +if (retval >=0 ) +return retval; +return 0 ; }static unsigned int cppc_cpufreq_khz_to_perf (struct cppc_cpudata *cpu_data,unsigned int freq) {struct cppc_perf_caps *caps = &cpu_data->perf_caps; +s64 retval, offset =0 ;static u64 max_khz;u64 mul, div;if (caps->lowest_freq && caps->nominal_freq) { -if (freq >= caps->nominal_freq) { - mul = caps->nominal_perf; - div = caps->nominal_freq; - }else { - mul = caps->lowest_perf; - div = caps->lowest_freq; - } + mul = caps->nominal_perf - caps->lowest_perf; + div = caps->nominal_freq - caps->lowest_freq; + offset = caps->nominal_perf -div64_u64 (caps->nominal_freq * mul, div); }else {if (!max_khz) max_khz =cppc_get_dmi_max_khz ();
@@ -356,7 +352,10 @@ static unsigned int cppc_cpufreq_khz_to_perf(struct cppc_cpudata *cpu_data, div = max_khz; } -return (u64 )freq * mul / div; + retval = offset +div64_u64 (freq * mul, div); +if (retval >=0 ) +return retval; +return 0 ; } static int cppc_cpufreq_set_target(struct cpufreq_policy *policy,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 165/343 opp: Expose of-nodes name in debugfs
In reply to Greg Kroah-HartmanFrom: Viresh Kumar <[email protected]>
[ Upstream commit 021dbecabc93b1610b5db989d52a94e0c6671136 ]
It is difficult to find which OPPs are active at the moment, specially if there are multiple OPPs with same frequency available in the device tree (controlled by supported hardware feature).
Expose name of the DT node to find out the exact OPP.
While at it, also expose level field.
--- drivers/opp/debugfs.c | 5 +++++ drivers/opp/opp.h | 1 + 2 files changed, 6 insertions(+)
drivers/opp/debugfs.c +5 -0
@@ -10,6 +10,7 @@#include <linux/debugfs.h> #include <linux/device.h> #include <linux/err.h> +#include <linux/of.h> #include <linux/init.h> #include <linux/limits.h> #include <linux/slab.h>
@@ -131,9 +132,13 @@ void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table)debugfs_create_bool ("suspend" ,S_IRUGO , d, &opp->suspend);debugfs_create_u32 ("performance_state" ,S_IRUGO , d, &opp->pstate);debugfs_create_ulong ("rate_hz" ,S_IRUGO , d, &opp->rate); +debugfs_create_u32 ("level" ,S_IRUGO , d, &opp->level);debugfs_create_ulong ("clock_latency_ns" ,S_IRUGO , d, &opp->clock_latency_ns); + opp->of_name =of_node_full_name (opp->np); +debugfs_create_str ("of_name" ,S_IRUGO , d, (char **)&opp->of_name); +opp_debug_create_supplies (opp, opp_table, d);opp_debug_create_bw (opp, opp_table, d);
drivers/opp/opp.h +1 -0
@@ -96,6 +96,7 @@ struct dev_pm_opp {#ifdef CONFIG_DEBUG_FS struct dentry *dentry; +const char *of_name;#endif };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 166/343 staging: wfx: apply the necessary SDIO quirks for the Silabs WF200
In reply to Greg Kroah-HartmanFrom: Jérôme Pouiller <[email protected]>
[ Upstream commit 96e0cbca1cb96e9d3deac3051aa816e13082f3fd ]
Until now, the SDIO quirks are applied directly from the driver. However, it is better to apply the quirks before driver probing. So, this patch relocate the quirks in the MMC framework.
Note that the WF200 has no valid SDIO VID/PID. Therefore, we match DT rather than on the SDIO VID/PID.
--- drivers/mmc/core/quirks.h | 5 +++++ drivers/staging/wfx/bus_sdio.c | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/mmc/core/quirks.h +5 -0
@@ -149,6 +149,11 @@ static const struct mmc_fixup __maybe_unused sdio_fixup_methods[] = {static const struct mmc_fixup __maybe_unused sdio_card_init_methods[] = {SDIO_FIXUP_COMPATIBLE ("ti,wl1251" , wl1251_quirk,0 ), +SDIO_FIXUP_COMPATIBLE ("silabs,wf200" , add_quirk, +MMC_QUIRK_BROKEN_BYTE_MODE_512 | +MMC_QUIRK_LENIENT_FN0 | +MMC_QUIRK_BLKSZ_FOR_BYTE_MODE ), +END_FIXUP };
drivers/staging/wfx/bus_sdio.c +0 -3
@@ -207,9 +207,6 @@ static int wfx_sdio_probe(struct sdio_func *func, bus->func = func;sdio_set_drvdata (func, bus); - func->card->quirks |=MMC_QUIRK_LENIENT_FN0 | -MMC_QUIRK_BLKSZ_FOR_BYTE_MODE | -MMC_QUIRK_BROKEN_BYTE_MODE_512 ;sdio_claim_host (func); ret =sdio_enable_func (func);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 167/343 staging: wfx: fix an error handling in wfx_init_common()
In reply to Greg Kroah-HartmanFrom: Xiaoke Wang <[email protected]>
[ Upstream commit 60f1d3c92dc1ef1026e5b917a329a7fa947da036 ]
One error handler of wfx_init_common() return without calling ieee80211_free_hw(hw), which may result in memory leak. And I add one err label to unify the error handler, which is useful for the subsequent changes.
--- drivers/staging/wfx/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/staging/wfx/main.c +6 -1
@@ -322,7 +322,8 @@ struct wfx_dev *wfx_init_common(struct device *dev, wdev->pdata.gpio_wakeup =devm_gpiod_get_optional (dev,"wakeup" ,GPIOD_OUT_LOW );if (IS_ERR (wdev->pdata.gpio_wakeup)) -return NULL ; + goto err; +if (wdev->pdata.gpio_wakeup)gpiod_set_consumer_name (wdev->pdata.gpio_wakeup,"wfx wakeup" );
@@ -341,6 +342,10 @@ struct wfx_dev *wfx_init_common(struct device *dev,return NULL ;return wdev; + +err: +ieee80211_free_hw (hw); +return NULL ; }int wfx_probe (struct wfx_dev *wdev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 168/343 w1: w1_therm: fixes w1_seq for ds28ea00 sensors
In reply to Greg Kroah-HartmanFrom: Lucas Denefle <[email protected]>
[ Upstream commit 41a92a89eee819298f805c40187ad8b02bb53426 ]
w1_seq was failing due to several devices responding to the CHAIN_DONE at the same time. Now properly selects the current device in the chain with MATCH_ROM. Also acknowledgment was read twice.
--- drivers/w1/slaves/w1_therm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/w1/slaves/w1_therm.c +6 -2
@@ -2089,16 +2089,20 @@ static ssize_t w1_seq_show(struct device *device,if (sl->reg_num.id == reg_num->id) seq = i; +if (w1_reset_bus (sl->master)) + goto error; + +/* Put the device into chain DONE state */ +w1_write_8 (sl->master,W1_MATCH_ROM ); +w1_write_block (sl->master, (u8 *)&rn,8 );w1_write_8 (sl->master,W1_42_CHAIN );w1_write_8 (sl->master,W1_42_CHAIN_DONE );w1_write_8 (sl->master,W1_42_CHAIN_DONE_INV ); -w1_read_block (sl->master, &ack,sizeof (ack));/* check for acknowledgment */ ack =w1_read_8 (sl->master);if (ack !=W1_42_SUCCESS_CONFIRM_BYTE ) goto error; - }/* Exit from CHAIN state */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 169/343 NFSv4.2: fix reference count leaks in _nfs42_proc_copy_notify()
In reply to Greg Kroah-HartmanFrom: Xin Xiong <[email protected]>
[ Upstream commit b7f114edd54326f730a754547e7cfb197b5bc132 ]
[You don't often get email from [email protected]. Learn why this is important at http://aka.ms/LearnAboutSenderIdentification.]
The reference counting issue happens in two error paths in the function _nfs42_proc_copy_notify(). In both error paths, the function simply returns the error code and forgets to balance the refcount of object ctx, bumped by get_nfs_open_context() earlier, which may cause refcount leaks.
Fix it by balancing refcount of the ctx object before the function returns in both error paths.
--- fs/nfs/nfs42proc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/nfs/nfs42proc.c +6 -3
@@ -591,8 +591,10 @@ static int _nfs42_proc_copy_notify(struct file *src, struct file *dst, ctx =get_nfs_open_context (nfs_file_open_context (src)); l_ctx =nfs_get_lock_context (ctx); -if (IS_ERR (l_ctx)) -return PTR_ERR (l_ctx); +if (IS_ERR (l_ctx)) { + status =PTR_ERR (l_ctx); + goto out; + } status =nfs4_set_rw_stateid (&args->cna_src_stateid, ctx, l_ctx,FMODE_READ );
@@ -600,7 +602,7 @@ static int _nfs42_proc_copy_notify(struct file *src, struct file *dst,if (status) {if (status == -EAGAIN ) status = -NFS4ERR_BAD_STATEID ; -return status; + goto out; } status = nfs4_call_sync(src_server->client, src_server, &msg,
@@ -609,6 +611,7 @@ static int _nfs42_proc_copy_notify(struct file *src, struct file *dst,if (status == -ENOTSUPP ) src_server->caps &= ~NFS_CAP_COPY_NOTIFY ; +out:put_nfs_open_context (nfs_file_open_context (src));return status; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 170/343 NFSv4: Protect the state recovery thread against direct reclaim
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 3e17898aca293a24dae757a440a50aa63ca29671 ]
If memory allocation triggers a direct reclaim from the state recovery thread, then we can deadlock. Use memalloc_nofs_save/restore to ensure that doesn't happen.
--- fs/nfs/nfs4state.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
fs/nfs/nfs4state.c +12 -0
@@ -49,6 +49,7 @@#include <linux/workqueue.h> #include <linux/bitops.h> #include <linux/jiffies.h> +#include <linux/sched/mm.h> #include <linux/sunrpc/clnt.h>
@@ -2560,9 +2561,17 @@ static void nfs4_layoutreturn_any_run(struct nfs_client *clp)static void nfs4_state_manager (struct nfs_client *clp) { +unsigned int memflags;int status =0 ;const char *section ="" , *section_sep ="" ; +/* +* State recovery can deadlock if the direct reclaim code tries +* start NFS writeback. So ensure memory allocations are all +* GFP_NOFS. +*/ + memflags =memalloc_nofs_save (); +/* Ensure exclusive access to NFSv4 state */ do { trace_nfs4_state_mgr(clp);
@@ -2657,6 +2666,7 @@ static void nfs4_state_manager(struct nfs_client *clp)clear_bit (NFS4CLNT_RECLAIM_NOGRACE , &clp->cl_state); } +memalloc_nofs_restore (memflags);nfs4_end_drain_session (clp);nfs4_clear_state_manager_bit (clp);
@@ -2674,6 +2684,7 @@ static void nfs4_state_manager(struct nfs_client *clp)return ;if (test_and_set_bit (NFS4CLNT_MANAGER_RUNNING , &clp->cl_state) !=0 )return ; + memflags =memalloc_nofs_save (); }while (refcount_read (&clp->cl_count) >1 && !signalled ()); goto out_drain;
@@ -2686,6 +2697,7 @@ static void nfs4_state_manager(struct nfs_client *clp) clp->cl_hostname, -status);ssleep (1 ); out_drain: +memalloc_nofs_restore (memflags);nfs4_end_drain_session (clp);nfs4_clear_state_manager_bit (clp); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 171/343 habanalabs: fix possible memory leak in MMU DR fini
In reply to Greg Kroah-HartmanFrom: Ohad Sharabi <[email protected]>
[ Upstream commit eb85eec858c1a5c11d3a0bff403f6440b05b40dc ]
This patch fixes what seems to be copy paste error.
We will have a memory leak if the host-resident shadow is NULL (which will likely happen as the DR and HR are not dependent).
--- drivers/misc/habanalabs/common/mmu/mmu_v1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/habanalabs/common/mmu/mmu_v1.c +1 -1
@@ -467,7 +467,7 @@ static void hl_mmu_v1_fini(struct hl_device *hdev) {/* MMU H/W fini was already done in device hw_fini() */ -if (!ZERO_OR_NULL_PTR (hdev->mmu_priv.hr.mmu_shadow_hop0)) { +if (!ZERO_OR_NULL_PTR (hdev->mmu_priv.dr.mmu_shadow_hop0)) {kvfree (hdev->mmu_priv.dr.mmu_shadow_hop0);gen_pool_destroy (hdev->mmu_priv.dr.mmu_pgt_pool);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 172/343 habanalabs: reject host map with mmu disabled
In reply to Greg Kroah-HartmanFrom: Oded Gabbay <[email protected]>
[ Upstream commit 9a79e3e4a3637c07352d9723b825490a1b04391f ]
This is not something we can do a workaround. It is clearly an error and we should notify the user that it is an error.
--- drivers/misc/habanalabs/common/memory.c | 30 +++++++++---------------- 1 file changed, 11 insertions(+), 19 deletions(-)
drivers/misc/habanalabs/common/memory.c +11 -19
@@ -1967,16 +1967,15 @@ static int export_dmabuf_from_handle(struct hl_ctx *ctx, u64 handle, int flags,static int mem_ioctl_no_mmu (struct hl_fpriv *hpriv,union hl_mem_args *args) {struct hl_device *hdev = hpriv->hdev; -struct hl_ctx *ctx = hpriv->ctx;u64 block_handle, device_addr =0 ; +struct hl_ctx *ctx = hpriv->ctx;u32 handle =0 , block_size; -int rc, dmabuf_fd = -EBADF ; +int rc;switch (args->in.op) {case HL_MEM_OP_ALLOC :if (args->in.alloc.mem_size ==0 ) { -dev_err (hdev->dev, -"alloc size must be larger than 0\n" ); +dev_err (hdev->dev,"alloc size must be larger than 0\n" ); rc = -EINVAL ; goto out; }
@@ -1997,15 +1996,14 @@ static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv, union hl_mem_args *args)case HL_MEM_OP_MAP :if (args->in.flags &HL_MEM_USERPTR ) { - device_addr = args->in.map_host.host_virt_addr; - rc =0 ; +dev_err (hdev->dev,"Failed to map host memory when MMU is disabled\n" ); + rc = -EPERM ; }else { - rc =get_paddr_from_handle (ctx, &args->in, - &device_addr); + rc =get_paddr_from_handle (ctx, &args->in, &device_addr); +memset (args,0 ,sizeof (*args)); + args->out.device_virt_addr = device_addr; } -memset (args,0 ,sizeof (*args)); - args->out.device_virt_addr = device_addr;break ;case HL_MEM_OP_UNMAP :
@@ -2013,20 +2011,14 @@ static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv, union hl_mem_args *args)break ;case HL_MEM_OP_MAP_BLOCK : - rc =map_block (hdev, args->in.map_block.block_addr, - &block_handle, &block_size); + rc =map_block (hdev, args->in.map_block.block_addr, &block_handle, &block_size); args->out.block_handle = block_handle; args->out.block_size = block_size;break ;case HL_MEM_OP_EXPORT_DMABUF_FD : - rc =export_dmabuf_from_addr (ctx, - args->in.export_dmabuf_fd.handle, - args->in.export_dmabuf_fd.mem_size, - args->in.flags, - &dmabuf_fd); -memset (args,0 ,sizeof (*args)); - args->out.fd = dmabuf_fd; +dev_err (hdev->dev,"Failed to export dma-buf object when MMU is disabled\n" ); + rc = -EPERM ;break ;default :
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 173/343 habanalabs/gaudi: handle axi errors from NIC engines
In reply to Greg Kroah-HartmanFrom: Oded Gabbay <[email protected]>
[ Upstream commit 26ef1c000bc21a192618c9ec651dd36ba63ca00c ]
Various AXI errors can occur in the NIC engines and are reported to the driver by the f/w. Add code to print the errors and ack them to the f/w.
--- drivers/misc/habanalabs/gaudi/gaudi.c | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
drivers/misc/habanalabs/gaudi/gaudi.c +48 -0
@@ -7819,6 +7819,48 @@ static void gaudi_print_fw_alive_info(struct hl_device *hdev, fw_alive->thread_id, fw_alive->uptime_seconds); } +static void gaudi_print_nic_axi_irq_info (struct hl_device *hdev,u16 event_type, +void *data) +{ +char desc[64 ] ="" , *type; +struct eq_nic_sei_event *eq_nic_sei = data; +u16 nic_id = event_type -GAUDI_EVENT_NIC_SEI_0 ; + +switch (eq_nic_sei->axi_error_cause) { +case RXB : + type ="RXB" ; +break ; +case RXE : + type ="RXE" ; +break ; +case TXS : + type ="TXS" ; +break ; +case TXE : + type ="TXE" ; +break ; +case QPC_RESP : + type ="QPC_RESP" ; +break ; +case NON_AXI_ERR : + type ="NON_AXI_ERR" ; +break ; +case TMR : + type ="TMR" ; +break ; +default : +dev_err (hdev->dev,"unknown NIC AXI cause %d\n" , + eq_nic_sei->axi_error_cause); + type ="N/A" ; +break ; + } + +snprintf (desc,sizeof (desc),"NIC%d_%s%d" , nic_id, type, + eq_nic_sei->id); +dev_err_ratelimited (hdev->dev,"Received H/W interrupt %d [\"%s\"]\n" , + event_type, desc); +} +static int gaudi_non_hard_reset_late_init (struct hl_device *hdev) {/* GAUDI doesn't support any reset except hard-reset */
@@ -8066,6 +8108,7 @@ static void gaudi_handle_eqe(struct hl_device *hdev, struct hl_eq_entry *eq_entry) {struct gaudi_device *gaudi = hdev->asic_specific; +u64 data =le64_to_cpu (eq_entry->data[0 ]);u32 ctl =le32_to_cpu (eq_entry->hdr.ctl);u32 fw_fatal_err_flag =0 ; u16 event_type = ((ctl & EQ_CTL_EVENT_TYPE_MASK)
@@ -8263,6 +8306,11 @@ static void gaudi_handle_eqe(struct hl_device *hdev,hl_fw_unmask_irq (hdev, event_type);break ; + case GAUDI_EVENT_NIC_SEI_0 ... GAUDI_EVENT_NIC_SEI_4: +gaudi_print_nic_axi_irq_info (hdev, event_type, &data); +hl_fw_unmask_irq (hdev, event_type); +break ; + case GAUDI_EVENT_DMA_IF_SEI_0 ... GAUDI_EVENT_DMA_IF_SEI_3:gaudi_print_irq_info (hdev, event_type, false); gaudi_print_sm_sei_info(hdev, event_type,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 174/343 xen: delay xen_hvm_init_time_ops() if kdump is boot on vcpu>=32
In reply to Greg Kroah-HartmanFrom: Dongli Zhang <[email protected]>
[ Upstream commit eed05744322da07dd7e419432dcedf3c2e017179 ]
The sched_clock() can be used very early since commit 857baa87b642 ("sched/clock: Enable sched clock early"). In addition, with commit 38669ba205d1 ("x86/xen/time: Output xen sched_clock time from 0"), kdump kernel in Xen HVM guest may panic at very early stage when accessing &__this_cpu_read(xen_vcpu)->time as in below:
setup_arch()
-> init_hypervisor_platform()
-> x86_init.hyper.init_platform = xen_hvm_guest_init()
-> xen_hvm_init_time_ops()
-> xen_clocksource_read()
-> src = &__this_cpu_read(xen_vcpu)->time;This is because Xen HVM supports at most MAX_VIRT_CPUS=32 'vcpu_info' embedded inside 'shared_info' during early stage until xen_vcpu_setup() is used to allocate/relocate 'vcpu_info' for boot cpu at arbitrary address.
However, when Xen HVM guest panic on vcpu >= 32, since xen_vcpu_info_reset(0) would set per_cpu(xen_vcpu, cpu) = NULL when vcpu >= 32, xen_clocksource_read() on vcpu >= 32 would panic.
This patch calls xen_hvm_init_time_ops() again later in xen_hvm_smp_prepare_boot_cpu() after the 'vcpu_info' for boot vcpu is registered when the boot vcpu is >= 32.
This issue can be reproduced on purpose via below command at the guest side when kdump/kexec is enabled:
"taskset -c 33 echo c > /proc/sysrq-trigger"
The bugfix for PVM is not implemented due to the lack of testing environment.
[boris: xen_hvm_init_time_ops() returns on errors instead of jumping to end]
--- arch/x86/xen/smp_hvm.c | 6 ++++++ arch/x86/xen/time.c | 24 +++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-)
arch/x86/xen/smp_hvm.c +6 -0
@@ -19,6 +19,12 @@ static void __init xen_hvm_smp_prepare_boot_cpu(void)*/ xen_vcpu_setup (0 ); +/* +* Called again in case the kernel boots on vcpu >= MAX_VIRT_CPUS. +* Refer to comments in xen_hvm_init_time_ops(). +*/ +xen_hvm_init_time_ops (); +/* * The alternative logic (which patches the unlock/lock) runs before * the smp bootup up code is activated. Hence we need to set this up
arch/x86/xen/time.c +23 -1
@@ -558,6 +558,11 @@ static void xen_hvm_setup_cpu_clockevents(void)void __init xen_hvm_init_time_ops (void ) { +static bool hvm_time_initialized; + +if (hvm_time_initialized) +return ; +/* * vector callback is needed otherwise we cannot receive interrupts * on cpu > 0 and at this point we don't know how many cpus are
@@ -567,7 +572,22 @@ void __init xen_hvm_init_time_ops(void)return ;if (!xen_feature (XENFEAT_hvm_safe_pvclock)) { -pr_info ("Xen doesn't support pvclock on HVM, disable pv timer" ); +pr_info_once ("Xen doesn't support pvclock on HVM, disable pv timer" ); +return ; + } + +/* +* Only MAX_VIRT_CPUS 'vcpu_info' are embedded inside 'shared_info'. +* The __this_cpu_read(xen_vcpu) is still NULL when Xen HVM guest +* boots on vcpu >= MAX_VIRT_CPUS (e.g., kexec), To access +* __this_cpu_read(xen_vcpu) via xen_clocksource_read() will panic. +* +* The xen_hvm_init_time_ops() should be called again later after +* __this_cpu_read(xen_vcpu) is available. +*/ +if (!__this_cpu_read (xen_vcpu)) { +pr_info ("Delay xen_init_time_common() as kernel is running on vcpu=%d\n" , +xen_vcpu_nr (0 ));return ; }
@@ -577,6 +597,8 @@ void __init xen_hvm_init_time_ops(void) x86_cpuinit.setup_percpu_clockev = xen_hvm_setup_cpu_clockevents; x86_platform.set_wallclock = xen_set_wallclock; + + hvm_time_initialized = true; }#endif
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 175/343 clk: ti: Preserve node in ti_dt_clocks_register()
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit 80864594ff2ad002e2755daf97d46ff0c86faf1f ]
In preparation for making use of the clock-output-names, we want to keep node around in ti_dt_clocks_register().
This change should not needed as a fix currently.
--- drivers/clk/ti/clk.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/clk/ti/clk.c +8 -5
@@ -131,7 +131,7 @@ int ti_clk_setup_ll_ops(struct ti_clk_ll_ops *ops)void __init ti_dt_clocks_register (struct ti_dt_clk oclks[]) {struct ti_dt_clk *c; -struct device_node *node, *parent; +struct device_node *node, *parent, *child;struct clk *clk;struct of_phandle_args clkspec;char buf[64 ];
@@ -171,10 +171,13 @@ void __init ti_dt_clocks_register(struct ti_dt_clk oclks[]) node =of_find_node_by_name (NULL , buf);if (num_args && compat_mode) { parent = node; - node =of_get_child_by_name (parent,"clock" ); -if (!node) - node =of_get_child_by_name (parent,"clk" ); -of_node_put (parent); + child =of_get_child_by_name (parent,"clock" ); +if (!child) + child =of_get_child_by_name (parent,"clk" ); +if (child) { +of_node_put (parent); + node = child; + } } clkspec.np = node;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 176/343 clk: Enforce that disjoints limits are invalid
In reply to Greg Kroah-HartmanFrom: Maxime Ripard <[email protected]>
[ Upstream commit 10c46f2ea914202482d19cf80dcc9c321c9ff59b ]
If we were to have two users of the same clock, doing something like:
clk_set_rate_range(user1, 1000, 2000);clk_set_rate_range(user2, 3000, 4000);
The second call would fail with -EINVAL, preventing from getting in a situation where we end up with impossible limits.
However, this is never explicitly checked against and enforced, and works by relying on an undocumented behaviour of clk_set_rate().
Indeed, on the first clk_set_rate_range will make sure the current clock rate is within the new range, so it will be between 1000 and 2000Hz. On the second clk_set_rate_range(), it will consider (rightfully), that our current clock is outside of the 3000-4000Hz range, and will call clk_core_set_rate_nolock() to set it to 3000Hz.
clk_core_set_rate_nolock() will then call clk_calc_new_rates() that will eventually check that our rate 3000Hz rate is outside the min 3000Hz max 2000Hz range, will bail out, the error will propagate and we'll eventually return -EINVAL.
This solely relies on the fact that clk_calc_new_rates(), and in particular clk_core_determine_round_nolock(), won't modify the new rate allowing the error to be reported. That assumption won't be true for all drivers, and most importantly we'll break that assumption in a later patch.
It can also be argued that we shouldn't even reach the point where we're calling clk_core_set_rate_nolock().
Let's make an explicit check for disjoints range before we're doing anything.
--- drivers/clk/clk.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/clk/clk.c +24 -0
@@ -632,6 +632,24 @@ static void clk_core_get_boundaries(struct clk_core *core, *max_rate =min (*max_rate, clk_user->max_rate); } +static bool clk_core_check_boundaries (struct clk_core *core, +unsigned long min_rate, +unsigned long max_rate) +{ +struct clk *user; + +lockdep_assert_held (&prepare_lock); + +if (min_rate > core->max_rate || max_rate < core->min_rate) +return false; + +hlist_for_each_entry (user, &core->clks, clks_node) +if (min_rate > user->max_rate || max_rate < user->min_rate) +return false; + +return true; +} +void clk_hw_set_rate_range (struct clk_hw *hw,unsigned long min_rate,unsigned long max_rate) {
@@ -2348,6 +2366,11 @@ int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max) clk->min_rate = min; clk->max_rate = max; +if (!clk_core_check_boundaries (clk->core, min, max)) { + ret = -EINVAL ; + goto out; + } + rate =clk_core_get_rate_nolock (clk->core);if (rate < min || rate > max) {/*
@@ -2376,6 +2399,7 @@ int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max) } } +out:if (clk->exclusive_count)clk_core_rate_protect (clk->core);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 177/343 SUNRPC/xprt: async tasks mustnt block waiting for memory
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
[ Upstream commit a721035477fb5fb8abc738fbe410b07c12af3dc5 ]
When memory is short, new worker threads cannot be created and we depend on the minimum one rpciod thread to be able to handle everything. So it must not block waiting for memory.
xprt_dynamic_alloc_slot can block indefinitely. This can tie up all workqueue threads and NFS can deadlock. So when called from a workqueue, set __GFP_NORETRY.
The rdma alloc_slot already does not block. However it sets the error to -EAGAIN suggesting this will trigger a sleep. It does not. As we can see in call_reserveresult(), only -ENOMEM causes a sleep. -EAGAIN causes immediate retry.
--- net/sunrpc/xprt.c | 5 ++++- net/sunrpc/xprtrdma/transport.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
net/sunrpc/xprt.c +4 -1
@@ -1690,12 +1690,15 @@ static bool xprt_throttle_congested(struct rpc_xprt *xprt, struct rpc_task *taskstatic struct rpc_rqst *xprt_dynamic_alloc_slot (struct rpc_xprt *xprt) {struct rpc_rqst *req =ERR_PTR (-EAGAIN ); +gfp_t gfp_mask =GFP_KERNEL ;if (xprt->num_reqs >= xprt->max_reqs) goto out; ++xprt->num_reqs;spin_unlock (&xprt->reserve_lock); - req =kzalloc (sizeof (struct rpc_rqst ),GFP_NOFS ); +if (current->flags &PF_WQ_WORKER ) + gfp_mask |= __GFP_NORETRY | __GFP_NOWARN; + req =kzalloc (sizeof (*req), gfp_mask);spin_lock (&xprt->reserve_lock);if (req !=NULL ) goto out;
net/sunrpc/xprtrdma/transport.c +1 -1
@@ -521,7 +521,7 @@ xprt_rdma_alloc_slot(struct rpc_xprt *xprt, struct rpc_task *task)return ; out_sleep: - task->tk_status = -EAGAIN ; + task->tk_status = -ENOMEM ;xprt_add_backlog (xprt, task); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 178/343 SUNRPC: remove scheduling boost for "SWAPPER" tasks.
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
[ Upstream commit a80a8461868905823609be97f91776a26befe839 ]
Currently, tasks marked as "swapper" tasks get put to the front of non-priority rpc_queues, and are sorted earlier than non-swapper tasks on the transport's ->xmit_queue.
This is pointless as currently *all* tasks for a mount that has swap enabled on *any* file are marked as "swapper" tasks. So the net result is that the non-priority rpc_queues are reverse-ordered (LIFO).
This scheduling boost is not necessary to avoid deadlocks, and hurts fairness, so remove it. If there were a need to expedite some requests, the tk_priority mechanism is a more appropriate tool.
--- net/sunrpc/sched.c | 7 ------- net/sunrpc/xprt.c | 11 ----------- 2 files changed, 18 deletions(-)
net/sunrpc/sched.c +0 -7
@@ -186,11 +186,6 @@ static void __rpc_add_wait_queue_priority(struct rpc_wait_queue *queue,/* * Add new request to wait queue. -* -* Swapper tasks always get inserted at the head of the queue. -* This should avoid many nasty memory deadlocks and hopefully -* improve overall performance. -* Everyone else gets appended to the queue to ensure proper FIFO behavior. */ static void __rpc_add_wait_queue(struct rpc_wait_queue *queue, struct rpc_task *task,
@@ -199,8 +194,6 @@ static void __rpc_add_wait_queue(struct rpc_wait_queue *queue,INIT_LIST_HEAD (&task->u.tk_wait.timer_list);if (RPC_IS_PRIORITY (queue))__rpc_add_wait_queue_priority (queue, task, queue_priority); -else if (RPC_IS_SWAPPER (task)) -list_add (&task->u.tk_wait.list, &queue->tasks[0 ]);else list_add_tail (&task->u.tk_wait.list, &queue->tasks[0 ]); task->tk_waitqueue = queue;
net/sunrpc/xprt.c +0 -11
@@ -1354,17 +1354,6 @@ xprt_request_enqueue_transmit(struct rpc_task *task)INIT_LIST_HEAD (&req->rq_xmit2); goto out; } - }else if (RPC_IS_SWAPPER (task)) { -list_for_each_entry (pos, &xprt->xmit_queue, rq_xmit) { -if (pos->rq_cong || pos->rq_bytes_sent) -continue ; -if (RPC_IS_SWAPPER (pos->rq_task)) -continue ; -/* Note: req is added _before_ pos */ -list_add_tail (&req->rq_xmit, &pos->rq_xmit); -INIT_LIST_HEAD (&req->rq_xmit2); - goto out; - } }else if (!req->rq_seqno) {list_for_each_entry (pos, &xprt->xmit_queue, rq_xmit) {if (pos->rq_task->tk_owner != task->tk_owner)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 179/343 NFS: swap IO handling is slightly different for O_DIRECT IO
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
[ Upstream commit 64158668ac8b31626a8ce48db4cad08496eb8340 ]
1/ Taking the i_rwsem for swap IO triggers lockdep warnings regarding
possible deadlocks with "fs_reclaim". These deadlocks could, I believe, eventuate if a buffered read on the swapfile was attempted.
We don't need coherence with the page cache for a swap file, and buffered writes are forbidden anyway. There is no other need for i_rwsem during direct IO. So never take it for swap_rw()
2/ generic_write_checks() explicitly forbids writes to swap, and
performs checks that are not needed for swap. So bypass it for swap_rw().
--- fs/nfs/direct.c | 42 ++++++++++++++++++++++++++++-------------- fs/nfs/file.c | 4 ++-- include/linux/nfs_fs.h | 8 ++++---- 3 files changed, 34 insertions(+), 20 deletions(-)
fs/nfs/direct.c +28 -14
@@ -173,8 +173,8 @@ ssize_t nfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)VM_BUG_ON (iov_iter_count (iter) !=PAGE_SIZE );if (iov_iter_rw (iter) ==READ ) -return nfs_file_direct_read (iocb, iter); -return nfs_file_direct_write (iocb, iter); +return nfs_file_direct_read (iocb, iter, true); +return nfs_file_direct_write (iocb, iter, true); }static void nfs_direct_release_pages (struct page **pages,unsigned int npages)
@@ -425,6 +425,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,* nfs_file_direct_read - file direct read operation for NFS files * @iocb: target I/O control block * @iter: vector of user buffers into which to read data +* @swap: flag indicating this is swap IO, not O_DIRECT IO * * We use this function for direct reads instead of calling * generic_file_aio_read() in order to avoid gfar's check to see if
@@ -440,7 +441,8 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,* client must read the updated atime from the server back into its * cache. */ -ssize_t nfs_file_direct_read (struct kiocb *iocb,struct iov_iter *iter) +ssize_t nfs_file_direct_read (struct kiocb *iocb,struct iov_iter *iter, +bool swap) {struct file *file = iocb->ki_filp;struct address_space *mapping = file->f_mapping;
@@ -482,12 +484,14 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter)if (iter_is_iovec (iter)) dreq->flags =NFS_ODIRECT_SHOULD_DIRTY ; -nfs_start_io_direct (inode); +if (!swap) +nfs_start_io_direct (inode);NFS_I (inode)->read_io += count; requested =nfs_direct_read_schedule_iovec (dreq, iter, iocb->ki_pos); -nfs_end_io_direct (inode); +if (!swap) +nfs_end_io_direct (inode);if (requested >0 ) { result =nfs_direct_wait (dreq);
@@ -876,6 +880,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,* nfs_file_direct_write - file direct write operation for NFS files * @iocb: target I/O control block * @iter: vector of user buffers from which to write data +* @swap: flag indicating this is swap IO, not O_DIRECT IO * * We use this function for direct writes instead of calling * generic_file_aio_write() in order to avoid taking the inode
@@ -892,7 +897,8 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,* Note that O_APPEND is not supported for NFS direct writes, as there * is no atomic O_APPEND write facility in the NFS protocol. */ -ssize_t nfs_file_direct_write (struct kiocb *iocb,struct iov_iter *iter) +ssize_t nfs_file_direct_write (struct kiocb *iocb,struct iov_iter *iter, +bool swap) {ssize_t result, requested;size_t count;
@@ -906,7 +912,11 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)dfprintk (FILE ,"NFS: direct write(%pD2, %zd@%Ld)\n" , file,iov_iter_count (iter), (long long ) iocb->ki_pos); - result =generic_write_checks (iocb, iter); +if (swap) +/* bypass generic checks */ + result =iov_iter_count (iter); +else + result =generic_write_checks (iocb, iter);if (result <=0 )return result; count = result;
@@ -937,16 +947,20 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter) dreq->iocb = iocb;pnfs_init_ds_commit_info_ops (&dreq->ds_cinfo, inode); -nfs_start_io_direct (inode); +if (swap) { + requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); + }else { +nfs_start_io_direct (inode); - requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); + requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); -if (mapping->nrpages) { -invalidate_inode_pages2_range (mapping, - pos >>PAGE_SHIFT , end); - } +if (mapping->nrpages) { +invalidate_inode_pages2_range (mapping, + pos >>PAGE_SHIFT , end); + } -nfs_end_io_direct (inode); +nfs_end_io_direct (inode); + }if (requested >0 ) { result =nfs_direct_wait (dreq);
fs/nfs/file.c +2 -2
@@ -162,7 +162,7 @@ nfs_file_read(struct kiocb *iocb, struct iov_iter *to)ssize_t result;if (iocb->ki_flags &IOCB_DIRECT ) -return nfs_file_direct_read (iocb, to); +return nfs_file_direct_read (iocb, to, false); dprintk("NFS: read(%pD2, %zu@%lu)\n", iocb->ki_filp,
@@ -619,7 +619,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)return result;if (iocb->ki_flags &IOCB_DIRECT ) -return nfs_file_direct_write (iocb, from); +return nfs_file_direct_write (iocb, from, false);dprintk ("NFS: write(%pD2, %zu@%Ld)\n" , file,iov_iter_count (from), (long long ) iocb->ki_pos);
include/linux/nfs_fs.h +4 -4
@@ -513,10 +513,10 @@ static inline const struct cred *nfs_file_cred(struct file *file)* linux/fs/nfs/direct.c */ extern ssize_t nfs_direct_IO (struct kiocb *,struct iov_iter *); -extern ssize_t nfs_file_direct_read (struct kiocb *iocb, -struct iov_iter *iter); -extern ssize_t nfs_file_direct_write (struct kiocb *iocb, -struct iov_iter *iter); +ssize_t nfs_file_direct_read (struct kiocb *iocb, +struct iov_iter *iter,bool swap); +ssize_t nfs_file_direct_write (struct kiocb *iocb, +struct iov_iter *iter,bool swap);/* * linux/fs/nfs/dir.c
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 180/343 NFS: swap-out must always use STABLE writes.
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
[ Upstream commit c265de257f558a05c1859ee9e3fed04883b9ec0e ]
The commit handling code is not safe against memory-pressure deadlocks when writing to swap. In particular, nfs_commitdata_alloc() blocks indefinitely waiting for memory, and this can consume all available workqueue threads.
swap-out most likely uses STABLE writes anyway as COND_STABLE indicates that a stable write should be used if the write fits in a single request, and it normally does. However if we ever swap with a small wsize, or gather unusually large numbers of pages for a single write, this might change.
For safety, make it explicit in the code that direct writes used for swap must always use FLUSH_STABLE.
--- fs/nfs/direct.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/nfs/direct.c +6 -4
@@ -794,7 +794,7 @@ static const struct nfs_pgio_completion_ops nfs_direct_write_completion_ops = {*/ static ssize_t nfs_direct_write_schedule_iovec (struct nfs_direct_req *dreq,struct iov_iter *iter, -loff_t pos) +loff_t pos,int ioflags) {struct nfs_pageio_descriptor desc;struct inode *inode = dreq->inode;
@@ -802,7 +802,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,size_t requested_bytes =0 ;size_t wsize =max_t (size_t,NFS_SERVER (inode)->wsize,PAGE_SIZE ); -nfs_pageio_init_write (&desc, inode,FLUSH_COND_STABLE , false, +nfs_pageio_init_write (&desc, inode, ioflags, false, &nfs_direct_write_completion_ops); desc.pg_dreq = dreq;get_dreq (dreq);
@@ -948,11 +948,13 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter,pnfs_init_ds_commit_info_ops (&dreq->ds_cinfo, inode);if (swap) { - requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); + requested =nfs_direct_write_schedule_iovec (dreq, iter, pos, +FLUSH_STABLE ); }else {nfs_start_io_direct (inode); - requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); + requested =nfs_direct_write_schedule_iovec (dreq, iter, pos, +FLUSH_COND_STABLE );if (mapping->nrpages) { invalidate_inode_pages2_range(mapping,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 181/343 x86: Annotate call_on_stack()
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit be0075951fde739f14ee2b659e2fd6e2499c46c0 ]
vmlinux.o: warning: objtool: page_fault_oops()+0x13c: unreachable instruction
0000 000000000005b460 <page_fault_oops>:
...
0128 5b588: 49 89 23 mov %rsp,(%r11) 012b 5b58b: 4c 89 dc mov %r11,%rsp 012e 5b58e: 4c 89 f2 mov %r14,%rdx 0131 5b591: 48 89 ee mov %rbp,%rsi 0134 5b594: 4c 89 e7 mov %r12,%rdi 0137 5b597: e8 00 00 00 00 call 5b59c <page_fault_oops+0x13c> 5b598: R_X86_64_PLT32 handle_stack_overflow-0x4 013c 5b59c: 5c pop %rsp
vmlinux.o: warning: objtool: sysvec_reboot()+0x6d: unreachable instruction
0000 00000000000033f0 <sysvec_reboot>:
...
005d 344d: 4c 89 dc mov %r11,%rsp 0060 3450: e8 00 00 00 00 call 3455 <sysvec_reboot+0x65> 3451: R_X86_64_PLT32 irq_enter_rcu-0x4 0065 3455: 48 89 ef mov %rbp,%rdi 0068 3458: e8 00 00 00 00 call 345d <sysvec_reboot+0x6d> 3459: R_X86_64_PC32 .text+0x47d0c 006d 345d: e8 00 00 00 00 call 3462 <sysvec_reboot+0x72> 345e: R_X86_64_PLT32 irq_exit_rcu-0x4 0072 3462: 5c pop %rsp
Both cases are due to a call_on_stack() calling a __noreturn function. Since that's an inline asm, GCC can't do anything about the instructions after the CALL. Therefore put in an explicit ASM_REACHABLE annotation to make sure objtool and gcc are consistently confused about control flow.
--- arch/x86/include/asm/irq_stack.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/include/asm/irq_stack.h +2 -1
@@ -99,7 +99,8 @@ }#define ASM_CALL_ARG0 \ - "call %P[__func] \n" + "call %P[__func] \n" \ + ASM_REACHABLE#define ASM_CALL_ARG1 \ "movq %[arg1], %%rdi \n" \
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 182/343 x86/Kconfig: Do not allow CONFIG_X86_X32_ABI=y with llvm-objcopy
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit aaeed6ecc1253ce1463fa1aca0b70a4ccbc9fa75 ]
There are two outstanding issues with CONFIG_X86_X32_ABI and llvm-objcopy, with similar root causes:
1. llvm-objcopy does not properly convert .note.gnu.property when going from x86_64 to x86_x32, resulting in a corrupted section when linking:
https://github.com/ClangBuiltLinux/linux/issues/1141
2. llvm-objcopy produces corrupted compressed debug sections when going from x86_64 to x86_x32, also resulting in an error when linking:
https://github.com/ClangBuiltLinux/linux/issues/514
After commit 41c5ef31ad71 ("x86/ibt: Base IBT bits"), the .note.gnu.property section is always generated when CONFIG_X86_KERNEL_IBT is enabled, which causes the first issue to become visible with an allmodconfig build:
ld.lld: error: arch/x86/entry/vdso/vclock_gettime-x32.o:(.note.gnu.property+0x1c): program property is too short
To avoid this error, do not allow CONFIG_X86_X32_ABI to be selected when using llvm-objcopy. If the two issues ever get fixed in llvm-objcopy, this can be turned into a feature check.
--- arch/x86/Kconfig | 5 +++++ 1 file changed, 5 insertions(+)
arch/x86/Kconfig +5 -0
@@ -2837,6 +2837,11 @@ config IA32_AOUT config X86_X32 bool "x32 ABI for 64-bit mode" depends on X86_64 + # llvm-objcopy does not convert x86_64 .note.gnu.property or + # compressed debug sections to x86_x32 properly: + # https://github.com/ClangBuiltLinux/linux/issues/514 + # https://github.com/ClangBuiltLinux/linux/issues/1141 + depends on $(success,$(OBJCOPY) --version | head -n1 | grep -qv llvm) help Include code to run binaries for the x32 native 32-bit ABI for 64-bit processors. An x32 process gets access to the
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 183/343 serial: samsung_tty: do not unlock port->lock for uart_write_wakeup()
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
[ Upstream commit 988c7c00691008ea1daaa1235680a0da49dab4e8 ]
The commit c15c3747ee32 (serial: samsung: fix potential soft lockup during uart write) added an unlock of port->lock before uart_write_wakeup() and a lock after it. It was always problematic to write data from tty_ldisc_ops::write_wakeup and it was even documented that way. We fixed the line disciplines to conform to this recently. So if there is still a missed one, we should fix them instead of this workaround.
On the top of that, s3c24xx_serial_tx_dma_complete() in this driver still holds the port->lock while calling uart_write_wakeup().
So revert the wrap added by the commit above.
--- drivers/tty/serial/samsung_tty.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/samsung_tty.c +1 -4
@@ -921,11 +921,8 @@ static void s3c24xx_serial_tx_chars(struct s3c24xx_uart_port *ourport)return ; } -if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS ) { -spin_unlock (&port->lock); +if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS )uart_write_wakeup (port); -spin_lock (&port->lock); - }if (uart_circ_empty (xmit))s3c24xx_serial_stop_tx (port);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 184/343 virtio_console: eliminate anonymous module_init & module_exit
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit fefb8a2a941338d871e2d83fbd65fbfa068857bd ]
Eliminate anonymous module_init() and module_exit(), which can lead to confusion or ambiguity when reading System.map, crashes/oops/bugs, or an initcall_debug log.
Give each of these init and exit functions unique driver-specific names to eliminate the anonymous names.
Example 1: (System.map)
ffffffff832fc78c t init
ffffffff832fc79e t init
ffffffff832fc8f8 t init
Example 2: (initcall_debug log)
calling init+0x0/0x12 @ 1
initcall init+0x0/0x12 returned 0 after 15 usecs
calling init+0x0/0x60 @ 1
initcall init+0x0/0x60 returned 0 after 2 usecs
calling init+0x0/0x9a @ 1
initcall init+0x0/0x9a returned 0 after 74 usecs
--- drivers/char/virtio_console.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/char/virtio_console.c +4 -4
@@ -2245,7 +2245,7 @@ static struct virtio_driver virtio_rproc_serial = { .remove = virtcons_remove, }; -static int __init init (void ) +static int __init virtio_console_init (void ) {int err;
@@ -2280,7 +2280,7 @@ static int __init init(void)return err; } -static void __exit fini(void) +static void __exit virtio_console_fini(void) {reclaim_dma_bufs ();
@@ -2290,8 +2290,8 @@ static void __exit fini(void)class_destroy (pdrvdata.class);debugfs_remove_recursive (pdrvdata.debugfs_dir); } -module_init (init); -module_exit (fini); +module_init (virtio_console_init); +module_exit (virtio_console_fini);MODULE_DESCRIPTION ("Virtio console driver" );MODULE_LICENSE ("GPL" );
Signature · 8 lines
2.35.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Greg Kroah-Hartman
maintainerPATCH 185/343 jfs: prevent NULL deref in diFree
In reply to Greg Kroah-HartmanFrom: Haimin Zhang <[email protected]>
[ Upstream commit a53046291020ec41e09181396c1e829287b48d47 ]
Add validation check for JFS_IP(ipimap)->i_imap to prevent a NULL deref in diFree since diFree uses it without do any validations. When function jfs_mount calls diMount to initialize fileset inode allocation map, it can fail and JFS_IP(ipimap)->i_imap won't be initialized. Then it calls diFreeSpecial to close fileset inode allocation map inode and it will flow into jfs_evict_inode. Function jfs_evict_inode just validates JFS_SBI(inode->i_sb)->ipimap, then calls diFree. diFree use JFS_IP(ipimap)->i_imap directly, then it will cause a NULL deref.
--- fs/jfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/jfs/inode.c +2 -1
@@ -146,12 +146,13 @@ void jfs_evict_inode(struct inode *inode)dquot_initialize (inode);if (JFS_IP (inode)->fileset ==FILESYSTEM_I ) { +struct inode *ipimap =JFS_SBI (inode->i_sb)->ipimap;truncate_inode_pages_final (&inode->i_data);if (test_cflag (COMMIT_Freewmap, inode))jfs_free_zero_link (inode); -if (JFS_SBI (inode->i_sb)->ipimap) +if (ipimap &&JFS_IP (ipimap)->i_imap)diFree (inode);/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 186/343 SUNRPC: Fix socket waits for write buffer space
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 7496b59f588dd52886fdbac7633608097543a0a5 ]
The socket layer requires that we use the socket lock to protect changes to the sock->sk_write_pending field and others.
--- net/sunrpc/xprtsock.c | 54 +++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 15 deletions(-)
net/sunrpc/xprtsock.c +39 -15
@@ -763,12 +763,12 @@ xs_stream_start_connect(struct sock_xprt *transport)/** * xs_nospace - handle transmit was incomplete * @req: pointer to RPC request +* @transport: pointer to struct sock_xprt * */ -static int xs_nospace (struct rpc_rqst *req) +static int xs_nospace (struct rpc_rqst *req,struct sock_xprt *transport) { -struct rpc_xprt *xprt = req->rq_xprt; - struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); +struct rpc_xprt *xprt = &transport->xprt;struct sock *sk = transport->inet;int ret = -EAGAIN ;
@@ -779,25 +779,49 @@ static int xs_nospace(struct rpc_rqst *req)/* Don't race with disconnect */ if (xprt_connected (xprt)) { +struct socket_wq *wq; + +rcu_read_lock (); + wq =rcu_dereference (sk->sk_wq); +set_bit (SOCKWQ_ASYNC_NOSPACE , &wq->flags); +rcu_read_unlock (); +/* wait for more buffer space */ +set_bit (SOCK_NOSPACE , &sk->sk_socket->flags); sk->sk_write_pending++;xprt_wait_for_buffer_space (xprt); }else ret = -ENOTCONN ;spin_unlock (&xprt->transport_lock); +return ret; +} -/* Race breaker in case memory is freed before above code is called */ -if (ret == -EAGAIN ) { -struct socket_wq *wq; +static int xs_sock_nospace (struct rpc_rqst *req) +{ +struct sock_xprt *transport = + container_of(req->rq_xprt, struct sock_xprt, xprt); +struct sock *sk = transport->inet; +int ret = -EAGAIN ; -rcu_read_lock (); - wq =rcu_dereference (sk->sk_wq); -set_bit (SOCKWQ_ASYNC_NOSPACE , &wq->flags); -rcu_read_unlock (); +lock_sock (sk); +if (!sock_writeable (sk)) + ret =xs_nospace (req, transport); +release_sock (sk); +return ret; +} - sk->sk_write_space (sk); - } +static int xs_stream_nospace (struct rpc_rqst *req) +{ +struct sock_xprt *transport = + container_of(req->rq_xprt, struct sock_xprt, xprt); +struct sock *sk = transport->inet; +int ret = -EAGAIN ; + +lock_sock (sk); +if (!sk_stream_memory_free (sk)) + ret =xs_nospace (req, transport); +release_sock (sk);return ret; }
@@ -887,7 +911,7 @@ static int xs_local_send_request(struct rpc_rqst *req)case -ENOBUFS :break ;case -EAGAIN : - status =xs_nospace (req); + status =xs_stream_nospace (req);break ;default : dprintk("RPC: sendmsg returned unrecognized error %d\n",
@@ -963,7 +987,7 @@ static int xs_udp_send_request(struct rpc_rqst *req)/* Should we call xs_close() here? */ break ;case -EAGAIN : - status =xs_nospace (req); + status =xs_sock_nospace (req);break ;case -ENETUNREACH :case -ENOBUFS :
@@ -1083,7 +1107,7 @@ static int xs_tcp_send_request(struct rpc_rqst *req)/* Should we call xs_close() here? */ break ;case -EAGAIN : - status =xs_nospace (req); + status =xs_stream_nospace (req);break ;case -ECONNRESET :case -ECONNREFUSED :
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 187/343 NFS: nfsiod should not block forever in mempool_alloc()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 515dcdcd48736576c6f5c197814da6f81c60a21e ]
The concern is that since nfsiod is sometimes required to kick off a commit, it can get locked up waiting forever in mempool_alloc() instead of failing gracefully and leaving the commit until later.
Try to allocate from the slab first, with GFP_KERNEL | __GFP_NORETRY, then fall back to a non-blocking attempt to allocate from the memory pool.
--- fs/nfs/internal.h | 7 +++++++ fs/nfs/pnfs_nfs.c | 8 ++++++-- fs/nfs/write.c | 24 +++++++++--------------- include/linux/nfs_fs.h | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-)
fs/nfs/internal.h +7 -0
@@ -573,6 +573,13 @@ nfs_write_match_verf(const struct nfs_writeverf *verf, !nfs_write_verifier_cmp (&req->wb_verf, &verf->verifier); } +static inline gfp_t nfs_io_gfp_mask (void ) +{ +if (current->flags &PF_WQ_WORKER ) +return GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN; +return GFP_KERNEL ; +} +/* unlink.c */ extern struct rpc_task * nfs_async_rename(struct inode *old_dir, struct inode *new_dir,
fs/nfs/pnfs_nfs.c +6 -2
@@ -419,7 +419,7 @@ static struct nfs_commit_data * pnfs_bucket_fetch_commitdata(struct pnfs_commit_bucket *bucket, struct nfs_commit_info *cinfo) { - struct nfs_commit_data *data = nfs_commitdata_alloc(false); + struct nfs_commit_data *data = nfs_commitdata_alloc();if (!data)return NULL ;
@@ -515,7 +515,11 @@ pnfs_generic_commit_pagelist(struct inode *inode, struct list_head *mds_pages,unsigned int nreq =0 ;if (!list_empty (mds_pages)) { - data =nfs_commitdata_alloc (true); + data =nfs_commitdata_alloc (); +if (!data) { +nfs_retry_commit (mds_pages,NULL , cinfo,-1 ); +return -ENOMEM ; + } data->ds_commit_index =-1 ;list_splice_init (mds_pages, &data->pages);list_add_tail (&data->list, &list);
fs/nfs/write.c +9 -15
@@ -70,27 +70,17 @@ static mempool_t *nfs_wdata_mempool;static struct kmem_cache *nfs_cdata_cachep;static mempool_t *nfs_commit_mempool; -struct nfs_commit_data *nfs_commitdata_alloc (bool never_fail) +struct nfs_commit_data *nfs_commitdata_alloc (void ) {struct nfs_commit_data *p; -if (never_fail) - p =mempool_alloc (nfs_commit_mempool,GFP_NOIO ); -else { -/* It is OK to do some reclaim, not no safe to wait -* for anything to be returned to the pool. -* mempool_alloc() cannot handle that particular combination, -* so we need two separate attempts. -*/ + p =kmem_cache_zalloc (nfs_cdata_cachep,nfs_io_gfp_mask ()); +if (!p) { p =mempool_alloc (nfs_commit_mempool,GFP_NOWAIT ); -if (!p) - p =kmem_cache_alloc (nfs_cdata_cachep,GFP_NOIO | - __GFP_NOWARN | __GFP_NORETRY);if (!p)return NULL ; +memset (p,0 ,sizeof (*p)); } - -memset (p,0 ,sizeof (*p));INIT_LIST_HEAD (&p->pages);return p; }
@@ -1826,7 +1816,11 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how,if (list_empty (head))return 0 ; - data =nfs_commitdata_alloc (true); + data =nfs_commitdata_alloc (); +if (!data) { +nfs_retry_commit (head,NULL , cinfo,-1 ); +return -ENOMEM ; + }/* Set up the argument struct */ nfs_init_commit (data, head,NULL , cinfo);
include/linux/nfs_fs.h +1 -1
@@ -585,7 +585,7 @@ extern int nfs_wb_all(struct inode *inode);extern int nfs_wb_page (struct inode *inode,struct page *page);extern int nfs_wb_page_cancel (struct inode *inode,struct page * page);extern int nfs_commit_inode (struct inode *,int ); -extern struct nfs_commit_data *nfs_commitdata_alloc (bool never_fail); +extern struct nfs_commit_data *nfs_commitdata_alloc (void );extern void nfs_commit_free (struct nfs_commit_data *data);bool nfs_commit_end (struct nfs_mds_commit_info *cinfo);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 188/343 NFS: Avoid writeback threads getting stuck in mempool_alloc()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 0bae835b63c53f86cdc524f5962e39409585b22c ]
In a low memory situation, allow the NFS writeback code to fail without getting stuck in infinite loops in mempool_alloc().
--- fs/nfs/pagelist.c | 10 +++++----- fs/nfs/write.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 7 deletions(-)
fs/nfs/pagelist.c +5 -5
@@ -90,10 +90,10 @@ void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos) } } -static inline struct nfs_page * -nfs_page_alloc (void ) +static inline struct nfs_page *nfs_page_alloc (void ) { -struct nfs_page *p =kmem_cache_zalloc (nfs_page_cachep,GFP_KERNEL ); +struct nfs_page *p = +kmem_cache_zalloc (nfs_page_cachep,nfs_io_gfp_mask ());if (p)INIT_LIST_HEAD (&p->wb_list);return p;
@@ -892,7 +892,7 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc,struct nfs_commit_info cinfo;struct nfs_page_array *pg_array = &hdr->page_array;unsigned int pagecount, pageused; -gfp_t gfp_flags =GFP_KERNEL ; +gfp_t gfp_flags =nfs_io_gfp_mask (); pagecount =nfs_page_array_len (mirror->pg_base, mirror->pg_count); pg_array->npages = pagecount;
@@ -979,7 +979,7 @@ nfs_pageio_alloc_mirrors(struct nfs_pageio_descriptor *desc, desc->pg_mirrors_dynamic =NULL ;if (mirror_count ==1 )return desc->pg_mirrors_static; - ret =kmalloc_array (mirror_count,sizeof (*ret),GFP_KERNEL ); + ret =kmalloc_array (mirror_count,sizeof (*ret),nfs_io_gfp_mask ());if (ret !=NULL ) {for (i =0 ; i < mirror_count; i++)nfs_pageio_mirror_init (&ret[i], desc->pg_bsize);
fs/nfs/write.c +8 -2
@@ -94,9 +94,15 @@ EXPORT_SYMBOL_GPL(nfs_commit_free);static struct nfs_pgio_header *nfs_writehdr_alloc (void ) { -struct nfs_pgio_header *p =mempool_alloc (nfs_wdata_mempool,GFP_KERNEL ); +struct nfs_pgio_header *p; -memset (p,0 ,sizeof (*p)); + p =kmem_cache_zalloc (nfs_wdata_cachep,nfs_io_gfp_mask ()); +if (!p) { + p =mempool_alloc (nfs_wdata_mempool,GFP_NOWAIT ); +if (!p) +return NULL ; +memset (p,0 ,sizeof (*p)); + } p->rw_mode =FMODE_WRITE ;return p; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 189/343 selftests: net: Add tls config dependency for tls selftests
In reply to Greg Kroah-HartmanFrom: Naresh Kamboju <[email protected]>
[ Upstream commit d9142e1cf3bbdaf21337767114ecab26fe702d47 ]
selftest net tls test cases need TLS=m without this the test hangs. Enabling config TLS solves this problem and runs to complete.
- CONFIG_TLS=m
--- tools/testing/selftests/net/config | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/net/config +1 -0
@@ -43,5 +43,6 @@ CONFIG_NET_ACT_TUNNEL_KEY=m CONFIG_NET_ACT_MIRRED=m CONFIG_BAREUDP=m CONFIG_IPV6_IOAM6_LWTUNNEL=y +CONFIG_TLS=m CONFIG_CRYPTO_SM4=y CONFIG_AMT=m
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 190/343 parisc: Fix CPU affinity for Lasi, WAX and Dino chips
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
[ Upstream commit 939fc856676c266c3bc347c1c1661872a3725c0f ]
Add the missing logic to allow Lasi, WAX and Dino to set the CPU affinity. This fixes IRQ migration to other CPUs when a CPU is shutdown which currently holds the IRQs for one of those chips.
--- drivers/parisc/dino.c | 41 +++++++++++++++++++++++++++++++++-------- drivers/parisc/gsc.c | 31 +++++++++++++++++++++++++++++++ drivers/parisc/gsc.h | 1 + drivers/parisc/lasi.c | 7 +++---- drivers/parisc/wax.c | 7 +++---- 5 files changed, 71 insertions(+), 16 deletions(-)
drivers/parisc/dino.c +33 -8
@@ -142,9 +142,8 @@ struct dino_device {struct pci_hba_data hba;/* 'C' inheritance - must be first */ spinlock_t dinosaur_pen; -unsigned long txn_addr;/* EIR addr to generate interrupt */ -u32 txn_data;/* EIR data assign to each dino */ u32 imr;/* IRQ's which are enabled */ +struct gsc_irq gsc_irq;int global_irq[DINO_LOCAL_IRQS ];/* map IMR bit to global irq */ #ifdef DINO_DEBUG unsigned int dino_irr0;/* save most recent IRQ line stat */
@@ -339,14 +338,43 @@ static void dino_unmask_irq(struct irq_data *d)if (tmp &DINO_MASK_IRQ (local_irq)) {DBG (KERN_WARNING "%s(): IRQ asserted! (ILR 0x%x)\n" , __func__, tmp); -gsc_writel (dino_dev->txn_data, dino_dev->txn_addr); +gsc_writel (dino_dev->gsc_irq.txn_data, dino_dev->gsc_irq.txn_addr); } } +#ifdef CONFIG_SMP +static int dino_set_affinity_irq (struct irq_data *d,const struct cpumask *dest, +bool force) +{ +struct dino_device *dino_dev =irq_data_get_irq_chip_data (d); +struct cpumask tmask; +int cpu_irq; +u32 eim; + +if (!cpumask_and (&tmask, dest, cpu_online_mask)) +return -EINVAL ; + + cpu_irq =cpu_check_affinity (d, &tmask); +if (cpu_irq <0 ) +return cpu_irq; + + dino_dev->gsc_irq.txn_addr =txn_affinity_addr (d->irq, cpu_irq); + eim = ((u32 ) dino_dev->gsc_irq.txn_addr) | dino_dev->gsc_irq.txn_data; +__raw_writel (eim, dino_dev->hba.base_addr+DINO_IAR0 ); + +irq_data_update_effective_affinity (d, &tmask); + +return IRQ_SET_MASK_OK ; +} +#endif +static struct irq_chip dino_interrupt_type = { .name ="GSC-PCI" , .irq_unmask = dino_unmask_irq, .irq_mask = dino_mask_irq, +#ifdef CONFIG_SMP + .irq_set_affinity = dino_set_affinity_irq, +#endif };
@@ -806,7 +834,6 @@ static int __init dino_common_init(struct parisc_device *dev, {int status;u32 eim; -struct gsc_irq gsc_irq;struct resource *res;pcibios_register_hba (&dino_dev->hba);
@@ -821,10 +848,8 @@ static int __init dino_common_init(struct parisc_device *dev,** still only has 11 IRQ input lines - just map some of them ** to a different processor. */ - dev->irq =gsc_alloc_irq (&gsc_irq); - dino_dev->txn_addr = gsc_irq.txn_addr; - dino_dev->txn_data = gsc_irq.txn_data; - eim = ((u32 ) gsc_irq.txn_addr) | gsc_irq.txn_data; + dev->irq =gsc_alloc_irq (&dino_dev->gsc_irq); + eim = ((u32 ) dino_dev->gsc_irq.txn_addr) | dino_dev->gsc_irq.txn_data;/* ** Dino needs a PA "IRQ" to get a processor's attention.
drivers/parisc/gsc.c +31 -0
@@ -135,10 +135,41 @@ static void gsc_asic_unmask_irq(struct irq_data *d)*/ } +#ifdef CONFIG_SMP +static int gsc_set_affinity_irq (struct irq_data *d,const struct cpumask *dest, +bool force) +{ +struct gsc_asic *gsc_dev =irq_data_get_irq_chip_data (d); +struct cpumask tmask; +int cpu_irq; + +if (!cpumask_and (&tmask, dest, cpu_online_mask)) +return -EINVAL ; + + cpu_irq =cpu_check_affinity (d, &tmask); +if (cpu_irq <0 ) +return cpu_irq; + + gsc_dev->gsc_irq.txn_addr =txn_affinity_addr (d->irq, cpu_irq); + gsc_dev->eim = ((u32 ) gsc_dev->gsc_irq.txn_addr) | gsc_dev->gsc_irq.txn_data; + +/* switch IRQ's for devices below LASI/WAX to other CPU */ +gsc_writel (gsc_dev->eim, gsc_dev->hpa +OFFSET_IAR ); + +irq_data_update_effective_affinity (d, &tmask); + +return IRQ_SET_MASK_OK ; +} +#endif + +static struct irq_chip gsc_asic_interrupt_type = { .name ="GSC-ASIC" , .irq_unmask = gsc_asic_unmask_irq, .irq_mask = gsc_asic_mask_irq, +#ifdef CONFIG_SMP + .irq_set_affinity = gsc_set_affinity_irq, +#endif };int gsc_assign_irq (struct irq_chip *type,void *data)
drivers/parisc/gsc.h +1 -0
@@ -31,6 +31,7 @@ struct gsc_asic {int version;int type;int eim; +struct gsc_irq gsc_irq;int global_irq[32 ]; };
drivers/parisc/lasi.c +3 -4
@@ -163,7 +163,6 @@ static int __init lasi_init_chip(struct parisc_device *dev) {extern void (*chassis_power_off)(void );struct gsc_asic *lasi; -struct gsc_irq gsc_irq;int ret; lasi =kzalloc (sizeof (*lasi),GFP_KERNEL );
@@ -185,7 +184,7 @@ static int __init lasi_init_chip(struct parisc_device *dev)lasi_init_irq (lasi);/* the IRQ lasi should use */ - dev->irq =gsc_alloc_irq (&gsc_irq); + dev->irq =gsc_alloc_irq (&lasi->gsc_irq);if (dev->irq <0 ) {printk (KERN_ERR "%s(): cannot get GSC irq\n" , __func__);
@@ -193,9 +192,9 @@ static int __init lasi_init_chip(struct parisc_device *dev)return -EBUSY ; } - lasi->eim = ((u32 ) gsc_irq.txn_addr) | gsc_irq.txn_data; + lasi->eim = ((u32 ) lasi->gsc_irq.txn_addr) | lasi->gsc_irq.txn_data; - ret =request_irq (gsc_irq.irq, gsc_asic_intr,0 ,"lasi" , lasi); + ret =request_irq (lasi->gsc_irq.irq, gsc_asic_intr,0 ,"lasi" , lasi);if (ret <0 ) {kfree (lasi);return ret;
drivers/parisc/wax.c +3 -4
@@ -68,7 +68,6 @@ static int __init wax_init_chip(struct parisc_device *dev) {struct gsc_asic *wax;struct parisc_device *parent; -struct gsc_irq gsc_irq;int ret; wax =kzalloc (sizeof (*wax),GFP_KERNEL );
@@ -85,7 +84,7 @@ static int __init wax_init_chip(struct parisc_device *dev)wax_init_irq (wax);/* the IRQ wax should use */ - dev->irq =gsc_claim_irq (&gsc_irq,WAX_GSC_IRQ ); + dev->irq =gsc_claim_irq (&wax->gsc_irq,WAX_GSC_IRQ );if (dev->irq <0 ) {printk (KERN_ERR "%s(): cannot get GSC irq\n" , __func__);
@@ -93,9 +92,9 @@ static int __init wax_init_chip(struct parisc_device *dev)return -EBUSY ; } - wax->eim = ((u32 ) gsc_irq.txn_addr) | gsc_irq.txn_data; + wax->eim = ((u32 ) wax->gsc_irq.txn_addr) | wax->gsc_irq.txn_data; - ret =request_irq (gsc_irq.irq, gsc_asic_intr,0 ,"wax" , wax); + ret =request_irq (wax->gsc_irq.irq, gsc_asic_intr,0 ,"wax" , wax);if (ret <0 ) {kfree (wax);return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 191/343 parisc: Fix patch code locking and flushing
In reply to Greg Kroah-HartmanFrom: John David Anglin <[email protected]>
[ Upstream commit a9fe7fa7d874a536e0540469f314772c054a0323 ]
This change fixes the following:
1) The flags variable is not initialized. Always use raw_spin_lock_irqsave and raw_spin_unlock_irqrestore to serialize patching.
2) flush_kernel_vmap_range is primarily intended for DMA flushes. Since __patch_text_multiple is often called with interrupts disabled, it is better to directly call flush_kernel_dcache_range_asm and flush_kernel_icache_range_asm. This avoids an extra call.
3) The final call to flush_icache_range is unnecessary.
--- arch/parisc/kernel/patch.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
arch/parisc/kernel/patch.c +11 -14
@@ -40,10 +40,7 @@ static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags, *need_unmap =1 ;set_fixmap (fixmap,page_to_phys (page)); -if (flags) -raw_spin_lock_irqsave (&patch_lock, *flags); -else -__acquire (&patch_lock); +raw_spin_lock_irqsave (&patch_lock, *flags);return (void *) (__fix_to_virt (fixmap) + (uintaddr & ~PAGE_MASK )); }
@@ -52,10 +49,7 @@ static void __kprobes patch_unmap(int fixmap, unsigned long *flags) {clear_fixmap (fixmap); -if (flags) -raw_spin_unlock_irqrestore (&patch_lock, *flags); -else -__release (&patch_lock); +raw_spin_unlock_irqrestore (&patch_lock, *flags); }void __kprobes __patch_text_multiple (void *addr,u32 *insn,unsigned int len)
@@ -67,8 +61,9 @@ void __kprobes __patch_text_multiple(void *addr, u32 *insn, unsigned int len)int mapped;/* Make sure we don't have any aliases in cache */ -flush_kernel_vmap_range (addr, len); -flush_icache_range (start, end); +flush_kernel_dcache_range_asm (start, end); +flush_kernel_icache_range_asm (start, end); +flush_tlb_kernel_range (start, end); p = fixmap =patch_map (addr,FIX_TEXT_POKE0 , &flags, &mapped);
@@ -81,8 +76,10 @@ void __kprobes __patch_text_multiple(void *addr, u32 *insn, unsigned int len)* We're crossing a page boundary, so * need to remap */ -flush_kernel_vmap_range ((void *)fixmap, - (p-fixmap) *sizeof (*p)); +flush_kernel_dcache_range_asm ((unsigned long )fixmap, + (unsigned long )p); +flush_tlb_kernel_range ((unsigned long )fixmap, + (unsigned long )p);if (mapped)patch_unmap (FIX_TEXT_POKE0 , &flags); p = fixmap = patch_map(addr, FIX_TEXT_POKE0, &flags,
@@ -90,10 +87,10 @@ void __kprobes __patch_text_multiple(void *addr, u32 *insn, unsigned int len) } } -flush_kernel_vmap_range ((void *)fixmap, (p-fixmap) *sizeof (*p)); +flush_kernel_dcache_range_asm ((unsigned long )fixmap, (unsigned long )p); +flush_tlb_kernel_range ((unsigned long )fixmap, (unsigned long )p);if (mapped)patch_unmap (FIX_TEXT_POKE0 , &flags); -flush_icache_range (start, end); }void __kprobes __patch_text (void *addr,u32 insn)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 192/343 mm: fix race between MADV_FREE reclaim and blkdev direct IO read
In reply to Greg Kroah-HartmanFrom: Mauricio Faria de Oliveira <[email protected]>
commit 6c8e2a256915a223f6289f651d6b926cd7135c9e upstream.
Problem:
=======
Userspace might read the zero-page instead of actual data from a direct IO read on a block device if the buffers have been called madvise(MADV_FREE) on earlier (this is discussed below) due to a race between page reclaim on MADV_FREE and blkdev direct IO read.
- Race condition:
==============
During page reclaim, the MADV_FREE page check in try_to_unmap_one() checks if the page is not dirty, then discards its rmap PTE(s) (vs. remap back if the page is dirty).
However, after try_to_unmap_one() returns to shrink_page_list(), it might keep the page _anyway_ if page_ref_freeze() fails (it expects exactly _one_ page reference, from the isolation for page reclaim).
Well, blkdev_direct_IO() gets references for all pages, and on READ operations it only sets them dirty _later_.
So, if MADV_FREE'd pages (i.e., not dirty) are used as buffers for direct IO read from block devices, and page reclaim happens during __blkdev_direct_IO[_simple]() exactly AFTER bio_iov_iter_get_pages() returns, but BEFORE the pages are set dirty, the situation happens.
The direct IO read eventually completes. Now, when userspace reads the buffers, the PTE is no longer there and the page fault handler do_anonymous_page() services that with the zero-page, NOT the data!
A synthetic reproducer is provided.
- Page faults:
===========
If page reclaim happens BEFORE bio_iov_iter_get_pages() the issue doesn't happen, because that faults-in all pages as writeable, so do_anonymous_page() sets up a new page/rmap/PTE, and that is used by direct IO. The userspace reads don't fault as the PTE is there (thus zero-page is not used/setup).
But if page reclaim happens AFTER it / BEFORE setting pages dirty, the PTE is no longer there; the subsequent page faults can't help:
The data-read from the block device probably won't generate faults due to DMA (no MMU) but even in the case it wouldn't use DMA, that happens on different virtual addresses (not user-mapped addresses) because struct bio_vec stores struct page to figure addresses out (which are different from user-mapped addresses) for the read.
Thus userspace reads (to user-mapped addresses) still fault, then do_anonymous_page() gets another struct page that would address/ map to other memory than the struct page used by struct bio_vec for the read. (The original struct page is not available, since it wasn't freed, as page_ref_freeze() failed due to more page refs. And even if it were available, its data cannot be trusted anymore.)
Solution:
========
One solution is to check for the expected page reference count in try_to_unmap_one().
There should be one reference from the isolation (that is also checked in shrink_page_list() with page_ref_freeze()) plus one or more references from page mapping(s) (put in discard: label). Further references mean that rmap/PTE cannot be unmapped/nuked.
(Note: there might be more than one reference from mapping due to fork()/clone() without CLONE_VM, which use the same struct page for references, until the copy-on-write page gets copied.)
So, additional page references (e.g., from direct IO read) now prevent the rmap/PTE from being unmapped/dropped; similarly to the page is not freed per shrink_page_list()/page_ref_freeze()).
- Races and Barriers:
==================
The new check in try_to_unmap_one() should be safe in races with bio_iov_iter_get_pages() in get_user_pages() fast and slow paths, as it's done under the PTE lock.
The fast path doesn't take the lock, but it checks if the PTE has changed and if so, it drops the reference and leaves the page for the slow path (which does take that lock).
The fast path requires synchronization w/ full memory barrier: it writes the page reference count first then it reads the PTE later, while try_to_unmap() writes PTE first then it reads page refcount.
And a second barrier is needed, as the page dirty flag should not be read before the page reference count (as in __remove_mapping()). (This can be a load memory barrier only; no writes are involved.)
Call stack/comments:
- try_to_unmap_one()
- page_vma_mapped_walk()
- map_pte() # see pte_offset_map_lock():
pte_offset_map()
spin_lock()
- ptep_get_and_clear() # write PTE
- smp_mb() # (new barrier) GUP fast path
- page_ref_count() # (new check) read refcount
- page_vma_mapped_walk_done() # see pte_unmap_unlock():
pte_unmap()
spin_unlock()- bio_iov_iter_get_pages()
- __bio_iov_iter_get_pages()
- iov_iter_get_pages()
- get_user_pages_fast()
- internal_get_user_pages_fast()
# fast path
- lockless_pages_from_mm()
- gup_{pgd,p4d,pud,pmd,pte}_range()
ptep = pte_offset_map() # not _lock()
pte = ptep_get_lockless(ptep)
page = pte_page(pte)
try_grab_compound_head(page) # inc refcount
# (RMW/barrier # on success)
if (pte_val(pte) != pte_val(*ptep)) # read PTE
put_compound_head(page) # dec refcount
# go slow path
# slow path
- __gup_longterm_unlocked()
- get_user_pages_unlocked()
- __get_user_pages_locked()
- __get_user_pages()
- follow_{page,p4d,pud,pmd}_mask()
- follow_page_pte()
ptep = pte_offset_map_lock() pte = *ptep
page = vm_normal_page(pte)
try_grab_page(page) # inc refcount
pte_unmap_unlock()
- Huge Pages:
==========
Regarding transparent hugepages, that logic shouldn't change, as MADV_FREE (aka lazyfree) pages are PageAnon() && !PageSwapBacked() (madvise_free_pte_range() -> mark_page_lazyfree() -> lru_lazyfree_fn()) thus should reach shrink_page_list() -> split_huge_page_to_list() before try_to_unmap[_one](), so it deals with normal pages only.
(And in case unlikely/TTU_SPLIT_HUGE_PMD/split_huge_pmd_address() happens, which should not or be rare, the page refcount should be greater than
mapcount: the head page is referenced by tail pages. That also prevents checking the head page then incorrectly call page_remove_rmap(subpage) for a tail page, that isn't even in the shrink_page_list()'s page_list (an effect of split huge pmd/pmvw), as it might happen today in this unlikely scenario.)
MADV_FREE'd buffers:
===================
So, back to the "if MADV_FREE pages are used as buffers" note. The case is arguable, and subject to multiple interpretations.
The madvise(2) manual page on the MADV_FREE advice value says:
1) 'After a successful MADV_FREE ... data will be lost when the kernel frees the pages.'
2) 'the free operation will be canceled if the caller writes into the page' / 'subsequent writes ... will succeed and then [the] kernel cannot free those dirtied pages'
3) 'If there is no subsequent write, the kernel can free the pages at any time.'
Thoughts, questions, considerations... respectively:
1) Since the kernel didn't actually free the page (page_ref_freeze() failed), should the data not have been lost? (on userspace read.)
2) Should writes performed by the direct IO read be able to cancel the free operation?
- Should the direct IO read be considered as 'the caller' too, as it's been requested by 'the caller'?
- Should the bio technique to dirty pages on return to userspace (bio_check_pages_dirty() is called/used by __blkdev_direct_IO()) be considered in another/special way here?
3) Should an upcoming write from a previously requested direct IO read be considered as a subsequent write, so the kernel should not free the pages? (as it's known at the time of page reclaim.)
And lastly:
Technically, the last point would seem a reasonable consideration and balance, as the madvise(2) manual page apparently (and fairly) seem to assume that 'writes' are memory access from the userspace process (not explicitly considering writes from the kernel or its corner cases; again, fairly).. plus the kernel fix implementation for the corner case of the largely 'non-atomic write' encompassed by a direct IO read operation, is relatively simple; and it helps.
Reproducer:
==========
@ test.c (simplified, but works)
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
int main() {
int fd, i;
char *buf;
fd = open(DEV, O_RDONLY | O_DIRECT);
buf = mmap(NULL, BUF_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
for (i = 0; i < BUF_SIZE; i += PAGE_SIZE)
buf[i] = 1; // init to non-zero
madvise(buf, BUF_SIZE, MADV_FREE);
read(fd, buf, BUF_SIZE);
for (i = 0; i < BUF_SIZE; i += PAGE_SIZE)
printf("%p: 0x%x\n", &buf[i], buf[i]);
return 0;
}@ block/fops.c (formerly fs/block_dev.c)
+#include <linux/swap.h>
...
... __blkdev_direct_IO[_simple](...)
{
...
+ if (!strcmp(current->comm, "good"))
+ shrink_all_memory(ULONG_MAX);
+
ret = bio_iov_iter_get_pages(...);
+
+ if (!strcmp(current->comm, "bad"))
+ shrink_all_memory(ULONG_MAX);
...
}@ shell
# NUM_PAGES=4
# PAGE_SIZE=$(getconf PAGE_SIZE)
# yes | dd of=test.img bs=${PAGE_SIZE} count=${NUM_PAGES}
# DEV=$(losetup -f --show test.img)
# gcc -DDEV=\"$DEV\" \
-DBUF_SIZE=$((PAGE_SIZE * NUM_PAGES)) \
-DPAGE_SIZE=${PAGE_SIZE} \
test.c -o test
# od -tx1 $DEV
0000000 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a
*
0040000
# mv test good
# ./good
0x7f7c10418000: 0x79
0x7f7c10419000: 0x79
0x7f7c1041a000: 0x79
0x7f7c1041b000: 0x79
# mv good bad
# ./bad
0x7fa1b8050000: 0x0
0x7fa1b8051000: 0x0
0x7fa1b8052000: 0x0
0x7fa1b8053000: 0x0Note: the issue is consistent on v5.17-rc3, but it's intermittent with the support of MADV_FREE on v4.5 (60%-70% error; needs swap). [wrap do_direct_IO() in do_blockdev_direct_IO() @ fs/direct-io.c].
- v5.17-rc3:
# for i in {1..1000}; do ./good; done \
| cut -d: -f2 | sort | uniq -c
4000 0x79 # mv good bad
# for i in {1..1000}; do ./bad; done \
| cut -d: -f2 | sort | uniq -c
4000 0x0 # free | grep Swap
Swap: 0 0 0- v4.5:
# for i in {1..1000}; do ./good; done \
| cut -d: -f2 | sort | uniq -c
4000 0x79 # mv good bad
# for i in {1..1000}; do ./bad; done \
| cut -d: -f2 | sort | uniq -c
2702 0x0
1298 0x79 # swapoff -av
swapoff /swap # for i in {1..1000}; do ./bad; done \
| cut -d: -f2 | sort | uniq -c
4000 0x79Ceph/TCMalloc:
=============
For documentation purposes, the use case driving the analysis/fix is Ceph on Ubuntu 18.04, as the TCMalloc library there still uses MADV_FREE to release unused memory to the system from the mmap'ed page heap (might be committed back/used again; it's not munmap'ed.) - PageHeap::DecommitSpan() -> TCMalloc_SystemRelease() -> madvise() - PageHeap::CommitSpan() -> TCMalloc_SystemCommit() -> do nothing.
Note: TCMalloc switched back to MADV_DONTNEED a few commits after the release in Ubuntu 18.04 (google-perftools/gperftools 2.5), so the issue just 'disappeared' on Ceph on later Ubuntu releases but is still present in the kernel, and can be hit by other use cases.
The observed issue seems to be the old Ceph bug #22464 [1], where checksum mismatches are observed (and instrumentation with buffer dumps shows zero-pages read from mmap'ed/MADV_FREE'd page ranges).
The issue in Ceph was reasonably deemed a kernel bug (comment #50) and mostly worked around with a retry mechanism, but other parts of Ceph could still hit that (rocksdb). Anyway, it's less likely to be hit again as TCMalloc switched out of MADV_FREE by default.
(Some kernel versions/reports from the Ceph bug, and relation with the MADV_FREE introduction/changes; TCMalloc versions not checked.)
- 4.4 good
- 4.5 (madv_free: introduction)
- 4.9 bad
- 4.10 good? maybe a swapless system
- 4.12 (madv_free: no longer free instantly on swapless systems)
- 4.13 bad
[1] https://tracker.ceph.com/issues/22464
Thanks:
======
Several people contributed to analysis/discussions/tests/reproducers in the first stages when drilling down on ceph/tcmalloc/linux kernel:
- Dan Hill
- Dan Streetman
- Dongdong Tao
- Gavin Guo
- Gerald Yang
- Heitor Alves de Siqueira
- Ioanna Alifieraki
- Jay Vosburgh
- Matthew Ruffell
- Ponnuvel Palaniyappan
Reviews, suggestions, corrections, comments:
- Minchan Kim
- Yu Zhao
- Huang, Ying
- John Hubbard
- Christoph Hellwig
[mfo: backport: replace folio/test_flag with page/flag equivalents;
real Fixes: 854e9ed09ded ("mm: support madvise(MADV_FREE)") in v4.]
--- mm/rmap.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
mm/rmap.c +24 -1
@@ -1599,7 +1599,30 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,/* MADV_FREE page check */ if (!PageSwapBacked (page)) { -if (!PageDirty (page)) { +int ref_count, map_count; + +/* +* Synchronize with gup_pte_range(): +* - clear PTE; barrier; read refcount +* - inc refcount; barrier; read PTE +*/ +smp_mb (); + + ref_count =page_ref_count (page); + map_count =page_mapcount (page); + +/* +* Order reads for page refcount and dirty flag +* (see comments in __remove_mapping()). +*/ +smp_rmb (); + +/* +* The only page refs must be one from isolation +* plus the rmap(s) (dropped by discard:). +*/ +if (ref_count ==1 + map_count && + !PageDirty (page)) {/* Invalidate as we cleared the pte */ mmu_notifier_invalidate_range (mm, address, address +PAGE_SIZE );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 193/343 drm/amdgpu: fix off by one in amdgpu_gfx_kiq_acquire()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 1647b54ed55d4d48c7199d439f8834626576cbe9 ]
This post-op should be a pre-op so that we do not pass -1 as the bit number to test_bit(). The current code will loop downwards from 63 to -1. After changing to a pre-op, it loops from 63 to 0.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -1
@@ -266,7 +266,7 @@ static int amdgpu_gfx_kiq_acquire(struct amdgpu_device *adev,* adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_queue_per_pipe; -while (queue_bit-- >= 0) { +while (--queue_bit >= 0) { if (test_bit(queue_bit, adev->gfx.mec.queue_bitmap)) continue;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 194/343 Drivers: hv: vmbus: Fix initialization of device object in vmbus_device_register()
In reply to Greg Kroah-HartmanFrom: Andrea Parri (Microsoft) <[email protected]>
[ Upstream commit 3a5469582c241abca22500f36a9cb8e9331969cf ]
Initialize the device's dma_{mask,parms} pointers and the device's dma_mask value before invoking device_register(). Address the following trace with 5.17-rc7:
[ 49.646839] WARNING: CPU: 0 PID: 189 at include/linux/dma-mapping.h:543 netvsc_probe+0x37a/0x3a0 [hv_netvsc] [ 49.646928] Call Trace: [ 49.646930] <TASK> [ 49.646935] vmbus_probe+0x40/0x60 [hv_vmbus] [ 49.646942] really_probe+0x1ce/0x3b0 [ 49.646948] __driver_probe_device+0x109/0x180 [ 49.646952] driver_probe_device+0x23/0xa0 [ 49.646955] __device_attach_driver+0x76/0xe0 [ 49.646958] ? driver_allows_async_probing+0x50/0x50 [ 49.646961] bus_for_each_drv+0x84/0xd0 [ 49.646964] __device_attach+0xed/0x170 [ 49.646967] device_initial_probe+0x13/0x20 [ 49.646970] bus_probe_device+0x8f/0xa0 [ 49.646973] device_add+0x41a/0x8e0 [ 49.646975] ? hrtimer_init+0x28/0x80 [ 49.646981] device_register+0x1b/0x20 [ 49.646983] vmbus_device_register+0x5e/0xf0 [hv_vmbus] [ 49.646991] vmbus_add_channel_work+0x12d/0x190 [hv_vmbus] [ 49.646999] process_one_work+0x21d/0x3f0 [ 49.647002] worker_thread+0x4a/0x3b0 [ 49.647005] ? process_one_work+0x3f0/0x3f0 [ 49.647007] kthread+0xff/0x130 [ 49.647011] ? kthread_complete_and_exit+0x20/0x20 [ 49.647015] ret_from_fork+0x22/0x30 [ 49.647020] </TASK> [ 49.647021] ---[ end trace 0000000000000000 ]---
--- drivers/hv/vmbus_drv.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/hv/vmbus_drv.c +4 -3
@@ -2097,6 +2097,10 @@ int vmbus_device_register(struct hv_device *child_device_obj) child_device_obj->device.parent = &hv_acpi_dev->dev; child_device_obj->device.release = vmbus_device_release; + child_device_obj->device.dma_parms = &child_device_obj->dma_parms; + child_device_obj->device.dma_mask = &child_device_obj->dma_mask; +dma_set_mask (&child_device_obj->device,DMA_BIT_MASK (64 )); +/* * Register with the LDM. This will kick off the driver/device * binding...which will eventually call vmbus_match() and vmbus_probe()
@@ -2122,9 +2126,6 @@ int vmbus_device_register(struct hv_device *child_device_obj) }hv_debug_add_dev_dir (child_device_obj); - child_device_obj->device.dma_parms = &child_device_obj->dma_parms; - child_device_obj->device.dma_mask = &child_device_obj->dma_mask; -dma_set_mask (&child_device_obj->device,DMA_BIT_MASK (64 ));return 0 ; err_kset_unregister:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 195/343 Drivers: hv: vmbus: Fix potential crash on module unload
In reply to Greg Kroah-HartmanFrom: Guilherme G. Piccoli <[email protected]>
[ Upstream commit 792f232d57ff28bbd5f9c4abe0466b23d5879dc8 ]
The vmbus driver relies on the panic notifier infrastructure to perform some operations when a panic event is detected. Since vmbus can be built as module, it is required that the driver handles both registering and unregistering such panic notifier callback.
After commit 74347a99e73a ("x86/Hyper-V: Unload vmbus channel in hv panic callback") though, the panic notifier registration is done unconditionally in the module initialization routine whereas the unregistering procedure is conditionally guarded and executes only if HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE capability is set.
This patch fixes that by unconditionally unregistering the panic notifier in the module's exit routine as well.
--- drivers/hv/vmbus_drv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/hv/vmbus_drv.c +7 -2
@@ -2781,10 +2781,15 @@ static void __exit vmbus_exit(void)if (ms_hyperv.misc_features &HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE ) {kmsg_dump_unregister (&hv_kmsg_dumper);unregister_die_notifier (&hyperv_die_block); -atomic_notifier_chain_unregister (&panic_notifier_list, - &hyperv_panic_block); } +/* +* The panic notifier is always registered, hence we should +* also unconditionally unregister it here as well. +*/ +atomic_notifier_chain_unregister (&panic_notifier_list, + &hyperv_panic_block); +free_page ((unsigned long )hv_panic_page);unregister_sysctl_table (hv_ctl_table_hdr); hv_ctl_table_hdr =NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 196/343 netfilter: bitwise: fix reduce comparisons
In reply to Greg Kroah-HartmanFrom: Jeremy Sowden <[email protected]>
[ Upstream commit 31818213170caa51d116eb5dc1167b88523b4fe1 ]
The nft_bitwise_reduce and nft_bitwise_fast_reduce functions should compare the bitwise operation in expr with the tracked operation associated with the destination register of expr. However, instead of being called on expr and track->regs[priv->dreg].selector, nft_expr_priv is called on expr twice, so both reduce functions return true even when the operations differ.
--- net/netfilter/nft_bitwise.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nft_bitwise.c +2 -2
@@ -287,7 +287,7 @@ static bool nft_bitwise_reduce(struct nft_regs_track *track,if (!track->regs[priv->sreg].selector)return false; - bitwise =nft_expr_priv (expr); + bitwise =nft_expr_priv (track->regs[priv->dreg].selector); if (track->regs[priv->sreg].selector == track->regs[priv->dreg].selector && track->regs[priv->dreg].bitwise && track->regs[priv->dreg].bitwise->ops == expr->ops &&
@@ -434,7 +434,7 @@ static bool nft_bitwise_fast_reduce(struct nft_regs_track *track,if (!track->regs[priv->sreg].selector)return false; - bitwise =nft_expr_priv (expr); + bitwise =nft_expr_priv (track->regs[priv->dreg].selector); if (track->regs[priv->sreg].selector == track->regs[priv->dreg].selector && track->regs[priv->dreg].bitwise && track->regs[priv->dreg].bitwise->ops == expr->ops &&
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 197/343 Revert "NFSv4: Handle the special Linux file open access mode"
In reply to Greg Kroah-HartmanFrom: ChenXiaoSong <[email protected]>
[ Upstream commit ab0fc21bc7105b54bafd85bd8b82742f9e68898a ]
This reverts commit 44942b4e457beda00981f616402a1a791e8c616e.
After secondly opening a file with O_ACCMODE|O_DIRECT flags, nfs4_valid_open_stateid() will dereference NULL nfs4_state when lseek().
Reproducer:
1. mount -t nfs -o vers=4.2 $server_ip:/ /mnt/
2. fd = open("/mnt/file", O_ACCMODE|O_DIRECT|O_CREAT)
3. close(fd)
4. fd = open("/mnt/file", O_ACCMODE|O_DIRECT)
5. lseek(fd)
--- fs/nfs/inode.c | 1 - fs/nfs/nfs4file.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
fs/nfs/inode.c +0 -1
@@ -1180,7 +1180,6 @@ int nfs_open(struct inode *inode, struct file *filp)nfs_fscache_open_file (inode, filp);return 0 ; } -EXPORT_SYMBOL_GPL (nfs_open);/* * This function is called whenever some part of NFS notices that
fs/nfs/nfs4file.c +1 -1
@@ -51,7 +51,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)return err;if ((openflags &O_ACCMODE ) ==3 ) -return nfs_open (inode, filp); + openflags--;/* We can't create new files here */ openflags &= ~(O_CREAT |O_EXCL );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 198/343 NFSv4: fix open failure with O_ACCMODE flag
In reply to Greg Kroah-HartmanFrom: ChenXiaoSong <[email protected]>
[ Upstream commit b243874f6f9568b2daf1a00e9222cacdc15e159c ]
open() with O_ACCMODE|O_DIRECT flags secondly will fail.
Reproducer:
1. mount -t nfs -o vers=4.2 $server_ip:/ /mnt/
2. fd = open("/mnt/file", O_ACCMODE|O_DIRECT|O_CREAT)
3. close(fd)
4. fd = open("/mnt/file", O_ACCMODE|O_DIRECT)
Server nfsd4_decode_share_access() will fail with error nfserr_bad_xdr when client use incorrect share access mode of 0.
Fix this by using NFS4_SHARE_ACCESS_BOTH share access mode in client, just like firstly opening.
--- fs/nfs/dir.c | 10 ---------- fs/nfs/internal.h | 10 ++++++++++ fs/nfs/nfs4file.c | 6 ++++-- 3 files changed, 14 insertions(+), 12 deletions(-)
fs/nfs/dir.c +0 -10
@@ -1853,16 +1853,6 @@ const struct dentry_operations nfs4_dentry_operations = { };EXPORT_SYMBOL_GPL (nfs4_dentry_operations); -static fmode_t flags_to_mode (int flags) -{ -fmode_t res = (__force fmode_t )flags &FMODE_EXEC ; -if ((flags &O_ACCMODE ) !=O_WRONLY ) - res |=FMODE_READ ; -if ((flags &O_ACCMODE ) !=O_RDONLY ) - res |=FMODE_WRITE ; -return res; -} -static struct nfs_open_context *create_nfs_open_context (struct dentry *dentry,int open_flags,struct file *filp) {return alloc_nfs_open_context (dentry,flags_to_mode (open_flags), filp);
fs/nfs/internal.h +10 -0
@@ -42,6 +42,16 @@ static inline bool nfs_lookup_is_soft_revalidate(const struct dentry *dentry)return true; } +static inline fmode_t flags_to_mode (int flags) +{ +fmode_t res = (__force fmode_t )flags &FMODE_EXEC ; +if ((flags &O_ACCMODE ) !=O_WRONLY ) + res |=FMODE_READ ; +if ((flags &O_ACCMODE ) !=O_RDONLY ) + res |=FMODE_WRITE ; +return res; +} +/* * Note: RFC 1813 doesn't limit the number of auth flavors that * a server can return, so make something up.
fs/nfs/nfs4file.c +4 -2
@@ -32,6 +32,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)struct dentry *parent =NULL ;struct inode *dir;unsigned openflags = filp->f_flags; +fmode_t f_mode;struct iattr attr;int err;
@@ -50,8 +51,9 @@ nfs4_file_open(struct inode *inode, struct file *filp)if (err)return err; + f_mode = filp->f_mode;if ((openflags &O_ACCMODE ) ==3 ) - openflags--; + f_mode |=flags_to_mode (openflags);/* We can't create new files here */ openflags &= ~(O_CREAT |O_EXCL );
@@ -59,7 +61,7 @@ nfs4_file_open(struct inode *inode, struct file *filp) parent =dget_parent (dentry); dir =d_inode (parent); - ctx =alloc_nfs_open_context (file_dentry (filp), filp->f_mode, filp); + ctx =alloc_nfs_open_context (file_dentry (filp), f_mode, filp); err =PTR_ERR (ctx);if (IS_ERR (ctx)) goto out;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 199/343 scsi: core: scsi_logging: Fix a BUG
In reply to Greg Kroah-HartmanFrom: Tomas Henzl <[email protected]>
[ Upstream commit f06aa52cb2723ec67e92df463827b800d6c477d1 ]
The request_queue may be NULL in a request, for example when it comes from scsi_ioctl_reset(). Check it before use.
--- drivers/scsi/scsi_logging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_logging.c +1 -1
@@ -30,7 +30,7 @@ static inline const char *scmd_name(const struct scsi_cmnd *scmd) {struct request *rq =scsi_cmd_to_rq ((struct scsi_cmnd *)scmd); -if (!rq->q->disk) +if (!rq->q || !rq->q->disk)return NULL ;return rq->q->disk->disk_name; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 200/343 scsi: sr: Fix typo in CDROM(CLOSETRAY|EJECT) handling
In reply to Greg Kroah-HartmanFrom: Kevin Groeneveld <[email protected]>
[ Upstream commit bc5519c18a32ce855bb51b9f5eceb77a9489d080 ]
Commit 2e27f576abc6 ("scsi: scsi_ioctl: Call scsi_cmd_ioctl() from scsi_ioctl()") seems to have a typo as it is checking ret instead of cmd in the if statement checking for CDROMCLOSETRAY and CDROMEJECT. This changes the behaviour of these ioctls as the cdrom_ioctl handling of these is more restrictive than the scsi_ioctl version.
--- drivers/scsi/sr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sr.c +1 -1
@@ -578,7 +578,7 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,scsi_autopm_get_device (sdev); -if (ret !=CDROMCLOSETRAY && ret !=CDROMEJECT ) { +if (cmd !=CDROMCLOSETRAY && cmd !=CDROMEJECT ) { ret =cdrom_ioctl (&cd->cdi, bdev, mode, cmd, arg);if (ret != -ENOSYS ) goto put;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 201/343 scsi: core: Fix sbitmap depth in scsi_realloc_sdev_budget_map()
In reply to Greg Kroah-HartmanFrom: John Garry <[email protected]>
[ Upstream commit eaba83b5b8506bbc9ee7ca2f10aeab3fff3719e7 ]
In commit edb854a3680b ("scsi: core: Reallocate device's budget map on queue depth change"), the sbitmap for the device budget map may be reallocated after the slave device depth is configured.
When the sbitmap is reallocated we use the result from scsi_device_max_queue_depth() for the sbitmap size, but don't resize to match the actual device queue depth.
Fix by resizing the sbitmap after reallocating the budget sbitmap. We do this instead of init'ing the sbitmap to the device queue depth as the user may want to change the queue depth later via sysfs or other.
--- drivers/scsi/scsi_scan.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/scsi/scsi_scan.c +5 -0
@@ -223,6 +223,8 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev,int ret;struct sbitmap sb_backup; + depth = min_t(unsigned int, depth, scsi_device_max_queue_depth(sdev)); +/* * realloc if new shift is calculated, which is caused by setting * up one new default queue depth after calling ->slave_configure
@@ -245,6 +247,9 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev,scsi_device_max_queue_depth (sdev), new_shift,GFP_KERNEL , sdev->request_queue->node, false, true); +if (!ret) +sbitmap_resize (&sdev->budget_map, depth); +if (need_free) {if (ret) sdev->budget_map = sb_backup;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 202/343 scsi: zorro7xx: Fix a resource leak in zorro7xx_remove_one()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 16ed828b872d12ccba8f07bcc446ae89ba662f9c ]
The error handling path of the probe releases a resource that is not freed in the remove function. In some cases, a ioremap() must be undone.
Add the missing iounmap() call in the remove function.
--- drivers/scsi/zorro7xx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/zorro7xx.c +2 -0
@@ -159,6 +159,8 @@ static void zorro7xx_remove_one(struct zorro_dev *z)scsi_remove_host (host);NCR_700_release (host); +if (host->base >0x01000000 ) +iounmap (hostdata->base);kfree (hostdata);free_irq (host->irq, host);zorro_release_device (z);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 203/343 vdpa: mlx5: prevent cvq work from hogging CPU
In reply to Greg Kroah-HartmanFrom: Jason Wang <[email protected]>
[ Upstream commit 55ebf0d60e3cc6c9e8593399e185842c00e12f36 ]
A userspace triggerable infinite loop could happen in mlx5_cvq_kick_handler() if userspace keeps sending a huge amount of cvq requests.
Fixing this by introducing a quota and re-queue the work if we're out of the budget (currently the implicit budget is one) . While at it, using a per device work struct to avoid on demand memory allocation for cvq.
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +9 -12
@@ -163,6 +163,7 @@ struct mlx5_vdpa_net {u32 cur_num_vqs;struct notifier_block nb;struct vdpa_callback config_cb; +struct mlx5_vdpa_wq_ent cvq_ent; };static void free_resources (struct mlx5_vdpa_net *ndev);
@@ -1616,10 +1617,10 @@ static void mlx5_cvq_kick_handler(struct work_struct *work) ndev =to_mlx5_vdpa_ndev (mvdev); cvq = &mvdev->cvq;if (!(ndev->mvdev.actual_features &BIT_ULL (VIRTIO_NET_F_CTRL_VQ ))) - goto out; +return ;if (!cvq->ready) - goto out; +return ;while (true) { err = vringh_getdesc_iotlb(&cvq->vring, &cvq->riov, &cvq->wiov, &cvq->head,
@@ -1653,9 +1654,10 @@ static void mlx5_cvq_kick_handler(struct work_struct *work)if (vringh_need_notify_iotlb (&cvq->vring))vringh_notify (&cvq->vring); + +queue_work (mvdev->wq, &wqent->work); +break ; } -out: -kfree (wqent); }static void mlx5_vdpa_kick_vq (struct vdpa_device *vdev,u16 idx)
@@ -1663,7 +1665,6 @@ static void mlx5_vdpa_kick_vq(struct vdpa_device *vdev, u16 idx)struct mlx5_vdpa_dev *mvdev =to_mvdev (vdev);struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev);struct mlx5_vdpa_virtqueue *mvq; -struct mlx5_vdpa_wq_ent *wqent;if (!is_index_valid (mvdev, idx))return ;
@@ -1672,13 +1673,7 @@ static void mlx5_vdpa_kick_vq(struct vdpa_device *vdev, u16 idx)if (!mvdev->wq || !mvdev->cvq.ready)return ; - wqent =kzalloc (sizeof (*wqent),GFP_ATOMIC ); -if (!wqent) -return ; - - wqent->mvdev = mvdev; -INIT_WORK (&wqent->work, mlx5_cvq_kick_handler); -queue_work (mvdev->wq, &wqent->work); +queue_work (mvdev->wq, &ndev->cvq_ent.work);return ; }
@@ -2668,6 +2663,8 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,if (err) goto err_mr; + ndev->cvq_ent.mvdev = mvdev; +INIT_WORK (&ndev->cvq_ent.work, mlx5_cvq_kick_handler); mvdev->wq =create_singlethread_workqueue ("mlx5_vdpa_wq" );if (!mvdev->wq) { err = -ENOMEM ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 204/343 net: sfc: add missing xdp queue reinitialization
In reply to Greg Kroah-HartmanFrom: Taehee Yoo <[email protected]>
[ Upstream commit 059a47f1da93811d37533556d67e72f2261b1127 ]
After rx/tx ring buffer size is changed, kernel panic occurs when it acts XDP_TX or XDP_REDIRECT.
When tx/rx ring buffer size is changed(ethtool -G), sfc driver reallocates and reinitializes rx and tx queues and their buffer (tx_queue->buffer).
But it misses reinitializing xdp queues(efx->xdp_tx_queues). So, while it is acting XDP_TX or XDP_REDIRECT, it uses the uninitialized tx_queue->buffer.
A new function efx_set_xdp_channels() is separated from efx_set_channels() to handle only xdp queues.
Splat looks like:
BUG: kernel NULL pointer dereference, address: 000000000000002a
#PF: supervisor write access in kernel mode
#PF: error_code(0x0002) - not-present page
PGD 0 P4D 0
Oops: 0002 [#4] PREEMPT SMP NOPTI
RIP: 0010:efx_tx_map_chunk+0x54/0x90 [sfc]
CPU: 2 PID: 0 Comm: swapper/2 Tainted: G D 5.17.0+ #55 e8beeee8289528f11357029357cf
Code: 48 8b 8d a8 01 00 00 48 8d 14 52 4c 8d 2c d0 44 89 e0 48 85 c9 74 0e 44 89 e2 4c 89 f6 48 80
RSP: 0018:ffff92f121e45c60 EFLAGS: 00010297
RIP: 0010:efx_tx_map_chunk+0x54/0x90 [sfc]
RAX: 0000000000000040 RBX: ffff92ea506895c0 RCX: ffffffffc0330870
RDX: 0000000000000001 RSI: 00000001139b10ce RDI: ffff92ea506895c0
RBP: ffffffffc0358a80 R08: 00000001139b110d R09: 0000000000000000
R10: 0000000000000001 R11: ffff92ea414c0088 R12: 0000000000000040
R13: 0000000000000018 R14: 00000001139b10ce R15: ffff92ea506895c0
FS: 0000000000000000(0000) GS:ffff92f121ec0000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Code: 48 8b 8d a8 01 00 00 48 8d 14 52 4c 8d 2c d0 44 89 e0 48 85 c9 74 0e 44 89 e2 4c 89 f6 48 80
CR2: 000000000000002a CR3: 00000003e6810004 CR4: 00000000007706e0
RSP: 0018:ffff92f121e85c60 EFLAGS: 00010297
PKRU: 55555554
RAX: 0000000000000040 RBX: ffff92ea50689700 RCX: ffffffffc0330870
RDX: 0000000000000001 RSI: 00000001145a90ce RDI: ffff92ea50689700
RBP: ffffffffc0358a80 R08: 00000001145a910d R09: 0000000000000000
R10: 0000000000000001 R11: ffff92ea414c0088 R12: 0000000000000040
R13: 0000000000000018 R14: 00000001145a90ce R15: ffff92ea50689700
FS: 0000000000000000(0000) GS:ffff92f121e80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000000000002a CR3: 00000003e6810005 CR4: 00000000007706e0
PKRU: 55555554
Call Trace:
<IRQ>
efx_xdp_tx_buffers+0x12b/0x3d0 [sfc 84c94b8e32d44d296c17e10a634d3ad454de4ba5]
__efx_rx_packet+0x5c3/0x930 [sfc 84c94b8e32d44d296c17e10a634d3ad454de4ba5]
efx_rx_packet+0x28c/0x2e0 [sfc 84c94b8e32d44d296c17e10a634d3ad454de4ba5]
efx_ef10_ev_process+0x5f8/0xf40 [sfc 84c94b8e32d44d296c17e10a634d3ad454de4ba5]
? enqueue_task_fair+0x95/0x550
efx_poll+0xc4/0x360 [sfc 84c94b8e32d44d296c17e10a634d3ad454de4ba5]--- drivers/net/ethernet/sfc/efx_channels.c | 146 +++++++++++++----------- 1 file changed, 81 insertions(+), 65 deletions(-)
drivers/net/ethernet/sfc/efx_channels.c +81 -65
@@ -764,6 +764,85 @@ void efx_remove_channels(struct efx_nic *efx)kfree (efx->xdp_tx_queues); } +static int efx_set_xdp_tx_queue (struct efx_nic *efx,int xdp_queue_number, +struct efx_tx_queue *tx_queue) +{ +if (xdp_queue_number >= efx->xdp_tx_queue_count) +return -EINVAL ; + +netif_dbg (efx, drv, efx->net_dev, +"Channel %u TXQ %u is XDP %u, HW %u\n" , + tx_queue->channel->channel, tx_queue->label, + xdp_queue_number, tx_queue->queue); + efx->xdp_tx_queues[xdp_queue_number] = tx_queue; +return 0 ; +} + +static void efx_set_xdp_channels (struct efx_nic *efx) +{ +struct efx_tx_queue *tx_queue; +struct efx_channel *channel; +unsigned int next_queue =0 ; +int xdp_queue_number =0 ; +int rc; + +/* We need to mark which channels really have RX and TX +* queues, and adjust the TX queue numbers if we have separate +* RX-only and TX-only channels. +*/ +efx_for_each_channel (channel, efx) { +if (channel->channel < efx->tx_channel_offset) +continue ; + +if (efx_channel_is_xdp_tx (channel)) { +efx_for_each_channel_tx_queue (tx_queue, channel) { + tx_queue->queue = next_queue++; + rc =efx_set_xdp_tx_queue (efx, xdp_queue_number, + tx_queue); +if (rc ==0 ) + xdp_queue_number++; + } + }else { +efx_for_each_channel_tx_queue (tx_queue, channel) { + tx_queue->queue = next_queue++; +netif_dbg (efx, drv, efx->net_dev, +"Channel %u TXQ %u is HW %u\n" , + channel->channel, tx_queue->label, + tx_queue->queue); + } + +/* If XDP is borrowing queues from net stack, it must +* use the queue with no csum offload, which is the +* first one of the channel +* (note: tx_queue_by_type is not initialized yet) +*/ +if (efx->xdp_txq_queues_mode == +EFX_XDP_TX_QUEUES_BORROWED ) { + tx_queue = &channel->tx_queue[0 ]; + rc =efx_set_xdp_tx_queue (efx, xdp_queue_number, + tx_queue); +if (rc ==0 ) + xdp_queue_number++; + } + } + } +WARN_ON (efx->xdp_txq_queues_mode ==EFX_XDP_TX_QUEUES_DEDICATED && + xdp_queue_number != efx->xdp_tx_queue_count); +WARN_ON (efx->xdp_txq_queues_mode !=EFX_XDP_TX_QUEUES_DEDICATED && + xdp_queue_number > efx->xdp_tx_queue_count); + +/* If we have more CPUs than assigned XDP TX queues, assign the already +* existing queues to the exceeding CPUs +*/ + next_queue =0 ; +while (xdp_queue_number < efx->xdp_tx_queue_count) { + tx_queue = efx->xdp_tx_queues[next_queue++]; + rc =efx_set_xdp_tx_queue (efx, xdp_queue_number, tx_queue); +if (rc ==0 ) + xdp_queue_number++; + } +} +int efx_realloc_channels (struct efx_nic *efx,u32 rxq_entries,u32 txq_entries) {struct efx_channel *other_channel[EFX_MAX_CHANNELS ], *channel;
@@ -835,6 +914,7 @@ int efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries)efx_init_napi_channel (efx->channel[i]); } +efx_set_xdp_channels (efx); out:/* Destroy unused channel structures */ for (i =0 ; i < efx->n_channels; i++) {
@@ -867,26 +947,9 @@ int efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries) goto out; } -static inline int -efx_set_xdp_tx_queue (struct efx_nic *efx,int xdp_queue_number, -struct efx_tx_queue *tx_queue) -{ -if (xdp_queue_number >= efx->xdp_tx_queue_count) -return -EINVAL ; - -netif_dbg (efx, drv, efx->net_dev,"Channel %u TXQ %u is XDP %u, HW %u\n" , - tx_queue->channel->channel, tx_queue->label, - xdp_queue_number, tx_queue->queue); - efx->xdp_tx_queues[xdp_queue_number] = tx_queue; -return 0 ; -} -int efx_set_channels (struct efx_nic *efx) { -struct efx_tx_queue *tx_queue;struct efx_channel *channel; -unsigned int next_queue =0 ; -int xdp_queue_number;int rc; efx->tx_channel_offset =
@@ -904,61 +967,14 @@ int efx_set_channels(struct efx_nic *efx)return -ENOMEM ; } -/* We need to mark which channels really have RX and TX -* queues, and adjust the TX queue numbers if we have separate -* RX-only and TX-only channels. -*/ - xdp_queue_number =0 ;efx_for_each_channel (channel, efx) {if (channel->channel < efx->n_rx_channels) channel->rx_queue.core_index = channel->channel;else channel->rx_queue.core_index =-1 ; - -if (channel->channel >= efx->tx_channel_offset) { -if (efx_channel_is_xdp_tx (channel)) { -efx_for_each_channel_tx_queue (tx_queue, channel) { - tx_queue->queue = next_queue++; - rc =efx_set_xdp_tx_queue (efx, xdp_queue_number, tx_queue); -if (rc ==0 ) - xdp_queue_number++; - } - }else { -efx_for_each_channel_tx_queue (tx_queue, channel) { - tx_queue->queue = next_queue++; -netif_dbg (efx, drv, efx->net_dev,"Channel %u TXQ %u is HW %u\n" , - channel->channel, tx_queue->label, - tx_queue->queue); - } - -/* If XDP is borrowing queues from net stack, it must use the queue -* with no csum offload, which is the first one of the channel -* (note: channel->tx_queue_by_type is not initialized yet) -*/ -if (efx->xdp_txq_queues_mode ==EFX_XDP_TX_QUEUES_BORROWED ) { - tx_queue = &channel->tx_queue[0 ]; - rc =efx_set_xdp_tx_queue (efx, xdp_queue_number, tx_queue); -if (rc ==0 ) - xdp_queue_number++; - } - } - } } -WARN_ON (efx->xdp_txq_queues_mode ==EFX_XDP_TX_QUEUES_DEDICATED && - xdp_queue_number != efx->xdp_tx_queue_count); -WARN_ON (efx->xdp_txq_queues_mode !=EFX_XDP_TX_QUEUES_DEDICATED && - xdp_queue_number > efx->xdp_tx_queue_count); -/* If we have more CPUs than assigned XDP TX queues, assign the already -* existing queues to the exceeding CPUs -*/ - next_queue =0 ; -while (xdp_queue_number < efx->xdp_tx_queue_count) { - tx_queue = efx->xdp_tx_queues[next_queue++]; - rc =efx_set_xdp_tx_queue (efx, xdp_queue_number, tx_queue); -if (rc ==0 ) - xdp_queue_number++; - } +efx_set_xdp_channels (efx); rc =netif_set_real_num_tx_queues (efx->net_dev, efx->n_tx_channels);if (rc)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 205/343 net/tls: fix slab-out-of-bounds bug in decrypt_internal
In reply to Greg Kroah-HartmanFrom: Ziyang Xuan <[email protected]>
[ Upstream commit 9381fe8c849cfbe50245ac01fc077554f6eaa0e2 ]
The memory size of tls_ctx->rx.iv for AES128-CCM is 12 setting in tls_set_sw_offload(). The return value of crypto_aead_ivsize() for "ccm(aes)" is 16. So memcpy() require 16 bytes from 12 bytes memory space will trigger slab-out-of-bounds bug as following:
==================================================================
BUG: KASAN: slab-out-of-bounds in decrypt_internal+0x385/0xc40 [tls] Read of size 16 at addr ffff888114e84e60 by task tls/10911 Call Trace: <TASK> dump_stack_lvl+0x34/0x44 print_report.cold+0x5e/0x5db ? decrypt_internal+0x385/0xc40 [tls] kasan_report+0xab/0x120 ? decrypt_internal+0x385/0xc40 [tls] kasan_check_range+0xf9/0x1e0 memcpy+0x20/0x60 decrypt_internal+0x385/0xc40 [tls] ? tls_get_rec+0x2e0/0x2e0 [tls] ? process_rx_list+0x1a5/0x420 [tls] ? tls_setup_from_iter.constprop.0+0x2e0/0x2e0 [tls] decrypt_skb_update+0x9d/0x400 [tls] tls_sw_recvmsg+0x3c8/0xb50 [tls] Allocated by task 10911: kasan_save_stack+0x1e/0x40 __kasan_kmalloc+0x81/0xa0 tls_set_sw_offload+0x2eb/0xa20 [tls] tls_setsockopt+0x68c/0x700 [tls] __sys_setsockopt+0xfe/0x1b0
Replace the crypto_aead_ivsize() with prot->iv_size + prot->salt_size when memcpy() iv value in TLS_1_3_VERSION scenario.
--- net/tls/tls_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/tls/tls_sw.c +1 -1
@@ -1495,7 +1495,7 @@ static int decrypt_internal(struct sock *sk, struct sk_buff *skb,if (prot->version ==TLS_1_3_VERSION || prot->cipher_type ==TLS_CIPHER_CHACHA20_POLY1305 )memcpy (iv + iv_offset, tls_ctx->rx.iv, -crypto_aead_ivsize (ctx->aead_recv)); + prot->iv_size + prot->salt_size);else memcpy (iv + iv_offset, tls_ctx->rx.iv, prot->salt_size);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 206/343 vrf: fix packet sniffing for traffic originating from ip tunnels
In reply to Greg Kroah-HartmanFrom: Eyal Birger <[email protected]>
[ Upstream commit 012d69fbfcc739f846766c1da56ef8b493b803b5 ]
in commit 048939088220
("vrf: add mac header for tunneled packets when sniffer is attached") an Ethernet header was cooked for traffic originating from tunnel devices.
However, the header is added based on whether the mac_header is unset and ignores cases where the device doesn't expose a mac header to upper layers, such as in ip tunnels like ipip and gre.
Traffic originating from such devices still appears garbled when capturing on the vrf device.
Fix by observing whether the original device exposes a header to upper layers, similar to the logic done in af_packet.
In addition, skb->mac_len needs to be adjusted after adding the Ethernet header for the skb_push/pull() surrounding dev_queue_xmit_nit() to work on these packets.
--- drivers/net/vrf.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/vrf.c +11 -4
@@ -1266,6 +1266,7 @@ static int vrf_prepare_mac_header(struct sk_buff *skb, eth = (struct ethhdr *)skb->data;skb_reset_mac_header (skb); +skb_reset_mac_len (skb);/* we set the ethernet destination and the source addresses to the * address of the VRF device.
@@ -1295,9 +1296,9 @@ static int vrf_prepare_mac_header(struct sk_buff *skb,*/ static int vrf_add_mac_header_if_unset (struct sk_buff *skb,struct net_device *vrf_dev, -u16 proto) +u16 proto,struct net_device *orig_dev) { -if (skb_mac_header_was_set (skb)) +if (skb_mac_header_was_set (skb) &&dev_has_header (orig_dev))return 0 ;return vrf_prepare_mac_header (skb, vrf_dev, proto);
@@ -1403,6 +1404,8 @@ static struct sk_buff *vrf_ip6_rcv(struct net_device *vrf_dev,/* if packet is NDISC then keep the ingress interface */ if (!is_ndisc) { +struct net_device *orig_dev = skb->dev; +vrf_rx_stats (vrf_dev, skb->len); skb->dev = vrf_dev; skb->skb_iif = vrf_dev->ifindex;
@@ -1411,7 +1414,8 @@ static struct sk_buff *vrf_ip6_rcv(struct net_device *vrf_dev,int err; err =vrf_add_mac_header_if_unset (skb, vrf_dev, -ETH_P_IPV6 ); +ETH_P_IPV6 , + orig_dev);if (likely (!err)) {skb_push (skb, skb->mac_len);dev_queue_xmit_nit (skb, vrf_dev);
@@ -1441,6 +1445,8 @@ static struct sk_buff *vrf_ip6_rcv(struct net_device *vrf_dev,static struct sk_buff *vrf_ip_rcv (struct net_device *vrf_dev,struct sk_buff *skb) { +struct net_device *orig_dev = skb->dev; + skb->dev = vrf_dev; skb->skb_iif = vrf_dev->ifindex;IPCB (skb)->flags |=IPSKB_L3SLAVE ;
@@ -1461,7 +1467,8 @@ static struct sk_buff *vrf_ip_rcv(struct net_device *vrf_dev,if (!list_empty (&vrf_dev->ptype_all)) {int err; - err =vrf_add_mac_header_if_unset (skb, vrf_dev,ETH_P_IP ); + err =vrf_add_mac_header_if_unset (skb, vrf_dev,ETH_P_IP , + orig_dev);if (likely (!err)) {skb_push (skb, skb->mac_len);dev_queue_xmit_nit (skb, vrf_dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 207/343 skbuff: fix coalescing for page_pool fragment recycling
In reply to Greg Kroah-HartmanFrom: Jean-Philippe Brucker <[email protected]>
[ Upstream commit 1effe8ca4e34c34cdd9318436a4232dcb582ebf4 ]
Fix a use-after-free when using page_pool with page fragments. We encountered this problem during normal RX in the hns3 driver:
(1) Initially we have three descriptors in the RX queue. The first one
allocates PAGE1 through page_pool, and the other two allocate one
half of PAGE2 each. Page references look like this:
RX_BD1 _______ PAGE1
RX_BD2 _______ PAGE2
RX_BD3 _________/(2) Handle RX on the first descriptor. Allocate SKB1, eventually added to the receive queue by tcp_queue_rcv().
(3) Handle RX on the second descriptor. Allocate SKB2 and pass it to
netif_receive_skb():
netif_receive_skb(SKB2)
ip_rcv(SKB2)
SKB3 = skb_clone(SKB2)
SKB2 and SKB3 share a reference to PAGE2 through
skb_shinfo()->dataref. The other ref to PAGE2 is still held by
RX_BD3:
SKB2 ---+- PAGE2
SKB3 __/ /
RX_BD3 _________/(3b) Now while handling TCP, coalesce SKB3 with SKB1:
tcp_v4_rcv(SKB3)
tcp_try_coalesce(to=SKB1, from=SKB3) // succeeds
kfree_skb_partial(SKB3)
skb_release_data(SKB3) // drops one dataref
SKB1 _____ PAGE1
\____
SKB2 _____ PAGE2
/
RX_BD3 _________/
In skb_try_coalesce(), __skb_frag_ref() takes a page reference to PAGE2, where it should instead have increased the page_pool frag reference, pp_frag_count. Without coalescing, when releasing both SKB2 and SKB3, a single reference to PAGE2 would be dropped. Now when releasing SKB1 and SKB2, two references to PAGE2 will be dropped, resulting in underflow.
(3c) Drop SKB2:
af_packet_rcv(SKB2)
consume_skb(SKB2)
skb_release_data(SKB2) // drops second dataref
page_pool_return_skb_page(PAGE2) // drops one pp_frag_count
SKB1 _____ PAGE1
\____
PAGE2
/
RX_BD3 _________/(4) Userspace calls recvmsg()
Copies SKB1 and releases it. Since SKB3 was coalesced with SKB1, we release the SKB3 page as well:
tcp_eat_recv_skb(SKB1)
skb_release_data(SKB1)
page_pool_return_skb_page(PAGE1)
page_pool_return_skb_page(PAGE2) // drops second pp_frag_count
(5) PAGE2 is freed, but the third RX descriptor was still using it! In our case this causes IOMMU faults, but it would silently corrupt memory if the IOMMU was disabled.
Change the logic that checks whether pp_recycle SKBs can be coalesced. We still reject differing pp_recycle between 'from' and 'to' SKBs, but in order to avoid the situation described above, we also reject coalescing when both 'from' and 'to' are pp_recycled and 'from' is cloned.
The new logic allows coalescing a cloned pp_recycle SKB into a page refcounted one, because in this case the release (4) will drop the right reference, the one taken by skb_try_coalesce().
--- net/core/skbuff.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
net/core/skbuff.c +11 -4
@@ -5275,11 +5275,18 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,if (skb_cloned (to))return false; -/* The page pool signature of struct page will eventually figure out -* which pages can be recycled or not but for now let's prohibit slab -* allocated and page_pool allocated SKBs from being coalesced. +/* In general, avoid mixing slab allocated and page_pool allocated +* pages within the same SKB. However when @to is not pp_recycle and +* @from is cloned, we can transition frag pages from page_pool to +* reference counted. +* +* On the other hand, don't allow coalescing two pp_recycle SKBs if +* @from is cloned, in case the SKB is using page_pool fragment +* references (PP_FLAG_PAGE_FRAG). Since we only take full page +* references for cloned SKBs at the moment that would result in +* inconsistent reference counts. */ -if (to->pp_recycle != from->pp_recycle) +if (to->pp_recycle != (from->pp_recycle && !skb_cloned (from)))return false;if (len <=skb_tailroom (to)) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 208/343 Revert "net: dsa: stop updating master MTU from master.c"
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 066dfc4290406b1b0b014ae3267d4266a344efd1 ]
This reverts commit a1ff94c2973c43bc1e2677ac63ebb15b1d1ff846.
Switch drivers that don't implement ->port_change_mtu() will cause the DSA master to remain with an MTU of 1500, since we've deleted the other code path. In turn, this causes a regression for those systems, where MTU-sized traffic can no longer be terminated.
Revert the change taking into account the fact that rtnl_lock() is now taken top-level from the callers of dsa_master_setup() and dsa_master_teardown(). Also add a comment in order for it to be absolutely clear why it is still needed.
--- net/dsa/master.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
net/dsa/master.c +24 -1
@@ -337,11 +337,24 @@ static const struct attribute_group dsa_group = {static struct lock_class_key dsa_master_addr_list_lock_key; +static void dsa_master_reset_mtu (struct net_device *dev) +{ +int err; + + err =dev_set_mtu (dev,ETH_DATA_LEN ); +if (err) +netdev_dbg (dev, +"Unable to reset MTU to exclude DSA overheads\n" ); +} +int dsa_master_setup (struct net_device *dev,struct dsa_port *cpu_dp) { +const struct dsa_device_ops *tag_ops = cpu_dp->tag_ops;struct dsa_switch *ds = cpu_dp->ds;struct device_link *consumer_link; -int ret; +int mtu, ret; + + mtu =ETH_DATA_LEN +dsa_tag_protocol_overhead (tag_ops);/* The DSA master must use SET_NETDEV_DEV for this to work. */ consumer_link = device_link_add(ds->dev, dev->dev.parent,
@@ -351,6 +364,15 @@ int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)"Failed to create a device link to DSA switch %s\n" , dev_name(ds->dev)); +/* The switch driver may not implement ->port_change_mtu(), case in +* which dsa_slave_change_mtu() will not update the master MTU either, +* so we need to do that here. +*/ + ret =dev_set_mtu (dev, mtu); +if (ret) +netdev_warn (dev,"error %d setting MTU to %d to include DSA overhead\n" , + ret, mtu); +/* If we use a tagging format that doesn't have an ethertype * field, make sure that all packets from this point on get * sent to the tag format's receive function.
@@ -388,6 +410,7 @@ void dsa_master_teardown(struct net_device *dev)sysfs_remove_group (&dev->dev.kobj, &dsa_group);dsa_netdev_ops_set (dev,NULL );dsa_master_ethtool_teardown (dev); +dsa_master_reset_mtu (dev);dsa_master_set_promiscuity (dev,-1 ); dev->dsa_ptr =NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 209/343 ice: Clear default forwarding VSI during VSI release
In reply to Greg Kroah-HartmanFrom: Ivan Vecera <[email protected]>
[ Upstream commit bd8c624c0cd59de0032752ba3001c107bba97f7b ]
VSI is set as default forwarding one when promisc mode is set for PF interface, when PF is switched to switchdev mode or when VF driver asks to enable allmulticast or promisc mode for the VF interface (when vf-true-promisc-support priv flag is off). The third case is buggy because in that case VSI associated with VF remains as default one after VF removal.
Reproducer:
1. Create VF
echo 1 > sys/class/net/ens7f0/device/sriov_numvfs
2. Enable allmulticast or promisc mode on VF ip link set ens7f0v0 allmulticast on
ip link set ens7f0v0 promisc on
3. Delete VF
echo 0 > sys/class/net/ens7f0/device/sriov_numvfs
4. Try to enable promisc mode on PF
ip link set ens7f0 promisc on
Although it looks that promisc mode on PF is enabled the opposite is true because ice_vsi_sync_fltr() responsible for IFF_PROMISC handling first checks if any other VSI is set as default forwarding one and if so the function does not do anything. At this point it is not possible to enable promisc mode on PF without re-probe device.
To resolve the issue this patch clear default forwarding VSI during ice_vsi_release() when the VSI to be released is the default one.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/ice/ice_lib.c +2 -0
@@ -3147,6 +3147,8 @@ int ice_vsi_release(struct ice_vsi *vsi) } } +if (ice_is_vsi_dflt_vsi (pf->first_sw, vsi)) +ice_clear_dflt_vsi (pf->first_sw);ice_fltr_remove_all (vsi);ice_rm_vsi_lan_cfg (vsi->port_info, vsi->idx); err =ice_rm_vsi_rdma_cfg (vsi->port_info, vsi->idx);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 210/343 ice: Fix MAC address setting
In reply to Greg Kroah-HartmanFrom: Ivan Vecera <[email protected]>
[ Upstream commit 2c0069f3f91f125b1b2ce66cc6bea8eb134723c3 ]
Commit 2ccc1c1ccc671b ("ice: Remove excess error variables") merged the usage of 'status' and 'err' variables into single one in function ice_set_mac_address(). Unfortunately this causes a regression when call of ice_fltr_add_mac() returns -EEXIST because this return value does not indicate an error in this case but value of 'err' remains to be -EEXIST till the end of the function and is returned to caller.
Prior mentioned commit this does not happen because return value of ice_fltr_add_mac() was stored to 'status' variable first and if it was -EEXIST then 'err' remains to be zero.
Fix the problem by reset 'err' to zero when ice_fltr_add_mac() returns -EEXIST.
--- drivers/net/ethernet/intel/ice/ice_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +5 -2
@@ -5432,16 +5432,19 @@ static int ice_set_mac_address(struct net_device *netdev, void *pi)/* Add filter for new MAC. If filter exists, return success */ err =ice_fltr_add_mac (vsi, mac,ICE_FWD_TO_VSI ); -if (err == -EEXIST ) +if (err == -EEXIST ) {/* Although this MAC filter is already present in hardware it's * possible in some cases (e.g. bonding) that dev_addr was * modified outside of the driver and needs to be restored back * to this value. */ netdev_dbg (netdev,"filter for MAC %pM already exists\n" , mac); -else if (err) + +return 0 ; + }else if (err) {/* error if the new filter addition failed */ err = -EADDRNOTAVAIL ; + } err_update_filters:if (err) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 211/343 mctp: Fix check for dev_hard_header() result
In reply to Greg Kroah-HartmanFrom: Matt Johnston <[email protected]>
[ Upstream commit 60be976ac45137657b7b505d7e0d44d0e51accb7 ]
dev_hard_header() returns the length of the header, so we need to test for negative errors rather than non-zero.
--- net/mctp/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mctp/route.c +1 -1
@@ -507,7 +507,7 @@ static int mctp_route_output(struct mctp_route *route, struct sk_buff *skb) rc =dev_hard_header (skb, skb->dev,ntohs (skb->protocol), daddr, skb->dev->dev_addr, skb->len); -if (rc) { +if (rc <0 ) {kfree_skb (skb);return -EHOSTUNREACH ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 212/343 mctp: Use output netdev to allocate skb headroom
In reply to Greg Kroah-HartmanFrom: Matt Johnston <[email protected]>
[ Upstream commit 4a9dda1c1da65beee994f0977a56a9a21c5db2a7 ]
Previously the skb was allocated with headroom MCTP_HEADER_MAXLEN, but that isn't sufficient if we are using devs that are not MCTP specific.
This also adds a check that the smctp_halen provided to sendmsg for extended addressing is the correct size for the netdev.
--- include/net/mctp.h | 2 -- net/mctp/af_mctp.c | 46 +++++++++++++++++++++++++++++++++------------- net/mctp/route.c | 14 +++++++++++--- 3 files changed, 44 insertions(+), 18 deletions(-)
include/net/mctp.h +0 -2
@@ -36,8 +36,6 @@ struct mctp_hdr {#define MCTP_HDR_TAG_SHIFT 0#define MCTP_HDR_TAG_MASK GENMASK(2, 0) -#define MCTP_HEADER_MAXLEN 4 -#define MCTP_INITIAL_DEFAULT_NET 1static inline bool mctp_address_ok (mctp_eid_t eid)
net/mctp/af_mctp.c +33 -13
77 lines not on this page · raw message
net/mctp/route.c +11 -3
@@ -498,6 +498,11 @@ static int mctp_route_output(struct mctp_route *route, struct sk_buff *skb)if (cb->ifindex) {/* direct route; use the hwaddr we stashed in sendmsg */ +if (cb->halen != skb->dev->addr_len) { +/* sanity check, sendmsg should have already caught this */ +kfree_skb (skb); +return -EMSGSIZE ; + } daddr = cb->haddr; }else {/* If lookup fails let the device handle daddr==NULL */
@@ -707,7 +712,7 @@ static int mctp_do_fragment_route(struct mctp_route *rt, struct sk_buff *skb, {const unsigned int hlen =sizeof (struct mctp_hdr );struct mctp_hdr *hdr, *hdr2; -unsigned int pos, size; +unsigned int pos, size, headroom;struct sk_buff *skb2;int rc;u8 seq;
@@ -721,6 +726,9 @@ static int mctp_do_fragment_route(struct mctp_route *rt, struct sk_buff *skb,return -EMSGSIZE ; } +/* keep same headroom as the original skb */ + headroom =skb_headroom (skb); +/* we've got the header */ skb_pull (skb, hlen);
@@ -728,7 +736,7 @@ static int mctp_do_fragment_route(struct mctp_route *rt, struct sk_buff *skb,/* size of message payload */ size =min (mtu - hlen, skb->len - pos); - skb2 =alloc_skb (MCTP_HEADER_MAXLEN + hlen + size,GFP_KERNEL ); + skb2 =alloc_skb (headroom + hlen + size,GFP_KERNEL );if (!skb2) { rc = -ENOMEM ;break ;
@@ -744,7 +752,7 @@ static int mctp_do_fragment_route(struct mctp_route *rt, struct sk_buff *skb,skb_set_owner_w (skb2, skb->sk);/* establish packet */ -skb_reserve (skb2,MCTP_HEADER_MAXLEN ); +skb_reserve (skb2, headroom);skb_reset_network_header (skb2);skb_put (skb2, hlen + size); skb2->transport_header = skb2->network_header + hlen;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 213/343 net: ipv4: fix route with nexthop object delete warning
In reply to Greg Kroah-HartmanFrom: Nikolay Aleksandrov <[email protected]>
[ Upstream commit 6bf92d70e690b7ff12b24f4bfff5e5434d019b82 ]
FRR folks have hit a kernel warning[1] while deleting routes[2] which is caused by trying to delete a route pointing to a nexthop id without specifying nhid but matching on an interface. That is, a route is found but we hit a warning while matching it. The warning is from fib_info_nh() in include/net/nexthop.h because we run it on a fib_info with nexthop object. The call chain is:
inet_rtm_delroute -> fib_table_delete -> fib_nh_match (called with a
nexthop fib_info and also with fc_oif set thus calling fib_info_nh on the fib_info and triggering the warning). The fix is to not do any matching in that branch if the fi has a nexthop object because those are managed separately. I.e. we should match when deleting without nh spec and should fail when deleting a nexthop route with old-style nh spec because nexthop objects are managed separately, e.g.:
$ ip r show 1.2.3.4/32 1.2.3.4 nhid 12 via 192.168.11.2 dev dummy0
$ ip r del 1.2.3.4/32 $ ip r del 1.2.3.4/32 nhid 12 <both should work>
$ ip r del 1.2.3.4/32 dev dummy0 <should fail with ESRCH>
[1]
[ 523.462226] ------------[ cut here ]------------ [ 523.462230] WARNING: CPU: 14 PID: 22893 at include/net/nexthop.h:468 fib_nh_match+0x210/0x460 [ 523.462236] Modules linked in: dummy rpcsec_gss_krb5 xt_socket nf_socket_ipv4 nf_socket_ipv6 ip6table_raw iptable_raw bpf_preload xt_statistic ip_set ip_vs_sh ip_vs_wrr ip_vs_rr ip_vs xt_mark nf_tables xt_nat veth nf_conntrack_netlink nfnetlink xt_addrtype br_netfilter overlay dm_crypt nfsv3 nfs fscache netfs vhost_net vhost vhost_iotlb tap tun xt_CHECKSUM xt_MASQUERADE xt_conntrack 8021q garp mrp ipt_REJECT nf_reject_ipv4 ip6table_mangle ip6table_nat iptable_mangle iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 iptable_filter bridge stp llc rfcomm snd_seq_dummy snd_hrtimer rpcrdma rdma_cm iw_cm ib_cm ib_core ip6table_filter xt_comment ip6_tables vboxnetadp(OE) vboxnetflt(OE) vboxdrv(OE) qrtr bnep binfmt_misc xfs vfat fat squashfs loop nvidia_drm(POE) nvidia_modeset(POE) nvidia_uvm(POE) nvidia(POE) intel_rapl_msr intel_rapl_common snd_hda_codec_realtek snd_hda_codec_generic ledtrig_audio snd_hda_codec_hdmi btusb btrtl iwlmvm uvcvideo btbcm snd_hda_intel edac_mce_amd [ 523.462274] videobuf2_vmalloc videobuf2_memops btintel snd_intel_dspcfg videobuf2_v4l2 snd_intel_sdw_acpi bluetooth snd_usb_audio snd_hda_codec mac80211 snd_usbmidi_lib joydev snd_hda_core videobuf2_common kvm_amd snd_rawmidi snd_hwdep snd_seq videodev ccp snd_seq_device libarc4 ecdh_generic mc snd_pcm kvm iwlwifi snd_timer drm_kms_helper snd cfg80211 cec soundcore irqbypass rapl wmi_bmof i2c_piix4 rfkill k10temp pcspkr acpi_cpufreq nfsd auth_rpcgss nfs_acl lockd grace sunrpc drm zram ip_tables crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel nvme sp5100_tco r8169 nvme_core wmi ipmi_devintf ipmi_msghandler fuse [ 523.462300] CPU: 14 PID: 22893 Comm: ip Tainted: P OE 5.16.18-200.fc35.x86_64 #1 [ 523.462302] Hardware name: Micro-Star International Co., Ltd. MS-7C37/MPG X570 GAMING EDGE WIFI (MS-7C37), BIOS 1.C0 10/29/2020 [ 523.462303] RIP: 0010:fib_nh_match+0x210/0x460 [ 523.462304] Code: 7c 24 20 48 8b b5 90 00 00 00 e8 bb ee f4 ff 48 8b 7c 24 20 41 89 c4 e8 ee eb f4 ff 45 85 e4 0f 85 2e fe ff ff e9 4c ff ff ff <0f> 0b e9 17 ff ff ff 3c 0a 0f 85 61 fe ff ff 48 8b b5 98 00 00 00 [ 523.462306] RSP: 0018:ffffaa53d4d87928 EFLAGS: 00010286 [ 523.462307] RAX: 0000000000000000 RBX: ffffaa53d4d87a90 RCX: ffffaa53d4d87bb0 [ 523.462308] RDX: ffff9e3d2ee6be80 RSI: ffffaa53d4d87a90 RDI: ffffffff920ed380 [ 523.462309] RBP: ffff9e3d2ee6be80 R08: 0000000000000064 R09: 0000000000000000 [ 523.462310] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000031 [ 523.462310] R13: 0000000000000020 R14: 0000000000000000 R15: ffff9e3d331054e0 [ 523.462311] FS: 00007f245517c1c0(0000) GS:ffff9e492ed80000(0000) knlGS:0000000000000000 [ 523.462313] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 523.462313] CR2: 000055e5dfdd8268 CR3: 00000003ef488000 CR4: 0000000000350ee0 [ 523.462315] Call Trace: [ 523.462316] <TASK> [ 523.462320] fib_table_delete+0x1a9/0x310 [ 523.462323] inet_rtm_delroute+0x93/0x110 [ 523.462325] rtnetlink_rcv_msg+0x133/0x370 [ 523.462327] ? _copy_to_iter+0xb5/0x6f0 [ 523.462330] ? rtnl_calcit.isra.0+0x110/0x110 [ 523.462331] netlink_rcv_skb+0x50/0xf0 [ 523.462334] netlink_unicast+0x211/0x330 [ 523.462336] netlink_sendmsg+0x23f/0x480 [ 523.462338] sock_sendmsg+0x5e/0x60 [ 523.462340] ____sys_sendmsg+0x22c/0x270 [ 523.462341] ? import_iovec+0x17/0x20 [ 523.462343] ? sendmsg_copy_msghdr+0x59/0x90 [ 523.462344] ? __mod_lruvec_page_state+0x85/0x110 [ 523.462348] ___sys_sendmsg+0x81/0xc0 [ 523.462350] ? netlink_seq_start+0x70/0x70 [ 523.462352] ? __dentry_kill+0x13a/0x180 [ 523.462354] ? __fput+0xff/0x250 [ 523.462356] __sys_sendmsg+0x49/0x80 [ 523.462358] do_syscall_64+0x3b/0x90 [ 523.462361] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 523.462364] RIP: 0033:0x7f24552aa337 [ 523.462365] Code: 0e 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b9 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 89 54 24 1c 48 89 74 24 10 [ 523.462366] RSP: 002b:00007fff7f05a838 EFLAGS: 00000246 ORIG_RAX: 000000000000002e [ 523.462368] RAX: ffffffffffffffda RBX: 000000006245bf91 RCX: 00007f24552aa337 [ 523.462368] RDX: 0000000000000000 RSI: 00007fff7f05a8a0 RDI: 0000000000000003 [ 523.462369] RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000 [ 523.462370] R10: 0000000000000008 R11: 0000000000000246 R12: 0000000000000001 [ 523.462370] R13: 00007fff7f05ce08 R14: 0000000000000000 R15: 000055e5dfdd1040 [ 523.462373] </TASK> [ 523.462374] ---[ end trace ba537bc16f6bf4ed ]---
[2] https://github.com/FRRouting/frr/issues/6412
--- net/ipv4/fib_semantics.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/ipv4/fib_semantics.c +6 -1
@@ -888,8 +888,13 @@ int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi, }if (cfg->fc_oif || cfg->fc_gw_family) { -struct fib_nh *nh =fib_info_nh (fi,0 ); +struct fib_nh *nh; + +/* cannot match on nexthop object attributes */ +if (fi->nh) +return 1 ; + nh =fib_info_nh (fi,0 );if (cfg->fc_encap) {if (fib_encap_match (net, cfg->fc_encap_type, cfg->fc_encap, nh, cfg, extack))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 214/343 net: stmmac: Fix unset max_speed difference between DT and non-DT platforms
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
[ Upstream commit c21cabb0fd0b54b8b54235fc1ecfe1195a23bcb2 ]
In commit 9cbadf094d9d ("net: stmmac: support max-speed device tree property"), when DT platforms don't set "max-speed", max_speed is set to -1; for non-DT platforms, it stays the default 0.
Prior to commit eeef2f6b9f6e ("net: stmmac: Start adding phylink support"), the check for a valid max_speed setting was to check if it was greater than zero. This commit got it right, but subsequent patches just checked for non-zero, which is incorrect for DT platforms.
In commit 92c3807b9ac3 ("net: stmmac: convert to phylink_get_linkmodes()") the conversion switched completely to checking for non-zero value as a valid value, which caused 1000base-T to stop getting advertised by default.
Instead of trying to fix all the checks, simply leave max_speed alone if DT property parsing fails.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -2
@@ -431,8 +431,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->phylink_node = np;/* Get max speed of operation from device tree */ -if (of_property_read_u32 (np,"max-speed" , &plat->max_speed)) - plat->max_speed =-1 ; +of_property_read_u32 (np,"max-speed" , &plat->max_speed); plat->bus_id =of_alias_get_id (np,"ethernet" );if (plat->bus_id <0 )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 215/343 drm/imx: imx-ldb: Check for null pointer after calling kmemdup
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 8027a9ad9b3568c5eb49c968ad6c97f279d76730 ]
As the possible failure of the allocation, kmemdup() may return NULL pointer.
Therefore, it should be better to check the return value of kmemdup() and return error if fails.
--- drivers/gpu/drm/imx/imx-ldb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/imx/imx-ldb.c +2 -0
@@ -572,6 +572,8 @@ static int imx_ldb_panel_ddc(struct device *dev, edidp =of_get_property (child,"edid" , &edid_len);if (edidp) { channel->edid =kmemdup (edidp, edid_len,GFP_KERNEL ); +if (!channel->edid) +return -ENOMEM ; }else if (!channel->panel) {/* fallback to display-timings node */ ret = of_get_drm_display_mode(child,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 216/343 drm/imx: Fix memory leak in imx_pd_connector_get_modes
In reply to Greg Kroah-HartmanFrom: José Expósito <[email protected]>
[ Upstream commit bce81feb03a20fca7bbdd1c4af16b4e9d5c0e1d3 ]
Avoid leaking the display mode variable if of_get_drm_display_mode fails.
Addresses-Coverity-ID: 1443943 ("Resource leak")
--- drivers/gpu/drm/imx/parallel-display.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/imx/parallel-display.c +3 -1
@@ -75,8 +75,10 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector) ret =of_get_drm_display_mode (np, &imxpd->mode, &imxpd->bus_flags,OF_USE_NATIVE_MODE ); -if (ret) +if (ret) { +drm_mode_destroy (connector->dev, mode);return ret; + }drm_mode_copy (mode, &imxpd->mode); mode->type |=DRM_MODE_TYPE_DRIVER |DRM_MODE_TYPE_PREFERRED ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 217/343 drm/imx: dw_hdmi-imx: Fix bailout in error cases of probe
In reply to Greg Kroah-HartmanFrom: Liu Ying <[email protected]>
[ Upstream commit e8083acc3f8cc2097917018e947fd4c857f60454 ]
In dw_hdmi_imx_probe(), if error happens after dw_hdmi_probe() returns successfully, dw_hdmi_remove() should be called where necessary as bailout.
--- drivers/gpu/drm/imx/dw_hdmi-imx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/imx/dw_hdmi-imx.c +7 -1
@@ -222,6 +222,7 @@ static int dw_hdmi_imx_probe(struct platform_device *pdev)struct device_node *np = pdev->dev.of_node;const struct of_device_id *match =of_match_node (dw_hdmi_imx_dt_ids, np);struct imx_hdmi *hdmi; +int ret; hdmi =devm_kzalloc (&pdev->dev,sizeof (*hdmi),GFP_KERNEL );if (!hdmi)
@@ -243,10 +244,15 @@ static int dw_hdmi_imx_probe(struct platform_device *pdev) hdmi->bridge =of_drm_find_bridge (np);if (!hdmi->bridge) {dev_err (hdmi->dev,"Unable to find bridge\n" ); +dw_hdmi_remove (hdmi->hdmi);return -ENODEV ; } -return component_add (&pdev->dev, &dw_hdmi_imx_ops); + ret =component_add (&pdev->dev, &dw_hdmi_imx_ops); +if (ret) +dw_hdmi_remove (hdmi->hdmi); + +return ret; }static int dw_hdmi_imx_remove (struct platform_device *pdev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 218/343 regulator: rtq2134: Fix missing active_discharge_on setting
In reply to Greg Kroah-HartmanFrom: Axel Lin <[email protected]>
[ Upstream commit 17049bf9de55a42ee96fd34520aff8a484677675 ]
The active_discharge_on setting was missed, so output discharge resistor is always disabled. Fix it.
--- drivers/regulator/rtq2134-regulator.c | 1 + 1 file changed, 1 insertion(+)
drivers/regulator/rtq2134-regulator.c +1 -0
@@ -285,6 +285,7 @@ static const unsigned int rtq2134_buck_ramp_delay_table[] = { .enable_mask = RTQ2134_VOUTEN_MASK, \ .active_discharge_reg = RTQ2134_REG_BUCK##_id##_CFG0, \ .active_discharge_mask = RTQ2134_ACTDISCHG_MASK, \ + .active_discharge_on = RTQ2134_ACTDISCHG_MASK, \ .ramp_reg = RTQ2134_REG_BUCK##_id##_RSPCFG, \ .ramp_mask = RTQ2134_RSPUP_MASK, \ .ramp_delay_table = rtq2134_buck_ramp_delay_table, \
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 219/343 spi: rpc-if: Fix RPM imbalance in probe error path
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 2f8cf5f642e80f8b6b0e660a9c86924a1f41cd80 ]
If rpcif_hw_init() fails, Runtime PM is left enabled.
--- drivers/spi/spi-rpc-if.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/spi/spi-rpc-if.c +6 -2
@@ -158,14 +158,18 @@ static int rpcif_spi_probe(struct platform_device *pdev) error =rpcif_hw_init (rpc, false);if (error) -return error; + goto out_disable_rpm; error =spi_register_controller (ctlr);if (error) {dev_err (&pdev->dev,"spi_register_controller failed\n" ); -rpcif_disable_rpm (rpc); + goto out_disable_rpm; } +return 0 ; + +out_disable_rpm: +rpcif_disable_rpm (rpc);return error; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 220/343 regulator: atc260x: Fix missing active_discharge_on setting
In reply to Greg Kroah-HartmanFrom: Axel Lin <[email protected]>
[ Upstream commit 2316f0fc0ad2aa87a568ceaf3d76be983ee555c3 ]
Without active_discharge_on setting, the SWITCH1 discharge enable control is always disabled. Fix it.
--- drivers/regulator/atc260x-regulator.c | 1 + 1 file changed, 1 insertion(+)
drivers/regulator/atc260x-regulator.c +1 -0
@@ -292,6 +292,7 @@ enum atc2603c_reg_ids { .bypass_mask = BIT(5), \ .active_discharge_reg = ATC2603C_PMU_SWITCH_CTL, \ .active_discharge_mask = BIT(1), \ + .active_discharge_on = BIT(1), \ .owner = THIS_MODULE, \ }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 221/343 arch/arm64: Fix topology initialization for core scheduling
In reply to Greg Kroah-HartmanFrom: Phil Auld <[email protected]>
[ Upstream commit 5524cbb1bfcdff0cad0aaa9f94e6092002a07259 ]
Arm64 systems rely on store_cpu_topology() to call update_siblings_masks() to transfer the toplogy to the various cpu masks. This needs to be done before the call to notify_cpu_starting() which tells the scheduler about each cpu found, otherwise the core scheduling data structures are setup in a way that does not match the actual topology.
With smt_mask not setup correctly we bail on cpumask_weight(smt_mask) == 1 for !leaders in:
notify_cpu_starting()
cpuhp_invoke_callback_range()
sched_cpu_starting()
sched_core_cpu_starting()
which leads to rq->core not being correctly set for !leader-rq's.
Without this change stress-ng (which enables core scheduling in its prctl tests in newer versions -- i.e. with PR_SCHED_CORE support) causes a warning and then a crash (trimmed for legibility):
[ 1853.805168] ------------[ cut here ]------------ [ 1853.809784] task_rq(b)->core != rq->core [ 1853.809792] WARNING: CPU: 117 PID: 0 at kernel/sched/fair.c:11102 cfs_prio_less+0x1b4/0x1c4 ... [ 1854.015210] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010 ... [ 1854.231256] Call trace: [ 1854.233689] pick_next_task+0x3dc/0x81c [ 1854.237512] __schedule+0x10c/0x4cc [ 1854.240988] schedule_idle+0x34/0x54
--- arch/arm64/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/smp.c +1 -1
@@ -234,6 +234,7 @@ asmlinkage notrace void secondary_start_kernel(void)* Log the CPU info before it is marked online and might get read. */ cpuinfo_store_cpu (); +store_cpu_topology (cpu);/* * Enable GIC and timers.
@@ -242,7 +243,6 @@ asmlinkage notrace void secondary_start_kernel(void)ipi_setup (cpu); -store_cpu_topology (cpu);numa_add_cpu (cpu);/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 222/343 bnxt_en: Synchronize tx when xdp redirects happen on same ring
In reply to Greg Kroah-HartmanFrom: Pavan Chebbi <[email protected]>
[ Upstream commit 4f81def272de17dc4bbd89ac38f49b2676c9b3d2 ]
If there are more CPUs than the number of TX XDP rings, multiple XDP redirects can select the same TX ring based on the CPU on which XDP redirect is called. Add locking when needed and use static key to decide whether to take the lock.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 +++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 8 ++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 2 ++ 4 files changed, 19 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +7 -0
@@ -3224,6 +3224,7 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp) } qidx = bp->tc_to_qidx[j]; ring->queue_id = bp->q_info[qidx].queue_id; +spin_lock_init (&txr->xdp_tx_lock);if (i < bp->tx_nr_rings_xdp)continue ;if (i % bp->tx_nr_rings_per_tc == (bp->tx_nr_rings_per_tc -1 ))
@@ -10294,6 +10295,12 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)if (irq_re_init)udp_tunnel_nic_reset_ntf (bp->dev); +if (bp->tx_nr_rings_xdp <num_possible_cpus ()) { +if (!static_key_enabled (&bnxt_xdp_locking_key)) +static_branch_enable (&bnxt_xdp_locking_key); + }else if (static_key_enabled (&bnxt_xdp_locking_key)) { +static_branch_disable (&bnxt_xdp_locking_key); + }set_bit (BNXT_STATE_OPEN , &bp->state);bnxt_enable_int (bp);/* Enable TX queues */
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -0
@@ -800,6 +800,8 @@ struct bnxt_tx_ring_info {u32 dev_state;struct bnxt_ring_struct tx_ring_struct; +/* Synchronize simultaneous xdp_xmit on same ring */ +spinlock_t xdp_tx_lock; };#define BNXT_LEGACY_COAL_CMPL_PARAMS \
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +8 -0
@@ -20,6 +20,8 @@#include "bnxt.h" #include "bnxt_xdp.h" +DEFINE_STATIC_KEY_FALSE (bnxt_xdp_locking_key); +struct bnxt_sw_tx_bd *bnxt_xmit_bd (struct bnxt *bp,struct bnxt_tx_ring_info *txr,dma_addr_t mapping,u32 len)
@@ -227,6 +229,9 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frames, ring =smp_processor_id () % bp->tx_nr_rings_xdp; txr = &bp->tx_ring[ring]; +if (static_branch_unlikely (&bnxt_xdp_locking_key)) +spin_lock (&txr->xdp_tx_lock); +for (i =0 ; i < num_frames; i++) {struct xdp_frame *xdp = frames[i];
@@ -250,6 +255,9 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frames,bnxt_db_write (bp, &txr->tx_db, txr->tx_prod); } +if (static_branch_unlikely (&bnxt_xdp_locking_key)) +spin_unlock (&txr->xdp_tx_lock); +return nxmit; }
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h +2 -0
@@ -10,6 +10,8 @@#ifndef BNXT_XDP_H #define BNXT_XDP_H +DECLARE_STATIC_KEY_FALSE (bnxt_xdp_locking_key); +struct bnxt_sw_tx_bd *bnxt_xmit_bd (struct bnxt *bp,struct bnxt_tx_ring_info *txr,dma_addr_t mapping,u32 len);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 223/343 bnxt_en: reserve space inside receive page for skb_shared_info
In reply to Greg Kroah-HartmanFrom: Andy Gospodarek <[email protected]>
[ Upstream commit facc173cf700e55b2ad249ecbd3a7537f7315691 ]
Insufficient space was being reserved in the page used for packet reception, so the interface MTU could be set too large to still have room for the contents of the packet when doing XDP redirect. This resulted in the following message when redirecting a packet between 3520 and 3822 bytes with an MTU of 3822:
[311815.561880] XDP_WARN: xdp_update_frame_from_buff(line:200): Driver BUG: missing reserved tailroom
--- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -1
@@ -593,7 +593,8 @@ struct nqe_cn {#define BNXT_MAX_MTU 9500#define BNXT_MAX_PAGE_MODE_MTU \ ((unsigned int)PAGE_SIZE - VLAN_ETH_HLEN - NET_IP_ALIGN - \ - XDP_PACKET_HEADROOM) + XDP_PACKET_HEADROOM - \ + SKB_DATA_ALIGN((unsigned int)sizeof(struct skb_shared_info)))#define BNXT_MIN_PKT_SIZE 52
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 224/343 bnxt_en: Prevent XDP redirect from running when stopping TX queue
In reply to Greg Kroah-HartmanFrom: Ray Jui <[email protected]>
[ Upstream commit 27d4073f8d9af0340362554414f4961643a4f4de ]
Add checks in the XDP redirect callback to prevent XDP from running when the TX ring is undergoing shutdown.
Also remove redundant checks in the XDP redirect callback to validate the txr and the flag that indicates the ring supports XDP. The modulo arithmetic on 'tx_nr_rings_xdp' already guarantees the derived TX ring is an XDP ring. txr is also guaranteed to be valid after checking BNXT_STATE_OPEN and within RCU grace period.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +4 -2
@@ -229,14 +229,16 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frames, ring =smp_processor_id () % bp->tx_nr_rings_xdp; txr = &bp->tx_ring[ring]; +if (READ_ONCE (txr->dev_state) ==BNXT_DEV_STATE_CLOSING ) +return -EINVAL ; +if (static_branch_unlikely (&bnxt_xdp_locking_key))spin_lock (&txr->xdp_tx_lock);for (i =0 ; i < num_frames; i++) {struct xdp_frame *xdp = frames[i]; -if (!txr || !bnxt_tx_avail (bp, txr) || - !(bp->bnapi[ring]->flags &BNXT_NAPI_FLAG_XDP )) +if (!bnxt_tx_avail (bp, txr))break ; mapping = dma_map_single(&pdev->dev, xdp->data, xdp->len,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 225/343 sfc: Do not free an empty page_ring
In reply to Greg Kroah-HartmanFrom: Martin Habets <[email protected]>
[ Upstream commit 458f5d92df4807e2a7c803ed928369129996bf96 ]
When the page_ring is not used page_ptr_mask is 0. Do not dereference page_ring[0] in this case.
--- drivers/net/ethernet/sfc/rx_common.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/sfc/rx_common.c +3 -0
@@ -166,6 +166,9 @@ static void efx_fini_rx_recycle_ring(struct efx_rx_queue *rx_queue)struct efx_nic *efx = rx_queue->efx;int i; +if (unlikely (!rx_queue->page_ring)) +return ; +/* Unmap and release the pages in the recycle ring. Remove the ring. */ for (i =0 ; i <= rx_queue->page_ptr_mask; i++) {struct page *page = rx_queue->page_ring[i];
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 226/343 RDMA/mlx5: Dont remove cache MRs when a delay is needed
In reply to Greg Kroah-HartmanFrom: Aharon Landau <[email protected]>
[ Upstream commit 84c2362fb65d69c721fec0974556378cbb36a62b ]
Don't remove MRs from the cache if need to delay the removal.
--- drivers/infiniband/hw/mlx5/mr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/mr.c +3 -1
@@ -541,8 +541,10 @@ static void __cache_work_func(struct mlx5_cache_ent *ent)spin_lock_irq (&ent->lock);if (ent->disabled) goto out; -if (need_delay) +if (need_delay) {queue_delayed_work (cache->wq, &ent->dwork,300 *HZ ); + goto out; + }remove_cache_mr_locked (ent);queue_adjust_cache_locked (ent); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 227/343 RDMA/mlx5: Add a missing update of cache->last_add
In reply to Greg Kroah-HartmanFrom: Aharon Landau <[email protected]>
[ Upstream commit 1d735eeee63a0beb65180ca0224f239cc0c9f804 ]
Update cache->last_add when returning an MR to the cache so that the cache work won't remove it.
--- drivers/infiniband/hw/mlx5/mr.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/mlx5/mr.c +1 -0
@@ -632,6 +632,7 @@ static void mlx5_mr_cache_free(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) {struct mlx5_cache_ent *ent = mr->cache_ent; +WRITE_ONCE (dev->cache.last_add, jiffies);spin_lock_irq (&ent->lock);list_add_tail (&mr->list, &ent->head); ent->available_mrs++;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 228/343 IB/cm: Cancel mad on the DREQ event when the state is MRA_REP_RCVD
In reply to Greg Kroah-HartmanFrom: Mark Zhang <[email protected]>
[ Upstream commit 107dd7beba403a363adfeb3ffe3734fe38a05cce ]
On the passive side when the disconnectReq event comes, if the current state is MRA_REP_RCVD, it needs to cancel the MAD before entering the DREQ_RCVD and TIMEWAIT states, otherwise the destroy_id may block until this mad will reach timeout.
--- drivers/infiniband/core/cm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/core/cm.c +1 -2
@@ -2824,6 +2824,7 @@ static int cm_dreq_handler(struct cm_work *work)switch (cm_id_priv->id.state) {case IB_CM_REP_SENT :case IB_CM_DREQ_SENT : +case IB_CM_MRA_REP_RCVD :ib_cancel_mad (cm_id_priv->msg);break ;case IB_CM_ESTABLISHED :
@@ -2831,8 +2832,6 @@ static int cm_dreq_handler(struct cm_work *work) cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)ib_cancel_mad (cm_id_priv->msg);break ; -case IB_CM_MRA_REP_RCVD : -break ;case IB_CM_TIMEWAIT :atomic_long_inc (&work->port->counters[CM_RECV_DUPLICATES ] [CM_DREQ_COUNTER ]);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 229/343 cifs: fix potential race with cifsd thread
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
[ Upstream commit 687127c81ad32c8900a3fedbc7ed8f686ca95855 ]
To avoid racing with demultiplex thread while it is handling data on socket, use cifs_signal_cifsd_for_reconnect() helper for marking current server to reconnect and let the demultiplex thread handle the rest.
--- fs/cifs/connect.c | 2 +- fs/cifs/netmisc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/cifs/connect.c +1 -1
@@ -4465,7 +4465,7 @@ static int tree_connect_dfs_target(const unsigned int xid, struct cifs_tcon *tco*/ if (rc && server->current_fullpath != server->origin_fullpath) { server->current_fullpath = server->origin_fullpath; -cifs_reconnect (tcon->ses->server, true); +cifs_signal_cifsd_for_reconnect (server, true); }dfs_cache_free_tgts (tl);
fs/cifs/netmisc.c +1 -1
@@ -896,7 +896,7 @@ map_and_check_smb_error(struct mid_q_entry *mid, bool logErr)if (class ==ERRSRV && code == ERRbaduid) {cifs_dbg (FYI ,"Server returned 0x%x, reconnecting session...\n" , code); -cifs_reconnect (mid->server, false); +cifs_signal_cifsd_for_reconnect (mid->server, false); } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 230/343 IB/rdmavt: add lock to call to rvt_error_qp to prevent a race condition
In reply to Greg Kroah-HartmanFrom: Niels Dossche <[email protected]>
[ Upstream commit 4d809f69695d4e7d1378b3a072fa9aef23123018 ]
The documentation of the function rvt_error_qp says both r_lock and s_lock need to be held when calling that function. It also asserts using lockdep that both of those locks are held. However, the commit I referenced in Fixes accidentally makes the call to rvt_error_qp in rvt_ruc_loopback no longer covered by r_lock. This results in the lockdep assertion failing and also possibly in a race condition.
--- drivers/infiniband/sw/rdmavt/qp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rdmavt/qp.c +5 -1
@@ -3190,7 +3190,11 @@ void rvt_ruc_loopback(struct rvt_qp *sqp)spin_lock_irqsave (&sqp->s_lock, flags);rvt_send_complete (sqp, wqe, send_status);if (sqp->ibqp.qp_type ==IB_QPT_RC ) { -int lastwqe =rvt_error_qp (sqp,IB_WC_WR_FLUSH_ERR ); +int lastwqe; + +spin_lock (&sqp->r_lock); + lastwqe =rvt_error_qp (sqp,IB_WC_WR_FLUSH_ERR ); +spin_unlock (&sqp->r_lock); sqp->s_flags &= ~RVT_S_BUSY ;spin_unlock_irqrestore (&sqp->s_lock, flags);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 231/343 sctp: count singleton chunks in assoc user stats
In reply to Greg Kroah-HartmanFrom: Jamie Bainbridge <[email protected]>
[ Upstream commit e3d37210df5c41c51147a2d5d465de1a4d77be7a ]
Singleton chunks (INIT, HEARTBEAT PMTU probes, and SHUTDOWN- COMPLETE) are not counted in SCTP_GET_ASOC_STATS "sas_octrlchunks" counter available to the assoc owner.
These are all control chunks so they should be counted as such.
Add counting of singleton chunks so they are properly accounted for.
--- net/sctp/outqueue.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/sctp/outqueue.c +5 -1
@@ -914,6 +914,7 @@ static void sctp_outq_flush_ctrl(struct sctp_flush_ctx *ctx) ctx->asoc->base.sk->sk_err = -error;return ; } + ctx->asoc->stats.octrlchunks++;break ;case SCTP_CID_ABORT :
@@ -938,7 +939,10 @@ static void sctp_outq_flush_ctrl(struct sctp_flush_ctx *ctx)case SCTP_CID_HEARTBEAT :if (chunk->pmtu_probe) { -sctp_packet_singleton (ctx->transport, chunk, ctx->gfp); + error =sctp_packet_singleton (ctx->transport, + chunk, ctx->gfp); +if (!error) + ctx->asoc->stats.octrlchunks++;break ; } fallthrough;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 232/343 dpaa2-ptp: Fix refcount leak in dpaa2_ptp_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 2b04bd4f03bba021959ca339314f6739710f0954 ]
This node pointer is returned by of_find_compatible_node() with refcount incremented. Calling of_node_put() to aovid the refcount leak.
--- drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c +3 -1
@@ -167,7 +167,7 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev) base =of_iomap (node,0 );if (!base) { err = -ENOMEM ; - goto err_close; + goto err_put; } err =fsl_mc_allocate_irqs (mc_dev);
@@ -210,6 +210,8 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev)fsl_mc_free_irqs (mc_dev); err_unmap:iounmap (base); +err_put: +of_node_put (node); err_close:dprtc_close (mc_dev->mc_io,0 , mc_dev->mc_handle); err_free_mcp:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 233/343 ice: Set txq_teid to ICE_INVAL_TEID on ring creation
In reply to Greg Kroah-HartmanFrom: Anatolii Gerasymenko <[email protected]>
[ Upstream commit ccfee1822042b87e5135d33cad8ea353e64612d2 ]
When VF is freshly created, but not brought up, ring->txq_teid value is by default set to 0.
But 0 is a valid TEID. On some platforms the Root Node of Tx scheduler has a TEID = 0. This can cause issues as shown below.
The proper way is to set ring->txq_teid to ICE_INVAL_TEID (0xFFFFFFFF).
Testing Hints:
echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs ip link set dev ens785f0v0 up
ip link set dev ens785f0v0 down
If we have freshly created VF and quickly turn it on and off, so there would be no time to reach VIRTCHNL_OP_CONFIG_VSI_QUEUES stage, then VIRTCHNL_OP_DISABLE_QUEUES stage will fail with error:
[ 639.531454] disable queue 89 failed 14 [ 639.532233] Failed to disable LAN Tx queues, error: ICE_ERR_AQ_ERROR [ 639.533107] ice 0000:02:00.0: Failed to stop Tx ring 0 on VSI 5
The reason for the fail is that we are trying to send AQ command to delete queue 89, which has never been created and receive an "invalid argument" error from firmware.
As this queue has never been created, it's teid and ring->txq_teid have default value 0.ice_dis_vsi_txq has a check against non-existent queues:
node = ice_sched_find_node_by_teid(pi->root, q_teids[i]); if (!node)
continue;
But on some platforms the Root Node of Tx scheduler has a teid = 0. Hence, ice_sched_find_node_by_teid finds a node with teid = 0 (it is pi->root), and we go further to submit an erroneous request to firmware.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/ice/ice_lib.c +1 -0
@@ -1452,6 +1452,7 @@ static int ice_vsi_alloc_rings(struct ice_vsi *vsi) ring->tx_tstamps = &pf->ptp.port.tx; ring->dev = dev; ring->count = vsi->num_tx_desc; + ring->txq_teid =ICE_INVAL_TEID ;WRITE_ONCE (vsi->tx_rings[i], ring); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 234/343 ice: Do not skip not enabled queues in ice_vc_dis_qs_msg
In reply to Greg Kroah-HartmanFrom: Anatolii Gerasymenko <[email protected]>
[ Upstream commit 05ef6813b234db3196f083b91db3963f040b65bb ]
Disable check for queue being enabled in ice_vc_dis_qs_msg, because there could be a case when queues were created, but were not enabled. We still need to delete those queues.
Normal workflow for VF looks like:
Enable path:VIRTCHNL_OP_ADD_ETH_ADDR (opcode 10)VIRTCHNL_OP_CONFIG_VSI_QUEUES (opcode 6)VIRTCHNL_OP_ENABLE_QUEUES (opcode 8)
Disable path:VIRTCHNL_OP_DISABLE_QUEUES (opcode 9)VIRTCHNL_OP_DEL_ETH_ADDR (opcode 11)
The issue appears only in stress conditions when VF is enabled and disabled very fast.
Eventually there will be a case, when queues are created by VIRTCHNL_OP_CONFIG_VSI_QUEUES, but are not enabled by VIRTCHNL_OP_ENABLE_QUEUES.
In turn, these queues are not deleted by VIRTCHNL_OP_DISABLE_QUEUES, because there is a check whether queues are enabled in ice_vc_dis_qs_msg.
When we bring up the VF again, we will see the "Failed to set LAN Tx queue context" error during VIRTCHNL_OP_CONFIG_VSI_QUEUES step. This happens because old 16 queues were not deleted and VF requests to create 16 more, but ice_sched_get_free_qparent in ice_ena_vsi_txq would fail to find a parent node for first newly requested queue (because all nodes are allocated to 16 old queues).
Testing Hints:
Just enable and disable VF fast enough, so it would be disabled before reaching VIRTCHNL_OP_ENABLE_QUEUES.
while true; do
ip link set dev ens785f0v0 up
sleep 0.065 # adjust delay value for you machine ip link set dev ens785f0v0 down
done
--- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +2 -2
@@ -3351,9 +3351,9 @@ static int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg) goto error_param; } -/* Skip queue if not enabled */ if (!test_bit (vf_q_id, vf->txq_ena)) -continue ; +dev_dbg (ice_pf_to_dev (vsi->back),"Queue %u on VSI %u is not enabled, but stopping it anyway\n" , + vf_q_id, vsi->vsi_num);ice_fill_txq_meta (vsi, ring, &txq_meta);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 235/343 ipv6: Fix stats accounting in ip6_pkt_drop
In reply to Greg Kroah-HartmanFrom: David Ahern <[email protected]>
[ Upstream commit 1158f79f82d437093aeed87d57df0548bdd68146 ]
VRF devices are the loopbacks for VRFs, and a loopback can not be assigned to a VRF. Accordingly, the condition in ip6_pkt_drop should be '||' not '&&'.
--- net/ipv6/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/route.c +1 -1
@@ -4495,7 +4495,7 @@ static int ip6_pkt_drop(struct sk_buff *skb, u8 code, int ipstats_mib_noroutes)struct inet6_dev *idev;int type; -if (netif_is_l3_master (skb->dev) && +if (netif_is_l3_master (skb->dev) || dst->dev == net->loopback_dev) idev =__in6_dev_get_safely (dev_get_by_index_rcu (net,IP6CB (skb)->iif));else
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 236/343 ice: synchronize_rcu() when terminating rings
In reply to Greg Kroah-HartmanFrom: Maciej Fijalkowski <[email protected]>
[ Upstream commit f9124c68f05ffdb87a47e3ea6d5fae9dad7cb6eb ]
Unfortunately, the ice driver doesn't respect the RCU critical section that XSK wakeup is surrounded with. To fix this, add synchronize_rcu() calls to paths that destroy resources that might be in use.
This was addressed in other AF_XDP ZC enabled drivers, for reference see for example commit b3873a5be757 ("net/i40e: Fix concurrency issues between config flow and XSK")
--- drivers/net/ethernet/intel/ice/ice.h | 2 +- drivers/net/ethernet/intel/ice/ice_main.c | 4 +++- drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +1 -1
@@ -674,7 +674,7 @@ static inline struct ice_pf *ice_netdev_to_pf(struct net_device *netdev)static inline bool ice_is_xdp_ena_vsi (struct ice_vsi *vsi) { -return !!vsi->xdp_prog; +return !!READ_ONCE (vsi->xdp_prog); }static inline void ice_set_ring_xdp (struct ice_tx_ring *ring)
drivers/net/ethernet/intel/ice/ice_main.c +3 -1
@@ -2742,8 +2742,10 @@ int ice_destroy_xdp_rings(struct ice_vsi *vsi)ice_for_each_xdp_txq (vsi, i)if (vsi->xdp_rings[i]) { -if (vsi->xdp_rings[i]->desc) +if (vsi->xdp_rings[i]->desc) { +synchronize_rcu ();ice_free_tx_ring (vsi->xdp_rings[i]); + }kfree_rcu (vsi->xdp_rings[i], rcu); vsi->xdp_rings[i] =NULL ; }
drivers/net/ethernet/intel/ice/ice_xsk.c +3 -1
@@ -41,8 +41,10 @@ static void ice_qp_reset_stats(struct ice_vsi *vsi, u16 q_idx)static void ice_qp_clean_rings (struct ice_vsi *vsi,u16 q_idx) {ice_clean_tx_ring (vsi->tx_rings[q_idx]); -if (ice_is_xdp_ena_vsi (vsi)) +if (ice_is_xdp_ena_vsi (vsi)) { +synchronize_rcu ();ice_clean_tx_ring (vsi->xdp_rings[q_idx]); + }ice_clean_rx_ring (vsi->rx_rings[q_idx]); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 237/343 ice: xsk: fix VSI state check in ice_xsk_wakeup()
In reply to Greg Kroah-HartmanFrom: Maciej Fijalkowski <[email protected]>
[ Upstream commit 72b915a2b444e9247c9d424a840e94263db07c27 ]
ICE_DOWN is dedicated for pf->state. Check for ICE_VSI_DOWN being set on vsi->state in ice_xsk_wakeup().
--- drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_xsk.c +1 -1
@@ -765,7 +765,7 @@ ice_xsk_wakeup(struct net_device *netdev, u32 queue_id,struct ice_vsi *vsi = np->vsi;struct ice_tx_ring *ring; -if (test_bit (ICE_DOWN , vsi->state)) +if (test_bit (ICE_VSI_DOWN , vsi->state))return -ENETDOWN ;if (!ice_is_xdp_ena_vsi (vsi))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 238/343 ice: clear cmd_type_offset_bsz for TX rings
In reply to Greg Kroah-HartmanFrom: Maciej Fijalkowski <[email protected]>
[ Upstream commit e19778e6c911691856447c3bf9617f00b3e1347f ]
Currently when XDP rings are created, each descriptor gets its DD bit set, which turns out to be the wrong approach as it can lead to a situation where more descriptors get cleaned than it was supposed to, e.g. when AF_XDP busy poll is run with a large batch size. In this situation, the driver would request for more buffers than it is able to handle.
Fix this by not setting the DD bits in ice_xdp_alloc_setup_rings(). They should be initialized to zero instead.
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -2546,7 +2546,7 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi)spin_lock_init (&xdp_ring->tx_lock);for (j =0 ; j < xdp_ring->count; j++) { tx_desc =ICE_TX_DESC (xdp_ring, j); - tx_desc->cmd_type_offset_bsz =cpu_to_le64 (ICE_TX_DESC_DTYPE_DESC_DONE ); + tx_desc->cmd_type_offset_bsz =0 ; } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 239/343 net: openvswitch: dont send internal clone attribute to the userspace.
In reply to Greg Kroah-HartmanFrom: Ilya Maximets <[email protected]>
[ Upstream commit 3f2a3050b4a3e7f32fc0ea3c9b0183090ae00522 ]
'OVS_CLONE_ATTR_EXEC' is an internal attribute that is used for performance optimization inside the kernel. It's added by the kernel while parsing user-provided actions and should not be sent during the flow dump as it's not part of the uAPI.
The issue doesn't cause any significant problems to the ovs-vswitchd process, because reported actions are not really used in the application lifecycle and only supposed to be shown to a human via ovs-dpctl flow dump. However, the action list is still incorrect and causes the following error if the user wants to look at the datapath flows:
# ovs-dpctl add-dp system@ovs-system
# ovs-dpctl add-flow "<flow match>" "clone(ct(commit),0)"
# ovs-dpctl dump-flows
<flow match>, packets:0, bytes:0, used:never,
actions:clone(bad length 4, expected -1 for: action0(01 00 00 00),
ct(commit),0)With the fix:
# ovs-dpctl dump-flows
<flow match>, packets:0, bytes:0, used:never,
actions:clone(ct(commit),0)Additionally fixed an incorrect attribute name in the comment.
--- net/openvswitch/actions.c | 2 +- net/openvswitch/flow_netlink.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)
net/openvswitch/actions.c +1 -1
@@ -1051,7 +1051,7 @@ static int clone(struct datapath *dp, struct sk_buff *skb,int rem =nla_len (attr);bool dont_clone_flow_key; -/* The first action is always 'OVS_CLONE_ATTR_ARG'. */ +/* The first action is always 'OVS_CLONE_ATTR_EXEC'. */ clone_arg =nla_data (attr); dont_clone_flow_key =nla_get_u32 (clone_arg); actions =nla_next (clone_arg, &rem);
net/openvswitch/flow_netlink.c +3 -1
@@ -3429,7 +3429,9 @@ static int clone_action_to_attr(const struct nlattr *attr,if (!start)return -EMSGSIZE ; - err =ovs_nla_put_actions (nla_data (attr), rem, skb); +/* Skipping the OVS_CLONE_ATTR_EXEC that is always the first attribute. */ + attr =nla_next (nla_data (attr), &rem); + err =ovs_nla_put_actions (attr, rem, skb);if (err)nla_nest_cancel (skb, start);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 240/343 net: ethernet: mv643xx: Fix over zealous checking of_get_mac_address()
In reply to Greg Kroah-HartmanFrom: Andrew Lunn <[email protected]>
[ Upstream commit 11f8e7c122ce013fa745029fa8c94c6db69c2e54 ]
There is often not a MAC address available in an EEPROM accessible by Linux with Marvell devices. Instead the bootload has the MAC address and directly programs it into the hardware. So don't consider an error from of_get_mac_address() has fatal. However, the check was added for the case where there is a MAC address in an the EEPROM, but the EEPROM has not probed yet, and -EPROBE_DEFER is returned. In that case the error should be returned. So make the check specific to this error code.
--- drivers/net/ethernet/marvell/mv643xx_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/mv643xx_eth.c +1 -1
@@ -2751,7 +2751,7 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev, } ret =of_get_mac_address (pnp, ppd.mac_addr); -if (ret) +if (ret == -EPROBE_DEFER )return ret;mv643xx_eth_property (pnp,"tx-queue-size" , ppd.tx_queue_size);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 241/343 net: openvswitch: fix leak of nested actions
In reply to Greg Kroah-HartmanFrom: Ilya Maximets <[email protected]>
[ Upstream commit 1f30fb9166d4f15a1aa19449b9da871fe0ed4796 ]
While parsing user-provided actions, openvswitch module may dynamically allocate memory and store pointers in the internal copy of the actions. So this memory has to be freed while destroying the actions.
Currently there are only two such actions: ct() and set(). However, there are many actions that can hold nested lists of actions and ovs_nla_free_flow_actions() just jumps over them leaking the memory.
For example, removal of the flow with the following actions will lead to a leak of the memory allocated by nf_ct_tmpl_alloc():
actions:clone(ct(commit),0)
Non-freed set() action may also leak the 'dst' structure for the tunnel info including device references.
Under certain conditions with a high rate of flow rotation that may cause significant memory leak problem (2MB per second in reporter's case). The problem is also hard to mitigate, because the user doesn't have direct control over the datapath flows generated by OVS.
Fix that by iterating over all the nested actions and freeing everything that needs to be freed recursively.
New build time assertion should protect us from this problem if new actions will be added in the future.
Unfortunately, openvswitch module doesn't use NLA_F_NESTED, so all attributes has to be explicitly checked. sample() and clone() actions are mixing extra attributes into the user-provided action list. That prevents some code generalization too.
--- net/openvswitch/flow_netlink.c | 95 ++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 5 deletions(-)
net/openvswitch/flow_netlink.c +90 -5
@@ -2288,6 +2288,62 @@ static struct sw_flow_actions *nla_alloc_flow_actions(int size)return sfa; } +static void ovs_nla_free_nested_actions (const struct nlattr *actions,int len); + +static void ovs_nla_free_check_pkt_len_action (const struct nlattr *action) +{ +const struct nlattr *a; +int rem; + +nla_for_each_nested (a, action, rem) { +switch (nla_type (a)) { +case OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL : +case OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER : +ovs_nla_free_nested_actions (nla_data (a),nla_len (a)); +break ; + } + } +} + +static void ovs_nla_free_clone_action (const struct nlattr *action) +{ +const struct nlattr *a =nla_data (action); +int rem =nla_len (action); + +switch (nla_type (a)) { +case OVS_CLONE_ATTR_EXEC : +/* The real list of actions follows this attribute. */ + a =nla_next (a, &rem); +ovs_nla_free_nested_actions (a, rem); +break ; + } +} + +static void ovs_nla_free_dec_ttl_action (const struct nlattr *action) +{ +const struct nlattr *a =nla_data (action); + +switch (nla_type (a)) { +case OVS_DEC_TTL_ATTR_ACTION : +ovs_nla_free_nested_actions (nla_data (a),nla_len (a)); +break ; + } +} + +static void ovs_nla_free_sample_action (const struct nlattr *action) +{ +const struct nlattr *a =nla_data (action); +int rem =nla_len (action); + +switch (nla_type (a)) { +case OVS_SAMPLE_ATTR_ARG : +/* The real list of actions follows this attribute. */ + a =nla_next (a, &rem); +ovs_nla_free_nested_actions (a, rem); +break ; + } +} +static void ovs_nla_free_set_action (const struct nlattr *a) {const struct nlattr *ovs_key =nla_data (a);
@@ -2301,25 +2357,54 @@ static void ovs_nla_free_set_action(const struct nlattr *a) } } -void ovs_nla_free_flow_actions (struct sw_flow_actions *sf_acts) +static void ovs_nla_free_nested_actions (const struct nlattr *actions,int len) {const struct nlattr *a;int rem; -if (!sf_acts) +/* Whenever new actions are added, the need to update this +* function should be considered. +*/ +BUILD_BUG_ON (OVS_ACTION_ATTR_MAX !=23 ); + +if (!actions)return ; -nla_for_each_attr (a, sf_acts->actions, sf_acts->actions_len, rem) { +nla_for_each_attr (a, actions, len, rem) {switch (nla_type (a)) { -case OVS_ACTION_ATTR_SET : -ovs_nla_free_set_action (a); +case OVS_ACTION_ATTR_CHECK_PKT_LEN : +ovs_nla_free_check_pkt_len_action (a); +break ; + +case OVS_ACTION_ATTR_CLONE : +ovs_nla_free_clone_action (a);break ; +case OVS_ACTION_ATTR_CT :ovs_ct_free_action (a);break ; + +case OVS_ACTION_ATTR_DEC_TTL : +ovs_nla_free_dec_ttl_action (a); +break ; + +case OVS_ACTION_ATTR_SAMPLE : +ovs_nla_free_sample_action (a); +break ; + +case OVS_ACTION_ATTR_SET : +ovs_nla_free_set_action (a); +break ; } } +} + +void ovs_nla_free_flow_actions (struct sw_flow_actions *sf_acts) +{ +if (!sf_acts) +return ; +ovs_nla_free_nested_actions (sf_acts->actions, sf_acts->actions_len);kfree (sf_acts); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 242/343 rxrpc: fix a race in rxrpc_exit_net()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 1946014ca3b19be9e485e780e862c375c6f98bad ]
Current code can lead to the following race:
CPU0 CPU1
rxrpc_exit_net()
rxrpc_peer_keepalive_worker()
if (rxnet->live)rxnet->live = false; del_timer_sync(&rxnet->peer_keepalive_timer);
timer_reduce(&rxnet->peer_keepalive_timer, jiffies + delay);
cancel_work_sync(&rxnet->peer_keepalive_work);
rxrpc_exit_net() exits while peer_keepalive_timer is still armed, leading to use-after-free.
syzbot report was:
ODEBUG: free active (active state 0) object type: timer_list hint: rxrpc_peer_keepalive_timeout+0x0/0xb0
WARNING: CPU: 0 PID: 3660 at lib/debugobjects.c:505 debug_print_object+0x16e/0x250 lib/debugobjects.c:505 Modules linked in: CPU: 0 PID: 3660 Comm: kworker/u4:6 Not tainted 5.17.0-syzkaller-13993-g88e6c0207623 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: netns cleanup_net RIP: 0010:debug_print_object+0x16e/0x250 lib/debugobjects.c:505 Code: ff df 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 af 00 00 00 48 8b 14 dd 00 1c 26 8a 4c 89 ee 48 c7 c7 00 10 26 8a e8 b1 e7 28 05 <0f> 0b 83 05 15 eb c5 09 01 48 83 c4 18 5b 5d 41 5c 41 5d 41 5e c3 RSP: 0018:ffffc9000353fb00 EFLAGS: 00010082 RAX: 0000000000000000 RBX: 0000000000000003 RCX: 0000000000000000 RDX: ffff888029196140 RSI: ffffffff815efad8 RDI: fffff520006a7f52 RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000 R10: ffffffff815ea4ae R11: 0000000000000000 R12: ffffffff89ce23e0 R13: ffffffff8a2614e0 R14: ffffffff816628c0 R15: dffffc0000000000 FS: 0000000000000000(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fe1f2908924 CR3: 0000000043720000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> __debug_check_no_obj_freed lib/debugobjects.c:992 [inline] debug_check_no_obj_freed+0x301/0x420 lib/debugobjects.c:1023 kfree+0xd6/0x310 mm/slab.c:3809 ops_free_list.part.0+0x119/0x370 net/core/net_namespace.c:176 ops_free_list net/core/net_namespace.c:174 [inline] cleanup_net+0x591/0xb00 net/core/net_namespace.c:598 process_one_work+0x996/0x1610 kernel/workqueue.c:2289 worker_thread+0x665/0x1080 kernel/workqueue.c:2436 kthread+0x2e9/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298 </TASK>
--- net/rxrpc/net_ns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rxrpc/net_ns.c +1 -1
@@ -113,8 +113,8 @@ static __net_exit void rxrpc_exit_net(struct net *net)struct rxrpc_net *rxnet =rxrpc_net (net); rxnet->live = false; -del_timer_sync (&rxnet->peer_keepalive_timer);cancel_work_sync (&rxnet->peer_keepalive_work); +del_timer_sync (&rxnet->peer_keepalive_timer);rxrpc_destroy_all_calls (rxnet);rxrpc_destroy_all_connections (rxnet);rxrpc_destroy_all_peers (rxnet);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 243/343 net: sfc: fix using uninitialized xdp tx_queue
In reply to Greg Kroah-HartmanFrom: Taehee Yoo <[email protected]>
[ Upstream commit fb5833d81e4333294add35d3ac7f7f52a7bf107f ]
In some cases, xdp tx_queue can get used before initialization.
1. interface up/down
2. ring buffer size change
When CPU cores are lower than maximum number of channels of sfc driver, it creates new channels only for XDP.
When an interface is up or ring buffer size is changed, all channels are initialized.
But xdp channels are always initialized later.
So, the below scenario is possible.
Packets are received to rx queue of normal channels and it is acted XDP_TX and tx_queue of xdp channels get used.
But these tx_queues are not initialized yet.
If so, TX DMA or queue error occurs.
In order to avoid this problem.
1. initializes xdp tx_queues earlier than other rx_queue in efx_start_channels().
2. checks whether tx_queue is initialized or not in efx_xdp_tx_buffers().
Splat looks like:
sfc 0000:08:00.1 enp8s0f1np1: TX queue 10 spurious TX completion id 250 sfc 0000:08:00.1 enp8s0f1np1: resetting (RECOVER_OR_ALL) sfc 0000:08:00.1 enp8s0f1np1: MC command 0x80 inlen 100 failed rc=-22 (raw=22) arg=789
sfc 0000:08:00.1 enp8s0f1np1: has been disabled
--- drivers/net/ethernet/sfc/efx_channels.c | 2 +- drivers/net/ethernet/sfc/tx.c | 3 +++ drivers/net/ethernet/sfc/tx_common.c | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/sfc/efx_channels.c +1 -1
@@ -1118,7 +1118,7 @@ void efx_start_channels(struct efx_nic *efx)struct efx_rx_queue *rx_queue;struct efx_channel *channel; -efx_for_each_channel (channel, efx) { +efx_for_each_channel_rev (channel, efx) {efx_for_each_channel_tx_queue (tx_queue, channel) {efx_init_tx_queue (tx_queue);atomic_inc (&efx->active_queues);
drivers/net/ethernet/sfc/tx.c +3 -0
@@ -443,6 +443,9 @@ int efx_xdp_tx_buffers(struct efx_nic *efx, int n, struct xdp_frame **xdpfs,if (unlikely (!tx_queue))return -EINVAL ; +if (!tx_queue->initialised) +return -EINVAL ; +if (efx->xdp_txq_queues_mode !=EFX_XDP_TX_QUEUES_DEDICATED )HARD_TX_LOCK (efx->net_dev, tx_queue->core_txq, cpu);
drivers/net/ethernet/sfc/tx_common.c +2 -0
@@ -101,6 +101,8 @@ void efx_fini_tx_queue(struct efx_tx_queue *tx_queue)netif_dbg (tx_queue->efx, drv, tx_queue->efx->net_dev,"shutting down TX queue %d\n" , tx_queue->queue); + tx_queue->initialised = false; +if (!tx_queue->buffer)return ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 244/343 net: phy: mscc-miim: reject clause 45 register accesses
In reply to Greg Kroah-HartmanFrom: Michael Walle <[email protected]>
[ Upstream commit 8d90991e5bf7fdb9f264f5f579d18969913054b7 ]
The driver doesn't support clause 45 register access yet, but doesn't check if the access is a c45 one either. This leads to spurious register reads and writes. Add the check.
--- drivers/net/mdio/mdio-mscc-miim.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/mdio/mdio-mscc-miim.c +6 -0
@@ -93,6 +93,9 @@ static int mscc_miim_read(struct mii_bus *bus, int mii_id, int regnum)u32 val;int ret; +if (regnum &MII_ADDR_C45 ) +return -EOPNOTSUPP ; + ret =mscc_miim_wait_pending (bus);if (ret) goto out;
@@ -136,6 +139,9 @@ static int mscc_miim_write(struct mii_bus *bus, int mii_id,struct mscc_miim_dev *miim = bus->priv;int ret; +if (regnum &MII_ADDR_C45 ) +return -EOPNOTSUPP ; + ret =mscc_miim_wait_pending (bus);if (ret <0 ) goto out;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 245/343 qede: confirm skb is allocated before using
In reply to Greg Kroah-HartmanFrom: Jamie Bainbridge <[email protected]>
[ Upstream commit 4e910dbe36508654a896d5735b318c0b88172570 ]
qede_build_skb() assumes build_skb() always works and goes straight to skb_reserve(). However, build_skb() can fail under memory pressure. This results in a kernel panic because the skb to reserve is NULL.
Add a check in case build_skb() failed to allocate and return NULL.
The NULL return is handled correctly in callers to qede_build_skb().
--- drivers/net/ethernet/qlogic/qede/qede_fp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/qlogic/qede/qede_fp.c +3 -0
@@ -748,6 +748,9 @@ qede_build_skb(struct qede_rx_queue *rxq, buf =page_address (bd->data) + bd->page_offset; skb =build_skb (buf, rxq->rx_buf_seg_size); +if (unlikely (!skb)) +return NULL ; +skb_reserve (skb, pad);skb_put (skb, len);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 246/343 spi: bcm-qspi: fix MSPI only access with bcm_qspi_exec_mem_op()
In reply to Greg Kroah-HartmanFrom: Kamal Dasu <[email protected]>
[ Upstream commit 2c7d1b281286c46049cd22b43435cecba560edde ]
This fixes case where MSPI controller is used to access spi-nor flash and BSPI block is not present.
--- drivers/spi/spi-bcm-qspi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-bcm-qspi.c +2 -2
@@ -1205,7 +1205,7 @@ static int bcm_qspi_exec_mem_op(struct spi_mem *mem, addr = op->addr.val; len = op->data.nbytes; -if (bcm_qspi_bspi_ver_three (qspi) == true) { +if (has_bspi (qspi) &&bcm_qspi_bspi_ver_three (qspi) == true) {/* * The address coming into this function is a raw flash offset. * But for BSPI <= V3, we need to convert it to a remapped BSPI
@@ -1224,7 +1224,7 @@ static int bcm_qspi_exec_mem_op(struct spi_mem *mem, len < 4) mspi_read = true; -if (mspi_read) +if (!has_bspi (qspi) || mspi_read)return bcm_qspi_mspi_exec_mem_op (spi, op); ret =bcm_qspi_bspi_set_mode (qspi, op,0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 247/343 drm/amd/display: Fix for dmub outbox notification enable
In reply to Greg Kroah-HartmanFrom: Meenakshikumar Somasundaram <[email protected]>
[ Upstream commit ed7208706448953c6f15009cf139135776c15713 ]
[Why]
Currently driver enables dmub outbox notification before oubox ISR is registered. During boot scenario, sometimes dmub issues hpd outbox message before driver registers ISR and those messages are missed.
[How]
Enable dmub outbox notification after outbox ISR is registered. Also, restructured outbox enable code to call from dm layer and renamed APIs.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 66 +++++++++++++++++-- drivers/gpu/drm/amd/display/dc/dc.h | 3 + .../gpu/drm/amd/display/dc/dce/dmub_outbox.c | 25 +++---- .../gpu/drm/amd/display/dc/dce/dmub_outbox.h | 4 +- .../amd/display/dc/dcn10/dcn10_hw_sequencer.c | 4 -- .../drm/amd/display/dc/dcn31/dcn31_hwseq.c | 2 +- 6 files changed, 80 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +60 -6
@@ -76,6 +76,8 @@#include "dc_trace.h" +#include "dce/dmub_outbox.h" +#define CTX \ dc->ctx
@@ -3707,13 +3709,23 @@ void dc_hardware_release(struct dc *dc) }#endif -/** -* dc_enable_dmub_notifications - Returns whether dmub notification can be enabled -* @dc: dc structure +/* +***************************************************************************** +* Function: dc_is_dmub_outbox_supported - +* +* @brief +* Checks whether DMUB FW supports outbox notifications, if supported +* DM should register outbox interrupt prior to actually enabling interrupts +* via dc_enable_dmub_outbox * -* Returns: True to enable dmub notifications, False otherwise +* @param +* [in] dc: dc structure +* +* @return +* True if DMUB FW supports outbox notifications, False otherwise +***************************************************************************** */ -bool dc_enable_dmub_notifications (struct dc *dc) +bool dc_is_dmub_outbox_supported (struct dc *dc) {#if defined(CONFIG_DRM_AMD_DC_DCN )/* YELLOW_CARP B0 USB4 DPIA needs dmub notifications for interrupts */
@@ -3728,6 +3740,48 @@ bool dc_enable_dmub_notifications(struct dc *dc)/** * dc_process_dmub_aux_transfer_async - Submits aux command to dmub via inbox message +* Function: dc_enable_dmub_notifications +* +* @brief +* Calls dc_is_dmub_outbox_supported to check if dmub fw supports outbox +* notifications. All DMs shall switch to dc_is_dmub_outbox_supported. +* This API shall be removed after switching. +* +* @param +* [in] dc: dc structure +* +* @return +* True if DMUB FW supports outbox notifications, False otherwise +***************************************************************************** +*/ +bool dc_enable_dmub_notifications (struct dc *dc) +{ +return dc_is_dmub_outbox_supported (dc); +} + +/** +***************************************************************************** +* Function: dc_enable_dmub_outbox +* +* @brief +* Enables DMUB unsolicited notifications to x86 via outbox +* +* @param +* [in] dc: dc structure +* +* @return +* None +***************************************************************************** +*/ +void dc_enable_dmub_outbox (struct dc *dc) +{ +struct dc_context *dc_ctx = dc->ctx; + +dmub_enable_outbox_notification (dc_ctx->dmub_srv); +} + +/** +***************************************************************************** * Sets port index appropriately for legacy DDC * @dc: dc structure * @link_index: link index
@@ -3829,7 +3883,7 @@ uint8_t get_link_index_from_dpia_port_index(const struct dc *dc,* [in] payload: aux payload * [out] notify: set_config immediate reply * -* @return +* @return * True if successful, False if failure ***************************************************************************** */
drivers/gpu/drm/amd/display/dc/dc.h +3 -0
@@ -1448,8 +1448,11 @@ void dc_z10_restore(const struct dc *dc);void dc_z10_save_init (struct dc *dc);#endif +bool dc_is_dmub_outbox_supported (struct dc *dc);bool dc_enable_dmub_notifications (struct dc *dc); +void dc_enable_dmub_outbox (struct dc *dc); +bool dc_process_dmub_aux_transfer_async (struct dc *dc,uint32_t link_index,struct aux_payload *payload);
drivers/gpu/drm/amd/display/dc/dce/dmub_outbox.c +14 -11
@@ -22,20 +22,23 @@* Authors: AMD */ -#include "dmub_outbox.h" +#include "dc.h" #include "dc_dmub_srv.h" +#include "dmub_outbox.h" #include "dmub/inc/dmub_cmd.h" -/** -* dmub_enable_outbox_notification - Sends inbox cmd to dmub to enable outbox1 -* messages with interrupt. Dmub sends outbox1 -* message and triggers outbox1 interrupt. -* @dc: dc structure +/* +* Function: dmub_enable_outbox_notification +* +* @brief +* Sends inbox cmd to dmub for enabling outbox notifications to x86. +* +* @param +* [in] dmub_srv: dmub_srv structure */ -void dmub_enable_outbox_notification (struct dc *dc) +void dmub_enable_outbox_notification (struct dc_dmub_srv *dmub_srv) {union dmub_rb_cmd cmd; -struct dc_context *dc_ctx = dc->ctx;memset (&cmd,0x0 ,sizeof (cmd)); cmd.outbox1_enable.header.type =DMUB_CMD__OUTBOX1_ENABLE ;
@@ -45,7 +48,7 @@ void dmub_enable_outbox_notification(struct dc *dc)sizeof (cmd.outbox1_enable.header); cmd.outbox1_enable.enable = true; -dc_dmub_srv_cmd_queue (dc_ctx->dmub_srv, &cmd); -dc_dmub_srv_cmd_execute (dc_ctx->dmub_srv); -dc_dmub_srv_wait_idle (dc_ctx->dmub_srv); +dc_dmub_srv_cmd_queue (dmub_srv, &cmd); +dc_dmub_srv_cmd_execute (dmub_srv); +dc_dmub_srv_wait_idle (dmub_srv); }
drivers/gpu/drm/amd/display/dc/dce/dmub_outbox.h +2 -2
@@ -26,8 +26,8 @@#ifndef _DMUB_OUTBOX_H_#define _DMUB_OUTBOX_H_ -#include "dc.h" +struct dc_dmub_srv ; -void dmub_enable_outbox_notification (struct dc *dc); +void dmub_enable_outbox_notification (struct dc_dmub_srv *dmub_srv);#endif /* _DMUB_OUTBOX_H_ */
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +0 -4
@@ -1500,10 +1500,6 @@ void dcn10_init_hw(struct dc *dc) hws->funcs.dsc_pg_control (hws, res_pool->dscs[i]->inst, false); } -/* Enable outbox notification feature of dmub */ -if (dc->debug.enable_dmub_aux_for_legacy_ddc) -dmub_enable_outbox_notification (dc); -/* we want to turn off all dp displays before doing detection */ if (dc->config.power_down_display_on_boot)dc_link_blank_all_dp_displays (dc);
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c +1 -1
@@ -194,7 +194,7 @@ void dcn31_init_hw(struct dc *dc)/* Enables outbox notifications for usb4 dpia */ if (dc->res_pool->usb4_dpia_count) -dmub_enable_outbox_notification (dc); +dmub_enable_outbox_notification (dc->ctx->dmub_srv);/* we want to turn off all dp displays before doing detection */ if (dc->config.power_down_display_on_boot)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 248/343 drm/amd/display: Remove redundant dsc power gating from init_hw
In reply to Greg Kroah-HartmanFrom: Roman Li <[email protected]>
[ Upstream commit 95707203407c4cf0b7e520a99d6f46d8aed4b57f ]
[Why]
DSC Power down code has been moved from dcn31_init_hw into init_pipes() Need to remove it from dcn10_init_hw() as well to avoid duplicated action on dcn1.x/2.x
[How]
Remove DSC power down code from dcn10_init_hw()
--- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +0 -7
@@ -1493,13 +1493,6 @@ void dcn10_init_hw(struct dc *dc) link->link_status.link_active = true; } -/* Power gate DSCs */ -if (!is_optimized_init_done) { -for (i =0 ; i < res_pool->res_cap->num_dsc; i++) -if (hws->funcs.dsc_pg_control !=NULL ) - hws->funcs.dsc_pg_control (hws, res_pool->dscs[i]->inst, false); - } -/* we want to turn off all dp displays before doing detection */ if (dc->config.power_down_display_on_boot)dc_link_blank_all_dp_displays (dc);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 249/343 bpf: Support dual-stack sockets in bpf_tcp_check_syncookie
In reply to Greg Kroah-HartmanFrom: Maxim Mikityanskiy <[email protected]>
[ Upstream commit 2e8702cc0cfa1080f29fd64003c00a3e24ac38de ]
bpf_tcp_gen_syncookie looks at the IP version in the IP header and validates the address family of the socket. It supports IPv4 packets in AF_INET6 dual-stack sockets.
On the other hand, bpf_tcp_check_syncookie looks only at the address family of the socket, ignoring the real IP version in headers, and validates only the packet size. This implementation has some drawbacks:
1. Packets are not validated properly, allowing a BPF program to trick bpf_tcp_check_syncookie into handling an IPv6 packet on an IPv4 socket.
2. Dual-stack sockets fail the checks on IPv4 packets. IPv4 clients end up receiving a SYNACK with the cookie, but the following ACK gets dropped.
This patch fixes these issues by changing the checks in bpf_tcp_check_syncookie to match the ones in bpf_tcp_gen_syncookie. IP version from the header is taken into account, and it is validated properly with address family.
--- net/core/filter.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
net/core/filter.c +13 -4
@@ -6777,24 +6777,33 @@ BPF_CALL_5(bpf_tcp_check_syncookie, struct sock *, sk, void *, iph, u32, iph_lenif (!th->ack || th->rst || th->syn)return -ENOENT ; +if (unlikely (iph_len <sizeof (struct iphdr ))) +return -EINVAL ; +if (tcp_synq_no_recent_overflow (sk))return -ENOENT ; cookie =ntohl (th->ack_seq) -1 ; -switch (sk->sk_family) { -case AF_INET : -if (unlikely (iph_len <sizeof (struct iphdr ))) +/* Both struct iphdr and struct ipv6hdr have the version field at the +* same offset so we can cast to the shorter header (struct iphdr). +*/ +switch (((struct iphdr *)iph)->version) { +case 4 : +if (sk->sk_family ==AF_INET6 &&ipv6_only_sock (sk))return -EINVAL ; ret =__cookie_v4_check ((struct iphdr *)iph, th, cookie);break ;#if IS_BUILTIN (CONFIG_IPV6 ) -case AF_INET6 : +case 6 :if (unlikely (iph_len <sizeof (struct ipv6hdr )))return -EINVAL ; +if (sk->sk_family !=AF_INET6 ) +return -EINVAL ; + ret =__cookie_v6_check ((struct ipv6hdr *)iph, th, cookie);break ;#endif /* CONFIG_IPV6 */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 250/343 drbd: Fix five use after free bugs in get_initial_state
In reply to Greg Kroah-HartmanFrom: Lv Yunlong <[email protected]>
[ Upstream commit aadb22ba2f656581b2f733deb3a467c48cc618f6 ]
In get_initial_state, it calls notify_initial_state_done(skb,..) if cb->args[5]==1. If genlmsg_put() failed in notify_initial_state_done(), the skb will be freed by nlmsg_free(skb).
Then get_initial_state will goto out and the freed skb will be used by return value skb->len, which is a uaf bug.
What's worse, the same problem goes even further: skb can also be freed in the notify_*_state_change -> notify_*_state calls below. Thus 4 additional uaf bugs happened.
My patch lets the problem callee functions: notify_initial_state_done and notify_*_state_change return an error code if errors happen. So that the error codes could be propagated and the uaf bugs can be avoid.
v2 reports a compilation warning. This v3 fixed this warning and built successfully in my local environment with no additional warnings.
v2: https://lore.kernel.org/patchwork/patch/1435218/
--- drivers/block/drbd/drbd_int.h | 8 ++--- drivers/block/drbd/drbd_nl.c | 41 ++++++++++++++++---------- drivers/block/drbd/drbd_state.c | 18 +++++------ drivers/block/drbd/drbd_state_change.h | 8 ++--- 4 files changed, 42 insertions(+), 33 deletions(-)
drivers/block/drbd/drbd_int.h +4 -4
@@ -1642,22 +1642,22 @@ struct sib_info { };void drbd_bcast_event (struct drbd_device *device,const struct sib_info *sib); -extern void notify_resource_state (struct sk_buff *, +extern int notify_resource_state (struct sk_buff *,unsigned int ,struct drbd_resource *,struct resource_info *,enum drbd_notification_type ); -extern void notify_device_state (struct sk_buff *, +extern int notify_device_state (struct sk_buff *,unsigned int ,struct drbd_device *,struct device_info *,enum drbd_notification_type ); -extern void notify_connection_state (struct sk_buff *, +extern int notify_connection_state (struct sk_buff *,unsigned int ,struct drbd_connection *,struct connection_info *,enum drbd_notification_type ); -extern void notify_peer_device_state(struct sk_buff *, +extern int notify_peer_device_state(struct sk_buff *, unsigned int, struct drbd_peer_device *, struct peer_device_info *,
drivers/block/drbd/drbd_nl.c +25 -16
156 lines not on this page · raw message
drivers/block/drbd/drbd_state.c +9 -9
@@ -1537,7 +1537,7 @@ int drbd_bitmap_io_from_worker(struct drbd_device *device,return rv; } -void notify_resource_state_change (struct sk_buff *skb, +int notify_resource_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_resource_state_change *resource_state_change,enum drbd_notification_type type)
@@ -1550,10 +1550,10 @@ void notify_resource_state_change(struct sk_buff *skb, .res_susp_fen = resource_state_change->susp_fen[NEW], }; -notify_resource_state (skb, seq, resource, &resource_info, type); +return notify_resource_state (skb, seq, resource, &resource_info, type); } -void notify_connection_state_change (struct sk_buff *skb, +int notify_connection_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_connection_state_change *connection_state_change,enum drbd_notification_type type)
@@ -1564,10 +1564,10 @@ void notify_connection_state_change(struct sk_buff *skb, .conn_role = connection_state_change->peer_role[NEW], }; -notify_connection_state (skb, seq, connection, &connection_info, type); +return notify_connection_state (skb, seq, connection, &connection_info, type); } -void notify_device_state_change (struct sk_buff *skb, +int notify_device_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_device_state_change *device_state_change,enum drbd_notification_type type)
@@ -1577,10 +1577,10 @@ void notify_device_state_change(struct sk_buff *skb, .dev_disk_state = device_state_change->disk_state[NEW], }; -notify_device_state (skb, seq, device, &device_info, type); +return notify_device_state (skb, seq, device, &device_info, type); } -void notify_peer_device_state_change (struct sk_buff *skb, +int notify_peer_device_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_peer_device_state_change *p,enum drbd_notification_type type)
@@ -1594,7 +1594,7 @@ void notify_peer_device_state_change(struct sk_buff *skb, .peer_resync_susp_dependency = p->resync_susp_dependency[NEW], }; -notify_peer_device_state (skb, seq, peer_device, &peer_device_info, type); +return notify_peer_device_state (skb, seq, peer_device, &peer_device_info, type); }static void broadcast_state_change (struct drbd_state_change *state_change)
@@ -1602,7 +1602,7 @@ static void broadcast_state_change(struct drbd_state_change *state_change)struct drbd_resource_state_change *resource_state_change = &state_change->resource[0 ];bool resource_state_has_changed;unsigned int n_device, n_connection, n_peer_device, n_peer_devices; -void (*last_func)(struct sk_buff *,unsigned int ,void *, +int (*last_func)(struct sk_buff *,unsigned int ,void *,enum drbd_notification_type ) =NULL ;void *last_arg =NULL ;
drivers/block/drbd/drbd_state_change.h +4 -4
@@ -44,19 +44,19 @@ extern struct drbd_state_change *remember_old_state(struct drbd_resource *, gfp_extern void copy_old_to_new_state_change (struct drbd_state_change *);extern void forget_state_change (struct drbd_state_change *); -extern void notify_resource_state_change (struct sk_buff *, +extern int notify_resource_state_change (struct sk_buff *,unsigned int ,struct drbd_resource_state_change *,enum drbd_notification_type type); -extern void notify_connection_state_change (struct sk_buff *, +extern int notify_connection_state_change (struct sk_buff *,unsigned int ,struct drbd_connection_state_change *,enum drbd_notification_type type); -extern void notify_device_state_change (struct sk_buff *, +extern int notify_device_state_change (struct sk_buff *,unsigned int ,struct drbd_device_state_change *,enum drbd_notification_type type); -extern void notify_peer_device_state_change (struct sk_buff *, +extern int notify_peer_device_state_change (struct sk_buff *,unsigned int ,struct drbd_peer_device_state_change *,enum drbd_notification_type type);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 251/343 scsi: sd: sd_read_cpr() requires VPD pages
In reply to Greg Kroah-HartmanFrom: Martin K. Petersen <[email protected]>
[ Upstream commit 1700714b1ff252b634db21186db4d91e7e006043 ]
As such it should be called inside the scsi_device_supports_vpd() conditional.
--- drivers/scsi/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sd.c +1 -1
@@ -3320,6 +3320,7 @@ static int sd_revalidate_disk(struct gendisk *disk)sd_read_block_limits (sdkp);sd_read_block_characteristics (sdkp);sd_zbc_read_zones (sdkp, buffer); +sd_read_cpr (sdkp); }sd_print_capacity (sdkp, old_capacity);
@@ -3329,7 +3330,6 @@ static int sd_revalidate_disk(struct gendisk *disk)sd_read_app_tag_own (sdkp, buffer);sd_read_write_same (sdkp, buffer);sd_read_security (sdkp, buffer); -sd_read_cpr (sdkp); }/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 252/343 scsi: ufs: ufshpb: Fix a NULL check on list iterator
In reply to Greg Kroah-HartmanFrom: Xiaomeng Tong <[email protected]>
[ Upstream commit bfb7789bcbd901caead43861461bc8f334c90d3b ]
The list iterator is always non-NULL so the check 'if (!rgn)' is always false and the dev_err() is never called. Move the check outside the loop and determine if 'victim_rgn' is NULL, to fix this bug.
--- drivers/scsi/ufs/ufshpb.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/scsi/ufs/ufshpb.c +5 -6
@@ -869,12 +869,6 @@ static struct ufshpb_region *ufshpb_victim_lru_info(struct ufshpb_lu *hpb)struct ufshpb_region *rgn, *victim_rgn =NULL ;list_for_each_entry (rgn, &lru_info->lh_lru_rgn, list_lru_rgn) { -if (!rgn) { -dev_err (&hpb->sdev_ufs_lu->sdev_dev, -"%s: no region allocated\n" , - __func__); -return NULL ; - }if (ufshpb_check_srgns_issue_state (hpb, rgn))continue ;
@@ -890,6 +884,11 @@ static struct ufshpb_region *ufshpb_victim_lru_info(struct ufshpb_lu *hpb)break ; } +if (!victim_rgn) +dev_err (&hpb->sdev_ufs_lu->sdev_dev, +"%s: no region allocated\n" , + __func__); +return victim_rgn; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 253/343 io_uring: nospec index for tags on files update
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
[ Upstream commit 34bb77184123ae401100a4d156584f12fa630e5c ]
Don't forget to array_index_nospec() for indexes before updating rsrc tags in __io_sqe_files_update(), just use already safe and precalculated index @i.
--- fs/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/io_uring.c +1 -1
@@ -8700,7 +8700,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx, err = -EBADF ;break ; } - *io_get_tag_slot (data, up->offset + done) = tag; + *io_get_tag_slot (data, i) = tag;io_fixed_file_set (file_slot, file); err =io_sqe_file_register (ctx, file, i);if (err) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 254/343 io_uring: dont touch scm_fp_list after queueing skb
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
[ Upstream commit a07211e3001435fe8591b992464cd8d5e3c98c5a ]
It's safer to not touch scm_fp_list after we queued an skb to which it was assigned, there might be races lurking if we screw subtle sync guarantees on the io_uring side.
--- fs/io_uring.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/io_uring.c +6 -2
@@ -8237,8 +8237,12 @@ static int __io_sqe_files_scm(struct io_ring_ctx *ctx, int nr, int offset)refcount_add (skb->truesize, &sk->sk_wmem_alloc);skb_queue_head (&sk->sk_receive_queue, skb); -for (i =0 ; i < nr_files; i++) -fput (fpl->fp[i]); +for (i =0 ; i < nr; i++) { +struct file *file =io_file_from_index (ctx, i + offset); + +if (file) +fput (file); + } }else {kfree_skb (skb);free_uid (fpl->user);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 255/343 SUNRPC: Handle ENOMEM in call_transmit_status()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit d3c15033b240767d0287f1c4a529cbbe2d5ded8a ]
Both call_transmit() and call_bc_transmit() can now return ENOMEM, so let's make sure that we handle the errors gracefully.
--- net/sunrpc/clnt.c | 2 ++ 1 file changed, 2 insertions(+)
net/sunrpc/clnt.c +2 -0
@@ -2197,6 +2197,7 @@ call_transmit_status(struct rpc_task *task)* socket just returned a connection error, * then hold onto the transport lock. */ +case -ENOMEM :case -ENOBUFS :rpc_delay (task,HZ >>2 ); fallthrough;
@@ -2280,6 +2281,7 @@ call_bc_transmit_status(struct rpc_task *task)case -ENOTCONN :case -EPIPE :break ; +case -ENOMEM :case -ENOBUFS :rpc_delay (task,HZ >>2 ); fallthrough;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 256/343 SUNRPC: Handle low memory situations in call_status()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 9d82819d5b065348ce623f196bf601028e22ed00 ]
We need to handle ENFILE, ENOBUFS, and ENOMEM, because xprt_wake_pending_tasks() can be called with any one of these due to socket creation failures.
--- net/sunrpc/clnt.c | 5 +++++ 1 file changed, 5 insertions(+)
net/sunrpc/clnt.c +5 -0
@@ -2364,6 +2364,11 @@ call_status(struct rpc_task *task)case -EPIPE :case -EAGAIN :break ; +case -ENFILE : +case -ENOBUFS : +case -ENOMEM : +rpc_delay (task,HZ >>2 ); +break ;case -EIO :/* shutdown or soft timeout */ goto out_exit;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 257/343 SUNRPC: svc_tcp_sendmsg() should handle errors from xdr_alloc_bvec()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit b056fa070814897be32d83b079dbc311375588e7 ]
The allocation is done with GFP_KERNEL, but it could still fail in a low memory situation.
--- net/sunrpc/svcsock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/sunrpc/svcsock.c +3 -1
@@ -1096,7 +1096,9 @@ static int svc_tcp_sendmsg(struct socket *sock, struct xdr_buf *xdr,int ret; *sentp =0 ; -xdr_alloc_bvec (xdr,GFP_KERNEL ); + ret =xdr_alloc_bvec (xdr,GFP_KERNEL ); +if (ret <0 ) +return ret; ret =kernel_sendmsg (sock, &msg, &rm,1 , rm.iov_len);if (ret <0 )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 258/343 iommu/omap: Fix regression in probe for NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit 71ff461c3f41f6465434b9e980c01782763e7ad8 ]
Commit 3f6634d997db ("iommu: Use right way to retrieve iommu_ops") started triggering a NULL pointer dereference for some omap variants:
__iommu_probe_device from probe_iommu_group+0x2c/0x38 probe_iommu_group from bus_for_each_dev+0x74/0xbc bus_for_each_dev from bus_iommu_probe+0x34/0x2e8 bus_iommu_probe from bus_set_iommu+0x80/0xc8 bus_set_iommu from omap_iommu_init+0x88/0xcc omap_iommu_init from do_one_initcall+0x44/0x24
This is caused by omap iommu probe returning 0 instead of ERR_PTR(-ENODEV) as noted by Jason Gunthorpe <[email protected]>.
Looks like the regression already happened with an earlier commit 6785eb9105e3 ("iommu/omap: Convert to probe/release_device() call-backs") that changed the function return type and missed converting one place.
--- drivers/iommu/omap-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/omap-iommu.c +1 -1
@@ -1661,7 +1661,7 @@ static struct iommu_device *omap_iommu_probe_device(struct device *dev) num_iommus =of_property_count_elems_of_size (dev->of_node,"iommus" ,sizeof (phandle));if (num_iommus <0 ) -return 0 ; +return ERR_PTR (-ENODEV ); arch_data =kcalloc (num_iommus +1 ,sizeof (*arch_data),GFP_KERNEL );if (!arch_data)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 259/343 perf unwind: Dont show unwind error messages when augmenting frame pointer stack
In reply to Greg Kroah-HartmanFrom: James Clark <[email protected]>
[ Upstream commit fa7095c5c3240bb2ecbc77f8b69be9b1d9e2cf60 ]
Commit Fixes: b9f6fbb3b2c29736 ("perf arm64: Inject missing frames when using 'perf record --call-graph=fp'") intended to add a 'best effort' DWARF unwind that improved the frame pointer stack in most scenarios.
It's expected that the unwind will fail sometimes, but this shouldn't be reported as an error. It only works when the return address can be determined from the contents of the link register alone.
Fix the error shown when the unwinder requires extra registers by adding a new flag that suppresses error messages. This flag is not set in the normal --call-graph=dwarf unwind mode so that behavior is not changed.
--- tools/perf/tests/dwarf-unwind.c | 2 +- .../perf/util/arm64-frame-pointer-unwind-support.c | 2 +- tools/perf/util/machine.c | 2 +- tools/perf/util/unwind-libdw.c | 10 +++++++--- tools/perf/util/unwind-libdw.h | 1 + tools/perf/util/unwind-libunwind-local.c | 10 +++++++--- tools/perf/util/unwind-libunwind.c | 6 ++++-- tools/perf/util/unwind.h | 13 ++++++++++--- 8 files changed, 32 insertions(+), 14 deletions(-)
tools/perf/tests/dwarf-unwind.c +1 -1
@@ -122,7 +122,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__thread(struct thread *thr } err =unwind__get_entries (unwind_entry, &cnt, thread, - &sample,MAX_STACK ); + &sample,MAX_STACK , false);if (err)pr_debug ("unwind failed\n" );else if (cnt !=MAX_STACK ) {
tools/perf/util/arm64-frame-pointer-unwind-support.c +1 -1
@@ -53,7 +53,7 @@ u64 get_leaf_frame_caller_aarch64(struct perf_sample *sample, struct thread *thr sample->user_regs.cache_regs[PERF_REG_ARM64_SP ] =0 ; } - ret =unwind__get_entries (add_entry, &entries, thread, sample,2 ); + ret =unwind__get_entries (add_entry, &entries, thread, sample,2 , true); sample->user_regs = old_regs;if (ret || entries.length !=2 )
tools/perf/util/machine.c +1 -1
@@ -2983,7 +2983,7 @@ static int thread__resolve_callchain_unwind(struct thread *thread,return 0 ;return unwind__get_entries (unwind_entry, cursor, - thread, sample, max_stack); + thread, sample, max_stack, false); } int thread__resolve_callchain(struct thread *thread,
tools/perf/util/unwind-libdw.c +7 -3
@@ -200,7 +200,8 @@ frame_callback(Dwfl_Frame *state, void *arg)bool isactivation;if (!dwfl_frame_pc (state, &pc,NULL )) { -pr_err ("%s" ,dwfl_errmsg (-1 )); +if (!ui->best_effort) +pr_err ("%s" ,dwfl_errmsg (-1 ));return DWARF_CB_ABORT ; }
@@ -208,7 +209,8 @@ frame_callback(Dwfl_Frame *state, void *arg)report_module (pc, ui);if (!dwfl_frame_pc (state, &pc, &isactivation)) { -pr_err ("%s" ,dwfl_errmsg (-1 )); +if (!ui->best_effort) +pr_err ("%s" ,dwfl_errmsg (-1 ));return DWARF_CB_ABORT ; }
@@ -222,7 +224,8 @@ frame_callback(Dwfl_Frame *state, void *arg)int unwind__get_entries (unwind_entry_cb_t cb,void *arg,struct thread *thread,struct perf_sample *data, -int max_stack) +int max_stack, +bool best_effort) {struct unwind_info *ui, ui_buf = { .sample = data,
@@ -231,6 +234,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg, .cb = cb, .arg = arg, .max_stack = max_stack, + .best_effort = best_effort };Dwarf_Word ip;int err = -EINVAL , i;
tools/perf/util/unwind-libdw.h +1 -0
@@ -20,6 +20,7 @@ struct unwind_info {void *arg;int max_stack;int idx; +bool best_effort;struct unwind_entry entries[]; };
tools/perf/util/unwind-libunwind-local.c +7 -3
@@ -96,6 +96,7 @@ struct unwind_info {struct perf_sample *sample;struct machine *machine;struct thread *thread; +bool best_effort; };#define dw_read (ptr, type, end) ({ \
@@ -553,7 +554,8 @@ static int access_reg(unw_addr_space_t __maybe_unused as, ret =perf_reg_value (&val, &ui->sample->user_regs, id);if (ret) { -pr_err ("unwind: can't read reg %d\n" , regnum); +if (!ui->best_effort) +pr_err ("unwind: can't read reg %d\n" , regnum);return ret; }
@@ -666,7 +668,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,return -1 ; ret =unw_init_remote (&c, addr_space, ui); -if (ret) +if (ret && !ui->best_effort)display_error (ret);while (!ret && (unw_step (&c) >0 ) && i < max_stack) {
@@ -704,12 +706,14 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,static int _unwind__get_entries (unwind_entry_cb_t cb,void *arg,struct thread *thread, -struct perf_sample *data,int max_stack) +struct perf_sample *data,int max_stack, +bool best_effort) {struct unwind_info ui = { .sample = data, .thread = thread, .machine = thread->maps->machine, + .best_effort = best_effort };if (!data->user_regs.regs)
tools/perf/util/unwind-libunwind.c +4 -2
@@ -80,9 +80,11 @@ void unwind__finish_access(struct maps *maps)int unwind__get_entries (unwind_entry_cb_t cb,void *arg,struct thread *thread, -struct perf_sample *data,int max_stack) +struct perf_sample *data,int max_stack, +bool best_effort) {if (thread->maps->unwind_libunwind_ops) -return thread->maps->unwind_libunwind_ops->get_entries (cb, arg, thread, data, max_stack); +return thread->maps->unwind_libunwind_ops->get_entries (cb, arg, thread, data, + max_stack, best_effort);return 0 ; }
tools/perf/util/unwind.h +10 -3
@@ -23,13 +23,19 @@ struct unwind_libunwind_ops {void (*finish_access)(struct maps *maps);int (*get_entries)(unwind_entry_cb_t cb,void *arg,struct thread *thread, -struct perf_sample *data,int max_stack); +struct perf_sample *data,int max_stack,bool best_effort); };#ifdef HAVE_DWARF_UNWIND_SUPPORT +/* +* When best_effort is set, don't report errors and fail silently. This could +* be expanded in the future to be more permissive about things other than +* error messages. +*/ int unwind__get_entries (unwind_entry_cb_t cb,void *arg,struct thread *thread, -struct perf_sample *data,int max_stack); +struct perf_sample *data,int max_stack, +bool best_effort);/* libunwind specific */ #ifdef HAVE_LIBUNWIND_SUPPORT #ifndef LIBUNWIND__ARCH_REG_ID
@@ -65,7 +71,8 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,void *arg__maybe_unused , struct thread *thread __maybe_unused, struct perf_sample *data __maybe_unused, - int max_stack __maybe_unused) + int max_stack __maybe_unused, + bool best_effort __maybe_unused) { return 0; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 260/343 perf: arm-spe: Fix perf report --mem-mode
In reply to Greg Kroah-HartmanFrom: James Clark <[email protected]>
[ Upstream commit ffab487052054162b3b6c9c6005777ec6cfcea05 ]
Since commit bb30acae4c4dacfa ("perf report: Bail out --mem-mode if mem info is not available") "perf mem report" and "perf report --mem-mode" don't allow opening the file unless one of the events has PERF_SAMPLE_DATA_SRC set.
SPE doesn't have this set even though synthetic memory data is generated after it is decoded. Fix this issue by setting DATA_SRC on SPE events. This has no effect on the data collected because the SPE driver doesn't do anything with that flag and doesn't generate samples.
--- tools/perf/arch/arm64/util/arm-spe.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/perf/arch/arm64/util/arm-spe.c +6 -0
@@ -239,6 +239,12 @@ static int arm_spe_recording_options(struct auxtrace_record *itr,arm_spe_set_timestamp (itr, arm_spe_evsel); } +/* +* Set this only so that perf report knows that SPE generates memory info. It has no effect +* on the opening of the event or the SPE data produced. +*/ +evsel__set_sample_bit (arm_spe_evsel,DATA_SRC ); +/* Add dummy event to keep tracking */ err =parse_events (evlist,"dummy:u" ,NULL );if (err)
Signature · 9 lines
2.35.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg Kroah-Hartman
maintainerPATCH 261/343 perf tools: Fix perfs libperf_print callback
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit aeee9dc53ce405d2161f9915f553114e94e5b677 ]
eprintf() does not expect va_list as the type of the 4th parameter.
Use veprintf() because it does.
--- tools/perf/perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/perf.c +1 -1
@@ -434,7 +434,7 @@ void pthread__unblock_sigwinch(void)static int libperf_print (enum libperf_print_level level,const char *fmt,va_list ap) { -return eprintf (level, verbose, fmt, ap); +return veprintf (level, verbose, fmt, ap); }int main (int argc,const char **argv)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 262/343 perf session: Remap buf if there is no space for event
In reply to Greg Kroah-HartmanFrom: Denis Nikitin <[email protected]>
[ Upstream commit bc21e74d4775f883ae1f542c1f1dc7205b15d925 ]
If a perf event doesn't fit into remaining buffer space return NULL to remap buf and fetch the event again.
Keep the logic to error out on inadequate input from fuzzing.
This fixes perf failing on ChromeOS (with 32b userspace):
$ perf report -v -i perf.data ... prefetch_event: head=0x1fffff8 event->header_size=0x30, mmap_size=0x2000000: fuzzed or compressed perf.data? Error: failed to process sample
--- tools/perf/util/session.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
tools/perf/util/session.c +12 -3
@@ -2084,6 +2084,7 @@ prefetch_event(char *buf, u64 head, size_t mmap_size, bool needs_swap, union perf_event *error) { union perf_event *event; +u16 event_size;/* * Ensure we have enough space remaining to read
@@ -2096,15 +2097,23 @@ prefetch_event(char *buf, u64 head, size_t mmap_size,if (needs_swap)perf_event_header__bswap (&event->header); -if (head + event->header.size <= mmap_size) + event_size = event->header.size; +if (head + event_size <= mmap_size)return event;/* We're not fetching the event so swap back again */ if (needs_swap)perf_event_header__bswap (&event->header); -pr_debug ("%s: head=%#" PRIx64" event->header_size=%#x, mmap_size=%#zx:" -" fuzzed or compressed perf.data?\n" ,__func__, head, event->header.size, mmap_size); +/* Check if the event fits into the next mmapped buf. */ +if (event_size <= mmap_size - head % page_size) { +/* Remap buf and fetch again. */ +return NULL ; + } + +/* Invalid input. Event size should never exceed mmap_size. */ +pr_debug ("%s: head=%#" PRIx64" event->header.size=%#x, mmap_size=%#zx:" +" fuzzed or compressed perf.data?\n" , __func__, head, event_size, mmap_size);return error; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 263/343 arm64: Add part number for Arm Cortex-A78AE
In reply to Greg Kroah-HartmanFrom: Chanho Park <[email protected]>
commit 83bea32ac7ed37bbda58733de61fc9369513f9f9 upstream.
Add the MIDR part number info for the Arm Cortex-A78AE[1] and add it to spectre-BHB affected list[2].
[1]: https://developer.arm.com/Processors/Cortex-A78AE
[2]: https://developer.arm.com/Arm%20Security%20Center/Spectre-BHB
--- arch/arm64/include/asm/cputype.h | 2 ++ arch/arm64/kernel/proton-pack.c | 1 + 2 files changed, 3 insertions(+)
arch/arm64/include/asm/cputype.h +2 -0
@@ -75,6 +75,7 @@#define ARM_CPU_PART_CORTEX_A77 0xD0D#define ARM_CPU_PART_NEOVERSE_V1 0xD40#define ARM_CPU_PART_CORTEX_A78 0xD41 +#define ARM_CPU_PART_CORTEX_A78AE 0xD42#define ARM_CPU_PART_CORTEX_X1 0xD44#define ARM_CPU_PART_CORTEX_A510 0xD46#define ARM_CPU_PART_CORTEX_A710 0xD47
@@ -123,6 +124,7 @@#define MIDR_CORTEX_A77 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A77)#define MIDR_NEOVERSE_V1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_V1)#define MIDR_CORTEX_A78 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78) +#define MIDR_CORTEX_A78AE MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78AE)#define MIDR_CORTEX_X1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X1)#define MIDR_CORTEX_A510 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A510)#define MIDR_CORTEX_A710 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A710)
arch/arm64/kernel/proton-pack.c +1 -0
@@ -853,6 +853,7 @@ u8 spectre_bhb_loop_affected(int scope)if (scope ==SCOPE_LOCAL_CPU ) {static const struct midr_range spectre_bhb_k32_list[] = {MIDR_ALL_VERSIONS (MIDR_CORTEX_A78 ), +MIDR_ALL_VERSIONS (MIDR_CORTEX_A78AE ),MIDR_ALL_VERSIONS (MIDR_CORTEX_A78C ),MIDR_ALL_VERSIONS (MIDR_CORTEX_X1 ),MIDR_ALL_VERSIONS (MIDR_CORTEX_A710 ),
Greg Kroah-Hartman
maintainerPATCH 264/343 scsi: mpt3sas: Fix use after free in _scsih_expander_node_remove()
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
commit 87d663d40801dffc99a5ad3b0188ad3e2b4d1557 upstream.
The function mpt3sas_transport_port_remove() called in _scsih_expander_node_remove() frees the port field of the sas_expander structure, leading to the following use-after-free splat from KASAN when the ioc_info() call following that function is executed (e.g. when doing rmmod of the driver module):
[ 3479.371167] ================================================================== [ 3479.378496] BUG: KASAN: use-after-free in _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.386936] Read of size 1 at addr ffff8881c037691c by task rmmod/1531 [ 3479.393524] [ 3479.395035] CPU: 18 PID: 1531 Comm: rmmod Not tainted 5.17.0-rc8+ #1436 [ 3479.401712] Hardware name: Supermicro Super Server/H12SSL-NT, BIOS 2.1 06/02/2021 [ 3479.409263] Call Trace: [ 3479.411743] <TASK> [ 3479.413875] dump_stack_lvl+0x45/0x59 [ 3479.417582] print_address_description.constprop.0+0x1f/0x120 [ 3479.423389] ? _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.429469] kasan_report.cold+0x83/0xdf [ 3479.433438] ? _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.439514] _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.445411] ? _raw_spin_unlock_irqrestore+0x2d/0x40 [ 3479.452032] scsih_remove+0x525/0xc90 [mpt3sas] [ 3479.458212] ? mpt3sas_expander_remove+0x1d0/0x1d0 [mpt3sas] [ 3479.465529] ? down_write+0xde/0x150 [ 3479.470746] ? up_write+0x14d/0x460 [ 3479.475840] ? kernfs_find_ns+0x137/0x310 [ 3479.481438] pci_device_remove+0x65/0x110 [ 3479.487013] __device_release_driver+0x316/0x680 [ 3479.493180] driver_detach+0x1ec/0x2d0 [ 3479.498499] bus_remove_driver+0xe7/0x2d0 [ 3479.504081] pci_unregister_driver+0x26/0x250 [ 3479.510033] _mpt3sas_exit+0x2b/0x6cf [mpt3sas] [ 3479.516144] __x64_sys_delete_module+0x2fd/0x510 [ 3479.522315] ? free_module+0xaa0/0xaa0 [ 3479.527593] ? __cond_resched+0x1c/0x90 [ 3479.532951] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 3479.539607] ? syscall_enter_from_user_mode+0x21/0x70 [ 3479.546161] ? trace_hardirqs_on+0x1c/0x110 [ 3479.551828] do_syscall_64+0x35/0x80 [ 3479.556884] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 3479.563402] RIP: 0033:0x7f1fc482483b ... [ 3479.943087] ==================================================================
Fix this by introducing the local variable port_id to store the port ID value before executing mpt3sas_transport_port_remove(). This local variable is then used in the call to ioc_info() instead of dereferencing the freed port structure.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +4 -1
@@ -11035,6 +11035,7 @@ _scsih_expander_node_remove(struct MPT3S {struct _sas_port *mpt3sas_port, *next;unsigned long flags; +int port_id;/* remove sibling ports attached to this expander */ list_for_each_entry_safe(mpt3sas_port, next,
@@ -11055,6 +11056,8 @@ _scsih_expander_node_remove(struct MPT3S mpt3sas_port->hba_port); } + port_id = sas_expander->port->port_id; +mpt3sas_transport_port_remove (ioc, sas_expander->sas_address, sas_expander->sas_address_parent, sas_expander->port);
@@ -11062,7 +11065,7 @@ _scsih_expander_node_remove(struct MPT3S"expander_remove: handle(0x%04x), sas_addr(0x%016llx), port:%d\n" , sas_expander->handle, (unsigned long long ) sas_expander->sas_address, - sas_expander->port->port_id); + port_id);spin_lock_irqsave (&ioc->sas_node_lock, flags);list_del (&sas_expander->list);
Greg Kroah-Hartman
maintainerPATCH 265/343 scsi: ufs: ufs-pci: Add support for Intel MTL
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit 4049f7acef3eb37c1ea0df45f3ffc29404f4e708 upstream.
Add PCI ID and callbacks to support Intel Meteor Lake (MTL).
--- drivers/scsi/ufs/ufshcd-pci.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/scsi/ufs/ufshcd-pci.c +17 -0
@@ -428,6 +428,12 @@ static int ufs_intel_adl_init(struct ufsreturn ufs_intel_common_init (hba); } +static int ufs_intel_mtl_init (struct ufs_hba *hba) +{ + hba->caps |=UFSHCD_CAP_CRYPTO |UFSHCD_CAP_WB_EN ; +return ufs_intel_common_init (hba); +} +static struct ufs_hba_variant_ops ufs_intel_cnl_hba_vops = { .name ="intel-pci" , .init = ufs_intel_common_init,
@@ -465,6 +471,16 @@ static struct ufs_hba_variant_ops ufs_in .device_reset = ufs_intel_device_reset, }; +static struct ufs_hba_variant_ops ufs_intel_mtl_hba_vops = { + .name ="intel-pci" , + .init = ufs_intel_mtl_init, + .exit = ufs_intel_common_exit, + .hce_enable_notify = ufs_intel_hce_enable_notify, + .link_startup_notify = ufs_intel_link_startup_notify, + .resume = ufs_intel_resume, + .device_reset = ufs_intel_device_reset, +}; +#ifdef CONFIG_PM_SLEEP static int ufshcd_pci_restore (struct device *dev) {
@@ -579,6 +595,7 @@ static const struct pci_device_id ufshcd { PCI_VDEVICE(INTEL, 0x98FA), (kernel_ulong_t)&ufs_intel_lkf_hba_vops }, { PCI_VDEVICE(INTEL, 0x51FF), (kernel_ulong_t)&ufs_intel_adl_hba_vops }, { PCI_VDEVICE(INTEL, 0x54FF), (kernel_ulong_t)&ufs_intel_adl_hba_vops }, + { PCI_VDEVICE(INTEL, 0x7E47), (kernel_ulong_t)&ufs_intel_mtl_hba_vops }, { } /* terminate list */ };
Greg Kroah-Hartman
maintainerPATCH 266/343 Revert "mmc: sdhci-xenon: fix annoying 1.8V regulator warning"
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 7e2646ed47542123168d43916b84b954532e5386 upstream.
This reverts commit bb32e1987bc55ce1db400faf47d85891da3c9b9f.
Commit 1a3ed0dc3594 ("mmc: sdhci-xenon: fix 1.8v regulator stabilization") contains proper fix for the issue described in commit bb32e1987bc5 ("mmc:
sdhci-xenon: fix annoying 1.8V regulator warning").
--- drivers/mmc/host/sdhci-xenon.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/mmc/host/sdhci-xenon.c +0 -10
@@ -241,16 +241,6 @@ static void xenon_voltage_switch(struct {/* Wait for 5ms after set 1.8V signal enable bit */ usleep_range (5000 ,5500 ); - -/* -* For some reason the controller's Host Control2 register reports -* the bit representing 1.8V signaling as 0 when read after it was -* written as 1. Subsequent read reports 1. -* -* Since this may cause some issues, do an empty read of the Host -* Control2 register here to circumvent this. -*/ -sdhci_readw (host,SDHCI_HOST_CONTROL2 ); }static unsigned int xenon_get_max_clock (struct sdhci_host *host)
Greg Kroah-Hartman
maintainerPATCH 267/343 mmc: block: Check for errors after write on SPI
In reply to Greg Kroah-HartmanFrom: Christian Löhle <[email protected]>
commit 5d435933376962b107bd76970912e7e80247dcc7 upstream.
Introduce a SEND_STATUS check for writes through SPI to not mark an unsuccessful write as successful.
Since SPI SD/MMC does not have states, after a write, the card will just hold the line LOW until it is ready again. The driver marks the write therefore as completed as soon as it reads something other than all zeroes.
The driver does not distinguish from a card no longer signalling busy and it being disconnected (and the line being pulled-up by the host). This lead to writes being marked as successful when disconnecting a busy card.
Now the card is ensured to be still connected by an additional CMD13, just like non-SPI is ensured to go back to TRAN state.
While at it and since we already poll for the post-write status anyway, we might as well check for SPIs error bits (any of them).
The disconnecting card problem is reproducable for me after continuous write activity and randomly disconnecting, around every 20-50 tries on SPI DS for some card.
--- drivers/mmc/core/block.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/mmc/core/block.c +33 -1
@@ -1880,6 +1880,31 @@ static inline bool mmc_blk_rq_error(stru brq->data.error || brq->cmd.resp[0 ] &CMD_ERRORS ; } +static int mmc_spi_err_check (struct mmc_card *card) +{ +u32 status =0 ; +int err; + +/* +* SPI does not have a TRAN state we have to wait on, instead the +* card is ready again when it no longer holds the line LOW. +* We still have to ensure two things here before we know the write +* was successful: +* 1. The card has not disconnected during busy and we actually read our +* own pull-up, thinking it was still connected, so ensure it +* still responds. +* 2. Check for any error bits, in particular R1_SPI_IDLE to catch a +* just reconnected card after being disconnected during busy. +*/ + err =__mmc_send_status (card, &status,0 ); +if (err) +return err; +/* All R1 and R2 bits of SPI are errors in our case */ +if (status) +return -EIO ; +return 0 ; +} +static int mmc_blk_busy_cb (void *cb_data,bool *busy) {struct mmc_blk_busy_data *data = cb_data;
@@ -1903,9 +1928,16 @@ static int mmc_blk_card_busy(struct mmc_struct mmc_blk_busy_data cb_data;int err; -if (mmc_host_is_spi (card->host) ||rq_data_dir (req) ==READ ) +if (rq_data_dir (req) ==READ )return 0 ; +if (mmc_host_is_spi (card->host)) { + err =mmc_spi_err_check (card); +if (err) + mqrq->brq.data.bytes_xfered =0 ; +return err; + } + cb_data.card = card; cb_data.status =0 ; err = __mmc_poll_for_busy(card->host, 0, MMC_BLK_TIMEOUT_MS,
Greg Kroah-Hartman
maintainerPATCH 268/343 mmc: mmci: stm32: correctly check all elements of sg list
In reply to Greg Kroah-HartmanFrom: Yann Gautier <[email protected]>
commit 0d319dd5a27183b75d984e3dc495248e59f99334 upstream.
Use sg and not data->sg when checking sg list elements. Else only the first element alignment is checked.
The last element should be checked the same way, for_each_sg already set sg to sg_next(sg).
--- drivers/mmc/host/mmci_stm32_sdmmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/mmci_stm32_sdmmc.c +3 -3
@@ -62,8 +62,8 @@ static int sdmmc_idma_validate_data(stru* excepted the last element which has no constraint on idmasize */ for_each_sg (data->sg, sg, data->sg_len -1 , i) { -if (!IS_ALIGNED (data->sg->offset,sizeof (u32)) || - !IS_ALIGNED (data->sg->length,SDMMC_IDMA_BURST )) { +if (!IS_ALIGNED (sg->offset,sizeof (u32)) || + !IS_ALIGNED (sg->length,SDMMC_IDMA_BURST )) {dev_err (mmc_dev (host->mmc),"unaligned scatterlist: ofst:%x length:%d\n" , data->sg->offset, data->sg->length);
@@ -71,7 +71,7 @@ static int sdmmc_idma_validate_data(stru } } -if (!IS_ALIGNED (data->sg->offset,sizeof (u32))) { +if (!IS_ALIGNED (sg->offset,sizeof (u32))) {dev_err (mmc_dev (host->mmc),"unaligned last scatterlist: ofst:%x length:%d\n" , data->sg->offset, data->sg->length);
Greg Kroah-Hartman
maintainerPATCH 269/343 mmc: renesas_sdhi: special 4tap settings only apply to HS400
In reply to Greg Kroah-HartmanFrom: Wolfram Sang <[email protected]>
commit 46d4820f949a3030b19ee482c68a50b06dd27590 upstream.
Previous documentation was vague, so we included SDR104 for slow SDnH clock settings. It turns out now, that it is only needed for HS400.
--- drivers/mmc/host/renesas_sdhi_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/renesas_sdhi_core.c +2 -2
@@ -144,9 +144,9 @@ static unsigned int renesas_sdhi_clk_updreturn clk_get_rate (priv->clk);if (priv->clkh) { +/* HS400 with 4TAP needs different clock settings */ bool use_4tap = priv->quirks && priv->quirks->hs400_4taps; -bool need_slow_clkh = (host->mmc->ios.timing ==MMC_TIMING_UHS_SDR104 ) || - (host->mmc->ios.timing ==MMC_TIMING_MMC_HS400 ); +bool need_slow_clkh = host->mmc->ios.timing ==MMC_TIMING_MMC_HS400 ; clkh_shift = use_4tap && need_slow_clkh ?1 :2 ; ref_clk = priv->clkh; }
Greg Kroah-Hartman
maintainerPATCH 270/343 mmc: renesas_sdhi: dont overwrite TAP settings when HS400 tuning is complete
In reply to Greg Kroah-HartmanFrom: Wolfram Sang <[email protected]>
commit 03e59b1e2f56245163b14c69e0a830c24b1a3a47 upstream.
When HS400 tuning is complete and HS400 is going to be activated, we have to keep the current number of TAPs and should not overwrite them with a hardcoded value. This was probably a copy&paste mistake when upporting HS400 support from the BSP.
--- drivers/mmc/host/renesas_sdhi_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/renesas_sdhi_core.c +2 -2
@@ -396,10 +396,10 @@ static void renesas_sdhi_hs400_complete( SH_MOBILE_SDHI_SCC_TMPPORT2_HS400OSEL) | sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_TMPPORT2)); -/* Set the sampling clock selection range of HS400 mode */ sd_scc_write32 (host, priv,SH_MOBILE_SDHI_SCC_DTCNTL ,SH_MOBILE_SDHI_SCC_DTCNTL_TAPEN | -0x4 <<SH_MOBILE_SDHI_SCC_DTCNTL_TAPNUM_SHIFT ); +sd_scc_read32 (host, priv, +SH_MOBILE_SDHI_SCC_DTCNTL ));/* Avoid bad TAP */ if (bad_taps &BIT (priv->tap_set)) {
Greg Kroah-Hartman
maintainerPATCH 271/343 mmc: core: Fixup support for writeback-cache for eMMC and SD
In reply to Greg Kroah-HartmanFrom: Michael Wu <[email protected]>
commit 08ebf903af57cda6d773f3dd1671b64f73b432b8 upstream.
During the card initialization process, the mmc core checks whether the eMMC/SD card supports an internal writeback-cache and then enables it inside the card.
Unfortunately, this isn't according to what the mmc core reports to the upper block layer. Instead, the writeback-cache support with REQ_FLUSH and REQ_FUA, are being enabled depending on whether the host supports the CMD23 (MMC_CAP_CMD23) and whether an eMMC supports the reliable-write command.
This is wrong and it may also sound awkward. In fact, it's a remnant from when both eMMC/SD cards didn't have dedicated commands/support to control the internal writeback-cache. In other words, it was the best we could do at that point in time.
To fix the problem, but also without breaking backwards compatibility, let's align the REQ_FLUSH support with whether the writeback-cache became successfully enabled - for both eMMC and SD cards.
Depends-on: 97fce126e279 ("mmc: block: Issue a cache flush only when it's enabled")
--- drivers/mmc/core/block.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mmc/core/block.c +9 -3
@@ -2382,6 +2382,8 @@ static struct mmc_blk_data *mmc_blk_allostruct mmc_blk_data *md;int devidx, ret;char cap_str[10 ]; +bool cache_enabled = false; +bool fua_enabled = false; devidx =ida_simple_get (&mmc_blk_ida,0 , max_devices,GFP_KERNEL );if (devidx <0 ) {
@@ -2461,13 +2463,17 @@ static struct mmc_blk_data *mmc_blk_allo md->flags |=MMC_BLK_CMD23 ; } -if (mmc_card_mmc (card) && - md->flags &MMC_BLK_CMD23 && +if (md->flags &MMC_BLK_CMD23 && ((card->ext_csd.rel_param &EXT_CSD_WR_REL_PARAM_EN ) || card->ext_csd.rel_sectors)) { md->flags |=MMC_BLK_REL_WR ; -blk_queue_write_cache (md->queue.queue, true, true); + fua_enabled = true; + cache_enabled = true; } +if (mmc_cache_enabled (card->host)) + cache_enabled = true; + +blk_queue_write_cache (md->queue.queue, cache_enabled, fua_enabled);string_get_size ((u64 )size,512 ,STRING_UNITS_2 , cap_str,sizeof (cap_str));
Greg Kroah-Hartman
maintainerPATCH 272/343 lz4: fix LZ4_decompress_safe_partial read out of bound
In reply to Greg Kroah-HartmanFrom: Guo Xuenan <[email protected]>
commit eafc0a02391b7b36617b36c97c4b5d6832cf5e24 upstream.
When partialDecoding, it is EOF if we've either filled the output buffer or can't proceed with reading an offset for following match.
In some extreme corner cases when compressed data is suitably corrupted, UAF will occur. As reported by KASAN [1], LZ4_decompress_safe_partial may lead to read out of bound problem during decoding. lz4 upstream has fixed it [2] and this issue has been disscussed here [3] before.
current decompression routine was ported from lz4 v1.8.3, bumping lib/lz4 to v1.9.+ is certainly a huge work to be done later, so, we'd better fix it first.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://github.com/lz4/lz4/commit/c5d6f8a8be3927c0bec91bcc58667a6cfad244ad#
[3] https://lore.kernel.org/all/[email protected]/
--- lib/lz4/lz4_decompress.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
lib/lz4/lz4_decompress.c +6 -2
@@ -271,8 +271,12 @@ static FORCE_INLINE int LZ4_decompress_g ip += length; op += length; -/* Necessarily EOF, due to parsing restrictions */ -if (!partialDecoding || (cpy == oend)) +/* Necessarily EOF when !partialDecoding. +* When partialDecoding, it is EOF if we've either +* filled the output buffer or +* can't proceed with reading an offset for following match. +*/ +if (!partialDecoding || (cpy == oend) || (ip >= (iend -2 )))break ; }else {/* may overwrite up to WILDCOPYLENGTH beyond cpy */
Greg Kroah-Hartman
maintainerPATCH 273/343 highmem: fix checks in __kmap_local_sched_{in,out}
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
commit 66f133ceab7456c789f70a242991ed1b27ba1c3d upstream.
When CONFIG_DEBUG_KMAP_LOCAL is enabled __kmap_local_sched_{in,out} check that even slots in the tsk->kmap_ctrl.pteval are unmapped. The slots are initialized with 0 value, but the check is done with pte_none. 0 pte however does not necessarily mean that pte_none will return true. e.g. on xtensa it returns false, resulting in the following runtime warnings:
WARNING: CPU: 0 PID: 101 at mm/highmem.c:627 __kmap_local_sched_out+0x51/0x108 CPU: 0 PID: 101 Comm: touch Not tainted 5.17.0-rc7-00010-gd3a1cdde80d2-dirty #13 Call Trace: dump_stack+0xc/0x40 __warn+0x8f/0x174 warn_slowpath_fmt+0x48/0xac __kmap_local_sched_out+0x51/0x108 __schedule+0x71a/0x9c4 preempt_schedule_irq+0xa0/0xe0 common_exception_return+0x5c/0x93 do_wp_page+0x30e/0x330 handle_mm_fault+0xa70/0xc3c do_page_fault+0x1d8/0x3c4 common_exception+0x7f/0x7f WARNING: CPU: 0 PID: 101 at mm/highmem.c:664 __kmap_local_sched_in+0x50/0xe0 CPU: 0 PID: 101 Comm: touch Tainted: G W 5.17.0-rc7-00010-gd3a1cdde80d2-dirty #13 Call Trace: dump_stack+0xc/0x40 __warn+0x8f/0x174 warn_slowpath_fmt+0x48/0xac __kmap_local_sched_in+0x50/0xe0 finish_task_switch$isra$0+0x1ce/0x2f8 __schedule+0x86e/0x9c4 preempt_schedule_irq+0xa0/0xe0 common_exception_return+0x5c/0x93 do_wp_page+0x30e/0x330 handle_mm_fault+0xa70/0xc3c do_page_fault+0x1d8/0x3c4 common_exception+0x7f/0x7f
Fix it by replacing !pte_none(pteval) with pte_val(pteval) != 0.
--- mm/highmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/highmem.c +2 -2
@@ -624,7 +624,7 @@ void __kmap_local_sched_out(void)/* With debug all even slots are unmapped and act as guard */ if (IS_ENABLED (CONFIG_DEBUG_KMAP_LOCAL ) && !(i &0x01 )) { -WARN_ON_ONCE (!pte_none (pteval)); +WARN_ON_ONCE (pte_val (pteval) !=0 );continue ; }if (WARN_ON_ONCE (pte_none (pteval)))
@@ -661,7 +661,7 @@ void __kmap_local_sched_in(void)/* With debug all even slots are unmapped and act as guard */ if (IS_ENABLED (CONFIG_DEBUG_KMAP_LOCAL ) && !(i &0x01 )) { -WARN_ON_ONCE (!pte_none (pteval)); +WARN_ON_ONCE (pte_val (pteval) !=0 );continue ; }if (WARN_ON_ONCE (pte_none (pteval)))
Greg Kroah-Hartman
maintainerPATCH 274/343 mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0)
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit 01e67e04c28170c47700c2c226d732bbfedb1ad0 upstream.
If an mremap() syscall with old_size=0 ends up in move_page_tables(), it will call invalidate_range_start()/invalidate_range_end() unnecessarily, i.e. with an empty range.
This causes a WARN in KVM's mmu_notifier. In the past, empty ranges have been diagnosed to be off-by-one bugs, hence the WARNing. Given the low (so far) number of unique reports, the benefits of detecting more buggy callers seem to outweigh the cost of having to fix cases such as this one, where userspace is doing something silly. In this particular case, an early return from move_page_tables() is enough to fix the issue.
--- mm/mremap.c | 3 +++ 1 file changed, 3 insertions(+)
mm/mremap.c +3 -0
@@ -486,6 +486,9 @@ unsigned long move_page_tables(struct vmpmd_t *old_pmd, *new_pmd;pud_t *old_pud, *new_pud; +if (!len) +return 0 ; + old_end = old_addr + len;flush_cache_range (vma, old_addr, old_end);
Greg Kroah-Hartman
maintainerPATCH 275/343 mm/mempolicy: fix mpol_new leak in shared_policy_replace
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
commit 4ad099559b00ac01c3726e5c95dc3108ef47d03e upstream.
If mpol_new is allocated but not used in restart loop, mpol_new will be freed via mpol_put before returning to the caller. But refcnt is not initialized yet, so mpol_put could not do the right things and might leak the unused mpol_new. This would happen if mempolicy was updated on the shared shmem file while the sp->lock has been dropped during the memory allocation.
This issue could be triggered easily with the below code snippet if there are many processes doing the below work at the same time:
shmid = shmget((key_t)5566, 1024 * PAGE_SIZE, 0666|IPC_CREAT);
shm = shmat(shmid, 0, 0);
loop many times {
mbind(shm, 1024 * PAGE_SIZE, MPOL_LOCAL, mask, maxnode, 0);
mbind(shm + 128 * PAGE_SIZE, 128 * PAGE_SIZE, MPOL_DEFAULT, mask,
maxnode, 0);
}--- mm/mempolicy.c | 1 + 1 file changed, 1 insertion(+)
mm/mempolicy.c +1 -0
@@ -2736,6 +2736,7 @@ alloc_new: mpol_new =kmem_cache_alloc (policy_cache,GFP_KERNEL );if (!mpol_new) goto err_out; +atomic_set (&mpol_new->refcnt,1 ); goto restart; }
Greg Kroah-Hartman
maintainerPATCH 276/343 io_uring: dont check req->file in io_fsync_prep()
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit ec858afda857e361182ceafc3d2ba2b164b8e889 upstream.
This is a leftover from the really old days where we weren't able to track and error early if we need a file and it wasn't assigned. Kill the check.
--- fs/io_uring.c | 3 --- 1 file changed, 3 deletions(-)
fs/io_uring.c +0 -3
@@ -4245,9 +4245,6 @@ static int io_fsync_prep(struct io_kiocb {struct io_ring_ctx *ctx = req->ctx; -if (!req->file) -return -EBADF ; -if (unlikely (ctx->flags &IORING_SETUP_IOPOLL ))return -EINVAL ; if (unlikely(sqe->addr || sqe->ioprio || sqe->buf_index ||
Greg Kroah-Hartman
maintainerPATCH 277/343 io_uring: defer splice/tee file validity check until command issue
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit a3e4bc23d5470b2beb7cc42a86b6a3e75b704c15 upstream.
In preparation for not using the file at prep time, defer checking if this file refers to a valid io_uring instance until issue time.
This also means we can get rid of the cleanup flag for splice and tee.
--- fs/io_uring.c | 49 +++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 28 deletions(-)
fs/io_uring.c +21 -28
@@ -621,10 +621,10 @@ struct io_epoll {struct io_splice {struct file *file_out; -struct file *file_in;loff_t off_out;loff_t off_in;u64 len; +int splice_fd_in;unsigned int flags; };
@@ -1551,14 +1551,6 @@ static void io_prep_async_work(struct ioif (def->unbound_nonreg_file) req->work.flags |=IO_WQ_WORK_UNBOUND ; } - -switch (req->opcode) { -case IORING_OP_SPLICE : -case IORING_OP_TEE : -if (!S_ISREG (file_inode (req->splice.file_in)->i_mode)) - req->work.flags |=IO_WQ_WORK_UNBOUND ; -break ; - } }static void io_prep_async_link (struct io_kiocb *req)
@@ -4144,18 +4136,11 @@ static int __io_splice_prep(struct io_kiif (unlikely (req->ctx->flags &IORING_SETUP_IOPOLL ))return -EINVAL ; - sp->file_in =NULL ; sp->len =READ_ONCE (sqe->len); sp->flags =READ_ONCE (sqe->splice_flags); -if (unlikely (sp->flags & ~valid_flags))return -EINVAL ; - - sp->file_in =io_file_get (req->ctx, req,READ_ONCE (sqe->splice_fd_in), - (sp->flags &SPLICE_F_FD_IN_FIXED )); -if (!sp->file_in) -return -EBADF ; - req->flags |=REQ_F_NEED_CLEANUP ; + sp->splice_fd_in =READ_ONCE (sqe->splice_fd_in);return 0 ; }
@@ -4170,20 +4155,27 @@ static int io_tee_prep(struct io_kiocb *static int io_tee (struct io_kiocb *req,unsigned int issue_flags) {struct io_splice *sp = &req->splice; -struct file *in = sp->file_in;struct file *out = sp->file_out;unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED ; +struct file *in;long ret =0 ;if (issue_flags &IO_URING_F_NONBLOCK )return -EAGAIN ; + + in =io_file_get (req->ctx, req, sp->splice_fd_in, + (sp->flags &SPLICE_F_FD_IN_FIXED )); +if (!in) { + ret = -EBADF ; + goto done; + } +if (sp->len) ret =do_tee (in, out, sp->len, flags);if (!(sp->flags &SPLICE_F_FD_IN_FIXED ))io_put_file (in); - req->flags &= ~REQ_F_NEED_CLEANUP ; - +done:if (ret != sp->len)req_set_fail (req);io_req_complete (req, ret);
@@ -4202,15 +4194,22 @@ static int io_splice_prep(struct io_kiocstatic int io_splice (struct io_kiocb *req,unsigned int issue_flags) {struct io_splice *sp = &req->splice; -struct file *in = sp->file_in;struct file *out = sp->file_out;unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED ;loff_t *poff_in, *poff_out; +struct file *in;long ret =0 ;if (issue_flags &IO_URING_F_NONBLOCK )return -EAGAIN ; + in =io_file_get (req->ctx, req, sp->splice_fd_in, + (sp->flags &SPLICE_F_FD_IN_FIXED )); +if (!in) { + ret = -EBADF ; + goto done; + } + poff_in = (sp->off_in ==-1 ) ?NULL : &sp->off_in; poff_out = (sp->off_out ==-1 ) ?NULL : &sp->off_out;
@@ -4219,8 +4218,7 @@ static int io_splice(struct io_kiocb *reif (!(sp->flags &SPLICE_F_FD_IN_FIXED ))io_put_file (in); - req->flags &= ~REQ_F_NEED_CLEANUP ; - +done:if (ret != sp->len)req_set_fail (req);io_req_complete (req, ret);
@@ -6686,11 +6684,6 @@ static void io_clean_op(struct io_kiocbkfree (io->free_iov);break ; } -case IORING_OP_SPLICE : -case IORING_OP_TEE : -if (!(req->splice.flags &SPLICE_F_FD_IN_FIXED )) -io_put_file (req->splice.file_in); -break ;case IORING_OP_OPENAT :case IORING_OP_OPENAT2 :if (req->open.filename)
Greg Kroah-Hartman
maintainerPATCH 278/343 io_uring: implement compat handling for IORING_REGISTER_IOWQ_AFF
In reply to Greg Kroah-HartmanFrom: Eugene Syromiatnikov <[email protected]>
commit 0f5e4b83b37a96e3643951588ed7176b9b187c0a upstream.
Similarly to the way it is done im mbind syscall.
--- fs/io_uring.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/io_uring.c +9 -1
@@ -10860,7 +10860,15 @@ static __cold int io_register_iowq_aff(sif (len >cpumask_size ()) len =cpumask_size (); -if (copy_from_user (new_mask, arg, len)) { +if (in_compat_syscall ()) { + ret =compat_get_bitmap (cpumask_bits (new_mask), + (const compat_ulong_t __user *)arg, + len *8 /* CHAR_BIT */ ); + }else { + ret =copy_from_user (new_mask, arg, len); + } + +if (ret) {free_cpumask_var (new_mask);return -EFAULT ; }
Greg Kroah-Hartman
maintainerPATCH 279/343 io_uring: fix race between timeout flush and removal
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit e677edbcabee849bfdd43f1602bccbecf736a646 upstream.
io_flush_timeouts() assumes the timeout isn't in progress of triggering or being removed/canceled, so it unconditionally removes it from the timeout list and attempts to cancel it.
Leave it on the list and let the normal timeout cancelation take care of it.
--- fs/io_uring.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/io_uring.c +3 -4
@@ -1644,12 +1644,11 @@ static __cold void io_flush_timeouts(str __must_hold(&ctx->completion_lock) {u32 seq = ctx->cached_cq_tail -atomic_read (&ctx->cq_timeouts); +struct io_kiocb *req, *tmp;spin_lock_irq (&ctx->timeout_lock); -while (!list_empty (&ctx->timeout_list)) { +list_for_each_entry_safe (req, tmp, &ctx->timeout_list, timeout.list) {u32 events_needed, events_got; -struct io_kiocb *req =list_first_entry (&ctx->timeout_list, - struct io_kiocb, timeout.list);if (io_is_timeout_noseq (req))break ;
@@ -1666,7 +1665,6 @@ static __cold void io_flush_timeouts(strif (events_got < events_needed)break ; -list_del_init (&req->timeout.list);io_kill_timeout (req,0 ); } ctx->cq_last_tm_flush = seq;
@@ -6276,6 +6274,7 @@ static int io_timeout_prep(struct io_kioif (data->ts.tv_sec <0 || data->ts.tv_nsec <0 )return -EINVAL ; +INIT_LIST_HEAD (&req->timeout.list); data->mode =io_translate_timeout_mode (flags);hrtimer_init (&data->timer,io_timeout_get_clock (data), data->mode);
Greg Kroah-Hartman
maintainerPATCH 280/343 x86/pm: Save the MSR validity status at context setup
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit 73924ec4d560257004d5b5116b22a3647661e364 upstream.
The mechanism to save/restore MSRs during S3 suspend/resume checks for the MSR validity during suspend, and only restores the MSR if its a valid MSR. This is not optimal, as an invalid MSR will unnecessarily throw an exception for every suspend cycle. The more invalid MSRs, higher the impact will be.
Check and save the MSR validity at setup. This ensures that only valid MSRs that are guaranteed to not throw an exception will be attempted during suspend.
--- arch/x86/power/cpu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/power/cpu.c +5 -2
@@ -40,7 +40,8 @@ static void msr_save_context(struct savestruct saved_msr *end = msr + ctxt->saved_msrs.num;while (msr < end) { - msr->valid = !rdmsrl_safe (msr->info.msr_no, &msr->info.reg.q); +if (msr->valid) +rdmsrl (msr->info.msr_no, msr->info.reg.q); msr++; } }
@@ -424,8 +425,10 @@ static int msr_build_context(const u32 * }for (i = saved_msrs->num, j =0 ; i < total_num; i++, j++) { +u64 dummy; + msr_array[i].info.msr_no = msr_id[j]; - msr_array[i].valid = false; + msr_array[i].valid = !rdmsrl_safe (msr_id[j], &dummy); msr_array[i].info.reg.q =0 ; } saved_msrs->num = total_num;
Greg Kroah-Hartman
maintainerPATCH 281/343 x86/speculation: Restore speculation related MSRs during S3 resume
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit e2a1256b17b16f9b9adf1b6fea56819e7b68e463 upstream.
After resuming from suspend-to-RAM, the MSRs that control CPU's speculative execution behavior are not being restored on the boot CPU.
These MSRs are used to mitigate speculative execution vulnerabilities. Not restoring them correctly may leave the CPU vulnerable. Secondary CPU's MSRs are correctly being restored at S3 resume by identify_secondary_cpu().
During S3 resume, restore these MSRs for boot CPU when restoring its processor state.
--- arch/x86/power/cpu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/x86/power/cpu.c +14 -0
@@ -503,10 +503,24 @@ static int pm_cpu_check(const struct x86return ret; } +static void pm_save_spec_msr (void ) +{ +u32 spec_msr_id[] = { +MSR_IA32_SPEC_CTRL , +MSR_IA32_TSX_CTRL , +MSR_TSX_FORCE_ABORT , +MSR_IA32_MCU_OPT_CTRL , +MSR_AMD64_LS_CFG , + }; + +msr_build_context (spec_msr_id,ARRAY_SIZE (spec_msr_id)); +} +static int pm_check_save_msr (void ) {dmi_check_system (msr_save_dmi_table);pm_cpu_check (msr_save_cpu_table); +pm_save_spec_msr ();return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 282/343 perf/x86/intel: Update the FRONTEND MSR mask on Sapphire Rapids
In reply to Greg Kroah-HartmanFrom: Kan Liang <[email protected]>
commit e590928de7547454469693da9bc7ffd562e54b7e upstream.
On Sapphire Rapids, the FRONTEND_RETIRED.MS_FLOWS event requires the FRONTEND MSR value 0x8. However, the current FRONTEND MSR mask doesn't support it.
Update intel_spr_extra_regs[] to support it.
--- arch/x86/events/intel/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/core.c +1 -1
@@ -281,7 +281,7 @@ static struct extra_reg intel_spr_extra_INTEL_UEVENT_EXTRA_REG (0x012a ,MSR_OFFCORE_RSP_0 ,0x3fffffffffull ,RSP_0 ),INTEL_UEVENT_EXTRA_REG (0x012b ,MSR_OFFCORE_RSP_1 ,0x3fffffffffull ,RSP_1 ),INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG (0x01cd ), -INTEL_UEVENT_EXTRA_REG (0x01c6 ,MSR_PEBS_FRONTEND ,0x7fff17 ,FE ), +INTEL_UEVENT_EXTRA_REG (0x01c6 ,MSR_PEBS_FRONTEND ,0x7fff1f ,FE ),INTEL_UEVENT_EXTRA_REG (0x40ad ,MSR_PEBS_FRONTEND ,0x7 ,FE ),INTEL_UEVENT_EXTRA_REG (0x04c2 ,MSR_PEBS_FRONTEND ,0x8 ,FE ),EVENT_EXTRA_END