30 May, 2018

1 commit

  • [ Upstream commit 9a3fb9fb84cc30577c1b012a6a3efda944684291 ]

    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 acf568ee859f ("xfrm: Reinject transport-mode packets ...")
    Signed-off-by: Steffen Klassert
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Steffen Klassert
     

19 May, 2018

1 commit

  • commit d16b46e4fd8bc6063624605f25b8c0835bb1fbe3 upstream.

    We do not need locking in xfrm_trans_queue because it is designed
    to use per-CPU buffers. However, the original code incorrectly
    used skb_queue_tail which takes the lock. This patch switches
    it to __skb_queue_tail instead.

    Reported-and-tested-by: Artem Savkov
    Fixes: acf568ee859f ("xfrm: Reinject transport-mode packets...")
    Signed-off-by: Herbert Xu
    Signed-off-by: Steffen Klassert
    Signed-off-by: Alistair Strachan
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     

03 Mar, 2018

1 commit

  • [ Upstream commit acf568ee859f098279eadf551612f103afdacb4e ]

    This is an old bugbear of mine:

    https://www.mail-archive.com/netdev@vger.kernel.org/msg03894.html

    By crafting special packets, it is possible to cause recursion
    in our kernel when processing transport-mode packets at levels
    that are only limited by packet size.

    The easiest one is with DNAT, but an even worse one is where
    UDP encapsulation is used in which case you just have to insert
    an UDP encapsulation header in between each level of recursion.

    This patch avoids this problem by reinjecting tranport-mode packets
    through a tasklet.

    Fixes: b05e106698d9 ("[IPV4/6]: Netfilter IPsec input hooks")
    Signed-off-by: Herbert Xu
    Signed-off-by: Steffen Klassert
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     

25 Feb, 2018

1 commit

  • [ Upstream commit 4ce3dbe397d7b6b15f272ae757c78c35e9e4b61d ]

    Code path when (encap_type < 0) does not verify the state is valid
    before progressing.

    This will result in a crash if, for instance, x->km.state ==
    XFRM_STATE_ACQ.

    Fixes: 7785bba299a8 ("esp: Add a software GRO codepath")
    Signed-off-by: Aviv Heller
    Signed-off-by: Yevgeny Kliteynik
    Signed-off-by: Steffen Klassert
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Aviv Heller
     

09 Nov, 2017

1 commit

  • Steffen Klassert says:

    ====================
    pull request (net): ipsec 2017-11-09

    1) Fix a use after free due to a reallocated skb head.
    From Florian Westphal.

    2) Fix sporadic lookup failures on labeled IPSEC.
    From Florian Westphal.

    3) Fix a stack out of bounds when a socket policy is applied
    to an IPv6 socket that sends IPv4 packets.

    Please pull or let me know if there are problems.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

02 Nov, 2017

2 commits

  • syzbot reports:
    BUG: KASAN: use-after-free in __xfrm_state_lookup+0x695/0x6b0
    Read of size 4 at addr ffff8801d434e538 by task syzkaller647520/2991
    [..]
    __xfrm_state_lookup+0x695/0x6b0 net/xfrm/xfrm_state.c:833
    xfrm_state_lookup+0x8a/0x160 net/xfrm/xfrm_state.c:1592
    xfrm_input+0x8e5/0x22f0 net/xfrm/xfrm_input.c:302

    The use-after-free is the ipv4 destination address, which points
    to an skb head area that has been reallocated:
    pskb_expand_head+0x36b/0x1210 net/core/skbuff.c:1494
    __pskb_pull_tail+0x14a/0x17c0 net/core/skbuff.c:1877
    pskb_may_pull include/linux/skbuff.h:2102 [inline]
    xfrm_parse_spi+0x3d3/0x4d0 net/xfrm/xfrm_input.c:170
    xfrm_input+0xce2/0x22f0 net/xfrm/xfrm_input.c:291

    so the real bug is that xfrm_parse_spi() uses pskb_may_pull, but
    for now do smaller workaround that makes xfrm_input fetch daddr
    after spi parsing.

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

    Florian Westphal
     
  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

13 Sep, 2017

