21 Jun, 2020

1 commit

  • The user tool modinfo is used to get information on kernel modules, including a
    description where it is available.

    This patch adds a brief MODULE_DESCRIPTION to the following modules:

    9p
    drop_monitor
    esp4_offload
    esp6_offload
    fou
    fou6
    ila
    sch_fq
    sch_fq_codel
    sch_hhf

    Signed-off-by: Rob Gill
    Signed-off-by: David S. Miller

    Rob Gill
     

01 Jun, 2020

1 commit

  • xdp_umem.c had overlapping changes between the 64-bit math fix
    for the calculation of npgs and the removal of the zerocopy
    memory type which got rid of the chunk_size_nohdr member.

    The mlx5 Kconfig conflict is a case where we just take the
    net-next copy of the Kconfig entry dependency as it takes on
    the ESWITCH dependency by one level of indirection which is
    what the 'net' conflicting change is trying to ensure.

    Signed-off-by: David S. Miller

    David S. Miller
     

14 May, 2020

1 commit

  • In esp6_init_state() for beet mode when x->sel.family != AF_INET6:

    x->props.header_len = sizeof(struct ip_esp_hdr) +
    crypto_aead_ivsize(aead) + IPV4_BEET_PHMAXLEN +
    (sizeof(struct ipv6hdr) - sizeof(struct iphdr))

    In xfrm6_beet_gso_segment() skb->transport_header is supposed to move
    to the end of the ph header for IPPROTO_BEETPH, so if x->sel.family !=
    AF_INET6 and it's IPPROTO_BEETPH, it should do:

    skb->transport_header -=
    (sizeof(struct ipv6hdr) - sizeof(struct iphdr));
    skb->transport_header += ph->hdrlen * 8;

    And IPV4_BEET_PHMAXLEN is only reserved for PH header, so if
    x->sel.family != AF_INET6 and it's not IPPROTO_BEETPH, it should do:

    skb->transport_header -=
    (sizeof(struct ipv6hdr) - sizeof(struct iphdr));
    skb->transport_header -= IPV4_BEET_PHMAXLEN;

    Thanks Sabrina for looking deep into this issue.

    Fixes: 7f9e40eb18a9 ("esp6: add gso_segment for esp6 beet mode")
    Reported-by: Sabrina Dubroca
    Signed-off-by: Xin Long
    Signed-off-by: Steffen Klassert

    Xin Long
     

28 Apr, 2020

1 commit


21 Apr, 2020

1 commit

  • For beet mode, when it's ipv6 inner address with nexthdrs set,
    the packet format might be:

    ----------------------------------------------------
    | outer | | dest | | | ESP | ESP |
    | IP6 hdr| ESP | opts.| TCP | Data | Trailer | ICV |
    ----------------------------------------------------

    Before doing gso segment in xfrm6_beet_gso_segment(), it should
    skip all nexthdrs and get the real transport proto, and set
    transport_header properly.

    This patch is to fix it by simply calling ipv6_skip_exthdr()
    in xfrm6_beet_gso_segment().

    v1->v2:
    - remove skb_transport_offset(), as it will always return 0
    in xfrm6_beet_gso_segment(), thank Sabrina's check.

    Fixes: 7f9e40eb18a9 ("esp6: add gso_segment for esp6 beet mode")
    Signed-off-by: Xin Long
    Signed-off-by: Steffen Klassert

    Xin Long
     

20 Apr, 2020

1 commit

  • This xfrm_state_put call in esp4/6_gro_receive() will cause
    double put for state, as in out_reset path secpath_reset()
    will put all states set in skb sec_path.

    So fix it by simply remove the xfrm_state_put call.

    Fixes: 6ed69184ed9c ("xfrm: Reset secpath in xfrm failure")
    Signed-off-by: Xin Long
    Signed-off-by: Steffen Klassert

    Xin Long
     

15 Apr, 2020

1 commit

  • For transport mode, when ipv6 nexthdr is set, the packet format might
    be like:

    ----------------------------------------------------
    | | dest | | | | ESP | ESP |
    | IP6 hdr| opts.| ESP | TCP | Data | Trailer | ICV |
    ----------------------------------------------------

    What it wants to get for x-proto in esp6_gso_encap() is the proto that
    will be set in ESP nexthdr. So it should skip all ipv6 nexthdrs and
    get the real transport protocol. Othersize, the wrong proto number
    will be set into ESP nexthdr.

    This patch is to skip all ipv6 nexthdrs by calling ipv6_skip_exthdr()
    in esp6_gso_encap().

    Fixes: 7862b4058b9f ("esp: Add gso handlers for esp4 and esp6")
    Signed-off-by: Xin Long
    Signed-off-by: Steffen Klassert

    Xin Long
     

