Skip to content
  1. Jul 31, 2021
    • Cristian Marussi's avatar
      firmware: arm_scmi: Fix range check for the maximum number of pending messages · 02a470e3
      Cristian Marussi authored
      [ Upstream commit bdb8742d
      
       ]
      
      SCMI message headers carry a sequence number and such field is sized to
      allow for MSG_TOKEN_MAX distinct numbers; moreover zero is not really an
      acceptable maximum number of pending in-flight messages.
      
      Fix accordingly the checks performed on the value exported by transports
      in scmi_desc.max_msg
      
      Link: https://lore.kernel.org/r/20210712141833.6628-3-cristian.marussi@arm.com
      Reported-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
      Signed-off-by: default avatarCristian Marussi <cristian.marussi@arm.com>
      [sudeep.holla: updated the patch title and error message]
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      02a470e3
    • Sudeep Holla's avatar
      firmware: arm_scmi: Fix possible scmi_linux_errmap buffer overflow · 289dd584
      Sudeep Holla authored
      [ Upstream commit 7a691f16
      
       ]
      
      The scmi_linux_errmap buffer access index is supposed to depend on the
      array size to prevent element out of bounds access. It uses SCMI_ERR_MAX
      to check bounds but that can mismatch with the array size. It also
      changes the success into -EIO though scmi_linux_errmap is never used in
      case of success, it is expected to work for success case too.
      
      It is slightly confusing code as the negative of the error code
      is used as index to the buffer. Fix it by negating it at the start and
      make it more readable.
      
      Link: https://lore.kernel.org/r/20210707135028.1869642-1-sudeep.holla@arm.com
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarCristian Marussi <cristian.marussi@arm.com>
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      289dd584
    • Desmond Cheong Zhi Xi's avatar
      hfs: add lock nesting notation to hfs_find_init · e3acb292
      Desmond Cheong Zhi Xi authored
      [ Upstream commit b3b2177a
      
       ]
      
      Syzbot reports a possible recursive lock in [1].
      
      This happens due to missing lock nesting information.  From the logs, we
      see that a call to hfs_fill_super is made to mount the hfs filesystem.
      While searching for the root inode, the lock on the catalog btree is
      grabbed.  Then, when the parent of the root isn't found, a call to
      __hfs_bnode_create is made to create the parent of the root.  This
      eventually leads to a call to hfs_ext_read_extent which grabs a lock on
      the extents btree.
      
      Since the order of locking is catalog btree -> extents btree, this lock
      hierarchy does not lead to a deadlock.
      
      To tell lockdep that this locking is safe, we add nesting notation to
      distinguish between catalog btrees, extents btrees, and attributes
      btrees (for HFS+).  This has already been done in hfsplus.
      
      Link: https://syzkaller.appspot.com/bug?id=f007ef1d7a31a469e3be7aeb0fde0769b18585db [1]
      Link: https://lkml.kernel.org/r/20210701030756.58760-4-desmondcheongzx@gmail.com
      Signed-off-by: default avatarDesmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
      Reported-by: default avatar <syzbot+b718ec84a87b7e73ade4@syzkaller.appspotmail.com>
      Tested-by: default avatar <syzbot+b718ec84a87b7e73ade4@syzkaller.appspotmail.com>
      Reviewed-by: default avatarViacheslav Dubeyko <slava@dubeyko.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e3acb292
    • Desmond Cheong Zhi Xi's avatar
      hfs: fix high memory mapping in hfs_bnode_read · af117829
      Desmond Cheong Zhi Xi authored
      [ Upstream commit 54a5ead6
      
       ]
      
      Pages that we read in hfs_bnode_read need to be kmapped into kernel
      address space.  However, currently only the 0th page is kmapped.  If the
      given offset + length exceeds this 0th page, then we have an invalid
      memory access.
      
      To fix this, we kmap relevant pages one by one and copy their relevant
      portions of data.
      
      An example of invalid memory access occurring without this fix can be seen
      in the following crash report:
      
        ==================================================================
        BUG: KASAN: use-after-free in memcpy include/linux/fortify-string.h:191 [inline]
        BUG: KASAN: use-after-free in hfs_bnode_read+0xc4/0xe0 fs/hfs/bnode.c:26
        Read of size 2 at addr ffff888125fdcffe by task syz-executor5/4634
      
        CPU: 0 PID: 4634 Comm: syz-executor5 Not tainted 5.13.0-syzkaller #0
        Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
        Call Trace:
         __dump_stack lib/dump_stack.c:79 [inline]
         dump_stack+0x195/0x1f8 lib/dump_stack.c:120
         print_address_description.constprop.0+0x1d/0x110 mm/kasan/report.c:233
         __kasan_report mm/kasan/report.c:419 [inline]
         kasan_report.cold+0x7b/0xd4 mm/kasan/report.c:436
         check_region_inline mm/kasan/generic.c:180 [inline]
         kasan_check_range+0x154/0x1b0 mm/kasan/generic.c:186
         memcpy+0x24/0x60 mm/kasan/shadow.c:65
         memcpy include/linux/fortify-string.h:191 [inline]
         hfs_bnode_read+0xc4/0xe0 fs/hfs/bnode.c:26
         hfs_bnode_read_u16 fs/hfs/bnode.c:34 [inline]
         hfs_bnode_find+0x880/0xcc0 fs/hfs/bnode.c:365
         hfs_brec_find+0x2d8/0x540 fs/hfs/bfind.c:126
         hfs_brec_read+0x27/0x120 fs/hfs/bfind.c:165
         hfs_cat_find_brec+0x19a/0x3b0 fs/hfs/catalog.c:194
         hfs_fill_super+0xc13/0x1460 fs/hfs/super.c:419
         mount_bdev+0x331/0x3f0 fs/super.c:1368
         hfs_mount+0x35/0x40 fs/hfs/super.c:457
         legacy_get_tree+0x10c/0x220 fs/fs_context.c:592
         vfs_get_tree+0x93/0x300 fs/super.c:1498
         do_new_mount fs/namespace.c:2905 [inline]
         path_mount+0x13f5/0x20e0 fs/namespace.c:3235
         do_mount fs/namespace.c:3248 [inline]
         __do_sys_mount fs/namespace.c:3456 [inline]
         __se_sys_mount fs/namespace.c:3433 [inline]
         __x64_sys_mount+0x2b8/0x340 fs/namespace.c:3433
         do_syscall_64+0x37/0xc0 arch/x86/entry/common.c:47
         entry_SYSCALL_64_after_hwframe+0x44/0xae
        RIP: 0033:0x45e63a
        Code: 48 c7 c2 bc ff ff ff f7 d8 64 89 02 b8 ff ff ff ff eb d2 e8 88 04 00 00 0f 1f 84 00 00 00 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
        RSP: 002b:00007f9404d410d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
        RAX: ffffffffffffffda RBX: 0000000020000248 RCX: 000000000045e63a
        RDX: 0000000020000000 RSI: 0000000020000100 RDI: 00007f9404d41120
        RBP: 00007f9404d41120 R08: 00000000200002c0 R09: 0000000020000000
        R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000003
        R13: 0000000000000003 R14: 00000000004ad5d8 R15: 0000000000000000
      
        The buggy address belongs to the page:
        page:00000000dadbcf3e refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x125fdc
        flags: 0x2fffc0000000000(node=0|zone=2|lastcpupid=0x3fff)
        raw: 02fffc0000000000 ffffea000497f748 ffffea000497f6c8 0000000000000000
        raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000
        page dumped because: kasan: bad access detected
      
        Memory state around the buggy address:
         ffff888125fdce80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
         ffff888125fdcf00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
        >ffff888125fdcf80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                                                        ^
         ffff888125fdd000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
         ffff888125fdd080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
        ==================================================================
      
      Link: https://lkml.kernel.org/r/20210701030756.58760-3-desmondcheongzx@gmail.com
      Signed-off-by: default avatarDesmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
      Reviewed-by: default avatarViacheslav Dubeyko <slava@dubeyko.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      af117829
    • Desmond Cheong Zhi Xi's avatar
      hfs: add missing clean-up in hfs_fill_super · 89136a47
      Desmond Cheong Zhi Xi authored
      [ Upstream commit 16ee572e
      
       ]
      
      Patch series "hfs: fix various errors", v2.
      
      This series ultimately aims to address a lockdep warning in
      hfs_find_init reported by Syzbot [1].
      
      The work done for this led to the discovery of another bug, and the
      Syzkaller repro test also reveals an invalid memory access error after
      clearing the lockdep warning.  Hence, this series is broken up into
      three patches:
      
      1. Add a missing call to hfs_find_exit for an error path in
         hfs_fill_super
      
      2. Fix memory mapping in hfs_bnode_read by fixing calls to kmap
      
      3. Add lock nesting notation to tell lockdep that the observed locking
         hierarchy is safe
      
      This patch (of 3):
      
      Before exiting hfs_fill_super, the struct hfs_find_data used in
      hfs_find_init should be passed to hfs_find_exit to be cleaned up, and to
      release the lock held on the btree.
      
      The call to hfs_find_exit is missing from an error path.  We add it back
      in by consolidating calls to hfs_find_exit for error paths.
      
      Link: https://syzkaller.appspot.com/bug?id=f007ef1d7a31a469e3be7aeb0fde0769b18585db [1]
      Link: https://lkml.kernel.org/r/20210701030756.58760-1-desmondcheongzx@gmail.com
      Link: https://lkml.kernel.org/r/20210701030756.58760-2-desmondcheongzx@gmail.com
      Signed-off-by: default avatarDesmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
      Reviewed-by: default avatarViacheslav Dubeyko <slava@dubeyko.com>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      89136a47
    • Vasily Averin's avatar
      ipv6: allocate enough headroom in ip6_finish_output2() · ded37d03
      Vasily Averin authored
      [ Upstream commit 5796015f
      
       ]
      
      When TEE target mirrors traffic to another interface, sk_buff may
      not have enough headroom to be processed correctly.
      ip_finish_output2() detect this situation for ipv4 and allocates
      new skb with enogh headroom. However ipv6 lacks this logic in
      ip_finish_output2 and it leads to skb_under_panic:
      
       skbuff: skb_under_panic: text:ffffffffc0866ad4 len:96 put:24
       head:ffff97be85e31800 data:ffff97be85e317f8 tail:0x58 end:0xc0 dev:gre0
       ------------[ cut here ]------------
       kernel BUG at net/core/skbuff.c:110!
       invalid opcode: 0000 [#1] SMP PTI
       CPU: 2 PID: 393 Comm: kworker/2:2 Tainted: G           OE     5.13.0 #13
       Hardware name: Virtuozzo KVM, BIOS 1.11.0-2.vz7.4 04/01/2014
       Workqueue: ipv6_addrconf addrconf_dad_work
       RIP: 0010:skb_panic+0x48/0x4a
       Call Trace:
        skb_push.cold.111+0x10/0x10
        ipgre_header+0x24/0xf0 [ip_gre]
        neigh_connected_output+0xae/0xf0
        ip6_finish_output2+0x1a8/0x5a0
        ip6_output+0x5c/0x110
        nf_dup_ipv6+0x158/0x1000 [nf_dup_ipv6]
        tee_tg6+0x2e/0x40 [xt_TEE]
        ip6t_do_table+0x294/0x470 [ip6_tables]
        nf_hook_slow+0x44/0xc0
        nf_hook.constprop.34+0x72/0xe0
        ndisc_send_skb+0x20d/0x2e0
        ndisc_send_ns+0xd1/0x210
        addrconf_dad_work+0x3c8/0x540
        process_one_work+0x1d1/0x370
        worker_thread+0x30/0x390
        kthread+0x116/0x130
        ret_from_fork+0x22/0x30
      
      Signed-off-by: default avatarVasily Averin <vvs@virtuozzo.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ded37d03
    • Xin Long's avatar
      sctp: move 198 addresses from unusable to private scope · f65b7f37
      Xin Long authored
      [ Upstream commit 1d11fa23
      
       ]
      
      The doc draft-stewart-tsvwg-sctp-ipv4-00 that restricts 198 addresses
      was never published. These addresses as private addresses should be
      allowed to use in SCTP.
      
      As Michael Tuexen suggested, this patch is to move 198 addresses from
      unusable to private scope.
      
      Reported-by: default avatarSérgio <surkamp@gmail.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Acked-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f65b7f37
    • Eric Dumazet's avatar
      net: annotate data race around sk_ll_usec · c8d32973
      Eric Dumazet authored
      [ Upstream commit 0dbffbb5
      
       ]
      
      sk_ll_usec is read locklessly from sk_can_busy_loop()
      while another thread can change its value in sock_setsockopt()
      
      This is correct but needs annotations.
      
      BUG: KCSAN: data-race in __skb_try_recv_datagram / sock_setsockopt
      
      write to 0xffff88814eb5f904 of 4 bytes by task 14011 on cpu 0:
       sock_setsockopt+0x1287/0x2090 net/core/sock.c:1175
       __sys_setsockopt+0x14f/0x200 net/socket.c:2100
       __do_sys_setsockopt net/socket.c:2115 [inline]
       __se_sys_setsockopt net/socket.c:2112 [inline]
       __x64_sys_setsockopt+0x62/0x70 net/socket.c:2112
       do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      read to 0xffff88814eb5f904 of 4 bytes by task 14001 on cpu 1:
       sk_can_busy_loop include/net/busy_poll.h:41 [inline]
       __skb_try_recv_datagram+0x14f/0x320 net/core/datagram.c:273
       unix_dgram_recvmsg+0x14c/0x870 net/unix/af_unix.c:2101
       unix_seqpacket_recvmsg+0x5a/0x70 net/unix/af_unix.c:2067
       ____sys_recvmsg+0x15d/0x310 include/linux/uio.h:244
       ___sys_recvmsg net/socket.c:2598 [inline]
       do_recvmmsg+0x35c/0x9f0 net/socket.c:2692
       __sys_recvmmsg net/socket.c:2771 [inline]
       __do_sys_recvmmsg net/socket.c:2794 [inline]
       __se_sys_recvmmsg net/socket.c:2787 [inline]
       __x64_sys_recvmmsg+0xcf/0x150 net/socket.c:2787
       do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      value changed: 0x00000000 -> 0x00000101
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 1 PID: 14001 Comm: syz-executor.3 Not tainted 5.13.0-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c8d32973
    • Yang Yingliang's avatar
      net/802/garp: fix memleak in garp_request_join() · c23b9a56
      Yang Yingliang authored
      [ Upstream commit 42ca63f9
      
       ]
      
      I got kmemleak report when doing fuzz test:
      
      BUG: memory leak
      unreferenced object 0xffff88810c909b80 (size 64):
        comm "syz", pid 957, jiffies 4295220394 (age 399.090s)
        hex dump (first 32 bytes):
          01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          00 00 00 00 00 00 00 00 08 00 00 00 01 02 00 04  ................
        backtrace:
          [<00000000ca1f2e2e>] garp_request_join+0x285/0x3d0
          [<00000000bf153351>] vlan_gvrp_request_join+0x15b/0x190
          [<0000000024005e72>] vlan_dev_open+0x706/0x980
          [<00000000dc20c4d4>] __dev_open+0x2bb/0x460
          [<0000000066573004>] __dev_change_flags+0x501/0x650
          [<0000000035b42f83>] rtnl_configure_link+0xee/0x280
          [<00000000a5e69de0>] __rtnl_newlink+0xed5/0x1550
          [<00000000a5258f4a>] rtnl_newlink+0x66/0x90
          [<00000000506568ee>] rtnetlink_rcv_msg+0x439/0xbd0
          [<00000000b7eaeae1>] netlink_rcv_skb+0x14d/0x420
          [<00000000c373ce66>] netlink_unicast+0x550/0x750
          [<00000000ec74ce74>] netlink_sendmsg+0x88b/0xda0
          [<00000000381ff246>] sock_sendmsg+0xc9/0x120
          [<000000008f6a2db3>] ____sys_sendmsg+0x6e8/0x820
          [<000000008d9c1735>] ___sys_sendmsg+0x145/0x1c0
          [<00000000aa39dd8b>] __sys_sendmsg+0xfe/0x1d0
      
      Calling garp_request_leave() after garp_request_join(), the attr->state
      is set to GARP_APPLICANT_VO, garp_attr_destroy() won't be called in last
      transmit event in garp_uninit_applicant(), the attr of applicant will be
      leaked. To fix this leak, iterate and free each attr of applicant before
      rerturning from garp_uninit_applicant().
      
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c23b9a56
    • Yang Yingliang's avatar
      net/802/mrp: fix memleak in mrp_request_join() · 88c4cae3
      Yang Yingliang authored
      [ Upstream commit 996af621
      
       ]
      
      I got kmemleak report when doing fuzz test:
      
      BUG: memory leak
      unreferenced object 0xffff88810c239500 (size 64):
      comm "syz-executor940", pid 882, jiffies 4294712870 (age 14.631s)
      hex dump (first 32 bytes):
      01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
      00 00 00 00 00 00 00 00 01 00 00 00 01 02 00 04 ................
      backtrace:
      [<00000000a323afa4>] slab_alloc_node mm/slub.c:2972 [inline]
      [<00000000a323afa4>] slab_alloc mm/slub.c:2980 [inline]
      [<00000000a323afa4>] __kmalloc+0x167/0x340 mm/slub.c:4130
      [<000000005034ca11>] kmalloc include/linux/slab.h:595 [inline]
      [<000000005034ca11>] mrp_attr_create net/802/mrp.c:276 [inline]
      [<000000005034ca11>] mrp_request_join+0x265/0x550 net/802/mrp.c:530
      [<00000000fcfd81f3>] vlan_mvrp_request_join+0x145/0x170 net/8021q/vlan_mvrp.c:40
      [<000000009258546e>] vlan_dev_open+0x477/0x890 net/8021q/vlan_dev.c:292
      [<0000000059acd82b>] __dev_open+0x281/0x410 net/core/dev.c:1609
      [<000000004e6dc695>] __dev_change_flags+0x424/0x560 net/core/dev.c:8767
      [<00000000471a09af>] rtnl_configure_link+0xd9/0x210 net/core/rtnetlink.c:3122
      [<0000000037a4672b>] __rtnl_newlink+0xe08/0x13e0 net/core/rtnetlink.c:3448
      [<000000008d5d0fda>] rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3488
      [<000000004882fe39>] rtnetlink_rcv_msg+0x369/0xa10 net/core/rtnetlink.c:5552
      [<00000000907e6c54>] netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2504
      [<00000000e7d7a8c4>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline]
      [<00000000e7d7a8c4>] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1340
      [<00000000e0645d50>] netlink_sendmsg+0x78e/0xc90 net/netlink/af_netlink.c:1929
      [<00000000c24559b7>] sock_sendmsg_nosec net/socket.c:654 [inline]
      [<00000000c24559b7>] sock_sendmsg+0x139/0x170 net/socket.c:674
      [<00000000fc210bc2>] ____sys_sendmsg+0x658/0x7d0 net/socket.c:2350
      [<00000000be4577b5>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2404
      
      Calling mrp_request_leave() after mrp_request_join(), the attr->state
      is set to MRP_APPLICANT_VO, mrp_attr_destroy() won't be called in last
      TX event in mrp_uninit_applicant(), the attr of applicant will be leaked.
      To fix this leak, iterate and free each attr of applicant before rerturning
      from mrp_uninit_applicant().
      
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      88c4cae3
    • Paul Gortmaker's avatar
      cgroup1: fix leaked context root causing sporadic NULL deref in LTP · eef99860
      Paul Gortmaker authored
      commit 1e7107c5 upstream.
      
      Richard reported sporadic (roughly one in 10 or so) null dereferences and
      other strange behaviour for a set of automated LTP tests.  Things like:
      
         BUG: kernel NULL pointer dereference, address: 0000000000000008
         #PF: supervisor read access in kernel mode
         #PF: error_code(0x0000) - not-present page
         PGD 0 P4D 0
         Oops: 0000 [#1] PREEMPT SMP PTI
         CPU: 0 PID: 1516 Comm: umount Not tainted 5.10.0-yocto-standard #1
         Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-48-gd9c812dda519-prebuilt.qemu.org 04/01/2014
         RIP: 0010:kernfs_sop_show_path+0x1b/0x60
      
      ...or these others:
      
         RIP: 0010:do_mkdirat+0x6a/0xf0
         RIP: 0010:d_alloc_parallel+0x98/0x510
         RIP: 0010:do_readlinkat+0x86/0x120
      
      There were other less common instances of some kind of a general scribble
      but the common theme was mount and cgroup and a dubious dentry triggering
      the NULL dereference.  I was only able to reproduce it under qemu by
      replicating Richard's setup as closely as possible - I never did get it
      to happen on bare metal, even while keeping everything else the same.
      
      In commit 71d883c3
      
       ("cgroup_do_mount(): massage calling conventions")
      we see this as a part of the overall change:
      
         --------------
                 struct cgroup_subsys *ss;
         -       struct dentry *dentry;
      
         [...]
      
         -       dentry = cgroup_do_mount(&cgroup_fs_type, fc->sb_flags, root,
         -                                CGROUP_SUPER_MAGIC, ns);
      
         [...]
      
         -       if (percpu_ref_is_dying(&root->cgrp.self.refcnt)) {
         -               struct super_block *sb = dentry->d_sb;
         -               dput(dentry);
         +       ret = cgroup_do_mount(fc, CGROUP_SUPER_MAGIC, ns);
         +       if (!ret && percpu_ref_is_dying(&root->cgrp.self.refcnt)) {
         +               struct super_block *sb = fc->root->d_sb;
         +               dput(fc->root);
                         deactivate_locked_super(sb);
                         msleep(10);
                         return restart_syscall();
                 }
         --------------
      
      In changing from the local "*dentry" variable to using fc->root, we now
      export/leave that dentry pointer in the file context after doing the dput()
      in the unlikely "is_dying" case.   With LTP doing a crazy amount of back to
      back mount/unmount [testcases/bin/cgroup_regression_5_1.sh] the unlikely
      becomes slightly likely and then bad things happen.
      
      A fix would be to not leave the stale reference in fc->root as follows:
      
         --------------
                        dput(fc->root);
        +               fc->root = NULL;
                        deactivate_locked_super(sb);
         --------------
      
      ...but then we are just open-coding a duplicate of fc_drop_locked() so we
      simply use that instead.
      
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Zefan Li <lizefan.x@bytedance.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: stable@vger.kernel.org      # v5.1+
      Reported-by: default avatarRichard Purdie <richard.purdie@linuxfoundation.org>
      Fixes: 71d883c3
      
       ("cgroup_do_mount(): massage calling conventions")
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eef99860
    • Yang Yingliang's avatar
      workqueue: fix UAF in pwq_unbound_release_workfn() · 7f0365b4
      Yang Yingliang authored
      commit b42b0bdd upstream.
      
      I got a UAF report when doing fuzz test:
      
      [  152.880091][ T8030] ==================================================================
      [  152.881240][ T8030] BUG: KASAN: use-after-free in pwq_unbound_release_workfn+0x50/0x190
      [  152.882442][ T8030] Read of size 4 at addr ffff88810d31bd00 by task kworker/3:2/8030
      [  152.883578][ T8030]
      [  152.883932][ T8030] CPU: 3 PID: 8030 Comm: kworker/3:2 Not tainted 5.13.0+ #249
      [  152.885014][ T8030] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
      [  152.886442][ T8030] Workqueue: events pwq_unbound_release_workfn
      [  152.887358][ T8030] Call Trace:
      [  152.887837][ T8030]  dump_stack_lvl+0x75/0x9b
      [  152.888525][ T8030]  ? pwq_unbound_release_workfn+0x50/0x190
      [  152.889371][ T8030]  print_address_description.constprop.10+0x48/0x70
      [  152.890326][ T8030]  ? pwq_unbound_release_workfn+0x50/0x190
      [  152.891163][ T8030]  ? pwq_unbound_release_workfn+0x50/0x190
      [  152.891999][ T8030]  kasan_report.cold.15+0x82/0xdb
      [  152.892740][ T8030]  ? pwq_unbound_release_workfn+0x50/0x190
      [  152.893594][ T8030]  __asan_load4+0x69/0x90
      [  152.894243][ T8030]  pwq_unbound_release_workfn+0x50/0x190
      [  152.895057][ T8030]  process_one_work+0x47b/0x890
      [  152.895778][ T8030]  worker_thread+0x5c/0x790
      [  152.896439][ T8030]  ? process_one_work+0x890/0x890
      [  152.897163][ T8030]  kthread+0x223/0x250
      [  152.897747][ T8030]  ? set_kthread_struct+0xb0/0xb0
      [  152.898471][ T8030]  ret_from_fork+0x1f/0x30
      [  152.899114][ T8030]
      [  152.899446][ T8030] Allocated by task 8884:
      [  152.900084][ T8030]  kasan_save_stack+0x21/0x50
      [  152.900769][ T8030]  __kasan_kmalloc+0x88/0xb0
      [  152.901416][ T8030]  __kmalloc+0x29c/0x460
      [  152.902014][ T8030]  alloc_workqueue+0x111/0x8e0
      [  152.902690][ T8030]  __btrfs_alloc_workqueue+0x11e/0x2a0
      [  152.903459][ T8030]  btrfs_alloc_workqueue+0x6d/0x1d0
      [  152.904198][ T8030]  scrub_workers_get+0x1e8/0x490
      [  152.904929][ T8030]  btrfs_scrub_dev+0x1b9/0x9c0
      [  152.905599][ T8030]  btrfs_ioctl+0x122c/0x4e50
      [  152.906247][ T8030]  __x64_sys_ioctl+0x137/0x190
      [  152.906916][ T8030]  do_syscall_64+0x34/0xb0
      [  152.907535][ T8030]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      [  152.908365][ T8030]
      [  152.908688][ T8030] Freed by task 8884:
      [  152.909243][ T8030]  kasan_save_stack+0x21/0x50
      [  152.909893][ T8030]  kasan_set_track+0x20/0x30
      [  152.910541][ T8030]  kasan_set_free_info+0x24/0x40
      [  152.911265][ T8030]  __kasan_slab_free+0xf7/0x140
      [  152.911964][ T8030]  kfree+0x9e/0x3d0
      [  152.912501][ T8030]  alloc_workqueue+0x7d7/0x8e0
      [  152.913182][ T8030]  __btrfs_alloc_workqueue+0x11e/0x2a0
      [  152.913949][ T8030]  btrfs_alloc_workqueue+0x6d/0x1d0
      [  152.914703][ T8030]  scrub_workers_get+0x1e8/0x490
      [  152.915402][ T8030]  btrfs_scrub_dev+0x1b9/0x9c0
      [  152.916077][ T8030]  btrfs_ioctl+0x122c/0x4e50
      [  152.916729][ T8030]  __x64_sys_ioctl+0x137/0x190
      [  152.917414][ T8030]  do_syscall_64+0x34/0xb0
      [  152.918034][ T8030]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      [  152.918872][ T8030]
      [  152.919203][ T8030] The buggy address belongs to the object at ffff88810d31bc00
      [  152.919203][ T8030]  which belongs to the cache kmalloc-512 of size 512
      [  152.921155][ T8030] The buggy address is located 256 bytes inside of
      [  152.921155][ T8030]  512-byte region [ffff88810d31bc00, ffff88810d31be00)
      [  152.922993][ T8030] The buggy address belongs to the page:
      [  152.923800][ T8030] page:ffffea000434c600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10d318
      [  152.925249][ T8030] head:ffffea000434c600 order:2 compound_mapcount:0 compound_pincount:0
      [  152.926399][ T8030] flags: 0x57ff00000010200(slab|head|node=1|zone=2|lastcpupid=0x7ff)
      [  152.927515][ T8030] raw: 057ff00000010200 dead000000000100 dead000000000122 ffff888009c42c80
      [  152.928716][ T8030] raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
      [  152.929890][ T8030] page dumped because: kasan: bad access detected
      [  152.930759][ T8030]
      [  152.931076][ T8030] Memory state around the buggy address:
      [  152.931851][ T8030]  ffff88810d31bc00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [  152.932967][ T8030]  ffff88810d31bc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [  152.934068][ T8030] >ffff88810d31bd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [  152.935189][ T8030]                    ^
      [  152.935763][ T8030]  ffff88810d31bd80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [  152.936847][ T8030]  ffff88810d31be00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      [  152.937940][ T8030] ==================================================================
      
      If apply_wqattrs_prepare() fails in alloc_workqueue(), it will call put_pwq()
      which invoke a work queue to call pwq_unbound_release_workfn() and use the 'wq'.
      The 'wq' allocated in alloc_workqueue() will be freed in error path when
      apply_wqattrs_prepare() fails. So it will lead a UAF.
      
      CPU0                                          CPU1
      alloc_workqueue()
      alloc_and_link_pwqs()
      apply_wqattrs_prepare() fails
      apply_wqattrs_cleanup()
      schedule_work(&pwq->unbound_release_work)
      kfree(wq)
                                                    worker_thread()
                                                    pwq_unbound_release_workfn() <- trigger uaf here
      
      If apply_wqattrs_prepare() fails, the new pwq are not linked, it doesn't
      hold any reference to the 'wq', 'wq' is invalid to access in the worker,
      so add check pwq if linked to fix this.
      
      Fixes: 2d5f0764
      
       ("workqueue: split apply_workqueue_attrs() into 3 stages")
      Cc: stable@vger.kernel.org # v4.2+
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Suggested-by: default avatarLai Jiangshan <jiangshanlai@gmail.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarLai Jiangshan <jiangshanlai@gmail.com>
      Tested-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7f0365b4
    • Miklos Szeredi's avatar
      af_unix: fix garbage collect vs MSG_PEEK · 85abe0d4
      Miklos Szeredi authored
      commit cbcf0112
      
       upstream.
      
      unix_gc() assumes that candidate sockets can never gain an external
      reference (i.e.  be installed into an fd) while the unix_gc_lock is
      held.  Except for MSG_PEEK this is guaranteed by modifying inflight
      count under the unix_gc_lock.
      
      MSG_PEEK does not touch any variable protected by unix_gc_lock (file
      count is not), yet it needs to be serialized with garbage collection.
      Do this by locking/unlocking unix_gc_lock:
      
       1) increment file count
      
       2) lock/unlock barrier to make sure incremented file count is visible
          to garbage collection
      
       3) install file into fd
      
      This is a lock barrier (unlike smp_mb()) that ensures that garbage
      collection is run completely before or completely after the barrier.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      85abe0d4
    • Maxim Levitsky's avatar
      KVM: x86: determine if an exception has an error code only when injecting it. · af45f352
      Maxim Levitsky authored
      commit b97f0745
      
       upstream.
      
      A page fault can be queued while vCPU is in real paged mode on AMD, and
      AMD manual asks the user to always intercept it
      (otherwise result is undefined).
      The resulting VM exit, does have an error code.
      
      Signed-off-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Message-Id: <20210225154135.405125-2-mlevitsk@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarZubin Mithra <zsm@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af45f352
    • Yonghong Song's avatar
      tools: Allow proper CC/CXX/... override with LLVM=1 in Makefile.include · 828cab3c
      Yonghong Song authored
      commit f62700ce
      
       upstream.
      
      selftests/bpf/Makefile includes tools/scripts/Makefile.include.
      With the following command
        make -j60 LLVM=1 LLVM_IAS=1  <=== compile kernel
        make -j60 -C tools/testing/selftests/bpf LLVM=1 LLVM_IAS=1 V=1
      some files are still compiled with gcc. This patch
      fixed the case if CC/AR/LD/CXX/STRIP is allowed to be
      overridden, it will be written to clang/llvm-ar/..., instead of
      gcc binaries. The definition of CC_NO_CLANG is also relocated
      to the place after the above CC is defined.
      
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210413153419.3028165-1-yhs@fb.com
      Cc: Anders Roxell <anders.roxell@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      828cab3c
    • Greg Kroah-Hartman's avatar
      selftest: fix build error in tools/testing/selftests/vm/userfaultfd.c · 525c5513
      Greg Kroah-Hartman authored
      When backporting 0db282ba
      
       ("selftest: use mmap instead of
      posix_memalign to allocate memory") to this stable branch, I forgot a {
      breaking the build.
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      525c5513
  2. Jul 28, 2021
    • Greg Kroah-Hartman's avatar
      Linux 5.4.136 · 253dccef
      Greg Kroah-Hartman authored
      
      
      Link: https://lore.kernel.org/r/20210726153831.696295003@linuxfoundation.org
      Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Tested-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Tested-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Tested-by: default avatarSudip Mukherjee <sudip.mukherjee@codethink.co.uk>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v5.4.136
      253dccef
    • Mathias Nyman's avatar
      xhci: add xhci_get_virt_ep() helper · 587f86b7
      Mathias Nyman authored
      [commit b1adc42d
      
       upstream]
      
      In several event handlers we need to find the right endpoint
      structure from slot_id and ep_index in the event.
      
      Add a helper for this, check that slot_id and ep_index are valid.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Link: https://lore.kernel.org/r/20210129130044.206855-6-mathias.nyman@linux.intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarCarsten Schmid <carsten_schmid@mentor.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      587f86b7
    • Riccardo Mancini's avatar
      perf inject: Close inject.output on exit · f9d0c355
      Riccardo Mancini authored
      commit 02e6246f
      
       upstream.
      
      ASan reports a memory leak when running:
      
        # perf test "83: Zstd perf.data compression/decompression"
      
      which happens inside 'perf inject'.
      
      The bug is caused by inject.output never being closed.
      
      This patch adds the missing perf_data__close().
      
      Signed-off-by: default avatarRiccardo Mancini <rickyman7@gmail.com>
      Fixes: 6ef81c55
      
       ("perf session: Return error code for perf_session__new() function on failure")
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/c06f682afa964687367cf6e92a64ceb49aec76a5.1626343282.git.rickyman7@gmail.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f9d0c355
    • Evan Quan's avatar
      PCI: Mark AMD Navi14 GPU ATS as broken · a9c103fa
      Evan Quan authored
      commit e8946a53 upstream
      
      Observed unexpected GPU hang during runpm stress test on 0x7341 rev 0x00.
      Further debugging shows broken ATS is related.
      
      Disable ATS on this part.  Similar issues on other devices:
      
        a2da5d8c ("PCI: Mark AMD Raven iGPU ATS as broken in some platforms")
        45beb31d ("PCI: Mark AMD Navi10 GPU rev 0x00 ATS as broken")
        5e89cd30
      
       ("PCI: Mark AMD Navi14 GPU rev 0xc5 ATS as broken")
      
      Suggested-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Link: https://lore.kernel.org/r/20210602021255.939090-1-evan.quan@amd.com
      Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarKrzysztof Wilczyński <kw@linux.com>
      Cc: stable@vger.kernel.org
      [sudip: adjust context]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a9c103fa
    • David Sterba's avatar
      btrfs: compression: don't try to compress if we don't have enough pages · 11561d2f
      David Sterba authored
      commit f2165627
      
       upstream
      
      The early check if we should attempt compression does not take into
      account the number of input pages. It can happen that there's only one
      page, eg. a tail page after some ranges of the BTRFS_MAX_UNCOMPRESSED
      have been processed, or an isolated page that won't be converted to an
      inline extent.
      
      The single page would be compressed but a later check would drop it
      again because the result size must be at least one block shorter than
      the input. That can never work with just one page.
      
      CC: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      [sudip: adjust context]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      11561d2f
    • Stephan Gerhold's avatar
      iio: accel: bma180: Fix BMA25x bandwidth register values · 4980301e
      Stephan Gerhold authored
      commit 8090d674 upstream
      
      According to the BMA253 datasheet [1] and BMA250 datasheet [2] the
      bandwidth value for BMA25x should be set as 01xxx:
      
        "Settings 00xxx result in a bandwidth of 7.81 Hz; [...]
         It is recommended [...] to use the range from ´01000b´ to ´01111b´
         only in order to be compatible with future products."
      
      However, at the moment the drivers sets bandwidth values from 0 to 6,
      which is not recommended and always results into 7.81 Hz bandwidth
      according to the datasheet.
      
      Fix this by introducing a bw_offset = 8 = 01000b for BMA25x,
      so the additional bit is always set for BMA25x.
      
      [1]: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bma253-ds000.pdf
      [2]: https://datasheet.octopart.com/BMA250-Bosch-datasheet-15540103.pdf
      
      Cc: Peter Meerwald <pmeerw@pmeerw.net>
      Fixes: 2017cff2
      
       ("iio:bma180: Add BMA250 chip support")
      Signed-off-by: default avatarStephan Gerhold <stephan@gerhold.net>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Link: https://lore.kernel.org/r/20210526094408.34298-2-stephan@gerhold.net
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      [sudip: adjust context]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4980301e
    • Linus Walleij's avatar
      iio: accel: bma180: Use explicit member assignment · d04f2582
      Linus Walleij authored
      commit 9436abc4
      
       upstream
      
      This uses the C99 explicit .member assignment for the
      variant data in struct bma180_part_info. This makes it
      easier to understand and add new variants.
      
      Cc: Peter Meerwald <pmeerw@pmeerw.net>
      Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d04f2582
    • Doug Berger's avatar
      net: bcmgenet: ensure EXT_ENERGY_DET_MASK is clear · 4e0afa88
      Doug Berger authored
      commit 5a3c680a upstream.
      
      Setting the EXT_ENERGY_DET_MASK bit allows the port energy detection
      logic of the internal PHY to prevent the system from sleeping. Some
      internal PHYs will report that energy is detected when the network
      interface is closed which can prevent the system from going to sleep
      if WoL is enabled when the interface is brought down.
      
      Since the driver does not support waking the system on this logic,
      this commit clears the bit whenever the internal PHY is powered up
      and the other logic for manipulating the bit is removed since it
      serves no useful function.
      
      Fixes: 1c1008c7
      
       ("net: bcmgenet: add main driver file")
      Signed-off-by: default avatarDoug Berger <opendmb@gmail.com>
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e0afa88
    • Marek Behún's avatar
      net: dsa: mv88e6xxx: use correct .stats_set_histogram() on Topaz · 2a4865d1
      Marek Behún authored
      commit 11527f3c upstream.
      
      Commit 40cff8fc
      
       ("net: dsa: mv88e6xxx: Fix stats histogram mode")
      introduced wrong .stats_set_histogram() method for Topaz family.
      
      The Peridot method should be used instead.
      
      Signed-off-by: default avatarMarek Behún <kabel@kernel.org>
      Fixes: 40cff8fc
      
       ("net: dsa: mv88e6xxx: Fix stats histogram mode")
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2a4865d1
    • Charles Baylis's avatar
      drm: Return -ENOTTY for non-drm ioctls · 7d8c06b8
      Charles Baylis authored
      commit 3abab27c
      
       upstream.
      
      drm: Return -ENOTTY for non-drm ioctls
      
      Return -ENOTTY from drm_ioctl() when userspace passes in a cmd number
      which doesn't relate to the drm subsystem.
      
      Glibc uses the TCGETS ioctl to implement isatty(), and without this
      change isatty() returns it incorrectly returns true for drm devices.
      
      To test run this command:
      $ if [ -t 0 ]; then echo is a tty; fi < /dev/dri/card0
      which shows "is a tty" without this patch.
      
      This may also modify memory which the userspace application is not
      expecting.
      
      Signed-off-by: default avatarCharles Baylis <cb-kernel@fishzet.co.uk>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/YPG3IBlzaMhfPqCr@stando.fishzet.co.uk
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7d8c06b8
    • Greg Kroah-Hartman's avatar
      nds32: fix up stack guard gap · b5d7bebd
      Greg Kroah-Hartman authored
      commit c453db6c upstream.
      
      Commit 1be7107f
      
       ("mm: larger stack guard gap, between vmas") fixed
      up all architectures to deal with the stack guard gap.  But when nds32
      was added to the tree, it forgot to do the same thing.
      
      Resolve this by properly fixing up the nsd32's version of
      arch_get_unmapped_area()
      
      Cc: Nick Hu <nickhu@andestech.com>
      Cc: Greentime Hu <green.hu@gmail.com>
      Cc: Vincent Chen <deanbo422@gmail.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Qiang Liu <cyruscyliu@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Reported-by: default avatariLifetruth <yixiaonn@gmail.com>
      Acked-by: default avatarHugh Dickins <hughd@google.com>
      Link: https://lore.kernel.org/r/20210629104024.2293615-1-gregkh@linuxfoundation.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b5d7bebd
    • Ilya Dryomov's avatar
      rbd: always kick acquire on "acquired" and "released" notifications · ba378b79
      Ilya Dryomov authored
      commit 8798d070
      
       upstream.
      
      Skipping the "lock has been released" notification if the lock owner
      is not what we expect based on owner_cid can lead to I/O hangs.
      One example is our own notifications: because owner_cid is cleared
      in rbd_unlock(), when we get our own notification it is processed as
      unexpected/duplicate and maybe_kick_acquire() isn't called.  If a peer
      that requested the lock then doesn't go through with acquiring it,
      I/O requests that came in while the lock was being quiesced would
      be stalled until another I/O request is submitted and kicks acquire
      from rbd_img_exclusive_lock().
      
      This makes the comment in rbd_release_lock() actually true: prior to
      this change the canceled work was being requeued in response to the
      "lock has been acquired" notification from rbd_handle_acquired_lock().
      
      Cc: stable@vger.kernel.org # 5.3+
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Tested-by: default avatarRobin Geuze <robin.geuze@nl.team.blue>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ba378b79
    • Ilya Dryomov's avatar
      rbd: don't hold lock_rwsem while running_list is being drained · 13066d66
      Ilya Dryomov authored
      commit ed9eb710
      
       upstream.
      
      Currently rbd_quiesce_lock() holds lock_rwsem for read while blocking
      on releasing_wait completion.  On the I/O completion side, each image
      request also needs to take lock_rwsem for read.  Because rw_semaphore
      implementation doesn't allow new readers after a writer has indicated
      interest in the lock, this can result in a deadlock if something that
      needs to take lock_rwsem for write gets involved.  For example:
      
      1. watch error occurs
      2. rbd_watch_errcb() takes lock_rwsem for write, clears owner_cid and
         releases lock_rwsem
      3. after reestablishing the watch, rbd_reregister_watch() takes
         lock_rwsem for write and calls rbd_reacquire_lock()
      4. rbd_quiesce_lock() downgrades lock_rwsem to for read and blocks on
         releasing_wait until running_list becomes empty
      5. another watch error occurs
      6. rbd_watch_errcb() blocks trying to take lock_rwsem for write
      7. no in-flight image request can complete and delete itself from
         running_list because lock_rwsem won't be granted anymore
      
      A similar scenario can occur with "lock has been acquired" and "lock
      has been released" notification handers which also take lock_rwsem for
      write to update owner_cid.
      
      We don't actually get anything useful from sitting on lock_rwsem in
      rbd_quiesce_lock() -- owner_cid updates certainly don't need to be
      synchronized with.  In fact the whole owner_cid tracking logic could
      probably be removed from the kernel client because we don't support
      proxied maintenance operations.
      
      Cc: stable@vger.kernel.org # 5.3+
      URL: https://tracker.ceph.com/issues/42757
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Tested-by: default avatarRobin Geuze <robin.geuze@nl.team.blue>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      13066d66
    • Mike Kravetz's avatar
      hugetlbfs: fix mount mode command line processing · b12ead82
      Mike Kravetz authored
      commit e0f7e2b2 upstream.
      
      In commit 32021982 ("hugetlbfs: Convert to fs_context") processing
      of the mount mode string was changed from match_octal() to fsparam_u32.
      
      This changed existing behavior as match_octal does not require octal
      values to have a '0' prefix, but fsparam_u32 does.
      
      Use fsparam_u32oct which provides the same behavior as match_octal.
      
      Link: https://lkml.kernel.org/r/20210721183326.102716-1-mike.kravetz@oracle.com
      Fixes: 32021982
      
       ("hugetlbfs: Convert to fs_context")
      Signed-off-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Reported-by: default avatarDennis Camera <bugs+kernel.org@dtnr.ch>
      Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b12ead82
    • Peter Collingbourne's avatar
      userfaultfd: do not untag user pointers · 60dbbd76
      Peter Collingbourne authored
      commit e71e2ace upstream.
      
      Patch series "userfaultfd: do not untag user pointers", v5.
      
      If a user program uses userfaultfd on ranges of heap memory, it may end
      up passing a tagged pointer to the kernel in the range.start field of
      the UFFDIO_REGISTER ioctl.  This can happen when using an MTE-capable
      allocator, or on Android if using the Tagged Pointers feature for MTE
      readiness [1].
      
      When a fault subsequently occurs, the tag is stripped from the fault
      address returned to the application in the fault.address field of struct
      uffd_msg.  However, from the application's perspective, the tagged
      address *is* the memory address, so if the application is unaware of
      memory tags, it may get confused by receiving an address that is, from
      its point of view, outside of the bounds of the allocation.  We observed
      this behavior in the kselftest for userfaultfd [2] but other
      applications could have the same problem.
      
      Address this by not untagging pointers passed to the userfaultfd ioctls.
      Instead, let the system call fail.  Also change the kselftest to use
      mmap so that it doesn't encounter this problem.
      
      [1] https://source.android.com/devices/tech/debug/tagged-pointers
      [2] tools/testing/selftests/vm/userfaultfd.c
      
      This patch (of 2):
      
      Do not untag pointers passed to the userfaultfd ioctls.  Instead, let
      the system call fail.  This will provide an early indication of problems
      with tag-unaware userspace code instead of letting the code get confused
      later, and is consistent with how we decided to handle brk/mmap/mremap
      in commit dcde2373 ("mm: Avoid creating virtual address aliases in
      brk()/mmap()/mremap()"), as well as being consistent with the existing
      tagged address ABI documentation relating to how ioctl arguments are
      handled.
      
      The code change is a revert of commit 7d032574 ("userfaultfd: untag
      user pointers") plus some fixups to some additional calls to
      validate_range that have appeared since then.
      
      [1] https://source.android.com/devices/tech/debug/tagged-pointers
      [2] tools/testing/selftests/vm/userfaultfd.c
      
      Link: https://lkml.kernel.org/r/20210714195437.118982-1-pcc@google.com
      Link: https://lkml.kernel.org/r/20210714195437.118982-2-pcc@google.com
      Link: https://linux-review.googlesource.com/id/I761aa9f0344454c482b83fcfcce547db0a25501b
      Fixes: 63f0c603
      
       ("arm64: Introduce prctl() options to control the tagged user addresses ABI")
      Signed-off-by: default avatarPeter Collingbourne <pcc@google.com>
      Reviewed-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Alistair Delva <adelva@google.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Dave Martin <Dave.Martin@arm.com>
      Cc: Evgenii Stepanov <eugenis@google.com>
      Cc: Lokesh Gidra <lokeshgidra@google.com>
      Cc: Mitch Phillips <mitchp@google.com>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: William McVicker <willmcvicker@google.com>
      Cc: <stable@vger.kernel.org>	[5.4]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      60dbbd76
    • Peter Collingbourne's avatar
      selftest: use mmap instead of posix_memalign to allocate memory · 540eee8c
      Peter Collingbourne authored
      commit 0db282ba upstream.
      
      This test passes pointers obtained from anon_allocate_area to the
      userfaultfd and mremap APIs.  This causes a problem if the system
      allocator returns tagged pointers because with the tagged address ABI
      the kernel rejects tagged addresses passed to these APIs, which would
      end up causing the test to fail.  To make this test compatible with such
      system allocators, stop using the system allocator to allocate memory in
      anon_allocate_area, and instead just use mmap.
      
      Link: https://lkml.kernel.org/r/20210714195437.118982-3-pcc@google.com
      Link: https://linux-review.googlesource.com/id/Icac91064fcd923f77a83e8e133f8631c5b8fc241
      Fixes: c47174fc
      
       ("userfaultfd: selftest")
      Co-developed-by: default avatarLokesh Gidra <lokeshgidra@google.com>
      Signed-off-by: default avatarLokesh Gidra <lokeshgidra@google.com>
      Signed-off-by: default avatarPeter Collingbourne <pcc@google.com>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Cc: Dave Martin <Dave.Martin@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Alistair Delva <adelva@google.com>
      Cc: William McVicker <willmcvicker@google.com>
      Cc: Evgenii Stepanov <eugenis@google.com>
      Cc: Mitch Phillips <mitchp@google.com>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: <stable@vger.kernel.org>	[5.4]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      540eee8c
    • Markus Boehme's avatar
      ixgbe: Fix packet corruption due to missing DMA sync · e706ac3f
      Markus Boehme authored
      commit 09cfae9f upstream.
      
      When receiving a packet with multiple fragments, hardware may still
      touch the first fragment until the entire packet has been received. The
      driver therefore keeps the first fragment mapped for DMA until end of
      packet has been asserted, and delays its dma_sync call until then.
      
      The driver tries to fit multiple receive buffers on one page. When using
      3K receive buffers (e.g. using Jumbo frames and legacy-rx is turned
      off/build_skb is being used) on an architecture with 4K pages, the
      driver allocates an order 1 compound page and uses one page per receive
      buffer. To determine the correct offset for a delayed DMA sync of the
      first fragment of a multi-fragment packet, the driver then cannot just
      use PAGE_MASK on the DMA address but has to construct a mask based on
      the actual size of the backing page.
      
      Using PAGE_MASK in the 3K RX buffer/4K page architecture configuration
      will always sync the first page of a compound page. With the SWIOTLB
      enabled this can lead to corrupted packets (zeroed out first fragment,
      re-used garbage from another packet) and various consequences, such as
      slow/stalling data transfers and connection resets. For example, testing
      on a link with MTU exceeding 3058 bytes on a host with SWIOTLB enabled
      (e.g. "iommu=soft swiotlb=262144,force") TCP transfers quickly fizzle
      out without this patch.
      
      Cc: stable@vger.kernel.org
      Fixes: 0c5661ec
      
       ("ixgbe: fix crash in build_skb Rx code path")
      Signed-off-by: default avatarMarkus Boehme <markubo@amazon.com>
      Tested-by: default avatarTony Brelinski <tonyx.brelinski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e706ac3f
    • Gustavo A. R. Silva's avatar
      media: ngene: Fix out-of-bounds bug in ngene_command_config_free_buf() · e617fa62
      Gustavo A. R. Silva authored
      commit 8d4abca9 upstream.
      
      Fix an 11-year old bug in ngene_command_config_free_buf() while
      addressing the following warnings caught with -Warray-bounds:
      
      arch/alpha/include/asm/string.h:22:16: warning: '__builtin_memcpy' offset [12, 16] from the object at 'com' is out of the bounds of referenced subobject 'config' with type 'unsigned char' at offset 10 [-Warray-bounds]
      arch/x86/include/asm/string_32.h:182:25: warning: '__builtin_memcpy' offset [12, 16] from the object at 'com' is out of the bounds of referenced subobject 'config' with type 'unsigned char' at offset 10 [-Warray-bounds]
      
      The problem is that the original code is trying to copy 6 bytes of
      data into a one-byte size member _config_ of the wrong structue
      FW_CONFIGURE_BUFFERS, in a single call to memcpy(). This causes a
      legitimate compiler warning because memcpy() overruns the length
      of &com.cmd.ConfigureBuffers.config. It seems that the right
      structure is FW_CONFIGURE_FREE_BUFFERS, instead, because it contains
      6 more members apart from the header _hdr_. Also, the name of
      the function ngene_command_config_free_buf() suggests that the actual
      intention is to ConfigureFreeBuffers, instead of ConfigureBuffers
      (which takes place in the function ngene_command_config_buf(), above).
      
      Fix this by enclosing those 6 members of struct FW_CONFIGURE_FREE_BUFFERS
      into new struct config, and use &com.cmd.ConfigureFreeBuffers.config as
      the destination address, instead of &com.cmd.ConfigureBuffers.config,
      when calling memcpy().
      
      This also helps with the ongoing efforts to globally enable
      -Warray-bounds and get us closer to being able to tighten the
      FORTIFY_SOURCE routines on memcpy().
      
      Link: https://github.com/KSPP/linux/issues/109
      Fixes: dae52d00
      
       ("V4L/DVB: ngene: Initial check-in")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Link: https://lore.kernel.org/linux-hardening/20210420001631.GA45456@embeddedor/
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e617fa62
    • Anand Jain's avatar
      btrfs: check for missing device in btrfs_trim_fs · 77713fb3
      Anand Jain authored
      commit 16a200f6
      
       upstream.
      
      A fstrim on a degraded raid1 can trigger the following null pointer
      dereference:
      
        BTRFS info (device loop0): allowing degraded mounts
        BTRFS info (device loop0): disk space caching is enabled
        BTRFS info (device loop0): has skinny extents
        BTRFS warning (device loop0): devid 2 uuid 97ac16f7-e14d-4db1-95bc-3d489b424adb is missing
        BTRFS warning (device loop0): devid 2 uuid 97ac16f7-e14d-4db1-95bc-3d489b424adb is missing
        BTRFS info (device loop0): enabling ssd optimizations
        BUG: kernel NULL pointer dereference, address: 0000000000000620
        PGD 0 P4D 0
        Oops: 0000 [#1] SMP NOPTI
        CPU: 0 PID: 4574 Comm: fstrim Not tainted 5.13.0-rc7+ #31
        Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
        RIP: 0010:btrfs_trim_fs+0x199/0x4a0 [btrfs]
        RSP: 0018:ffff959541797d28 EFLAGS: 00010293
        RAX: 0000000000000000 RBX: ffff946f84eca508 RCX: a7a67937adff8608
        RDX: ffff946e8122d000 RSI: 0000000000000000 RDI: ffffffffc02fdbf0
        RBP: ffff946ea4615000 R08: 0000000000000001 R09: 0000000000000000
        R10: 0000000000000000 R11: ffff946e8122d960 R12: 0000000000000000
        R13: ffff959541797db8 R14: ffff946e8122d000 R15: ffff959541797db8
        FS:  00007f55917a5080(0000) GS:ffff946f9bc00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000000000620 CR3: 000000002d2c8001 CR4: 00000000000706f0
        Call Trace:
        btrfs_ioctl_fitrim+0x167/0x260 [btrfs]
        btrfs_ioctl+0x1c00/0x2fe0 [btrfs]
        ? selinux_file_ioctl+0x140/0x240
        ? syscall_trace_enter.constprop.0+0x188/0x240
        ? __x64_sys_ioctl+0x83/0xb0
        __x64_sys_ioctl+0x83/0xb0
      
      Reproducer:
      
        $ mkfs.btrfs -fq -d raid1 -m raid1 /dev/loop0 /dev/loop1
        $ mount /dev/loop0 /btrfs
        $ umount /btrfs
        $ btrfs dev scan --forget
        $ mount -o degraded /dev/loop0 /btrfs
      
        $ fstrim /btrfs
      
      The reason is we call btrfs_trim_free_extents() for the missing device,
      which uses device->bdev (NULL for missing device) to find if the device
      supports discard.
      
      Fix is to check if the device is missing before calling
      btrfs_trim_free_extents().
      
      CC: stable@vger.kernel.org # 5.4+
      Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarAnand Jain <anand.jain@oracle.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>
      77713fb3
    • Haoran Luo's avatar
      tracing: Fix bug in rb_per_cpu_empty() that might cause deadloop. · f899f24d
      Haoran Luo authored
      commit 67f0d6d9 upstream.
      
      The "rb_per_cpu_empty()" misinterpret the condition (as not-empty) when
      "head_page" and "commit_page" of "struct ring_buffer_per_cpu" points to
      the same buffer page, whose "buffer_data_page" is empty and "read" field
      is non-zero.
      
      An error scenario could be constructed as followed (kernel perspective):
      
      1. All pages in the buffer has been accessed by reader(s) so that all of
      them will have non-zero "read" field.
      
      2. Read and clear all buffer pages so that "rb_num_of_entries()" will
      return 0 rendering there's no more data to read. It is also required
      that the "read_page", "commit_page" and "tail_page" points to the same
      page, while "head_page" is the next page of them.
      
      3. Invoke "ring_buffer_lock_reserve()" with large enough "length"
      so that it shot pass the end of current tail buffer page. Now the
      "head_page", "commit_page" and "tail_page" points to the same page.
      
      4. Discard current event with "ring_buffer_discard_commit()", so that
      "head_page", "commit_page" and "tail_page" points to a page whose buffer
      data page is now empty.
      
      When the error scenario has been constructed, "tracing_read_pipe" will
      be trapped inside a deadloop: "trace_empty()" returns 0 since
      "rb_per_cpu_empty()" returns 0 when it hits the CPU containing such
      constructed ring buffer. Then "trace_find_next_entry_inc()" always
      return NULL since "rb_num_of_entries()" reports there's no more entry
      to read. Finally "trace_seq_to_user()" returns "-EBUSY" spanking
      "tracing_read_pipe" back to the start of the "waitagain" loop.
      
      I've also written a proof-of-concept script to construct the scenario
      and trigger the bug automatically, you can use it to trace and validate
      my reasoning above:
      
        https://github.com/aegistudio/RingBufferDetonator.git
      
      Tests has been carried out on linux kernel 5.14-rc2
      (2734d6c1), my fixed version
      of kernel (for testing whether my update fixes the bug) and
      some older kernels (for range of affected kernels). Test result is
      also attached to the proof-of-concept repository.
      
      Link: https://lore.kernel.org/linux-trace-devel/YPaNxsIlb2yjSi5Y@aegistudio/
      Link: https://lore.kernel.org/linux-trace-devel/YPgrN85WL9VyrZ55@aegistudio
      
      Cc: stable@vger.kernel.org
      Fixes: bf41a158
      
       ("ring-buffer: make reentrant")
      Suggested-by: default avatarLinus Torvalds <torvalds@linuxfoundation.org>
      Signed-off-by: default avatarHaoran Luo <www@aegistudio.net>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f899f24d
    • Steven Rostedt (VMware)'s avatar
      tracing/histogram: Rename "cpu" to "common_cpu" · 59a9f75f
      Steven Rostedt (VMware) authored
      commit 1e3bac71 upstream.
      
      Currently the histogram logic allows the user to write "cpu" in as an
      event field, and it will record the CPU that the event happened on.
      
      The problem with this is that there's a lot of events that have "cpu"
      as a real field, and using "cpu" as the CPU it ran on, makes it
      impossible to run histograms on the "cpu" field of events.
      
      For example, if I want to have a histogram on the count of the
      workqueue_queue_work event on its cpu field, running:
      
       ># echo 'hist:keys=cpu' > events/workqueue/workqueue_queue_work/trigger
      
      Gives a misleading and wrong result.
      
      Change the command to "common_cpu" as no event should have "common_*"
      fields as that's a reserved name for fields used by all events. And
      this makes sense here as common_cpu would be a field used by all events.
      
      Now we can even do:
      
       ># echo 'hist:keys=common_cpu,cpu if cpu < 100' > events/workqueue/workqueue_queue_work/trigger
       ># cat events/workqueue/workqueue_queue_work/hist
       # event histogram
       #
       # trigger info: hist:keys=common_cpu,cpu:vals=hitcount:sort=hitcount:size=2048 if cpu < 100 [active]
       #
      
       { common_cpu:          0, cpu:          2 } hitcount:          1
       { common_cpu:          0, cpu:          4 } hitcount:          1
       { common_cpu:          7, cpu:          7 } hitcount:          1
       { common_cpu:          0, cpu:          7 } hitcount:          1
       { common_cpu:          0, cpu:          1 } hitcount:          1
       { common_cpu:          0, cpu:          6 } hitcount:          2
       { common_cpu:          0, cpu:          5 } hitcount:          2
       { common_cpu:          1, cpu:          1 } hitcount:          4
       { common_cpu:          6, cpu:          6 } hitcount:          4
       { common_cpu:          5, cpu:          5 } hitcount:         14
       { common_cpu:          4, cpu:          4 } hitcount:         26
       { common_cpu:          0, cpu:          0 } hitcount:         39
       { common_cpu:          2, cpu:          2 } hitcount:        184
      
      Now for backward compatibility, I added a trick. If "cpu" is used, and
      the field is not found, it will fall back to "common_cpu" and work as
      it did before. This way, it will still work for old programs that use
      "cpu" to get the actual CPU, but if the event has a "cpu" as a field, it
      will get that event's "cpu" field, which is probably what it wants
      anyway.
      
      I updated the tracefs/README to include documentation about both the
      common_timestamp and the common_cpu. This way, if that text is present in
      the README, then an application can know that common_cpu is supported over
      just plain "cpu".
      
      Link: https://lkml.kernel.org/r/20210721110053.26b4f641@oasis.local.home
      
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: stable@vger.kernel.org
      Fixes: 8b7622bf
      
       ("tracing: Add cpu field for hist triggers")
      Reviewed-by: default avatarTom Zanussi <zanussi@kernel.org>
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      59a9f75f
    • Marc Zyngier's avatar
      firmware/efi: Tell memblock about EFI iomem reservations · 379d8da3
      Marc Zyngier authored
      commit 2bab693a
      
       upstream.
      
      kexec_load_file() relies on the memblock infrastructure to avoid
      stamping over regions of memory that are essential to the survival
      of the system.
      
      However, nobody seems to agree how to flag these regions as reserved,
      and (for example) EFI only publishes its reservations in /proc/iomem
      for the benefit of the traditional, userspace based kexec tool.
      
      On arm64 platforms with GICv3, this can result in the payload being
      placed at the location of the LPI tables. Shock, horror!
      
      Let's augment the EFI reservation code with a memblock_reserve() call,
      protecting our dear tables from the secondary kernel invasion.
      
      Reported-by: default avatarMoritz Fischer <mdf@kernel.org>
      Tested-by: default avatarMoritz Fischer <mdf@kernel.org>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Cc: stable@vger.kernel.org
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: James Morse <james.morse@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      379d8da3
    • Minas Harutyunyan's avatar
      usb: dwc2: gadget: Fix sending zero length packet in DDMA mode. · 281a9436
      Minas Harutyunyan authored
      commit d53dc388 upstream.
      
      Sending zero length packet in DDMA mode perform by DMA descriptor
      by setting SP (short packet) flag.
      
      For DDMA in function dwc2_hsotg_complete_in() does not need to send
      zlp.
      
      Tested by USBCV MSC tests.
      
      Fixes: f71b5e25
      
       ("usb: dwc2: gadget: fix zero length packet transfers")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarMinas Harutyunyan <Minas.Harutyunyan@synopsys.com>
      Link: https://lore.kernel.org/r/967bad78c55dd2db1c19714eee3d0a17cf99d74a.1626777738.git.Minas.Harutyunyan@synopsys.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      281a9436
    • John Keeping's avatar
      USB: serial: cp210x: add ID for CEL EM3588 USB ZigBee stick · 167079fb
      John Keeping authored
      commit d6a206e6
      
       upstream.
      
      Add the USB serial device ID for the CEL ZigBee EM3588 radio stick.
      
      Signed-off-by: default avatarJohn Keeping <john@metanate.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      167079fb