1. 08 3月, 2023 1 次提交
  2. 24 2月, 2023 1 次提交
  3. 20 2月, 2023 1 次提交
    • E
      net: add location to trace_consume_skb() · dd1b5278
      Eric Dumazet 提交于
      kfree_skb() includes the location, it makes sense
      to add it to consume_skb() as well.
      
      After patch:
      
       taskd_EventMana  8602 [004]   420.406239: skb:consume_skb: skbaddr=0xffff893a4a6d0500 location=unix_stream_read_generic
               swapper     0 [011]   422.732607: skb:consume_skb: skbaddr=0xffff89597f68cee0 location=mlx4_en_free_tx_desc
            discipline  9141 [043]   423.065653: skb:consume_skb: skbaddr=0xffff893a487e9c00 location=skb_consume_udp
               swapper     0 [010]   423.073166: skb:consume_skb: skbaddr=0xffff8949ce9cdb00 location=icmpv6_rcv
               borglet  8672 [014]   425.628256: skb:consume_skb: skbaddr=0xffff8949c42e9400 location=netlink_dump
               swapper     0 [028]   426.263317: skb:consume_skb: skbaddr=0xffff893b1589dce0 location=net_rx_action
                  wget 14339 [009]   426.686380: skb:consume_skb: skbaddr=0xffff893a51b552e0 location=tcp_rcv_state_process
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      dd1b5278
  4. 16 2月, 2023 3 次提交
    • I
      devlink: Fix netdev notifier chain corruption · b20b8aec
      Ido Schimmel 提交于
      Cited commit changed devlink to register its netdev notifier block on
      the global netdev notifier chain instead of on the per network namespace
      one.
      
      However, when changing the network namespace of the devlink instance,
      devlink still tries to unregister its notifier block from the chain of
      the old namespace and register it on the chain of the new namespace.
      This results in corruption of the notifier chains, as the same notifier
      block is registered on two different chains: The global one and the per
      network namespace one. In turn, this causes other problems such as the
      inability to dismantle namespaces due to netdev reference count issues.
      
      Fix by preventing devlink from moving its notifier block between
      namespaces.
      
      Reproducer:
      
       # echo "10 1" > /sys/bus/netdevsim/new_device
       # ip netns add test123
       # devlink dev reload netdevsim/netdevsim10 netns test123
       # ip netns del test123
       [   71.935619] unregister_netdevice: waiting for lo to become free. Usage count = 2
       [   71.938348] leaked reference.
      
      Fixes: 565b4824 ("devlink: change port event netdev notifier from per-net to global")
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: NJiri Pirko <jiri@nvidia.com>
      Reviewed-by: NJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: NJakub Kicinski <kuba@kernel.org>
      Link: https://lore.kernel.org/r/20230215073139.1360108-1-idosch@nvidia.comSigned-off-by: NPaolo Abeni <pabeni@redhat.com>
      b20b8aec
    • J
      net/core: refactor promiscuous mode message · 3ba0bf47
      Jesse Brandeburg 提交于
      The kernel stack can be more consistent by printing the IFF_PROMISC
      aka promiscuous enable/disable messages with the standard netdev_info
      message which can include bus and driver info as well as the device.
      
      typical command usage from user space looks like:
      ip link set eth0 promisc <on|off>
      
      But lots of utilities such as bridge, tcpdump, etc put the interface into
      promiscuous mode.
      
      old message:
      [  406.034418] device eth0 entered promiscuous mode
      [  408.424703] device eth0 left promiscuous mode
      
      new message:
      [  406.034431] ice 0000:17:00.0 eth0: entered promiscuous mode
      [  408.424715] ice 0000:17:00.0 eth0: left promiscuous mode
      Signed-off-by: NJesse Brandeburg <jesse.brandeburg@intel.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      3ba0bf47
    • J
      net/core: print message for allmulticast · 802dcbd6
      Jesse Brandeburg 提交于
      When the user sets or clears the IFF_ALLMULTI flag in the netdev, there are
      no log messages printed to the kernel log to indicate anything happened.
      This is inexplicably different from most other dev->flags changes, and
      could suprise the user.
      
      Typically this occurs from user-space when a user:
      ip link set eth0 allmulticast <on|off>
      
      However, other devices like bridge set allmulticast as well, and many
      other flows might trigger entry into allmulticast as well.
      
      The new message uses the standard netdev_info print and looks like:
      [  413.246110] ixgbe 0000:17:00.0 eth0: entered allmulticast mode
      [  415.977184] ixgbe 0000:17:00.0 eth0: left allmulticast mode
      Signed-off-by: NJesse Brandeburg <jesse.brandeburg@intel.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      802dcbd6
  5. 13 2月, 2023 1 次提交
  6. 03 2月, 2023 1 次提交
  7. 02 2月, 2023 1 次提交
  8. 24 1月, 2023 3 次提交
  9. 19 12月, 2022 1 次提交
  10. 04 12月, 2022 1 次提交
  11. 18 11月, 2022 1 次提交
  12. 16 11月, 2022 4 次提交
  13. 10 11月, 2022 1 次提交
  14. 09 11月, 2022 1 次提交
    • A
      net/core: Allow live renaming when an interface is up · bd039b5e
      Andy Ren 提交于
      Allow a network interface to be renamed when the interface
      is up.
      
      As described in the netconsole documentation [1], when netconsole is
      used as a built-in, it will bring up the specified interface as soon as
      possible. As a result, user space will not be able to rename the
      interface since the kernel disallows renaming of interfaces that are
      administratively up unless the 'IFF_LIVE_RENAME_OK' private flag was set
      by the kernel.
      
      The original solution [2] to this problem was to add a new parameter to
      the netconsole configuration parameters that allows renaming of
      the interface used by netconsole while it is administratively up.
      However, during the discussion that followed, it became apparent that we
      have no reason to keep the current restriction and instead we should
      allow user space to rename interfaces regardless of their administrative
      state:
      
      1. The restriction was put in place over 20 years ago when renaming was
      only possible via IOCTL and before rtnetlink started notifying user
      space about such changes like it does today.
      
      2. The 'IFF_LIVE_RENAME_OK' flag was added over 3 years ago in version
      5.2 and no regressions were reported.
      
      3. In-kernel listeners to 'NETDEV_CHANGENAME' do not seem to care about
      the administrative state of interface.
      
      Therefore, allow user space to rename running interfaces by removing the
      restriction and the associated 'IFF_LIVE_RENAME_OK' flag. Help in
      possible triage by emitting a message to the kernel log that an
      interface was renamed while UP.
      
      [1] https://www.kernel.org/doc/Documentation/networking/netconsole.rst
      [2] https://lore.kernel.org/netdev/20221102002420.2613004-1-andy.ren@getcruise.com/Signed-off-by: NAndy Ren <andy.ren@getcruise.com>
      Reviewed-by: NIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: NDavid Ahern <dsahern@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      bd039b5e
  15. 04 11月, 2022 1 次提交
    • J
      net: devlink: track netdev with devlink_port assigned · 02a68a47
      Jiri Pirko 提交于
      Currently, ethernet drivers are using devlink_port_type_eth_set() and
      devlink_port_type_clear() to set devlink port type and link to related
      netdev.
      
      Instead of calling them directly, let the driver use
      SET_NETDEV_DEVLINK_PORT macro to assign devlink_port pointer and let
      devlink to track it. Note the devlink port pointer is static during
      the time netdevice is registered.
      
      In devlink code, use per-namespace netdev notifier to track
      the netdevices with devlink_port assigned and change the internal
      devlink_port type and related type pointer accordingly.
      Signed-off-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      02a68a47
  16. 01 11月, 2022 2 次提交
  17. 29 10月, 2022 1 次提交
  18. 26 10月, 2022 1 次提交
    • K
      net: dev: Convert sa_data to flexible array in struct sockaddr · b5f0de6d
      Kees Cook 提交于
      One of the worst offenders of "fake flexible arrays" is struct sockaddr,
      as it is the classic example of why GCC and Clang have been traditionally
      forced to treat all trailing arrays as fake flexible arrays: in the
      distant misty past, sa_data became too small, and code started just
      treating it as a flexible array, even though it was fixed-size. The
      special case by the compiler is specifically that sizeof(sa->sa_data)
      and FORTIFY_SOURCE (which uses __builtin_object_size(sa->sa_data, 1))
      do not agree (14 and -1 respectively), which makes FORTIFY_SOURCE treat
      it as a flexible array.
      
      However, the coming -fstrict-flex-arrays compiler flag will remove
      these special cases so that FORTIFY_SOURCE can gain coverage over all
      the trailing arrays in the kernel that are _not_ supposed to be treated
      as a flexible array. To deal with this change, convert sa_data to a true
      flexible array. To keep the structure size the same, move sa_data into
      a union with a newly introduced sa_data_min with the original size. The
      result is that FORTIFY_SOURCE can continue to have no idea how large
      sa_data may actually be, but anything using sizeof(sa->sa_data) must
      switch to sizeof(sa->sa_data_min).
      
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Pavel Begunkov <asml.silence@gmail.com>
      Cc: David Ahern <dsahern@kernel.org>
      Cc: Dylan Yudaken <dylany@fb.com>
      Cc: Yajun Deng <yajun.deng@linux.dev>
      Cc: Petr Machata <petrm@nvidia.com>
      Cc: Hangbin Liu <liuhangbin@gmail.com>
      Cc: Leon Romanovsky <leon@kernel.org>
      Cc: syzbot <syzkaller@googlegroups.com>
      Cc: Willem de Bruijn <willemb@google.com>
      Cc: Pablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20221018095503.never.671-kees@kernel.orgSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      b5f0de6d
  19. 19 10月, 2022 1 次提交
    • P
      net: Fix return value of qdisc ingress handling on success · 672e97ef
      Paul Blakey 提交于
      Currently qdisc ingress handling (sch_handle_ingress()) doesn't
      set a return value and it is left to the old return value of
      the caller (__netif_receive_skb_core()) which is RX drop, so if
      the packet is consumed, caller will stop and return this value
      as if the packet was dropped.
      
      This causes a problem in the kernel tcp stack when having a
      egress tc rule forwarding to a ingress tc rule.
      The tcp stack sending packets on the device having the egress rule
      will see the packets as not successfully transmitted (although they
      actually were), will not advance it's internal state of sent data,
      and packets returning on such tcp stream will be dropped by the tcp
      stack with reason ack-of-unsent-data. See reproduction in [0] below.
      
      Fix that by setting the return value to RX success if
      the packet was handled successfully.
      
      [0] Reproduction steps:
       $ ip link add veth1 type veth peer name peer1
       $ ip link add veth2 type veth peer name peer2
       $ ifconfig peer1 5.5.5.6/24 up
       $ ip netns add ns0
       $ ip link set dev peer2 netns ns0
       $ ip netns exec ns0 ifconfig peer2 5.5.5.5/24 up
       $ ifconfig veth2 0 up
       $ ifconfig veth1 0 up
      
       #ingress forwarding veth1 <-> veth2
       $ tc qdisc add dev veth2 ingress
       $ tc qdisc add dev veth1 ingress
       $ tc filter add dev veth2 ingress prio 1 proto all flower \
         action mirred egress redirect dev veth1
       $ tc filter add dev veth1 ingress prio 1 proto all flower \
         action mirred egress redirect dev veth2
      
       #steal packet from peer1 egress to veth2 ingress, bypassing the veth pipe
       $ tc qdisc add dev peer1 clsact
       $ tc filter add dev peer1 egress prio 20 proto ip flower \
         action mirred ingress redirect dev veth1
      
       #run iperf and see connection not running
       $ iperf3 -s&
       $ ip netns exec ns0 iperf3 -c 5.5.5.6 -i 1
      
       #delete egress rule, and run again, now should work
       $ tc filter del dev peer1 egress
       $ ip netns exec ns0 iperf3 -c 5.5.5.6 -i 1
      
      Fixes: f697c3e8 ("[NET]: Avoid unnecessary cloning for ingress filtering")
      Signed-off-by: NPaul Blakey <paulb@nvidia.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      672e97ef
  20. 30 9月, 2022 1 次提交
  21. 24 8月, 2022 6 次提交
  22. 23 8月, 2022 1 次提交
  23. 22 8月, 2022 1 次提交
  24. 20 7月, 2022 1 次提交
  25. 06 7月, 2022 1 次提交
    • J
      xdp: Fix spurious packet loss in generic XDP TX path · 1fd6e567
      Johan Almbladh 提交于
      The byte queue limits (BQL) mechanism is intended to move queuing from
      the driver to the network stack in order to reduce latency caused by
      excessive queuing in hardware. However, when transmitting or redirecting
      a packet using generic XDP, the qdisc layer is bypassed and there are no
      additional queues. Since netif_xmit_stopped() also takes BQL limits into
      account, but without having any alternative queuing, packets are
      silently dropped.
      
      This patch modifies the drop condition to only consider cases when the
      driver itself cannot accept any more packets. This is analogous to the
      condition in __dev_direct_xmit(). Dropped packets are also counted on
      the device.
      
      Bypassing the qdisc layer in the generic XDP TX path means that XDP
      packets are able to starve other packets going through a qdisc, and
      DDOS attacks will be more effective. In-driver-XDP use dedicated TX
      queues, so they do not have this starvation issue.
      Signed-off-by: NJohan Almbladh <johan.almbladh@anyfinetworks.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20220705082345.2494312-1-johan.almbladh@anyfinetworks.com
      1fd6e567
  26. 17 6月, 2022 1 次提交
    • E
      net: fix data-race in dev_isalive() · cc26c266
      Eric Dumazet 提交于
      dev_isalive() is called under RTNL or dev_base_lock protection.
      
      This means that changes to dev->reg_state should be done with both locks held.
      
      syzbot reported:
      
      BUG: KCSAN: data-race in register_netdevice / type_show
      
      write to 0xffff888144ecf518 of 1 bytes by task 20886 on cpu 0:
      register_netdevice+0xb9f/0xdf0 net/core/dev.c:10050
      lapbeth_new_device drivers/net/wan/lapbether.c:414 [inline]
      lapbeth_device_event+0x4a0/0x6c0 drivers/net/wan/lapbether.c:456
      notifier_call_chain kernel/notifier.c:87 [inline]
      raw_notifier_call_chain+0x53/0xb0 kernel/notifier.c:455
      __dev_notify_flags+0x1d6/0x3a0
      dev_change_flags+0xa2/0xc0 net/core/dev.c:8607
      do_setlink+0x778/0x2230 net/core/rtnetlink.c:2780
      __rtnl_newlink net/core/rtnetlink.c:3546 [inline]
      rtnl_newlink+0x114c/0x16a0 net/core/rtnetlink.c:3593
      rtnetlink_rcv_msg+0x811/0x8c0 net/core/rtnetlink.c:6089
      netlink_rcv_skb+0x13e/0x240 net/netlink/af_netlink.c:2501
      rtnetlink_rcv+0x18/0x20 net/core/rtnetlink.c:6107
      netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
      netlink_unicast+0x58a/0x660 net/netlink/af_netlink.c:1345
      netlink_sendmsg+0x661/0x750 net/netlink/af_netlink.c:1921
      sock_sendmsg_nosec net/socket.c:714 [inline]
      sock_sendmsg net/socket.c:734 [inline]
      __sys_sendto+0x21e/0x2c0 net/socket.c:2119
      __do_sys_sendto net/socket.c:2131 [inline]
      __se_sys_sendto net/socket.c:2127 [inline]
      __x64_sys_sendto+0x74/0x90 net/socket.c:2127
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      read to 0xffff888144ecf518 of 1 bytes by task 20423 on cpu 1:
      dev_isalive net/core/net-sysfs.c:38 [inline]
      netdev_show net/core/net-sysfs.c:50 [inline]
      type_show+0x24/0x90 net/core/net-sysfs.c:112
      dev_attr_show+0x35/0x90 drivers/base/core.c:2095
      sysfs_kf_seq_show+0x175/0x240 fs/sysfs/file.c:59
      kernfs_seq_show+0x75/0x80 fs/kernfs/file.c:162
      seq_read_iter+0x2c3/0x8e0 fs/seq_file.c:230
      kernfs_fop_read_iter+0xd1/0x2f0 fs/kernfs/file.c:235
      call_read_iter include/linux/fs.h:2052 [inline]
      new_sync_read fs/read_write.c:401 [inline]
      vfs_read+0x5a5/0x6a0 fs/read_write.c:482
      ksys_read+0xe8/0x1a0 fs/read_write.c:620
      __do_sys_read fs/read_write.c:630 [inline]
      __se_sys_read fs/read_write.c:628 [inline]
      __x64_sys_read+0x3e/0x50 fs/read_write.c:628
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      value changed: 0x00 -> 0x01
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 1 PID: 20423 Comm: udevd Tainted: G W 5.19.0-rc2-syzkaller-dirty #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      cc26c266
  27. 10 6月, 2022 1 次提交