]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
esp4/6: Fix GSO path for non-GSO SW-crypto packets
authorIlan Tayari <ilant@mellanox.com>
Wed, 19 Apr 2017 05:41:01 +0000 (08:41 +0300)
committerSteffen Klassert <steffen.klassert@secunet.com>
Wed, 19 Apr 2017 05:48:57 +0000 (07:48 +0200)
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 <ilant@mellanox.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/ipv4/esp4_offload.c
net/ipv6/esp6_offload.c

index f3e33c26dc3389f37a888f1abd8d0b2c1953b2f4..e0666016a7642c017b4693d32723245adc484982 100644 (file)
@@ -209,8 +209,8 @@ static int esp_xmit(struct xfrm_state *x, struct sk_buff *skb,  netdev_features_
        if (!xo)
                return -EINVAL;
 
-       if (!(features & NETIF_F_HW_ESP) ||
-           (x->xso.offload_handle &&  x->xso.dev != skb->dev)) {
+       if (!(features & NETIF_F_HW_ESP) || !x->xso.offload_handle ||
+           (x->xso.dev != skb->dev)) {
                xo->flags |= CRYPTO_FALLBACK;
                hw_offload = false;
        }
index 95f10728abaaa84dd3f031e1bbf023dd05922d31..d950d43ba255442cf3079546a46b95693029f10c 100644 (file)
@@ -211,9 +211,10 @@ static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb,  netdev_features
        if (!xo)
                return -EINVAL;
 
-       if (!(features & NETIF_F_HW_ESP) ||
-           (x->xso.offload_handle &&  x->xso.dev != skb->dev)) {
+       if (!(features & NETIF_F_HW_ESP) || !x->xso.offload_handle ||
+           (x->xso.dev != skb->dev)) {
                xo->flags |= CRYPTO_FALLBACK;
+               hw_offload = false;
        }
 
        esp.proto = xo->proto;
@@ -254,7 +255,7 @@ static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb,  netdev_features
                ipv6_hdr(skb)->payload_len = htons(len);
        }
 
-       if (x->xso.offload_handle && !(xo->flags & CRYPTO_FALLBACK))
+       if (hw_offload)
                return 0;
 
        esp.seqno = cpu_to_be64(xo->seq.low + ((u64)xo->seq.hi << 32));