26 Mar, 2020

1 commit

  • Similar to xfrm6_tunnel/transport_gso_segment(), _gso_segment()
    is added to do gso_segment for esp6 beet mode. Before calling
    inet6_offloads[proto]->callbacks.gso_segment, it needs to do:

    - Get the upper proto from ph header to get its gso_segment
    when xo->proto is IPPROTO_BEETPH.

    - Add SKB_GSO_TCPV6 to gso_type if x->sel.family != AF_INET6
    and the proto == IPPROTO_TCP, so that the current tcp ipv6
    packet can be segmented.

    - Calculate a right value for skb->transport_header and move
    skb->data to the transport header position.

    Signed-off-by: Xin Long
    Signed-off-by: Steffen Klassert

    Xin Long
     

15 Jan, 2020

1 commit

  • Commit 9b42c1f179a6 ("xfrm: Extend the output_mark") added output_mark
    support but missed ESP offload support.

    xfrm_smark_get() is not called within xfrm_input() for packets coming
    from esp4_gro_receive() or esp6_gro_receive(). Therefore call
    xfrm_smark_get() directly within these functions.

    Fixes: 9b42c1f179a6 ("xfrm: Extend the output_mark to support input direction and masking.")
    Signed-off-by: Ulrich Weber
    Signed-off-by: Steffen Klassert

    Ulrich Weber
     

06 Jul, 2019

1 commit


06 Jun, 2019

1 commit

  • Only a handful of xfrm_types exist, no need to have 512 pointers for them.

    Reduces size of afinfo struct from 4k to 120 bytes on 64bit platforms.

    Also, the unregister function doesn't need to return an error, no single
    caller does anything useful with it.

    Just place a WARN_ON() where needed instead.

    Signed-off-by: Florian Westphal
    Signed-off-by: Steffen Klassert

    Florian Westphal
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms and conditions of the gnu general public license
    version 2 as published by the free software foundation

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 101 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190531190113.822954939@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

03 May, 2019

1 commit


08 Apr, 2019

2 commits

  • This structure is now only 4 bytes, so its more efficient
    to cache a copy rather than its address.

    No significant size difference in allmodconfig vmlinux.

    With non-modular kernel that has all XFRM options enabled, this
    series reduces vmlinux image size by ~11kb. All xfrm_mode
    indirections are gone and all modes are built-in.

    before (ipsec-next master):
    text data bss dec filename
    21071494 7233140 11104324 39408958 vmlinux.master

    after this series:
    21066448 7226772 11104324 39397544 vmlinux.patched

    With allmodconfig kernel, the size increase is only 362 bytes,
    even all the xfrm config options removed in this series are
    modular.

    before:
    text data bss dec filename
    15731286 6936912 4046908 26715106 vmlinux.master

    after this series:
    15731492 6937068 4046908 26715468 vmlinux

    Signed-off-by: Florian Westphal
    Reviewed-by: Sabrina Dubroca
    Signed-off-by: Steffen Klassert

    Florian Westphal
     
  • These functions are small and we only have versions for tunnel
    and transport mode for ipv4 and ipv6 respectively.

    Just place the 'transport or tunnel' conditional in the protocol
    specific function instead of using an indirection.

    Before:
    3226 12 0 3238 net/ipv4/esp4_offload.o
    7004 492 0 7496 net/ipv4/ip_vti.o
    3339 12 0 3351 net/ipv6/esp6_offload.o
    11294 460 0 11754 net/ipv6/ip6_vti.o
    1180 72 0 1252 net/ipv4/xfrm4_mode_beet.o
    428 48 0 476 net/ipv4/xfrm4_mode_transport.o
    1271 48 0 1319 net/ipv4/xfrm4_mode_tunnel.o
    1083 60 0 1143 net/ipv6/xfrm6_mode_beet.o
    172 48 0 220 net/ipv6/xfrm6_mode_ro.o
    429 48 0 477 net/ipv6/xfrm6_mode_transport.o
    1164 48 0 1212 net/ipv6/xfrm6_mode_tunnel.o
    15730428 6937008 4046908 26714344 vmlinux

    After:
    3461 12 0 3473 net/ipv4/esp4_offload.o
    7000 492 0 7492 net/ipv4/ip_vti.o
    3574 12 0 3586 net/ipv6/esp6_offload.o
    11295 460 0 11755 net/ipv6/ip6_vti.o
    1180 64 0 1244 net/ipv4/xfrm4_mode_beet.o
    171 40 0 211 net/ipv4/xfrm4_mode_transport.o
    1163 40 0 1203 net/ipv4/xfrm4_mode_tunnel.o
    1083 52 0 1135 net/ipv6/xfrm6_mode_beet.o
    172 40 0 212 net/ipv6/xfrm6_mode_ro.o
    172 40 0 212 net/ipv6/xfrm6_mode_transport.o
    1056 40 0 1096 net/ipv6/xfrm6_mode_tunnel.o
    15730424 6937008 4046908 26714340 vmlinux

    Signed-off-by: Florian Westphal
    Reviewed-by: Sabrina Dubroca
    Signed-off-by: Steffen Klassert

    Florian Westphal
     

