--- zzzz-none-000/linux-4.4.271/net/ipv4/esp4.c 2021-06-03 06:22:09.000000000 +0000 +++ hawkeye-5590-750/linux-4.4.271/net/ipv4/esp4.c 2023-04-19 10:22:30.000000000 +0000 @@ -150,6 +150,7 @@ int assoclen; int extralen; __be64 seqno; + bool nosupp_sg; /* skb is pure payload to encrypt */ @@ -157,6 +158,12 @@ alen = crypto_aead_authsize(aead); ivlen = crypto_aead_ivsize(aead); + nosupp_sg = crypto_tfm_alg_flags(&aead->base) & CRYPTO_ALG_NOSUPP_SG; + if (nosupp_sg && skb_linearize(skb)) { + err = -ENOMEM; + goto error; + } + tfclen = 0; if (x->tfcpad) { struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb); @@ -431,6 +438,7 @@ u8 *iv; struct scatterlist *sg; int err = -EINVAL; + bool nosupp_sg; if (!pskb_may_pull(skb, sizeof(*esph) + ivlen)) goto out; @@ -438,6 +446,12 @@ if (elen <= 0) goto out; + nosupp_sg = crypto_tfm_alg_flags(&aead->base) & CRYPTO_ALG_NOSUPP_SG; + if (nosupp_sg && skb_linearize(skb)) { + err = -ENOMEM; + goto out; + } + err = skb_cow_data(skb, 0, &trailer); if (err < 0) goto out;