Skip to content
  1. Apr 02, 2020
    • Taehee Yoo's avatar
      hsr: set .netnsok flag · 4ba7450c
      Taehee Yoo authored
      [ Upstream commit 09e91dbe ]
      
      The hsr module has been supporting the list and status command.
      (HSR_C_GET_NODE_LIST and HSR_C_GET_NODE_STATUS)
      These commands send node information to the user-space via generic netlink.
      But, in the non-init_net namespace, these commands are not allowed
      because .netnsok flag is false.
      So, there is no way to get node information in the non-init_net namespace.
      
      Fixes: f421436a
      
       ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4ba7450c
    • Taehee Yoo's avatar
      hsr: add restart routine into hsr_get_node_list() · 718742a0
      Taehee Yoo authored
      [ Upstream commit ca19c70f ]
      
      The hsr_get_node_list() is to send node addresses to the userspace.
      If there are so many nodes, it could fail because of buffer size.
      In order to avoid this failure, the restart routine is added.
      
      Fixes: f421436a
      
       ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      718742a0
    • Taehee Yoo's avatar
      hsr: use rcu_read_lock() in hsr_get_node_{list/status}() · 16da9c5d
      Taehee Yoo authored
      [ Upstream commit 173756b8 ]
      
      hsr_get_node_{list/status}() are not under rtnl_lock() because
      they are callback functions of generic netlink.
      But they use __dev_get_by_index() without rtnl_lock().
      So, it would use unsafe data.
      In order to fix it, rcu_read_lock() and dev_get_by_index_rcu()
      are used instead of __dev_get_by_index().
      
      Fixes: f421436a
      
       ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      16da9c5d
    • Taehee Yoo's avatar
      vxlan: check return value of gro_cells_init() · b200a210
      Taehee Yoo authored
      [ Upstream commit 384d91c2 ]
      
      gro_cells_init() returns error if memory allocation is failed.
      But the vxlan module doesn't check the return value of gro_cells_init().
      
      Fixes: 58ce31cc
      
       ("vxlan: GRO support at tunnel layer")`
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b200a210
    • René van Dorst's avatar
      net: dsa: mt7530: Change the LINK bit to reflect the link status · bee69eac
      René van Dorst authored
      [ Upstream commit 22259471 ]
      
      Andrew reported:
      
      After a number of network port link up/down changes, sometimes the switch
      port gets stuck in a state where it thinks it is still transmitting packets
      but the cpu port is not actually transmitting anymore. In this state you
      will see a message on the console
      "mtk_soc_eth 1e100000.ethernet eth0: transmit timed out" and the Tx counter
      in ifconfig will be incrementing on virtual port, but not incrementing on
      cpu port.
      
      The issue is that MAC TX/RX status has no impact on the link status or
      queue manager of the switch. So the queue manager just queues up packets
      of a disabled port and sends out pause frames when the queue is full.
      
      Change the LINK bit to reflect the link status.
      
      Fixes: b8f126a8
      
       ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
      Reported-by: default avatarAndrew Smith <andrew.smith@digi.com>
      Signed-off-by: default avatarRené van Dorst <opensource@vdorst.com>
      Reviewed-by: default avatarVivien Didelot <vivien.didelot@gmail.com>
      Reviewed-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>
      bee69eac
    • Edwin Peer's avatar
      bnxt_en: fix memory leaks in bnxt_dcbnl_ieee_getets() · f9c47737
      Edwin Peer authored
      [ Upstream commit 62d4073e ]
      
      The allocated ieee_ets structure goes out of scope without being freed,
      leaking memory. Appropriate result codes should be returned so that
      callers do not rely on invalid data passed by reference.
      
      Also cache the ETS config retrieved from the device so that it doesn't
      need to be freed. The balance of the code was clearly written with the
      intent of having the results of querying the hardware cached in the
      device structure. The commensurate store was evidently missed though.
      
      Fixes: 7df4ae9f
      
       ("bnxt_en: Implement DCBNL to support host-based DCBX.")
      Signed-off-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f9c47737
    • Oliver Hartkopp's avatar
      slcan: not call free_netdev before rtnl_unlock in slcan_open · 795536e9
      Oliver Hartkopp authored
      [ Upstream commit 2091a3d4 ]
      
      As the description before netdev_run_todo, we cannot call free_netdev
      before rtnl_unlock, fix it by reorder the code.
      
      This patch is a 1:1 copy of upstream slip.c commit f596c870
      
      
      ("slip: not call free_netdev before rtnl_unlock in slip_open").
      
      Reported-by: default avataryangerkun <yangerkun@huawei.com>
      Signed-off-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      795536e9
    • Dan Carpenter's avatar
      NFC: fdp: Fix a signedness bug in fdp_nci_send_patch() · dc583862
      Dan Carpenter authored
      [ Upstream commit 0dcdf9f6 ]
      
      The nci_conn_max_data_pkt_payload_size() function sometimes returns
      -EPROTO so "max_size" needs to be signed for the error handling to
      work.  We can make "payload_size" an int as well.
      
      Fixes: a06347c0
      
       ("NFC: Add Intel Fields Peak NFC solution driver")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dc583862
    • Emil Renner Berthing's avatar
      net: stmmac: dwmac-rk: fix error path in rk_gmac_probe · acfd29fa
      Emil Renner Berthing authored
      [ Upstream commit 9de9aa48 ]
      
      Make sure we clean up devicetree related configuration
      also when clock init fails.
      
      Fixes: fecd4d7e
      
       ("net: stmmac: dwmac-rk: Add integrated PHY support")
      Signed-off-by: default avatarEmil Renner Berthing <kernel@esmil.dk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      acfd29fa
    • Cong Wang's avatar
      net_sched: keep alloc_hash updated after hash allocation · 9f8b6c44
      Cong Wang authored
      [ Upstream commit 0d1c3530 ]
      
      In commit 599be01e
      
       ("net_sched: fix an OOB access in cls_tcindex")
      I moved cp->hash calculation before the first
      tcindex_alloc_perfect_hash(), but cp->alloc_hash is left untouched.
      This difference could lead to another out of bound access.
      
      cp->alloc_hash should always be the size allocated, we should
      update it after this tcindex_alloc_perfect_hash().
      
      Reported-and-tested-by: default avatar <syzbot+dcc34d54d68ef7d2d53d@syzkaller.appspotmail.com>
      Reported-and-tested-by: default avatar <syzbot+c72da7b9ed57cde6fca2@syzkaller.appspotmail.com>
      Fixes: 599be01e
      
       ("net_sched: fix an OOB access in cls_tcindex")
      Cc: Jamal Hadi Salim <jhs@mojatatu.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9f8b6c44
    • Cong Wang's avatar
      net_sched: cls_route: remove the right filter from hashtable · f0c92f59
      Cong Wang authored
      [ Upstream commit ef299cc3
      
       ]
      
      route4_change() allocates a new filter and copies values from
      the old one. After the new filter is inserted into the hash
      table, the old filter should be removed and freed, as the final
      step of the update.
      
      However, the current code mistakenly removes the new one. This
      looks apparently wrong to me, and it causes double "free" and
      use-after-free too, as reported by syzbot.
      
      Reported-and-tested-by: default avatar <syzbot+f9b32aaacd60305d9687@syzkaller.appspotmail.com>
      Reported-and-tested-by: default avatar <syzbot+2f8c233f131943d6056d@syzkaller.appspotmail.com>
      Reported-and-tested-by: default avatar <syzbot+9c2df9fd5e9445b74e01@syzkaller.appspotmail.com>
      Fixes: 1109c005
      
       ("net: sched: RCU cls_route")
      Cc: Jamal Hadi Salim <jhs@mojatatu.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f0c92f59
    • Pawel Dembicki's avatar
      net: qmi_wwan: add support for ASKEY WWHC050 · ee86fd16
      Pawel Dembicki authored
      [ Upstream commit 12a5ba5a
      
       ]
      
      ASKEY WWHC050 is a mcie LTE modem.
      The oem configuration states:
      
      T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480  MxCh= 0
      D:  Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
      P:  Vendor=1690 ProdID=7588 Rev=ff.ff
      S:  Manufacturer=Android
      S:  Product=Android
      S:  SerialNumber=813f0eef6e6e
      C:* #Ifs= 6 Cfg#= 1 Atr=80 MxPwr=500mA
      I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
      E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none)
      E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
      E:  Ad=84(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
      E:  Ad=86(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
      E:  Ad=88(I) Atr=03(Int.) MxPS=   8 Ivl=32ms
      E:  Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 5 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=(none)
      E:  Ad=89(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=125us
      
      Tested on openwrt distribution.
      
      Signed-off-by: default avatarCezary Jackiewicz <cezary@eko.one.pl>
      Signed-off-by: default avatarPawel Dembicki <paweldembicki@gmail.com>
      Acked-by: default avatarBjørn Mork <bjorn@mork.no>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ee86fd16
    • Willem de Bruijn's avatar
      net/packet: tpacket_rcv: avoid a producer race condition · 2975472e
      Willem de Bruijn authored
      [ Upstream commit 61fad681
      
       ]
      
      PACKET_RX_RING can cause multiple writers to access the same slot if a
      fast writer wraps the ring while a slow writer is still copying. This
      is particularly likely with few, large, slots (e.g., GSO packets).
      
      Synchronize kernel thread ownership of rx ring slots with a bitmap.
      
      Writers acquire a slot race-free by testing tp_status TP_STATUS_KERNEL
      while holding the sk receive queue lock. They release this lock before
      copying and set tp_status to TP_STATUS_USER to release to userspace
      when done. During copying, another writer may take the lock, also see
      TP_STATUS_KERNEL, and start writing to the same slot.
      
      Introduce a new rx_owner_map bitmap with a bit per slot. To acquire a
      slot, test and set with the lock held. To release race-free, update
      tp_status and owner bit as a transaction, so take the lock again.
      
      This is the one of a variety of discussed options (see Link below):
      
      * instead of a shadow ring, embed the data in the slot itself, such as
      in tp_padding. But any test for this field may match a value left by
      userspace, causing deadlock.
      
      * avoid the lock on release. This leaves a small race if releasing the
      shadow slot before setting TP_STATUS_USER. The below reproducer showed
      that this race is not academic. If releasing the slot after tp_status,
      the race is more subtle. See the first link for details.
      
      * add a new tp_status TP_KERNEL_OWNED to avoid the transactional store
      of two fields. But, legacy applications may interpret all non-zero
      tp_status as owned by the user. As libpcap does. So this is possible
      only opt-in by newer processes. It can be added as an optional mode.
      
      * embed the struct at the tail of pg_vec to avoid extra allocation.
      The implementation proved no less complex than a separate field.
      
      The additional locking cost on release adds contention, no different
      than scaling on multicore or multiqueue h/w. In practice, below
      reproducer nor small packet tcpdump showed a noticeable change in
      perf report in cycles spent in spinlock. Where contention is
      problematic, packet sockets support mitigation through PACKET_FANOUT.
      And we can consider adding opt-in state TP_KERNEL_OWNED.
      
      Easy to reproduce by running multiple netperf or similar TCP_STREAM
      flows concurrently with `tcpdump -B 129 -n greater 60000`.
      
      Based on an earlier patchset by Jon Rosen. See links below.
      
      I believe this issue goes back to the introduction of tpacket_rcv,
      which predates git history.
      
      Link: https://www.mail-archive.com/netdev@vger.kernel.org/msg237222.html
      Suggested-by: default avatarJon Rosen <jrosen@cisco.com>
      Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarJon Rosen <jrosen@cisco.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2975472e
    • Jisheng Zhang's avatar
      net: mvneta: Fix the case where the last poll did not process all rx · 7645f403
      Jisheng Zhang authored
      [ Upstream commit 065fd83e ]
      
      For the case where the last mvneta_poll did not process all
      RX packets, we need to xor the pp->cause_rx_tx or port->cause_rx_tx
      before claculating the rx_queue.
      
      Fixes: 2dcf75e2
      
       ("net: mvneta: Associate RX queues with each CPU")
      Signed-off-by: default avatarJisheng Zhang <Jisheng.Zhang@synaptics.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7645f403
    • Florian Fainelli's avatar
      net: dsa: Fix duplicate frames flooded by learning · c5980c71
      Florian Fainelli authored
      [ Upstream commit 0e62f543 ]
      
      When both the switch and the bridge are learning about new addresses,
      switch ports attached to the bridge would see duplicate ARP frames
      because both entities would attempt to send them.
      
      Fixes: 5037d532
      
       ("net: dsa: add Broadcom tag RX/TX handler")
      Reported-by: default avatarMaxime Bizon <mbizon@freebox.fr>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: default avatarVivien Didelot <vivien.didelot@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c5980c71
    • Willem de Bruijn's avatar
      macsec: restrict to ethernet devices · dccb6b9b
      Willem de Bruijn authored
      [ Upstream commit b06d072c
      
       ]
      
      Only attach macsec to ethernet devices.
      
      Syzbot was able to trigger a KMSAN warning in macsec_handle_frame
      by attaching to a phonet device.
      
      Macvlan has a similar check in macvlan_port_create.
      
      v1->v2
        - fix commit message typo
      
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dccb6b9b
    • Taehee Yoo's avatar
      hsr: fix general protection fault in hsr_addr_is_self() · b597b0c4
      Taehee Yoo authored
      [ Upstream commit 3a303cfd
      
       ]
      
      The port->hsr is used in the hsr_handle_frame(), which is a
      callback of rx_handler.
      hsr master and slaves are initialized in hsr_add_port().
      This function initializes several pointers, which includes port->hsr after
      registering rx_handler.
      So, in the rx_handler routine, un-initialized pointer would be used.
      In order to fix this, pointers should be initialized before
      registering rx_handler.
      
      Test commands:
          ip netns del left
          ip netns del right
          modprobe -rv veth
          modprobe -rv hsr
          killall ping
          modprobe hsr
          ip netns add left
          ip netns add right
          ip link add veth0 type veth peer name veth1
          ip link add veth2 type veth peer name veth3
          ip link add veth4 type veth peer name veth5
          ip link set veth1 netns left
          ip link set veth3 netns right
          ip link set veth4 netns left
          ip link set veth5 netns right
          ip link set veth0 up
          ip link set veth2 up
          ip link set veth0 address fc:00:00:00:00:01
          ip link set veth2 address fc:00:00:00:00:02
          ip netns exec left ip link set veth1 up
          ip netns exec left ip link set veth4 up
          ip netns exec right ip link set veth3 up
          ip netns exec right ip link set veth5 up
          ip link add hsr0 type hsr slave1 veth0 slave2 veth2
          ip a a 192.168.100.1/24 dev hsr0
          ip link set hsr0 up
          ip netns exec left ip link add hsr1 type hsr slave1 veth1 slave2 veth4
          ip netns exec left ip a a 192.168.100.2/24 dev hsr1
          ip netns exec left ip link set hsr1 up
          ip netns exec left ip n a 192.168.100.1 dev hsr1 lladdr \
      	    fc:00:00:00:00:01 nud permanent
          ip netns exec left ip n r 192.168.100.1 dev hsr1 lladdr \
      	    fc:00:00:00:00:01 nud permanent
          for i in {1..100}
          do
              ip netns exec left ping 192.168.100.1 &
          done
          ip netns exec left hping3 192.168.100.1 -2 --flood &
          ip netns exec right ip link add hsr2 type hsr slave1 veth3 slave2 veth5
          ip netns exec right ip a a 192.168.100.3/24 dev hsr2
          ip netns exec right ip link set hsr2 up
          ip netns exec right ip n a 192.168.100.1 dev hsr2 lladdr \
      	    fc:00:00:00:00:02 nud permanent
          ip netns exec right ip n r 192.168.100.1 dev hsr2 lladdr \
      	    fc:00:00:00:00:02 nud permanent
          for i in {1..100}
          do
              ip netns exec right ping 192.168.100.1 &
          done
          ip netns exec right hping3 192.168.100.1 -2 --flood &
          while :
          do
              ip link add hsr0 type hsr slave1 veth0 slave2 veth2
      	ip a a 192.168.100.1/24 dev hsr0
      	ip link set hsr0 up
      	ip link del hsr0
          done
      
      Splat looks like:
      [  120.954938][    C0] general protection fault, probably for non-canonical address 0xdffffc0000000006: 0000 [#1]I
      [  120.957761][    C0] KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037]
      [  120.959064][    C0] CPU: 0 PID: 1511 Comm: hping3 Not tainted 5.6.0-rc5+ #460
      [  120.960054][    C0] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      [  120.962261][    C0] RIP: 0010:hsr_addr_is_self+0x65/0x2a0 [hsr]
      [  120.963149][    C0] Code: 44 24 18 70 73 2f c0 48 c1 eb 03 48 8d 04 13 c7 00 f1 f1 f1 f1 c7 40 04 00 f2 f2 f2 4
      [  120.966277][    C0] RSP: 0018:ffff8880d9c09af0 EFLAGS: 00010206
      [  120.967293][    C0] RAX: 0000000000000006 RBX: 1ffff1101b38135f RCX: 0000000000000000
      [  120.968516][    C0] RDX: dffffc0000000000 RSI: ffff8880d17cb208 RDI: 0000000000000000
      [  120.969718][    C0] RBP: 0000000000000030 R08: ffffed101b3c0e3c R09: 0000000000000001
      [  120.972203][    C0] R10: 0000000000000001 R11: ffffed101b3c0e3b R12: 0000000000000000
      [  120.973379][    C0] R13: ffff8880aaf80100 R14: ffff8880aaf800f2 R15: ffff8880aaf80040
      [  120.974410][    C0] FS:  00007f58e693f740(0000) GS:ffff8880d9c00000(0000) knlGS:0000000000000000
      [  120.979794][    C0] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  120.980773][    C0] CR2: 00007ffcb8b38f29 CR3: 00000000afe8e001 CR4: 00000000000606f0
      [  120.981945][    C0] Call Trace:
      [  120.982411][    C0]  <IRQ>
      [  120.982848][    C0]  ? hsr_add_node+0x8c0/0x8c0 [hsr]
      [  120.983522][    C0]  ? rcu_read_lock_held+0x90/0xa0
      [  120.984159][    C0]  ? rcu_read_lock_sched_held+0xc0/0xc0
      [  120.984944][    C0]  hsr_handle_frame+0x1db/0x4e0 [hsr]
      [  120.985597][    C0]  ? hsr_nl_nodedown+0x2b0/0x2b0 [hsr]
      [  120.986289][    C0]  __netif_receive_skb_core+0x6bf/0x3170
      [  120.992513][    C0]  ? check_chain_key+0x236/0x5d0
      [  120.993223][    C0]  ? do_xdp_generic+0x1460/0x1460
      [  120.993875][    C0]  ? register_lock_class+0x14d0/0x14d0
      [  120.994609][    C0]  ? __netif_receive_skb_one_core+0x8d/0x160
      [  120.995377][    C0]  __netif_receive_skb_one_core+0x8d/0x160
      [  120.996204][    C0]  ? __netif_receive_skb_core+0x3170/0x3170
      [ ... ]
      
      Reported-by: default avatar <syzbot+fcf5dd39282ceb27108d@syzkaller.appspotmail.com>
      Fixes: c5a75911
      
       ("net/hsr: Use list_head (and rcu) instead of array for slave devices.")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b597b0c4
    • Lyude Paul's avatar
      Revert "drm/dp_mst: Skip validating ports during destruction, just ref" · 0207ef33
      Lyude Paul authored
      commit 9765635b upstream.
      
      This reverts commit:
      
      c54c7374
      
       ("drm/dp_mst: Skip validating ports during destruction, just ref")
      
      ugh.
      
      In drm_dp_destroy_connector_work(), we have a pretty good chance of
      freeing the actual struct drm_dp_mst_port. However, after destroying
      things we send a hotplug through (*mgr->cbs->hotplug)(mgr) which is
      where the problems start.
      
      For i915, this calls all the way down to the fbcon probing helpers,
      which start trying to access the port in a modeset.
      
      [   45.062001] ==================================================================
      [   45.062112] BUG: KASAN: use-after-free in ex_handler_refcount+0x146/0x180
      [   45.062196] Write of size 4 at addr ffff8882b4b70968 by task kworker/3:1/53
      
      [   45.062325] CPU: 3 PID: 53 Comm: kworker/3:1 Kdump: loaded Tainted: G           O      4.20.0-rc4Lyude-Test+ #3
      [   45.062442] Hardware name: LENOVO 20BWS1KY00/20BWS1KY00, BIOS JBET71WW (1.35 ) 09/14/2018
      [   45.062554] Workqueue: events drm_dp_destroy_connector_work [drm_kms_helper]
      [   45.062641] Call Trace:
      [   45.062685]  dump_stack+0xbd/0x15a
      [   45.062735]  ? dump_stack_print_info.cold.0+0x1b/0x1b
      [   45.062801]  ? printk+0x9f/0xc5
      [   45.062847]  ? kmsg_dump_rewind_nolock+0xe4/0xe4
      [   45.062909]  ? ex_handler_refcount+0x146/0x180
      [   45.062970]  print_address_description+0x71/0x239
      [   45.063036]  ? ex_handler_refcount+0x146/0x180
      [   45.063095]  kasan_report.cold.5+0x242/0x30b
      [   45.063155]  __asan_report_store4_noabort+0x1c/0x20
      [   45.063313]  ex_handler_refcount+0x146/0x180
      [   45.063371]  ? ex_handler_clear_fs+0xb0/0xb0
      [   45.063428]  fixup_exception+0x98/0xd7
      [   45.063484]  ? raw_notifier_call_chain+0x20/0x20
      [   45.063548]  do_trap+0x6d/0x210
      [   45.063605]  ? _GLOBAL__sub_I_65535_1_drm_dp_aux_unregister_devnode+0x2f/0x1c6 [drm_kms_helper]
      [   45.063732]  do_error_trap+0xc0/0x170
      [   45.063802]  ? _GLOBAL__sub_I_65535_1_drm_dp_aux_unregister_devnode+0x2f/0x1c6 [drm_kms_helper]
      [   45.063929]  do_invalid_op+0x3b/0x50
      [   45.063997]  ? _GLOBAL__sub_I_65535_1_drm_dp_aux_unregister_devnode+0x2f/0x1c6 [drm_kms_helper]
      [   45.064103]  invalid_op+0x14/0x20
      [   45.064162] RIP: 0010:_GLOBAL__sub_I_65535_1_drm_dp_aux_unregister_devnode+0x2f/0x1c6 [drm_kms_helper]
      [   45.064274] Code: 00 48 c7 c7 80 fe 53 a0 48 89 e5 e8 5b 6f 26 e1 5d c3 48 8d 0e 0f 0b 48 8d 0b 0f 0b 48 8d 0f 0f 0b 48 8d 0f 0f 0b 49 8d 4d 00 <0f> 0b 49 8d 0e 0f 0b 48 8d 08 0f 0b 49 8d 4d 00 0f 0b 48 8d 0b 0f
      [   45.064569] RSP: 0018:ffff8882b789ee10 EFLAGS: 00010282
      [   45.064637] RAX: ffff8882af47ae70 RBX: ffff8882af47aa60 RCX: ffff8882b4b70968
      [   45.064723] RDX: ffff8882af47ae70 RSI: 0000000000000008 RDI: ffff8882b788bdb8
      [   45.064808] RBP: ffff8882b789ee28 R08: ffffed1056f13db4 R09: ffffed1056f13db3
      [   45.064894] R10: ffffed1056f13db3 R11: ffff8882b789ed9f R12: ffff8882af47ad28
      [   45.064980] R13: ffff8882b4b70968 R14: ffff8882acd86728 R15: ffff8882b4b75dc8
      [   45.065084]  drm_dp_mst_reset_vcpi_slots+0x12/0x80 [drm_kms_helper]
      [   45.065225]  intel_mst_disable_dp+0xda/0x180 [i915]
      [   45.065361]  intel_encoders_disable.isra.107+0x197/0x310 [i915]
      [   45.065498]  haswell_crtc_disable+0xbe/0x400 [i915]
      [   45.065622]  ? i9xx_disable_plane+0x1c0/0x3e0 [i915]
      [   45.065750]  intel_atomic_commit_tail+0x74e/0x3e60 [i915]
      [   45.065884]  ? intel_pre_plane_update+0xbc0/0xbc0 [i915]
      [   45.065968]  ? drm_atomic_helper_swap_state+0x88b/0x1d90 [drm_kms_helper]
      [   45.066054]  ? kasan_check_write+0x14/0x20
      [   45.066165]  ? i915_gem_track_fb+0x13a/0x330 [i915]
      [   45.066277]  ? i915_sw_fence_complete+0xe9/0x140 [i915]
      [   45.066406]  ? __i915_sw_fence_complete+0xc50/0xc50 [i915]
      [   45.066540]  intel_atomic_commit+0x72e/0xef0 [i915]
      [   45.066635]  ? drm_dev_dbg+0x200/0x200 [drm]
      [   45.066764]  ? intel_atomic_commit_tail+0x3e60/0x3e60 [i915]
      [   45.066898]  ? intel_atomic_commit_tail+0x3e60/0x3e60 [i915]
      [   45.067001]  drm_atomic_commit+0xc4/0xf0 [drm]
      [   45.067074]  restore_fbdev_mode_atomic+0x562/0x780 [drm_kms_helper]
      [   45.067166]  ? drm_fb_helper_debug_leave+0x690/0x690 [drm_kms_helper]
      [   45.067249]  ? kasan_check_read+0x11/0x20
      [   45.067324]  restore_fbdev_mode+0x127/0x4b0 [drm_kms_helper]
      [   45.067364]  ? kasan_check_read+0x11/0x20
      [   45.067406]  drm_fb_helper_restore_fbdev_mode_unlocked+0x164/0x200 [drm_kms_helper]
      [   45.067462]  ? drm_fb_helper_hotplug_event+0x30/0x30 [drm_kms_helper]
      [   45.067508]  ? kasan_check_write+0x14/0x20
      [   45.070360]  ? mutex_unlock+0x22/0x40
      [   45.073748]  drm_fb_helper_set_par+0xb2/0xf0 [drm_kms_helper]
      [   45.075846]  drm_fb_helper_hotplug_event.part.33+0x1cd/0x290 [drm_kms_helper]
      [   45.078088]  drm_fb_helper_hotplug_event+0x1c/0x30 [drm_kms_helper]
      [   45.082614]  intel_fbdev_output_poll_changed+0x9f/0x140 [i915]
      [   45.087069]  drm_kms_helper_hotplug_event+0x67/0x90 [drm_kms_helper]
      [   45.089319]  intel_dp_mst_hotplug+0x37/0x50 [i915]
      [   45.091496]  drm_dp_destroy_connector_work+0x510/0x6f0 [drm_kms_helper]
      [   45.093675]  ? drm_dp_update_payload_part1+0x1220/0x1220 [drm_kms_helper]
      [   45.095851]  ? kasan_check_write+0x14/0x20
      [   45.098473]  ? kasan_check_read+0x11/0x20
      [   45.101155]  ? strscpy+0x17c/0x530
      [   45.103808]  ? __switch_to_asm+0x34/0x70
      [   45.106456]  ? syscall_return_via_sysret+0xf/0x7f
      [   45.109711]  ? read_word_at_a_time+0x20/0x20
      [   45.113138]  ? __switch_to_asm+0x40/0x70
      [   45.116529]  ? __switch_to_asm+0x34/0x70
      [   45.119891]  ? __switch_to_asm+0x40/0x70
      [   45.123224]  ? __switch_to_asm+0x34/0x70
      [   45.126540]  ? __switch_to_asm+0x34/0x70
      [   45.129824]  process_one_work+0x88d/0x15d0
      [   45.133172]  ? pool_mayday_timeout+0x850/0x850
      [   45.136459]  ? pci_mmcfg_check_reserved+0x110/0x128
      [   45.139739]  ? wake_q_add+0xb0/0xb0
      [   45.143010]  ? check_preempt_wakeup+0x652/0x1050
      [   45.146304]  ? worker_enter_idle+0x29e/0x740
      [   45.149589]  ? __schedule+0x1ec0/0x1ec0
      [   45.152937]  ? kasan_check_read+0x11/0x20
      [   45.156179]  ? _raw_spin_lock_irq+0xa3/0x130
      [   45.159382]  ? _raw_read_unlock_irqrestore+0x30/0x30
      [   45.162542]  ? kasan_check_write+0x14/0x20
      [   45.165657]  worker_thread+0x1a5/0x1470
      [   45.168725]  ? set_load_weight+0x2e0/0x2e0
      [   45.171755]  ? process_one_work+0x15d0/0x15d0
      [   45.174806]  ? __switch_to_asm+0x34/0x70
      [   45.177645]  ? __switch_to_asm+0x40/0x70
      [   45.180323]  ? __switch_to_asm+0x34/0x70
      [   45.182936]  ? __switch_to_asm+0x40/0x70
      [   45.185539]  ? __switch_to_asm+0x34/0x70
      [   45.188100]  ? __switch_to_asm+0x40/0x70
      [   45.190628]  ? __schedule+0x7d4/0x1ec0
      [   45.193143]  ? save_stack+0xa9/0xd0
      [   45.195632]  ? kasan_check_write+0x10/0x20
      [   45.198162]  ? kasan_kmalloc+0xc4/0xe0
      [   45.200609]  ? kmem_cache_alloc_trace+0xdd/0x190
      [   45.203046]  ? kthread+0x9f/0x3b0
      [   45.205470]  ? ret_from_fork+0x35/0x40
      [   45.207876]  ? unwind_next_frame+0x43/0x50
      [   45.210273]  ? __save_stack_trace+0x82/0x100
      [   45.212658]  ? deactivate_slab.isra.67+0x3d4/0x580
      [   45.215026]  ? default_wake_function+0x35/0x50
      [   45.217399]  ? kasan_check_read+0x11/0x20
      [   45.219825]  ? _raw_spin_lock_irqsave+0xae/0x140
      [   45.222174]  ? __lock_text_start+0x8/0x8
      [   45.224521]  ? replenish_dl_entity.cold.62+0x4f/0x4f
      [   45.226868]  ? __kthread_parkme+0x87/0xf0
      [   45.229200]  kthread+0x2f7/0x3b0
      [   45.231557]  ? process_one_work+0x15d0/0x15d0
      [   45.233923]  ? kthread_park+0x120/0x120
      [   45.236249]  ret_from_fork+0x35/0x40
      
      [   45.240875] Allocated by task 242:
      [   45.243136]  save_stack+0x43/0xd0
      [   45.245385]  kasan_kmalloc+0xc4/0xe0
      [   45.247597]  kmem_cache_alloc_trace+0xdd/0x190
      [   45.249793]  drm_dp_add_port+0x1e0/0x2170 [drm_kms_helper]
      [   45.252000]  drm_dp_send_link_address+0x4a7/0x740 [drm_kms_helper]
      [   45.254389]  drm_dp_check_and_send_link_address+0x1a7/0x210 [drm_kms_helper]
      [   45.256803]  drm_dp_mst_link_probe_work+0x6f/0xb0 [drm_kms_helper]
      [   45.259200]  process_one_work+0x88d/0x15d0
      [   45.261597]  worker_thread+0x1a5/0x1470
      [   45.264038]  kthread+0x2f7/0x3b0
      [   45.266371]  ret_from_fork+0x35/0x40
      
      [   45.270937] Freed by task 53:
      [   45.273170]  save_stack+0x43/0xd0
      [   45.275382]  __kasan_slab_free+0x139/0x190
      [   45.277604]  kasan_slab_free+0xe/0x10
      [   45.279826]  kfree+0x99/0x1b0
      [   45.282044]  drm_dp_free_mst_port+0x4a/0x60 [drm_kms_helper]
      [   45.284330]  drm_dp_destroy_connector_work+0x43e/0x6f0 [drm_kms_helper]
      [   45.286660]  process_one_work+0x88d/0x15d0
      [   45.288934]  worker_thread+0x1a5/0x1470
      [   45.291231]  kthread+0x2f7/0x3b0
      [   45.293547]  ret_from_fork+0x35/0x40
      
      [   45.298206] The buggy address belongs to the object at ffff8882b4b70968
                      which belongs to the cache kmalloc-2k of size 2048
      [   45.303047] The buggy address is located 0 bytes inside of
                      2048-byte region [ffff8882b4b70968, ffff8882b4b71168)
      [   45.308010] The buggy address belongs to the page:
      [   45.310477] page:ffffea000ad2dc00 count:1 mapcount:0 mapping:ffff8882c080cf40 index:0x0 compound_mapcount: 0
      [   45.313051] flags: 0x8000000000010200(slab|head)
      [   45.315635] raw: 8000000000010200 ffffea000aac2808 ffffea000abe8608 ffff8882c080cf40
      [   45.318300] raw: 0000000000000000 00000000000d000d 00000001ffffffff 0000000000000000
      [   45.320966] page dumped because: kasan: bad access detected
      
      [   45.326312] Memory state around the buggy address:
      [   45.329085]  ffff8882b4b70800: fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      [   45.331845]  ffff8882b4b70880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      [   45.334584] >ffff8882b4b70900: fc fc fc fc fc fc fc fc fc fc fc fc fc fb fb fb
      [   45.337302]                                                           ^
      [   45.340061]  ffff8882b4b70980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [   45.342910]  ffff8882b4b70a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [   45.345748] ==================================================================
      
      So, this definitely isn't a fix that we want. This being said; there's
      no real easy fix for this problem because of some of the catch-22's of
      the MST helpers current design. For starters; we always need to validate
      a port with drm_dp_get_validated_port_ref(), but validation relies on
      the lifetime of the port in the actual topology. So once the port is
      gone, it can't be validated again.
      
      If we were to try to make the payload helpers not use port validation,
      then we'd cause another problem: if the port isn't validated, it could
      be freed and we'd just start causing more KASAN issues. There are
      already hacks that attempt to workaround this in
      drm_dp_mst_destroy_connector_work() by re-initializing the kref so that
      it can be used again and it's memory can be freed once the VCPI helpers
      finish removing the port's respective payloads. But none of these really
      do anything helpful since the port still can't be validated since it's
      gone from the topology. Also, that workaround is immensely confusing to
      read through.
      
      What really needs to be done in order to fix this is to teach DRM how to
      track the lifetime of the structs for MST ports and branch devices
      separately from their lifetime in the actual topology. Simply put; this
      means having two different krefs-one that removes the port/branch device
      from the topology, and one that finally calls kfree(). This would let us
      simplify things, since we'd now be able to keep ports around without
      having to keep them in the topology at the same time, which is exactly
      what we need in order to teach our VCPI helpers to only validate ports
      when it's actually necessary without running the risk of trying to use
      unallocated memory.
      
      Such a fix is on it's way, but for now let's play it safe and just
      revert this. If this bug has been around for well over a year, we can
      wait a little while to get an actual proper fix here.
      
      Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
      Fixes: c54c7374
      
       ("drm/dp_mst: Skip validating ports during destruction, just ref")
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Sean Paul <sean@poorly.run>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Harry Wentland <Harry.Wentland@amd.com>
      Cc: stable@vger.kernel.org # v4.6+
      Acked-by: default avatarSean Paul <sean@poorly.run>
      Link: https://patchwork.freedesktop.org/patch/msgid/20181128210005.24434-1-lyude@redhat.com
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0207ef33
    • Johan Hovold's avatar
      staging: greybus: loopback_test: fix potential path truncations · e3bc8d88
      Johan Hovold authored
      commit ae62cf5e upstream.
      
      Newer GCC warns about possible truncations of two generated path names as
      we're concatenating the configurable sysfs and debugfs path prefixes
      with a filename and placing the results in buffers of the same size as
      the maximum length of the prefixes.
      
      	snprintf(d->name, MAX_STR_LEN, "gb_loopback%u", dev_id);
      
      	snprintf(d->sysfs_entry, MAX_SYSFS_PATH, "%s%s/",
      		 t->sysfs_prefix, d->name);
      
      	snprintf(d->debugfs_entry, MAX_SYSFS_PATH, "%sraw_latency_%s",
      		 t->debugfs_prefix, d->name);
      
      Fix this by separating the maximum path length from the maximum prefix
      length and reducing the latter enough to fit the generated strings.
      
      Note that we also need to reduce the device-name buffer size as GCC
      isn't smart enough to figure out that we ever only used MAX_STR_LEN
      bytes of it.
      
      Fixes: 6b0658f6
      
       ("greybus: tools: Add tools directory to greybus repo and add loopback")
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20200312110151.22028-4-johan@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e3bc8d88
    • Johan Hovold's avatar
      staging: greybus: loopback_test: fix potential path truncation · dacad557
      Johan Hovold authored
      commit f1602383 upstream.
      
      Newer GCC warns about a possible truncation of a generated sysfs path
      name as we're concatenating a directory path with a file name and
      placing the result in a buffer that is half the size of the maximum
      length of the directory path (which is user controlled).
      
      loopback_test.c: In function 'open_poll_files':
      loopback_test.c:651:31: warning: '%s' directive output may be truncated writing up to 511 bytes into a region of size 255 [-Wformat-truncation=]
        651 |   snprintf(buf, sizeof(buf), "%s%s", dev->sysfs_entry, "iteration_count");
            |                               ^~
      loopback_test.c:651:3: note: 'snprintf' output between 16 and 527 bytes into a destination of size 255
        651 |   snprintf(buf, sizeof(buf), "%s%s", dev->sysfs_entry, "iteration_count");
            |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Fix this by making sure the buffer is large enough the concatenated
      strings.
      
      Fixes: 6b0658f6 ("greybus: tools: Add tools directory to greybus repo and add loopback")
      Fixes: 9250c0ee
      
       ("greybus: Loopback_test: use poll instead of inotify")
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20200312110151.22028-3-johan@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dacad557
    • Jernej Skrabec's avatar
      drm/bridge: dw-hdmi: fix AVI frame colorimetry · bff9bc14
      Jernej Skrabec authored
      commit e8dca30f
      
       upstream.
      
      CTA-861-F explicitly states that for RGB colorspace colorimetry should
      be set to "none". Fix that.
      
      Acked-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Fixes: def23aa7
      
       ("drm: bridge: dw-hdmi: Switch to V4L bus format and encodings")
      Signed-off-by: default avatarJernej Skrabec <jernej.skrabec@siol.net>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200304232512.51616-2-jernej.skrabec@siol.net
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bff9bc14
    • Cristian Marussi's avatar
      arm64: smp: fix crash_smp_send_stop() behaviour · 2742449e
      Cristian Marussi authored
      commit f50b7dac upstream.
      
      On a system configured to trigger a crash_kexec() reboot, when only one CPU
      is online and another CPU panics while starting-up, crash_smp_send_stop()
      will fail to send any STOP message to the other already online core,
      resulting in fail to freeze and registers not properly saved.
      
      Moreover even if the proper messages are sent (case CPUs > 2)
      it will similarly fail to account for the booting CPU when executing
      the final stop wait-loop, so potentially resulting in some CPU not
      been waited for shutdown before rebooting.
      
      A tangible effect of this behaviour can be observed when, after a panic
      with kexec enabled and loaded, on the following reboot triggered by kexec,
      the cpu that could not be successfully stopped fails to come back online:
      
      [  362.291022] ------------[ cut here ]------------
      [  362.291525] kernel BUG at arch/arm64/kernel/cpufeature.c:886!
      [  362.292023] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
      [  362.292400] Modules linked in:
      [  362.292970] CPU: 3 PID: 0 Comm: swapper/3 Kdump: loaded Not tainted 5.6.0-rc4-00003-gc780b890948a #105
      [  362.293136] Hardware name: Foundation-v8A (DT)
      [  362.293382] pstate: 200001c5 (nzCv dAIF -PAN -UAO)
      [  362.294063] pc : has_cpuid_feature+0xf0/0x348
      [  362.294177] lr : verify_local_elf_hwcaps+0x84/0xe8
      [  362.294280] sp : ffff800011b1bf60
      [  362.294362] x29: ffff800011b1bf60 x28: 0000000000000000
      [  362.294534] x27: 0000000000000000 x26: 0000000000000000
      [  362.294631] x25: 0000000000000000 x24: ffff80001189a25c
      [  362.294718] x23: 0000000000000000 x22: 0000000000000000
      [  362.294803] x21: ffff8000114aa018 x20: ffff800011156a00
      [  362.294897] x19: ffff800010c944a0 x18: 0000000000000004
      [  362.294987] x17: 0000000000000000 x16: 0000000000000000
      [  362.295073] x15: 00004e53b831ae3c x14: 00004e53b831ae3c
      [  362.295165] x13: 0000000000000384 x12: 0000000000000000
      [  362.295251] x11: 0000000000000000 x10: 00400032b5503510
      [  362.295334] x9 : 0000000000000000 x8 : ffff800010c7e204
      [  362.295426] x7 : 00000000410fd0f0 x6 : 0000000000000001
      [  362.295508] x5 : 00000000410fd0f0 x4 : 0000000000000000
      [  362.295592] x3 : 0000000000000000 x2 : ffff8000100939d8
      [  362.295683] x1 : 0000000000180420 x0 : 0000000000180480
      [  362.296011] Call trace:
      [  362.296257]  has_cpuid_feature+0xf0/0x348
      [  362.296350]  verify_local_elf_hwcaps+0x84/0xe8
      [  362.296424]  check_local_cpu_capabilities+0x44/0x128
      [  362.296497]  secondary_start_kernel+0xf4/0x188
      [  362.296998] Code: 52805001 72a00301 6b01001f 54000ec0 (d4210000)
      [  362.298652] SMP: stopping secondary CPUs
      [  362.300615] Starting crashdump kernel...
      [  362.301168] Bye!
      [    0.000000] Booting Linux on physical CPU 0x0000000003 [0x410fd0f0]
      [    0.000000] Linux version 5.6.0-rc4-00003-gc780b890948a (crimar01@e120937-lin) (gcc version 8.3.0 (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36))) #105 SMP PREEMPT Fri Mar 6 17:00:42 GMT 2020
      [    0.000000] Machine model: Foundation-v8A
      [    0.000000] earlycon: pl11 at MMIO 0x000000001c090000 (options '')
      [    0.000000] printk: bootconsole [pl11] enabled
      .....
      [    0.138024] rcu: Hierarchical SRCU implementation.
      [    0.153472] its@2f020000: unable to locate ITS domain
      [    0.154078] its@2f020000: Unable to locate ITS domain
      [    0.157541] EFI services will not be available.
      [    0.175395] smp: Bringing up secondary CPUs ...
      [    0.209182] psci: failed to boot CPU1 (-22)
      [    0.209377] CPU1: failed to boot: -22
      [    0.274598] Detected PIPT I-cache on CPU2
      [    0.278707] GICv3: CPU2: found redistributor 1 region 0:0x000000002f120000
      [    0.285212] CPU2: Booted secondary processor 0x0000000001 [0x410fd0f0]
      [    0.369053] Detected PIPT I-cache on CPU3
      [    0.372947] GICv3: CPU3: found redistributor 2 region 0:0x000000002f140000
      [    0.378664] CPU3: Booted secondary processor 0x0000000002 [0x410fd0f0]
      [    0.401707] smp: Brought up 1 node, 3 CPUs
      [    0.404057] SMP: Total of 3 processors activated.
      
      Make crash_smp_send_stop() account also for the online status of the
      calling CPU while evaluating how many CPUs are effectively online: this way
      the right number of STOPs is sent and all other stopped-cores's registers
      are properly saved.
      
      Fixes: 78fd584c
      
       ("arm64: kdump: implement machine_crash_shutdown()")
      Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarCristian Marussi <cristian.marussi@arm.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2742449e
    • Cristian Marussi's avatar
      arm64: smp: fix smp_send_stop() behaviour · 194fb5c0
      Cristian Marussi authored
      commit d0bab0c3 upstream.
      
      On a system with only one CPU online, when another one CPU panics while
      starting-up, smp_send_stop() will fail to send any STOP message to the
      other already online core, resulting in a system still responsive and
      alive at the end of the panic procedure.
      
      [  186.700083] CPU3: shutdown
      [  187.075462] CPU2: shutdown
      [  187.162869] CPU1: shutdown
      [  188.689998] ------------[ cut here ]------------
      [  188.691645] kernel BUG at arch/arm64/kernel/cpufeature.c:886!
      [  188.692079] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
      [  188.692444] Modules linked in:
      [  188.693031] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 5.6.0-rc4-00001-g338d25c35a98 #104
      [  188.693175] Hardware name: Foundation-v8A (DT)
      [  188.693492] pstate: 200001c5 (nzCv dAIF -PAN -UAO)
      [  188.694183] pc : has_cpuid_feature+0xf0/0x348
      [  188.694311] lr : verify_local_elf_hwcaps+0x84/0xe8
      [  188.694410] sp : ffff800011b1bf60
      [  188.694536] x29: ffff800011b1bf60 x28: 0000000000000000
      [  188.694707] x27: 0000000000000000 x26: 0000000000000000
      [  188.694801] x25: 0000000000000000 x24: ffff80001189a25c
      [  188.694905] x23: 0000000000000000 x22: 0000000000000000
      [  188.694996] x21: ffff8000114aa018 x20: ffff800011156a38
      [  188.695089] x19: ffff800010c944a0 x18: 0000000000000004
      [  188.695187] x17: 0000000000000000 x16: 0000000000000000
      [  188.695280] x15: 0000249dbde5431e x14: 0262cbe497efa1fa
      [  188.695371] x13: 0000000000000002 x12: 0000000000002592
      [  188.695472] x11: 0000000000000080 x10: 00400032b5503510
      [  188.695572] x9 : 0000000000000000 x8 : ffff800010c80204
      [  188.695659] x7 : 00000000410fd0f0 x6 : 0000000000000001
      [  188.695750] x5 : 00000000410fd0f0 x4 : 0000000000000000
      [  188.695836] x3 : 0000000000000000 x2 : ffff8000100939d8
      [  188.695919] x1 : 0000000000180420 x0 : 0000000000180480
      [  188.696253] Call trace:
      [  188.696410]  has_cpuid_feature+0xf0/0x348
      [  188.696504]  verify_local_elf_hwcaps+0x84/0xe8
      [  188.696591]  check_local_cpu_capabilities+0x44/0x128
      [  188.696666]  secondary_start_kernel+0xf4/0x188
      [  188.697150] Code: 52805001 72a00301 6b01001f 54000ec0 (d4210000)
      [  188.698639] ---[ end trace 3f12ca47652f7b72 ]---
      [  188.699160] Kernel panic - not syncing: Attempted to kill the idle task!
      [  188.699546] Kernel Offset: disabled
      [  188.699828] CPU features: 0x00004,20c02008
      [  188.700012] Memory Limit: none
      [  188.700538] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---
      
      [root@arch ~]# echo Helo
      Helo
      [root@arch ~]# cat /proc/cpuinfo | grep proce
      processor	: 0
      
      Make smp_send_stop() account also for the online status of the calling CPU
      while evaluating how many CPUs are effectively online: this way, the right
      number of STOPs is sent, so enforcing a proper freeze of the system at the
      end of panic even under the above conditions.
      
      Fixes: 08e875c1
      
       ("arm64: SMP support")
      Reported-by: default avatarDave Martin <Dave.Martin@arm.com>
      Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarCristian Marussi <cristian.marussi@arm.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      194fb5c0
    • Kai-Heng Feng's avatar
      ALSA: hda/realtek: Fix pop noise on ALC225 · 1a2a8799
      Kai-Heng Feng authored
      commit 3b36b13d upstream.
      
      Commit 317d9313 ("ALSA: hda/realtek - Set default power save node to
      0") makes the ALC225 have pop noise on S3 resume and cold boot.
      
      So partially revert this commit for ALC225 to fix the regression.
      
      Fixes: 317d9313
      
       ("ALSA: hda/realtek - Set default power save node to 0")
      BugLink: https://bugs.launchpad.net/bugs/1866357
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Link: https://lore.kernel.org/r/20200311061328.17614-1-kai.heng.feng@canonical.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1a2a8799
    • Sasha Levin's avatar
      Revert "ipv6: Fix handling of LLA with VRF and sockets bound to VRF" · c4ad1166
      Sasha Levin authored
      This reverts commit 0293f8d1
      
      .
      
      This patch shouldn't have been backported to 4.14.
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c4ad1166
    • Sasha Levin's avatar
      Revert "vrf: mark skb for multicast or link-local as enslaved to VRF" · afed1a4d
      Sasha Levin authored
      This reverts commit 2271c950
      
      .
      
      This patch shouldn't have been backported to 4.14.
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      afed1a4d
    • Thomas Gleixner's avatar
      futex: Unbreak futex hashing · 25963a66
      Thomas Gleixner authored
      commit 8d677436 upstream.
      
      The recent futex inode life time fix changed the ordering of the futex key
      union struct members, but forgot to adjust the hash function accordingly,
      
      As a result the hashing omits the leading 64bit and even hashes beyond the
      futex key causing a bad hash distribution which led to a ~100% performance
      regression.
      
      Hand in the futex key pointer instead of a random struct member and make
      the size calculation based of the struct offset.
      
      Fixes: 8019ad13
      
       ("futex: Fix inode life-time issue")
      Reported-by: default avatarRong Chen <rong.a.chen@intel.com>
      Decoded-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarRong Chen <rong.a.chen@intel.com>
      Link: https://lkml.kernel.org/r/87h7yy90ve.fsf@nanos.tec.linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      25963a66
    • Peter Zijlstra's avatar
      futex: Fix inode life-time issue · e52694b5
      Peter Zijlstra authored
      commit 8019ad13
      
       upstream.
      
      As reported by Jann, ihold() does not in fact guarantee inode
      persistence. And instead of making it so, replace the usage of inode
      pointers with a per boot, machine wide, unique inode identifier.
      
      This sequence number is global, but shared (file backed) futexes are
      rare enough that this should not become a performance issue.
      
      Reported-by: default avatarJann Horn <jannh@google.com>
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e52694b5
    • Nathan Chancellor's avatar
      kbuild: Disable -Wpointer-to-enum-cast · dafda49d
      Nathan Chancellor authored
      commit 82f2bc2f
      
       upstream.
      
      Clang's -Wpointer-to-int-cast deviates from GCC in that it warns when
      casting to enums. The kernel does this in certain places, such as device
      tree matches to set the version of the device being used, which allows
      the kernel to avoid using a gigantic union.
      
      https://elixir.bootlin.com/linux/v5.5.8/source/drivers/ata/ahci_brcm.c#L428
      https://elixir.bootlin.com/linux/v5.5.8/source/drivers/ata/ahci_brcm.c#L402
      https://elixir.bootlin.com/linux/v5.5.8/source/include/linux/mod_devicetable.h#L264
      
      To avoid a ton of false positive warnings, disable this particular part
      of the warning, which has been split off into a separate diagnostic so
      that the entire warning does not need to be turned off for clang. It
      will be visible under W=1 in case people want to go about fixing these
      easily and enabling the warning treewide.
      
      Cc: stable@vger.kernel.org
      Link: https://github.com/ClangBuiltLinux/linux/issues/887
      Link: https://github.com/llvm/llvm-project/commit/2a41b31fcdfcb67ab7038fc2ffb606fd50b83a84
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dafda49d
    • Eugen Hristev's avatar
      iio: adc: at91-sama5d2_adc: fix differential channels in triggered mode · 9d25ef1a
      Eugen Hristev authored
      [ Upstream commit a500f3bd ]
      
      The differential channels require writing the channel offset register (COR).
      Otherwise they do not work in differential mode.
      The configuration of COR is missing in triggered mode.
      
      Fixes: 5e1a1da0
      
       ("iio: adc: at91-sama5d2_adc: add hw trigger and buffer support")
      Signed-off-by: default avatarEugen Hristev <eugen.hristev@microchip.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9d25ef1a
    • Eugen Hristev's avatar
      iio: adc: at91-sama5d2_adc: fix channel configuration for differential channels · c9a99f73
      Eugen Hristev authored
      [ Upstream commit f0c8d1f6 ]
      
      When iterating through the channels, the index in the array is not the
      scan index. Added an xlate function to translate to the proper index.
      The result of the bug is that the channel array is indexed with a wrong index,
      thus instead of the proper channel, we access invalid memory, which may
      lead to invalid results and/or corruption.
      This will be used also for devicetree channel xlate.
      
      Fixes: 5e1a1da0 ("iio: adc: at91-sama5d2_adc: add hw trigger and buffer support")
      Fixes: 073c6620
      
       ("iio: adc: at91-sama5d2_adc: add support for DMA")
      Signed-off-by: default avatarEugen Hristev <eugen.hristev@microchip.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c9a99f73
    • Anthony Mallet's avatar
      USB: cdc-acm: fix rounding error in TIOCSSERIAL · 71233761
      Anthony Mallet authored
      [ Upstream commit b401f8c4 ]
      
      By default, tty_port_init() initializes those parameters to a multiple
      of HZ. For instance in line 69 of tty_port.c:
         port->close_delay = (50 * HZ) / 100;
      https://github.com/torvalds/linux/blob/master/drivers/tty/tty_port.c#L69
      
      With e.g. CONFIG_HZ = 250 (as this is the case for Ubuntu 18.04
      linux-image-4.15.0-37-generic), the default setting for close_delay is
      thus 125.
      
      When ioctl(fd, TIOCGSERIAL, &s) is executed, the setting returned in
      user space is '12' (125/10). When ioctl(fd, TIOCSSERIAL, &s) is then
      executed with the same setting '12', the value is interpreted as '120'
      which is different from the current setting and a EPERM error may be
      raised by set_serial_info() if !CAP_SYS_ADMIN.
      https://github.com/torvalds/linux/blob/master/drivers/usb/class/cdc-acm.c#L919
      
      Fixes: ba2d8ce9
      
       ("cdc-acm: implement TIOCSSERIAL to avoid blocking close(2)")
      Signed-off-by: default avatarAnthony Mallet <anthony.mallet@laas.fr>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200312133101.7096-2-anthony.mallet@laas.fr
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      71233761
    • Anthony Mallet's avatar
      USB: cdc-acm: fix close_delay and closing_wait units in TIOCSSERIAL · c3024ba3
      Anthony Mallet authored
      [ Upstream commit 633e2b2d
      
       ]
      
      close_delay and closing_wait are specified in hundredth of a second but stored
      internally in jiffies. Use the jiffies_to_msecs() and msecs_to_jiffies()
      functions to convert from each other.
      
      Signed-off-by: default avatarAnthony Mallet <anthony.mallet@laas.fr>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200312133101.7096-1-anthony.mallet@laas.fr
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c3024ba3
    • Joerg Roedel's avatar
      x86/mm: split vmalloc_sync_all() · c3cf92fd
      Joerg Roedel authored
      commit 763802b5 upstream.
      
      Commit 3f8fd02b ("mm/vmalloc: Sync unmappings in
      __purge_vmap_area_lazy()") introduced a call to vmalloc_sync_all() in
      the vunmap() code-path.  While this change was necessary to maintain
      correctness on x86-32-pae kernels, it also adds additional cycles for
      architectures that don't need it.
      
      Specifically on x86-64 with CONFIG_VMAP_STACK=y some people reported
      severe performance regressions in micro-benchmarks because it now also
      calls the x86-64 implementation of vmalloc_sync_all() on vunmap().  But
      the vmalloc_sync_all() implementation on x86-64 is only needed for newly
      created mappings.
      
      To avoid the unnecessary work on x86-64 and to gain the performance
      back, split up vmalloc_sync_all() into two functions:
      
      	* vmalloc_sync_mappings(), and
      	* vmalloc_sync_unmappings()
      
      Most call-sites to vmalloc_sync_all() only care about new mappings being
      synchronized.  The only exception is the new call-site added in the
      above mentioned commit.
      
      Shile Zhang directed us to a report of an 80% regression in reaim
      throughput.
      
      Fixes: 3f8fd02b
      
       ("mm/vmalloc: Sync unmappings in __purge_vmap_area_lazy()")
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Reported-by: default avatarShile Zhang <shile.zhang@linux.alibaba.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Tested-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>	[GHES]
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/20191009124418.8286-1-joro@8bytes.org
      Link: https://lists.01.org/hyperkitty/list/lkp@lists.01.org/thread/4D3JPPHBNOSPFK2KEPC6KGKS6J25AIDB/
      Link: http://lkml.kernel.org/r/20191113095530.228959-1-shile.zhang@linux.alibaba.com
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c3cf92fd
    • Qian Cai's avatar
      page-flags: fix a crash at SetPageError(THP_SWAP) · a07b91a7
      Qian Cai authored
      commit d72520ad upstream.
      
      Commit bd4c82c2 ("mm, THP, swap: delay splitting THP after swapped
      out") supported writing THP to a swap device but forgot to upgrade an
      older commit df8c94d1 ("page-flags: define behavior of FS/IO-related
      flags on compound pages") which could trigger a crash during THP
      swapping out with DEBUG_VM_PGFLAGS=y,
      
        kernel BUG at include/linux/page-flags.h:317!
      
        page dumped because: VM_BUG_ON_PAGE(1 && PageCompound(page))
        page:fffff3b2ec3a8000 refcount:512 mapcount:0 mapping:000000009eb0338c index:0x7f6e58200 head:fffff3b2ec3a8000 order:9 compound_mapcount:0 compound_pincount:0
        anon flags: 0x45fffe0000d8454(uptodate|lru|workingset|owner_priv_1|writeback|head|reclaim|swapbacked)
      
        end_swap_bio_write()
          SetPageError(page)
            VM_BUG_ON_PAGE(1 && PageCompound(page))
      
        <IRQ>
        bio_endio+0x297/0x560
        dec_pending+0x218/0x430 [dm_mod]
        clone_endio+0xe4/0x2c0 [dm_mod]
        bio_endio+0x297/0x560
        blk_update_request+0x201/0x920
        scsi_end_request+0x6b/0x4b0
        scsi_io_completion+0x509/0x7e0
        scsi_finish_command+0x1ed/0x2a0
        scsi_softirq_done+0x1c9/0x1d0
        __blk_mqnterrupt+0xf/0x20
        </IRQ>
      
      Fix by checking PF_NO_TAIL in those places instead.
      
      Fixes: bd4c82c2
      
       ("mm, THP, swap: delay splitting THP after swapped out")
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Acked-by: default avatar"Huang, Ying" <ying.huang@intel.com>
      Acked-by: default avatarRafael Aquini <aquini@redhat.com>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/20200310235846.1319-1-cai@lca.pw
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a07b91a7
    • Vlastimil Babka's avatar
      mm, slub: prevent kmalloc_node crashes and memory leaks · f7521741
      Vlastimil Babka authored
      commit 0715e6c5 upstream.
      
      Sachin reports [1] a crash in SLUB __slab_alloc():
      
        BUG: Kernel NULL pointer dereference on read at 0x000073b0
        Faulting instruction address: 0xc0000000003d55f4
        Oops: Kernel access of bad area, sig: 11 [#1]
        LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
        Modules linked in:
        CPU: 19 PID: 1 Comm: systemd Not tainted 5.6.0-rc2-next-20200218-autotest #1
        NIP:  c0000000003d55f4 LR: c0000000003d5b94 CTR: 0000000000000000
        REGS: c0000008b37836d0 TRAP: 0300   Not tainted  (5.6.0-rc2-next-20200218-autotest)
        MSR:  8000000000009033 <SF,EE,ME,IR,DR,RI,LE>  CR: 24004844  XER: 00000000
        CFAR: c00000000000dec4 DAR: 00000000000073b0 DSISR: 40000000 IRQMASK: 1
        GPR00: c0000000003d5b94 c0000008b3783960 c00000000155d400 c0000008b301f500
        GPR04: 0000000000000dc0 0000000000000002 c0000000003443d8 c0000008bb398620
        GPR08: 00000008ba2f0000 0000000000000001 0000000000000000 0000000000000000
        GPR12: 0000000024004844 c00000001ec52a00 0000000000000000 0000000000000000
        GPR16: c0000008a1b20048 c000000001595898 c000000001750c18 0000000000000002
        GPR20: c000000001750c28 c000000001624470 0000000fffffffe0 5deadbeef0000122
        GPR24: 0000000000000001 0000000000000dc0 0000000000000002 c0000000003443d8
        GPR28: c0000008b301f500 c0000008bb398620 0000000000000000 c00c000002287180
        NIP ___slab_alloc+0x1f4/0x760
        LR __slab_alloc+0x34/0x60
        Call Trace:
          ___slab_alloc+0x334/0x760 (unreliable)
          __slab_alloc+0x34/0x60
          __kmalloc_node+0x110/0x490
          kvmalloc_node+0x58/0x110
          mem_cgroup_css_online+0x108/0x270
          online_css+0x48/0xd0
          cgroup_apply_control_enable+0x2ec/0x4d0
          cgroup_mkdir+0x228/0x5f0
          kernfs_iop_mkdir+0x90/0xf0
          vfs_mkdir+0x110/0x230
          do_mkdirat+0xb0/0x1a0
          system_call+0x5c/0x68
      
      This is a PowerPC platform with following NUMA topology:
      
        available: 2 nodes (0-1)
        node 0 cpus:
        node 0 size: 0 MB
        node 0 free: 0 MB
        node 1 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
        node 1 size: 35247 MB
        node 1 free: 30907 MB
        node distances:
        node   0   1
          0:  10  40
          1:  40  10
      
        possible numa nodes: 0-31
      
      This only happens with a mmotm patch "mm/memcontrol.c: allocate
      shrinker_map on appropriate NUMA node" [2] which effectively calls
      kmalloc_node for each possible node.  SLUB however only allocates
      kmem_cache_node on online N_NORMAL_MEMORY nodes, and relies on
      node_to_mem_node to return such valid node for other nodes since commit
      a561ce00 ("slub: fall back to node_to_mem_node() node if allocating
      on memoryless node").  This is however not true in this configuration
      where the _node_numa_mem_ array is not initialized for nodes 0 and 2-31,
      thus it contains zeroes and get_partial() ends up accessing
      non-allocated kmem_cache_node.
      
      A related issue was reported by Bharata (originally by Ramachandran) [3]
      where a similar PowerPC configuration, but with mainline kernel without
      patch [2] ends up allocating large amounts of pages by kmalloc-1k
      kmalloc-512.  This seems to have the same underlying issue with
      node_to_mem_node() not behaving as expected, and might probably also
      lead to an infinite loop with CONFIG_SLUB_CPU_PARTIAL [4].
      
      This patch should fix both issues by not relying on node_to_mem_node()
      anymore and instead simply falling back to NUMA_NO_NODE, when
      kmalloc_node(node) is attempted for a node that's not online, or has no
      usable memory.  The "usable memory" condition is also changed from
      node_present_pages() to N_NORMAL_MEMORY node state, as that is exactly
      the condition that SLUB uses to allocate kmem_cache_node structures.
      The check in get_partial() is removed completely, as the checks in
      ___slab_alloc() are now sufficient to prevent get_partial() being
      reached with an invalid node.
      
      [1] https://lore.kernel.org/linux-next/3381CD91-AB3D-4773-BA04-E7A072A63968@linux.vnet.ibm.com/
      [2] https://lore.kernel.org/linux-mm/fff0e636-4c36-ed10-281c-8cdb0687c839@virtuozzo.com/
      [3] https://lore.kernel.org/linux-mm/20200317092624.GB22538@in.ibm.com/
      [4] https://lore.kernel.org/linux-mm/088b5996-faae-8a56-ef9c-5b567125ae54@suse.cz/
      
      Fixes: a561ce00
      
       ("slub: fall back to node_to_mem_node() node if allocating on memoryless node")
      Reported-by: default avatarSachin Sant <sachinp@linux.vnet.ibm.com>
      Reported-by: default avatarPUVICHAKRAVARTHY RAMACHANDRAN <puvichakravarthy@in.ibm.com>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Tested-by: default avatarSachin Sant <sachinp@linux.vnet.ibm.com>
      Tested-by: default avatarBharata B Rao <bharata@linux.ibm.com>
      Reviewed-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: Christopher Lameter <cl@linux.com>
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Nathan Lynch <nathanl@linux.ibm.com>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/20200320115533.9604-1-vbabka@suse.cz
      Debugged-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f7521741
    • Linus Torvalds's avatar
      mm: slub: be more careful about the double cmpxchg of freelist · ffb15296
      Linus Torvalds authored
      commit 5076190d upstream.
      
      This is just a cleanup addition to Jann's fix to properly update the
      transaction ID for the slub slowpath in commit fd4d9c7d
      
       ("mm: slub:
      add missing TID bump..").
      
      The transaction ID is what protects us against any concurrent accesses,
      but we should really also make sure to make the 'freelist' comparison
      itself always use the same freelist value that we then used as the new
      next free pointer.
      
      Jann points out that if we do all of this carefully, we could skip the
      transaction ID update for all the paths that only remove entries from
      the lists, and only update the TID when adding entries (to avoid the ABA
      issue with cmpxchg and list handling re-adding a previously seen value).
      
      But this patch just does the "make sure to cmpxchg the same value we
      used" rather than then try to be clever.
      
      Acked-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ffb15296
    • Chunguang Xu's avatar
      memcg: fix NULL pointer dereference in __mem_cgroup_usage_unregister_event · 6c7bec78
      Chunguang Xu authored
      commit 7d36665a upstream.
      
      An eventfd monitors multiple memory thresholds of the cgroup, closes them,
      the kernel deletes all events related to this eventfd.  Before all events
      are deleted, another eventfd monitors the memory threshold of this cgroup,
      leading to a crash:
      
        BUG: kernel NULL pointer dereference, address: 0000000000000004
        #PF: supervisor write access in kernel mode
        #PF: error_code(0x0002) - not-present page
        PGD 800000033058e067 P4D 800000033058e067 PUD 3355ce067 PMD 0
        Oops: 0002 [#1] SMP PTI
        CPU: 2 PID: 14012 Comm: kworker/2:6 Kdump: loaded Not tainted 5.6.0-rc4 #3
        Hardware name: LENOVO 20AWS01K00/20AWS01K00, BIOS GLET70WW (2.24 ) 05/21/2014
        Workqueue: events memcg_event_remove
        RIP: 0010:__mem_cgroup_usage_unregister_event+0xb3/0x190
        RSP: 0018:ffffb47e01c4fe18 EFLAGS: 00010202
        RAX: 0000000000000001 RBX: ffff8bb223a8a000 RCX: 0000000000000001
        RDX: 0000000000000001 RSI: ffff8bb22fb83540 RDI: 0000000000000001
        RBP: ffffb47e01c4fe48 R08: 0000000000000000 R09: 0000000000000010
        R10: 000000000000000c R11: 071c71c71c71c71c R12: ffff8bb226aba880
        R13: ffff8bb223a8a480 R14: 0000000000000000 R15: 0000000000000000
        FS:  0000000000000000(0000) GS:ffff8bb242680000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000000000004 CR3: 000000032c29c003 CR4: 00000000001606e0
        Call Trace:
          memcg_event_remove+0x32/0x90
          process_one_work+0x172/0x380
          worker_thread+0x49/0x3f0
          kthread+0xf8/0x130
          ret_from_fork+0x35/0x40
        CR2: 0000000000000004
      
      We can reproduce this problem in the following ways:
      
      1. We create a new cgroup subdirectory and a new eventfd, and then we
         monitor multiple memory thresholds of the cgroup through this eventfd.
      
      2.  closing this eventfd, and __mem_cgroup_usage_unregister_event ()
         will be called multiple times to delete all events related to this
         eventfd.
      
      The first time __mem_cgroup_usage_unregister_event() is called, the
      kernel will clear all items related to this eventfd in thresholds->
      primary.
      
      Since there is currently only one eventfd, thresholds-> primary becomes
      empty, so the kernel will set thresholds-> primary and hresholds-> spare
      to NULL.  If at this time, the user creates a new eventfd and monitor
      the memory threshold of this cgroup, kernel will re-initialize
      thresholds-> primary.
      
      Then when __mem_cgroup_usage_unregister_event () is called for the
      second time, because thresholds-> primary is not empty, the system will
      access thresholds-> spare, but thresholds-> spare is NULL, which will
      trigger a crash.
      
      In general, the longer it takes to delete all events related to this
      eventfd, the easier it is to trigger this problem.
      
      The solution is to check whether the thresholds associated with the
      eventfd has been cleared when deleting the event.  If so, we do nothing.
      
      [akpm@linux-foundation.org: fix comment, per Kirill]
      Fixes: 907860ed
      
       ("cgroups: make cftype.unregister_event() void-returning")
      Signed-off-by: default avatarChunguang Xu <brookxu@tencent.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/077a6f67-aefa-4591-efec-f2f3af2b0b02@gmail.com
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6c7bec78
    • Steven Rostedt (VMware)'s avatar
      xhci: Do not open code __print_symbolic() in xhci trace events · 4c36106e
      Steven Rostedt (VMware) authored
      commit 045706bf
      
       upstream.
      
      libtraceevent (used by perf and trace-cmd) failed to parse the
      xhci_urb_dequeue trace event. This is because the user space trace
      event format parsing is not a full C compiler. It can handle some basic
      logic, but is not meant to be able to handle everything C can do.
      
      In cases where a trace event field needs to be converted from a number
      to a string, there's the __print_symbolic() macro that should be used:
      
       See samples/trace_events/trace-events-sample.h
      
      Some xhci trace events open coded the __print_symbolic() causing the
      user spaces tools to fail to parse it. This has to be replaced with
      __print_symbolic() instead.
      
      CC: stable@vger.kernel.org
      Reported-by: default avatarTzvetomir Stoyanov <tstoyanov@vmware.com>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=206531
      Fixes: 5abdc2e6
      
       ("usb: host: xhci: add urb_enqueue/dequeue/giveback tracers")
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Link: https://lore.kernel.org/r/20200306150858.21904-2-mathias.nyman@linux.intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4c36106e
    • Corentin Labbe's avatar
      rtc: max8907: add missing select REGMAP_IRQ · 7d2c3a9c
      Corentin Labbe authored
      commit 5d892919 upstream.
      
      I have hit the following build error:
      
        armv7a-hardfloat-linux-gnueabi-ld: drivers/rtc/rtc-max8907.o: in function `max8907_rtc_probe':
        rtc-max8907.c:(.text+0x400): undefined reference to `regmap_irq_get_virq'
      
      max8907 should select REGMAP_IRQ
      
      Fixes: 94c01ab6
      
       ("rtc: add MAX8907 RTC driver")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarCorentin Labbe <clabbe@baylibre.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7d2c3a9c