1 commit

  • Can be reproduced with LTP tests:
    # icmp-uni-vti.sh -p ah -a sha256 -m tunnel -S fffffffe -k 1 -s 10

    IPv4:
    RIP: 0010:xfrm_input+0x7f9/0x870
    ...
    Call Trace:

    vti_input+0xaa/0x110 [ip_vti]
    ? skb_free_head+0x21/0x40
    vti_rcv+0x33/0x40 [ip_vti]
    xfrm4_ah_rcv+0x33/0x60
    ip_local_deliver_finish+0x94/0x1e0
    ip_local_deliver+0x6f/0xe0
    ? ip_route_input_noref+0x28/0x50
    ...

    # icmp-uni-vti.sh -6 -p ah -a sha256 -m tunnel -S fffffffe -k 1 -s 10
    IPv6:
    RIP: 0010:xfrm_input+0x7f9/0x870
    ...
    Call Trace:

    xfrm6_rcv_tnl+0x3c/0x40
    vti6_rcv+0xd5/0xe0 [ip6_vti]
    xfrm6_ah_rcv+0x33/0x60
    ip6_input_finish+0xee/0x460
    ip6_input+0x3f/0xb0
    ip6_rcv_finish+0x45/0xa0
    ipv6_rcv+0x34b/0x540

    xfrm_input() invokes xfrm_rcv_cb() -> vti_rcv_cb(), the last callback
    might call skb_scrub_packet(), which in turn can reset secpath.

    Fix it by adding a check that skb->sp is not NULL.

    Fixes: 7e9e9202bccc ("xfrm: Clear RX SKB secpath xfrm_offload")
    Signed-off-by: Alexey Kodanev
    Signed-off-by: Steffen Klassert

    Alexey Kodanev
     

31 Aug, 2017

1 commit

  • In conjunction with crypto offload [1], removing the ESP trailer by
    hardware can potentially improve the performance by avoiding (1) a
    cache miss incurred by reading the nexthdr field and (2) the necessity
    to calculate the csum value of the trailer in order to keep skb->csum
    valid.

    This patch introduces the changes to the xfrm stack and merely serves
    as an infrastructure. Subsequent patch to mlx5 driver will put this to
    a good use.

    [1] https://www.mail-archive.com/netdev@vger.kernel.org/msg175733.html

    Signed-off-by: Yossi Kuperman
    Signed-off-by: Steffen Klassert

    Yossi Kuperman
     

02 Aug, 2017

1 commit

  • If an incoming packet undergoes XFRM crypto-offload, its secpath is
    filled with xfrm_offload struct denoting offload information.

    If the SKB is then forwarded to a device which supports crypto-
    offload, the stack wrongfully attempts to offload it (even though
    the output SA may not exist on the device) due to the leftover
    secpath xo.

    Clear the ingress xo by zeroizing secpath->olen just before
    delivering the decapsulated packet to the network stack.

    Fixes: d77e38e612a0 ("xfrm: Add an IPsec hardware offloading API")
    Signed-off-by: Ilan Tayari
    Signed-off-by: Steffen Klassert

    Ilan Tayari
     

05 Jul, 2017

1 commit

  • refcount_t type and corresponding API should be
    used instead of atomic_t when the variable is used as
    a reference counter. This allows to avoid accidental
    refcounter overflows that might lead to use-after-free
    situations.

    Signed-off-by: Elena Reshetova
    Signed-off-by: Hans Liljestrand
    Signed-off-by: Kees Cook
    Signed-off-by: David Windsor
    Signed-off-by: David S. Miller

    Reshetova, Elena
     

03 May, 2017

1 commit

  • Pull networking updates from David Millar:
    "Here are some highlights from the 2065 networking commits that
    happened this development cycle:

    1) XDP support for IXGBE (John Fastabend) and thunderx (Sunil Kowuri)

    2) Add a generic XDP driver, so that anyone can test XDP even if they
    lack a networking device whose driver has explicit XDP support
    (me).

    3) Sparc64 now has an eBPF JIT too (me)

    4) Add a BPF program testing framework via BPF_PROG_TEST_RUN (Alexei
    Starovoitov)

    5) Make netfitler network namespace teardown less expensive (Florian
    Westphal)

    6) Add symmetric hashing support to nft_hash (Laura Garcia Liebana)

    7) Implement NAPI and GRO in netvsc driver (Stephen Hemminger)

    8) Support TC flower offload statistics in mlxsw (Arkadi Sharshevsky)

    9) Multiqueue support in stmmac driver (Joao Pinto)

    10) Remove TCP timewait recycling, it never really could possibly work
    well in the real world and timestamp randomization really zaps any
    hint of usability this feature had (Soheil Hassas Yeganeh)

    11) Support level3 vs level4 ECMP route hashing in ipv4 (Nikolay
    Aleksandrov)

    12) Add socket busy poll support to epoll (Sridhar Samudrala)

    13) Netlink extended ACK support (Johannes Berg, Pablo Neira Ayuso,
    and several others)

    14) IPSEC hw offload infrastructure (Steffen Klassert)"

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (2065 commits)
    tipc: refactor function tipc_sk_recv_stream()
    tipc: refactor function tipc_sk_recvmsg()
    net: thunderx: Optimize page recycling for XDP
    net: thunderx: Support for XDP header adjustment
    net: thunderx: Add support for XDP_TX
    net: thunderx: Add support for XDP_DROP
    net: thunderx: Add basic XDP support
    net: thunderx: Cleanup receive buffer allocation
    net: thunderx: Optimize CQE_TX handling
    net: thunderx: Optimize RBDR descriptor handling
    net: thunderx: Support for page recycling
    ipx: call ipxitf_put() in ioctl error path
    net: sched: add helpers to handle extended actions
    qed*: Fix issues in the ptp filter config implementation.
    qede: Fix concurrency issue in PTP Tx path processing.
    stmmac: Add support for SIMATIC IOT2000 platform
    net: hns: fix ethtool_get_strings overflow in hns driver
    tcp: fix wraparound issue in tcp_lp
    bpf, arm64: fix jit branch offset related to ldimm64
    bpf, arm64: implement jiting of BPF_XADD
    ...

    Linus Torvalds
     

