1. 22 4月, 2018 4 次提交
  2. 20 4月, 2018 7 次提交
    • E
      net/ipv6: Fix ip6_convert_metrics() bug · 263243d6
      Eric Dumazet 提交于
      If ip6_convert_metrics() fails to allocate memory, it should not
      overwrite rt->fib6_metrics or we risk a crash later as syzbot found.
      
      BUG: KASAN: null-ptr-deref in atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
      BUG: KASAN: null-ptr-deref in refcount_sub_and_test+0x92/0x330 lib/refcount.c:179
      Read of size 4 at addr 0000000000000044 by task syzkaller832429/4487
      
      CPU: 1 PID: 4487 Comm: syzkaller832429 Not tainted 4.16.0+ #6
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x1b9/0x294 lib/dump_stack.c:113
       kasan_report_error mm/kasan/report.c:352 [inline]
       kasan_report.cold.7+0x6d/0x2fe 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
       kasan_check_read+0x11/0x20 mm/kasan/kasan.c:272
       atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
       refcount_sub_and_test+0x92/0x330 lib/refcount.c:179
       refcount_dec_and_test+0x1a/0x20 lib/refcount.c:212
       fib6_info_destroy+0x2d0/0x3c0 net/ipv6/ip6_fib.c:206
       fib6_info_release include/net/ip6_fib.h:304 [inline]
       ip6_route_info_create+0x677/0x3240 net/ipv6/route.c:3020
       ip6_route_add+0x23/0xb0 net/ipv6/route.c:3030
       inet6_rtm_newroute+0x142/0x160 net/ipv6/route.c:4406
       rtnetlink_rcv_msg+0x466/0xc10 net/core/rtnetlink.c:4648
       netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2448
       rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:4666
       netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
       netlink_unicast+0x58b/0x740 net/netlink/af_netlink.c:1336
       netlink_sendmsg+0x9f0/0xfa0 net/netlink/af_netlink.c:1901
       sock_sendmsg_nosec net/socket.c:629 [inline]
       sock_sendmsg+0xd5/0x120 net/socket.c:639
       ___sys_sendmsg+0x805/0x940 net/socket.c:2117
       __sys_sendmsg+0x115/0x270 net/socket.c:2155
       SYSC_sendmsg net/socket.c:2164 [inline]
       SyS_sendmsg+0x29/0x30 net/socket.c:2162
       do_syscall_64+0x29e/0x9d0 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x42/0xb7
      
      Fixes: d4ead6b3 ("net/ipv6: move metrics from dst to rt6_info")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Cc: David Ahern <dsa@cumulusnetworks.com>
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Acked-by: NDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      263243d6
    • D
      net/ipv6: Fix gfp_flags arg to addrconf_prefix_route · 27b10608
      David Ahern 提交于
      Eric noticed that __ipv6_ifa_notify is called under rcu_read_lock, so
      the gfp argument to addrconf_prefix_route can not be GFP_KERNEL.
      
      While scrubbing other calls I noticed addrconf_addr_gen has one
      place with GFP_ATOMIC that can be GFP_KERNEL.
      
      Fixes: acb54e3c ("net/ipv6: Add gfp_flags to route add functions")
      Reported-by: syzbot+2add39b05179b31f912f@syzkaller.appspotmail.com
      Reported-by: NEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      27b10608
    • D
      net/ipv6: Remove fib6_idev · dcd1f572
      David Ahern 提交于
      fib6_idev can be obtained from __in6_dev_get on the nexthop device
      rather than caching it in the fib6_info. Remove it.
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      dcd1f572
    • D
      net/ipv6: Remove unnecessary checks on fib6_idev · eea68cd3
      David Ahern 提交于
      Prior to 4832c30d ("net: ipv6: put host and anycast routes on device
      with address") host routes and anycast routes were installed with the
      device set to loopback (or VRF device once that feature was added). In the
      older code dst.dev was set to loopback (needed for packet tx) and rt6i_idev
      was used to denote the actual interface.
      
      Commit 4832c30d changed the code to have dst.dev pointing to the real
      device with the switch to lo or vrf device done on dst clones. As a
      consequence of this change a couple of device checks during route lookups
      are no longer needed. Remove them.
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      eea68cd3
    • D
      net/ipv6: Remove aca_idev · 9ee8cbb2
      David Ahern 提交于
      aca_idev has only 1 user - inet6_fill_ifacaddr - and it only
      wants the device index which can be extracted from the fib6_info
      nexthop.
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9ee8cbb2
    • D
      net/ipv6: Rename addrconf_dst_alloc · 360a9887
      David Ahern 提交于
      addrconf_dst_alloc now returns a fib6_info. Update the name
      and its users to reflect the change.
      
      Rename only; no functional change intended.
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      360a9887
    • D
      net/ipv6: Rename fib6_info struct elements · 93c2fb25
      David Ahern 提交于
      Change the prefix for fib6_info struct elements from rt6i_ to fib6_.
      rt6i_pcpu and rt6i_exception_bucket are left as is given that they
      point to rt6_info entries.
      
      Rename only; not functional change intended.
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      93c2fb25
  3. 19 4月, 2018 1 次提交
    • E
      ipv6: frags: fix a lockdep false positive · 415787d7
      Eric Dumazet 提交于
      lockdep does not know that the locks used by IPv4 defrag
      and IPv6 reassembly units are of different classes.
      
      It complains because of following chains :
      
      1) sch_direct_xmit()        (lock txq->_xmit_lock)
          dev_hard_start_xmit()
           xmit_one()
            dev_queue_xmit_nit()
             packet_rcv_fanout()
              ip_check_defrag()
               ip_defrag()
                spin_lock()     (lock frag queue spinlock)
      
      2) ip6_input_finish()
          ipv6_frag_rcv()       (lock frag queue spinlock)
           ip6_frag_queue()
            icmpv6_param_prob() (lock txq->_xmit_lock at some point)
      
      We could add lockdep annotations, but we also can make sure IPv6
      calls icmpv6_param_prob() only after the release of the frag queue spinlock,
      since this naturally makes frag queue spinlock a leaf in lock hierarchy.
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      415787d7
  4. 18 4月, 2018 21 次提交
  5. 17 4月, 2018 3 次提交
    • E
      tcp: implement mmap() for zero copy receive · 93ab6cc6
      Eric Dumazet 提交于
      Some networks can make sure TCP payload can exactly fit 4KB pages,
      with well chosen MSS/MTU and architectures.
      
      Implement mmap() system call so that applications can avoid
      copying data without complex splice() games.
      
      Note that a successful mmap( X bytes) on TCP socket is consuming
      bytes, as if recvmsg() has been done. (tp->copied += X)
      
      Only PROT_READ mappings are accepted, as skb page frags
      are fundamentally shared and read only.
      
      If tcp_mmap() finds data that is not a full page, or a patch of
      urgent data, -EINVAL is returned, no bytes are consumed.
      
      Application must fallback to recvmsg() to read the problematic sequence.
      
      mmap() wont block,  regardless of socket being in blocking or
      non-blocking mode. If not enough bytes are in receive queue,
      mmap() would return -EAGAIN, or -EIO if socket is in a state
      where no other bytes can be added into receive queue.
      
      An application might use SO_RCVLOWAT, poll() and/or ioctl( FIONREAD)
      to efficiently use mmap()
      
      On the sender side, MSG_EOR might help to clearly separate unaligned
      headers and 4K-aligned chunks if necessary.
      
      Tested:
      
      mlx4 (cx-3) 40Gbit NIC, with tcp_mmap program provided in following patch.
      MTU set to 4168  (4096 TCP payload, 40 bytes IPv6 header, 32 bytes TCP header)
      
      Without mmap() (tcp_mmap -s)
      
      received 32768 MB (0 % mmap'ed) in 8.13342 s, 33.7961 Gbit,
        cpu usage user:0.034 sys:3.778, 116.333 usec per MB, 63062 c-switches
      received 32768 MB (0 % mmap'ed) in 8.14501 s, 33.748 Gbit,
        cpu usage user:0.029 sys:3.997, 122.864 usec per MB, 61903 c-switches
      received 32768 MB (0 % mmap'ed) in 8.11723 s, 33.8635 Gbit,
        cpu usage user:0.048 sys:3.964, 122.437 usec per MB, 62983 c-switches
      received 32768 MB (0 % mmap'ed) in 8.39189 s, 32.7552 Gbit,
        cpu usage user:0.038 sys:4.181, 128.754 usec per MB, 55834 c-switches
      
      With mmap() on receiver (tcp_mmap -s -z)
      
      received 32768 MB (100 % mmap'ed) in 8.03083 s, 34.2278 Gbit,
        cpu usage user:0.024 sys:1.466, 45.4712 usec per MB, 65479 c-switches
      received 32768 MB (100 % mmap'ed) in 7.98805 s, 34.4111 Gbit,
        cpu usage user:0.026 sys:1.401, 43.5486 usec per MB, 65447 c-switches
      received 32768 MB (100 % mmap'ed) in 7.98377 s, 34.4296 Gbit,
        cpu usage user:0.028 sys:1.452, 45.166 usec per MB, 65496 c-switches
      received 32768 MB (99.9969 % mmap'ed) in 8.01838 s, 34.281 Gbit,
        cpu usage user:0.02 sys:1.446, 44.7388 usec per MB, 65505 c-switches
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      93ab6cc6
    • E
      tcp: fix SO_RCVLOWAT and RCVBUF autotuning · d1361840
      Eric Dumazet 提交于
      Applications might use SO_RCVLOWAT on TCP socket hoping to receive
      one [E]POLLIN event only when a given amount of bytes are ready in socket
      receive queue.
      
      Problem is that receive autotuning is not aware of this constraint,
      meaning sk_rcvbuf might be too small to allow all bytes to be stored.
      
      Add a new (struct proto_ops)->set_rcvlowat method so that a protocol
      can override the default setsockopt(SO_RCVLOWAT) behavior.
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d1361840
    • L
      ipv6: remove unnecessary check in addrconf_prefix_rcv_add_addr() · f85f94b8
      Lorenzo Bianconi 提交于
      Remove unnecessary check on update_lft variable in
      addrconf_prefix_rcv_add_addr routine since it is always set to 0.
      Moreover remove update_lft re-initialization to 0
      Signed-off-by: NLorenzo Bianconi <lorenzo.bianconi@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f85f94b8
  6. 06 4月, 2018 4 次提交
    • J
      net/ipv6: Increment OUTxxx counters after netfilter hook · 71a1c915
      Jeff Barnhill 提交于
      At the end of ip6_forward(), IPSTATS_MIB_OUTFORWDATAGRAMS and
      IPSTATS_MIB_OUTOCTETS are incremented immediately before the NF_HOOK call
      for NFPROTO_IPV6 / NF_INET_FORWARD.  As a result, these counters get
      incremented regardless of whether or not the netfilter hook allows the
      packet to continue being processed.  This change increments the counters
      in ip6_forward_finish() so that it will not happen if the netfilter hook
      chooses to terminate the packet, which is similar to how IPv4 works.
      Signed-off-by: NJeff Barnhill <0xeffeff@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      71a1c915
    • E
      vti6: better validate user provided tunnel names · 537b361f
      Eric Dumazet 提交于
      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: NEric Dumazet <edumazet@google.com>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      537b361f
    • E
      ip6_tunnel: better validate user provided tunnel names · db7a65e3
      Eric Dumazet 提交于
      Use valid_name() to make sure user does not provide illegal
      device name.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      db7a65e3
    • E
      ip6_gre: better validate user provided tunnel names · 5f42df01
      Eric Dumazet 提交于
      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: NEric Dumazet <edumazet@google.com>
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5f42df01