Skip to content
  1. Jun 12, 2024
    • Wei Fang's avatar
      net: fec: avoid lock evasion when reading pps_enable · 4f11834e
      Wei Fang authored
      [ Upstream commit 3b1c92f8 ]
      
      The assignment of pps_enable is protected by tmreg_lock, but the read
      operation of pps_enable is not. So the Coverity tool reports a lock
      evasion warning which may cause data race to occur when running in a
      multithread environment. Although this issue is almost impossible to
      occur, we'd better fix it, at least it seems more logically reasonable,
      and it also prevents Coverity from continuing to issue warnings.
      
      Fixes: 278d2404
      
       ("net: fec: ptp: Enable PPS output based on ptp clock")
      Signed-off-by: default avatarWei Fang <wei.fang@nxp.com>
      Link: https://lore.kernel.org/r/20240521023800.17102-1-wei.fang@nxp.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4f11834e
    • Jacob Keller's avatar
      Revert "ixgbe: Manual AN-37 for troublesome link partners for X550 SFI" · eeae2526
      Jacob Keller authored
      [ Upstream commit b35b1c0b ]
      
      This reverts commit 56573604.
      
      According to the commit, it implements a manual AN-37 for some
      "troublesome" Juniper MX5 switches. This appears to be a workaround for a
      particular switch.
      
      It has been reported that this causes a severe breakage for other switches,
      including a Cisco 3560CX-12PD-S.
      
      The code appears to be a workaround for a specific switch which fails to
      link in SFI mode. It expects to see AN-37 auto negotiation in order to
      link. The Cisco switch is not expecting AN-37 auto negotiation. When the
      device starts the manual AN-37, the Cisco switch decides that the port is
      confused and stops attempting to link with it. This persists until a power
      cycle. A simple driver unload and reload does not resolve the issue, even
      if loading with a version of the driver which lacks this workaround.
      
      The authors of the workaround commit have not responded with
      clarifications, and the result of the workaround is complete failure to
      connect with other switches.
      
      This appears to be a case where the driver can either "correctly" link with
      the Juniper MX5 switch, at the cost of bricking the link with the Cisco
      switch, or it can behave properly for the Cisco switch, but fail to link
      with the Junipir MX5 switch. I do not know enough about the standards
      involved to clearly determine whether either switch is at fault or behaving
      incorrectly. Nor do I know whether there exists some alternative fix which
      corrects behavior with both switches.
      
      Revert the workaround for the Juniper switch.
      
      Fixes: 56573604
      
       ("ixgbe: Manual AN-37 for troublesome link partners for X550 SFI")
      Link: https://lore.kernel.org/netdev/cbe874db-9ac9-42b8-afa0-88ea910e1e99@intel.com/T/
      Link: https://forum.proxmox.com/threads/intel-x553-sfp-ixgbe-no-go-on-pve8.135129/#post-612291
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Cc: Jeff Daly <jeffd@silicom-usa.com>
      Cc: kernel.org-fo5k2w@ycharbi.fr
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/20240520-net-2024-05-20-revert-silicom-switch-workaround-v1-1-50f80f261c94@intel.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eeae2526
    • Matthew Bystrin's avatar
      riscv: stacktrace: fixed walk_stackframe() · 2ae3749f
      Matthew Bystrin authored
      [ Upstream commit a2a4d4a6 ]
      
      If the load access fault occures in a leaf function (with
      CONFIG_FRAME_POINTER=y), when wrong stack trace will be displayed:
      
      [<ffffffff804853c2>] regmap_mmio_read32le+0xe/0x1c
      ---[ end trace 0000000000000000 ]---
      
      Registers dump:
          ra     0xffffffff80485758 <regmap_mmio_read+36>
          sp     0xffffffc80200b9a0
          fp     0xffffffc80200b9b0
          pc     0xffffffff804853ba <regmap_mmio_read32le+6>
      
      Stack dump:
          0xffffffc80200b9a0:  0xffffffc80200b9e0  0xffffffc80200b9e0
          0xffffffc80200b9b0:  0xffffffff8116d7e8  0x0000000000000100
          0xffffffc80200b9c0:  0xffffffd8055b9400  0xffffffd8055b9400
          0xffffffc80200b9d0:  0xffffffc80200b9f0  0xffffffff8047c526
          0xffffffc80200b9e0:  0xffffffc80200ba30  0xffffffff8047fe9a
      
      The assembler dump of the function preambula:
          add     sp,sp,-16
          sd      s0,8(sp)
          add     s0,sp,16
      
      In the fist stack frame, where ra is not stored on the stack we can
      observe:
      
              0(sp)                  8(sp)
              .---------------------------------------------.
          sp->|       frame->fp      | frame->ra (saved fp) |
              |---------------------------------------------|
          fp->|         ....         |         ....         |
              |---------------------------------------------|
              |                      |                      |
      
      and in the code check is performed:
      	if (regs && (regs->epc == pc) && (frame->fp & 0x7))
      
      I see no reason to check frame->fp value at all, because it is can be
      uninitialized value on the stack. A better way is to check frame->ra to
      be an address on the stack. After the stacktrace shows as expect:
      
      [<ffffffff804853c2>] regmap_mmio_read32le+0xe/0x1c
      [<ffffffff80485758>] regmap_mmio_read+0x24/0x52
      [<ffffffff8047c526>] _regmap_bus_reg_read+0x1a/0x22
      [<ffffffff8047fe9a>] _regmap_read+0x5c/0xea
      [<ffffffff80480376>] _regmap_update_bits+0x76/0xc0
      ...
      ---[ end trace 0000000000000000 ]---
      As pointed by Samuel Holland it is incorrect to remove check of the stackframe
      entirely.
      
      Changes since v2 [2]:
       - Add accidentally forgotten curly brace
      
      Changes since v1 [1]:
       - Instead of just dropping frame->fp check, replace it with validation of
         frame->ra, which should be a stack address.
       - Move frame pointer validation into the separate function.
      
      [1] https://lore.kernel.org/linux-riscv/20240426072701.6463-1-dev.mbstr@gmail.com/
      [2] https://lore.kernel.org/linux-riscv/20240521131314.48895-1-dev.mbstr@gmail.com/
      
      Fixes: f766f77a
      
       ("riscv/stacktrace: Fix stack output without ra on the stack top")
      Signed-off-by: default avatarMatthew Bystrin <dev.mbstr@gmail.com>
      Reviewed-by: default avatarSamuel Holland <samuel.holland@sifive.com>
      Link: https://lore.kernel.org/r/20240521191727.62012-1-dev.mbstr@gmail.com
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2ae3749f
    • Guo Ren's avatar
      riscv: stacktrace: Make walk_stackframe cross pt_regs frame · 62bcc5c9
      Guo Ren authored
      [ Upstream commit 7ecdadf7
      
       ]
      
      The current walk_stackframe with FRAME_POINTER would stop unwinding at
      ret_from_exception:
        BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:1518
        in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 1, name: init
        CPU: 0 PID: 1 Comm: init Not tainted 5.10.113-00021-g15c15974895c-dirty #192
        Call Trace:
        [<ffffffe0002038c8>] walk_stackframe+0x0/0xee
        [<ffffffe000aecf48>] show_stack+0x32/0x4a
        [<ffffffe000af1618>] dump_stack_lvl+0x72/0x8e
        [<ffffffe000af1648>] dump_stack+0x14/0x1c
        [<ffffffe000239ad2>] ___might_sleep+0x12e/0x138
        [<ffffffe000239aec>] __might_sleep+0x10/0x18
        [<ffffffe000afe3fe>] down_read+0x22/0xa4
        [<ffffffe000207588>] do_page_fault+0xb0/0x2fe
        [<ffffffe000201b80>] ret_from_exception+0x0/0xc
      
      The optimization would help walk_stackframe cross the pt_regs frame and
      get more backtrace of debug info:
        BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:1518
        in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 1, name: init
        CPU: 0 PID: 1 Comm: init Not tainted 5.10.113-00021-g15c15974895c-dirty #192
        Call Trace:
        [<ffffffe0002038c8>] walk_stackframe+0x0/0xee
        [<ffffffe000aecf48>] show_stack+0x32/0x4a
        [<ffffffe000af1618>] dump_stack_lvl+0x72/0x8e
        [<ffffffe000af1648>] dump_stack+0x14/0x1c
        [<ffffffe000239ad2>] ___might_sleep+0x12e/0x138
        [<ffffffe000239aec>] __might_sleep+0x10/0x18
        [<ffffffe000afe3fe>] down_read+0x22/0xa4
        [<ffffffe000207588>] do_page_fault+0xb0/0x2fe
        [<ffffffe000201b80>] ret_from_exception+0x0/0xc
        [<ffffffe000613c06>] riscv_intc_irq+0x1a/0x72
        [<ffffffe000201b80>] ret_from_exception+0x0/0xc
        [<ffffffe00033f44a>] vma_link+0x54/0x160
        [<ffffffe000341d7a>] mmap_region+0x2cc/0x4d0
        [<ffffffe000342256>] do_mmap+0x2d8/0x3ac
        [<ffffffe000326318>] vm_mmap_pgoff+0x70/0xb8
        [<ffffffe00032638a>] vm_mmap+0x2a/0x36
        [<ffffffe0003cfdde>] elf_map+0x72/0x84
        [<ffffffe0003d05f8>] load_elf_binary+0x69a/0xec8
        [<ffffffe000376240>] bprm_execve+0x246/0x53a
        [<ffffffe00037786c>] kernel_execve+0xe8/0x124
        [<ffffffe000aecdf2>] run_init_process+0xfa/0x10c
        [<ffffffe000aece16>] try_to_run_init_process+0x12/0x3c
        [<ffffffe000afa920>] kernel_init+0xb4/0xf8
        [<ffffffe000201b80>] ret_from_exception+0x0/0xc
      
      Here is the error injection test code for the above output:
       drivers/irqchip/irq-riscv-intc.c:
       static asmlinkage void riscv_intc_irq(struct pt_regs *regs)
       {
              unsigned long cause = regs->cause & ~CAUSE_IRQ_FLAG;
      +       u32 tmp; __get_user(tmp, (u32 *)0);
      
      Signed-off-by: default avatarGuo Ren <guoren@linux.alibaba.com>
      Signed-off-by: default avatarGuo Ren <guoren@kernel.org>
      Link: https://lore.kernel.org/r/20221109064937.3643993-3-guoren@kernel.org
      [Palmer: use SYM_CODE_*]
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Stable-dep-of: a2a4d4a6
      
       ("riscv: stacktrace: fixed walk_stackframe()")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      62bcc5c9
    • Jiri Pirko's avatar
      virtio: delete vq in vp_find_vqs_msix() when request_irq() fails · abf00165
      Jiri Pirko authored
      [ Upstream commit 89875151 ]
      
      When request_irq() fails, error path calls vp_del_vqs(). There, as vq is
      present in the list, free_irq() is called for the same vector. That
      causes following splat:
      
      [    0.414355] Trying to free already-free IRQ 27
      [    0.414403] WARNING: CPU: 1 PID: 1 at kernel/irq/manage.c:1899 free_irq+0x1a1/0x2d0
      [    0.414510] Modules linked in:
      [    0.414540] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.9.0-rc4+ #27
      [    0.414540] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-1.fc39 04/01/2014
      [    0.414540] RIP: 0010:free_irq+0x1a1/0x2d0
      [    0.414540] Code: 1e 00 48 83 c4 08 48 89 e8 5b 5d 41 5c 41 5d 41 5e 41 5f c3 cc cc cc cc 90 8b 74 24 04 48 c7 c7 98 80 6c b1 e8 00 c9 f7 ff 90 <0f> 0b 90 90 48 89 ee 4c 89 ef e8 e0 20 b8 00 49 8b 47 40 48 8b 40
      [    0.414540] RSP: 0000:ffffb71480013ae0 EFLAGS: 00010086
      [    0.414540] RAX: 0000000000000000 RBX: ffffa099c2722000 RCX: 0000000000000000
      [    0.414540] RDX: 0000000000000000 RSI: ffffb71480013998 RDI: 0000000000000001
      [    0.414540] RBP: 0000000000000246 R08: 00000000ffffdfff R09: 0000000000000001
      [    0.414540] R10: 00000000ffffdfff R11: ffffffffb18729c0 R12: ffffa099c1c91760
      [    0.414540] R13: ffffa099c1c916a4 R14: ffffa099c1d2f200 R15: ffffa099c1c91600
      [    0.414540] FS:  0000000000000000(0000) GS:ffffa099fec40000(0000) knlGS:0000000000000000
      [    0.414540] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    0.414540] CR2: 0000000000000000 CR3: 0000000008e3e001 CR4: 0000000000370ef0
      [    0.414540] Call Trace:
      [    0.414540]  <TASK>
      [    0.414540]  ? __warn+0x80/0x120
      [    0.414540]  ? free_irq+0x1a1/0x2d0
      [    0.414540]  ? report_bug+0x164/0x190
      [    0.414540]  ? handle_bug+0x3b/0x70
      [    0.414540]  ? exc_invalid_op+0x17/0x70
      [    0.414540]  ? asm_exc_invalid_op+0x1a/0x20
      [    0.414540]  ? free_irq+0x1a1/0x2d0
      [    0.414540]  vp_del_vqs+0xc1/0x220
      [    0.414540]  vp_find_vqs_msix+0x305/0x470
      [    0.414540]  vp_find_vqs+0x3e/0x1a0
      [    0.414540]  vp_modern_find_vqs+0x1b/0x70
      [    0.414540]  init_vqs+0x387/0x600
      [    0.414540]  virtnet_probe+0x50a/0xc80
      [    0.414540]  virtio_dev_probe+0x1e0/0x2b0
      [    0.414540]  really_probe+0xc0/0x2c0
      [    0.414540]  ? __pfx___driver_attach+0x10/0x10
      [    0.414540]  __driver_probe_device+0x73/0x120
      [    0.414540]  driver_probe_device+0x1f/0xe0
      [    0.414540]  __driver_attach+0x88/0x180
      [    0.414540]  bus_for_each_dev+0x85/0xd0
      [    0.414540]  bus_add_driver+0xec/0x1f0
      [    0.414540]  driver_register+0x59/0x100
      [    0.414540]  ? __pfx_virtio_net_driver_init+0x10/0x10
      [    0.414540]  virtio_net_driver_init+0x90/0xb0
      [    0.414540]  do_one_initcall+0x58/0x230
      [    0.414540]  kernel_init_freeable+0x1a3/0x2d0
      [    0.414540]  ? __pfx_kernel_init+0x10/0x10
      [    0.414540]  kernel_init+0x1a/0x1c0
      [    0.414540]  ret_from_fork+0x31/0x50
      [    0.414540]  ? __pfx_kernel_init+0x10/0x10
      [    0.414540]  ret_from_fork_asm+0x1a/0x30
      [    0.414540]  </TASK>
      
      Fix this by calling deleting the current vq when request_irq() fails.
      
      Fixes: 0b0f9dc5
      
       ("Revert "virtio_pci: use shared interrupts for virtqueues"")
      Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
      Message-Id: <20240426150845.3999481-1-jiri@resnulli.us>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      abf00165
    • Yang Li's avatar
      rv: Update rv_en(dis)able_monitor doc to match kernel-doc · e63c1085
      Yang Li authored
      [ Upstream commit 1e8b7b3d ]
      
      The patch updates the function documentation comment for
      rv_en(dis)able_monitor to adhere to the kernel-doc specification.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240520054239.61784-1-yang.lee@linux.alibaba.com
      
      Fixes: 102227b9
      
       ("rv: Add Runtime Verification (RV) interface")
      Signed-off-by: default avatarYang Li <yang.lee@linux.alibaba.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e63c1085
    • Jiangfeng Xiao's avatar
      arm64: asm-bug: Add .align 2 to the end of __BUG_ENTRY · 3fd487ff
      Jiangfeng Xiao authored
      [ Upstream commit ffbf4fb9 ]
      
      When CONFIG_DEBUG_BUGVERBOSE=n, we fail to add necessary padding bytes
      to bug_table entries, and as a result the last entry in a bug table will
      be ignored, potentially leading to an unexpected panic(). All prior
      entries in the table will be handled correctly.
      
      The arm64 ABI requires that struct fields of up to 8 bytes are
      naturally-aligned, with padding added within a struct such that struct
      are suitably aligned within arrays.
      
      When CONFIG_DEBUG_BUGVERPOSE=y, the layout of a bug_entry is:
      
      	struct bug_entry {
      		signed int      bug_addr_disp;	// 4 bytes
      		signed int      file_disp;	// 4 bytes
      		unsigned short  line;		// 2 bytes
      		unsigned short  flags;		// 2 bytes
      	}
      
      ... with 12 bytes total, requiring 4-byte alignment.
      
      When CONFIG_DEBUG_BUGVERBOSE=n, the layout of a bug_entry is:
      
      	struct bug_entry {
      		signed int      bug_addr_disp;	// 4 bytes
      		unsigned short  flags;		// 2 bytes
      		< implicit padding >		// 2 bytes
      	}
      
      ... with 8 bytes total, with 6 bytes of data and 2 bytes of trailing
      padding, requiring 4-byte alginment.
      
      When we create a bug_entry in assembly, we align the start of the entry
      to 4 bytes, which implicitly handles padding for any prior entries.
      However, we do not align the end of the entry, and so when
      CONFIG_DEBUG_BUGVERBOSE=n, the final entry lacks the trailing padding
      bytes.
      
      For the main kernel image this is not a problem as find_bug() doesn't
      depend on the trailing padding bytes when searching for entries:
      
      	for (bug = __start___bug_table; bug < __stop___bug_table; ++bug)
      		if (bugaddr == bug_addr(bug))
      			return bug;
      
      However for modules, module_bug_finalize() depends on the trailing
      bytes when calculating the number of entries:
      
      	mod->num_bugs = sechdrs[i].sh_size / sizeof(struct bug_entry);
      
      ... and as the last bug_entry lacks the necessary padding bytes, this entry
      will not be counted, e.g. in the case of a single entry:
      
      	sechdrs[i].sh_size == 6
      	sizeof(struct bug_entry) == 8;
      
      	sechdrs[i].sh_size / sizeof(struct bug_entry) == 0;
      
      Consequently module_find_bug() will miss the last bug_entry when it does:
      
      	for (i = 0; i < mod->num_bugs; ++i, ++bug)
      		if (bugaddr == bug_addr(bug))
      			goto out;
      
      ... which can lead to a kenrel panic due to an unhandled bug.
      
      This can be demonstrated with the following module:
      
      	static int __init buginit(void)
      	{
      		WARN(1, "hello\n");
      		return 0;
      	}
      
      	static void __exit bugexit(void)
      	{
      	}
      
      	module_init(buginit);
      	module_exit(bugexit);
      	MODULE_LICENSE("GPL");
      
      ... which will trigger a kernel panic when loaded:
      
      	------------[ cut here ]------------
      	hello
      	Unexpected kernel BRK exception at EL1
      	Internal error: BRK handler: 00000000f2000800 [#1] PREEMPT SMP
      	Modules linked in: hello(O+)
      	CPU: 0 PID: 50 Comm: insmod Tainted: G           O       6.9.1 #8
      	Hardware name: linux,dummy-virt (DT)
      	pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      	pc : buginit+0x18/0x1000 [hello]
      	lr : buginit+0x18/0x1000 [hello]
      	sp : ffff800080533ae0
      	x29: ffff800080533ae0 x28: 0000000000000000 x27: 0000000000000000
      	x26: ffffaba8c4e70510 x25: ffff800080533c30 x24: ffffaba8c4a28a58
      	x23: 0000000000000000 x22: 0000000000000000 x21: ffff3947c0eab3c0
      	x20: ffffaba8c4e3f000 x19: ffffaba846464000 x18: 0000000000000006
      	x17: 0000000000000000 x16: ffffaba8c2492834 x15: 0720072007200720
      	x14: 0720072007200720 x13: ffffaba8c49b27c8 x12: 0000000000000312
      	x11: 0000000000000106 x10: ffffaba8c4a0a7c8 x9 : ffffaba8c49b27c8
      	x8 : 00000000ffffefff x7 : ffffaba8c4a0a7c8 x6 : 80000000fffff000
      	x5 : 0000000000000107 x4 : 0000000000000000 x3 : 0000000000000000
      	x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff3947c0eab3c0
      	Call trace:
      	 buginit+0x18/0x1000 [hello]
      	 do_one_initcall+0x80/0x1c8
      	 do_init_module+0x60/0x218
      	 load_module+0x1ba4/0x1d70
      	 __do_sys_init_module+0x198/0x1d0
      	 __arm64_sys_init_module+0x1c/0x28
      	 invoke_syscall+0x48/0x114
      	 el0_svc_common.constprop.0+0x40/0xe0
      	 do_el0_svc+0x1c/0x28
      	 el0_svc+0x34/0xd8
      	 el0t_64_sync_handler+0x120/0x12c
      	 el0t_64_sync+0x190/0x194
      	Code: d0ffffe0 910003fd 91000000 9400000b (d4210000)
      	---[ end trace 0000000000000000 ]---
      	Kernel panic - not syncing: BRK handler: Fatal exception
      
      Fix this by always aligning the end of a bug_entry to 4 bytes, which is
      correct regardless of CONFIG_DEBUG_BUGVERBOSE.
      
      Fixes: 9fb7410f
      
       ("arm64/BUG: Use BRK instruction for generic BUG traps")
      
      Signed-off-by: default avatarYuanbin Xie <xieyuanbin1@huawei.com>
      Signed-off-by: default avatarJiangfeng Xiao <xiaojiangfeng@huawei.com>
      Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
      Link: https://lore.kernel.org/r/1716212077-43826-1-git-send-email-xiaojiangfeng@huawei.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3fd487ff
    • Aaron Conole's avatar
      openvswitch: Set the skbuff pkt_type for proper pmtud support. · b4ff9af8
      Aaron Conole authored
      [ Upstream commit 30a92c9e
      
       ]
      
      Open vSwitch is originally intended to switch at layer 2, only dealing with
      Ethernet frames.  With the introduction of l3 tunnels support, it crossed
      into the realm of needing to care a bit about some routing details when
      making forwarding decisions.  If an oversized packet would need to be
      fragmented during this forwarding decision, there is a chance for pmtu
      to get involved and generate a routing exception.  This is gated by the
      skbuff->pkt_type field.
      
      When a flow is already loaded into the openvswitch module this field is
      set up and transitioned properly as a packet moves from one port to
      another.  In the case that a packet execute is invoked after a flow is
      newly installed this field is not properly initialized.  This causes the
      pmtud mechanism to omit sending the required exception messages across
      the tunnel boundary and a second attempt needs to be made to make sure
      that the routing exception is properly setup.  To fix this, we set the
      outgoing packet's pkt_type to PACKET_OUTGOING, since it can only get
      to the openvswitch module via a port device or packet command.
      
      Even for bridge ports as users, the pkt_type needs to be reset when
      doing the transmit as the packet is truly outgoing and routing needs
      to get involved post packet transformations, in the case of
      VXLAN/GENEVE/udp-tunnel packets.  In general, the pkt_type on output
      gets ignored, since we go straight to the driver, but in the case of
      tunnel ports they go through IP routing layer.
      
      This issue is periodically encountered in complex setups, such as large
      openshift deployments, where multiple sets of tunnel traversal occurs.
      A way to recreate this is with the ovn-heater project that can setup
      a networking environment which mimics such large deployments.  We need
      larger environments for this because we need to ensure that flow
      misses occur.  In these environment, without this patch, we can see:
      
        ./ovn_cluster.sh start
        podman exec ovn-chassis-1 ip r a 170.168.0.5/32 dev eth1 mtu 1200
        podman exec ovn-chassis-1 ip netns exec sw01p1 ip r flush cache
        podman exec ovn-chassis-1 ip netns exec sw01p1 \
               ping 21.0.0.3 -M do -s 1300 -c2
        PING 21.0.0.3 (21.0.0.3) 1300(1328) bytes of data.
        From 21.0.0.3 icmp_seq=2 Frag needed and DF set (mtu = 1142)
      
        --- 21.0.0.3 ping statistics ---
        ...
      
      Using tcpdump, we can also see the expected ICMP FRAG_NEEDED message is not
      sent into the server.
      
      With this patch, setting the pkt_type, we see the following:
      
        podman exec ovn-chassis-1 ip netns exec sw01p1 \
               ping 21.0.0.3 -M do -s 1300 -c2
        PING 21.0.0.3 (21.0.0.3) 1300(1328) bytes of data.
        From 21.0.0.3 icmp_seq=1 Frag needed and DF set (mtu = 1222)
        ping: local error: message too long, mtu=1222
      
        --- 21.0.0.3 ping statistics ---
        ...
      
      In this case, the first ping request receives the FRAG_NEEDED message and
      a local routing exception is created.
      
      Tested-by: default avatarJaime Caamano <jcaamano@redhat.com>
      Reported-at: https://issues.redhat.com/browse/FDP-164
      Fixes: 58264848
      
       ("openvswitch: Add vxlan tunneling support.")
      Signed-off-by: default avatarAaron Conole <aconole@redhat.com>
      Acked-by: default avatarEelco Chaudron <echaudro@redhat.com>
      Link: https://lore.kernel.org/r/20240516200941.16152-1-aconole@redhat.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b4ff9af8
    • Olga Kornievskaia's avatar
      pNFS/filelayout: fixup pNfs allocation modes · 1d20ba60
      Olga Kornievskaia authored
      [ Upstream commit 3ebcb246 ]
      
      Change left over allocation flags.
      
      Fixes: a245832a
      
       ("pNFS/files: Ensure pNFS allocation modes are consistent with nfsiod")
      Signed-off-by: default avatarOlga Kornievskaia <kolga@netapp.com>
      Reviewed-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1d20ba60
    • Kuniyuki Iwashima's avatar
      tcp: Fix shift-out-of-bounds in dctcp_update_alpha(). · e65d13ec
      Kuniyuki Iwashima authored
      [ Upstream commit 3ebc46ca
      
       ]
      
      In dctcp_update_alpha(), we use a module parameter dctcp_shift_g
      as follows:
      
        alpha -= min_not_zero(alpha, alpha >> dctcp_shift_g);
        ...
        delivered_ce <<= (10 - dctcp_shift_g);
      
      It seems syzkaller started fuzzing module parameters and triggered
      shift-out-of-bounds [0] by setting 100 to dctcp_shift_g:
      
        memcpy((void*)0x20000080,
               "/sys/module/tcp_dctcp/parameters/dctcp_shift_g\000", 47);
        res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x20000080ul,
                      /*flags=*/2ul, /*mode=*/0ul);
        memcpy((void*)0x20000000, "100\000", 4);
        syscall(__NR_write, /*fd=*/r[0], /*val=*/0x20000000ul, /*len=*/4ul);
      
      Let's limit the max value of dctcp_shift_g by param_set_uint_minmax().
      
      With this patch:
      
        # echo 10 > /sys/module/tcp_dctcp/parameters/dctcp_shift_g
        # cat /sys/module/tcp_dctcp/parameters/dctcp_shift_g
        10
        # echo 11 > /sys/module/tcp_dctcp/parameters/dctcp_shift_g
        -bash: echo: write error: Invalid argument
      
      [0]:
      UBSAN: shift-out-of-bounds in net/ipv4/tcp_dctcp.c:143:12
      shift exponent 100 is too large for 32-bit type 'u32' (aka 'unsigned int')
      CPU: 0 PID: 8083 Comm: syz-executor345 Not tainted 6.9.0-05151-g1b294a1f3561 #2
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
      1.13.0-1ubuntu1.1 04/01/2014
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x201/0x300 lib/dump_stack.c:114
       ubsan_epilogue lib/ubsan.c:231 [inline]
       __ubsan_handle_shift_out_of_bounds+0x346/0x3a0 lib/ubsan.c:468
       dctcp_update_alpha+0x540/0x570 net/ipv4/tcp_dctcp.c:143
       tcp_in_ack_event net/ipv4/tcp_input.c:3802 [inline]
       tcp_ack+0x17b1/0x3bc0 net/ipv4/tcp_input.c:3948
       tcp_rcv_state_process+0x57a/0x2290 net/ipv4/tcp_input.c:6711
       tcp_v4_do_rcv+0x764/0xc40 net/ipv4/tcp_ipv4.c:1937
       sk_backlog_rcv include/net/sock.h:1106 [inline]
       __release_sock+0x20f/0x350 net/core/sock.c:2983
       release_sock+0x61/0x1f0 net/core/sock.c:3549
       mptcp_subflow_shutdown+0x3d0/0x620 net/mptcp/protocol.c:2907
       mptcp_check_send_data_fin+0x225/0x410 net/mptcp/protocol.c:2976
       __mptcp_close+0x238/0xad0 net/mptcp/protocol.c:3072
       mptcp_close+0x2a/0x1a0 net/mptcp/protocol.c:3127
       inet_release+0x190/0x1f0 net/ipv4/af_inet.c:437
       __sock_release net/socket.c:659 [inline]
       sock_close+0xc0/0x240 net/socket.c:1421
       __fput+0x41b/0x890 fs/file_table.c:422
       task_work_run+0x23b/0x300 kernel/task_work.c:180
       exit_task_work include/linux/task_work.h:38 [inline]
       do_exit+0x9c8/0x2540 kernel/exit.c:878
       do_group_exit+0x201/0x2b0 kernel/exit.c:1027
       __do_sys_exit_group kernel/exit.c:1038 [inline]
       __se_sys_exit_group kernel/exit.c:1036 [inline]
       __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1036
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xe4/0x240 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x67/0x6f
      RIP: 0033:0x7f6c2b5005b6
      Code: Unable to access opcode bytes at 0x7f6c2b50058c.
      RSP: 002b:00007ffe883eb948 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
      RAX: ffffffffffffffda RBX: 00007f6c2b5862f0 RCX: 00007f6c2b5005b6
      RDX: 0000000000000001 RSI: 000000000000003c RDI: 0000000000000001
      RBP: 0000000000000001 R08: 00000000000000e7 R09: ffffffffffffffc0
      R10: 0000000000000006 R11: 0000000000000246 R12: 00007f6c2b5862f0
      R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001
       </TASK>
      
      Reported-by: default avatarsyzkaller <syzkaller@googlegroups.com>
      Reported-by: default avatarYue Sun <samsun1006219@gmail.com>
      Reported-by: default avatarxingwei lee <xrivendell7@gmail.com>
      Closes: https://lore.kernel.org/netdev/CAEkJfYNJM=cw-8x7_Vmj1J6uYVCWMbbvD=EFmDPVBGpTsqOxEA@mail.gmail.com/
      Fixes: e3118e83
      
       ("net: tcp: add DCTCP congestion control algorithm")
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/20240517091626.32772-1-kuniyu@amazon.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e65d13ec
    • Hangbin Liu's avatar
      ipv6: sr: fix memleak in seg6_hmac_init_algo · 599a5654
      Hangbin Liu authored
      [ Upstream commit efb9f4f1 ]
      
      seg6_hmac_init_algo returns without cleaning up the previous allocations
      if one fails, so it's going to leak all that memory and the crypto tfms.
      
      Update seg6_hmac_exit to only free the memory when allocated, so we can
      reuse the code directly.
      
      Fixes: bf355b8d
      
       ("ipv6: sr: add core files for SR HMAC support")
      Reported-by: default avatarSabrina Dubroca <sd@queasysnail.net>
      Closes: https://lore.kernel.org/netdev/Zj3bh-gE7eT6V6aH@hog/
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Reviewed-by: default avatarSabrina Dubroca <sd@queasysnail.net>
      Link: https://lore.kernel.org/r/20240517005435.2600277-1-liuhangbin@gmail.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      599a5654
    • Kuniyuki Iwashima's avatar
      af_unix: Update unix_sk(sk)->oob_skb under sk_receive_queue lock. · 4bf69644
      Kuniyuki Iwashima authored
      [ Upstream commit 9841991a ]
      
      Billy Jheng Bing-Jhong reported a race between __unix_gc() and
      queue_oob().
      
      __unix_gc() tries to garbage-collect close()d inflight sockets,
      and then if the socket has MSG_OOB in unix_sk(sk)->oob_skb, GC
      will drop the reference and set NULL to it locklessly.
      
      However, the peer socket still can send MSG_OOB message and
      queue_oob() can update unix_sk(sk)->oob_skb concurrently, leading
      NULL pointer dereference. [0]
      
      To fix the issue, let's update unix_sk(sk)->oob_skb under the
      sk_receive_queue's lock and take it everywhere we touch oob_skb.
      
      Note that we defer kfree_skb() in manage_oob() to silence lockdep
      false-positive (See [1]).
      
      [0]:
      BUG: kernel NULL pointer dereference, address: 0000000000000008
       PF: supervisor write access in kernel mode
       PF: error_code(0x0002) - not-present page
      PGD 8000000009f5e067 P4D 8000000009f5e067 PUD 9f5d067 PMD 0
      Oops: 0002 [#1] PREEMPT SMP PTI
      CPU: 3 PID: 50 Comm: kworker/3:1 Not tainted 6.9.0-rc5-00191-gd091e579b864 #110
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
      Workqueue: events delayed_fput
      RIP: 0010:skb_dequeue (./include/linux/skbuff.h:2386 ./include/linux/skbuff.h:2402 net/core/skbuff.c:3847)
      Code: 39 e3 74 3e 8b 43 10 48 89 ef 83 e8 01 89 43 10 49 8b 44 24 08 49 c7 44 24 08 00 00 00 00 49 8b 14 24 49 c7 04 24 00 00 00 00 <48> 89 42 08 48 89 10 e8 e7 c5 42 00 4c 89 e0 5b 5d 41 5c c3 cc cc
      RSP: 0018:ffffc900001bfd48 EFLAGS: 00000002
      RAX: 0000000000000000 RBX: ffff8880088f5ae8 RCX: 00000000361289f9
      RDX: 0000000000000000 RSI: 0000000000000206 RDI: ffff8880088f5b00
      RBP: ffff8880088f5b00 R08: 0000000000080000 R09: 0000000000000001
      R10: 0000000000000003 R11: 0000000000000001 R12: ffff8880056b6a00
      R13: ffff8880088f5280 R14: 0000000000000001 R15: ffff8880088f5a80
      FS:  0000000000000000(0000) GS:ffff88807dd80000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000008 CR3: 0000000006314000 CR4: 00000000007506f0
      PKRU: 55555554
      Call Trace:
       <TASK>
       unix_release_sock (net/unix/af_unix.c:654)
       unix_release (net/unix/af_unix.c:1050)
       __sock_release (net/socket.c:660)
       sock_close (net/socket.c:1423)
       __fput (fs/file_table.c:423)
       delayed_fput (fs/file_table.c:444 (discriminator 3))
       process_one_work (kernel/workqueue.c:3259)
       worker_thread (kernel/workqueue.c:3329 kernel/workqueue.c:3416)
       kthread (kernel/kthread.c:388)
       ret_from_fork (arch/x86/kernel/process.c:153)
       ret_from_fork_asm (arch/x86/entry/entry_64.S:257)
       </TASK>
      Modules linked in:
      CR2: 0000000000000008
      
      Link: https://lore.kernel.org/netdev/a00d3993-c461-43f2-be6d-07259c98509a@rbox.co/ [1]
      Fixes: 1279f9d9
      
       ("af_unix: Call kfree_skb() for dead unix_(sk)->oob_skb in GC.")
      Reported-by: default avatarBilly Jheng Bing-Jhong <billy@starlabs.sg>
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Link: https://lore.kernel.org/r/20240516134835.8332-1-kuniyu@amazon.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4bf69644
    • Dan Aloni's avatar
      rpcrdma: fix handling for RDMA_CM_EVENT_DEVICE_REMOVAL · cdc02349
      Dan Aloni authored
      [ Upstream commit 4836da21 ]
      
      Under the scenario of IB device bonding, when bringing down one of the
      ports, or all ports, we saw xprtrdma entering a non-recoverable state
      where it is not even possible to complete the disconnect and shut it
      down the mount, requiring a reboot. Following debug, we saw that
      transport connect never ended after receiving the
      RDMA_CM_EVENT_DEVICE_REMOVAL callback.
      
      The DEVICE_REMOVAL callback is irrespective of whether the CM_ID is
      connected, and ESTABLISHED may not have happened. So need to work with
      each of these states accordingly.
      
      Fixes: 2acc5cae
      
       ('xprtrdma: Prevent dereferencing r_xprt->rx_ep after it is freed')
      Cc: Sagi Grimberg <sagi.grimberg@vastdata.com>
      Signed-off-by: default avatarDan Aloni <dan.aloni@vastdata.com>
      Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
      Reviewed-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cdc02349
    • Dan Aloni's avatar
      sunrpc: fix NFSACL RPC retry on soft mount · 3c92f3a5
      Dan Aloni authored
      [ Upstream commit 0dc9f430 ]
      
      It used to be quite awhile ago since 1b63a751 ('SUNRPC: Refactor
      rpc_clone_client()'), in 2012, that `cl_timeout` was copied in so that
      all mount parameters propagate to NFSACL clients. However since that
      change, if mount options as follows are given:
      
          soft,timeo=50,retrans=16,vers=3
      
      The resultant NFSACL client receives:
      
          cl_softrtry: 1
          cl_timeout: to_initval=60000, to_maxval=60000, to_increment=0, to_retries=2, to_exponential=0
      
      These values lead to NFSACL operations not being retried under the
      condition of transient network outages with soft mount. Instead, getacl
      call fails after 60 seconds with EIO.
      
      The simple fix is to pass the existing client's `cl_timeout` as the new
      client timeout.
      
      Cc: Chuck Lever <chuck.lever@oracle.com>
      Cc: Benjamin Coddington <bcodding@redhat.com>
      Link: https://lore.kernel.org/all/20231105154857.ryakhmgaptq3hb6b@gmail.com/T/
      Fixes: 1b63a751
      
       ('SUNRPC: Refactor rpc_clone_client()')
      Signed-off-by: default avatarDan Aloni <dan.aloni@vastdata.com>
      Reviewed-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3c92f3a5
    • Martin Kaiser's avatar
      nfs: keep server info for remounts · 99530e42
      Martin Kaiser authored
      [ Upstream commit b322bf9e ]
      
      With newer kernels that use fs_context for nfs mounts, remounts fail with
      -EINVAL.
      
      $ mount -t nfs -o nolock 10.0.0.1:/tmp/test /mnt/test/
      $ mount -t nfs -o remount /mnt/test/
      mount: mounting 10.0.0.1:/tmp/test on /mnt/test failed: Invalid argument
      
      For remounts, the nfs server address and port are populated by
      nfs_init_fs_context and later overwritten with 0x00 bytes by
      nfs23_parse_monolithic. The remount then fails as the server address is
      invalid.
      
      Fix this by not overwriting nfs server info in nfs23_parse_monolithic if
      we're doing a remount.
      
      Fixes: f2aedb71
      
       ("NFS: Add fs_context support.")
      Signed-off-by: default avatarMartin Kaiser <martin@kaiser.cx>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      99530e42
    • Benjamin Coddington's avatar
      NFSv4: Fixup smatch warning for ambiguous return · b72a3a25
      Benjamin Coddington authored
      [ Upstream commit 37ffe065
      
       ]
      
      Dan Carpenter reports smatch warning for nfs4_try_migration() when a memory
      allocation failure results in a zero return value.  In this case, a
      transient allocation failure error will likely be retried the next time the
      server responds with NFS4ERR_MOVED.
      
      We can fixup the smatch warning with a small refactor: attempt all three
      allocations before testing and returning on a failure.
      
      Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Fixes: c3ed2227
      
       ("NFSv4: Fix free of uninitialized nfs4_label on referral lookup.")
      Signed-off-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Reviewed-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Reviewed-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b72a3a25
    • Shenghao Ding's avatar
      ASoC: tas2552: Add TX path for capturing AUDIO-OUT data · 7995b66f
      Shenghao Ding authored
      [ Upstream commit 7078ac4f ]
      
      TAS2552 is a Smartamp with I/V sense data, add TX path
      to support capturing I/V data.
      
      Fixes: 38803ce7
      
       ("ASoC: codecs: tas*: merge .digital_mute() into .mute_stream()")
      Signed-off-by: default avatarShenghao Ding <shenghao-ding@ti.com>
      Link: https://msgid.link/r/20240518033515.866-1-shenghao-ding@ti.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7995b66f
    • Ryosuke Yasuoka's avatar
      nfc: nci: Fix uninit-value in nci_rx_work · e8c8e0d0
      Ryosuke Yasuoka authored
      [ Upstream commit e4a87abf ]
      
      syzbot reported the following uninit-value access issue [1]
      
      nci_rx_work() parses received packet from ndev->rx_q. It should be
      validated header size, payload size and total packet size before
      processing the packet. If an invalid packet is detected, it should be
      silently discarded.
      
      Fixes: d24b0353
      
       ("nfc: nci: Fix uninit-value in nci_dev_up and nci_ntf_packet")
      Reported-and-tested-by: default avatar <syzbot+d7b4dc6cd50410152534@syzkaller.appspotmail.com>
      Closes: https://syzkaller.appspot.com/bug?extid=d7b4dc6cd50410152534 [1]
      Signed-off-by: default avatarRyosuke Yasuoka <ryasuoka@redhat.com>
      Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e8c8e0d0
    • Taehee Yoo's avatar
      selftests: net: kill smcrouted in the cleanup logic in amt.sh · 47c5707d
      Taehee Yoo authored
      [ Upstream commit cc563e74 ]
      
      The amt.sh requires smcrouted for multicasting routing.
      So, it starts smcrouted before forwarding tests.
      It must be stopped after all tests, but it isn't.
      
      To fix this issue, it kills smcrouted in the cleanup logic.
      
      Fixes: c08e8bae
      
       ("selftests: add amt interface selftest script")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      47c5707d
    • Andrea Mayer's avatar
      ipv6: sr: fix missing sk_buff release in seg6_input_core · 8f1fc3b8
      Andrea Mayer authored
      [ Upstream commit 5447f970 ]
      
      The seg6_input() function is responsible for adding the SRH into a
      packet, delegating the operation to the seg6_input_core(). This function
      uses the skb_cow_head() to ensure that there is sufficient headroom in
      the sk_buff for accommodating the link-layer header.
      In the event that the skb_cow_header() function fails, the
      seg6_input_core() catches the error but it does not release the sk_buff,
      which will result in a memory leak.
      
      This issue was introduced in commit af3b5158 ("ipv6: sr: fix BUG due
      to headroom too small after SRH push") and persists even after commit
      7a3f5b0d ("netfilter: add netfilter hooks to SRv6 data plane"),
      where the entire seg6_input() code was refactored to deal with netfilter
      hooks.
      
      The proposed patch addresses the identified memory leak by requiring the
      seg6_input_core() function to release the sk_buff in the event that
      skb_cow_head() fails.
      
      Fixes: af3b5158
      
       ("ipv6: sr: fix BUG due to headroom too small after SRH push")
      Signed-off-by: default avatarAndrea Mayer <andrea.mayer@uniroma2.it>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8f1fc3b8
    • Florian Fainelli's avatar
      net: Always descend into dsa/ folder with CONFIG_NET_DSA enabled · d2223fd3
      Florian Fainelli authored
      [ Upstream commit b1fa60ec ]
      
      Stephen reported that he was unable to get the dsa_loop driver to get
      probed, and the reason ended up being because he had CONFIG_FIXED_PHY=y
      in his kernel configuration. As Masahiro explained it:
      
        "obj-m += dsa/" means everything under dsa/ must be modular.
      
        If there is a built-in object under dsa/ with CONFIG_NET_DSA=m,
        you cannot do  "obj-$(CONFIG_NET_DSA) += dsa/".
      
        You need to change it back to "obj-y += dsa/".
      
      This was the case here whereby CONFIG_NET_DSA=m, and so the
      obj-$(CONFIG_FIXED_PHY) += dsa_loop_bdinfo.o rule is not executed and
      the DSA loop mdio_board info structure is not registered with the
      kernel, and eventually the device is simply not found.
      
      To preserve the intention of the original commit of limiting the amount
      of folder descending, conditionally descend into drivers/net/dsa when
      CONFIG_NET_DSA is enabled.
      
      Fixes: 227d7206
      
       ("dsa: simplify Kconfig symbols and dependencies")
      Reported-by: default avatarStephen Langstaff <stephenlangstaff1@gmail.com>
      Signed-off-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
      Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: default avatarAlexander Lobakin <aleksander.lobakin@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d2223fd3
    • Masahiro Yamada's avatar
      x86/kconfig: Select ARCH_WANT_FRAME_POINTERS again when UNWINDER_FRAME_POINTER=y · fde26c4a
      Masahiro Yamada authored
      [ Upstream commit 66ee3636 ]
      
      It took me some time to understand the purpose of the tricky code at
      the end of arch/x86/Kconfig.debug.
      
      Without it, the following would be shown:
      
        WARNING: unmet direct dependencies detected for FRAME_POINTER
      
      because
      
        81d38719 ("x86/kconfig: Consolidate unwinders into multiple choice selection")
      
      removed 'select ARCH_WANT_FRAME_POINTERS'.
      
      The correct and more straightforward approach should have been to move
      it where 'select FRAME_POINTER' is located.
      
      Several architectures properly handle the conditional selection of
      ARCH_WANT_FRAME_POINTERS. For example, 'config UNWINDER_FRAME_POINTER'
      in arch/arm/Kconfig.debug.
      
      Fixes: 81d38719
      
       ("x86/kconfig: Consolidate unwinders into multiple choice selection")
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
      Link: https://lore.kernel.org/r/20240204122003.53795-1-masahiroy@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fde26c4a
    • Namhyung Kim's avatar
      perf/arm-dmc620: Fix lockdep assert in ->event_init() · f23f182b
      Namhyung Kim authored
      [ Upstream commit a4c5a457
      
       ]
      
      for_each_sibling_event() checks leader's ctx but it doesn't have the ctx
      yet if it's the leader.  Like in perf_event_validate_size(), we should
      skip checking siblings in that case.
      
      Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
      Fixes: f3c0eba2
      
       ("perf: Add a few assertions")
      Reported-by: default avatarGreg Thelen <gthelen@google.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Tuan Phan <tuanphan@os.amperecomputing.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Reviewed-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Link: https://lore.kernel.org/r/20240514180050.182454-1-namhyung@kernel.org
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f23f182b
    • Matti Vaittinen's avatar
      regulator: bd71828: Don't overwrite runtime voltages · e9774d15
      Matti Vaittinen authored
      [ Upstream commit 0f9f7c63
      
       ]
      
      Some of the regulators on the BD71828 have common voltage setting for
      RUN/SUSPEND/IDLE/LPSR states. The enable control can be set for each
      state though.
      
      The driver allows setting the voltage values for these states via
      device-tree. As a side effect, setting the voltages for
      SUSPEND/IDLE/LPSR will also change the RUN level voltage which is not
      desired and can break the system.
      
      The comment in code reflects this behaviour, but it is likely to not
      make people any happier. The right thing to do is to allow setting the
      enable/disable state at SUSPEND/IDLE/LPSR via device-tree, but to
      disallow setting state specific voltages for those regulators.
      
      BUCK1 is a bit different. It only shares the SUSPEND and LPSR state
      voltages. The former behaviour of allowing to silently overwrite the
      SUSPEND state voltage by LPSR state voltage is also changed here so that
      the SUSPEND voltage is prioritized over LPSR voltage.
      
      Prevent setting PMIC state specific voltages for regulators which do not
      support it.
      
      Signed-off-by: default avatarMatti Vaittinen <mazziesaccount@gmail.com>
      Fixes: 522498f8
      
       ("regulator: bd71828: Basic support for ROHM bd71828 PMIC regulators")
      Link: https://msgid.link/r/e1883ae1e3ae5668f1030455d4750923561f3d68.1715848512.git.mazziesaccount@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e9774d15
    • Hsin-Te Yuan's avatar
      ASoC: mediatek: mt8192: fix register configuration for tdm · 60c406bb
      Hsin-Te Yuan authored
      [ Upstream commit a85ed162 ]
      
      For DSP_A, data is a BCK cycle behind LRCK trigger edge. For DSP_B, this
      delay doesn't exist. Fix the delay configuration to match the standard.
      
      Fixes: 52fcd654
      
       ("ASoC: mediatek: mt8192: support tdm in platform driver")
      Signed-off-by: default avatarHsin-Te Yuan <yuanhsinte@chromium.org>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Reviewed-by: default avatarChen-Yu Tsai <wenst@chromium.org>
      Link: https://lore.kernel.org/r/20240509-8192-tdm-v1-1-530b54645763@chromium.org
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      60c406bb
    • Richard Fitzgerald's avatar
      ALSA: hda/cs_dsp_ctl: Use private_free for control cleanup · 191dc1b2
      Richard Fitzgerald authored
      [ Upstream commit 172811e3
      
       ]
      
      Use the control private_free callback to free the associated data
      block. This ensures that the memory won't leak, whatever way the
      control gets destroyed.
      
      The original implementation didn't actually remove the ALSA
      controls in hda_cs_dsp_control_remove(). It only freed the internal
      tracking structure. This meant it was possible to remove/unload the
      amp driver while leaving its ALSA controls still present in the
      soundcard. Obviously attempting to access them could cause segfaults
      or at least dereferencing stale pointers.
      
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: 3233b978
      
       ("ALSA: hda: hda_cs_dsp_ctl: Add Library to support CS_DSP ALSA controls")
      Link: https://lore.kernel.org/r/20240508095627.44476-1-rf@opensource.cirrus.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      191dc1b2
    • Zhu Yanjun's avatar
      null_blk: Fix the WARNING: modpost: missing MODULE_DESCRIPTION() · 1056e520
      Zhu Yanjun authored
      [ Upstream commit 9e6727f8 ]
      
      No functional changes intended.
      
      Fixes: f2298c04
      
       ("null_blk: multi queue aware block test driver")
      Signed-off-by: default avatarZhu Yanjun <yanjun.zhu@linux.dev>
      Reviewed-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
      Link: https://lore.kernel.org/r/20240506075538.6064-1-yanjun.zhu@linux.dev
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1056e520
    • Konrad Dybcio's avatar
      drm/msm/a6xx: Avoid a nullptr dereference when speedbin setting fails · 247849ee
      Konrad Dybcio authored
      [ Upstream commit 46d4efcc ]
      
      Calling a6xx_destroy() before adreno_gpu_init() leads to a null pointer
      dereference on:
      
      msm_gpu_cleanup() : platform_set_drvdata(gpu->pdev, NULL);
      
      as gpu->pdev is only assigned in:
      
      a6xx_gpu_init()
      |_ adreno_gpu_init
          |_ msm_gpu_init()
      
      Instead of relying on handwavy null checks down the cleanup chain,
      explicitly de-allocate the LLC data and free a6xx_gpu instead.
      
      Fixes: 76efc245
      
       ("drm/msm/gpu: Fix crash during system suspend after unbind")
      Signed-off-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
      Patchwork: https://patchwork.freedesktop.org/patch/588919/
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      247849ee
    • Rob Clark's avatar
      drm/msm: Enable clamp_to_idle for 7c3 · 7904aee9
      Rob Clark authored
      [ Upstream commit 2c1b7748
      
       ]
      
      This was overlooked.
      
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarChia-I Wu <olvaffe@gmail.com>
      Patchwork: https://patchwork.freedesktop.org/patch/511693/
      Link: https://lore.kernel.org/r/20221115155535.1615278-1-robdclark@gmail.com
      Stable-dep-of: 46d4efcc
      
       ("drm/msm/a6xx: Avoid a nullptr dereference when speedbin setting fails")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7904aee9
    • Luca Ceresoli's avatar
      Revert "drm/bridge: ti-sn65dsi83: Fix enable error path" · ac9de7b2
      Luca Ceresoli authored
      [ Upstream commit ad81feb5 ]
      
      This reverts commit 8a91b29f.
      
      The regulator_disable() added by the original commit solves one kind of
      regulator imbalance but adds another one as it allows the regulator to be
      disabled one more time than it is enabled in the following scenario:
      
       1. Start video pipeline -> sn65dsi83_atomic_pre_enable -> regulator_enable
       2. PLL lock fails -> regulator_disable
       3. Stop video pipeline -> sn65dsi83_atomic_disable -> regulator_disable
      
      The reason is clear from the code flow, which looks like this (after
      removing unrelated code):
      
        static void sn65dsi83_atomic_pre_enable()
        {
            regulator_enable(ctx->vcc);
      
            if (PLL failed locking) {
                regulator_disable(ctx->vcc);  <---- added by patch being reverted
                return;
            }
        }
      
        static void sn65dsi83_atomic_disable()
        {
            regulator_disable(ctx->vcc);
        }
      
      The use case for introducing the additional regulator_disable() was
      removing the module for debugging (see link below for the discussion). If
      the module is removed after a .atomic_pre_enable, i.e. with an active
      pipeline from the DRM point of view, .atomic_disable is not called and thus
      the regulator would not be disabled.
      
      According to the discussion however there is no actual use case for
      removing the module with an active pipeline, except for
      debugging/development.
      
      On the other hand, the occurrence of a PLL lock failure is possible due to
      any physical reason (e.g. a temporary hardware failure for electrical
      reasons) so handling it gracefully should be supported. As there is no way
      for .atomic[_pre]_enable to report an error to the core, the only clean way
      to support it is calling regulator_disabled() only in .atomic_disable,
      unconditionally, as it was before.
      
      Link: https://lore.kernel.org/all/15244220.uLZWGnKmhe@steina-w/
      Fixes: 8a91b29f
      
       ("drm/bridge: ti-sn65dsi83: Fix enable error path")
      Reviewed-by: default avatarAlexander Stein <alexander.stein@ew.tq-group.com>
      Signed-off-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
      Signed-off-by: default avatarRobert Foss <rfoss@kernel.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240426122259.46808-1-luca.ceresoli@bootlin.com
      (cherry picked from commit 2940ee03b23281071620dda1d790cd644dabd394)
      Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ac9de7b2
    • Hans Verkuil's avatar
      media: cec: core: avoid confusing "transmit timed out" message · 3f56c18a
      Hans Verkuil authored
      [ Upstream commit cbe49997
      
       ]
      
      If, when waiting for a transmit to finish, the wait is interrupted,
      then you might get a "transmit timed out" message, even though the
      transmit was interrupted and did not actually time out.
      
      Set transmit_in_progress_aborted to true if the
      wait_for_completion_killable() call was interrupted and ensure
      that the transmit is properly marked as ABORTED.
      
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Reported-by: default avatarYang, Chenyuan <cy54@illinois.edu>
      Closes: https://lore.kernel.org/linux-media/PH7PR11MB57688E64ADE4FE82E658D86DA09EA@PH7PR11MB5768.namprd11.prod.outlook.com/
      Fixes: 590a8e56
      
       ("media: cec: abort if the current transmit was canceled")
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3f56c18a
    • Hans Verkuil's avatar
      media: cec: core: avoid recursive cec_claim_log_addrs · 302077d2
      Hans Verkuil authored
      [ Upstream commit 47c82aac
      
       ]
      
      Keep track if cec_claim_log_addrs() is running, and return -EBUSY
      if it is when calling CEC_ADAP_S_LOG_ADDRS.
      
      This prevents a case where cec_claim_log_addrs() could be called
      while it was still in progress.
      
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Reported-by: default avatarYang, Chenyuan <cy54@illinois.edu>
      Closes: https://lore.kernel.org/linux-media/PH7PR11MB57688E64ADE4FE82E658D86DA09EA@PH7PR11MB5768.namprd11.prod.outlook.com/
      Fixes: ca684386
      
       ("[media] cec: add HDMI CEC framework (api)")
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      302077d2
    • Hans Verkuil's avatar
      media: cec: cec-api: add locking in cec_release() · 6d6ddabc
      Hans Verkuil authored
      [ Upstream commit 42bcaaca
      
       ]
      
      When cec_release() uses fh->msgs it has to take fh->lock,
      otherwise the list can get corrupted.
      
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Reported-by: default avatarYang, Chenyuan <cy54@illinois.edu>
      Closes: https://lore.kernel.org/linux-media/PH7PR11MB57688E64ADE4FE82E658D86DA09EA@PH7PR11MB5768.namprd11.prod.outlook.com/
      Fixes: ca684386
      
       ("[media] cec: add HDMI CEC framework (api)")
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6d6ddabc
    • Hans Verkuil's avatar
      media: cec: cec-adap: always cancel work in cec_transmit_msg_fh · 1e1e7a6e
      Hans Verkuil authored
      [ Upstream commit 9fe28168
      
       ]
      
      Do not check for !data->completed, just always call
      cancel_delayed_work_sync(). This fixes a small race condition.
      
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Reported-by: default avatarYang, Chenyuan <cy54@illinois.edu>
      Closes: https://lore.kernel.org/linux-media/PH7PR11MB57688E64ADE4FE82E658D86DA09EA@PH7PR11MB5768.namprd11.prod.outlook.com/
      Fixes: 490d84f6
      
       ("media: cec: forgot to cancel delayed work")
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1e1e7a6e
    • Randy Dunlap's avatar
      media: sunxi: a83-mips-csi2: also select GENERIC_PHY · a19d05e1
      Randy Dunlap authored
      [ Upstream commit 82370261 ]
      
      When selecting GENERIC_PHY_MIPI_DPHY, also select GENERIC_PHY to
      prevent kconfig warnings:
      
      WARNING: unmet direct dependencies detected for GENERIC_PHY_MIPI_DPHY
        Depends on [n]: GENERIC_PHY [=n]
        Selected by [y]:
        - VIDEO_SUN8I_A83T_MIPI_CSI2 [=y] && MEDIA_SUPPORT [=y] && MEDIA_PLATFORM_SUPPORT [=y] && MEDIA_PLATFORM_DRIVERS [=y] && V4L_PLATFORM_DRIVERS [=y] && VIDEO_DEV [=y] && (ARCH_SUNXI || COMPILE_TEST [=y]) && PM [=y] && COMMON_CLK [=y] && RESET_CONTROLLER [=y]
      
      Fixes: 94d7fd96
      
       ("media: sunxi: Depend on GENERIC_PHY_MIPI_DPHY")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Closes: https://lore.kernel.org/r/ZQ/WS8HC1A3F0Qn8@rli9-mobl
      Link: https://lore.kernel.org/linux-media/20230927040438.5589-1-rdunlap@infradead.org
      
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a19d05e1
    • Tiwei Bie's avatar
      um: Fix the declaration of kasan_map_memory · 1ffee510
      Tiwei Bie authored
      [ Upstream commit 6a85e34c ]
      
      Make it match its definition (size_t vs unsigned long). And declare
      it in a shared header to fix the -Wmissing-prototypes warning, as it
      is defined in the user code and called in the kernel code.
      
      Fixes: 5b301409
      
       ("UML: add support for KASAN under x86_64")
      Signed-off-by: default avatarTiwei Bie <tiwei.btw@antgroup.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1ffee510
    • Tiwei Bie's avatar
      um: Fix the -Wmissing-prototypes warning for get_thread_reg · 68bc383a
      Tiwei Bie authored
      [ Upstream commit 3144013e ]
      
      The get_thread_reg function is defined in the user code, and is
      called by the kernel code. It should be declared in a shared header.
      
      Fixes: dbba7f70
      
       ("um: stop polluting the namespace with registers.h contents")
      Signed-off-by: default avatarTiwei Bie <tiwei.btw@antgroup.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      68bc383a
    • Tiwei Bie's avatar
      um: Fix the -Wmissing-prototypes warning for __switch_mm · b6eda6de
      Tiwei Bie authored
      [ Upstream commit 2cbade17 ]
      
      The __switch_mm function is defined in the user code, and is called
      by the kernel code. It should be declared in a shared header.
      
      Fixes: 4dc706c2
      
       ("um: take um_mmu.h to asm/mmu.h, clean asm/mmu_context.h a bit")
      Signed-off-by: default avatarTiwei Bie <tiwei.btw@antgroup.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b6eda6de
    • Shrikanth Hegde's avatar
      powerpc/pseries: Add failure related checks for h_get_mpp and h_get_ppp · 1d168e68
      Shrikanth Hegde authored
      [ Upstream commit 6d434163
      
       ]
      
      Couple of Minor fixes:
      
      - hcall return values are long. Fix that for h_get_mpp, h_get_ppp and
      parse_ppp_data
      
      - If hcall fails, values set should be at-least zero. It shouldn't be
      uninitialized values. Fix that for h_get_mpp and h_get_ppp
      
      Signed-off-by: default avatarShrikanth Hegde <sshegde@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20240412092047.455483-3-sshegde@linux.ibm.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1d168e68
    • Dongliang Mu's avatar
      media: flexcop-usb: fix sanity check of bNumEndpoints · 64c0cbc5
      Dongliang Mu authored
      [ Upstream commit f62dc8f6 ]
      
      Commit d725d20e ("media: flexcop-usb: sanity checking of endpoint type
      ") adds a sanity check for endpoint[1], but fails to modify the sanity
      check of bNumEndpoints.
      
      Fix this by modifying the sanity check of bNumEndpoints to 2.
      
      Link: https://lore.kernel.org/linux-media/20220602055027.849014-1-dzm91@hust.edu.cn
      Fixes: d725d20e
      
       ("media: flexcop-usb: sanity checking of endpoint type")
      Signed-off-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      64c0cbc5