crypto: talitos - Avoid consecutive packets going out with same IV

The SEC's h/w IV out implementation DMAs the trailing encrypted payload
block of the last encryption to ctx->iv. Since the last encryption may
still be pending completion, we can sufficiently prevent successive
packets from being transmitted with the same IV by xoring with sequence
number.

Also initialize alg_list earlier to prevent oopsing on a failed probe.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Signed-off-by: Lee Nipper <lee.nipper@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by Kim Phillips and committed by Herbert Xu ba95487d 6bfb09a1

+4 -2
+4 -2
drivers/crypto/talitos.c
··· 1157 1157 edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_MODE0_ENCRYPT; 1158 1158 1159 1159 memcpy(req->giv, ctx->iv, crypto_aead_ivsize(authenc)); 1160 + /* avoid consecutive packets going out with same IV */ 1161 + *(__be64 *)req->giv ^= cpu_to_be64(req->seq); 1160 1162 1161 1163 return ipsec_esp(edesc, areq, req->giv, req->seq, 1162 1164 ipsec_esp_encrypt_done); ··· 1451 1449 1452 1450 priv->ofdev = ofdev; 1453 1451 1452 + INIT_LIST_HEAD(&priv->alg_list); 1453 + 1454 1454 tasklet_init(&priv->done_task, talitos_done, (unsigned long)dev); 1455 1455 tasklet_init(&priv->error_task, talitos_error, (unsigned long)dev); 1456 1456 ··· 1579 1575 } 1580 1576 1581 1577 /* register crypto algorithms the device supports */ 1582 - INIT_LIST_HEAD(&priv->alg_list); 1583 - 1584 1578 for (i = 0; i < ARRAY_SIZE(driver_algs); i++) { 1585 1579 if (hw_supports(dev, driver_algs[i].desc_hdr_template)) { 1586 1580 struct talitos_crypto_alg *t_alg;