1. 19 6月, 2018 1 次提交
    • E
      xfrm_user: prevent leaking 2 bytes of kernel memory · 45c180bc
      Eric Dumazet 提交于
      struct xfrm_userpolicy_type has two holes, so we should not
      use C99 style initializer.
      
      KMSAN report:
      
      BUG: KMSAN: kernel-infoleak in copyout lib/iov_iter.c:140 [inline]
      BUG: KMSAN: kernel-infoleak in _copy_to_iter+0x1b14/0x2800 lib/iov_iter.c:571
      CPU: 1 PID: 4520 Comm: syz-executor841 Not tainted 4.17.0+ #5
      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+0x188/0x2a0 mm/kmsan/kmsan.c:1117
       kmsan_internal_check_memory+0x138/0x1f0 mm/kmsan/kmsan.c:1211
       kmsan_copy_to_user+0x7a/0x160 mm/kmsan/kmsan.c:1253
       copyout lib/iov_iter.c:140 [inline]
       _copy_to_iter+0x1b14/0x2800 lib/iov_iter.c:571
       copy_to_iter include/linux/uio.h:106 [inline]
       skb_copy_datagram_iter+0x422/0xfa0 net/core/datagram.c:431
       skb_copy_datagram_msg include/linux/skbuff.h:3268 [inline]
       netlink_recvmsg+0x6f1/0x1900 net/netlink/af_netlink.c:1959
       sock_recvmsg_nosec net/socket.c:802 [inline]
       sock_recvmsg+0x1d6/0x230 net/socket.c:809
       ___sys_recvmsg+0x3fe/0x810 net/socket.c:2279
       __sys_recvmmsg+0x58e/0xe30 net/socket.c:2391
       do_sys_recvmmsg+0x2a6/0x3e0 net/socket.c:2472
       __do_sys_recvmmsg net/socket.c:2485 [inline]
       __se_sys_recvmmsg net/socket.c:2481 [inline]
       __x64_sys_recvmmsg+0x15d/0x1c0 net/socket.c:2481
       do_syscall_64+0x15b/0x230 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      RIP: 0033:0x446ce9
      RSP: 002b:00007fc307918db8 EFLAGS: 00000293 ORIG_RAX: 000000000000012b
      RAX: ffffffffffffffda RBX: 00000000006dbc24 RCX: 0000000000446ce9
      RDX: 000000000000000a RSI: 0000000020005040 RDI: 0000000000000003
      RBP: 00000000006dbc20 R08: 0000000020004e40 R09: 0000000000000000
      R10: 0000000040000000 R11: 0000000000000293 R12: 0000000000000000
      R13: 00007ffc8d2df32f R14: 00007fc3079199c0 R15: 0000000000000001
      
      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:413
       __nla_put lib/nlattr.c:569 [inline]
       nla_put+0x276/0x340 lib/nlattr.c:627
       copy_to_user_policy_type net/xfrm/xfrm_user.c:1678 [inline]
       dump_one_policy+0xbe1/0x1090 net/xfrm/xfrm_user.c:1708
       xfrm_policy_walk+0x45a/0xd00 net/xfrm/xfrm_policy.c:1013
       xfrm_dump_policy+0x1c0/0x2a0 net/xfrm/xfrm_user.c:1749
       netlink_dump+0x9b5/0x1550 net/netlink/af_netlink.c:2226
       __netlink_dump_start+0x1131/0x1270 net/netlink/af_netlink.c:2323
       netlink_dump_start include/linux/netlink.h:214 [inline]
       xfrm_user_rcv_msg+0x8a3/0x9b0 net/xfrm/xfrm_user.c:2577
       netlink_rcv_skb+0x37e/0x600 net/netlink/af_netlink.c:2448
       xfrm_netlink_rcv+0xb2/0xf0 net/xfrm/xfrm_user.c:2598
       netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
       netlink_unicast+0x1680/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+0xec8/0x1320 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+0x15b/0x230 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      Local variable description: ----upt.i@dump_one_policy
      Variable was created at:
       dump_one_policy+0x78/0x1090 net/xfrm/xfrm_user.c:1689
       xfrm_policy_walk+0x45a/0xd00 net/xfrm/xfrm_policy.c:1013
      
      Byte 130 of 137 is uninitialized
      Memory access starts at ffff88019550407f
      
      Fixes: c0144bea ("[XFRM] netlink: Use nla_put()/NLA_PUT() variantes")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      45c180bc
  2. 28 3月, 2018 1 次提交
  3. 09 3月, 2018 1 次提交
  4. 13 2月, 2018 1 次提交
  5. 18 1月, 2018 1 次提交
  6. 08 12月, 2017 1 次提交
    • 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
  7. 01 12月, 2017 1 次提交
  8. 29 11月, 2017 1 次提交
    • C
      xfrm: check id proto in validate_tmpl() · 6a53b759
      Cong Wang 提交于
      syzbot reported a kernel warning in xfrm_state_fini(), which
      indicates that we have entries left in the list
      net->xfrm.state_all whose proto is zero. And
      xfrm_id_proto_match() doesn't consider them as a match with
      IPSEC_PROTO_ANY in this case.
      
      Proto with value 0 is probably not a valid value, at least
      verify_newsa_info() doesn't consider it valid either.
      
      This patch fixes it by checking the proto value in
      validate_tmpl() and rejecting invalid ones, like what iproute2
      does in xfrm_xfrmproto_getbyname().
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NCong Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      6a53b759
  9. 26 10月, 2017 1 次提交
  10. 23 10月, 2017 1 次提交
    • H
      ipsec: Fix aborted xfrm policy dump crash · 1137b5e2
      Herbert Xu 提交于
      An independent security researcher, Mohamed Ghannam, has reported
      this vulnerability to Beyond Security's SecuriTeam Secure Disclosure
      program.
      
      The xfrm_dump_policy_done function expects xfrm_dump_policy to
      have been called at least once or it will crash.  This can be
      triggered if a dump fails because the target socket's receive
      buffer is full.
      
      This patch fixes it by using the cb->start mechanism to ensure that
      the initialisation is always done regardless of the buffer situation.
      
      Fixes: 12a169e7 ("ipsec: Put dumpers on the dump list")
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      1137b5e2
  11. 25 9月, 2017 5 次提交
  12. 11 9月, 2017 1 次提交
  13. 31 8月, 2017 1 次提交
  14. 28 8月, 2017 4 次提交
  15. 11 8月, 2017 1 次提交
    • L
      net: xfrm: support setting an output mark. · 077fbac4
      Lorenzo Colitti 提交于
      On systems that use mark-based routing it may be necessary for
      routing lookups to use marks in order for packets to be routed
      correctly. An example of such a system is Android, which uses
      socket marks to route packets via different networks.
      
      Currently, routing lookups in tunnel mode always use a mark of
      zero, making routing incorrect on such systems.
      
      This patch adds a new output_mark element to the xfrm state and
      a corresponding XFRMA_OUTPUT_MARK netlink attribute. The output
      mark differs from the existing xfrm mark in two ways:
      
      1. The xfrm mark is used to match xfrm policies and states, while
         the xfrm output mark is used to set the mark (and influence
         the routing) of the packets emitted by those states.
      2. The existing mark is constrained to be a subset of the bits of
         the originating socket or transformed packet, but the output
         mark is arbitrary and depends only on the state.
      
      The use of a separate mark provides additional flexibility. For
      example:
      
      - A packet subject to two transforms (e.g., transport mode inside
        tunnel mode) can have two different output marks applied to it,
        one for the transport mode SA and one for the tunnel mode SA.
      - On a system where socket marks determine routing, the packets
        emitted by an IPsec tunnel can be routed based on a mark that
        is determined by the tunnel, not by the marks of the
        unencrypted packets.
      - Support for setting the output marks can be introduced without
        breaking any existing setups that employ both mark-based
        routing and xfrm tunnel mode. Simply changing the code to use
        the xfrm mark for routing output packets could xfrm mark could
        change behaviour in a way that breaks these setups.
      
      If the output mark is unspecified or set to zero, the mark is not
      set or changed.
      
      Tested: make allyesconfig; make -j64
      Tested: https://android-review.googlesource.com/452776Signed-off-by: NLorenzo Colitti <lorenzo@google.com>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      077fbac4
  16. 02 8月, 2017 1 次提交
  17. 19 7月, 2017 1 次提交
  18. 12 6月, 2017 1 次提交
    • H
      xfrm: move xfrm_garbage_collect out of xfrm_policy_flush · 138437f5
      Hangbin Liu 提交于
      Now we will force to do garbage collection if any policy removed in
      xfrm_policy_flush(). But during xfrm_net_exit(). We call flow_cache_fini()
      first and set set fc->percpu to NULL. Then after we call xfrm_policy_fini()
      -> frxm_policy_flush() -> flow_cache_flush(), we will get NULL pointer
      dereference when check percpu_empty. The code path looks like:
      
      flow_cache_fini()
        - fc->percpu = NULL
      xfrm_policy_fini()
        - xfrm_policy_flush()
          - xfrm_garbage_collect()
            - flow_cache_flush()
              - flow_cache_percpu_empty()
      	  - fcp = per_cpu_ptr(fc->percpu, cpu)
      
      To reproduce, just add ipsec in netns and then remove the netns.
      
      v2:
      As Xin Long suggested, since only two other places need to call it. move
      xfrm_garbage_collect() outside xfrm_policy_flush().
      
      v3:
      Fix subject mismatch after v2 fix.
      
      Fixes: 35db0691 ("xfrm: do the garbage collection after flushing policy")
      Signed-off-by: NHangbin Liu <liuhangbin@gmail.com>
      Reviewed-by: NXin Long <lucien.xin@gmail.com>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      138437f5
  19. 07 6月, 2017 2 次提交
  20. 02 5月, 2017 1 次提交
  21. 14 4月, 2017 4 次提交
    • S
      xfrm: Add an IPsec hardware offloading API · d77e38e6
      Steffen Klassert 提交于
      This patch adds all the bits that are needed to do
      IPsec hardware offload for IPsec states and ESP packets.
      We add xfrmdev_ops to the net_device. xfrmdev_ops has
      function pointers that are needed to manage the xfrm
      states in the hardware and to do a per packet
      offloading decision.
      
      Joint work with:
      Ilan Tayari <ilant@mellanox.com>
      Guy Shapiro <guysh@mellanox.com>
      Yossi Kuperman <yossiku@mellanox.com>
      Signed-off-by: NGuy Shapiro <guysh@mellanox.com>
      Signed-off-by: NIlan Tayari <ilant@mellanox.com>
      Signed-off-by: NYossi Kuperman <yossiku@mellanox.com>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      d77e38e6
    • J
      netlink: pass extended ACK struct where available · fe52145f
      Johannes Berg 提交于
      This is an add-on to the previous patch that passes the extended ACK
      structure where it's already available by existing genl_info or extack
      function arguments.
      
      This was done with this spatch (with some manual adjustment of
      indentation):
      
      @@
      expression A, B, C, D, E;
      identifier fn, info;
      @@
      fn(..., struct genl_info *info, ...) {
      ...
      -nlmsg_parse(A, B, C, D, E, NULL)
      +nlmsg_parse(A, B, C, D, E, info->extack)
      ...
      }
      
      @@
      expression A, B, C, D, E;
      identifier fn, info;
      @@
      fn(..., struct genl_info *info, ...) {
      <...
      -nla_parse_nested(A, B, C, D, NULL)
      +nla_parse_nested(A, B, C, D, info->extack)
      ...>
      }
      
      @@
      expression A, B, C, D, E;
      identifier fn, extack;
      @@
      fn(..., struct netlink_ext_ack *extack, ...) {
      <...
      -nlmsg_parse(A, B, C, D, E, NULL)
      +nlmsg_parse(A, B, C, D, E, extack)
      ...>
      }
      
      @@
      expression A, B, C, D, E;
      identifier fn, extack;
      @@
      fn(..., struct netlink_ext_ack *extack, ...) {
      <...
      -nla_parse(A, B, C, D, E, NULL)
      +nla_parse(A, B, C, D, E, extack)
      ...>
      }
      
      @@
      expression A, B, C, D, E;
      identifier fn, extack;
      @@
      fn(..., struct netlink_ext_ack *extack, ...) {
      ...
      -nlmsg_parse(A, B, C, D, E, NULL)
      +nlmsg_parse(A, B, C, D, E, extack)
      ...
      }
      
      @@
      expression A, B, C, D;
      identifier fn, extack;
      @@
      fn(..., struct netlink_ext_ack *extack, ...) {
      <...
      -nla_parse_nested(A, B, C, D, NULL)
      +nla_parse_nested(A, B, C, D, extack)
      ...>
      }
      
      @@
      expression A, B, C, D;
      identifier fn, extack;
      @@
      fn(..., struct netlink_ext_ack *extack, ...) {
      <...
      -nlmsg_validate(A, B, C, D, NULL)
      +nlmsg_validate(A, B, C, D, extack)
      ...>
      }
      
      @@
      expression A, B, C, D;
      identifier fn, extack;
      @@
      fn(..., struct netlink_ext_ack *extack, ...) {
      <...
      -nla_validate(A, B, C, D, NULL)
      +nla_validate(A, B, C, D, extack)
      ...>
      }
      
      @@
      expression A, B, C;
      identifier fn, extack;
      @@
      fn(..., struct netlink_ext_ack *extack, ...) {
      <...
      -nla_validate_nested(A, B, C, NULL)
      +nla_validate_nested(A, B, C, extack)
      ...>
      }
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Reviewed-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fe52145f
    • J
      netlink: pass extended ACK struct to parsing functions · fceb6435
      Johannes Berg 提交于
      Pass the new extended ACK reporting struct to all of the generic
      netlink parsing functions. For now, pass NULL in almost all callers
      (except for some in the core.)
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fceb6435
    • J
      netlink: extended ACK reporting · 2d4bc933
      Johannes Berg 提交于
      Add the base infrastructure and UAPI for netlink extended ACK
      reporting. All "manual" calls to netlink_ack() pass NULL for now and
      thus don't get extended ACK reporting.
      
      Big thanks goes to Pablo Neira Ayuso for not only bringing up the
      whole topic at netconf (again) but also coming up with the nlattr
      passing trick and various other ideas.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Reviewed-by: NDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2d4bc933
  22. 10 4月, 2017 1 次提交
  23. 29 3月, 2017 2 次提交
  24. 24 3月, 2017 1 次提交
  25. 25 12月, 2016 1 次提交
  26. 30 11月, 2016 1 次提交
  27. 09 9月, 2016 1 次提交
  28. 27 7月, 2016 1 次提交