1. 05 12月, 2022 2 次提交
  2. 25 11月, 2022 2 次提交
  3. 29 9月, 2022 1 次提交
  4. 22 9月, 2022 3 次提交
  5. 29 8月, 2022 1 次提交
    • E
      xfrm: interface: support collect metadata mode · abc340b3
      Eyal Birger 提交于
      This commit adds support for 'collect_md' mode on xfrm interfaces.
      
      Each net can have one collect_md device, created by providing the
      IFLA_XFRM_COLLECT_METADATA flag at creation. This device cannot be
      altered and has no if_id or link device attributes.
      
      On transmit to this device, the if_id is fetched from the attached dst
      metadata on the skb. If exists, the link property is also fetched from
      the metadata. The dst metadata type used is METADATA_XFRM which holds
      these properties.
      
      On the receive side, xfrmi_rcv_cb() populates a dst metadata for each
      packet received and attaches it to the skb. The if_id used in this case is
      fetched from the xfrm state, and the link is fetched from the incoming
      device. This information can later be used by upper layers such as tc,
      ebpf, and ip rules.
      
      Because the skb is scrubed in xfrmi_rcv_cb(), the attachment of the dst
      metadata is postponed until after scrubing. Similarly, xfrm_input() is
      adapted to avoid dropping metadata dsts by only dropping 'valid'
      (skb_valid_dst(skb) == true) dsts.
      
      Policy matching on packets arriving from collect_md xfrmi devices is
      done by using the xfrm state existing in the skb's sec_path.
      The xfrm_if_cb.decode_cb() interface implemented by xfrmi_decode_session()
      is changed to keep the details of the if_id extraction tucked away
      in xfrm_interface.c.
      Reviewed-by: NNicolas Dichtel <nicolas.dichtel@6wind.com>
      Reviewed-by: NNikolay Aleksandrov <razor@blackwall.org>
      Signed-off-by: NEyal Birger <eyal.birger@gmail.com>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      abc340b3
  6. 11 7月, 2022 1 次提交
    • S
      net: Find dst with sk's xfrm policy not ctl_sk · e22aa148
      sewookseo 提交于
      If we set XFRM security policy by calling setsockopt with option
      IPV6_XFRM_POLICY, the policy will be stored in 'sock_policy' in 'sock'
      struct. However tcp_v6_send_response doesn't look up dst_entry with the
      actual socket but looks up with tcp control socket. This may cause a
      problem that a RST packet is sent without ESP encryption & peer's TCP
      socket can't receive it.
      This patch will make the function look up dest_entry with actual socket,
      if the socket has XFRM policy(sock_policy), so that the TCP response
      packet via this function can be encrypted, & aligned on the encrypted
      TCP socket.
      
      Tested: We encountered this problem when a TCP socket which is encrypted
      in ESP transport mode encryption, receives challenge ACK at SYN_SENT
      state. After receiving challenge ACK, TCP needs to send RST to
      establish the socket at next SYN try. But the RST was not encrypted &
      peer TCP socket still remains on ESTABLISHED state.
      So we verified this with test step as below.
      [Test step]
      1. Making a TCP state mismatch between client(IDLE) & server(ESTABLISHED).
      2. Client tries a new connection on the same TCP ports(src & dst).
      3. Server will return challenge ACK instead of SYN,ACK.
      4. Client will send RST to server to clear the SOCKET.
      5. Client will retransmit SYN to server on the same TCP ports.
      [Expected result]
      The TCP connection should be established.
      
      Cc: Maciej Żenczykowski <maze@google.com>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Cc: Sehee Lee <seheele@google.com>
      Signed-off-by: NSewook Seo <sewookseo@google.com>
      Reviewed-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e22aa148
  7. 24 6月, 2022 1 次提交
  8. 10 6月, 2022 1 次提交
  9. 16 5月, 2022 1 次提交
    • E
      xfrm: fix "disable_policy" flag use when arriving from different devices · e6175a2e
      Eyal Birger 提交于
      In IPv4 setting the "disable_policy" flag on a device means no policy
      should be enforced for traffic originating from the device. This was
      implemented by seting the DST_NOPOLICY flag in the dst based on the
      originating device.
      
      However, dsts are cached in nexthops regardless of the originating
      devices, in which case, the DST_NOPOLICY flag value may be incorrect.
      
      Consider the following setup:
      
                           +------------------------------+
                           | ROUTER                       |
        +-------------+    | +-----------------+          |
        | ipsec src   |----|-|ipsec0           |          |
        +-------------+    | |disable_policy=0 |   +----+ |
                           | +-----------------+   |eth1|-|-----
        +-------------+    | +-----------------+   +----+ |
        | noipsec src |----|-|eth0             |          |
        +-------------+    | |disable_policy=1 |          |
                           | +-----------------+          |
                           +------------------------------+
      
      Where ROUTER has a default route towards eth1.
      
      dst entries for traffic arriving from eth0 would have DST_NOPOLICY
      and would be cached and therefore can be reused by traffic originating
      from ipsec0, skipping policy check.
      
      Fix by setting a IPSKB_NOPOLICY flag in IPCB and observing it instead
      of the DST in IN/FWD IPv4 policy checks.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Reported-by: NShmulik Ladkani <shmulik.ladkani@gmail.com>
      Signed-off-by: NEyal Birger <eyal.birger@gmail.com>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      e6175a2e
  10. 06 5月, 2022 5 次提交
  11. 18 3月, 2022 1 次提交
  12. 27 1月, 2022 1 次提交
  13. 26 1月, 2022 1 次提交
    • Y
      xfrm: Check if_id in xfrm_migrate · c1aca308
      Yan Yan 提交于
      This patch enables distinguishing SAs and SPs based on if_id during
      the xfrm_migrate flow. This ensures support for xfrm interfaces
      throughout the SA/SP lifecycle.
      
      When there are multiple existing SPs with the same direction,
      the same xfrm_selector and different endpoint addresses,
      xfrm_migrate might fail with ENODATA.
      
      Specifically, the code path for performing xfrm_migrate is:
        Stage 1: find policy to migrate with
          xfrm_migrate_policy_find(sel, dir, type, net)
        Stage 2: find and update state(s) with
          xfrm_migrate_state_find(mp, net)
        Stage 3: update endpoint address(es) of template(s) with
          xfrm_policy_migrate(pol, m, num_migrate)
      
      Currently "Stage 1" always returns the first xfrm_policy that
      matches, and "Stage 3" looks for the xfrm_tmpl that matches the
      old endpoint address. Thus if there are multiple xfrm_policy
      with same selector, direction, type and net, "Stage 1" might
      rertun a wrong xfrm_policy and "Stage 3" will fail with ENODATA
      because it cannot find a xfrm_tmpl with the matching endpoint
      address.
      
      The fix is to allow userspace to pass an if_id and add if_id
      to the matching rule in Stage 1 and Stage 2 since if_id is a
      unique ID for xfrm_policy and xfrm_state. For compatibility,
      if_id will only be checked if the attribute is set.
      
      Tested with additions to Android's kernel unit test suite:
      https://android-review.googlesource.com/c/kernel/tests/+/1668886Signed-off-by: NYan Yan <evitayan@google.com>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      c1aca308
  14. 23 12月, 2021 1 次提交
  15. 11 12月, 2021 1 次提交
  16. 23 11月, 2021 1 次提交
  17. 21 7月, 2021 1 次提交
  18. 23 6月, 2021 1 次提交
  19. 21 6月, 2021 5 次提交
  20. 16 6月, 2021 1 次提交
  21. 11 6月, 2021 1 次提交
  22. 09 6月, 2021 1 次提交
  23. 01 6月, 2021 1 次提交
  24. 14 5月, 2021 1 次提交
  25. 19 4月, 2021 1 次提交
    • S
      xfrm: xfrm_state_mtu should return at least 1280 for ipv6 · b515d263
      Sabrina Dubroca 提交于
      Jianwen reported that IPv6 Interoperability tests are failing in an
      IPsec case where one of the links between the IPsec peers has an MTU
      of 1280. The peer generates a packet larger than this MTU, the router
      replies with a "Packet too big" message indicating an MTU of 1280.
      When the peer tries to send another large packet, xfrm_state_mtu
      returns 1280 - ipsec_overhead, which causes ip6_setup_cork to fail
      with EINVAL.
      
      We can fix this by forcing xfrm_state_mtu to return IPV6_MIN_MTU when
      IPv6 is used. After going through IPsec, the packet will then be
      fragmented to obey the actual network's PMTU, just before leaving the
      host.
      
      Currently, TFC padding is capped to PMTU - overhead to avoid
      fragementation: after padding and encapsulation, we still fit within
      the PMTU. That behavior is preserved in this patch.
      
      Fixes: 91657eaf ("xfrm: take net hdr len into account for esp payload size calculation")
      Reported-by: NJianwen Ji <jiji@redhat.com>
      Signed-off-by: NSabrina Dubroca <sd@queasysnail.net>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      b515d263
  26. 24 3月, 2021 1 次提交
  27. 03 3月, 2021 1 次提交
    • E
      xfrm: Use actual socket sk instead of skb socket for xfrm_output_resume · 9ab1265d
      Evan Nimmo 提交于
      A situation can occur where the interface bound to the sk is different
      to the interface bound to the sk attached to the skb. The interface
      bound to the sk is the correct one however this information is lost inside
      xfrm_output2 and instead the sk on the skb is used in xfrm_output_resume
      instead. This assumes that the sk bound interface and the bound interface
      attached to the sk within the skb are the same which can lead to lookup
      failures inside ip_route_me_harder resulting in the packet being dropped.
      
      We have an l2tp v3 tunnel with ipsec protection. The tunnel is in the
      global VRF however we have an encapsulated dot1q tunnel interface that
      is within a different VRF. We also have a mangle rule that marks the
      packets causing them to be processed inside ip_route_me_harder.
      
      Prior to commit 31c70d59 ("l2tp: keep original skb ownership") this
      worked fine as the sk attached to the skb was changed from the dot1q
      encapsulated interface to the sk for the tunnel which meant the interface
      bound to the sk and the interface bound to the skb were identical.
      Commit 46d6c5ae ("netfilter: use actual socket sk rather than skb sk
      when routing harder") fixed some of these issues however a similar
      problem existed in the xfrm code.
      
      Fixes: 31c70d59 ("l2tp: keep original skb ownership")
      Signed-off-by: NEvan Nimmo <evan.nimmo@alliedtelesis.co.nz>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      9ab1265d
  28. 24 9月, 2020 1 次提交