1. 25 2月, 2020 2 次提交
  2. 21 2月, 2020 1 次提交
    • K
      net: ip6_gre: Distribute switch variables for initialization · 46d30cb1
      Kees Cook 提交于
      Variables declared in a switch statement before any case statements
      cannot be automatically initialized with compiler instrumentation (as
      they are not part of any execution flow). With GCC's proposed automatic
      stack variable initialization feature, this triggers a warning (and they
      don't get initialized). Clang's automatic stack variable initialization
      (via CONFIG_INIT_STACK_ALL=y) doesn't throw a warning, but it also
      doesn't initialize such variables[1]. Note that these warnings (or silent
      skipping) happen before the dead-store elimination optimization phase,
      so even when the automatic initializations are later elided in favor of
      direct initializations, the warnings remain.
      
      To avoid these problems, move such variables into the "case" where
      they're used or lift them up into the main function body.
      
      net/ipv6/ip6_gre.c: In function ‘ip6gre_err’:
      net/ipv6/ip6_gre.c:440:32: warning: statement will never be executed [-Wswitch-unreachable]
        440 |   struct ipv6_tlv_tnl_enc_lim *tel;
            |                                ^~~
      
      net/ipv6/ip6_tunnel.c: In function ‘ip6_tnl_err’:
      net/ipv6/ip6_tunnel.c:520:32: warning: statement will never be executed [-Wswitch-unreachable]
        520 |   struct ipv6_tlv_tnl_enc_lim *tel;
            |                                ^~~
      
      [1] https://bugs.llvm.org/show_bug.cgi?id=44916Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      46d30cb1
  3. 17 2月, 2020 2 次提交
    • B
      ipv6: Fix nlmsg_flags when splitting a multipath route · afecdb37
      Benjamin Poirier 提交于
      When splitting an RTA_MULTIPATH request into multiple routes and adding the
      second and later components, we must not simply remove NLM_F_REPLACE but
      instead replace it by NLM_F_CREATE. Otherwise, it may look like the netlink
      message was malformed.
      
      For example,
      	ip route add 2001:db8::1/128 dev dummy0
      	ip route change 2001:db8::1/128 nexthop via fe80::30:1 dev dummy0 \
      		nexthop via fe80::30:2 dev dummy0
      results in the following warnings:
      [ 1035.057019] IPv6: RTM_NEWROUTE with no NLM_F_CREATE or NLM_F_REPLACE
      [ 1035.057517] IPv6: NLM_F_CREATE should be set when creating new route
      
      This patch makes the nlmsg sequence look equivalent for __ip6_ins_rt() to
      what it would get if the multipath route had been added in multiple netlink
      operations:
      	ip route add 2001:db8::1/128 dev dummy0
      	ip route change 2001:db8::1/128 nexthop via fe80::30:1 dev dummy0
      	ip route append 2001:db8::1/128 nexthop via fe80::30:2 dev dummy0
      
      Fixes: 27596472 ("ipv6: fix ECMP route replacement")
      Signed-off-by: NBenjamin Poirier <bpoirier@cumulusnetworks.com>
      Reviewed-by: NMichal Kubecek <mkubecek@suse.cz>
      Reviewed-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      afecdb37
    • B
      ipv6: Fix route replacement with dev-only route · e404b8c7
      Benjamin Poirier 提交于
      After commit 27596472 ("ipv6: fix ECMP route replacement") it is no
      longer possible to replace an ECMP-able route by a non ECMP-able route.
      For example,
      	ip route add 2001:db8::1/128 via fe80::1 dev dummy0
      	ip route replace 2001:db8::1/128 dev dummy0
      does not work as expected.
      
      Tweak the replacement logic so that point 3 in the log of the above commit
      becomes:
      3. If the new route is not ECMP-able, and no matching non-ECMP-able route
      exists, replace matching ECMP-able route (if any) or add the new route.
      
      We can now summarize the entire replace semantics to:
      When doing a replace, prefer replacing a matching route of the same
      "ECMP-able-ness" as the replace argument. If there is no such candidate,
      fallback to the first route found.
      
      Fixes: 27596472 ("ipv6: fix ECMP route replacement")
      Signed-off-by: NBenjamin Poirier <bpoirier@cumulusnetworks.com>
      Reviewed-by: NMichal Kubecek <mkubecek@suse.cz>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e404b8c7
  4. 14 2月, 2020 2 次提交
    • W
      net, ip6_tunnel: enhance tunnel locate with link check · 5fdcce21
      William Dauchy 提交于
      With ipip, it is possible to create an extra interface explicitly
      attached to a given physical interface:
      
        # ip link show tunl0
        4: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000
          link/ipip 0.0.0.0 brd 0.0.0.0
        # ip link add tunl1 type ipip dev eth0
        # ip link show tunl1
        6: tunl1@eth0: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000
          link/ipip 0.0.0.0 brd 0.0.0.0
      
      But it is not possible with ip6tnl:
      
        # ip link show ip6tnl0
        5: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop state DOWN mode DEFAULT group default qlen 1000
            link/tunnel6 :: brd ::
        # ip link add ip6tnl1 type ip6tnl dev eth0
        RTNETLINK answers: File exists
      
      This patch aims to make it possible by adding link comparaison in both
      tunnel locate and lookup functions; we also modify mtu calculation when
      attached to an interface with a lower mtu.
      
      This permits to make use of x-netns communication by moving the newly
      created tunnel in a given netns.
      Signed-off-by: NWilliam Dauchy <w.dauchy@criteo.com>
      Reviewed-by: NNicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5fdcce21
    • J
      icmp: introduce helper for nat'd source address in network device context · 0b41713b
      Jason A. Donenfeld 提交于
      This introduces a helper function to be called only by network drivers
      that wraps calls to icmp[v6]_send in a conntrack transformation, in case
      NAT has been used. We don't want to pollute the non-driver path, though,
      so we introduce this as a helper to be called by places that actually
      make use of this, as suggested by Florian.
      Signed-off-by: NJason A. Donenfeld <Jason@zx2c4.com>
      Cc: Florian Westphal <fw@strlen.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0b41713b
  5. 08 2月, 2020 1 次提交
    • E
      ipv6/addrconf: fix potential NULL deref in inet6_set_link_af() · db3fa271
      Eric Dumazet 提交于
      __in6_dev_get(dev) called from inet6_set_link_af() can return NULL.
      
      The needed check has been recently removed, let's add it back.
      
      While do_setlink() does call validate_linkmsg() :
      ...
      err = validate_linkmsg(dev, tb); /* OK at this point */
      ...
      
      It is possible that the following call happening before the
      ->set_link_af() removes IPv6 if MTU is less than 1280 :
      
      if (tb[IFLA_MTU]) {
          err = dev_set_mtu_ext(dev, nla_get_u32(tb[IFLA_MTU]), extack);
          if (err < 0)
                goto errout;
          status |= DO_SETLINK_MODIFIED;
      }
      ...
      
      if (tb[IFLA_AF_SPEC]) {
         ...
         err = af_ops->set_link_af(dev, af);
            ->inet6_set_link_af() // CRASH because idev is NULL
      
      Please note that IPv4 is immune to the bug since inet_set_link_af() does :
      
      struct in_device *in_dev = __in_dev_get_rcu(dev);
      if (!in_dev)
          return -EAFNOSUPPORT;
      
      This problem has been mentioned in commit cf7afbfe ("rtnl: make
      link af-specific updates atomic") changelog :
      
          This method is not fail proof, while it is currently sufficient
          to make set_link_af() inerrable and thus 100% atomic, the
          validation function method will not be able to detect all error
          scenarios in the future, there will likely always be errors
          depending on states which are f.e. not protected by rtnl_mutex
          and thus may change between validation and setting.
      
      IPv6: ADDRCONF(NETDEV_CHANGE): lo: link becomes ready
      general protection fault, probably for non-canonical address 0xdffffc0000000056: 0000 [#1] PREEMPT SMP KASAN
      KASAN: null-ptr-deref in range [0x00000000000002b0-0x00000000000002b7]
      CPU: 0 PID: 9698 Comm: syz-executor712 Not tainted 5.5.0-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      RIP: 0010:inet6_set_link_af+0x66e/0xae0 net/ipv6/addrconf.c:5733
      Code: 38 d0 7f 08 84 c0 0f 85 20 03 00 00 48 8d bb b0 02 00 00 45 0f b6 64 24 04 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 1a 03 00 00 44 89 a3 b0 02 00
      RSP: 0018:ffffc90005b06d40 EFLAGS: 00010206
      RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff86df39a6
      RDX: 0000000000000056 RSI: ffffffff86df3e74 RDI: 00000000000002b0
      RBP: ffffc90005b06e70 R08: ffff8880a2ac0380 R09: ffffc90005b06db0
      R10: fffff52000b60dbe R11: ffffc90005b06df7 R12: 0000000000000000
      R13: 0000000000000000 R14: ffff8880a1fcc424 R15: dffffc0000000000
      FS:  0000000000c46880(0000) GS:ffff8880ae800000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 000055f0494ca0d0 CR3: 000000009e4ac000 CR4: 00000000001406f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       do_setlink+0x2a9f/0x3720 net/core/rtnetlink.c:2754
       rtnl_group_changelink net/core/rtnetlink.c:3103 [inline]
       __rtnl_newlink+0xdd1/0x1790 net/core/rtnetlink.c:3257
       rtnl_newlink+0x69/0xa0 net/core/rtnetlink.c:3377
       rtnetlink_rcv_msg+0x45e/0xaf0 net/core/rtnetlink.c:5438
       netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477
       rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5456
       netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
       netlink_unicast+0x59e/0x7e0 net/netlink/af_netlink.c:1328
       netlink_sendmsg+0x91c/0xea0 net/netlink/af_netlink.c:1917
       sock_sendmsg_nosec net/socket.c:652 [inline]
       sock_sendmsg+0xd7/0x130 net/socket.c:672
       ____sys_sendmsg+0x753/0x880 net/socket.c:2343
       ___sys_sendmsg+0x100/0x170 net/socket.c:2397
       __sys_sendmsg+0x105/0x1d0 net/socket.c:2430
       __do_sys_sendmsg net/socket.c:2439 [inline]
       __se_sys_sendmsg net/socket.c:2437 [inline]
       __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2437
       do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x4402e9
      Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
      RSP: 002b:00007fffd62fbcf8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004402e9
      RDX: 0000000000000000 RSI: 0000000020000080 RDI: 0000000000000003
      RBP: 00000000006ca018 R08: 0000000000000008 R09: 00000000004002c8
      R10: 0000000000000005 R11: 0000000000000246 R12: 0000000000401b70
      R13: 0000000000401c00 R14: 0000000000000000 R15: 0000000000000000
      Modules linked in:
      ---[ end trace cfa7664b8fdcdff3 ]---
      RIP: 0010:inet6_set_link_af+0x66e/0xae0 net/ipv6/addrconf.c:5733
      Code: 38 d0 7f 08 84 c0 0f 85 20 03 00 00 48 8d bb b0 02 00 00 45 0f b6 64 24 04 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 1a 03 00 00 44 89 a3 b0 02 00
      RSP: 0018:ffffc90005b06d40 EFLAGS: 00010206
      RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff86df39a6
      RDX: 0000000000000056 RSI: ffffffff86df3e74 RDI: 00000000000002b0
      RBP: ffffc90005b06e70 R08: ffff8880a2ac0380 R09: ffffc90005b06db0
      R10: fffff52000b60dbe R11: ffffc90005b06df7 R12: 0000000000000000
      R13: 0000000000000000 R14: ffff8880a1fcc424 R15: dffffc0000000000
      FS:  0000000000c46880(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000020000004 CR3: 000000009e4ac000 CR4: 00000000001406e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      
      Fixes: 7dc2bcca ("Validate required parameters in inet6_validate_link_af")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Bisected-and-reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Cc: Maxim Mikityanskiy <maximmi@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      db3fa271
  6. 30 1月, 2020 2 次提交
    • G
      mptcp: Fix undefined mptcp_handle_ipv6_mapped for modular IPV6 · 31484d56
      Geert Uytterhoeven 提交于
      If CONFIG_MPTCP=y, CONFIG_MPTCP_IPV6=n, and CONFIG_IPV6=m:
      
          ERROR: "mptcp_handle_ipv6_mapped" [net/ipv6/ipv6.ko] undefined!
      
      This does not happen if CONFIG_MPTCP_IPV6=y, as CONFIG_MPTCP_IPV6
      selects CONFIG_IPV6, and thus forces CONFIG_IPV6 builtin.
      
      As exporting a symbol for an empty function would be a bit wasteful, fix
      this by providing a dummy version of mptcp_handle_ipv6_mapped() for the
      CONFIG_MPTCP_IPV6=n case.
      
      Rename mptcp_handle_ipv6_mapped() to mptcpv6_handle_mapped(), to make it
      clear this is a pure-IPV6 function, just like mptcpv6_init().
      
      Fixes: cec37a6e ("mptcp: Handle MP_CAPABLE options for outgoing connections")
      Signed-off-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      31484d56
    • F
      mptcp: handle tcp fallback when using syn cookies · ae2dd716
      Florian Westphal 提交于
      We can't deal with syncookie mode yet, the syncookie rx path will create
      tcp reqsk, i.e. we get OOB access because we treat tcp reqsk as mptcp reqsk one:
      
      TCP: SYN flooding on port 20002. Sending cookies.
      BUG: KASAN: slab-out-of-bounds in subflow_syn_recv_sock+0x451/0x4d0 net/mptcp/subflow.c:191
      Read of size 1 at addr ffff8881167bc148 by task syz-executor099/2120
       subflow_syn_recv_sock+0x451/0x4d0 net/mptcp/subflow.c:191
       tcp_get_cookie_sock+0xcf/0x520 net/ipv4/syncookies.c:209
       cookie_v6_check+0x15a5/0x1e90 net/ipv6/syncookies.c:252
       tcp_v6_cookie_check net/ipv6/tcp_ipv6.c:1123 [inline]
       [..]
      
      Bug can be reproduced via "sysctl net.ipv4.tcp_syncookies=2".
      
      Note that MPTCP should work with syncookies (4th ack would carry needed
      state), but it appears better to sort that out in -next so do tcp
      fallback for now.
      
      I removed the MPTCP ifdef for tcp_rsk "is_mptcp" member because
      if (IS_ENABLED()) is easier to read than "#ifdef IS_ENABLED()/#endif" pair.
      
      Cc: Eric Dumazet <edumazet@google.com>
      Fixes: cec37a6e ("mptcp: Handle MP_CAPABLE options for outgoing connections")
      Reported-by: NChristoph Paasch <cpaasch@apple.com>
      Tested-by: NChristoph Paasch <cpaasch@apple.com>
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ae2dd716
  7. 27 1月, 2020 1 次提交
  8. 24 1月, 2020 3 次提交
  9. 23 1月, 2020 1 次提交
  10. 21 1月, 2020 1 次提交
    • Y
      ipv6: sr: remove SKB_GSO_IPXIP6 on End.D* actions · 62ebaeae
      Yuki Taguchi 提交于
      After LRO/GRO is applied, SRv6 encapsulated packets have
      SKB_GSO_IPXIP6 feature flag, and this flag must be removed right after
      decapulation procedure.
      
      Currently, SKB_GSO_IPXIP6 flag is not removed on End.D* actions, which
      creates inconsistent packet state, that is, a normal TCP/IP packets
      have the SKB_GSO_IPXIP6 flag. This behavior can cause unexpected
      fallback to GSO on routing to netdevices that do not support
      SKB_GSO_IPXIP6. For example, on inter-VRF forwarding, decapsulated
      packets separated into small packets by GSO because VRF devices do not
      support TSO for packets with SKB_GSO_IPXIP6 flag, and this degrades
      forwarding performance.
      
      This patch removes encapsulation related GSO flags from the skb right
      after the End.D* action is applied.
      
      Fixes: d7a669dd ("ipv6: sr: add helper functions for seg6local")
      Signed-off-by: NYuki Taguchi <tagyounit@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      62ebaeae
  11. 20 1月, 2020 1 次提交
  12. 15 1月, 2020 3 次提交
  13. 14 1月, 2020 1 次提交
    • N
      vti[6]: fix packet tx through bpf_redirect() · 95224166
      Nicolas Dichtel 提交于
      With an ebpf program that redirects packets through a vti[6] interface,
      the packets are dropped because no dst is attached.
      
      This could also be reproduced with an AF_PACKET socket, with the following
      python script (vti1 is an ip_vti interface):
      
       import socket
       send_s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, 0)
       # scapy
       # p = IP(src='10.100.0.2', dst='10.200.0.1')/ICMP(type='echo-request')
       # raw(p)
       req = b'E\x00\x00\x1c\x00\x01\x00\x00@\x01e\xb2\nd\x00\x02\n\xc8\x00\x01\x08\x00\xf7\xff\x00\x00\x00\x00'
       send_s.sendto(req, ('vti1', 0x800, 0, 0))
      Signed-off-by: NNicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      95224166
  14. 10 1月, 2020 1 次提交
  15. 04 1月, 2020 1 次提交
  16. 03 1月, 2020 3 次提交
    • D
      net: Add device index to tcp_md5sig · 6b102db5
      David Ahern 提交于
      Add support for userspace to specify a device index to limit the scope
      of an entry via the TCP_MD5SIG_EXT setsockopt. The existing __tcpm_pad
      is renamed to tcpm_ifindex and the new field is only checked if the new
      TCP_MD5SIG_FLAG_IFINDEX is set in tcpm_flags. For now, the device index
      must point to an L3 master device (e.g., VRF). The API and error
      handling are setup to allow the constraint to be relaxed in the future
      to any device index.
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6b102db5
    • D
      tcp: Add l3index to tcp_md5sig_key and md5 functions · dea53bb8
      David Ahern 提交于
      Add l3index to tcp_md5sig_key to represent the L3 domain of a key, and
      add l3index to tcp_md5_do_add and tcp_md5_do_del to fill in the key.
      
      With the key now based on an l3index, add the new parameter to the
      lookup functions and consider the l3index when looking for a match.
      
      The l3index comes from the skb when processing ingress packets leveraging
      the helpers created for socket lookups, tcp_v4_sdif and inet_iif (and the
      v6 variants). When the sdif index is set it means the packet ingressed a
      device that is part of an L3 domain and inet_iif points to the VRF device.
      For egress, the L3 domain is determined from the socket binding and
      sk_bound_dev_if.
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      dea53bb8
    • D
      ipv6/tcp: Pass dif and sdif to tcp_v6_inbound_md5_hash · d14c77e0
      David Ahern 提交于
      The original ingress device index is saved to the cb space of the skb
      and the cb is moved during tcp processing. Since tcp_v6_inbound_md5_hash
      can be called before and after the cb move, pass dif and sdif to it so
      the caller can save both prior to the cb move. Both are used by a later
      patch.
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d14c77e0
  17. 25 12月, 2019 12 次提交
  18. 14 12月, 2019 1 次提交
  19. 10 12月, 2019 1 次提交