08 Mar, 2019

1 commit

  • In esp4_gro_receive() and esp6_gro_receive(), secpath can be allocated
    without adding xfrm state to xvec. Then, sp->xvec[sp->len - 1] would
    fail and result in dereferencing invalid pointer in esp4_gso_segment()
    and esp6_gso_segment(). Reset secpath if xfrm function returns error.

    Fixes: 7785bba299a8 ("esp: Add a software GRO codepath")
    Reported-by: syzbot+b69368fd933c6c592f4c@syzkaller.appspotmail.com
    Signed-off-by: Myungho Jung
    Signed-off-by: Steffen Klassert

    Myungho Jung
     

20 Dec, 2018

2 commits

  • skb_sec_path gains 'const' qualifier to avoid
    xt_policy.c: 'skb_sec_path' discards 'const' qualifier from pointer target type

    same reasoning as previous conversions: Won't need to touch these
    spots anymore when skb->sp is removed.

    Signed-off-by: Florian Westphal
    Signed-off-by: David S. Miller

    Florian Westphal
     
  • It can only return 0 (success) or -ENOMEM.
    Change return value to a pointer to secpath struct.

    This avoids direct access to skb->sp:

    err = secpath_set(skb);
    if (!err) ..
    skb->sp-> ...

    Becomes:
    sp = secpath_set(skb)
    if (!sp) ..
    sp-> ..

    This reduces noise in followup patch which is going to remove skb->sp.

    Signed-off-by: Florian Westphal
    Signed-off-by: David S. Miller

    Florian Westphal
     

28 Jul, 2018

1 commit

  • Steffen Klassert says:

    ====================
    pull request (net-next): ipsec-next 2018-07-27

    1) Extend the output_mark to also support the input direction
    and masking the mark values before applying to the skb.

    2) Add a new lookup key for the upcomming xfrm interfaces.

    3) Extend the xfrm lookups to match xfrm interface IDs.

    4) Add virtual xfrm interfaces. The purpose of these interfaces
    is to overcome the design limitations that the existing
    VTI devices have.

    The main limitations that we see with the current VTI are the
    following:

    VTI interfaces are L3 tunnels with configurable endpoints.
    For xfrm, the tunnel endpoint are already determined by the SA.
    So the VTI tunnel endpoints must be either the same as on the
    SA or wildcards. In case VTI tunnel endpoints are same as on
    the SA, we get a one to one correlation between the SA and
    the tunnel. So each SA needs its own tunnel interface.

    On the other hand, we can have only one VTI tunnel with
    wildcard src/dst tunnel endpoints in the system because the
    lookup is based on the tunnel endpoints. The existing tunnel
    lookup won't work with multiple tunnels with wildcard
    tunnel endpoints. Some usecases require more than on
    VTI tunnel of this type, for example if somebody has multiple
    namespaces and every namespace requires such a VTI.

    VTI needs separate interfaces for IPv4 and IPv6 tunnels.
    So when routing to a VTI, we have to know to which address
    family this traffic class is going to be encapsulated.
    This is a lmitation because it makes routing more complex
    and it is not always possible to know what happens behind the
    VTI, e.g. when the VTI is move to some namespace.

    VTI works just with tunnel mode SAs. We need generic interfaces
    that ensures transfomation, regardless of the xfrm mode and
    the encapsulated address family.

    VTI is configured with a combination GRE keys and xfrm marks.
    With this we have to deal with some extra cases in the generic
    tunnel lookup because the GRE keys on the VTI are actually
    not GRE keys, the GRE keys were just reused for something else.
    All extensions to the VTI interfaces would require to add
    even more complexity to the generic tunnel lookup.

    So to overcome this, we developed xfrm interfaces with the
    following design goal:

    It should be possible to tunnel IPv4 and IPv6 through the same
    interface.

    No limitation on xfrm mode (tunnel, transport and beet).

    Should be a generic virtual interface that ensures IPsec
    transformation, no need to know what happens behind the
    interface.

    Interfaces should be configured with a new key that must match a
    new policy/SA lookup key.

    The lookup logic should stay in the xfrm codebase, no need to
    change or extend generic routing and tunnel lookups.

    Should be possible to use IPsec hardware offloads of the underlying
    interface.

    5) Remove xfrm pcpu policy cache. This was added after the flowcache
    removal, but it turned out to make things even worse.
    From Florian Westphal.

    6) Allow to update the set mark on SA updates.
    From Nathan Harold.

    7) Convert some timestamps to time64_t.
    From Arnd Bergmann.

    8) Don't check the offload_handle in xfrm code,
    it is an opaque data cookie for the driver.
    From Shannon Nelson.

    9) Remove xfrmi interface ID from flowi. After this pach
    no generic code is touched anymore to do xfrm interface
    lookups. From Benedict Wong.

    10) Allow to update the xfrm interface ID on SA updates.
    From Nathan Harold.

    11) Don't pass zero to ERR_PTR() in xfrm_resolve_and_create_bundle.
    From YueHaibing.

    12) Return more detailed errors on xfrm interface creation.
    From Benedict Wong.

    13) Use PTR_ERR_OR_ZERO instead of IS_ERR + PTR_ERR.
    From the kbuild test robot.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

