Skip to content
  1. Apr 16, 2018
  2. Apr 15, 2018
  3. Apr 12, 2018
    • Greg Kroah-Hartman's avatar
      Linux 4.14.34 · ffebeb0d
      Greg Kroah-Hartman authored
      ffebeb0d
    • Moshe Shemesh's avatar
      net/mlx4_core: Fix memory leak while delete slave's resources · fdae5b62
      Moshe Shemesh authored
      
      [ Upstream commit 461d5f1b ]
      
      mlx4_delete_all_resources_for_slave in resource tracker should free all
      memory allocated for a slave.
      While releasing memory of fs_rule, it misses releasing memory of
      fs_rule->mirr_mbox.
      
      Fixes: 78efed27
      
       ('net/mlx4_core: Support mirroring VF DMFS rules on both ports')
      Signed-off-by: default avatarMoshe Shemesh <moshe@mellanox.com>
      Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fdae5b62
    • Jason Wang's avatar
      vhost_net: add missing lock nesting notation · 9fdeb33e
      Jason Wang authored
      
      [ Upstream commit aaa3149b ]
      
      We try to hold TX virtqueue mutex in vhost_net_rx_peek_head_len()
      after RX virtqueue mutex is held in handle_rx(). This requires an
      appropriate lock nesting notation to calm down deadlock detector.
      
      Fixes: 03088137
      
       ("vhost_net: basic polling support")
      Reported-by: default avatar <syzbot+7f073540b1384a614e09@syzkaller.appspotmail.com>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9fdeb33e
    • Xin Long's avatar
      team: move dev_mc_sync after master_upper_dev_link in team_port_add · 8c316b62
      Xin Long authored
      
      [ Upstream commit 982cf3b3 ]
      
      The same fix as in 'bonding: move dev_mc_sync after master_upper_dev_link
      in bond_enslave' is needed for team driver.
      
      The panic can be reproduced easily:
      
        ip link add team1 type team
        ip link set team1 up
        ip link add link team1 vlan1 type vlan id 80
        ip link set vlan1 master team1
      
      Fixes: cb41c997
      
       ("team: team should sync the port's uc/mc addrs when add a port")
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c316b62
    • Xin Long's avatar
      route: check sysctl_fib_multipath_use_neigh earlier than hash · 233ba28e
      Xin Long authored
      
      [ Upstream commit 6174a30d ]
      
      Prior to this patch, when one packet is hashed into path [1]
      (hash <= nh_upper_bound) and it's neigh is dead, it will try
      path [2]. However, if path [2]'s neigh is alive but it's
      hash > nh_upper_bound, it will not return this alive path.
      This packet will never be sent even if path [2] is alive.
      
       3.3.3.1/24:
        nexthop via 1.1.1.254 dev eth1 weight 1 <--[1] (dead neigh)
        nexthop via 2.2.2.254 dev eth2 weight 1 <--[2]
      
      With sysctl_fib_multipath_use_neigh set is supposed to find an
      available path respecting to the l3/l4 hash. But if there is
      no available route with this hash, it should at least return
      an alive route even with other hash.
      
      This patch is to fix it by processing fib_multipath_use_neigh
      earlier than the hash check, so that it will at least return
      an alive route if there is when fib_multipath_use_neigh is
      enabled. It's also compatible with before when there are alive
      routes with the l3/l4 hash.
      
      Fixes: a6db4494
      
       ("net: ipv4: Consider failed nexthops in multipath routes")
      Reported-by: default avatarJianlin Shi <jishi@redhat.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Acked-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      233ba28e
    • Jason Wang's avatar
      vhost: validate log when IOTLB is enabled · 2f8aa659
      Jason Wang authored
      
      [ Upstream commit d65026c6 ]
      
      Vq log_base is the userspace address of bitmap which has nothing to do
      with IOTLB. So it needs to be validated unconditionally otherwise we
      may try use 0 as log_base which may lead to pin pages that will lead
      unexpected result (e.g trigger BUG_ON() in set_bit_to_user()).
      
      Fixes: 6b1e6cc7
      
       ("vhost: new device IOTLB API")
      Reported-by: default avatar <syzbot+6304bf97ef436580fede@syzkaller.appspotmail.com>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f8aa659
    • Roi Dayan's avatar
      net/mlx5e: Fix traffic being dropped on VF representor · 72b880f4
      Roi Dayan authored
      
      [ Upstream commit 4246f698 ]
      
      Increase representor netdev RQ size to avoid dropped packets.
      The current size (two) is just too small to keep up with
      conventional slow path traffic patterns.
      Also match the SQ size to the RQ size.
      
      Fixes: cb67b832
      
       ("net/mlx5e: Introduce SRIOV VF representors")
      Signed-off-by: default avatarRoi Dayan <roid@mellanox.com>
      Reviewed-by: default avatarPaul Blakey <paulb@mellanox.com>
      Reviewed-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      72b880f4
    • Eran Ben Elisha's avatar
      net/mlx4_en: Fix mixed PFC and Global pause user control requests · 9408bceb
      Eran Ben Elisha authored
      
      [ Upstream commit 6e8814ce ]
      
      Global pause and PFC configuration should be mutually exclusive (i.e. only
      one of them at most can be set). However, once PFC was turned off,
      driver automatically turned Global pause on. This is a bug.
      
      Fix the driver behaviour to turn off PFC/Global once the user turned the
      other on.
      
      This also fixed a weird behaviour that at a current time, the profile
      had both PFC and global pause configuration turned on, which is
      Hardware-wise impossible and caused returning false positive indication
      to query tools.
      
      In addition, fix error code when setting global pause or PFC to change
      metadata only upon successful change.
      
      Also, removed useless debug print.
      
      Fixes: af7d5185 ("net/mlx4_en: Add DCB PFC support through CEE netlink commands")
      Fixes: c27a02cd
      
       ("mlx4_en: Add driver for Mellanox ConnectX 10GbE NIC")
      Signed-off-by: default avatarEran Ben Elisha <eranbe@mellanox.com>
      Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9408bceb
    • Dave Watson's avatar
      strparser: Fix sign of err codes · 477c73ab
      Dave Watson authored
      
      [ Upstream commit cd00edc1 ]
      
      strp_parser_err is called with a negative code everywhere, which then
      calls abort_parser with a negative code.  strp_msg_timeout calls
      abort_parser directly with a positive code.  Negate ETIMEDOUT
      to match signed-ness of other calls.
      
      The default abort_parser callback, strp_abort_strp, sets
      sk->sk_err to err.  Also negate the error here so sk_err always
      holds a positive value, as the rest of the net code expects.  Currently
      a negative sk_err can result in endless loops, or user code that
      thinks it actually sent/received err bytes.
      
      Found while testing net/tls_sw recv path.
      
      Fixes: 43a0c675
      
       ("strparser: Stream parser for messages")
      Signed-off-by: default avatarDave Watson <davejwatson@fb.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      477c73ab
    • Davide Caratti's avatar
      net/sched: fix NULL dereference on the error path of tcf_skbmod_init() · 1c71bfe8
      Davide Caratti authored
      
      [ Upstream commit 2d433610 ]
      
      when the following command
      
       # tc action replace action skbmod swap mac index 100
      
      is run for the first time, and tcf_skbmod_init() fails to allocate struct
      tcf_skbmod_params, tcf_skbmod_cleanup() calls kfree_rcu(NULL), thus
      causing the following error:
      
       BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
       IP: __call_rcu+0x23/0x2b0
       PGD 8000000034057067 P4D 8000000034057067 PUD 74937067 PMD 0
       Oops: 0002 [#1] SMP PTI
       Modules linked in: act_skbmod(E) psample ip6table_filter ip6_tables iptable_filter binfmt_misc ext4 snd_hda_codec_generic snd_hda_intel snd_hda_codec crct10dif_pclmul mbcache jbd2 crc32_pclmul snd_hda_core ghash_clmulni_intel snd_hwdep pcbc snd_seq snd_seq_device snd_pcm aesni_intel snd_timer crypto_simd glue_helper snd cryptd virtio_balloon joydev soundcore pcspkr i2c_piix4 nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c ata_generic pata_acpi qxl drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm drm virtio_console virtio_net virtio_blk ata_piix libata crc32c_intel virtio_pci serio_raw virtio_ring virtio i2c_core floppy dm_mirror dm_region_hash dm_log dm_mod [last unloaded: act_skbmod]
       CPU: 3 PID: 3144 Comm: tc Tainted: G            E    4.16.0-rc4.act_vlan.orig+ #403
       Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
       RIP: 0010:__call_rcu+0x23/0x2b0
       RSP: 0018:ffffbd2e403e7798 EFLAGS: 00010246
       RAX: ffffffffc0872080 RBX: ffff981d34bff780 RCX: 00000000ffffffff
       RDX: ffffffff922a5f00 RSI: 0000000000000000 RDI: 0000000000000000
       RBP: 0000000000000000 R08: 0000000000000001 R09: 000000000000021f
       R10: 000000003d003000 R11: 0000000000aaaaaa R12: 0000000000000000
       R13: ffffffff922a5f00 R14: 0000000000000001 R15: ffff981d3b698c2c
       FS:  00007f3678292740(0000) GS:ffff981d3fd80000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 0000000000000008 CR3: 000000007c57a006 CR4: 00000000001606e0
       Call Trace:
        __tcf_idr_release+0x79/0xf0
        tcf_skbmod_init+0x1d1/0x210 [act_skbmod]
        tcf_action_init_1+0x2cc/0x430
        tcf_action_init+0xd3/0x1b0
        tc_ctl_action+0x18b/0x240
        rtnetlink_rcv_msg+0x29c/0x310
        ? _cond_resched+0x15/0x30
        ? __kmalloc_node_track_caller+0x1b9/0x270
        ? rtnl_calcit.isra.28+0x100/0x100
        netlink_rcv_skb+0xd2/0x110
        netlink_unicast+0x17c/0x230
        netlink_sendmsg+0x2cd/0x3c0
        sock_sendmsg+0x30/0x40
        ___sys_sendmsg+0x27a/0x290
        ? filemap_map_pages+0x34a/0x3a0
        ? __handle_mm_fault+0xbfd/0xe20
        __sys_sendmsg+0x51/0x90
        do_syscall_64+0x6e/0x1a0
        entry_SYSCALL_64_after_hwframe+0x3d/0xa2
       RIP: 0033:0x7f36776a3ba0
       RSP: 002b:00007fff4703b618 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
       RAX: ffffffffffffffda RBX: 00007fff4703b740 RCX: 00007f36776a3ba0
       RDX: 0000000000000000 RSI: 00007fff4703b690 RDI: 0000000000000003
       RBP: 000000005aaaba36 R08: 0000000000000002 R09: 0000000000000000
       R10: 00007fff4703b0a0 R11: 0000000000000246 R12: 0000000000000000
       R13: 00007fff4703b754 R14: 0000000000000001 R15: 0000000000669f60
       Code: 5d e9 42 da ff ff 66 90 0f 1f 44 00 00 41 57 41 56 41 55 49 89 d5 41 54 55 48 89 fd 53 48 83 ec 08 40 f6 c7 07 0f 85 19 02 00 00 <48> 89 75 08 48 c7 45 00 00 00 00 00 9c 58 0f 1f 44 00 00 49 89
       RIP: __call_rcu+0x23/0x2b0 RSP: ffffbd2e403e7798
       CR2: 0000000000000008
      
      Fix it in tcf_skbmod_cleanup(), ensuring that kfree_rcu(p, ...) is called
      only when p is not NULL.
      
      Fixes: 86da71b5
      
       ("net_sched: Introduce skbmod action")
      Signed-off-by: default avatarDavide Caratti <dcaratti@redhat.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1c71bfe8
    • Davide Caratti's avatar
      net/sched: fix NULL dereference in the error path of tunnel_key_init() · a19024a3
      Davide Caratti authored
      
      [ Upstream commit abdadd3c ]
      
      when the following command
      
       # tc action add action tunnel_key unset index 100
      
      is run for the first time, and tunnel_key_init() fails to allocate struct
      tcf_tunnel_key_params, tunnel_key_release() dereferences NULL pointers.
      This causes the following error:
      
       BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
       IP: tunnel_key_release+0xd/0x40 [act_tunnel_key]
       PGD 8000000033787067 P4D 8000000033787067 PUD 74646067 PMD 0
       Oops: 0000 [#1] SMP PTI
       Modules linked in: act_tunnel_key(E) act_csum ip6table_filter ip6_tables iptable_filter binfmt_misc ext4 mbcache jbd2 crct10dif_pclmul crc32_pclmul snd_hda_codec_generic ghash_clmulni_intel snd_hda_intel pcbc snd_hda_codec snd_hda_core snd_hwdep snd_seq aesni_intel snd_seq_device crypto_simd glue_helper snd_pcm cryptd joydev snd_timer pcspkr virtio_balloon snd i2c_piix4 soundcore nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c ata_generic pata_acpi qxl drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm virtio_net virtio_blk drm virtio_console crc32c_intel ata_piix serio_raw i2c_core virtio_pci libata virtio_ring virtio floppy dm_mirror dm_region_hash dm_log dm_mod
       CPU: 2 PID: 3101 Comm: tc Tainted: G            E    4.16.0-rc4.act_vlan.orig+ #403
       Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
       RIP: 0010:tunnel_key_release+0xd/0x40 [act_tunnel_key]
       RSP: 0018:ffffba46803b7768 EFLAGS: 00010286
       RAX: ffffffffc09010a0 RBX: 0000000000000000 RCX: 0000000000000024
       RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff99ee336d7480
       RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000044
       R10: 0000000000000220 R11: ffff99ee79d73131 R12: 0000000000000000
       R13: ffff99ee32d67610 R14: ffff99ee7671dc38 R15: 00000000fffffff4
       FS:  00007febcb2cd740(0000) GS:ffff99ee7fd00000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 0000000000000010 CR3: 000000007c8e4005 CR4: 00000000001606e0
       Call Trace:
        __tcf_idr_release+0x79/0xf0
        tunnel_key_init+0xd9/0x460 [act_tunnel_key]
        tcf_action_init_1+0x2cc/0x430
        tcf_action_init+0xd3/0x1b0
        tc_ctl_action+0x18b/0x240
        rtnetlink_rcv_msg+0x29c/0x310
        ? _cond_resched+0x15/0x30
        ? __kmalloc_node_track_caller+0x1b9/0x270
        ? rtnl_calcit.isra.28+0x100/0x100
        netlink_rcv_skb+0xd2/0x110
        netlink_unicast+0x17c/0x230
        netlink_sendmsg+0x2cd/0x3c0
        sock_sendmsg+0x30/0x40
        ___sys_sendmsg+0x27a/0x290
        __sys_sendmsg+0x51/0x90
        do_syscall_64+0x6e/0x1a0
        entry_SYSCALL_64_after_hwframe+0x3d/0xa2
       RIP: 0033:0x7febca6deba0
       RSP: 002b:00007ffe7b0dd128 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
       RAX: ffffffffffffffda RBX: 00007ffe7b0dd250 RCX: 00007febca6deba0
       RDX: 0000000000000000 RSI: 00007ffe7b0dd1a0 RDI: 0000000000000003
       RBP: 000000005aaa90cb R08: 0000000000000002 R09: 0000000000000000
       R10: 00007ffe7b0dcba0 R11: 0000000000000246 R12: 0000000000000000
       R13: 00007ffe7b0dd264 R14: 0000000000000001 R15: 0000000000669f60
       Code: 44 00 00 8b 0d b5 23 00 00 48 8b 87 48 10 00 00 48 8b 3c c8 e9 a5 e5 d8 c3 0f 1f 44 00 00 0f 1f 44 00 00 53 48 8b 9f b0 00 00 00 <83> 7b 10 01 74 0b 48 89 df 31 f6 5b e9 f2 fa 7f c3 48 8b 7b 18
       RIP: tunnel_key_release+0xd/0x40 [act_tunnel_key] RSP: ffffba46803b7768
       CR2: 0000000000000010
      
      Fix this in tunnel_key_release(), ensuring 'param' is not NULL before
      dereferencing it.
      
      Fixes: d0f6dd8a
      
       ("net/sched: Introduce act_tunnel_key")
      Signed-off-by: default avatarDavide Caratti <dcaratti@redhat.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a19024a3
    • Shahar Klein's avatar
      net/mlx5e: Sync netdev vxlan ports at open · e096c8bf
      Shahar Klein authored
      
      [ Upstream commit a117f73d ]
      
      When mlx5_core is loaded it is expected to sync ports
      with all vxlan devices so it can support vxlan encap/decap.
      This is done via udp_tunnel_get_rx_info(). Currently this
      call is set in mlx5e_nic_enable() and if the netdev is not in
      NETREG_REGISTERED state it will not be called.
      
      Normally on load the netdev state is not NETREG_REGISTERED
      so udp_tunnel_get_rx_info() will not be called.
      
      Moving udp_tunnel_get_rx_info() to mlx5e_open() so
      it will be called on netdev UP event and allow encap/decap.
      
      Fixes: 610e89e0
      
       ("net/mlx5e: Don't sync netdev state when not registered")
      Signed-off-by: default avatarShahar Klein <shahark@mellanox.com>
      Reviewed-by: default avatarRoi Dayan <roid@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e096c8bf
    • Jianbo Liu's avatar
      net/mlx5e: Don't override vport admin link state in switchdev mode · baab1f0c
      Jianbo Liu authored
      
      The vport admin original link state will be re-applied after returning
      back to legacy mode, it is not right to change the admin link state value
      when in switchdev mode.
      
      Use direct vport commands to alter logical vport state in netdev
      representor open/close flows rather than the administrative eswitch API.
      
      Fixes: 20a1ea67
      
       ('net/mlx5e: Support VF vport link state control for SRIOV switchdev mode')
      Signed-off-by: default avatarJianbo Liu <jianbol@mellanox.com>
      Reviewed-by: default avatarRoi Dayan <roid@mellanox.com>
      Reviewed-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      baab1f0c
    • David Lebrun's avatar
      ipv6: sr: fix seg6 encap performances with TSO enabled · 1ec7966a
      David Lebrun authored
      
      [ Upstream commit 5807b22c
      
       ]
      
      Enabling TSO can lead to abysmal performances when using seg6 in
      encap mode, such as with the ixgbe driver. This patch adds a call to
      iptunnel_handle_offloads() to remove the encapsulation bit if needed.
      
      Before:
      root@comp4-seg6bpf:~# iperf3 -c fc00::55
      Connecting to host fc00::55, port 5201
      [  4] local fc45::4 port 36592 connected to fc00::55 port 5201
      [ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
      [  4]   0.00-1.00   sec   196 KBytes  1.60 Mbits/sec   47   6.66 KBytes
      [  4]   1.00-2.00   sec   304 KBytes  2.49 Mbits/sec  100   5.33 KBytes
      [  4]   2.00-3.00   sec   284 KBytes  2.32 Mbits/sec   92   5.33 KBytes
      
      After:
      root@comp4-seg6bpf:~# iperf3 -c fc00::55
      Connecting to host fc00::55, port 5201
      [  4] local fc45::4 port 43062 connected to fc00::55 port 5201
      [ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
      [  4]   0.00-1.00   sec  1.03 GBytes  8.89 Gbits/sec    0    743 KBytes
      [  4]   1.00-2.00   sec  1.03 GBytes  8.87 Gbits/sec    0    743 KBytes
      [  4]   2.00-3.00   sec  1.03 GBytes  8.87 Gbits/sec    0    743 KBytes
      
      Reported-by: default avatarTom Herbert <tom@quantonium.net>
      Fixes: 6c8702c6
      
       ("ipv6: sr: add support for SRH encapsulation and injection with lwtunnels")
      Signed-off-by: default avatarDavid Lebrun <dlebrun@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1ec7966a
    • Dirk van der Merwe's avatar
      nfp: use full 40 bits of the NSP buffer address · e52a45bb
      Dirk van der Merwe authored
      
      [ Upstream commit 1489bbd1 ]
      
      The NSP default buffer is a piece of NFP memory where additional
      command data can be placed.  Its format has been copied from
      host buffer, but the PCIe selection bits do not make sense in
      this case.  If those get masked out from a NFP address - writes
      to random place in the chip memory may be issued and crash the
      device.
      
      Even in the general NSP buffer case, it doesn't make sense to have the
      PCIe selection bits there anymore. These are unused at the moment, and
      when it becomes necessary, the PCIe selection bits should rather be
      moved to another register to utilise more bits for the buffer address.
      
      This has never been an issue because the buffer used to be
      allocated in memory with less-than-38-bit-long address but that
      is about to change.
      
      Fixes: 1a64821c
      
       ("nfp: add support for service processor access")
      Signed-off-by: default avatarDirk van der Merwe <dirk.vandermerwe@netronome.com>
      Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e52a45bb
    • Jianbo Liu's avatar
      net/mlx5e: Fix memory usage issues in offloading TC flows · ddf79878
      Jianbo Liu authored
      
      [ Upstream commit af1607c3 ]
      
      For NIC flows, the parsed attributes are not freed when we exit
      successfully from mlx5e_configure_flower().
      
      There is possible double free for eswitch flows. If error is returned
      from rhashtable_insert_fast(), the parse attrs will be freed in
      mlx5e_tc_del_flow(), but they will be freed again before exiting
      mlx5e_configure_flower().
      
      To fix both issues we do the following:
      (1) change the condition that determines if to issue the free call to
          check if this flow is NIC flow, or it does not have encap action.
      (2) reorder the code such that that the check and free calls are done
          before we attempt to add into the hash table.
      
      Fixes: 232c0013
      
       ('net/mlx5e: Add support to neighbour update flow')
      Signed-off-by: default avatarJianbo Liu <jianbol@mellanox.com>
      Reviewed-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Reviewed-by: default avatarRoi Dayan <roid@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ddf79878
    • Or Gerlitz's avatar
      net/mlx5e: Avoid using the ipv6 stub in the TC offload neigh update path · 9282181c
      Or Gerlitz authored
      
      [ Upstream commit 423c9db2 ]
      
      Currently we use the global ipv6_stub var to access the ipv6 global
      nd table. This practice gets us to troubles when the stub is only partially
      set e.g when ipv6 is loaded under the disabled policy. In this case, as of commit
      343d60aa ("ipv6: change ipv6_stub_impl.ipv6_dst_lookup to take net argument")
      the stub is not null, but stub->nd_tbl is and we crash.
      
      As we can access the ipv6 nd_tbl directly, the fix is just to avoid the
      reference through the stub. There is one place in the code where we
      issue ipv6 route lookup and keep doing it through the stub, but that
      mentioned commit makes sure we get -EAFNOSUPPORT from the stack.
      
      Fixes: 232c0013
      
       ("net/mlx5e: Add support to neighbour update flow")
      Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Reviewed-by: default avatarAviv Heller <avivh@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9282181c
    • Eric Dumazet's avatar
      vti6: better validate user provided tunnel names · b9c6ddda
      Eric Dumazet authored
      
      [ Upstream commit 537b361f ]
      
      Use valid_name() to make sure user does not provide illegal
      device name.
      
      Fixes: ed1efb2a
      
       ("ipv6: Add support for IPsec virtual tunnel interfaces")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b9c6ddda
    • Eric Dumazet's avatar
      ip6_tunnel: better validate user provided tunnel names · 109dce20
      Eric Dumazet authored
      
      [ Upstream commit db7a65e3 ]
      
      Use valid_name() to make sure user does not provide illegal
      device name.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      109dce20
    • Eric Dumazet's avatar
      ip6_gre: better validate user provided tunnel names · 72363c63
      Eric Dumazet authored
      
      [ Upstream commit 5f42df01 ]
      
      Use dev_valid_name() to make sure user does not provide illegal
      device name.
      
      syzbot caught the following bug :
      
      BUG: KASAN: stack-out-of-bounds in strlcpy include/linux/string.h:300 [inline]
      BUG: KASAN: stack-out-of-bounds in ip6gre_tunnel_locate+0x334/0x860 net/ipv6/ip6_gre.c:339
      Write of size 20 at addr ffff8801afb9f7b8 by task syzkaller851048/4466
      
      CPU: 1 PID: 4466 Comm: syzkaller851048 Not tainted 4.16.0+ #1
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:17 [inline]
       dump_stack+0x1b9/0x29f lib/dump_stack.c:53
       print_address_description+0x6c/0x20b mm/kasan/report.c:256
       kasan_report_error mm/kasan/report.c:354 [inline]
       kasan_report.cold.7+0xac/0x2f5 mm/kasan/report.c:412
       check_memory_region_inline mm/kasan/kasan.c:260 [inline]
       check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
       memcpy+0x37/0x50 mm/kasan/kasan.c:303
       strlcpy include/linux/string.h:300 [inline]
       ip6gre_tunnel_locate+0x334/0x860 net/ipv6/ip6_gre.c:339
       ip6gre_tunnel_ioctl+0x69d/0x12e0 net/ipv6/ip6_gre.c:1195
       dev_ifsioc+0x43e/0xb90 net/core/dev_ioctl.c:334
       dev_ioctl+0x69a/0xcc0 net/core/dev_ioctl.c:525
       sock_ioctl+0x47e/0x680 net/socket.c:1015
       vfs_ioctl fs/ioctl.c:46 [inline]
       file_ioctl fs/ioctl.c:500 [inline]
       do_vfs_ioctl+0x1cf/0x1650 fs/ioctl.c:684
       ksys_ioctl+0xa9/0xd0 fs/ioctl.c:701
       SYSC_ioctl fs/ioctl.c:708 [inline]
       SyS_ioctl+0x24/0x30 fs/ioctl.c:706
       do_syscall_64+0x29e/0x9d0 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x42/0xb7
      
      Fixes: c12b395a
      
       ("gre: Support GRE over IPv6")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      72363c63
    • Eric Dumazet's avatar
      ipv6: sit: better validate user provided tunnel names · a7309cad
      Eric Dumazet authored
      
      [ Upstream commit b95211e0 ]
      
      Use dev_valid_name() to make sure user does not provide illegal
      device name.
      
      syzbot caught the following bug :
      
      BUG: KASAN: stack-out-of-bounds in strlcpy include/linux/string.h:300 [inline]
      BUG: KASAN: stack-out-of-bounds in ipip6_tunnel_locate+0x63b/0xaa0 net/ipv6/sit.c:254
      Write of size 33 at addr ffff8801b64076d8 by task syzkaller932654/4453
      
      CPU: 0 PID: 4453 Comm: syzkaller932654 Not tainted 4.16.0+ #1
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:17 [inline]
       dump_stack+0x1b9/0x29f lib/dump_stack.c:53
       print_address_description+0x6c/0x20b mm/kasan/report.c:256
       kasan_report_error mm/kasan/report.c:354 [inline]
       kasan_report.cold.7+0xac/0x2f5 mm/kasan/report.c:412
       check_memory_region_inline mm/kasan/kasan.c:260 [inline]
       check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
       memcpy+0x37/0x50 mm/kasan/kasan.c:303
       strlcpy include/linux/string.h:300 [inline]
       ipip6_tunnel_locate+0x63b/0xaa0 net/ipv6/sit.c:254
       ipip6_tunnel_ioctl+0xe71/0x241b net/ipv6/sit.c:1221
       dev_ifsioc+0x43e/0xb90 net/core/dev_ioctl.c:334
       dev_ioctl+0x69a/0xcc0 net/core/dev_ioctl.c:525
       sock_ioctl+0x47e/0x680 net/socket.c:1015
       vfs_ioctl fs/ioctl.c:46 [inline]
       file_ioctl fs/ioctl.c:500 [inline]
       do_vfs_ioctl+0x1cf/0x1650 fs/ioctl.c:684
       ksys_ioctl+0xa9/0xd0 fs/ioctl.c:701
       SYSC_ioctl fs/ioctl.c:708 [inline]
       SyS_ioctl+0x24/0x30 fs/ioctl.c:706
       do_syscall_64+0x29e/0x9d0 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x42/0xb7
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7309cad
    • Eric Dumazet's avatar
      ip_tunnel: better validate user provided tunnel names · 6816295f
      Eric Dumazet authored
      
      [ Upstream commit 9cb726a2 ]
      
      Use dev_valid_name() to make sure user does not provide illegal
      device name.
      
      syzbot caught the following bug :
      
      BUG: KASAN: stack-out-of-bounds in strlcpy include/linux/string.h:300 [inline]
      BUG: KASAN: stack-out-of-bounds in __ip_tunnel_create+0xca/0x6b0 net/ipv4/ip_tunnel.c:257
      Write of size 20 at addr ffff8801ac79f810 by task syzkaller268107/4482
      
      CPU: 0 PID: 4482 Comm: syzkaller268107 Not tainted 4.16.0+ #1
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:17 [inline]
       dump_stack+0x1b9/0x29f lib/dump_stack.c:53
       print_address_description+0x6c/0x20b mm/kasan/report.c:256
       kasan_report_error mm/kasan/report.c:354 [inline]
       kasan_report.cold.7+0xac/0x2f5 mm/kasan/report.c:412
       check_memory_region_inline mm/kasan/kasan.c:260 [inline]
       check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
       memcpy+0x37/0x50 mm/kasan/kasan.c:303
       strlcpy include/linux/string.h:300 [inline]
       __ip_tunnel_create+0xca/0x6b0 net/ipv4/ip_tunnel.c:257
       ip_tunnel_create net/ipv4/ip_tunnel.c:352 [inline]
       ip_tunnel_ioctl+0x818/0xd40 net/ipv4/ip_tunnel.c:861
       ipip_tunnel_ioctl+0x1c5/0x420 net/ipv4/ipip.c:350
       dev_ifsioc+0x43e/0xb90 net/core/dev_ioctl.c:334
       dev_ioctl+0x69a/0xcc0 net/core/dev_ioctl.c:525
       sock_ioctl+0x47e/0x680 net/socket.c:1015
       vfs_ioctl fs/ioctl.c:46 [inline]
       file_ioctl fs/ioctl.c:500 [inline]
       do_vfs_ioctl+0x1cf/0x1650 fs/ioctl.c:684
       ksys_ioctl+0xa9/0xd0 fs/ioctl.c:701
       SYSC_ioctl fs/ioctl.c:708 [inline]
       SyS_ioctl+0x24/0x30 fs/ioctl.c:706
       do_syscall_64+0x29e/0x9d0 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x42/0xb7
      
      Fixes: c5441932
      
       ("GRE: Refactor GRE tunneling code.")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6816295f
    • Eric Dumazet's avatar
      net: fool proof dev_valid_name() · 048a64fb
      Eric Dumazet authored
      
      [ Upstream commit a9d48205
      
       ]
      
      We want to use dev_valid_name() to validate tunnel names,
      so better use strnlen(name, IFNAMSIZ) than strlen(name) to make
      sure to not upset KASAN.
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      048a64fb
    • Xin Long's avatar
      bonding: process the err returned by dev_set_allmulti properly in bond_enslave · 77b9fc37
      Xin Long authored
      
      [ Upstream commit 9f5a90c1 ]
      
      When dev_set_promiscuity(1) succeeds but dev_set_allmulti(1) fails,
      dev_set_promiscuity(-1) should be done before going to the err path.
      Otherwise, dev->promiscuity will leak.
      
      Fixes: 7e1a1ac1
      
       ("bonding: Check return of dev_set_promiscuity/allmulti")
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Acked-by: default avatarAndy Gospodarek <andy@greyhouse.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      77b9fc37
    • Xin Long's avatar
      bonding: move dev_mc_sync after master_upper_dev_link in bond_enslave · 22ab1f87
      Xin Long authored
      
      [ Upstream commit ae42cc62 ]
      
      Beniamino found a crash when adding vlan as slave of bond which is also
      the parent link:
      
        ip link add bond1 type bond
        ip link set bond1 up
        ip link add link bond1 vlan1 type vlan id 80
        ip link set vlan1 master bond1
      
      The call trace is as below:
      
        [<ffffffffa850842a>] queued_spin_lock_slowpath+0xb/0xf
        [<ffffffffa8515680>] _raw_spin_lock+0x20/0x30
        [<ffffffffa83f6f07>] dev_mc_sync+0x37/0x80
        [<ffffffffc08687dc>] vlan_dev_set_rx_mode+0x1c/0x30 [8021q]
        [<ffffffffa83efd2a>] __dev_set_rx_mode+0x5a/0xa0
        [<ffffffffa83f7138>] dev_mc_sync_multiple+0x78/0x80
        [<ffffffffc084127c>] bond_enslave+0x67c/0x1190 [bonding]
        [<ffffffffa8401909>] do_setlink+0x9c9/0xe50
        [<ffffffffa8403bf2>] rtnl_newlink+0x522/0x880
        [<ffffffffa8403ff7>] rtnetlink_rcv_msg+0xa7/0x260
        [<ffffffffa8424ecb>] netlink_rcv_skb+0xab/0xc0
        [<ffffffffa83fe498>] rtnetlink_rcv+0x28/0x30
        [<ffffffffa8424850>] netlink_unicast+0x170/0x210
        [<ffffffffa8424bf8>] netlink_sendmsg+0x308/0x420
        [<ffffffffa83cc396>] sock_sendmsg+0xb6/0xf0
      
      This is actually a dead lock caused by sync slave hwaddr from master when
      the master is the slave's 'slave'. This dead loop check is actually done
      by netdev_master_upper_dev_link. However, Commit 1f718f0f ("bonding:
      populate neighbour's private on enslave") moved it after dev_mc_sync.
      
      This patch is to fix it by moving dev_mc_sync after master_upper_dev_link,
      so that this loop check would be earlier than dev_mc_sync. It also moves
      if (mode == BOND_MODE_8023AD) into if (!bond_uses_primary) clause as an
      improvement.
      
      Note team driver also has this issue, I will fix it in another patch.
      
      Fixes: 1f718f0f
      
       ("bonding: populate neighbour's private on enslave")
      Reported-by: default avatarBeniamino Galvani <bgalvani@redhat.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Acked-by: default avatarAndy Gospodarek <andy@greyhouse.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      22ab1f87
    • Xin Long's avatar
      bonding: fix the err path for dev hwaddr sync in bond_enslave · d7e7ab42
      Xin Long authored
      
      [ Upstream commit 5c78f6bf ]
      
      vlan_vids_add_by_dev is called right after dev hwaddr sync, so on
      the err path it should unsync dev hwaddr. Otherwise, the slave
      dev's hwaddr will never be unsync when this err happens.
      
      Fixes: 1ff412ad
      
       ("bonding: change the bond's vlan syncing functions with the standard ones")
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Reviewed-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
      Acked-by: default avatarAndy Gospodarek <andy@greyhouse.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d7e7ab42
    • David Ahern's avatar
      vrf: Fix use after free and double free in vrf_finish_output · 65c42a2d
      David Ahern authored
      
      [ Upstream commit 82dd0d2a ]
      
      Miguel reported an skb use after free / double free in vrf_finish_output
      when neigh_output returns an error. The vrf driver should return after
      the call to neigh_output as it takes over the skb on error path as well.
      
      Patch is a simplified version of Miguel's patch which was written for 4.9,
      and updated to top of tree.
      
      Fixes: 8f58336d
      
       ("net: Add ethernet header for pass through VRF device")
      Signed-off-by: default avatarMiguel Fadon Perlines <mfadon@teldat.com>
      Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      65c42a2d
    • Hangbin Liu's avatar
      vlan: also check phy_driver ts_info for vlan's real device · 09cb8267
      Hangbin Liu authored
      
      [ Upstream commit ec1d8ccb ]
      
      Just like function ethtool_get_ts_info(), we should also consider the
      phy_driver ts_info call back. For example, driver dp83640.
      
      Fixes: 37dd9255
      
       ("vlan: Pass ethtool get_ts_info queries to real device.")
      Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      09cb8267
    • Jason Wang's avatar
      vhost: correctly remove wait queue during poll failure · 4f288c97
      Jason Wang authored
      
      [ Upstream commit dc6455a7
      
       ]
      
      We tried to remove vq poll from wait queue, but do not check whether
      or not it was in a list before. This will lead double free. Fixing
      this by switching to use vhost_poll_stop() which zeros poll->wqh after
      removing poll from waitqueue to make sure it won't be freed twice.
      
      Cc: Darren Kenny <darren.kenny@oracle.com>
      Reported-by: default avatar <syzbot+c0272972b01b872e604a@syzkaller.appspotmail.com>
      Fixes: 2b8b328b
      
       ("vhost_net: handle polling errors when setting backend")
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      Reviewed-by: default avatarDarren Kenny <darren.kenny@oracle.com>
      Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4f288c97
    • Kai-Heng Feng's avatar
      sky2: Increase D3 delay to sky2 stops working after suspend · c5fc4dc5
      Kai-Heng Feng authored
      
      [ Upstream commit afb13363 ]
      
      The sky2 ethernet stops working after system resume from suspend:
      [ 582.852065] sky2 0000:04:00.0: Refused to change power state, currently in D3
      
      The current 150ms delay is not enough, change it to 200ms can solve the
      issue.
      
      BugLink: https://bugs.launchpad.net/bugs/1758507
      
      
      Cc: Stable <stable@vger.kernel.org>
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c5fc4dc5
    • Eric Dumazet's avatar
      sctp: sctp_sockaddr_af must check minimal addr length for AF_INET6 · 3fdd4370
      Eric Dumazet authored
      
      [ Upstream commit 81e98370
      
       ]
      
      Check must happen before call to ipv6_addr_v4mapped()
      
      syzbot report was :
      
      BUG: KMSAN: uninit-value in sctp_sockaddr_af net/sctp/socket.c:359 [inline]
      BUG: KMSAN: uninit-value in sctp_do_bind+0x60f/0xdc0 net/sctp/socket.c:384
      CPU: 0 PID: 3576 Comm: syzkaller968804 Not tainted 4.16.0+ #82
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:17 [inline]
       dump_stack+0x185/0x1d0 lib/dump_stack.c:53
       kmsan_report+0x142/0x240 mm/kmsan/kmsan.c:1067
       __msan_warning_32+0x6c/0xb0 mm/kmsan/kmsan_instr.c:676
       sctp_sockaddr_af net/sctp/socket.c:359 [inline]
       sctp_do_bind+0x60f/0xdc0 net/sctp/socket.c:384
       sctp_bind+0x149/0x190 net/sctp/socket.c:332
       inet6_bind+0x1fd/0x1820 net/ipv6/af_inet6.c:293
       SYSC_bind+0x3f2/0x4b0 net/socket.c:1474
       SyS_bind+0x54/0x80 net/socket.c:1460
       do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      RIP: 0033:0x43fd49
      RSP: 002b:00007ffe99df3d28 EFLAGS: 00000213 ORIG_RAX: 0000000000000031
      RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 000000000043fd49
      RDX: 0000000000000010 RSI: 0000000020000000 RDI: 0000000000000003
      RBP: 00000000006ca018 R08: 00000000004002c8 R09: 00000000004002c8
      R10: 00000000004002c8 R11: 0000000000000213 R12: 0000000000401670
      R13: 0000000000401700 R14: 0000000000000000 R15: 0000000000000000
      
      Local variable description: ----address@SYSC_bind
      Variable was created at:
       SYSC_bind+0x6f/0x4b0 net/socket.c:1461
       SyS_bind+0x54/0x80 net/socket.c:1460
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Vlad Yasevich <vyasevich@gmail.com>
      Cc: Neil Horman <nhorman@tuxdriver.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3fdd4370
    • Eric Dumazet's avatar
      sctp: do not leak kernel memory to user space · 3f80d01b
      Eric Dumazet authored
      
      [ Upstream commit 6780db24 ]
      
      syzbot produced a nice report [1]
      
      Issue here is that a recvmmsg() managed to leak 8 bytes of kernel memory
      to user space, because sin_zero (padding field) was not properly cleared.
      
      [1]
      BUG: KMSAN: uninit-value in copy_to_user include/linux/uaccess.h:184 [inline]
      BUG: KMSAN: uninit-value in move_addr_to_user+0x32e/0x530 net/socket.c:227
      CPU: 1 PID: 3586 Comm: syzkaller481044 Not tainted 4.16.0+ #82
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:17 [inline]
       dump_stack+0x185/0x1d0 lib/dump_stack.c:53
       kmsan_report+0x142/0x240 mm/kmsan/kmsan.c:1067
       kmsan_internal_check_memory+0x164/0x1d0 mm/kmsan/kmsan.c:1176
       kmsan_copy_to_user+0x69/0x160 mm/kmsan/kmsan.c:1199
       copy_to_user include/linux/uaccess.h:184 [inline]
       move_addr_to_user+0x32e/0x530 net/socket.c:227
       ___sys_recvmsg+0x4e2/0x810 net/socket.c:2211
       __sys_recvmmsg+0x54e/0xdb0 net/socket.c:2313
       SYSC_recvmmsg+0x29b/0x3e0 net/socket.c:2394
       SyS_recvmmsg+0x76/0xa0 net/socket.c:2378
       do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      RIP: 0033:0x4401c9
      RSP: 002b:00007ffc56f73098 EFLAGS: 00000217 ORIG_RAX: 000000000000012b
      RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004401c9
      RDX: 0000000000000001 RSI: 0000000020003ac0 RDI: 0000000000000003
      RBP: 00000000006ca018 R08: 0000000020003bc0 R09: 0000000000000010
      R10: 0000000000000000 R11: 0000000000000217 R12: 0000000000401af0
      R13: 0000000000401b80 R14: 0000000000000000 R15: 0000000000000000
      
      Local variable description: ----addr@___sys_recvmsg
      Variable was created at:
       ___sys_recvmsg+0xd5/0x810 net/socket.c:2172
       __sys_recvmmsg+0x54e/0xdb0 net/socket.c:2313
      
      Bytes 8-15 of 16 are uninitialized
      
      ==================================================================
      Kernel panic - not syncing: panic_on_warn set ...
      
      CPU: 1 PID: 3586 Comm: syzkaller481044 Tainted: G    B            4.16.0+ #82
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:17 [inline]
       dump_stack+0x185/0x1d0 lib/dump_stack.c:53
       panic+0x39d/0x940 kernel/panic.c:183
       kmsan_report+0x238/0x240 mm/kmsan/kmsan.c:1083
       kmsan_internal_check_memory+0x164/0x1d0 mm/kmsan/kmsan.c:1176
       kmsan_copy_to_user+0x69/0x160 mm/kmsan/kmsan.c:1199
       copy_to_user include/linux/uaccess.h:184 [inline]
       move_addr_to_user+0x32e/0x530 net/socket.c:227
       ___sys_recvmsg+0x4e2/0x810 net/socket.c:2211
       __sys_recvmmsg+0x54e/0xdb0 net/socket.c:2313
       SYSC_recvmmsg+0x29b/0x3e0 net/socket.c:2394
       SyS_recvmmsg+0x76/0xa0 net/socket.c:2378
       do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc:	Vlad Yasevich <vyasevich@gmail.com>
      Cc:	Neil Horman <nhorman@tuxdriver.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f80d01b
    • Heiner Kallweit's avatar
      r8169: fix setting driver_data after register_netdev · c17f6594
      Heiner Kallweit authored
      
      [ Upstream commit 19c9ea36
      
       ]
      
      pci_set_drvdata() is called only after registering the net_device,
      therefore we could run into a NPE if one of the functions using
      driver_data is called before it's set.
      
      Fix this by calling pci_set_drvdata() before registering the
      net_device.
      
      This fix is a candidate for stable. As far as I can see the
      bug has been there in kernel version 3.2 already, therefore
      I can't provide a reference which commit is fixed by it.
      
      The fix may need small adjustments per kernel version because
      due to other changes the label which is jumped to if
      register_netdev() fails has changed over time.
      
      Reported-by: default avatarDavid Miller <davem@davemloft.net>
      Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c17f6594
    • Eric Dumazet's avatar
      pptp: remove a buggy dst release in pptp_connect() · a7c8900c
      Eric Dumazet authored
      
      [ Upstream commit bfacfb45
      
       ]
      
      Once dst has been cached in socket via sk_setup_caps(),
      it is illegal to call ip_rt_put() (or dst_release()),
      since sk_setup_caps() did not change dst refcount.
      
      We can still dereference it since we hold socket lock.
      
      Caugth by syzbot :
      
      BUG: KASAN: use-after-free in atomic_dec_return include/asm-generic/atomic-instrumented.h:198 [inline]
      BUG: KASAN: use-after-free in dst_release+0x27/0xa0 net/core/dst.c:185
      Write of size 4 at addr ffff8801c54dc040 by task syz-executor4/20088
      
      CPU: 1 PID: 20088 Comm: syz-executor4 Not tainted 4.16.0+ #376
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:17 [inline]
       dump_stack+0x1a7/0x27d lib/dump_stack.c:53
       print_address_description+0x73/0x250 mm/kasan/report.c:256
       kasan_report_error mm/kasan/report.c:354 [inline]
       kasan_report+0x23c/0x360 mm/kasan/report.c:412
       check_memory_region_inline mm/kasan/kasan.c:260 [inline]
       check_memory_region+0x137/0x190 mm/kasan/kasan.c:267
       kasan_check_write+0x14/0x20 mm/kasan/kasan.c:278
       atomic_dec_return include/asm-generic/atomic-instrumented.h:198 [inline]
       dst_release+0x27/0xa0 net/core/dst.c:185
       sk_dst_set include/net/sock.h:1812 [inline]
       sk_dst_reset include/net/sock.h:1824 [inline]
       sock_setbindtodevice net/core/sock.c:610 [inline]
       sock_setsockopt+0x431/0x1b20 net/core/sock.c:707
       SYSC_setsockopt net/socket.c:1845 [inline]
       SyS_setsockopt+0x2ff/0x360 net/socket.c:1828
       do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x42/0xb7
      RIP: 0033:0x4552d9
      RSP: 002b:00007f4878126c68 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
      RAX: ffffffffffffffda RBX: 00007f48781276d4 RCX: 00000000004552d9
      RDX: 0000000000000019 RSI: 0000000000000001 RDI: 0000000000000013
      RBP: 000000000072bea0 R08: 0000000000000010 R09: 0000000000000000
      R10: 00000000200010c0 R11: 0000000000000246 R12: 00000000ffffffff
      R13: 0000000000000526 R14: 00000000006fac30 R15: 0000000000000000
      
      Allocated by task 20088:
       save_stack+0x43/0xd0 mm/kasan/kasan.c:447
       set_track mm/kasan/kasan.c:459 [inline]
       kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:552
       kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489
       kmem_cache_alloc+0x12e/0x760 mm/slab.c:3542
       dst_alloc+0x11f/0x1a0 net/core/dst.c:104
       rt_dst_alloc+0xe9/0x540 net/ipv4/route.c:1520
       __mkroute_output net/ipv4/route.c:2265 [inline]
       ip_route_output_key_hash_rcu+0xa49/0x2c60 net/ipv4/route.c:2493
       ip_route_output_key_hash+0x20b/0x370 net/ipv4/route.c:2322
       __ip_route_output_key include/net/route.h:126 [inline]
       ip_route_output_flow+0x26/0xa0 net/ipv4/route.c:2577
       ip_route_output_ports include/net/route.h:163 [inline]
       pptp_connect+0xa84/0x1170 drivers/net/ppp/pptp.c:453
       SYSC_connect+0x213/0x4a0 net/socket.c:1639
       SyS_connect+0x24/0x30 net/socket.c:1620
       do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x42/0xb7
      
      Freed by task 20082:
       save_stack+0x43/0xd0 mm/kasan/kasan.c:447
       set_track mm/kasan/kasan.c:459 [inline]
       __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:520
       kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:527
       __cache_free mm/slab.c:3486 [inline]
       kmem_cache_free+0x83/0x2a0 mm/slab.c:3744
       dst_destroy+0x266/0x380 net/core/dst.c:140
       dst_destroy_rcu+0x16/0x20 net/core/dst.c:153
       __rcu_reclaim kernel/rcu/rcu.h:178 [inline]
       rcu_do_batch kernel/rcu/tree.c:2675 [inline]
       invoke_rcu_callbacks kernel/rcu/tree.c:2930 [inline]
       __rcu_process_callbacks kernel/rcu/tree.c:2897 [inline]
       rcu_process_callbacks+0xd6c/0x17b0 kernel/rcu/tree.c:2914
       __do_softirq+0x2d7/0xb85 kernel/softirq.c:285
      
      The buggy address belongs to the object at ffff8801c54dc000
       which belongs to the cache ip_dst_cache of size 168
      The buggy address is located 64 bytes inside of
       168-byte region [ffff8801c54dc000, ffff8801c54dc0a8)
      The buggy address belongs to the page:
      page:ffffea0007153700 count:1 mapcount:0 mapping:ffff8801c54dc000 index:0x0
      flags: 0x2fffc0000000100(slab)
      raw: 02fffc0000000100 ffff8801c54dc000 0000000000000000 0000000100000010
      raw: ffffea0006b34b20 ffffea0006b6c1e0 ffff8801d674a1c0 0000000000000000
      page dumped because: kasan: bad access detected
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7c8900c
    • Davide Caratti's avatar
      net/sched: fix NULL dereference in the error path of tcf_bpf_init() · 21563c4d
      Davide Caratti authored
      
      [ Upstream commit 3239534a ]
      
      when tcf_bpf_init_from_ops() fails (e.g. because of program having invalid
      number of instructions), tcf_bpf_cfg_cleanup() calls bpf_prog_put(NULL) or
      bpf_prog_destroy(NULL). Unless CONFIG_BPF_SYSCALL is unset, this causes
      the following error:
      
       BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
       PGD 800000007345a067 P4D 800000007345a067 PUD 340e1067 PMD 0
       Oops: 0000 [#1] SMP PTI
       Modules linked in: act_bpf(E) ip6table_filter ip6_tables iptable_filter binfmt_misc ext4 mbcache jbd2 crct10dif_pclmul crc32_pclmul ghash_clmulni_intel snd_hda_codec_generic pcbc snd_hda_intel snd_hda_codec snd_hda_core snd_hwdep snd_seq snd_seq_device snd_pcm aesni_intel crypto_simd glue_helper cryptd joydev snd_timer snd virtio_balloon pcspkr soundcore i2c_piix4 nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c ata_generic pata_acpi qxl drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm virtio_blk drm virtio_net virtio_console i2c_core crc32c_intel serio_raw virtio_pci ata_piix libata virtio_ring floppy virtio dm_mirror dm_region_hash dm_log dm_mod [last unloaded: act_bpf]
       CPU: 3 PID: 5654 Comm: tc Tainted: G            E    4.16.0.bpf_test+ #408
       Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
       RIP: 0010:__bpf_prog_put+0xc/0xc0
       RSP: 0018:ffff9594003ef728 EFLAGS: 00010202
       RAX: 0000000000000000 RBX: ffff9594003ef758 RCX: 0000000000000024
       RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000
       RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000044
       R10: 0000000000000220 R11: ffff8a7ab9f17131 R12: 0000000000000000
       R13: ffff8a7ab7c3c8e0 R14: 0000000000000001 R15: ffff8a7ab88f1054
       FS:  00007fcb2f17c740(0000) GS:ffff8a7abfd80000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 0000000000000020 CR3: 000000007c888006 CR4: 00000000001606e0
       Call Trace:
        tcf_bpf_cfg_cleanup+0x2f/0x40 [act_bpf]
        tcf_bpf_cleanup+0x4c/0x70 [act_bpf]
        __tcf_idr_release+0x79/0x140
        tcf_bpf_init+0x125/0x330 [act_bpf]
        tcf_action_init_1+0x2cc/0x430
        ? get_page_from_freelist+0x3f0/0x11b0
        tcf_action_init+0xd3/0x1b0
        tc_ctl_action+0x18b/0x240
        rtnetlink_rcv_msg+0x29c/0x310
        ? _cond_resched+0x15/0x30
        ? __kmalloc_node_track_caller+0x1b9/0x270
        ? rtnl_calcit.isra.29+0x100/0x100
        netlink_rcv_skb+0xd2/0x110
        netlink_unicast+0x17c/0x230
        netlink_sendmsg+0x2cd/0x3c0
        sock_sendmsg+0x30/0x40
        ___sys_sendmsg+0x27a/0x290
        ? mem_cgroup_commit_charge+0x80/0x130
        ? page_add_new_anon_rmap+0x73/0xc0
        ? do_anonymous_page+0x2a2/0x560
        ? __handle_mm_fault+0xc75/0xe20
        __sys_sendmsg+0x58/0xa0
        do_syscall_64+0x6e/0x1a0
        entry_SYSCALL_64_after_hwframe+0x3d/0xa2
       RIP: 0033:0x7fcb2e58eba0
       RSP: 002b:00007ffc93c496c8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
       RAX: ffffffffffffffda RBX: 00007ffc93c497f0 RCX: 00007fcb2e58eba0
       RDX: 0000000000000000 RSI: 00007ffc93c49740 RDI: 0000000000000003
       RBP: 000000005ac6a646 R08: 0000000000000002 R09: 0000000000000000
       R10: 00007ffc93c49120 R11: 0000000000000246 R12: 0000000000000000
       R13: 00007ffc93c49804 R14: 0000000000000001 R15: 000000000066afa0
       Code: 5f 00 48 8b 43 20 48 c7 c7 70 2f 7c b8 c7 40 10 00 00 00 00 5b e9 a5 8b 61 00 0f 1f 44 00 00 0f 1f 44 00 00 41 54 55 48 89 fd 53 <48> 8b 47 20 f0 ff 08 74 05 5b 5d 41 5c c3 41 89 f4 0f 1f 44 00
       RIP: __bpf_prog_put+0xc/0xc0 RSP: ffff9594003ef728
       CR2: 0000000000000020
      
      Fix it in tcf_bpf_cfg_cleanup(), ensuring that bpf_prog_{put,destroy}(f)
      is called only when f is not NULL.
      
      Fixes: bbc09e78
      
       ("net/sched: fix idr leak on the error path of tcf_bpf_init()")
      Reported-by: default avatarLucas Bates <lucasb@mojatatu.com>
      Signed-off-by: default avatarDavide Caratti <dcaratti@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21563c4d
    • Craig Dillabaugh's avatar
      net sched actions: fix dumping which requires several messages to user space · cd19a9b1
      Craig Dillabaugh authored
      
      [ Upstream commit 734549eb ]
      
      Fixes a bug in the tcf_dump_walker function that can cause some actions
      to not be reported when dumping a large number of actions. This issue
      became more aggrevated when cookies feature was added. In particular
      this issue is manifest when large cookie values are assigned to the
      actions and when enough actions are created that the resulting table
      must be dumped in multiple batches.
      
      The number of actions returned in each batch is limited by the total
      number of actions and the memory buffer size.  With small cookies
      the numeric limit is reached before the buffer size limit, which avoids
      the code path triggering this bug. When large cookies are used buffer
      fills before the numeric limit, and the erroneous code path is hit.
      
      For example after creating 32 csum actions with the cookie
      aaaabbbbccccdddd
      
      $ tc actions ls action csum
      total acts 26
      
          action order 0: csum (tcp) action continue
          index 1 ref 1 bind 0
          cookie aaaabbbbccccdddd
      
          .....
      
          action order 25: csum (tcp) action continue
          index 26 ref 1 bind 0
          cookie aaaabbbbccccdddd
      total acts 6
      
          action order 0: csum (tcp) action continue
          index 28 ref 1 bind 0
          cookie aaaabbbbccccdddd
      
          ......
      
          action order 5: csum (tcp) action continue
          index 32 ref 1 bind 0
          cookie aaaabbbbccccdddd
      
      Note that the action with index 27 is omitted from the report.
      
      Fixes: 4b3550ef
      
       ("[NET_SCHED]: Use nla_nest_start/nla_nest_end")"
      Signed-off-by: default avatarCraig Dillabaugh <cdillaba@mojatatu.com>
      Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cd19a9b1
    • Alexander Potapenko's avatar
      netlink: make sure nladdr has correct size in netlink_connect() · 787b9406
      Alexander Potapenko authored
      
      [ Upstream commit 78802879
      
       ]
      
      KMSAN reports use of uninitialized memory in the case when |alen| is
      smaller than sizeof(struct sockaddr_nl), and therefore |nladdr| isn't
      fully copied from the userspace.
      
      Signed-off-by: default avatarAlexander Potapenko <glider@google.com>
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      787b9406