]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: talitos - Fix timing leak in ESP ICV verification
authorDavid Gstir <david@sigma-star.at>
Sun, 15 Nov 2015 16:14:42 +0000 (17:14 +0100)
committerLuis Henriques <luis.henriques@canonical.com>
Tue, 5 Jan 2016 11:22:18 +0000 (11:22 +0000)
commit 79960943fdc114fd4583c9ab164b5c89da7aa601 upstream.

Using non-constant time memcmp() makes the verification of the authentication
tag in the decrypt path vulnerable to timing attacks. Fix this by using
crypto_memneq() instead.

Signed-off-by: David Gstir <david@sigma-star.at>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
drivers/crypto/talitos.c

index 307931528eb20545e4d5879e0513b654ca13695b..da328ed633fb570c6319d56171fe0bdd14ac68fc 100644 (file)
@@ -870,8 +870,8 @@ static void ipsec_esp_decrypt_swauth_done(struct device *dev,
                        icvdata = &edesc->link_tbl[0];
 
                sg = sg_last(req->dst, edesc->dst_nents ? : 1);
-               err = memcmp(icvdata, (char *)sg_virt(sg) + sg->length -
-                            ctx->authsize, ctx->authsize) ? -EBADMSG : 0;
+               err = crypto_memneq(icvdata, (char *)sg_virt(sg) + sg->length -
+                                   ctx->authsize, ctx->authsize) ? -EBADMSG : 0;
        }
 
        kfree(edesc);