19 Jul, 2018

1 commit

  • The offload_handle should be an opaque data cookie for the driver
    to use, much like the data cookie for a timer or alarm callback.
    Thus, the XFRM stack should not be checking for non-zero, because
    the driver might use that to store an array reference, which could
    be zero, or some other zero but meaningful value.

    We can remove the checks for non-zero because there are plenty
    other attributes also being checked to see if there is an offload
    in place for the SA in question.

    Signed-off-by: Shannon Nelson
    Signed-off-by: Steffen Klassert

    Shannon Nelson
     

26 Jun, 2018

1 commit

  • Manage pending per-NAPI GRO packets via list_head.

    Return an SKB pointer from the GRO receive handlers. When GRO receive
    handlers return non-NULL, it means that this SKB needs to be completed
    at this time and removed from the NAPI queue.

    Several operations are greatly simplified by this transformation,
    especially timing out the oldest SKB in the list when gro_count
    exceeds MAX_GRO_SKBS, and napi_gro_flush() which walks the queue
    in reverse order.

    Signed-off-by: David S. Miller

    David Miller
     

27 Feb, 2018

1 commit


24 Jan, 2018

1 commit


23 Jan, 2018

1 commit

  • Validate gso_type during segmentation as SKB_GSO_DODGY sources
    may pass packets where the gso_type does not match the contents.

    Syzkaller was able to enter the SCTP gso handler with a packet of
    gso_type SKB_GSO_TCPV4.

    On entry of transport layer gso handlers, verify that the gso_type
    matches the transport protocol.

    Fixes: 90017accff61 ("sctp: Add GSO support")
    Link: http://lkml.kernel.org/r/
    Reported-by: syzbot+fee64147a25aecd48055@syzkaller.appspotmail.com
    Signed-off-by: Willem de Bruijn
    Acked-by: Jason Wang
    Reviewed-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Willem de Bruijn
     

17 Jan, 2018

1 commit


09 Jan, 2018

1 commit

  • The GRO layer does not necessarily pull the complete headers
    into the linear part of the skb, a part may remain on the
    first page fragment. This can lead to a crash if we try to
    pull the headers, so make sure we have them on the linear
    part before pulling.

    Fixes: 7785bba299a8 ("esp: Add a software GRO codepath")
    Reported-by: syzbot+82bbd65569c49c6c0c4d@syzkaller.appspotmail.com
    Signed-off-by: Steffen Klassert

    Steffen Klassert
     

20 Dec, 2017

1 commit


02 Sep, 2017

1 commit


07 Aug, 2017

1 commit

  • esp_output_tail() and esp6_output_tail() can return negative
    and positive error values. We currently treat only negative
    values as errors, fix this to treat both cases as error.

    Fixes: fca11ebde3f0 ("esp4: Reorganize esp_output")
    Fixes: 383d0350f2cc ("esp6: Reorganize esp_output")
    Signed-off-by: Steffen Klassert

    Steffen Klassert
     