27 Apr, 2017

1 commit

  • In xfrm_input() when called from GRO, async == 0, and we end up
    skipping the processing in xfrm4_transport_finish(). GRO path will
    always skip the NF_HOOK, so we don't need the special-case for
    !NETFILTER during GRO processing.

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

    Sabrina Dubroca
     

14 Apr, 2017

2 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 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
    Guy Shapiro
    Yossi Kuperman

    Signed-off-by: Guy Shapiro
    Signed-off-by: Ilan Tayari
    Signed-off-by: Yossi Kuperman
    Signed-off-by: Steffen Klassert

    Steffen Klassert
     

15 Feb, 2017

4 commits


09 Feb, 2017

1 commit


30 Jan, 2017

1 commit


11 Aug, 2016

1 commit

  • Running LTP 'icmp-uni-basic.sh -6 -p ipcomp -m tunnel' test over
    openvswitch + veth can trigger kernel panic:

    BUG: unable to handle kernel NULL pointer dereference
    at 00000000000000e0 IP: [] xfrm_input+0x82/0x750
    ...
    [] xfrm6_rcv_spi+0x1e/0x20
    [] xfrm6_tunnel_rcv+0x42/0x50 [xfrm6_tunnel]
    [] tunnel6_rcv+0x3e/0x8c [tunnel6]
    [] ip6_input_finish+0xd5/0x430
    [] ip6_input+0x33/0x90
    [] ip6_rcv_finish+0xa5/0xb0
    ...

    It seems that tunnel.ip6 can have garbage values and also dereferenced
    without a proper check, only tunnel.ip4 is being verified. Fix it by
    adding one more if block for AF_INET6 and initialize tunnel.ip6 with NULL
    inside xfrm6_rcv_spi() (which is similar to xfrm4_rcv_spi()).

    Fixes: 049f8e2 ("xfrm: Override skb->mark with tunnel->parm.i_key in xfrm_input")

    Signed-off-by: Alexey Kodanev
    Signed-off-by: Steffen Klassert

    Alexey Kodanev
     

25 Mar, 2016

