1. 30 3月, 2018 1 次提交
  2. 28 3月, 2018 1 次提交
  3. 27 3月, 2018 1 次提交
  4. 23 3月, 2018 1 次提交
    • S
      xfrm: Fix transport mode skb control buffer usage. · 9a3fb9fb
      Steffen Klassert 提交于
      A recent commit introduced a new struct xfrm_trans_cb
      that is used with the sk_buff control buffer. Unfortunately
      it placed the structure in front of the control buffer and
      overlooked that the IPv4/IPv6 control buffer is still needed
      for some layer 4 protocols. As a result the IPv4/IPv6 control
      buffer is overwritten with this structure. Fix this by setting
      a apropriate header in front of the structure.
      
      Fixes acf568ee ("xfrm: Reinject transport-mode packets ...")
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      9a3fb9fb
  5. 16 3月, 2018 1 次提交
  6. 13 3月, 2018 1 次提交
    • G
      net: xfrm: use preempt-safe this_cpu_read() in ipcomp_alloc_tfms() · 0dcd7876
      Greg Hackmann 提交于
      f7c83bcb ("net: xfrm: use __this_cpu_read per-cpu helper") added a
      __this_cpu_read() call inside ipcomp_alloc_tfms().
      
      At the time, __this_cpu_read() required the caller to either not care
      about races or to handle preemption/interrupt issues.  3.15 tightened
      the rules around some per-cpu operations, and now __this_cpu_read()
      should never be used in a preemptible context.  On 3.15 and later, we
      need to use this_cpu_read() instead.
      
      syzkaller reported this leading to the following kernel BUG while
      fuzzing sendmsg:
      
      BUG: using __this_cpu_read() in preemptible [00000000] code: repro/3101
      caller is ipcomp_init_state+0x185/0x990
      CPU: 3 PID: 3101 Comm: repro Not tainted 4.16.0-rc4-00123-g86f84779 #154
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
      Call Trace:
       dump_stack+0xb9/0x115
       check_preemption_disabled+0x1cb/0x1f0
       ipcomp_init_state+0x185/0x990
       ? __xfrm_init_state+0x876/0xc20
       ? lock_downgrade+0x5e0/0x5e0
       ipcomp4_init_state+0xaa/0x7c0
       __xfrm_init_state+0x3eb/0xc20
       xfrm_init_state+0x19/0x60
       pfkey_add+0x20df/0x36f0
       ? pfkey_broadcast+0x3dd/0x600
       ? pfkey_sock_destruct+0x340/0x340
       ? pfkey_seq_stop+0x80/0x80
       ? __skb_clone+0x236/0x750
       ? kmem_cache_alloc+0x1f6/0x260
       ? pfkey_sock_destruct+0x340/0x340
       ? pfkey_process+0x62a/0x6f0
       pfkey_process+0x62a/0x6f0
       ? pfkey_send_new_mapping+0x11c0/0x11c0
       ? mutex_lock_io_nested+0x1390/0x1390
       pfkey_sendmsg+0x383/0x750
       ? dump_sp+0x430/0x430
       sock_sendmsg+0xc0/0x100
       ___sys_sendmsg+0x6c8/0x8b0
       ? copy_msghdr_from_user+0x3b0/0x3b0
       ? pagevec_lru_move_fn+0x144/0x1f0
       ? find_held_lock+0x32/0x1c0
       ? do_huge_pmd_anonymous_page+0xc43/0x11e0
       ? lock_downgrade+0x5e0/0x5e0
       ? get_kernel_page+0xb0/0xb0
       ? _raw_spin_unlock+0x29/0x40
       ? do_huge_pmd_anonymous_page+0x400/0x11e0
       ? __handle_mm_fault+0x553/0x2460
       ? __fget_light+0x163/0x1f0
       ? __sys_sendmsg+0xc7/0x170
       __sys_sendmsg+0xc7/0x170
       ? SyS_shutdown+0x1a0/0x1a0
       ? __do_page_fault+0x5a0/0xca0
       ? lock_downgrade+0x5e0/0x5e0
       SyS_sendmsg+0x27/0x40
       ? __sys_sendmsg+0x170/0x170
       do_syscall_64+0x19f/0x640
       entry_SYSCALL_64_after_hwframe+0x42/0xb7
      RIP: 0033:0x7f0ee73dfb79
      RSP: 002b:00007ffe14fc15a8 EFLAGS: 00000207 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f0ee73dfb79
      RDX: 0000000000000000 RSI: 00000000208befc8 RDI: 0000000000000004
      RBP: 00007ffe14fc15b0 R08: 00007ffe14fc15c0 R09: 00007ffe14fc15c0
      R10: 0000000000000000 R11: 0000000000000207 R12: 0000000000400440
      R13: 00007ffe14fc16b0 R14: 0000000000000000 R15: 0000000000000000
      Signed-off-by: NGreg Hackmann <ghackmann@google.com>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      0dcd7876
  7. 09 3月, 2018 1 次提交
  8. 07 3月, 2018 1 次提交
  9. 05 3月, 2018 1 次提交
  10. 01 3月, 2018 1 次提交
  11. 27 2月, 2018 1 次提交
  12. 20 2月, 2018 1 次提交
  13. 19 2月, 2018 1 次提交
  14. 13 2月, 2018 3 次提交
    • K
      net: Convert pernet_subsys, registered from inet_init() · f84c6821
      Kirill Tkhai 提交于
      arp_net_ops just addr/removes /proc entry.
      
      devinet_ops allocates and frees duplicate of init_net tables
      and (un)registers sysctl entries.
      
      fib_net_ops allocates and frees pernet tables, creates/destroys
      netlink socket and (un)initializes /proc entries. Foreign
      pernet_operations do not touch them.
      
      ip_rt_proc_ops only modifies pernet /proc entries.
      
      xfrm_net_ops creates/destroys /proc entries, allocates/frees
      pernet statistics, hashes and tables, and (un)initializes
      sysctl files. These are not touched by foreigh pernet_operations
      
      xfrm4_net_ops allocates/frees private pernet memory, and
      configures sysctls.
      
      sysctl_route_ops creates/destroys sysctls.
      
      rt_genid_ops only initializes fields of just allocated net.
      
      ipv4_inetpeer_ops allocated/frees net private memory.
      
      igmp_net_ops just creates/destroys /proc files and socket,
      noone else interested in.
      
      tcp_sk_ops seems to be safe, because tcp_sk_init() does not
      depend on any other pernet_operations modifications. Iteration
      over hash table in inet_twsk_purge() is made under RCU lock,
      and it's safe to iterate the table this way. Removing from
      the table happen from inet_twsk_deschedule_put(), but this
      function is safe without any extern locks, as it's synchronized
      inside itself. There are many examples, it's used in different
      context. So, it's safe to leave tcp_sk_exit_batch() unlocked.
      
      tcp_net_metrics_ops is synchronized on tcp_metrics_lock and safe.
      
      udplite4_net_ops only creates/destroys pernet /proc file.
      
      icmp_sk_ops creates percpu sockets, not touched by foreign
      pernet_operations.
      
      ipmr_net_ops creates/destroys pernet fib tables, (un)registers
      fib rules and /proc files. This seem to be safe to execute
      in parallel with foreign pernet_operations.
      
      af_inet_ops just sets up default parameters of newly created net.
      
      ipv4_mib_ops creates and destroys pernet percpu statistics.
      
      raw_net_ops, tcp4_net_ops, udp4_net_ops, ping_v4_net_ops
      and ip_proc_ops only create/destroy pernet /proc files.
      
      ip4_frags_ops creates and destroys sysctl file.
      
      So, it's safe to make the pernet_operations async.
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: NAndrei Vagin <avagin@virtuozzo.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f84c6821
    • F
      xfrm_user: uncoditionally validate esn replay attribute struct · d97ca5d7
      Florian Westphal 提交于
      The sanity test added in ecd79187 can be bypassed, validation
      only occurs if XFRM_STATE_ESN flag is set, but rest of code doesn't care
      and just checks if the attribute itself is present.
      
      So always validate.  Alternative is to reject if we have the attribute
      without the flag but that would change abi.
      
      Reported-by: syzbot+0ab777c27d2bb7588f73@syzkaller.appspotmail.com
      Cc: Mathias Krause <minipli@googlemail.com>
      Fixes: ecd79187 ("xfrm_user: ensure user supplied esn replay window is valid")
      Fixes: d8647b79 ("xfrm: Add user interface for esn and big anti-replay windows")
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      d97ca5d7
    • S
      xfrm: Fix policy hold queue after flowcache removal. · 2471c981
      Steffen Klassert 提交于
      Now that the flowcache is removed we need to generate
      a new dummy bundle every time we check if the needed
      SAs are in place because the dummy bundle is not cached
      anymore. Fix it by passing the XFRM_LOOKUP_QUEUE flag
      to xfrm_lookup(). This makes sure that we get a dummy
      bundle in case the SAs are not yet in place.
      
      Fixes: 3ca28286 ("xfrm_policy: bypass flow_cache_lookup")
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      2471c981
  15. 02 2月, 2018 1 次提交
  16. 23 1月, 2018 1 次提交
  17. 19 1月, 2018 1 次提交
  18. 18 1月, 2018 2 次提交
  19. 17 1月, 2018 1 次提交
    • A
      net: delete /proc THIS_MODULE references · 96890d62
      Alexey Dobriyan 提交于
      /proc has been ignoring struct file_operations::owner field for 10 years.
      Specifically, it started with commit 786d7e16
      ("Fix rmmod/read/write races in /proc entries"). Notice the chunk where
      inode->i_fop is initialized with proxy struct file_operations for
      regular files:
      
      	-               if (de->proc_fops)
      	-                       inode->i_fop = de->proc_fops;
      	+               if (de->proc_fops) {
      	+                       if (S_ISREG(inode->i_mode))
      	+                               inode->i_fop = &proc_reg_file_ops;
      	+                       else
      	+                               inode->i_fop = de->proc_fops;
      	+               }
      
      VFS stopped pinning module at this point.
      Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      96890d62
  20. 10 1月, 2018 1 次提交
  21. 08 1月, 2018 1 次提交
  22. 05 1月, 2018 1 次提交
  23. 31 12月, 2017 1 次提交
  24. 30 12月, 2017 2 次提交
    • F
      xfrm: skip policies marked as dead while rehashing · 862591bf
      Florian Westphal 提交于
      syzkaller triggered following KASAN splat:
      
      BUG: KASAN: slab-out-of-bounds in xfrm_hash_rebuild+0xdbe/0xf00 net/xfrm/xfrm_policy.c:618
      read of size 2 at addr ffff8801c8e92fe4 by task kworker/1:1/23 [..]
      Workqueue: events xfrm_hash_rebuild [..]
       __asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:428
       xfrm_hash_rebuild+0xdbe/0xf00 net/xfrm/xfrm_policy.c:618
       process_one_work+0xbbf/0x1b10 kernel/workqueue.c:2112
       worker_thread+0x223/0x1990 kernel/workqueue.c:2246 [..]
      
      The reproducer triggers:
      1016                 if (error) {
      1017                         list_move_tail(&walk->walk.all, &x->all);
      1018                         goto out;
      1019                 }
      
      in xfrm_policy_walk() via pfkey (it sets tiny rcv space, dump
      callback returns -ENOBUFS).
      
      In this case, *walk is located the pfkey socket struct, so this socket
      becomes visible in the global policy list.
      
      It looks like this is intentional -- phony walker has walk.dead set to 1
      and all other places skip such "policies".
      
      Ccing original authors of the two commits that seem to expose this
      issue (first patch missed ->dead check, second patch adds pfkey
      sockets to policies dumper list).
      
      Fixes: 880a6fab ("xfrm: configure policy hash table thresholds by netlink")
      Fixes: 12a169e7 ("ipsec: Put dumpers on the dump list")
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Timo Teras <timo.teras@iki.fi>
      Cc: Christophe Gouault <christophe.gouault@6wind.com>
      Reported-by: Nsyzbot <bot+c028095236fcb6f4348811565b75084c754dc729@syzkaller.appspotmail.com>
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      862591bf
    • H
      xfrm: Forbid state updates from changing encap type · 257a4b01
      Herbert Xu 提交于
      Currently we allow state updates to competely replace the contents
      of x->encap.  This is bad because on the user side ESP only sets up
      header lengths depending on encap_type once when the state is first
      created.  This could result in the header lengths getting out of
      sync with the actual state configuration.
      
      In practice key managers will never do a state update to change the
      encapsulation type.  Only the port numbers need to be changed as the
      peer NAT entry is updated.
      
      Therefore this patch adds a check in xfrm_state_update to forbid
      any changes to the encap_type.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      257a4b01
  25. 21 12月, 2017 1 次提交
    • S
      xfrm: check for xdo_dev_ops add and delete · 92a23206
      Shannon Nelson 提交于
      This adds a check for the required add and delete functions up front
      at registration time to be sure both are defined.
      
      Since both the features check and the registration check are looking
      at the same things, break out the check for both to call.
      
      Lastly, for some reason the feature check was setting xfrmdev_ops to
      NULL if the NETIF_F_HW_ESP bit was missing, which would probably
      surprise the driver later if the driver turned its NETIF_F_HW_ESP bit
      back on.  We shouldn't be messing with the driver's callback list, so
      we stop doing that with this patch.
      Signed-off-by: NShannon Nelson <shannon.nelson@oracle.com>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      92a23206
  26. 20 12月, 2017 3 次提交
  27. 19 12月, 2017 1 次提交
  28. 12 12月, 2017 1 次提交
  29. 08 12月, 2017 2 次提交
    • S
      xfrm: Fix stack-out-of-bounds with misconfigured transport mode policies. · 732706af
      Steffen Klassert 提交于
      On policies with a transport mode template, we pass the addresses
      from the flowi to xfrm_state_find(), assuming that the IP addresses
      (and address family) don't change during transformation.
      
      Unfortunately our policy template validation is not strict enough.
      It is possible to configure policies with transport mode template
      where the address family of the template does not match the selectors
      address family. This lead to stack-out-of-bound reads because
      we compare arddesses of the wrong family. Fix this by refusing
      such a configuration, address family can not change on transport
      mode.
      
      We use the assumption that, on transport mode, the first templates
      address family must match the address family of the policy selector.
      Subsequent transport mode templates must mach the address family of
      the previous template.
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      732706af
    • A
      xfrm: fix xfrm_do_migrate() with AEAD e.g(AES-GCM) · 75bf50f4
      Antony Antony 提交于
      copy geniv when cloning the xfrm state.
      
      x->geniv was not copied to the new state and migration would fail.
      
      xfrm_do_migrate
        ..
        xfrm_state_clone()
         ..
         ..
         esp_init_aead()
         crypto_alloc_aead()
          crypto_alloc_tfm()
           crypto_find_alg() return EAGAIN and failed
      Signed-off-by: NAntony Antony <antony@phenome.org>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      75bf50f4
  30. 01 12月, 2017 4 次提交