1. 19 7月, 2017 9 次提交
  2. 12 7月, 2017 2 次提交
    • I
      mlxsw: spectrum_router: Fix use-after-free in route replace · 7387dbbc
      Ido Schimmel 提交于
      While working on IPv6 route replace I realized we can have a
      use-after-free in IPv4 in case the replaced route is offloaded and the
      only one using its FIB info.
      
      The problem is that fib_table_insert() drops the reference on the FIB
      info of the replaced routes which is eventually freed via call_rcu().
      Since the driver doesn't hold a reference on this FIB info it can cause
      a use-after-free when it tries to clear the RTNH_F_OFFLOAD flag stored
      in fi->fib_flags.
      
      After running the following commands in a loop for enough time with a
      KASAN enabled kernel I finally got the below trace.
      
      $ ip route add 192.168.50.0/24 via 192.168.200.1 dev enp3s0np3
      $ ip route replace 192.168.50.0/24 dev enp3s0np5
      $ ip route del 192.168.50.0/24 dev enp3s0np5
      
      BUG: KASAN: use-after-free in mlxsw_sp_fib_entry_offload_unset+0xa7/0x120 [mlxsw_spectrum]
      Read of size 4 at addr ffff8803717d9820 by task kworker/u4:2/55
      [...]
      ? mlxsw_sp_fib_entry_offload_unset+0xa7/0x120 [mlxsw_spectrum]
      ? mlxsw_sp_fib_entry_offload_unset+0xa7/0x120 [mlxsw_spectrum]
      ? mlxsw_sp_router_neighs_update_work+0x1cd0/0x1ce0 [mlxsw_spectrum]
      ? mlxsw_sp_fib_entry_offload_unset+0xa7/0x120 [mlxsw_spectrum]
      __asan_load4+0x61/0x80
      mlxsw_sp_fib_entry_offload_unset+0xa7/0x120 [mlxsw_spectrum]
      mlxsw_sp_fib_entry_offload_refresh+0xb6/0x370 [mlxsw_spectrum]
      mlxsw_sp_router_fib_event_work+0xd1c/0x2780 [mlxsw_spectrum]
      [...]
      Freed by task 5131:
       save_stack_trace+0x16/0x20
       save_stack+0x46/0xd0
       kasan_slab_free+0x70/0xc0
       kfree+0x144/0x570
       free_fib_info_rcu+0x2e7/0x410
       rcu_process_callbacks+0x4f8/0xe30
       __do_softirq+0x1d3/0x9e2
      
      Fix this by taking a reference on the FIB info when creating the nexthop
      group it represents and drop it when the group is destroyed.
      
      Fixes: 599cf8f9 ("mlxsw: spectrum_router: Add support for route replace")
      Signed-off-by: NIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7387dbbc
    • I
      mlxsw: spectrum_router: Add missing rollback · a4e75b76
      Ido Schimmel 提交于
      With this patch the error path of mlxsw_sp_nexthop_init() is symmetric
      with mlxsw_sp_nexthop_fini(). Noticed during code review.
      
      Fixes: a8c97014 ("mlxsw: spectrum_router: Refactor nexthop init routine")
      Signed-off-by: NIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a4e75b76
  3. 30 6月, 2017 1 次提交
    • I
      mlxsw: spectrum_router: Fix NULL pointer dereference · 6b27c8ad
      Ido Schimmel 提交于
      In case a VLAN device is enslaved to a bridge we shouldn't create a
      router interface (RIF) for it when it's configured with an IP address.
      This is already handled by the driver for other types of netdevs, such
      as physical ports and LAG devices.
      
      If this IP address is then removed and the interface is subsequently
      unlinked from the bridge, a NULL pointer dereference can happen, as the
      original 802.1d FID was replaced with an rFID which was then deleted.
      
      To reproduce:
      $ ip link set dev enp3s0np9 up
      $ ip link add name enp3s0np9.111 link enp3s0np9 type vlan id 111
      $ ip link set dev enp3s0np9.111 up
      $ ip link add name br0 type bridge
      $ ip link set dev br0 up
      $ ip link set enp3s0np9.111 master br0
      $ ip address add dev enp3s0np9.111 192.168.0.1/24
      $ ip address del dev enp3s0np9.111 192.168.0.1/24
      $ ip link set dev enp3s0np9.111 nomaster
      
      Fixes: 99724c18 ("mlxsw: spectrum: Introduce support for router interfaces")
      Signed-off-by: NIdo Schimmel <idosch@mellanox.com>
      Reported-by: NPetr Machata <petrm@mellanox.com>
      Tested-by: NPetr Machata <petrm@mellanox.com>
      Reviewed-by: NPetr Machata <petrm@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6b27c8ad
  4. 09 6月, 2017 1 次提交
  5. 05 6月, 2017 1 次提交
  6. 27 5月, 2017 14 次提交
  7. 26 5月, 2017 1 次提交
  8. 18 5月, 2017 6 次提交
  9. 01 5月, 2017 1 次提交
    • I
      mlxsw: spectrum_router: Simplify VRF enslavement · b1e45526
      Ido Schimmel 提交于
      When a netdev is enslaved to a VRF master, its router interface (RIF)
      needs to be destroyed (if exists) and a new one created using the
      corresponding virtual router (VR).
      
      >From the driver's perspective, the above is equivalent to an inetaddr
      event sent for this netdev. Therefore, when a port netdev (or its
      uppers) are enslaved to a VRF master, call the same function that
      would've been called had a NETDEV_UP was sent for this netdev in the
      inetaddr notification chain.
      
      This patch also fixes a bug when a LAG netdev with an existing RIF is
      enslaved to a VRF. Before this patch, each LAG port would drop the
      reference on the RIF, but would re-join the same one (in the wrong VR)
      soon after. With this patch, the corresponding RIF is first destroyed
      and a new one is created using the correct VR.
      
      Fixes: 7179eb5a ("mlxsw: spectrum_router: Add support for VRFs")
      Signed-off-by: NIdo Schimmel <idosch@mellanox.com>
      Reviewed-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b1e45526
  10. 21 4月, 2017 1 次提交
  11. 29 3月, 2017 2 次提交
  12. 26 3月, 2017 1 次提交