1 commit

  • A crash is observed when a decrypted packet is processed in receive
    path. get_rps_cpus() tries to dereference the skb->dev fields but it
    appears that the device is freed from the poison pattern.

    [] get_rps_cpu+0x94/0x2f0
    [] netif_rx_internal+0x140/0x1cc
    [] netif_rx+0x74/0x94
    [] xfrm_input+0x754/0x7d0
    [] xfrm_input_resume+0x10/0x1c
    [] esp_input_done+0x20/0x30
    [] process_one_work+0x244/0x3fc
    [] worker_thread+0x2f8/0x418
    [] kthread+0xe0/0xec

    -013|get_rps_cpu(
    | dev = 0xFFFFFFC08B688000,
    | skb = 0xFFFFFFC0C76AAC00 -> (
    | dev = 0xFFFFFFC08B688000 -> (
    | name =
    "......................................................
    | name_hlist = (next = 0xAAAAAAAAAAAAAAAA, pprev =
    0xAAAAAAAAAAA

    Following are the sequence of events observed -

    - Encrypted packet in receive path from netdevice is queued
    - Encrypted packet queued for decryption (asynchronous)
    - Netdevice brought down and freed
    - Packet is decrypted and returned through callback in esp_input_done
    - Packet is queued again for process in network stack using netif_rx

    Since the device appears to have been freed, the dereference of
    skb->dev in get_rps_cpus() leads to an unhandled page fault
    exception.

    Fix this by holding on to device reference when queueing packets
    asynchronously and releasing the reference on call back return.

    v2: Make the change generic to xfrm as mentioned by Steffen and
    update the title to xfrm

    Suggested-by: Herbert Xu
    Signed-off-by: Jerome Stanislaus
    Signed-off-by: Subash Abhinov Kasiviswanathan
    Signed-off-by: David S. Miller

    subashab@codeaurora.org
     

23 Oct, 2015

1 commit


02 Jun, 2015

1 commit

  • Conflicts:
    drivers/net/phy/amd-xgbe-phy.c
    drivers/net/wireless/iwlwifi/Kconfig
    include/net/mac80211.h

    iwlwifi/Kconfig and mac80211.h were both trivial overlapping
    changes.

    The drivers/net/phy/amd-xgbe-phy.c file got removed in 'net-next' and
    the bug fix that happened on the 'net' side is already integrated
    into the rest of the amd-xgbe driver.

    Signed-off-by: David S. Miller

    David S. Miller
     

28 May, 2015

1 commit


24 Apr, 2015

1 commit


23 Apr, 2015

1 commit


07 Apr, 2015

1 commit

  • https://bugzilla.kernel.org/show_bug.cgi?id=95211

    Commit 70be6c91c86596ad2b60c73587880b47df170a41
    ("xfrm: Add xfrm_tunnel_skb_cb to the skb common buffer") added check
    which dereferences ->outer_mode too early but larval SAs don't have
    this pointer set (yet). So check for tunnel stuff later.

    Mike Noordermeer reported this bug and patiently applied all the debugging.

    Technically this is remote-oops-in-interrupt-context type of thing.

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000034
    IP: [] xfrm_input+0x3c2/0x5a0
    ...
    [] ? xfrm4_esp_rcv+0x36/0x70
    [] ? ip_local_deliver_finish+0x9a/0x200
    [] ? __netif_receive_skb_core+0x6f3/0x8f0
    ...

    RIP [] xfrm_input+0x3c2/0x5a0
    Kernel panic - not syncing: Fatal exception in interrupt

    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Steffen Klassert

    Alexey Dobriyan
     

14 Mar, 2014

1 commit


25 Feb, 2014

2 commits


02 Jan, 2014

1 commit


06 Jun, 2013

1 commit

  • When host ping its peer, ICMP echo request packet triggers IPsec
    policy, then host negotiates SA secret with its peer. After IKE
    installed SA for OUT direction, but before SA for IN direction
    installed, host get ICMP echo reply from its peer. At the time
    being, the SA state for IN direction could be XFRM_STATE_ACQ,
    then the received packet will be dropped after adding
    LINUX_MIB_XFRMINSTATEINVALID statistic.

    Adding a LINUX_MIB_XFRMACQUIREERROR statistic counter for such
    scenario when SA in larval state is much clearer for user than
    LINUX_MIB_XFRMINSTATEINVALID which indicates the SA is totally
    bad.

    Signed-off-by: Fan Du
    Signed-off-by: Steffen Klassert

    Fan Du
     

05 Sep, 2012

1 commit

  • ESN for esp is defined in RFC 4303. This RFC assumes that the
    sequence number counters are always up to date. However,
    this is not true if an async crypto algorithm is employed.

    If the sequence number counters are not up to date on sequence
    number check, we may incorrectly update the upper 32 bit of
    the sequence number. This leads to a DOS.

    We workaround this by comparing the upper sequence number,
    (used for authentication) with the upper sequence number
    computed after the async processing. We drop the packet
    if these numbers are different.

    To do this, we introduce a recheck function that does this
    check in the ESN case.

    Signed-off-by: Steffen Klassert
    Acked-by: Herbert Xu
    Signed-off-by: David S. Miller

    Steffen Klassert
     

22 Sep, 2011

1 commit

  • When asyncronous crypto algorithms are used, there might be many
    packets that passed the xfrm replay check, but the replay advance
    function is not called yet for these packets. So the replay check
    function would accept a replay of all of these packets. Also the
    system might crash if there are more packets in async processing
    than the size of the anti replay window, because the replay advance
    function would try to update the replay window beyond the bounds.

    This pach adds a second replay check after resuming from the async
    processing to fix these issues.

    Signed-off-by: Steffen Klassert
    Acked-by: Herbert Xu
    Signed-off-by: David S. Miller

    Steffen Klassert
     

29 Mar, 2011

1 commit


28 Mar, 2011

1 commit

  • Crypto requests might return asynchronous. In this case we leave
    the rcu protected region, so force a refcount on the skb's
    destination entry before we enter the xfrm type input/output
    handlers.

    This fixes a crash when a route is deleted whilst sending IPsec
    data that is transformed by an asynchronous algorithm.

    Signed-off-by: Steffen Klassert
    Signed-off-by: David S. Miller

    Steffen Klassert
     

14 Mar, 2011

2 commits