1. 12 6月, 2018 4 次提交
    • D
      net/ipv6: Ensure cfg is properly initialized in ipv6_create_tempaddr · 3f2d67b6
      David Ahern 提交于
      Valdis reported a BUG in ipv6_add_addr:
      
      [ 1820.832682] BUG: unable to handle kernel NULL pointer dereference at 0000000000000209
      [ 1820.832728] RIP: 0010:ipv6_add_addr+0x280/0xd10
      [ 1820.832732] Code: 49 8b 1f 0f 84 6a 0a 00 00 48 85 db 0f 84 4e 0a 00 00 48 8b 03 48 8b 53 08 49 89 45 00 49 8b 47 10
      49 89 55 08 48 85 c0 74 15 <48> 8b 50 08 48 8b 00 49 89 95 b8 01 00 00 49 89 85 b0 01 00 00 4c
      [ 1820.832847] RSP: 0018:ffffaa07c2fd7880 EFLAGS: 00010202
      [ 1820.832853] RAX: 0000000000000201 RBX: ffffaa07c2fd79b0 RCX: 0000000000000000
      [ 1820.832858] RDX: a4cfbfba2cbfa64c RSI: 0000000000000000 RDI: ffffffff8a8e9fa0
      [ 1820.832862] RBP: ffffaa07c2fd7920 R08: 000000000000017a R09: ffffffff8a555300
      [ 1820.832866] R10: 0000000000000000 R11: 0000000000000000 R12: ffff888d18e71c00
      [ 1820.832871] R13: ffff888d0a9b1200 R14: 0000000000000000 R15: ffffaa07c2fd7980
      [ 1820.832876] FS:  00007faa51bdb800(0000) GS:ffff888d1d400000(0000) knlGS:0000000000000000
      [ 1820.832880] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 1820.832885] CR2: 0000000000000209 CR3: 000000021e8f8001 CR4: 00000000001606e0
      [ 1820.832888] Call Trace:
      [ 1820.832898]  ? __local_bh_enable_ip+0x119/0x260
      [ 1820.832904]  ? ipv6_create_tempaddr+0x259/0x5a0
      [ 1820.832912]  ? __local_bh_enable_ip+0x139/0x260
      [ 1820.832921]  ipv6_create_tempaddr+0x2da/0x5a0
      [ 1820.832926]  ? ipv6_create_tempaddr+0x2da/0x5a0
      [ 1820.832941]  manage_tempaddrs+0x1a5/0x240
      [ 1820.832951]  inet6_addr_del+0x20b/0x3b0
      [ 1820.832959]  ? nla_parse+0xce/0x1e0
      [ 1820.832968]  inet6_rtm_deladdr+0xd9/0x210
      [ 1820.832981]  rtnetlink_rcv_msg+0x1d4/0x5f0
      
      Looking at the code I found 1 element (peer_pfx) of the newly introduced
      ifa6_config struct that is not initialized. Use a memset rather than hard
      coding an init for each struct element.
      Reported-by: NValdis Kletnieks <valdis.kletnieks@vt.edu>
      Fixes: e6464b8c ("net/ipv6: Convert ipv6_add_addr to struct ifa6_config")
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3f2d67b6
    • D
      tls: fix NULL pointer dereference on poll · f6fadff3
      Daniel Borkmann 提交于
      While hacking on kTLS, I ran into the following panic from an
      unprivileged netserver / netperf TCP session:
      
        BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
        PGD 800000037f378067 P4D 800000037f378067 PUD 3c0e61067 PMD 0
        Oops: 0010 [#1] SMP KASAN PTI
        CPU: 1 PID: 2289 Comm: netserver Not tainted 4.17.0+ #139
        Hardware name: LENOVO 20FBCTO1WW/20FBCTO1WW, BIOS N1FET47W (1.21 ) 11/28/2016
        RIP: 0010:          (null)
        Code: Bad RIP value.
        RSP: 0018:ffff88036abcf740 EFLAGS: 00010246
        RAX: dffffc0000000000 RBX: ffff88036f5f6800 RCX: 1ffff1006debed26
        RDX: ffff88036abcf920 RSI: ffff8803cb1a4f00 RDI: ffff8803c258c280
        RBP: ffff8803c258c280 R08: ffff8803c258c280 R09: ffffed006f559d48
        R10: ffff88037aacea43 R11: ffffed006f559d49 R12: ffff8803c258c280
        R13: ffff8803cb1a4f20 R14: 00000000000000db R15: ffffffffc168a350
        FS:  00007f7e631f4700(0000) GS:ffff8803d1c80000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: ffffffffffffffd6 CR3: 00000003ccf64005 CR4: 00000000003606e0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        Call Trace:
         ? tls_sw_poll+0xa4/0x160 [tls]
         ? sock_poll+0x20a/0x680
         ? do_select+0x77b/0x11a0
         ? poll_schedule_timeout.constprop.12+0x130/0x130
         ? pick_link+0xb00/0xb00
         ? read_word_at_a_time+0x13/0x20
         ? vfs_poll+0x270/0x270
         ? deref_stack_reg+0xad/0xe0
         ? __read_once_size_nocheck.constprop.6+0x10/0x10
        [...]
      
      Debugging further, it turns out that calling into ctx->sk_poll() is
      invalid since sk_poll itself is NULL which was saved from the original
      TCP socket in order for tls_sw_poll() to invoke it.
      
      Looks like the recent conversion from poll to poll_mask callback started
      in 15252423 ("net: add support for ->poll_mask in proto_ops") missed
      to eventually convert kTLS, too: TCP's ->poll was converted over to the
      ->poll_mask in commit 2c7d3dac ("net/tcp: convert to ->poll_mask")
      and therefore kTLS wrongly saved the ->poll old one which is now NULL.
      
      Convert kTLS over to use ->poll_mask instead. Also instead of POLLIN |
      POLLRDNORM use the proper EPOLLIN | EPOLLRDNORM bits as the case in
      tcp_poll_mask() as well that is mangled here.
      
      Fixes: 2c7d3dac ("net/tcp: convert to ->poll_mask")
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Dave Watson <davejwatson@fb.com>
      Tested-by: NDave Watson <davejwatson@fb.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f6fadff3
    • Z
      net: dsa: add error handling for pskb_trim_rcsum · 349b71d6
      Zhouyang Jia 提交于
      When pskb_trim_rcsum fails, the lack of error-handling code may
      cause unexpected results.
      
      This patch adds error-handling code after calling pskb_trim_rcsum.
      Signed-off-by: NZhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      349b71d6
    • J
      ipv6: allow PMTU exceptions to local routes · 09757646
      Julian Anastasov 提交于
      IPVS setups with local client and remote tunnel server need
      to create exception for the local virtual IP. What we do is to
      change PMTU from 64KB (on "lo") to 1460 in the common case.
      Suggested-by: NMartin KaFai Lau <kafai@fb.com>
      Fixes: 45e4fd26 ("ipv6: Only create RTF_CACHE routes after encountering pmtu exception")
      Fixes: 7343ff31 ("ipv6: Don't create clones of host routes.")
      Signed-off-by: NJulian Anastasov <ja@ssi.bg>
      Acked-by: NDavid Ahern <dsahern@gmail.com>
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      09757646
  2. 11 6月, 2018 2 次提交
  3. 09 6月, 2018 3 次提交
  4. 08 6月, 2018 10 次提交
    • F
      netfilter: x_tables: initialise match/target check parameter struct · c568503e
      Florian Westphal 提交于
      syzbot reports following splat:
      
      BUG: KMSAN: uninit-value in ebt_stp_mt_check+0x24b/0x450
       net/bridge/netfilter/ebt_stp.c:162
       ebt_stp_mt_check+0x24b/0x450 net/bridge/netfilter/ebt_stp.c:162
       xt_check_match+0x1438/0x1650 net/netfilter/x_tables.c:506
       ebt_check_match net/bridge/netfilter/ebtables.c:372 [inline]
       ebt_check_entry net/bridge/netfilter/ebtables.c:702 [inline]
      
      The uninitialised access is
         xt_mtchk_param->nft_compat
      
      ... which should be set to 0.
      Fix it by zeroing the struct beforehand, same for tgchk.
      
      ip(6)tables targetinfo uses c99-style initialiser, so no change
      needed there.
      
      Reported-by: syzbot+da4494182233c23a5fcf@syzkaller.appspotmail.com
      Fixes: 55917a21 ("netfilter: x_tables: add context to know if extension runs from nft_compat")
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      c568503e
    • S
      net/9p/trans_xen.c: don't inclide rwlock.h directly · e56ee574
      Sebastian Andrzej Siewior 提交于
      rwlock.h should not be included directly.  Instead linux/splinlock.h
      should be included.  One thing it does is to break the RT build.
      
      Link: http://lkml.kernel.org/r/20180504100319.11880-1-bigeasy@linutronix.deSigned-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Reviewed-by: NAndrew Morton <akpm@linux-foundation.org>
      Cc: Eric Van Hensbergen <ericvh@gmail.com>
      Cc: Ron Minnich <rminnich@sandia.gov>
      Cc: Latchesar Ionkov <lucho@ionkov.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e56ee574
    • C
      net/9p: detect invalid options as much as possible · 8d856c72
      Chengguang Xu 提交于
      Currently when detecting invalid options in option parsing, some
      options(e.g.  msize) just set errno and allow to continuously validate
      other options so that it can detect invalid options as much as possible
      and give proper error messages together.
      
      This patch applies same rule to option 'trans' and 'version' when
      detecting -EINVAL.
      
      Link: http://lkml.kernel.org/r/1525340676-34072-1-git-send-email-cgxu519@gmx.comSigned-off-by: NChengguang Xu <cgxu519@gmx.com>
      Reviewed-by: NAndrew Morton <akpm@linux-foundation.org>
      Cc: Eric Van Hensbergen <ericvh@gmail.com>
      Cc: Ron Minnich <rminnich@sandia.gov>
      Cc: Latchesar Ionkov <lucho@ionkov.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8d856c72
    • A
      bpfilter: fix race in pipe access · 66e58e0e
      Alexei Starovoitov 提交于
      syzbot reported the following crash
      [  338.293946] bpfilter: read fail -512
      [  338.304515] kasan: GPF could be caused by NULL-ptr deref or user memory access
      [  338.311863] general protection fault: 0000 [#1] SMP KASAN
      [  338.344360] RIP: 0010:__vfs_write+0x4a6/0x960
      [  338.426363] Call Trace:
      [  338.456967]  __kernel_write+0x10c/0x380
      [  338.460928]  __bpfilter_process_sockopt+0x1d8/0x35b
      [  338.487103]  bpfilter_mbox_request+0x4d/0xb0
      [  338.491492]  bpfilter_ip_get_sockopt+0x6b/0x90
      
      This can happen when multiple cpus trying to talk to user mode process
      via bpfilter_mbox_request(). One cpu grabs the mutex while another goes to
      sleep on the same mutex. Then former cpu sees that umh pipe is down and
      shuts down the pipes. Later cpu finally acquires the mutex and crashes
      on freed pipe.
      Fix the race by using info.pid as an indicator that umh and pipes are healthy
      and check it after acquiring the mutex.
      
      Fixes: d2ba09c1 ("net: add skeleton of bpfilter kernel module")
      Reported-by: syzbot+7ade6c94abb2774c0fee@syzkaller.appspotmail.com
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      66e58e0e
    • D
      bpf, xdp: fix crash in xdp_umem_unaccount_pages · c09290c5
      Daniel Borkmann 提交于
      syzkaller was able to trigger the following panic for AF_XDP:
      
        BUG: KASAN: null-ptr-deref in atomic64_sub include/asm-generic/atomic-instrumented.h:144 [inline]
        BUG: KASAN: null-ptr-deref in atomic_long_sub include/asm-generic/atomic-long.h:199 [inline]
        BUG: KASAN: null-ptr-deref in xdp_umem_unaccount_pages.isra.4+0x3d/0x80 net/xdp/xdp_umem.c:135
        Write of size 8 at addr 0000000000000060 by task syz-executor246/4527
      
        CPU: 1 PID: 4527 Comm: syz-executor246 Not tainted 4.17.0+ #89
        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_write+0x14/0x20 mm/kasan/kasan.c:278
         atomic64_sub include/asm-generic/atomic-instrumented.h:144 [inline]
         atomic_long_sub include/asm-generic/atomic-long.h:199 [inline]
         xdp_umem_unaccount_pages.isra.4+0x3d/0x80 net/xdp/xdp_umem.c:135
         xdp_umem_reg net/xdp/xdp_umem.c:334 [inline]
         xdp_umem_create+0xd6c/0x10f0 net/xdp/xdp_umem.c:349
         xsk_setsockopt+0x443/0x550 net/xdp/xsk.c:531
         __sys_setsockopt+0x1bd/0x390 net/socket.c:1935
         __do_sys_setsockopt net/socket.c:1946 [inline]
         __se_sys_setsockopt net/socket.c:1943 [inline]
         __x64_sys_setsockopt+0xbe/0x150 net/socket.c:1943
         do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
         entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      In xdp_umem_reg() the call to xdp_umem_account_pages() passed
      with CAP_IPC_LOCK where we didn't need to end up charging rlimit
      on memlock for the current user and therefore umem->user continues
      to be NULL. Later on through fault injection syzkaller triggered
      a failure in either umem->pgs or umem->pages allocation such that
      we bail out and undo accounting in xdp_umem_unaccount_pages()
      where we eventually hit the panic since it tries to deref the
      umem->user.
      
      The code is pretty close to mm_account_pinned_pages() and
      mm_unaccount_pinned_pages() pair and potentially could reuse
      it even in a later cleanup, and it appears that the initial
      commit c0c77d8f ("xsk: add user memory registration support
      sockopt") got this right while later follow-up introduced the
      bug via a49049ea ("xsk: simplified umem setup").
      
      Fixes: a49049ea ("xsk: simplified umem setup")
      Reported-by: syzbot+979217770b09ebf5c407@syzkaller.appspotmail.com
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      c09290c5
    • G
      xsk: Fix umem fill/completion queue mmap on 32-bit · a5a16e43
      Geert Uytterhoeven 提交于
      With gcc-4.1.2 on 32-bit:
      
          net/xdp/xsk.c:663: warning: integer constant is too large for ‘long’ type
          net/xdp/xsk.c:665: warning: integer constant is too large for ‘long’ type
      
      Add the missing "ULL" suffixes to the large XDP_UMEM_PGOFF_*_RING values
      to fix this.
      
          net/xdp/xsk.c:663: warning: comparison is always false due to limited range of data type
          net/xdp/xsk.c:665: warning: comparison is always false due to limited range of data type
      
      "unsigned long" is 32-bit on 32-bit systems, hence the offset is
      truncated, and can never be equal to any of the XDP_UMEM_PGOFF_*_RING
      values.  Use loff_t (and the required cast) to fix this.
      
      Fixes: 423f3832 ("xsk: add umem fill queue support and mmap")
      Fixes: fe230832 ("xsk: add umem completion queue support and mmap")
      Signed-off-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Acked-by: NBjörn Töpel <bjorn.topel@intel.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      a5a16e43
    • A
      bpfilter: fix OUTPUT_FORMAT · 8d97ca6b
      Alexei Starovoitov 提交于
      CONFIG_OUTPUT_FORMAT is x86 only macro.
      Used objdump to extract elf file format.
      
      Fixes: d2ba09c1 ("net: add skeleton of bpfilter kernel module")
      Reported-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8d97ca6b
    • S
      ip_tunnel: Fix name string concatenate in __ip_tunnel_create() · 000ade80
      Sultan Alsawaf 提交于
      By passing a limit of 2 bytes to strncat, strncat is limited to writing
      fewer bytes than what it's supposed to append to the name here.
      
      Since the bounds are checked on the line above this, just remove the string
      bounds checks entirely since they're unneeded.
      Signed-off-by: NSultan Alsawaf <sultanxda@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      000ade80
    • W
      net: in virtio_net_hdr only add VLAN_HLEN to csum_start if payload holds vlan · fd3a8862
      Willem de Bruijn 提交于
      Tun, tap, virtio, packet and uml vector all use struct virtio_net_hdr
      to communicate packet metadata to userspace.
      
      For skbuffs with vlan, the first two return the packet as it may have
      existed on the wire, inserting the VLAN tag in the user buffer.  Then
      virtio_net_hdr.csum_start needs to be adjusted by VLAN_HLEN bytes.
      
      Commit f09e2249 ("macvtap: restore vlan header on user read")
      added this feature to macvtap. Commit 3ce9b20f ("macvtap: Fix
      csum_start when VLAN tags are present") then fixed up csum_start.
      
      Virtio, packet and uml do not insert the vlan header in the user
      buffer.
      
      When introducing virtio_net_hdr_from_skb to deduplicate filling in
      the virtio_net_hdr, the variant from macvtap which adds VLAN_HLEN was
      applied uniformly, breaking csum offset for packets with vlan on
      virtio and packet.
      
      Make insertion of VLAN_HLEN optional. Convert the callers to pass it
      when needed.
      
      Fixes: e858fae2 ("virtio_net: use common code for virtio_net_hdr and skb GSO conversion")
      Fixes: 1276f24e ("packet: use common code for virtio_net_hdr and skb GSO conversion")
      Signed-off-by: NWillem de Bruijn <willemb@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fd3a8862
    • P
      netfilter: nf_tables: add NFT_LOGLEVEL_* enumeration and use it · 7eced5ab
      Pablo Neira Ayuso 提交于
      This is internal, not exposed through uapi, and although it maps with
      userspace LOG_*, with the introduction of LOGLEVEL_AUDIT we are
      incurring in namespace pollution.
      
      This patch adds the NFT_LOGLEVEL_ enumeration and use it from nft_log.
      
      Fixes: 1a893b44 ("netfilter: nf_tables: Add audit support to log statement")
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Acked-by: NPhil Sutter <phil@nwl.cc>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7eced5ab
  5. 07 6月, 2018 5 次提交
    • K
      treewide: Use struct_size() for kmalloc()-family · acafe7e3
      Kees Cook 提交于
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          void *entry[];
      };
      
      instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);
      
      This patch makes the changes for kmalloc()-family (and kvmalloc()-family)
      uses. It was done via automatic conversion with manual review for the
      "CHECKME" non-standard cases noted below, using the following Coccinelle
      script:
      
      // pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
      //                      sizeof *pkey_cache->table, GFP_KERNEL);
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      identifier VAR, ELEMENT;
      expression COUNT;
      @@
      
      - alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
      + alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
      
      // mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      identifier VAR, ELEMENT;
      expression COUNT;
      @@
      
      - alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
      + alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
      
      // Same pattern, but can't trivially locate the trailing element name,
      // or variable name.
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      expression SOMETHING, COUNT, ELEMENT;
      @@
      
      - alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
      + alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)
      Signed-off-by: NKees Cook <keescook@chromium.org>
      acafe7e3
    • D
      strparser: Add __strp_unpause and use it in ktls. · 7170e604
      Doron Roberts-Kedes 提交于
      strp_unpause queues strp_work in order to parse any messages that
      arrived while the strparser was paused. However, the process invoking
      strp_unpause could eagerly parse a buffered message itself if it held
      the sock lock.
      
      __strp_unpause is an alternative to strp_pause that avoids the scheduling
      overhead that results when a receiving thread unpauses the strparser
      and waits for the next message to be delivered by the workqueue thread.
      
      This patch more than doubled the IOPS achieved in a benchmark of NBD
      traffic encrypted using ktls.
      Signed-off-by: NDoron Roberts-Kedes <doronrk@fb.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7170e604
    • D
      rxrpc: Fix terminal retransmission connection ID to include the channel · fb1967a6
      David Howells 提交于
      When retransmitting the final ACK or ABORT packet for a call, the cid field
      in the packet header is set to the connection's cid, but this is incorrect
      as it also needs to include the channel number on that connection that the
      call was made on.
      
      Fix this by OR'ing in the channel number.
      
      Note that this fixes the bug that:
      
      	commit 1a025028
      	rxrpc: Fix handling of call quietly cancelled out on server
      
      works around.  I'm not intending to revert that as it will help protect
      against problems that might occur on the server.
      
      Fixes: 3136ef49 ("rxrpc: Delay terminal ACK transmission on a client call")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fb1967a6
    • D
      Revert "net: sched: cls: Fix offloading when ingress dev is vxlan" · 9a99dc1c
      David S. Miller 提交于
      This reverts commit d96a43c6.
      
      This potentially breaks things, so reverting as per
      request by Jakub Kicinski.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9a99dc1c
    • T
      netfilter: nft_set_rbtree: fix parameter of __nft_rbtree_lookup() · 82e20b44
      Taehee Yoo 提交于
      The parameter this doesn't have a flags value. so that it can't be
      used by nft_rbtree_interval_end().
      
      test commands:
         %nft add table ip filter
         %nft add set ip filter s { type ipv4_addr \; flags interval \; }
         %nft add element ip filter s {0-1}
         %nft add element ip filter s {2-10}
         %nft add chain ip filter input { type filter hook input priority 0\; }
         %nft add rule ip filter input ip saddr @s
      
      Splat looks like:
      [  246.752502] BUG: KASAN: slab-out-of-bounds in __nft_rbtree_lookup+0x677/0x6a0 [nft_set_rbtree]
      [  246.752502] Read of size 1 at addr ffff88010d9efa47 by task http/1092
      
      [  246.752502] CPU: 1 PID: 1092 Comm: http Not tainted 4.17.0-rc6+ #185
      [  246.752502] Call Trace:
      [  246.752502]  <IRQ>
      [  246.752502]  dump_stack+0x74/0xbb
      [  246.752502]  ? __nft_rbtree_lookup+0x677/0x6a0 [nft_set_rbtree]
      [  246.752502]  print_address_description+0xc7/0x290
      [  246.752502]  ? __nft_rbtree_lookup+0x677/0x6a0 [nft_set_rbtree]
      [  246.752502]  kasan_report+0x22c/0x350
      [  246.752502]  __nft_rbtree_lookup+0x677/0x6a0 [nft_set_rbtree]
      [  246.752502]  nft_rbtree_lookup+0xc9/0x2d2 [nft_set_rbtree]
      [  246.752502]  ? sched_clock_cpu+0x144/0x180
      [  246.752502]  nft_lookup_eval+0x149/0x3a0 [nf_tables]
      [  246.752502]  ? __lock_acquire+0xcea/0x4ed0
      [  246.752502]  ? nft_lookup_init+0x6b0/0x6b0 [nf_tables]
      [  246.752502]  nft_do_chain+0x263/0xf50 [nf_tables]
      [  246.752502]  ? __nft_trace_packet+0x1a0/0x1a0 [nf_tables]
      [  246.752502]  ? sched_clock_cpu+0x144/0x180
      [ ... ]
      
      Fixes: f9121355 ("netfilter: nft_set_rbtree: incorrect assumption on lower interval lookups")
      Signed-off-by: NTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      82e20b44
  6. 06 6月, 2018 9 次提交
    • F
      netfilter: ebtables: reject non-bridge targets · 11ff7288
      Florian Westphal 提交于
      the ebtables evaluation loop expects targets to return
      positive values (jumps), or negative values (absolute verdicts).
      
      This is completely different from what xtables does.
      In xtables, targets are expected to return the standard netfilter
      verdicts, i.e. NF_DROP, NF_ACCEPT, etc.
      
      ebtables will consider these as jumps.
      
      Therefore reject any target found due to unspec fallback.
      v2: also reject watchers.  ebtables ignores their return value, so
      a target that assumes skb ownership (and returns NF_STOLEN) causes
      use-after-free.
      
      The only watchers in the 'ebtables' front-end are log and nflog;
      both have AF_BRIDGE specific wrappers on kernel side.
      
      Reported-by: syzbot+2b43f681169a2a0d306a@syzkaller.appspotmail.com
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      11ff7288
    • F
      netfilter: ipset: forbid family for hash:mac sets · cbdebe48
      Florent Fourcot 提交于
      Userspace `ipset` command forbids family option for hash:mac type:
      
      ipset create test hash:mac family inet4
      ipset v6.30: Unknown argument: `family'
      
      However, this check is not done in kernel itself. When someone use
      external netlink applications (pyroute2 python library for example), one
      can create hash:mac with invalid family and inconsistant results from
      userspace (`ipset` command cannot read set content anymore).
      
      This patch enforce the logic in kernel, and forbids insertion of
      hash:mac with a family set.
      
      Since IP_SET_PROTO_UNDEF is defined only for hash:mac, this patch has no
      impact on other hash:* sets
      Signed-off-by: NFlorent Fourcot <florent.fourcot@wifirst.fr>
      Signed-off-by: NVictorien Molle <victorien.molle@wifirst.fr>
      Signed-off-by: NJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
      cbdebe48
    • J
      netfilter: ipset: Limit max timeout value · 30a2e107
      Jozsef Kadlecsik 提交于
      Due to the negative value condition in msecs_to_jiffies(), the real
      max possible timeout value must be set to (UINT_MAX >> 1)/MSEC_PER_SEC.
      
      Neutron Soutmun proposed the proper fix, but an insufficient one was
      applied, see https://patchwork.ozlabs.org/patch/400405/.
      Signed-off-by: NJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
      30a2e107
    • S
      netfilter: xt_set: Check hook mask correctly · 9dcceb13
      Serhey Popovych 提交于
      Inserting rule before one with SET target we get error with warning in
      dmesg(1) output:
      
        # iptables -A FORWARD -t mangle -j SET --map-set test src --map-prio
        # iptables -I FORWARD 1 -t mangle -j ACCEPT
        iptables: Invalid argument. Run `dmesg' for more information.
        # dmesg |tail -n1
        [268578.026643] mapping of prio or/and queue is allowed only from \
        OUTPUT/FORWARD/POSTROUTING chains
      
      Rather than checking for supported hook bits for SET target check for
      unsupported one as done in all rest of matches and targets.
      Signed-off-by: NSerhey Popovych <serhe.popovych@gmail.com>
      Signed-off-by: NJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
      9dcceb13
    • E
      rtnetlink: validate attributes in do_setlink() · 644c7eeb
      Eric Dumazet 提交于
      It seems that rtnl_group_changelink() can call do_setlink
      while a prior call to validate_linkmsg(dev = NULL, ...) could
      not validate IFLA_ADDRESS / IFLA_BROADCAST
      
      Make sure do_setlink() calls validate_linkmsg() instead
      of letting its callers having this responsibility.
      
      With help from Dmitry Vyukov, thanks a lot !
      
      BUG: KMSAN: uninit-value in is_valid_ether_addr include/linux/etherdevice.h:199 [inline]
      BUG: KMSAN: uninit-value in eth_prepare_mac_addr_change net/ethernet/eth.c:275 [inline]
      BUG: KMSAN: uninit-value in eth_mac_addr+0x203/0x2b0 net/ethernet/eth.c:308
      CPU: 1 PID: 8695 Comm: syz-executor3 Not tainted 4.17.0-rc5+ #103
      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+0x185/0x1d0 lib/dump_stack.c:113
       kmsan_report+0x149/0x260 mm/kmsan/kmsan.c:1084
       __msan_warning_32+0x6e/0xc0 mm/kmsan/kmsan_instr.c:686
       is_valid_ether_addr include/linux/etherdevice.h:199 [inline]
       eth_prepare_mac_addr_change net/ethernet/eth.c:275 [inline]
       eth_mac_addr+0x203/0x2b0 net/ethernet/eth.c:308
       dev_set_mac_address+0x261/0x530 net/core/dev.c:7157
       do_setlink+0xbc3/0x5fc0 net/core/rtnetlink.c:2317
       rtnl_group_changelink net/core/rtnetlink.c:2824 [inline]
       rtnl_newlink+0x1fe9/0x37a0 net/core/rtnetlink.c:2976
       rtnetlink_rcv_msg+0xa32/0x1560 net/core/rtnetlink.c:4646
       netlink_rcv_skb+0x378/0x600 net/netlink/af_netlink.c:2448
       rtnetlink_rcv+0x50/0x60 net/core/rtnetlink.c:4664
       netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
       netlink_unicast+0x1678/0x1750 net/netlink/af_netlink.c:1336
       netlink_sendmsg+0x104f/0x1350 net/netlink/af_netlink.c:1901
       sock_sendmsg_nosec net/socket.c:629 [inline]
       sock_sendmsg net/socket.c:639 [inline]
       ___sys_sendmsg+0xec0/0x1310 net/socket.c:2117
       __sys_sendmsg net/socket.c:2155 [inline]
       __do_sys_sendmsg net/socket.c:2164 [inline]
       __se_sys_sendmsg net/socket.c:2162 [inline]
       __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
       do_syscall_64+0x152/0x230 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      RIP: 0033:0x455a09
      RSP: 002b:00007fc07480ec68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 00007fc07480f6d4 RCX: 0000000000455a09
      RDX: 0000000000000000 RSI: 00000000200003c0 RDI: 0000000000000014
      RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
      R13: 00000000000005d0 R14: 00000000006fdc20 R15: 0000000000000000
      
      Uninit was stored to memory at:
       kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279 [inline]
       kmsan_save_stack mm/kmsan/kmsan.c:294 [inline]
       kmsan_internal_chain_origin+0x12b/0x210 mm/kmsan/kmsan.c:685
       kmsan_memcpy_origins+0x11d/0x170 mm/kmsan/kmsan.c:527
       __msan_memcpy+0x109/0x160 mm/kmsan/kmsan_instr.c:478
       do_setlink+0xb84/0x5fc0 net/core/rtnetlink.c:2315
       rtnl_group_changelink net/core/rtnetlink.c:2824 [inline]
       rtnl_newlink+0x1fe9/0x37a0 net/core/rtnetlink.c:2976
       rtnetlink_rcv_msg+0xa32/0x1560 net/core/rtnetlink.c:4646
       netlink_rcv_skb+0x378/0x600 net/netlink/af_netlink.c:2448
       rtnetlink_rcv+0x50/0x60 net/core/rtnetlink.c:4664
       netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
       netlink_unicast+0x1678/0x1750 net/netlink/af_netlink.c:1336
       netlink_sendmsg+0x104f/0x1350 net/netlink/af_netlink.c:1901
       sock_sendmsg_nosec net/socket.c:629 [inline]
       sock_sendmsg net/socket.c:639 [inline]
       ___sys_sendmsg+0xec0/0x1310 net/socket.c:2117
       __sys_sendmsg net/socket.c:2155 [inline]
       __do_sys_sendmsg net/socket.c:2164 [inline]
       __se_sys_sendmsg net/socket.c:2162 [inline]
       __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
       do_syscall_64+0x152/0x230 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      Uninit was created at:
       kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279 [inline]
       kmsan_internal_poison_shadow+0xb8/0x1b0 mm/kmsan/kmsan.c:189
       kmsan_kmalloc+0x94/0x100 mm/kmsan/kmsan.c:315
       kmsan_slab_alloc+0x10/0x20 mm/kmsan/kmsan.c:322
       slab_post_alloc_hook mm/slab.h:446 [inline]
       slab_alloc_node mm/slub.c:2753 [inline]
       __kmalloc_node_track_caller+0xb32/0x11b0 mm/slub.c:4395
       __kmalloc_reserve net/core/skbuff.c:138 [inline]
       __alloc_skb+0x2cb/0x9e0 net/core/skbuff.c:206
       alloc_skb include/linux/skbuff.h:988 [inline]
       netlink_alloc_large_skb net/netlink/af_netlink.c:1182 [inline]
       netlink_sendmsg+0x76e/0x1350 net/netlink/af_netlink.c:1876
       sock_sendmsg_nosec net/socket.c:629 [inline]
       sock_sendmsg net/socket.c:639 [inline]
       ___sys_sendmsg+0xec0/0x1310 net/socket.c:2117
       __sys_sendmsg net/socket.c:2155 [inline]
       __do_sys_sendmsg net/socket.c:2164 [inline]
       __se_sys_sendmsg net/socket.c:2162 [inline]
       __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
       do_syscall_64+0x152/0x230 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Fixes: e7ed828f ("netlink: support setting devgroup parameters")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      644c7eeb
    • D
      devlink: Add extack to reload and port_{un, }split operations · ac0fc8a1
      David Ahern 提交于
      Add extack argument to reload, port_split and port_unsplit operations.
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Acked-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ac0fc8a1
    • E
      net: metrics: add proper netlink validation · 5b5e7a0d
      Eric Dumazet 提交于
      Before using nla_get_u32(), better make sure the attribute
      is of the proper size.
      
      Code recently was changed, but bug has been there from beginning
      of git.
      
      BUG: KMSAN: uninit-value in rtnetlink_put_metrics+0x553/0x960 net/core/rtnetlink.c:746
      CPU: 1 PID: 14139 Comm: syz-executor6 Not tainted 4.17.0-rc5+ #103
      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+0x185/0x1d0 lib/dump_stack.c:113
       kmsan_report+0x149/0x260 mm/kmsan/kmsan.c:1084
       __msan_warning_32+0x6e/0xc0 mm/kmsan/kmsan_instr.c:686
       rtnetlink_put_metrics+0x553/0x960 net/core/rtnetlink.c:746
       fib_dump_info+0xc42/0x2190 net/ipv4/fib_semantics.c:1361
       rtmsg_fib+0x65f/0x8c0 net/ipv4/fib_semantics.c:419
       fib_table_insert+0x2314/0x2b50 net/ipv4/fib_trie.c:1287
       inet_rtm_newroute+0x210/0x340 net/ipv4/fib_frontend.c:779
       rtnetlink_rcv_msg+0xa32/0x1560 net/core/rtnetlink.c:4646
       netlink_rcv_skb+0x378/0x600 net/netlink/af_netlink.c:2448
       rtnetlink_rcv+0x50/0x60 net/core/rtnetlink.c:4664
       netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
       netlink_unicast+0x1678/0x1750 net/netlink/af_netlink.c:1336
       netlink_sendmsg+0x104f/0x1350 net/netlink/af_netlink.c:1901
       sock_sendmsg_nosec net/socket.c:629 [inline]
       sock_sendmsg net/socket.c:639 [inline]
       ___sys_sendmsg+0xec0/0x1310 net/socket.c:2117
       __sys_sendmsg net/socket.c:2155 [inline]
       __do_sys_sendmsg net/socket.c:2164 [inline]
       __se_sys_sendmsg net/socket.c:2162 [inline]
       __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
       do_syscall_64+0x152/0x230 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      RIP: 0033:0x455a09
      RSP: 002b:00007faae5fd8c68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 00007faae5fd96d4 RCX: 0000000000455a09
      RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000013
      RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
      R13: 00000000000005d0 R14: 00000000006fdc20 R15: 0000000000000000
      
      Uninit was stored to memory at:
       kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279 [inline]
       kmsan_save_stack mm/kmsan/kmsan.c:294 [inline]
       kmsan_internal_chain_origin+0x12b/0x210 mm/kmsan/kmsan.c:685
       __msan_chain_origin+0x69/0xc0 mm/kmsan/kmsan_instr.c:529
       fib_convert_metrics net/ipv4/fib_semantics.c:1056 [inline]
       fib_create_info+0x2d46/0x9dc0 net/ipv4/fib_semantics.c:1150
       fib_table_insert+0x3e4/0x2b50 net/ipv4/fib_trie.c:1146
       inet_rtm_newroute+0x210/0x340 net/ipv4/fib_frontend.c:779
       rtnetlink_rcv_msg+0xa32/0x1560 net/core/rtnetlink.c:4646
       netlink_rcv_skb+0x378/0x600 net/netlink/af_netlink.c:2448
       rtnetlink_rcv+0x50/0x60 net/core/rtnetlink.c:4664
       netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
       netlink_unicast+0x1678/0x1750 net/netlink/af_netlink.c:1336
       netlink_sendmsg+0x104f/0x1350 net/netlink/af_netlink.c:1901
       sock_sendmsg_nosec net/socket.c:629 [inline]
       sock_sendmsg net/socket.c:639 [inline]
       ___sys_sendmsg+0xec0/0x1310 net/socket.c:2117
       __sys_sendmsg net/socket.c:2155 [inline]
       __do_sys_sendmsg net/socket.c:2164 [inline]
       __se_sys_sendmsg net/socket.c:2162 [inline]
       __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
       do_syscall_64+0x152/0x230 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      Uninit was created at:
       kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279 [inline]
       kmsan_internal_poison_shadow+0xb8/0x1b0 mm/kmsan/kmsan.c:189
       kmsan_kmalloc+0x94/0x100 mm/kmsan/kmsan.c:315
       kmsan_slab_alloc+0x10/0x20 mm/kmsan/kmsan.c:322
       slab_post_alloc_hook mm/slab.h:446 [inline]
       slab_alloc_node mm/slub.c:2753 [inline]
       __kmalloc_node_track_caller+0xb32/0x11b0 mm/slub.c:4395
       __kmalloc_reserve net/core/skbuff.c:138 [inline]
       __alloc_skb+0x2cb/0x9e0 net/core/skbuff.c:206
       alloc_skb include/linux/skbuff.h:988 [inline]
       netlink_alloc_large_skb net/netlink/af_netlink.c:1182 [inline]
       netlink_sendmsg+0x76e/0x1350 net/netlink/af_netlink.c:1876
       sock_sendmsg_nosec net/socket.c:629 [inline]
       sock_sendmsg net/socket.c:639 [inline]
       ___sys_sendmsg+0xec0/0x1310 net/socket.c:2117
       __sys_sendmsg net/socket.c:2155 [inline]
       __do_sys_sendmsg net/socket.c:2164 [inline]
       __se_sys_sendmsg net/socket.c:2162 [inline]
       __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
       do_syscall_64+0x152/0x230 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Fixes: a919525a ("net: Move fib_convert_metrics to metrics file")
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Cc: David Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5b5e7a0d
    • S
      ipmr: fix error path when ipmr_new_table fails · e783bb00
      Sabrina Dubroca 提交于
      commit 0bbbf0e7 ("ipmr, ip6mr: Unite creation of new mr_table")
      refactored ipmr_new_table, so that it now returns NULL when
      mr_table_alloc fails. Unfortunately, all callers of ipmr_new_table
      expect an ERR_PTR.
      
      This can result in NULL deref, for example when ipmr_rules_exit calls
      ipmr_free_table with NULL net->ipv4.mrt in the
      !CONFIG_IP_MROUTE_MULTIPLE_TABLES version.
      
      This patch makes mr_table_alloc return errors, and changes
      ip6mr_new_table and its callers to return/expect error pointers as
      well. It also removes the version of mr_table_alloc defined under
      !CONFIG_IP_MROUTE_COMMON, since it is never used.
      
      Fixes: 0bbbf0e7 ("ipmr, ip6mr: Unite creation of new mr_table")
      Signed-off-by: NSabrina Dubroca <sd@queasysnail.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e783bb00
    • S
      ip6mr: only set ip6mr_table from setsockopt when ip6mr_new_table succeeds · 848235ed
      Sabrina Dubroca 提交于
      Currently, raw6_sk(sk)->ip6mr_table is set unconditionally during
      ip6_mroute_setsockopt(MRT6_TABLE). A subsequent attempt at the same
      setsockopt will fail with -ENOENT, since we haven't actually created
      that table.
      
      A similar fix for ipv4 was included in commit 5e1859fb ("ipv4: ipmr:
      various fixes and cleanups").
      
      Fixes: d1db275d ("ipv6: ip6mr: support multiple tables")
      Signed-off-by: NSabrina Dubroca <sd@queasysnail.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      848235ed
  7. 05 6月, 2018 7 次提交