Skip to content
  1. Feb 23, 2022
    • Kamal Dasu's avatar
      mtd: rawnand: brcmnand: Refactored code to introduce helper functions · dc8437ed
      Kamal Dasu authored
      [ Upstream commit 3c7c1e45
      
       ]
      
      Refactored NAND ECC and CMD address configuration code to use helper
      functions.
      
      Signed-off-by: default avatarKamal Dasu <kdasu.kdev@gmail.com>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dc8437ed
    • Max Kellermann's avatar
      lib/iov_iter: initialize "flags" in new pipe_buffer · a162b11c
      Max Kellermann authored
      commit 9d2231c5 upstream.
      
      The functions copy_page_to_iter_pipe() and push_pipe() can both
      allocate a new pipe_buffer, but the "flags" member initializer is
      missing.
      
      Fixes: 241699cd
      
       ("new iov_iter flavour: pipe-backed")
      To: Alexander Viro <viro@zeniv.linux.org.uk>
      To: linux-fsdevel@vger.kernel.org
      To: linux-kernel@vger.kernel.org
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMax Kellermann <max.kellermann@ionos.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a162b11c
    • Rafał Miłecki's avatar
      i2c: brcmstb: fix support for DSL and CM variants · 0b296fa5
      Rafał Miłecki authored
      commit 834cea3a upstream.
      
      DSL and CM (Cable Modem) support 8 B max transfer size and have a custom
      DT binding for that reason. This driver was checking for a wrong
      "compatible" however which resulted in an incorrect setup.
      
      Fixes: e2e5a2c6
      
       ("i2c: brcmstb: Adding support for CM and DSL SoCs")
      Signed-off-by: default avatarRafał Miłecki <rafal@milecki.pl>
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0b296fa5
    • 蒋家盛's avatar
      dmaengine: sh: rcar-dmac: Check for error num after setting mask · c64e2664
      蒋家盛 authored
      commit 2d21543e upstream.
      
      Because of the possible failure of the dma_supported(), the
      dma_set_mask_and_coherent() may return error num.
      Therefore, it should be better to check it and return the error if
      fails.
      
      Fixes: dc312349
      
       ("dmaengine: rcar-dmac: Widen DMA mask to 40 bits")
      Signed-off-by: default avatarJiasheng Jiang <jiasheng@iscas.ac.cn>
      Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Link: https://lore.kernel.org/r/20220106030939.2644320-1-jiasheng@iscas.ac.cn
      
      
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c64e2664
    • Eric Dumazet's avatar
      net: sched: limit TC_ACT_REPEAT loops · 2170a3d1
      Eric Dumazet authored
      commit 5740d068 upstream.
      
      We have been living dangerously, at the mercy of malicious users,
      abusing TC_ACT_REPEAT, as shown by this syzpot report [1].
      
      Add an arbitrary limit (32) to the number of times an action can
      return TC_ACT_REPEAT.
      
      v2: switch the limit to 32 instead of 10.
          Use net_warn_ratelimited() instead of pr_err_once().
      
      [1] (C repro available on demand)
      
      rcu: INFO: rcu_preempt self-detected stall on CPU
      rcu:    1-...!: (10500 ticks this GP) idle=021/1/0x4000000000000000 softirq=5592/5592 fqs=0
              (t=10502 jiffies g=5305 q=190)
      rcu: rcu_preempt kthread timer wakeup didn't happen for 10502 jiffies! g5305 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x402
      rcu:    Possible timer handling issue on cpu=0 timer-softirq=3527
      rcu: rcu_preempt kthread starved for 10505 jiffies! g5305 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x402 ->cpu=0
      rcu:    Unless rcu_preempt kthread gets sufficient CPU time, OOM is now expected behavior.
      rcu: RCU grace-period kthread stack dump:
      task:rcu_preempt     state:I stack:29344 pid:   14 ppid:     2 flags:0x00004000
      Call Trace:
       <TASK>
       context_switch kernel/sched/core.c:4986 [inline]
       __schedule+0xab2/0x4db0 kernel/sched/core.c:6295
       schedule+0xd2/0x260 kernel/sched/core.c:6368
       schedule_timeout+0x14a/0x2a0 kernel/time/timer.c:1881
       rcu_gp_fqs_loop+0x186/0x810 kernel/rcu/tree.c:1963
       rcu_gp_kthread+0x1de/0x320 kernel/rcu/tree.c:2136
       kthread+0x2e9/0x3a0 kernel/kthread.c:377
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
       </TASK>
      rcu: Stack dump where RCU GP kthread last ran:
      Sending NMI from CPU 1 to CPUs 0:
      NMI backtrace for cpu 0
      CPU: 0 PID: 3646 Comm: syz-executor358 Not tainted 5.17.0-rc3-syzkaller-00149-gbf8e59fd315f #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      RIP: 0010:rep_nop arch/x86/include/asm/vdso/processor.h:13 [inline]
      RIP: 0010:cpu_relax arch/x86/include/asm/vdso/processor.h:18 [inline]
      RIP: 0010:pv_wait_head_or_lock kernel/locking/qspinlock_paravirt.h:437 [inline]
      RIP: 0010:__pv_queued_spin_lock_slowpath+0x3b8/0xb40 kernel/locking/qspinlock.c:508
      Code: 48 89 eb c6 45 01 01 41 bc 00 80 00 00 48 c1 e9 03 83 e3 07 41 be 01 00 00 00 48 b8 00 00 00 00 00 fc ff df 4c 8d 2c 01 eb 0c <f3> 90 41 83 ec 01 0f 84 72 04 00 00 41 0f b6 45 00 38 d8 7f 08 84
      RSP: 0018:ffffc9000283f1b0 EFLAGS: 00000206
      RAX: 0000000000000003 RBX: 0000000000000000 RCX: 1ffff1100fc0071e
      RDX: 0000000000000001 RSI: 0000000000000201 RDI: 0000000000000000
      RBP: ffff88807e0038f0 R08: 0000000000000001 R09: ffffffff8ffbf9ff
      R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000004c1e
      R13: ffffed100fc0071e R14: 0000000000000001 R15: ffff8880b9c3aa80
      FS:  00005555562bf300(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007ffdbfef12b8 CR3: 00000000723c2000 CR4: 00000000003506f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <TASK>
       pv_queued_spin_lock_slowpath arch/x86/include/asm/paravirt.h:591 [inline]
       queued_spin_lock_slowpath arch/x86/include/asm/qspinlock.h:51 [inline]
       queued_spin_lock include/asm-generic/qspinlock.h:85 [inline]
       do_raw_spin_lock+0x200/0x2b0 kernel/locking/spinlock_debug.c:115
       spin_lock_bh include/linux/spinlock.h:354 [inline]
       sch_tree_lock include/net/sch_generic.h:610 [inline]
       sch_tree_lock include/net/sch_generic.h:605 [inline]
       prio_tune+0x3b9/0xb50 net/sched/sch_prio.c:211
       prio_init+0x5c/0x80 net/sched/sch_prio.c:244
       qdisc_create.constprop.0+0x44a/0x10f0 net/sched/sch_api.c:1253
       tc_modify_qdisc+0x4c5/0x1980 net/sched/sch_api.c:1660
       rtnetlink_rcv_msg+0x413/0xb80 net/core/rtnetlink.c:5594
       netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494
       netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
       netlink_unicast+0x539/0x7e0 net/netlink/af_netlink.c:1343
       netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1919
       sock_sendmsg_nosec net/socket.c:705 [inline]
       sock_sendmsg+0xcf/0x120 net/socket.c:725
       ____sys_sendmsg+0x6e8/0x810 net/socket.c:2413
       ___sys_sendmsg+0xf3/0x170 net/socket.c:2467
       __sys_sendmsg+0xe5/0x1b0 net/socket.c:2496
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      RIP: 0033:0x7f7ee98aae99
      Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 41 15 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007ffdbfef12d8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 00007ffdbfef1300 RCX: 00007f7ee98aae99
      RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000003
      RBP: 0000000000000000 R08: 000000000000000d R09: 000000000000000d
      R10: 000000000000000d R11: 0000000000000246 R12: 00007ffdbfef12f0
      R13: 00000000000f4240 R14: 000000000004ca47 R15: 00007ffdbfef12e4
       </TASK>
      INFO: NMI handler (nmi_cpu_backtrace_handler) took too long to run: 2.293 msecs
      NMI backtrace for cpu 1
      CPU: 1 PID: 3260 Comm: kworker/1:3 Not tainted 5.17.0-rc3-syzkaller-00149-gbf8e59fd315f #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Workqueue: mld mld_ifc_work
      Call Trace:
       <IRQ>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
       nmi_cpu_backtrace.cold+0x47/0x144 lib/nmi_backtrace.c:111
       nmi_trigger_cpumask_backtrace+0x1b3/0x230 lib/nmi_backtrace.c:62
       trigger_single_cpu_backtrace include/linux/nmi.h:164 [inline]
       rcu_dump_cpu_stacks+0x25e/0x3f0 kernel/rcu/tree_stall.h:343
       print_cpu_stall kernel/rcu/tree_stall.h:604 [inline]
       check_cpu_stall kernel/rcu/tree_stall.h:688 [inline]
       rcu_pending kernel/rcu/tree.c:3919 [inline]
       rcu_sched_clock_irq.cold+0x5c/0x759 kernel/rcu/tree.c:2617
       update_process_times+0x16d/0x200 kernel/time/timer.c:1785
       tick_sched_handle+0x9b/0x180 kernel/time/tick-sched.c:226
       tick_sched_timer+0x1b0/0x2d0 kernel/time/tick-sched.c:1428
       __run_hrtimer kernel/time/hrtimer.c:1685 [inline]
       __hrtimer_run_queues+0x1c0/0xe50 kernel/time/hrtimer.c:1749
       hrtimer_interrupt+0x31c/0x790 kernel/time/hrtimer.c:1811
       local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1086 [inline]
       __sysvec_apic_timer_interrupt+0x146/0x530 arch/x86/kernel/apic/apic.c:1103
       sysvec_apic_timer_interrupt+0x8e/0xc0 arch/x86/kernel/apic/apic.c:1097
       </IRQ>
       <TASK>
       asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:638
      RIP: 0010:__sanitizer_cov_trace_const_cmp4+0xc/0x70 kernel/kcov.c:286
      Code: 00 00 00 48 89 7c 30 e8 48 89 4c 30 f0 4c 89 54 d8 20 48 89 10 5b c3 0f 1f 80 00 00 00 00 41 89 f8 bf 03 00 00 00 4c 8b 14 24 <89> f1 65 48 8b 34 25 00 70 02 00 e8 14 f9 ff ff 84 c0 74 4b 48 8b
      RSP: 0018:ffffc90002c5eea8 EFLAGS: 00000246
      RAX: 0000000000000007 RBX: ffff88801c625800 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
      RBP: ffff8880137d3100 R08: 0000000000000000 R09: 0000000000000000
      R10: ffffffff874fcd88 R11: 0000000000000000 R12: ffff88801d692dc0
      R13: ffff8880137d3104 R14: 0000000000000000 R15: ffff88801d692de8
       tcf_police_act+0x358/0x11d0 net/sched/act_police.c:256
       tcf_action_exec net/sched/act_api.c:1049 [inline]
       tcf_action_exec+0x1a6/0x530 net/sched/act_api.c:1026
       tcf_exts_exec include/net/pkt_cls.h:326 [inline]
       route4_classify+0xef0/0x1400 net/sched/cls_route.c:179
       __tcf_classify net/sched/cls_api.c:1549 [inline]
       tcf_classify+0x3e8/0x9d0 net/sched/cls_api.c:1615
       prio_classify net/sched/sch_prio.c:42 [inline]
       prio_enqueue+0x3a7/0x790 net/sched/sch_prio.c:75
       dev_qdisc_enqueue+0x40/0x300 net/core/dev.c:3668
       __dev_xmit_skb net/core/dev.c:3756 [inline]
       __dev_queue_xmit+0x1f61/0x3660 net/core/dev.c:4081
       neigh_hh_output include/net/neighbour.h:533 [inline]
       neigh_output include/net/neighbour.h:547 [inline]
       ip_finish_output2+0x14dc/0x2170 net/ipv4/ip_output.c:228
       __ip_finish_output net/ipv4/ip_output.c:306 [inline]
       __ip_finish_output+0x396/0x650 net/ipv4/ip_output.c:288
       ip_finish_output+0x32/0x200 net/ipv4/ip_output.c:316
       NF_HOOK_COND include/linux/netfilter.h:296 [inline]
       ip_output+0x196/0x310 net/ipv4/ip_output.c:430
       dst_output include/net/dst.h:451 [inline]
       ip_local_out+0xaf/0x1a0 net/ipv4/ip_output.c:126
       iptunnel_xmit+0x628/0xa50 net/ipv4/ip_tunnel_core.c:82
       geneve_xmit_skb drivers/net/geneve.c:966 [inline]
       geneve_xmit+0x10c8/0x3530 drivers/net/geneve.c:1077
       __netdev_start_xmit include/linux/netdevice.h:4683 [inline]
       netdev_start_xmit include/linux/netdevice.h:4697 [inline]
       xmit_one net/core/dev.c:3473 [inline]
       dev_hard_start_xmit+0x1eb/0x920 net/core/dev.c:3489
       __dev_queue_xmit+0x2985/0x3660 net/core/dev.c:4116
       neigh_hh_output include/net/neighbour.h:533 [inline]
       neigh_output include/net/neighbour.h:547 [inline]
       ip6_finish_output2+0xf7a/0x14f0 net/ipv6/ip6_output.c:126
       __ip6_finish_output net/ipv6/ip6_output.c:191 [inline]
       __ip6_finish_output+0x61e/0xe90 net/ipv6/ip6_output.c:170
       ip6_finish_output+0x32/0x200 net/ipv6/ip6_output.c:201
       NF_HOOK_COND include/linux/netfilter.h:296 [inline]
       ip6_output+0x1e4/0x530 net/ipv6/ip6_output.c:224
       dst_output include/net/dst.h:451 [inline]
       NF_HOOK include/linux/netfilter.h:307 [inline]
       NF_HOOK include/linux/netfilter.h:301 [inline]
       mld_sendpack+0x9a3/0xe40 net/ipv6/mcast.c:1826
       mld_send_cr net/ipv6/mcast.c:2127 [inline]
       mld_ifc_work+0x71c/0xdc0 net/ipv6/mcast.c:2659
       process_one_work+0x9ac/0x1650 kernel/workqueue.c:2307
       worker_thread+0x657/0x1110 kernel/workqueue.c:2454
       kthread+0x2e9/0x3a0 kernel/kthread.c:377
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
       </TASK>
      ----------------
      Code disassembly (best guess):
         0:   48 89 eb                mov    %rbp,%rbx
         3:   c6 45 01 01             movb   $0x1,0x1(%rbp)
         7:   41 bc 00 80 00 00       mov    $0x8000,%r12d
         d:   48 c1 e9 03             shr    $0x3,%rcx
        11:   83 e3 07                and    $0x7,%ebx
        14:   41 be 01 00 00 00       mov    $0x1,%r14d
        1a:   48 b8 00 00 00 00 00    movabs $0xdffffc0000000000,%rax
        21:   fc ff df
        24:   4c 8d 2c 01             lea    (%rcx,%rax,1),%r13
        28:   eb 0c                   jmp    0x36
      * 2a:   f3 90                   pause <-- trapping instruction
        2c:   41 83 ec 01             sub    $0x1,%r12d
        30:   0f 84 72 04 00 00       je     0x4a8
        36:   41 0f b6 45 00          movzbl 0x0(%r13),%eax
        3b:   38 d8                   cmp    %bl,%al
        3d:   7f 08                   jg     0x47
        3f:   84                      .byte 0x84
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Link: https://lore.kernel.org/r/20220215235305.3272331-1-eric.dumazet@gmail.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2170a3d1
    • Eliav Farber's avatar
      EDAC: Fix calculation of returned address and next offset in edac_align_ptr() · 4feddbe5
      Eliav Farber authored
      commit f8efca92 upstream.
      
      Do alignment logic properly and use the "ptr" local variable for
      calculating the remainder of the alignment.
      
      This became an issue because struct edac_mc_layer has a size that is not
      zero modulo eight, and the next offset that was prepared for the private
      data was unaligned, causing an alignment exception.
      
      The patch in Fixes: which broke this actually wanted to "what we
      actually care about is the alignment of the actual pointer that's about
      to be returned." But it didn't check that alignment.
      
      Use the correct variable "ptr" for that.
      
        [ bp: Massage commit message. ]
      
      Fixes: 8447c4d1
      
       ("edac: Do alignment logic properly in edac_align_ptr()")
      Signed-off-by: default avatarEliav Farber <farbere@amazon.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220113100622.12783-2-farbere@amazon.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4feddbe5
    • Trond Myklebust's avatar
      NFS: LOOKUP_DIRECTORY is also ok with symlinks · 2e4841a2
      Trond Myklebust authored
      commit e0caaf75 upstream.
      
      Commit ac795161
      
       (NFSv4: Handle case where the lookup of a directory
      fails) [1], part of Linux since 5.17-rc2, introduced a regression, where
      a symbolic link on an NFS mount to a directory on another NFS does not
      resolve(?) the first time it is accessed:
      
      Reported-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Fixes: ac795161
      
       ("NFSv4: Handle case where the lookup of a directory fails")
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Tested-by: default avatarDonald Buczek <buczek@molgen.mpg.de>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e4841a2
    • Anders Roxell's avatar
      powerpc/lib/sstep: fix 'ptesync' build error · 16e919d0
      Anders Roxell authored
      commit fe663df7 upstream.
      
      Building tinyconfig with gcc (Debian 11.2.0-16) and assembler (Debian
      2.37.90.20220207) the following build error shows up:
      
        {standard input}: Assembler messages:
        {standard input}:2088: Error: unrecognized opcode: `ptesync'
        make[3]: *** [/builds/linux/scripts/Makefile.build:287: arch/powerpc/lib/sstep.o] Error 1
      
      Add the 'ifdef CONFIG_PPC64' around the 'ptesync' in function
      'emulate_update_regs()' to like it is in 'analyse_instr()'. Since it looks like
      it got dropped inadvertently by commit 3cdfcbfd ("powerpc: Change
      analyse_instr so it doesn't modify *regs").
      
      A key detail is that analyse_instr() will never recognise lwsync or
      ptesync on 32-bit (because of the existing ifdef), and as a result
      emulate_update_regs() should never be called with an op specifying
      either of those on 32-bit. So removing them from emulate_update_regs()
      should be a nop in terms of runtime behaviour.
      
      Fixes: 3cdfcbfd
      
       ("powerpc: Change analyse_instr so it doesn't modify *regs")
      Cc: stable@vger.kernel.org # v4.14+
      Suggested-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarAnders Roxell <anders.roxell@linaro.org>
      [mpe: Add last paragraph of change log mentioning analyse_instr() details]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220211005113.1361436-1-anders.roxell@linaro.org
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      16e919d0
    • Mark Brown's avatar
      ASoC: ops: Fix stereo change notifications in snd_soc_put_volsw_range() · 1bc64ea1
      Mark Brown authored
      commit 650204de
      
       upstream.
      
      When writing out a stereo control we discard the change notification from
      the first channel, meaning that events are only generated based on changes
      to the second channel. Ensure that we report a change if either channel
      has changed.
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20220201155629.120510-4-broonie@kernel.org
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1bc64ea1
    • Mark Brown's avatar
      ASoC: ops: Fix stereo change notifications in snd_soc_put_volsw() · 7cc7db09
      Mark Brown authored
      commit 564778d7
      
       upstream.
      
      When writing out a stereo control we discard the change notification from
      the first channel, meaning that events are only generated based on changes
      to the second channel. Ensure that we report a change if either channel
      has changed.
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20220201155629.120510-2-broonie@kernel.org
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7cc7db09
    • Takashi Iwai's avatar
      ALSA: hda: Fix missing codec probe on Shenker Dock 15 · 5434aaa3
      Takashi Iwai authored
      commit dd8e5b16
      
       upstream.
      
      By some unknown reason, BIOS on Shenker Dock 15 doesn't set up the
      codec mask properly for the onboard audio.  Let's set the forced codec
      mask to enable the codec discovery.
      
      Reported-by: default avatar <dmummenschanz@web.de>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/trinity-f018660b-95c9-442b-a2a8-c92a56eb07ed-1644345967148@3c-app-webde-bap22
      Link: https://lore.kernel.org/r/20220214100020.8870-2-tiwai@suse.de
      
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5434aaa3
    • Takashi Iwai's avatar
      ALSA: hda: Fix regression on forced probe mask option · bef7a619
      Takashi Iwai authored
      commit 6317f744 upstream.
      
      The forced probe mask via probe_mask 0x100 bit doesn't work any longer
      as expected since the bus init code was moved and it's clearing the
      codec_mask value that was set beforehand.  This patch fixes the
      long-time regression by moving the check_probe_mask() call.
      
      Fixes: a41d1224
      
       ("ALSA: hda - Embed bus into controller object")
      Reported-by: default avatar <dmummenschanz@web.de>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/trinity-f018660b-95c9-442b-a2a8-c92a56eb07ed-1644345967148@3c-app-webde-bap22
      Link: https://lore.kernel.org/r/20220214100020.8870-1-tiwai@suse.de
      
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bef7a619
    • Kees Cook's avatar
      libsubcmd: Fix use-after-free for realloc(..., 0) · e89bb266
      Kees Cook authored
      commit 52a9dab6 upstream.
      
      GCC 12 correctly reports a potential use-after-free condition in the
      xrealloc helper. Fix the warning by avoiding an implicit "free(ptr)"
      when size == 0:
      
      In file included from help.c:12:
      In function 'xrealloc',
          inlined from 'add_cmdname' at help.c:24:2: subcmd-util.h:56:23: error: pointer may be used after 'realloc' [-Werror=use-after-free]
         56 |                 ret = realloc(ptr, size);
            |                       ^~~~~~~~~~~~~~~~~~
      subcmd-util.h:52:21: note: call to 'realloc' here
         52 |         void *ret = realloc(ptr, size);
            |                     ^~~~~~~~~~~~~~~~~~
      subcmd-util.h:58:31: error: pointer may be used after 'realloc' [-Werror=use-after-free]
         58 |                         ret = realloc(ptr, 1);
            |                               ^~~~~~~~~~~~~~~
      subcmd-util.h:52:21: note: call to 'realloc' here
         52 |         void *ret = realloc(ptr, size);
            |                     ^~~~~~~~~~~~~~~~~~
      
      Fixes: 2f4ce5ec
      
       ("perf tools: Finalize subcmd independence")
      Reported-by: default avatarValdis Klētnieks <valdis.kletnieks@vt.edu>
      Signed-off-by: default avatarKees Kook <keescook@chromium.org>
      Tested-by: default avatarValdis Klētnieks <valdis.kletnieks@vt.edu>
      Tested-by: default avatarJustin M. Forbes <jforbes@fedoraproject.org>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: linux-hardening@vger.kernel.org
      Cc: Valdis Klētnieks <valdis.kletnieks@vt.edu>
      Link: http://lore.kernel.org/lkml/20220213182443.4037039-1-keescook@chromium.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e89bb266
    • Eric Dumazet's avatar
      bonding: fix data-races around agg_select_timer · c039dc76
      Eric Dumazet authored
      commit 9ceaf6f7 upstream.
      
      syzbot reported that two threads might write over agg_select_timer
      at the same time. Make agg_select_timer atomic to fix the races.
      
      BUG: KCSAN: data-race in bond_3ad_initiate_agg_selection / bond_3ad_state_machine_handler
      
      read to 0xffff8881242aea90 of 4 bytes by task 1846 on cpu 1:
       bond_3ad_state_machine_handler+0x99/0x2810 drivers/net/bonding/bond_3ad.c:2317
       process_one_work+0x3f6/0x960 kernel/workqueue.c:2307
       worker_thread+0x616/0xa70 kernel/workqueue.c:2454
       kthread+0x1bf/0x1e0 kernel/kthread.c:377
       ret_from_fork+0x1f/0x30
      
      write to 0xffff8881242aea90 of 4 bytes by task 25910 on cpu 0:
       bond_3ad_initiate_agg_selection+0x18/0x30 drivers/net/bonding/bond_3ad.c:1998
       bond_open+0x658/0x6f0 drivers/net/bonding/bond_main.c:3967
       __dev_open+0x274/0x3a0 net/core/dev.c:1407
       dev_open+0x54/0x190 net/core/dev.c:1443
       bond_enslave+0xcef/0x3000 drivers/net/bonding/bond_main.c:1937
       do_set_master net/core/rtnetlink.c:2532 [inline]
       do_setlink+0x94f/0x2500 net/core/rtnetlink.c:2736
       __rtnl_newlink net/core/rtnetlink.c:3414 [inline]
       rtnl_newlink+0xfeb/0x13e0 net/core/rtnetlink.c:3529
       rtnetlink_rcv_msg+0x745/0x7e0 net/core/rtnetlink.c:5594
       netlink_rcv_skb+0x14e/0x250 net/netlink/af_netlink.c:2494
       rtnetlink_rcv+0x18/0x20 net/core/rtnetlink.c:5612
       netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
       netlink_unicast+0x602/0x6d0 net/netlink/af_netlink.c:1343
       netlink_sendmsg+0x728/0x850 net/netlink/af_netlink.c:1919
       sock_sendmsg_nosec net/socket.c:705 [inline]
       sock_sendmsg net/socket.c:725 [inline]
       ____sys_sendmsg+0x39a/0x510 net/socket.c:2413
       ___sys_sendmsg net/socket.c:2467 [inline]
       __sys_sendmsg+0x195/0x230 net/socket.c:2496
       __do_sys_sendmsg net/socket.c:2505 [inline]
       __se_sys_sendmsg net/socket.c:2503 [inline]
       __x64_sys_sendmsg+0x42/0x50 net/socket.c:2503
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      value changed: 0x00000050 -> 0x0000004f
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 0 PID: 25910 Comm: syz-executor.1 Tainted: G        W         5.17.0-rc4-syzkaller-dirty #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Cc: Jay Vosburgh <j.vosburgh@gmail.com>
      Cc: Veaceslav Falico <vfalico@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c039dc76
    • Eric Dumazet's avatar
      drop_monitor: fix data-race in dropmon_net_event / trace_napi_poll_hit · cbc0e2a0
      Eric Dumazet authored
      commit dcd54265 upstream.
      
      trace_napi_poll_hit() is reading stat->dev while another thread can write
      on it from dropmon_net_event()
      
      Use READ_ONCE()/WRITE_ONCE() here, RCU rules are properly enforced already,
      we only have to take care of load/store tearing.
      
      BUG: KCSAN: data-race in dropmon_net_event / trace_napi_poll_hit
      
      write to 0xffff88816f3ab9c0 of 8 bytes by task 20260 on cpu 1:
       dropmon_net_event+0xb8/0x2b0 net/core/drop_monitor.c:1579
       notifier_call_chain kernel/notifier.c:84 [inline]
       raw_notifier_call_chain+0x53/0xb0 kernel/notifier.c:392
       call_netdevice_notifiers_info net/core/dev.c:1919 [inline]
       call_netdevice_notifiers_extack net/core/dev.c:1931 [inline]
       call_netdevice_notifiers net/core/dev.c:1945 [inline]
       unregister_netdevice_many+0x867/0xfb0 net/core/dev.c:10415
       ip_tunnel_delete_nets+0x24a/0x280 net/ipv4/ip_tunnel.c:1123
       vti_exit_batch_net+0x2a/0x30 net/ipv4/ip_vti.c:515
       ops_exit_list net/core/net_namespace.c:173 [inline]
       cleanup_net+0x4dc/0x8d0 net/core/net_namespace.c:597
       process_one_work+0x3f6/0x960 kernel/workqueue.c:2307
       worker_thread+0x616/0xa70 kernel/workqueue.c:2454
       kthread+0x1bf/0x1e0 kernel/kthread.c:377
       ret_from_fork+0x1f/0x30
      
      read to 0xffff88816f3ab9c0 of 8 bytes by interrupt on cpu 0:
       trace_napi_poll_hit+0x89/0x1c0 net/core/drop_monitor.c:292
       trace_napi_poll include/trace/events/napi.h:14 [inline]
       __napi_poll+0x36b/0x3f0 net/core/dev.c:6366
       napi_poll net/core/dev.c:6432 [inline]
       net_rx_action+0x29e/0x650 net/core/dev.c:6519
       __do_softirq+0x158/0x2de kernel/softirq.c:558
       do_softirq+0xb1/0xf0 kernel/softirq.c:459
       __local_bh_enable_ip+0x68/0x70 kernel/softirq.c:383
       __raw_spin_unlock_bh include/linux/spinlock_api_smp.h:167 [inline]
       _raw_spin_unlock_bh+0x33/0x40 kernel/locking/spinlock.c:210
       spin_unlock_bh include/linux/spinlock.h:394 [inline]
       ptr_ring_consume_bh include/linux/ptr_ring.h:367 [inline]
       wg_packet_decrypt_worker+0x73c/0x780 drivers/net/wireguard/receive.c:506
       process_one_work+0x3f6/0x960 kernel/workqueue.c:2307
       worker_thread+0x616/0xa70 kernel/workqueue.c:2454
       kthread+0x1bf/0x1e0 kernel/kthread.c:377
       ret_from_fork+0x1f/0x30
      
      value changed: 0xffff88815883e000 -> 0x0000000000000000
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 0 PID: 26435 Comm: kworker/0:1 Not tainted 5.17.0-rc1-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Workqueue: wg-crypt-wg2 wg_packet_decrypt_worker
      
      Fixes: 4ea7e386
      
       ("dropmon: add ability to detect when hardware dropsrxpackets")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Neil Horman <nhorman@tuxdriver.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cbc0e2a0
    • Xin Long's avatar
      ping: fix the dif and sdif check in ping_lookup · 5a5c871b
      Xin Long authored
      commit 35a79e64 upstream.
      
      When 'ping' changes to use PING socket instead of RAW socket by:
      
         # sysctl -w net.ipv4.ping_group_range="0 100"
      
      There is another regression caused when matching sk_bound_dev_if
      and dif, RAW socket is using inet_iif() while PING socket lookup
      is using skb->dev->ifindex, the cmd below fails due to this:
      
        # ip link add dummy0 type dummy
        # ip link set dummy0 up
        # ip addr add 192.168.111.1/24 dev dummy0
        # ping -I dummy0 192.168.111.1 -c1
      
      The issue was also reported on:
      
        https://github.com/iputils/iputils/issues/104
      
      But fixed in iputils in a wrong way by not binding to device when
      destination IP is on device, and it will cause some of kselftests
      to fail, as Jianlin noticed.
      
      This patch is to use inet(6)_iif and inet(6)_sdif to get dif and
      sdif for PING socket, and keep consistent with RAW socket.
      
      Fixes: c319b4d7
      
       ("net: ipv4: add IPPROTO_ICMP socket kind")
      Reported-by: default avatarJianlin Shi <jishi@redhat.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5a5c871b
    • Miquel Raynal's avatar
      net: ieee802154: ca8210: Fix lifs/sifs periods · 5b877cc8
      Miquel Raynal authored
      commit bdc120a2 upstream.
      
      These periods are expressed in time units (microseconds) while 40 and 12
      are the number of symbol durations these periods will last. We need to
      multiply them both with the symbol_duration in order to get these
      values in microseconds.
      
      Fixes: ded845a7
      
       ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Link: https://lore.kernel.org/r/20220201180629.93410-2-miquel.raynal@bootlin.com
      
      
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5b877cc8
    • Johannes Berg's avatar
      iwlwifi: pcie: gen2: fix locking when "HW not ready" · 4468f1e5
      Johannes Berg authored
      commit 4c29c1e2 upstream.
      
      If we run into this error path, we shouldn't unlock the mutex
      since it's not locked since. Fix this in the gen2 code as well.
      
      Fixes: eda50cde
      
       ("iwlwifi: pcie: add context information support")
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/iwlwifi.20220128142706.b8b0dfce16ef.Ie20f0f7b23e5911350a2766524300d2915e7b677@changeid
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4468f1e5
    • Johannes Berg's avatar
      iwlwifi: pcie: fix locking when "HW not ready" · d6a529f7
      Johannes Berg authored
      commit e9848aed upstream.
      
      If we run into this error path, we shouldn't unlock the mutex
      since it's not locked since. Fix this.
      
      Fixes: a6bd005f
      
       ("iwlwifi: pcie: fix RF-Kill vs. firmware load race")
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/iwlwifi.20220128142706.5d16821d1433.Id259699ddf9806459856d6aefbdbe54477aecffd@changeid
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d6a529f7
    • Seth Forshee's avatar
      vsock: remove vsock from connected table when connect is interrupted by a signal · e3b3939f
      Seth Forshee authored
      commit b9208492 upstream.
      
      vsock_connect() expects that the socket could already be in the
      TCP_ESTABLISHED state when the connecting task wakes up with a signal
      pending. If this happens the socket will be in the connected table, and
      it is not removed when the socket state is reset. In this situation it's
      common for the process to retry connect(), and if the connection is
      successful the socket will be added to the connected table a second
      time, corrupting the list.
      
      Prevent this by calling vsock_remove_connected() if a signal is received
      while waiting for a connection. This is harmless if the socket is not in
      the connected table, and if it is in the table then removing it will
      prevent list corruption from a double add.
      
      Note for backporting: this patch requires d5afa82c ("vsock: correct
      removal of socket from the list"), which is in all current stable trees
      except 4.9.y.
      
      Fixes: d021c344
      
       ("VSOCK: Introduce VM Sockets")
      Signed-off-by: default avatarSeth Forshee <sforshee@digitalocean.com>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Link: https://lore.kernel.org/r/20220217141312.2297547-1-sforshee@digitalocean.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e3b3939f
    • Eric W. Biederman's avatar
      taskstats: Cleanup the use of task->exit_code · 16926f2a
      Eric W. Biederman authored
      commit 1b5a42d9 upstream.
      
      In the function bacct_add_task the code reading task->exit_code was
      introduced in commit f3cef7a9 ("[PATCH] csa: basic accounting over
      taskstats"), and it is not entirely clear what the taskstats interface
      is trying to return as only returning the exit_code of the first task
      in a process doesn't make a lot of sense.
      
      As best as I can figure the intent is to return task->exit_code after
      a task exits.  The field is returned with per task fields, so the
      exit_code of the entire process is not wanted.  Only the value of the
      first task is returned so this is not a useful way to get the per task
      ptrace stop code.  The ordinary case of returning this value is
      returning after a task exits, which also precludes use for getting
      a ptrace value.
      
      It is common to for the first task of a process to also be the last
      task of a process so this field may have done something reasonable by
      accident in testing.
      
      Make ac_exitcode a reliable per task value by always returning it for
      every exited task.
      
      Setting ac_exitcode in a sensible mannter makes it possible to continue
      to provide this value going forward.
      
      Cc: Balbir Singh <bsingharora@gmail.com>
      Fixes: f3cef7a9 ("[PATCH] csa: basic accounting over taskstats")
      Link: https://lkml.kernel.org/r/20220103213312.9144-5-ebiederm@xmission.com
      
      
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      [sudip: adjust context]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      16926f2a
    • Guillaume Nault's avatar
      xfrm: Don't accidentally set RTO_ONLINK in decode_session4() · 45f9a195
      Guillaume Nault authored
      commit 23e7b1bf upstream.
      
      Similar to commit 94e22389 ("xfrm4: strip ECN bits from tos field"),
      clear the ECN bits from iph->tos when setting ->flowi4_tos.
      This ensures that the last bit of ->flowi4_tos is cleared, so
      ip_route_output_key_hash() isn't going to restrict the scope of the
      route lookup.
      
      Use ~INET_ECN_MASK instead of IPTOS_RT_MASK, because we have no reason
      to clear the high order bits.
      
      Found by code inspection, compile tested only.
      
      Fixes: 4da3089f
      
       ("[IPSEC]: Use TOS when doing tunnel lookups")
      Signed-off-by: default avatarGuillaume Nault <gnault@redhat.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      [sudip: manually backport to previous location]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45f9a195
    • Nicholas Bishop's avatar
      drm/radeon: Fix backlight control on iMac 12,1 · 02af01d3
      Nicholas Bishop authored
      commit 364438fd upstream.
      
      The iMac 12,1 does not use the gmux driver for backlight, so the radeon
      backlight device is needed to set the brightness.
      
      Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1838
      
      
      Signed-off-by: default avatarNicholas Bishop <nicholasbishop@google.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      02af01d3
    • Johannes Berg's avatar
      iwlwifi: fix use-after-free · d3b98fe3
      Johannes Berg authored
      commit bea2662e
      
       upstream.
      
      If no firmware was present at all (or, presumably, all of the
      firmware files failed to parse), we end up unbinding by calling
      device_release_driver(), which calls remove(), which then in
      iwlwifi calls iwl_drv_stop(), freeing the 'drv' struct. However
      the new code I added will still erroneously access it after it
      was freed.
      
      Set 'failure=false' in this case to avoid the access, all data
      was already freed anyway.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarStefan Agner <stefan@agner.ch>
      Reported-by: default avatarWolfgang Walter <linux@stwm.de>
      Reported-by: default avatarJason Self <jason@bluehome.net>
      Reported-by: default avatarDominik Behr <dominik@dominikbehr.com>
      Reported-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Fixes: ab07506b
      
       ("iwlwifi: fix leaks/bad data after failed firmware load")
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20220208114728.e6b514cf4c85.Iffb575ca2a623d7859b542c33b2a507d01554251@changeid
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d3b98fe3
    • Igor Pylypiv's avatar
      Revert "module, async: async_synchronize_full() on module init iff async is used" · 2e5ed753
      Igor Pylypiv authored
      [ Upstream commit 67d6212a ]
      
      This reverts commit 774a1221.
      
      We need to finish all async code before the module init sequence is
      done.  In the reverted commit the PF_USED_ASYNC flag was added to mark a
      thread that called async_schedule().  Then the PF_USED_ASYNC flag was
      used to determine whether or not async_synchronize_full() needs to be
      invoked.  This works when modprobe thread is calling async_schedule(),
      but it does not work if module dispatches init code to a worker thread
      which then calls async_schedule().
      
      For example, PCI driver probing is invoked from a worker thread based on
      a node where device is attached:
      
      	if (cpu < nr_cpu_ids)
      		error = work_on_cpu(cpu, local_pci_probe, &ddi);
      	else
      		error = local_pci_probe(&ddi);
      
      We end up in a situation where a worker thread gets the PF_USED_ASYNC
      flag set instead of the modprobe thread.  As a result,
      async_synchronize_full() is not invoked and modprobe completes without
      waiting for the async code to finish.
      
      The issue was discovered while loading the pm80xx driver:
      (scsi_mod.scan=async)
      
      modprobe pm80xx                      worker
      ...
        do_init_module()
        ...
          pci_call_probe()
            work_on_cpu(local_pci_probe)
                                           local_pci_probe()
                                             pm8001_pci_probe()
                                               scsi_scan_host()
                                                 async_schedule()
                                                 worker->flags |= PF_USED_ASYNC;
                                           ...
            < return from worker >
        ...
        if (current->flags & PF_USED_ASYNC) <--- false
        	async_synchronize_full();
      
      Commit 21c3c5d2 ("block: don't request module during elevator init")
      fixed the deadlock issue which the reverted commit 774a1221
      ("module, async: async_synchronize_full() on module init iff async is
      used") tried to fix.
      
      Since commit 0fdff3ec
      
       ("async, kmod: warn on synchronous
      request_module() from async workers") synchronous module loading from
      async is not allowed.
      
      Given that the original deadlock issue is fixed and it is no longer
      allowed to call synchronous request_module() from async we can remove
      PF_USED_ASYNC flag to make module init consistently invoke
      async_synchronize_full() unless async module probe is requested.
      
      Signed-off-by: default avatarIgor Pylypiv <ipylypiv@google.com>
      Reviewed-by: default avatarChangyuan Lyu <changyuanl@google.com>
      Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Acked-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2e5ed753
    • Darrick J. Wong's avatar
      quota: make dquot_quota_sync return errors from ->sync_fs · 36d90ece
      Darrick J. Wong authored
      [ Upstream commit dd5532a4
      
       ]
      
      Strangely, dquot_quota_sync ignores the return code from the ->sync_fs
      call, which means that quotacalls like Q_SYNC never see the error.  This
      doesn't seem right, so fix that.
      
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Acked-by: default avatarChristian Brauner <brauner@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      36d90ece
    • Darrick J. Wong's avatar
      vfs: make freeze_super abort when sync_filesystem returns error · ebd0a328
      Darrick J. Wong authored
      [ Upstream commit 2719c716
      
       ]
      
      If we fail to synchronize the filesystem while preparing to freeze the
      fs, abort the freeze.
      
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Acked-by: default avatarChristian Brauner <brauner@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ebd0a328
    • Duoming Zhou's avatar
      ax25: improve the incomplete fix to avoid UAF and NPD bugs · a509dbde
      Duoming Zhou authored
      [ Upstream commit 4e0f718d ]
      
      The previous commit 1ade48d0
      
       ("ax25: NPD bug when detaching
      AX25 device") introduce lock_sock() into ax25_kill_by_device to
      prevent NPD bug. But the concurrency NPD or UAF bug will occur,
      when lock_sock() or release_sock() dereferences the ax25_cb->sock.
      
      The NULL pointer dereference bug can be shown as below:
      
      ax25_kill_by_device()        | ax25_release()
                                   |   ax25_destroy_socket()
                                   |     ax25_cb_del()
        ...                        |     ...
                                   |     ax25->sk=NULL;
        lock_sock(s->sk); //(1)    |
        s->ax25_dev = NULL;        |     ...
        release_sock(s->sk); //(2) |
        ...                        |
      
      The root cause is that the sock is set to null before dereference
      site (1) or (2). Therefore, this patch extracts the ax25_cb->sock
      in advance, and uses ax25_list_lock to protect it, which can synchronize
      with ax25_cb_del() and ensure the value of sock is not null before
      dereference sites.
      
      The concurrency UAF bug can be shown as below:
      
      ax25_kill_by_device()        | ax25_release()
                                   |   ax25_destroy_socket()
        ...                        |   ...
                                   |   sock_put(sk); //FREE
        lock_sock(s->sk); //(1)    |
        s->ax25_dev = NULL;        |   ...
        release_sock(s->sk); //(2) |
        ...                        |
      
      The root cause is that the sock is released before dereference
      site (1) or (2). Therefore, this patch uses sock_hold() to increase
      the refcount of sock and uses ax25_list_lock to protect it, which
      can synchronize with ax25_cb_del() in ax25_destroy_socket() and
      ensure the sock wil not be released before dereference sites.
      
      Signed-off-by: default avatarDuoming Zhou <duoming@zju.edu.cn>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a509dbde
    • Yang Xu's avatar
      selftests/zram: Adapt the situation that /dev/zram0 is being used · 957568ed
      Yang Xu authored
      [ Upstream commit 01dabed2 ]
      
      If zram-generator package is installed and works, then we can not remove
      zram module because zram swap is being used. This case needs a clean zram
      environment, change this test by using hot_add/hot_remove interface. So
      even zram device is being used, we still can add zram device and remove
      them in cleanup.
      
      The two interface was introduced since kernel commit 6566d1a3
      
      ("zram:
      add dynamic device add/remove functionality") in v4.2-rc1. If kernel
      supports these two interface, we use hot_add/hot_remove to slove this
      problem, if not, just check whether zram is being used or built in, then
      skip it on old kernel.
      
      Signed-off-by: default avatarYang Xu <xuyang2018.jy@fujitsu.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      957568ed
    • Yang Xu's avatar
      selftests/zram01.sh: Fix compression ratio calculation · fb00ecbb
      Yang Xu authored
      [ Upstream commit d18da7ec
      
       ]
      
      zram01 uses `free -m` to measure zram memory usage. The results are no
      sense because they are polluted by all running processes on the system.
      
      We Should only calculate the free memory delta for the current process.
      So use the third field of /sys/block/zram<id>/mm_stat to measure memory
      usage instead. The file is available since kernel 4.1.
      
      orig_data_size(first): uncompressed size of data stored in this disk.
      compr_data_size(second): compressed size of data stored in this disk
      mem_used_total(third): the amount of memory allocated for this disk
      
      Also remove useless zram cleanup call in zram_fill_fs and so we don't
      need to cleanup zram twice if fails.
      
      Signed-off-by: default avatarYang Xu <xuyang2018.jy@fujitsu.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fb00ecbb
    • Yang Xu's avatar
      selftests/zram: Skip max_comp_streams interface on newer kernel · e382cc63
      Yang Xu authored
      [ Upstream commit fc4eb486 ]
      
      Since commit 43209ea2
      
       ("zram: remove max_comp_streams internals"), zram
      has switched to per-cpu streams. Even kernel still keep this interface for
      some reasons, but writing to max_comp_stream doesn't take any effect. So
      skip it on newer kernel ie 4.7.
      
      The code that comparing kernel version is from xfstests testsuite ext4/053.
      
      Signed-off-by: default avatarYang Xu <xuyang2018.jy@fujitsu.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e382cc63
    • Miquel Raynal's avatar
      net: ieee802154: at86rf230: Stop leaking skb's · af649e5c
      Miquel Raynal authored
      [ Upstream commit e5ce576d
      
       ]
      
      Upon error the ieee802154_xmit_complete() helper is not called. Only
      ieee802154_wake_queue() is called manually. In the Tx case we then leak
      the skb structure.
      
      Free the skb structure upon error before returning when appropriate.
      
      As the 'is_tx = 0' cannot be moved in the complete handler because of a
      possible race between the delay in switching to STATE_RX_AACK_ON and a
      new interrupt, we introduce an intermediate 'was_tx' boolean just for
      this purpose.
      
      There is no Fixes tag applying here, many changes have been made on this
      area and the issue kind of always existed.
      
      Suggested-by: default avatarAlexander Aring <alex.aring@gmail.com>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
      Link: https://lore.kernel.org/r/20220125121426.848337-4-miquel.raynal@bootlin.com
      
      
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      af649e5c
    • Dāvis Mosāns's avatar
      btrfs: send: in case of IO error log it · 97e4a8bd
      Dāvis Mosāns authored
      commit 2e7be9db
      
       upstream.
      
      Currently if we get IO error while doing send then we abort without
      logging information about which file caused issue.  So log it to help
      with debugging.
      
      CC: stable@vger.kernel.org # 4.9+
      Signed-off-by: default avatarDāvis Mosāns <davispuh@gmail.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      97e4a8bd
    • John David Anglin's avatar
      parisc: Fix sglist access in ccio-dma.c · 993bd417
      John David Anglin authored
      commit d7da660c
      
       upstream.
      
      This patch implements the same bug fix to ccio-dma.c as to sba_iommu.c.
      It ensures that only the allocated entries of the sglist are accessed.
      
      Signed-off-by: default avatarJohn David Anglin <dave.anglin@bell.net>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      993bd417
    • John David Anglin's avatar
      parisc: Fix data TLB miss in sba_unmap_sg · de75676e
      John David Anglin authored
      commit b7d6f44a
      
       upstream.
      
      Rolf Eike Beer reported the following bug:
      
      [1274934.746891] Bad Address (null pointer deref?): Code=15 (Data TLB miss fault) at addr 0000004140000018
      [1274934.746891] CPU: 3 PID: 5549 Comm: cmake Not tainted 5.15.4-gentoo-parisc64 #4
      [1274934.746891] Hardware name: 9000/785/C8000
      [1274934.746891]
      [1274934.746891]      YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI
      [1274934.746891] PSW: 00001000000001001111111000001110 Not tainted
      [1274934.746891] r00-03  000000ff0804fe0e 0000000040bc9bc0 00000000406760e4 0000004140000000
      [1274934.746891] r04-07  0000000040b693c0 0000004140000000 000000004a2b08b0 0000000000000001
      [1274934.746891] r08-11  0000000041f98810 0000000000000000 000000004a0a7000 0000000000000001
      [1274934.746891] r12-15  0000000040bddbc0 0000000040c0cbc0 0000000040bddbc0 0000000040bddbc0
      [1274934.746891] r16-19  0000000040bde3c0 0000000040bddbc0 0000000040bde3c0 0000000000000007
      [1274934.746891] r20-23  0000000000000006 000000004a368950 0000000000000000 0000000000000001
      [1274934.746891] r24-27  0000000000001fff 000000000800000e 000000004a1710f0 0000000040b693c0
      [1274934.746891] r28-31  0000000000000001 0000000041f988b0 0000000041f98840 000000004a171118
      [1274934.746891] sr00-03  00000000066e5800 0000000000000000 0000000000000000 00000000066e5800
      [1274934.746891] sr04-07  0000000000000000 0000000000000000 0000000000000000 0000000000000000
      [1274934.746891]
      [1274934.746891] IASQ: 0000000000000000 0000000000000000 IAOQ: 00000000406760e8 00000000406760ec
      [1274934.746891]  IIR: 48780030    ISR: 0000000000000000  IOR: 0000004140000018
      [1274934.746891]  CPU:        3   CR30: 00000040e3a9c000 CR31: ffffffffffffffff
      [1274934.746891]  ORIG_R28: 0000000040acdd58
      [1274934.746891]  IAOQ[0]: sba_unmap_sg+0xb0/0x118
      [1274934.746891]  IAOQ[1]: sba_unmap_sg+0xb4/0x118
      [1274934.746891]  RP(r2): sba_unmap_sg+0xac/0x118
      [1274934.746891] Backtrace:
      [1274934.746891]  [<00000000402740cc>] dma_unmap_sg_attrs+0x6c/0x70
      [1274934.746891]  [<000000004074d6bc>] scsi_dma_unmap+0x54/0x60
      [1274934.746891]  [<00000000407a3488>] mptscsih_io_done+0x150/0xd70
      [1274934.746891]  [<0000000040798600>] mpt_interrupt+0x168/0xa68
      [1274934.746891]  [<0000000040255a48>] __handle_irq_event_percpu+0xc8/0x278
      [1274934.746891]  [<0000000040255c34>] handle_irq_event_percpu+0x3c/0xd8
      [1274934.746891]  [<000000004025ecb4>] handle_percpu_irq+0xb4/0xf0
      [1274934.746891]  [<00000000402548e0>] generic_handle_irq+0x50/0x70
      [1274934.746891]  [<000000004019a254>] call_on_stack+0x18/0x24
      [1274934.746891]
      [1274934.746891] Kernel panic - not syncing: Bad Address (null pointer deref?)
      
      The bug is caused by overrunning the sglist and incorrectly testing
      sg_dma_len(sglist) before nents. Normally this doesn't cause a crash,
      but in this case sglist crossed a page boundary. This occurs in the
      following code:
      
      	while (sg_dma_len(sglist) && nents--) {
      
      The fix is simply to test nents first and move the decrement of nents
      into the loop.
      
      Reported-by: default avatarRolf Eike Beer <eike-kernel@sf-tec.de>
      Signed-off-by: default avatarJohn David Anglin <dave.anglin@bell.net>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      de75676e
    • Randy Dunlap's avatar
      serial: parisc: GSC: fix build when IOSAPIC is not set · 9e0123a1
      Randy Dunlap authored
      commit 6e879367
      
       upstream.
      
      There is a build error when using a kernel .config file from
      'kernel test robot' for a different build problem:
      
      hppa64-linux-ld: drivers/tty/serial/8250/8250_gsc.o: in function `.LC3':
      (.data.rel.ro+0x18): undefined reference to `iosapic_serial_irq'
      
      when:
        CONFIG_GSC=y
        CONFIG_SERIO_GSCPS2=y
        CONFIG_SERIAL_8250_GSC=y
        CONFIG_PCI is not set
          and hence PCI_LBA is not set.
        IOSAPIC depends on PCI_LBA, so IOSAPIC is not set/enabled.
      
      Make the use of iosapic_serial_irq() conditional to fix the build error.
      
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: linux-parisc@vger.kernel.org
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: linux-serial@vger.kernel.org
      Cc: Jiri Slaby <jirislaby@kernel.org>
      Cc: Johan Hovold <johan@kernel.org>
      Suggested-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9e0123a1
    • Jann Horn's avatar
      net: usb: ax88179_178a: Fix out-of-bounds accesses in RX fixup · 63f0cfb3
      Jann Horn authored
      commit 57bc3d3a upstream.
      
      ax88179_rx_fixup() contains several out-of-bounds accesses that can be
      triggered by a malicious (or defective) USB device, in particular:
      
       - The metadata array (hdr_off..hdr_off+2*pkt_cnt) can be out of bounds,
         causing OOB reads and (on big-endian systems) OOB endianness flips.
       - A packet can overlap the metadata array, causing a later OOB
         endianness flip to corrupt data used by a cloned SKB that has already
         been handed off into the network stack.
       - A packet SKB can be constructed whose tail is far beyond its end,
         causing out-of-bounds heap data to be considered part of the SKB's
         data.
      
      I have tested that this can be used by a malicious USB device to send a
      bogus ICMPv6 Echo Request and receive an ICMPv6 Echo Reply in response
      that contains random kernel heap data.
      It's probably also possible to get OOB writes from this on a
      little-endian system somehow - maybe by triggering skb_cow() via IP
      options processing -, but I haven't tested that.
      
      Fixes: e2ca90c2
      
       ("ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver")
      Cc: stable@kernel.org
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      63f0cfb3
    • Nathan Chancellor's avatar
      Makefile.extrawarn: Move -Wunaligned-access to W=1 · cbcb9c9b
      Nathan Chancellor authored
      commit 1cf5f151 upstream.
      
      -Wunaligned-access is a new warning in clang that is default enabled for
      arm and arm64 under certain circumstances within the clang frontend (see
      LLVM commit below). On v5.17-rc2, an ARCH=arm allmodconfig build shows
      1284 total/70 unique instances of this warning (most of the instances
      are in header files), which is quite noisy.
      
      To keep a normal build green through CONFIG_WERROR, only show this
      warning with W=1, which will allow automated build systems to catch new
      instances of the warning so that the total number can be driven down to
      zero eventually since catching unaligned accesses at compile time would
      be generally useful.
      
      Cc: stable@vger.kernel.org
      Link: https://github.com/llvm/llvm-project/commit/35737df4dcd28534bd3090157c224c19b501278a
      Link: https://github.com/ClangBuiltLinux/linux/issues/1569
      Link: https://github.com/ClangBuiltLinux/linux/issues/1576
      
      
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      [nathan: Fix conflict due to lack of afe956c5
      
      ]
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cbcb9c9b
  2. Feb 16, 2022