Skip to content
  1. Dec 08, 2020
    • Davide Caratti's avatar
      net: skbuff: ensure LSE is pullable before decrementing the MPLS ttl · ba203b92
      Davide Caratti authored
      [ Upstream commit 13de4ed9 ]
      
      skb_mpls_dec_ttl() reads the LSE without ensuring that it is contained in
      the skb "linear" area. Fix this calling pskb_may_pull() before reading the
      current ttl.
      
      Found by code inspection.
      
      Fixes: 2a2ea508
      
       ("net: sched: add mpls manipulation actions to TC")
      Reported-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavide Caratti <dcaratti@redhat.com>
      Link: https://lore.kernel.org/r/53659f28be8bc336c113b5254dc637cc76bbae91.1606987074.git.dcaratti@redhat.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ba203b92
    • Wang Hai's avatar
      net: mvpp2: Fix error return code in mvpp2_open() · 892e08e0
      Wang Hai authored
      [ Upstream commit 82a10dc7 ]
      
      Fix to return negative error code -ENOENT from invalid configuration
      error handling case instead of 0, as done elsewhere in this function.
      
      Fixes: 4bb04326
      
       ("net: mvpp2: phylink support")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/20201203141806.37966-1-wanghai38@huawei.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      892e08e0
    • Dan Carpenter's avatar
      chelsio/chtls: fix a double free in chtls_setkey() · 7c3894f6
      Dan Carpenter authored
      [ Upstream commit 391119fb ]
      
      The "skb" is freed by the transmit code in cxgb4_ofld_send() and we
      shouldn't use it again.  But in the current code, if we hit an error
      later on in the function then the clean up code will call kfree_skb(skb)
      and so it causes a double free.
      
      Set the "skb" to NULL and that makes the kfree_skb() a no-op.
      
      Fixes: d25f2f71
      
       ("crypto: chtls - Program the TLS session Key")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Link: https://lore.kernel.org/r/X8ilb6PtBRLWiSHp@mwanda
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7c3894f6
    • Zhang Changzhong's avatar
      vxlan: fix error return code in __vxlan_dev_create() · 178da08f
      Zhang Changzhong authored
      [ Upstream commit 832e0979 ]
      
      Fix to return a negative error code from the error handling
      case instead of 0, as done elsewhere in this function.
      
      Fixes: 0ce1822c
      
       ("vxlan: add adjacent link to limit depth level")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
      Link: https://lore.kernel.org/r/1606903122-2098-1-git-send-email-zhangchangzhong@huawei.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      178da08f
    • Zhang Changzhong's avatar
      net: pasemi: fix error return code in pasemi_mac_open() · 5405a299
      Zhang Changzhong authored
      [ Upstream commit aba84871 ]
      
      Fix to return a negative error code from the error handling
      case instead of 0, as done elsewhere in this function.
      
      Fixes: 72b05b99 ("pasemi_mac: RX/TX ring management cleanup")
      Fixes: 8d636d8b
      
       ("pasemi_mac: jumbo frame support")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
      Link: https://lore.kernel.org/r/1606903035-1838-1-git-send-email-zhangchangzhong@huawei.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5405a299
    • Zhang Changzhong's avatar
      cxgb3: fix error return code in t3_sge_alloc_qset() · dc469f42
      Zhang Changzhong authored
      [ Upstream commit ff992489 ]
      
      Fix to return a negative error code from the error handling
      case instead of 0, as done elsewhere in this function.
      
      Fixes: b1fb1f28
      
       ("cxgb3 - Fix dma mapping error path")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
      Acked-by: default avatarRaju Rangoju <rajur@chelsio.com>
      Link: https://lore.kernel.org/r/1606902965-1646-1-git-send-email-zhangchangzhong@huawei.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dc469f42
    • Dan Carpenter's avatar
      net/x25: prevent a couple of overflows · 8bfe5b73
      Dan Carpenter authored
      [ Upstream commit 6ee50c8e ]
      
      The .x25_addr[] address comes from the user and is not necessarily
      NUL terminated.  This leads to a couple problems.  The first problem is
      that the strlen() in x25_bind() can read beyond the end of the buffer.
      
      The second problem is more subtle and could result in memory corruption.
      The call tree is:
        x25_connect()
        --> x25_write_internal()
            --> x25_addr_aton()
      
      The .x25_addr[] buffers are copied to the "addresses" buffer from
      x25_write_internal() so it will lead to stack corruption.
      
      Verify that the strings are NUL terminated and return -EINVAL if they
      are not.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Fixes: a9288525
      
       ("X25: Dont let x25_bind use addresses containing characters")
      Reported-by: default avatar"kiyin(尹亮)" <kiyin@tencent.com>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: default avatarMartin Schiller <ms@dev.tdt.de>
      Link: https://lore.kernel.org/r/X8ZeAKm8FnFpN//B@mwanda
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8bfe5b73
    • Antoine Tenart's avatar
      net: ip6_gre: set dev->hard_header_len when using header_ops · 187a6daf
      Antoine Tenart authored
      [ Upstream commit 832ba596 ]
      
      syzkaller managed to crash the kernel using an NBMA ip6gre interface. I
      could reproduce it creating an NBMA ip6gre interface and forwarding
      traffic to it:
      
        skbuff: skb_under_panic: text:ffffffff8250e927 len:148 put:44 head:ffff8c03c7a33
        ------------[ cut here ]------------
        kernel BUG at net/core/skbuff.c:109!
        Call Trace:
        skb_push+0x10/0x10
        ip6gre_header+0x47/0x1b0
        neigh_connected_output+0xae/0xf0
      
      ip6gre tunnel provides its own header_ops->create, and sets it
      conditionally when initializing the tunnel in NBMA mode. When
      header_ops->create is used, dev->hard_header_len should reflect the
      length of the header created. Otherwise, when not used,
      dev->needed_headroom should be used.
      
      Fixes: eb95f52f
      
       ("net: ipv6_gre: Fix GRO to work on IPv6 over GRE tap")
      Cc: Maria Pasechnik <mariap@mellanox.com>
      Signed-off-by: default avatarAntoine Tenart <atenart@kernel.org>
      Link: https://lore.kernel.org/r/20201130161911.464106-1-atenart@kernel.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      187a6daf
    • Eric Dumazet's avatar
      geneve: pull IP header before ECN decapsulation · a6cd7613
      Eric Dumazet authored
      [ Upstream commit 4179b00c ]
      
      IP_ECN_decapsulate() and IP6_ECN_decapsulate() assume
      IP header is already pulled.
      
      geneve does not ensure this yet.
      
      Fixing this generically in IP_ECN_decapsulate() and
      IP6_ECN_decapsulate() is not possible, since callers
      pass a pointer that might be freed by pskb_may_pull()
      
      syzbot reported :
      
      BUG: KMSAN: uninit-value in __INET_ECN_decapsulate include/net/inet_ecn.h:238 [inline]
      BUG: KMSAN: uninit-value in INET_ECN_decapsulate+0x345/0x1db0 include/net/inet_ecn.h:260
      CPU: 1 PID: 8941 Comm: syz-executor.0 Not tainted 5.10.0-rc4-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       <IRQ>
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x21c/0x280 lib/dump_stack.c:118
       kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:118
       __msan_warning+0x5f/0xa0 mm/kmsan/kmsan_instr.c:197
       __INET_ECN_decapsulate include/net/inet_ecn.h:238 [inline]
       INET_ECN_decapsulate+0x345/0x1db0 include/net/inet_ecn.h:260
       geneve_rx+0x2103/0x2980 include/net/inet_ecn.h:306
       geneve_udp_encap_recv+0x105c/0x1340 drivers/net/geneve.c:377
       udp_queue_rcv_one_skb+0x193a/0x1af0 net/ipv4/udp.c:2093
       udp_queue_rcv_skb+0x282/0x1050 net/ipv4/udp.c:2167
       udp_unicast_rcv_skb net/ipv4/udp.c:2325 [inline]
       __udp4_lib_rcv+0x399d/0x5880 net/ipv4/udp.c:2394
       udp_rcv+0x5c/0x70 net/ipv4/udp.c:2564
       ip_protocol_deliver_rcu+0x572/0xc50 net/ipv4/ip_input.c:204
       ip_local_deliver_finish net/ipv4/ip_input.c:231 [inline]
       NF_HOOK include/linux/netfilter.h:301 [inline]
       ip_local_deliver+0x583/0x8d0 net/ipv4/ip_input.c:252
       dst_input include/net/dst.h:449 [inline]
       ip_rcv_finish net/ipv4/ip_input.c:428 [inline]
       NF_HOOK include/linux/netfilter.h:301 [inline]
       ip_rcv+0x5c3/0x840 net/ipv4/ip_input.c:539
       __netif_receive_skb_one_core net/core/dev.c:5315 [inline]
       __netif_receive_skb+0x1ec/0x640 net/core/dev.c:5429
       process_backlog+0x523/0xc10 net/core/dev.c:6319
       napi_poll+0x420/0x1010 net/core/dev.c:6763
       net_rx_action+0x35c/0xd40 net/core/dev.c:6833
       __do_softirq+0x1a9/0x6fa kernel/softirq.c:298
       asm_call_irq_on_stack+0xf/0x20
       </IRQ>
       __run_on_irqstack arch/x86/include/asm/irq_stack.h:26 [inline]
       run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:77 [inline]
       do_softirq_own_stack+0x6e/0x90 arch/x86/kernel/irq_64.c:77
       do_softirq kernel/softirq.c:343 [inline]
       __local_bh_enable_ip+0x184/0x1d0 kernel/softirq.c:195
       local_bh_enable+0x36/0x40 include/linux/bottom_half.h:32
       rcu_read_unlock_bh include/linux/rcupdate.h:730 [inline]
       __dev_queue_xmit+0x3a9b/0x4520 net/core/dev.c:4167
       dev_queue_xmit+0x4b/0x60 net/core/dev.c:4173
       packet_snd net/packet/af_packet.c:2992 [inline]
       packet_sendmsg+0x86f9/0x99d0 net/packet/af_packet.c:3017
       sock_sendmsg_nosec net/socket.c:651 [inline]
       sock_sendmsg net/socket.c:671 [inline]
       __sys_sendto+0x9dc/0xc80 net/socket.c:1992
       __do_sys_sendto net/socket.c:2004 [inline]
       __se_sys_sendto+0x107/0x130 net/socket.c:2000
       __x64_sys_sendto+0x6e/0x90 net/socket.c:2000
       do_syscall_64+0x9f/0x140 arch/x86/entry/common.c:48
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Fixes: 2d07dc79
      
       ("geneve: add initial netdev driver for GENEVE tunnels")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Link: https://lore.kernel.org/r/20201201090507.4137906-1-eric.dumazet@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a6cd7613
    • Toke Høiland-Jørgensen's avatar
      inet_ecn: Fix endianness of checksum update when setting ECT(1) · 2b714b60
      Toke Høiland-Jørgensen authored
      [ Upstream commit 2867e1ea ]
      
      When adding support for propagating ECT(1) marking in IP headers it seems I
      suffered from endianness-confusion in the checksum update calculation: In
      fact the ECN field is in the *lower* bits of the first 16-bit word of the
      IP header when calculating in network byte order. This means that the
      addition performed to update the checksum field was wrong; let's fix that.
      
      Fixes: b7237487
      
       ("tunnel: Propagate ECT(1) when decapsulating as recommended by RFC6040")
      Reported-by: default avatarJonathan Morton <chromatix99@gmail.com>
      Tested-by: default avatarPete Heist <pete@heistp.net>
      Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Link: https://lore.kernel.org/r/20201130183705.17540-1-toke@redhat.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2b714b60
    • Thomas Falcon's avatar
      ibmvnic: Fix TX completion error handling · 9a3cce1c
      Thomas Falcon authored
      [ Upstream commit ba246c17 ]
      
      TX completions received with an error return code are not
      being processed properly. When an error code is seen, do not
      proceed to the next completion before cleaning up the existing
      entry's data structures.
      
      Fixes: 032c5e82
      
       ("Driver for IBM System i/p VNIC protocol")
      Signed-off-by: default avatarThomas Falcon <tlfalcon@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9a3cce1c
    • Thomas Falcon's avatar
      ibmvnic: Ensure that SCRQ entry reads are correctly ordered · 40caea31
      Thomas Falcon authored
      [ Upstream commit b71ec952 ]
      
      Ensure that received Subordinate Command-Response Queue (SCRQ)
      entries are properly read in order by the driver. These queues
      are used in the ibmvnic device to process RX buffer and TX completion
      descriptors. dma_rmb barriers have been added after checking for a
      pending descriptor to ensure the correct descriptor entry is checked
      and after reading the SCRQ descriptor to ensure the entire
      descriptor is read before processing.
      
      Fixes: 032c5e82
      
       ("Driver for IBM System i/p VNIC protocol")
      Signed-off-by: default avatarThomas Falcon <tlfalcon@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      40caea31
    • Vinay Kumar Yadav's avatar
      chelsio/chtls: fix panic during unload reload chtls · d126c30e
      Vinay Kumar Yadav authored
      [ Upstream commit e3d5e971 ]
      
      there is kernel panic in inet_twsk_free() while chtls
      module unload when socket is in TIME_WAIT state because
      sk_prot_creator was not preserved on connection socket.
      
      Fixes: cc35c88a
      
       ("crypto : chtls - CPL handler definition")
      Signed-off-by: default avatarUdai Sharma <udai.sharma@chelsio.com>
      Signed-off-by: default avatarVinay Kumar Yadav <vinay.yadav@chelsio.com>
      Link: https://lore.kernel.org/r/20201125214913.16938-1-vinay.yadav@chelsio.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d126c30e
    • Krzysztof Kozlowski's avatar
      dt-bindings: net: correct interrupt flags in examples · 8a1bb298
      Krzysztof Kozlowski authored
      [ Upstream commit 4d521943 ]
      
      GPIO_ACTIVE_x flags are not correct in the context of interrupt flags.
      These are simple defines so they could be used in DTS but they will not
      have the same meaning:
      1. GPIO_ACTIVE_HIGH = 0 = IRQ_TYPE_NONE
      2. GPIO_ACTIVE_LOW  = 1 = IRQ_TYPE_EDGE_RISING
      
      Correct the interrupt flags, assuming the author of the code wanted same
      logical behavior behind the name "ACTIVE_xxx", this is:
        ACTIVE_LOW  => IRQ_TYPE_LEVEL_LOW
        ACTIVE_HIGH => IRQ_TYPE_LEVEL_HIGH
      
      Fixes: a1a8b459 ("NFC: pn544: i2c: Add DTS Documentation")
      Fixes: 6be88670 ("NFC: nxp-nci_i2c: Add I2C support to NXP NCI driver")
      Fixes: e3b32922
      
       ("dt-bindings: can: tcan4x5x: Update binding to use interrupt property")
      Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> # for tcan4x5x.txt
      Link: https://lore.kernel.org/r/20201026153620.89268-1-krzk@kernel.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8a1bb298
    • Guillaume Nault's avatar
      ipv4: Fix tos mask in inet_rtm_getroute() · af0b082e
      Guillaume Nault authored
      [ Upstream commit 1ebf1790 ]
      
      When inet_rtm_getroute() was converted to use the RCU variants of
      ip_route_input() and ip_route_output_key(), the TOS parameters
      stopped being masked with IPTOS_RT_MASK before doing the route lookup.
      
      As a result, "ip route get" can return a different route than what
      would be used when sending real packets.
      
      For example:
      
          $ ip route add 192.0.2.11/32 dev eth0
          $ ip route add unreachable 192.0.2.11/32 tos 2
          $ ip route get 192.0.2.11 tos 2
          RTNETLINK answers: No route to host
      
      But, packets with TOS 2 (ECT(0) if interpreted as an ECN bit) would
      actually be routed using the first route:
      
          $ ping -c 1 -Q 2 192.0.2.11
          PING 192.0.2.11 (192.0.2.11) 56(84) bytes of data.
          64 bytes from 192.0.2.11: icmp_seq=1 ttl=64 time=0.173 ms
      
          --- 192.0.2.11 ping statistics ---
          1 packets transmitted, 1 received, 0% packet loss, time 0ms
          rtt min/avg/max/mdev = 0.173/0.173/0.173/0.000 ms
      
      This patch re-applies IPTOS_RT_MASK in inet_rtm_getroute(), to
      return results consistent with real route lookups.
      
      Fixes: 3765d35e
      
       ("net: ipv4: Convert inet_rtm_getroute to rcu versions of route lookup")
      Signed-off-by: default avatarGuillaume Nault <gnault@redhat.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/b2d237d08317ca55926add9654a48409ac1b8f5b.1606412894.git.gnault@redhat.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af0b082e
    • Antoine Tenart's avatar
      netfilter: bridge: reset skb->pkt_type after NF_INET_POST_ROUTING traversal · 4615228a
      Antoine Tenart authored
      [ Upstream commit 44f64f23 ]
      
      Netfilter changes PACKET_OTHERHOST to PACKET_HOST before invoking the
      hooks as, while it's an expected value for a bridge, routing expects
      PACKET_HOST. The change is undone later on after hook traversal. This
      can be seen with pairs of functions updating skb>pkt_type and then
      reverting it to its original value:
      
      For hook NF_INET_PRE_ROUTING:
        setup_pre_routing / br_nf_pre_routing_finish
      
      For hook NF_INET_FORWARD:
        br_nf_forward_ip / br_nf_forward_finish
      
      But the third case where netfilter does this, for hook
      NF_INET_POST_ROUTING, the packet type is changed in br_nf_post_routing
      but never reverted. A comment says:
      
        /* We assume any code from br_dev_queue_push_xmit onwards doesn't care
         * about the value of skb->pkt_type. */
      
      But when having a tunnel (say vxlan) attached to a bridge we have the
      following call trace:
      
        br_nf_pre_routing
        br_nf_pre_routing_ipv6
           br_nf_pre_routing_finish
        br_nf_forward_ip
           br_nf_forward_finish
        br_nf_post_routing           <- pkt_type is updated to PACKET_HOST
           br_nf_dev_queue_xmit      <- but not reverted to its original value
        vxlan_xmit
           vxlan_xmit_one
              skb_tunnel_check_pmtu  <- a check on pkt_type is performed
      
      In this specific case, this creates issues such as when an ICMPv6 PTB
      should be sent back. When CONFIG_BRIDGE_NETFILTER is enabled, the PTB
      isn't sent (as skb_tunnel_check_pmtu checks if pkt_type is PACKET_HOST
      and returns early).
      
      If the comment is right and no one cares about the value of
      skb->pkt_type after br_dev_queue_push_xmit (which isn't true), resetting
      it to its original value should be safe.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarAntoine Tenart <atenart@kernel.org>
      Reviewed-by: default avatarFlorian Westphal <fw@strlen.de>
      Link: https://lore.kernel.org/r/20201123174902.622102-1-atenart@kernel.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4615228a
    • Vincent Guittot's avatar
      sched/fair: Fix unthrottle_cfs_rq() for leaf_cfs_rq list · 294de893
      Vincent Guittot authored
      [ Upstream commit 39f23ce0 ]
      
      Although not exactly identical, unthrottle_cfs_rq() and enqueue_task_fair()
      are quite close and follow the same sequence for enqueuing an entity in the
      cfs hierarchy. Modify unthrottle_cfs_rq() to use the same pattern as
      enqueue_task_fair(). This fixes a problem already faced with the latter and
      add an optimization in the last for_each_sched_entity loop.
      
      Fixes: fe61468b
      
       (sched/fair: Fix enqueue_task_fair warning)
      Reported-by Tao Zhou <zohooouoto@zoho.com.cn>
      Signed-off-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarPhil Auld <pauld@redhat.com>
      Reviewed-by: default avatarBen Segall <bsegall@google.com>
      Link: https://lkml.kernel.org/r/20200513135528.4742-1-vincent.guittot@linaro.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      294de893
    • Maurizio Drocco's avatar
      ima: extend boot_aggregate with kernel measurements · c4405cdf
      Maurizio Drocco authored
      [ Upstream commit 20c59ce0
      
       ]
      
      Registers 8-9 are used to store measurements of the kernel and its
      command line (e.g., grub2 bootloader with tpm module enabled). IMA
      should include them in the boot aggregate. Registers 8-9 should be
      only included in non-SHA1 digests to avoid ambiguity.
      
      Signed-off-by: default avatarMaurizio Drocco <maurizio.drocco@ibm.com>
      Reviewed-by: default avatarBruno Meneguele <bmeneg@redhat.com>
      Tested-by: Bruno Meneguele <bmeneg@redhat.com>  (TPM 1.2, TPM 2.0)
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c4405cdf
    • Randy Dunlap's avatar
      staging/octeon: fix up merge error · 733729d3
      Randy Dunlap authored
      commit 673b41e0 upstream.
      
      There's a semantic conflict in the Octeon staging network driver, which
      used the skb_reset_tc() function to reset skb state when re-using an
      skb.  But that inline helper function was removed in mainline by commit
      2c64605b
      
       ("net: Fix CONFIG_NET_CLS_ACT=n and
      CONFIG_NFT_FWD_NETDEV={y, m} build").
      
      Fix it by using skb_reset_redirect() instead.  Also move it out of the
      
      This code path only ends up triggering if REUSE_SKBUFFS_WITHOUT_FREE is
      enabled, which in turn only happens if you don't have CONFIG_NETFILTER
      configured.  Which was how this wasn't caught by the usual allmodconfig
      builds.
      
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Pablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      733729d3
    • Jamie Iles's avatar
      bonding: wait for sysfs kobject destruction before freeing struct slave · 6dd37fdc
      Jamie Iles authored
      [ Upstream commit b9ad3e9f ]
      
      syzkaller found that with CONFIG_DEBUG_KOBJECT_RELEASE=y, releasing a
      struct slave device could result in the following splat:
      
        kobject: 'bonding_slave' (00000000cecdd4fe): kobject_release, parent 0000000074ceb2b2 (delayed 1000)
        bond0 (unregistering): (slave bond_slave_1): Releasing backup interface
        ------------[ cut here ]------------
        ODEBUG: free active (active state 0) object type: timer_list hint: workqueue_select_cpu_near kernel/workqueue.c:1549 [inline]
        ODEBUG: free active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x98 kernel/workqueue.c:1600
        WARNING: CPU: 1 PID: 842 at lib/debugobjects.c:485 debug_print_object+0x180/0x240 lib/debugobjects.c:485
        Kernel panic - not syncing: panic_on_warn set ...
        CPU: 1 PID: 842 Comm: kworker/u4:4 Tainted: G S                5.9.0-rc8+ #96
        Hardware name: linux,dummy-virt (DT)
        Workqueue: netns cleanup_net
        Call trace:
         dump_backtrace+0x0/0x4d8 include/linux/bitmap.h:239
         show_stack+0x34/0x48 arch/arm64/kernel/traps.c:142
         __dump_stack lib/dump_stack.c:77 [inline]
         dump_stack+0x174/0x1f8 lib/dump_stack.c:118
         panic+0x360/0x7a0 kernel/panic.c:231
         __warn+0x244/0x2ec kernel/panic.c:600
         report_bug+0x240/0x398 lib/bug.c:198
         bug_handler+0x50/0xc0 arch/arm64/kernel/traps.c:974
         call_break_hook+0x160/0x1d8 arch/arm64/kernel/debug-monitors.c:322
         brk_handler+0x30/0xc0 arch/arm64/kernel/debug-monitors.c:329
         do_debug_exception+0x184/0x340 arch/arm64/mm/fault.c:864
         el1_dbg+0x48/0xb0 arch/arm64/kernel/entry-common.c:65
         el1_sync_handler+0x170/0x1c8 arch/arm64/kernel/entry-common.c:93
         el1_sync+0x80/0x100 arch/arm64/kernel/entry.S:594
         debug_print_object+0x180/0x240 lib/debugobjects.c:485
         __debug_check_no_obj_freed lib/debugobjects.c:967 [inline]
         debug_check_no_obj_freed+0x200/0x430 lib/debugobjects.c:998
         slab_free_hook mm/slub.c:1536 [inline]
         slab_free_freelist_hook+0x190/0x210 mm/slub.c:1577
         slab_free mm/slub.c:3138 [inline]
         kfree+0x13c/0x460 mm/slub.c:4119
         bond_free_slave+0x8c/0xf8 drivers/net/bonding/bond_main.c:1492
         __bond_release_one+0xe0c/0xec8 drivers/net/bonding/bond_main.c:2190
         bond_slave_netdev_event drivers/net/bonding/bond_main.c:3309 [inline]
         bond_netdev_event+0x8f0/0xa70 drivers/net/bonding/bond_main.c:3420
         notifier_call_chain+0xf0/0x200 kernel/notifier.c:83
         __raw_notifier_call_chain kernel/notifier.c:361 [inline]
         raw_notifier_call_chain+0x44/0x58 kernel/notifier.c:368
         call_netdevice_notifiers_info+0xbc/0x150 net/core/dev.c:2033
         call_netdevice_notifiers_extack net/core/dev.c:2045 [inline]
         call_netdevice_notifiers net/core/dev.c:2059 [inline]
         rollback_registered_many+0x6a4/0xec0 net/core/dev.c:9347
         unregister_netdevice_many.part.0+0x2c/0x1c0 net/core/dev.c:10509
         unregister_netdevice_many net/core/dev.c:10508 [inline]
         default_device_exit_batch+0x294/0x338 net/core/dev.c:10992
         ops_exit_list.isra.0+0xec/0x150 net/core/net_namespace.c:189
         cleanup_net+0x44c/0x888 net/core/net_namespace.c:603
         process_one_work+0x96c/0x18c0 kernel/workqueue.c:2269
         worker_thread+0x3f0/0xc30 kernel/workqueue.c:2415
         kthread+0x390/0x498 kernel/kthread.c:292
         ret_from_fork+0x10/0x18 arch/arm64/kernel/entry.S:925
      
      This is a potential use-after-free if the sysfs nodes are being accessed
      whilst removing the struct slave, so wait for the object destruction to
      complete before freeing the struct slave itself.
      
      Fixes: 07699f9a ("bonding: add sysfs /slave dir for bond slave devices.")
      Fixes: a068aab4
      
       ("bonding: Fix reference count leak in bond_sysfs_slave_add.")
      Cc: Qiushi Wu <wu000273@umn.edu>
      Cc: Jay Vosburgh <j.vosburgh@gmail.com>
      Cc: Veaceslav Falico <vfalico@gmail.com>
      Cc: Andy Gospodarek <andy@greyhouse.net>
      Signed-off-by: default avatarJamie Iles <jamie@nuviainc.com>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Link: https://lore.kernel.org/r/20201120142827.879226-1-jamie@nuviainc.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6dd37fdc
    • Yves-Alexis Perez's avatar
      usbnet: ipheth: fix connectivity with iOS 14 · beead010
      Yves-Alexis Perez authored
      [ Upstream commit f33d9e2b
      
       ]
      
      Starting with iOS 14 released in September 2020, connectivity using the
      personal hotspot USB tethering function of iOS devices is broken.
      
      Communication between the host and the device (for example ICMP traffic
      or DNS resolution using the DNS service running in the device itself)
      works fine, but communication to endpoints further away doesn't work.
      
      Investigation on the matter shows that no UDP and ICMP traffic from the
      tethered host is reaching the Internet at all. For TCP traffic there are
      exchanges between tethered host and server but packets are modified in
      transit leading to impossible communication.
      
      After some trials Matti Vuorela discovered that reducing the URB buffer
      size by two bytes restored the previous behavior. While a better
      solution might exist to fix the issue, since the protocol is not
      publicly documented and considering the small size of the fix, let's do
      that.
      
      Tested-by: default avatarMatti Vuorela <matti.vuorela@bitfactor.fi>
      Signed-off-by: default avatarYves-Alexis Perez <corsac@corsac.net>
      Link: https://lore.kernel.org/linux-usb/CAAn0qaXmysJ9vx3ZEMkViv_B19ju-_ExN8Yn_uSefxpjS6g4Lw@mail.gmail.com/
      Link: https://github.com/libimobiledevice/libimobiledevice/issues/1038
      Link: https://lore.kernel.org/r/20201119172439.94988-1-corsac@corsac.net
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      beead010
    • Jens Axboe's avatar
      tun: honor IOCB_NOWAIT flag · f057c4d2
      Jens Axboe authored
      [ Upstream commit 5aac0390
      
       ]
      
      tun only checks the file O_NONBLOCK flag, but it should also be checking
      the iocb IOCB_NOWAIT flag. Any fops using ->read/write_iter() should check
      both, otherwise it breaks users that correctly expect O_NONBLOCK semantics
      if IOCB_NOWAIT is set.
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Link: https://lore.kernel.org/r/e9451860-96cc-c7c7-47b8-fe42cadd5f4c@kernel.dk
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f057c4d2
    • Alexander Duyck's avatar
      tcp: Set INET_ECN_xmit configuration in tcp_reinit_congestion_control · 53800874
      Alexander Duyck authored
      [ Upstream commit 55472017 ]
      
      When setting congestion control via a BPF program it is seen that the
      SYN/ACK for packets within a given flow will not include the ECT0 flag. A
      bit of simple printk debugging shows that when this is configured without
      BPF we will see the value INET_ECN_xmit value initialized in
      tcp_assign_congestion_control however when we configure this via BPF the
      socket is in the closed state and as such it isn't configured, and I do not
      see it being initialized when we transition the socket into the listen
      state. The result of this is that the ECT0 bit is configured based on
      whatever the default state is for the socket.
      
      Any easy way to reproduce this is to monitor the following with tcpdump:
      tools/testing/selftests/bpf/test_progs -t bpf_tcp_ca
      
      Without this patch the SYN/ACK will follow whatever the default is. If dctcp
      all SYN/ACK packets will have the ECT0 bit set, and if it is not then ECT0
      will be cleared on all SYN/ACK packets. With this patch applied the SYN/ACK
      bit matches the value seen on the other packets in the given stream.
      
      Fixes: 91b5b21c
      
       ("bpf: Add support for changing congestion control")
      Signed-off-by: default avatarAlexander Duyck <alexanderduyck@fb.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      53800874
    • Willem de Bruijn's avatar
      sock: set sk_err to ee_errno on dequeue from errq · 9a62c822
      Willem de Bruijn authored
      [ Upstream commit 985f7337 ]
      
      When setting sk_err, set it to ee_errno, not ee_origin.
      
      Commit f5f99309 ("sock: do not set sk_err in
      sock_dequeue_err_skb") disabled updating sk_err on errq dequeue,
      which is correct for most error types (origins):
      
        -       sk->sk_err = err;
      
      Commit 38b25793 ("sock: reset sk_err when the error queue is
      empty") reenabled the behavior for IMCP origins, which do require it:
      
        +       if (icmp_next)
        +               sk->sk_err = SKB_EXT_ERR(skb_next)->ee.ee_origin;
      
      But read from ee_errno.
      
      Fixes: 38b25793
      
       ("sock: reset sk_err when the error queue is empty")
      Reported-by: default avatarAyush Ranjan <ayushranjan@google.com>
      Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
      Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
      Link: https://lore.kernel.org/r/20201126151220.2819322-1-willemdebruijn.kernel@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9a62c822
    • Anmol Karn's avatar
      rose: Fix Null pointer dereference in rose_send_frame() · 7f0ddd41
      Anmol Karn authored
      [ Upstream commit 3b3fd068 ]
      
      rose_send_frame() dereferences `neigh->dev` when called from
      rose_transmit_clear_request(), and the first occurrence of the
      `neigh` is in rose_loopback_timer() as `rose_loopback_neigh`,
      and it is initialized in rose_add_loopback_neigh() as NULL.
      i.e when `rose_loopback_neigh` used in rose_loopback_timer()
      its `->dev` was still NULL and rose_loopback_timer() was calling
      rose_rx_call_request() without checking for NULL.
      
      - net/rose/rose_link.c
      This bug seems to get triggered in this line:
      
      rose_call = (ax25_address *)neigh->dev->dev_addr;
      
      Fix it by adding NULL checking for `rose_loopback_neigh->dev`
      in rose_loopback_timer().
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Suggested-by: default avatarJakub Kicinski <kuba@kernel.org>
      Reported-by: default avatar <syzbot+a1c743815982d9496393@syzkaller.appspotmail.com>
      Tested-by: default avatar <syzbot+a1c743815982d9496393@syzkaller.appspotmail.com>
      Link: https://syzkaller.appspot.com/bug?id=9d2a7ca8c7f2e4b682c97578dfa3f236258300b3
      Signed-off-by: default avatarAnmol Karn <anmol.karan123@gmail.com>
      Link: https://lore.kernel.org/r/20201119191043.28813-1-anmol.karan123@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7f0ddd41
    • Maxim Mikityanskiy's avatar
      net/tls: Protect from calling tls_dev_del for TLS RX twice · f2f25bc7
      Maxim Mikityanskiy authored
      [ Upstream commit 025cc2fb ]
      
      tls_device_offload_cleanup_rx doesn't clear tls_ctx->netdev after
      calling tls_dev_del if TLX TX offload is also enabled. Clearing
      tls_ctx->netdev gets postponed until tls_device_gc_task. It leaves a
      time frame when tls_device_down may get called and call tls_dev_del for
      RX one extra time, confusing the driver, which may lead to a crash.
      
      This patch corrects this racy behavior by adding a flag to prevent
      tls_device_down from calling tls_dev_del the second time.
      
      Fixes: e8f69799
      
       ("net/tls: Add generic NIC offload infrastructure")
      Signed-off-by: default avatarMaxim Mikityanskiy <maximmi@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Link: https://lore.kernel.org/r/20201125221810.69870-1-saeedm@nvidia.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f2f25bc7
    • Vadim Fedorenko's avatar
      net/tls: missing received data after fast remote close · a6300aed
      Vadim Fedorenko authored
      [ Upstream commit 20ffc7ad ]
      
      In case when tcp socket received FIN after some data and the
      parser haven't started before reading data caller will receive
      an empty buffer. This behavior differs from plain TCP socket and
      leads to special treating in user-space.
      The flow that triggers the race is simple. Server sends small
      amount of data right after the connection is configured to use TLS
      and closes the connection. In this case receiver sees TLS Handshake
      data, configures TLS socket right after Change Cipher Spec record.
      While the configuration is in process, TCP socket receives small
      Application Data record, Encrypted Alert record and FIN packet. So
      the TCP socket changes sk_shutdown to RCV_SHUTDOWN and sk_flag with
      SK_DONE bit set. The received data is not parsed upon arrival and is
      never sent to user-space.
      
      Patch unpauses parser directly if we have unparsed data in tcp
      receive queue.
      
      Fixes: fcf4793e
      
       ("tls: check RCV_SHUTDOWN in tls_wait_data")
      Signed-off-by: default avatarVadim Fedorenko <vfedorenko@novek.ru>
      Link: https://lore.kernel.org/r/1605801588-12236-1-git-send-email-vfedorenko@novek.ru
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a6300aed
    • Julian Wiedmann's avatar
      net/af_iucv: set correct sk_protocol for child sockets · a15beea8
      Julian Wiedmann authored
      [ Upstream commit c5dab094 ]
      
      Child sockets erroneously inherit their parent's sk_type (ie. SOCK_*),
      instead of the PF_IUCV protocol that the parent was created with in
      iucv_sock_create().
      
      We're currently not using sk->sk_protocol ourselves, so this shouldn't
      have much impact (except eg. getting the output in skb_dump() right).
      
      Fixes: eac3731b
      
       ("[S390]: Add AF_IUCV socket support")
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Link: https://lore.kernel.org/r/20201120100657.34407-1-jwi@linux.ibm.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a15beea8
    • Wang Hai's avatar
      ipv6: addrlabel: fix possible memory leak in ip6addrlbl_net_init · 9414855a
      Wang Hai authored
      [ Upstream commit e255e11e ]
      
      kmemleak report a memory leak as follows:
      
      unreferenced object 0xffff8880059c6a00 (size 64):
        comm "ip", pid 23696, jiffies 4296590183 (age 1755.384s)
        hex dump (first 32 bytes):
          20 01 00 10 00 00 00 00 00 00 00 00 00 00 00 00   ...............
          1c 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00  ................
        backtrace:
          [<00000000aa4e7a87>] ip6addrlbl_add+0x90/0xbb0
          [<0000000070b8d7f1>] ip6addrlbl_net_init+0x109/0x170
          [<000000006a9ca9d4>] ops_init+0xa8/0x3c0
          [<000000002da57bf2>] setup_net+0x2de/0x7e0
          [<000000004e52d573>] copy_net_ns+0x27d/0x530
          [<00000000b07ae2b4>] create_new_namespaces+0x382/0xa30
          [<000000003b76d36f>] unshare_nsproxy_namespaces+0xa1/0x1d0
          [<0000000030653721>] ksys_unshare+0x3a4/0x780
          [<0000000007e82e40>] __x64_sys_unshare+0x2d/0x40
          [<0000000031a10c08>] do_syscall_64+0x33/0x40
          [<0000000099df30e7>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      We should free all rules when we catch an error in ip6addrlbl_net_init().
      otherwise a memory leak will occur.
      
      Fixes: 2a8cc6c8
      
       ("[IPV6] ADDRCONF: Support RFC3484 configurable address selection policy table.")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Link: https://lore.kernel.org/r/20201124071728.8385-1-wanghai38@huawei.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9414855a
    • Parav Pandit's avatar
      devlink: Hold rtnl lock while reading netdev attributes · 99b5382b
      Parav Pandit authored
      [ Upstream commit b187c9b4 ]
      
      A netdevice of a devlink port can be moved to different net namespace
      than its parent devlink instance.
      This scenario occurs when devlink reload is not used.
      
      When netdevice is undergoing migration to net namespace, its ifindex
      and name may change.
      
      In such use case, devlink port query may read stale netdev attributes.
      
      Fix it by reading them under rtnl lock.
      
      Fixes: bfcd3a46
      
       ("Introduce devlink infrastructure")
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      99b5382b
  2. Dec 02, 2020