02 Aug, 2017

2 commits

  • IPSec crypto offload depends on the protocol-specific
    offload module (such as esp_offload.ko).

    When the user installs an SA with crypto-offload, load
    the offload module automatically, in the same way
    that the protocol module is loaded (such as esp.ko)

    Signed-off-by: Ilan Tayari
    Signed-off-by: Steffen Klassert

    Ilan Tayari
     
  • Keep the device's reported ip_summed indication in case crypto
    was offloaded by the device. Subtract the csum values of the
    stripped parts (esp header+iv, esp trailer+auth_data) to keep
    value correct.

    Note: CHECKSUM_COMPLETE should be indicated only if skb->csum
    has the post-decryption offload csum value.

    Signed-off-by: Ariel Levkovich
    Signed-off-by: Ilan Tayari
    Signed-off-by: Steffen Klassert

    Ilan Tayari
     

22 Jun, 2017

1 commit

  • IP6CB(skb)->nhoff is the offset of the nexthdr field in an IPv6
    header, unless there are extension headers present, in which case
    nhoff points to the nexthdr field of the last extension header.

    In non-GRO code path, nhoff is set by ipv6_rcv before any XFRM code
    is executed. Conversely, in GRO code path (when esp6_offload is loaded),
    nhoff is not set. The following functions fail to read the correct value
    and eventually the packet is dropped:

    xfrm6_transport_finish
    xfrm6_tunnel_input
    xfrm6_rcv_tnl

    Set nhoff to the proper offset of nexthdr in esp6_gro_receive.

    Fixes: 7785bba299a8 ("esp: Add a software GRO codepath")
    Signed-off-by: Yossi Kuperman
    Signed-off-by: Steffen Klassert

    Yossi Kuperman
     

19 Apr, 2017

2 commits

  • If esp*_offload module is loaded, outbound packets take the
    GSO code path, being encapsulated at layer 3, but encrypted
    in layer 2. validate_xmit_xfrm calls esp*_xmit for that.

    esp*_xmit was wrongfully detecting these packets as going
    through hardware crypto offload, while in fact they should
    be encrypted in software, causing plaintext leakage to
    the network, and also dropping at the receiver side.

    Perform the encryption in esp*_xmit, if the SA doesn't have
    a hardware offload_handle.

    Also, align esp6 code to esp4 logic.

    Fixes: fca11ebde3f0 ("esp4: Reorganize esp_output")
    Fixes: 383d0350f2cc ("esp6: Reorganize esp_output")
    Signed-off-by: Ilan Tayari
    Signed-off-by: Steffen Klassert

    Ilan Tayari
     
  • The check for xo being null is incorrect, currently it is checking
    for non-null, it should be checking for null.

    Detected with CoverityScan, CID#1429349 ("Dereference after null check")

    Fixes: 7862b4058b9f ("esp: Add gso handlers for esp4 and esp6")
    Signed-off-by: Colin Ian King
    Signed-off-by: Steffen Klassert

    Colin Ian King
     

14 Apr, 2017

3 commits

  • On IPsec hardware offloading, we already get a secpath with
    valid state attached when the packet enters the GRO handlers.
    So check for hardware offload and skip the state lookup in this
    case.

    Signed-off-by: Steffen Klassert

    Steffen Klassert
     
  • This patch extends the xfrm_type by an encap function pointer
    and implements esp4_gso_encap and esp6_gso_encap. These functions
    doing the basic esp encapsulation for a GSO packet. In case the
    GSO packet needs to be segmented in software, we add gso_segment
    functions. This codepath is going to be used on esp hardware
    offloads.

    Signed-off-by: Steffen Klassert

    Steffen Klassert
     
  • We need a fallback for ESP at layer 2, so split esp6_output
    into generic functions that can be used at layer 3 and layer 2
    and use them in esp_output. We also add esp6_xmit which is
    used for the layer 2 fallback.

    Signed-off-by: Steffen Klassert

    Steffen Klassert
     

15 Feb, 2017

1 commit

  • This patch adds GRO ifrastructure and callbacks for ESP on
    ipv4 and ipv6.

    In case the GRO layer detects an ESP packet, the
    esp{4,6}_gro_receive() function does a xfrm state lookup
    and calls the xfrm input layer if it finds a matching state.
    The packet will be decapsulated and reinjected it into layer 2.

    Signed-off-by: Steffen Klassert

    Steffen Klassert