Skip to content

Commit 396bf4c

Browse files
committed
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu: - use-after-free in algif_aead - modular aesni regression when pcbc is modular but absent - bug causing IO page faults in ccp - double list add in ccp - NULL pointer dereference in qat (two patches) - panic in chcr - NULL pointer dereference in chcr - out-of-bound access in chcr * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: crypto: chcr - Fix key length for RFC4106 crypto: algif_aead - Fix kernel panic on list_del crypto: aesni - Fix failure when pcbc module is absent crypto: ccp - Fix double add when creating new DMA command crypto: ccp - Fix DMA operations when IOMMU is enabled crypto: chcr - Check device is allocated before use crypto: chcr - Fix panic on dma_unmap_sg crypto: qat - zero esram only for DH85x devices crypto: qat - fix bar discovery for c62x
2 parents d5adbfc + 7c2cf1c commit 396bf4c

File tree

11 files changed

+55
-45
lines changed

11 files changed

+55
-45
lines changed

arch/x86/crypto/aesni-intel_glue.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,9 +1085,9 @@ static void aesni_free_simds(void)
10851085
aesni_simd_skciphers[i]; i++)
10861086
simd_skcipher_free(aesni_simd_skciphers[i]);
10871087

1088-
for (i = 0; i < ARRAY_SIZE(aesni_simd_skciphers2) &&
1089-
aesni_simd_skciphers2[i].simd; i++)
1090-
simd_skcipher_free(aesni_simd_skciphers2[i].simd);
1088+
for (i = 0; i < ARRAY_SIZE(aesni_simd_skciphers2); i++)
1089+
if (aesni_simd_skciphers2[i].simd)
1090+
simd_skcipher_free(aesni_simd_skciphers2[i].simd);
10911091
}
10921092

10931093
static int __init aesni_init(void)
@@ -1168,7 +1168,7 @@ static int __init aesni_init(void)
11681168
simd = simd_skcipher_create_compat(algname, drvname, basename);
11691169
err = PTR_ERR(simd);
11701170
if (IS_ERR(simd))
1171-
goto unregister_simds;
1171+
continue;
11721172

11731173
aesni_simd_skciphers2[i].simd = simd;
11741174
}

crypto/algif_aead.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,9 @@ static int aead_recvmsg_sync(struct socket *sock, struct msghdr *msg, int flags)
661661
unlock:
662662
list_for_each_entry_safe(rsgl, tmp, &ctx->list, list) {
663663
af_alg_free_sg(&rsgl->sgl);
664+
list_del(&rsgl->list);
664665
if (rsgl != &ctx->first_rsgl)
665666
sock_kfree_s(sk, rsgl, sizeof(*rsgl));
666-
list_del(&rsgl->list);
667667
}
668668
INIT_LIST_HEAD(&ctx->list);
669669
aead_wmem_wakeup(sk);

drivers/crypto/ccp/ccp-dev-v5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ static irqreturn_t ccp5_irq_handler(int irq, void *data)
959959
static void ccp5_config(struct ccp_device *ccp)
960960
{
961961
/* Public side */
962-
iowrite32(0x00001249, ccp->io_regs + CMD5_REQID_CONFIG_OFFSET);
962+
iowrite32(0x0, ccp->io_regs + CMD5_REQID_CONFIG_OFFSET);
963963
}
964964

965965
static void ccp5other_config(struct ccp_device *ccp)

drivers/crypto/ccp/ccp-dev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ struct ccp_dma_chan {
238238
struct ccp_device *ccp;
239239

240240
spinlock_t lock;
241+
struct list_head created;
241242
struct list_head pending;
242243
struct list_head active;
243244
struct list_head complete;

drivers/crypto/ccp/ccp-dmaengine.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ static void ccp_free_chan_resources(struct dma_chan *dma_chan)
6363
ccp_free_desc_resources(chan->ccp, &chan->complete);
6464
ccp_free_desc_resources(chan->ccp, &chan->active);
6565
ccp_free_desc_resources(chan->ccp, &chan->pending);
66+
ccp_free_desc_resources(chan->ccp, &chan->created);
6667

6768
spin_unlock_irqrestore(&chan->lock, flags);
6869
}
@@ -273,6 +274,7 @@ static dma_cookie_t ccp_tx_submit(struct dma_async_tx_descriptor *tx_desc)
273274
spin_lock_irqsave(&chan->lock, flags);
274275

275276
cookie = dma_cookie_assign(tx_desc);
277+
list_del(&desc->entry);
276278
list_add_tail(&desc->entry, &chan->pending);
277279

278280
spin_unlock_irqrestore(&chan->lock, flags);
@@ -426,7 +428,7 @@ static struct ccp_dma_desc *ccp_create_desc(struct dma_chan *dma_chan,
426428

427429
spin_lock_irqsave(&chan->lock, sflags);
428430

429-
list_add_tail(&desc->entry, &chan->pending);
431+
list_add_tail(&desc->entry, &chan->created);
430432

431433
spin_unlock_irqrestore(&chan->lock, sflags);
432434

@@ -610,6 +612,7 @@ static int ccp_terminate_all(struct dma_chan *dma_chan)
610612
/*TODO: Purge the complete list? */
611613
ccp_free_desc_resources(chan->ccp, &chan->active);
612614
ccp_free_desc_resources(chan->ccp, &chan->pending);
615+
ccp_free_desc_resources(chan->ccp, &chan->created);
613616

614617
spin_unlock_irqrestore(&chan->lock, flags);
615618

@@ -679,6 +682,7 @@ int ccp_dmaengine_register(struct ccp_device *ccp)
679682
chan->ccp = ccp;
680683

681684
spin_lock_init(&chan->lock);
685+
INIT_LIST_HEAD(&chan->created);
682686
INIT_LIST_HEAD(&chan->pending);
683687
INIT_LIST_HEAD(&chan->active);
684688
INIT_LIST_HEAD(&chan->complete);

drivers/crypto/chelsio/chcr_algo.c

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ int chcr_handle_resp(struct crypto_async_request *req, unsigned char *input,
158158
case CRYPTO_ALG_TYPE_AEAD:
159159
ctx_req.req.aead_req = (struct aead_request *)req;
160160
ctx_req.ctx.reqctx = aead_request_ctx(ctx_req.req.aead_req);
161-
dma_unmap_sg(&u_ctx->lldi.pdev->dev, ctx_req.req.aead_req->dst,
161+
dma_unmap_sg(&u_ctx->lldi.pdev->dev, ctx_req.ctx.reqctx->dst,
162162
ctx_req.ctx.reqctx->dst_nents, DMA_FROM_DEVICE);
163163
if (ctx_req.ctx.reqctx->skb) {
164164
kfree_skb(ctx_req.ctx.reqctx->skb);
@@ -1362,8 +1362,7 @@ static struct sk_buff *create_authenc_wr(struct aead_request *req,
13621362
struct chcr_wr *chcr_req;
13631363
struct cpl_rx_phys_dsgl *phys_cpl;
13641364
struct phys_sge_parm sg_param;
1365-
struct scatterlist *src, *dst;
1366-
struct scatterlist src_sg[2], dst_sg[2];
1365+
struct scatterlist *src;
13671366
unsigned int frags = 0, transhdr_len;
13681367
unsigned int ivsize = crypto_aead_ivsize(tfm), dst_size = 0;
13691368
unsigned int kctx_len = 0;
@@ -1383,19 +1382,21 @@ static struct sk_buff *create_authenc_wr(struct aead_request *req,
13831382

13841383
if (sg_nents_for_len(req->src, req->assoclen + req->cryptlen) < 0)
13851384
goto err;
1386-
src = scatterwalk_ffwd(src_sg, req->src, req->assoclen);
1387-
dst = src;
1385+
src = scatterwalk_ffwd(reqctx->srcffwd, req->src, req->assoclen);
1386+
reqctx->dst = src;
1387+
13881388
if (req->src != req->dst) {
13891389
err = chcr_copy_assoc(req, aeadctx);
13901390
if (err)
13911391
return ERR_PTR(err);
1392-
dst = scatterwalk_ffwd(dst_sg, req->dst, req->assoclen);
1392+
reqctx->dst = scatterwalk_ffwd(reqctx->dstffwd, req->dst,
1393+
req->assoclen);
13931394
}
13941395
if (get_aead_subtype(tfm) == CRYPTO_ALG_SUB_TYPE_AEAD_NULL) {
13951396
null = 1;
13961397
assoclen = 0;
13971398
}
1398-
reqctx->dst_nents = sg_nents_for_len(dst, req->cryptlen +
1399+
reqctx->dst_nents = sg_nents_for_len(reqctx->dst, req->cryptlen +
13991400
(op_type ? -authsize : authsize));
14001401
if (reqctx->dst_nents <= 0) {
14011402
pr_err("AUTHENC:Invalid Destination sg entries\n");
@@ -1460,7 +1461,7 @@ static struct sk_buff *create_authenc_wr(struct aead_request *req,
14601461
sg_param.obsize = req->cryptlen + (op_type ? -authsize : authsize);
14611462
sg_param.qid = qid;
14621463
sg_param.align = 0;
1463-
if (map_writesg_phys_cpl(&u_ctx->lldi.pdev->dev, phys_cpl, dst,
1464+
if (map_writesg_phys_cpl(&u_ctx->lldi.pdev->dev, phys_cpl, reqctx->dst,
14641465
&sg_param))
14651466
goto dstmap_fail;
14661467

@@ -1711,8 +1712,7 @@ static struct sk_buff *create_aead_ccm_wr(struct aead_request *req,
17111712
struct chcr_wr *chcr_req;
17121713
struct cpl_rx_phys_dsgl *phys_cpl;
17131714
struct phys_sge_parm sg_param;
1714-
struct scatterlist *src, *dst;
1715-
struct scatterlist src_sg[2], dst_sg[2];
1715+
struct scatterlist *src;
17161716
unsigned int frags = 0, transhdr_len, ivsize = AES_BLOCK_SIZE;
17171717
unsigned int dst_size = 0, kctx_len;
17181718
unsigned int sub_type;
@@ -1728,17 +1728,19 @@ static struct sk_buff *create_aead_ccm_wr(struct aead_request *req,
17281728
if (sg_nents_for_len(req->src, req->assoclen + req->cryptlen) < 0)
17291729
goto err;
17301730
sub_type = get_aead_subtype(tfm);
1731-
src = scatterwalk_ffwd(src_sg, req->src, req->assoclen);
1732-
dst = src;
1731+
src = scatterwalk_ffwd(reqctx->srcffwd, req->src, req->assoclen);
1732+
reqctx->dst = src;
1733+
17331734
if (req->src != req->dst) {
17341735
err = chcr_copy_assoc(req, aeadctx);
17351736
if (err) {
17361737
pr_err("AAD copy to destination buffer fails\n");
17371738
return ERR_PTR(err);
17381739
}
1739-
dst = scatterwalk_ffwd(dst_sg, req->dst, req->assoclen);
1740+
reqctx->dst = scatterwalk_ffwd(reqctx->dstffwd, req->dst,
1741+
req->assoclen);
17401742
}
1741-
reqctx->dst_nents = sg_nents_for_len(dst, req->cryptlen +
1743+
reqctx->dst_nents = sg_nents_for_len(reqctx->dst, req->cryptlen +
17421744
(op_type ? -authsize : authsize));
17431745
if (reqctx->dst_nents <= 0) {
17441746
pr_err("CCM:Invalid Destination sg entries\n");
@@ -1777,7 +1779,7 @@ static struct sk_buff *create_aead_ccm_wr(struct aead_request *req,
17771779
sg_param.obsize = req->cryptlen + (op_type ? -authsize : authsize);
17781780
sg_param.qid = qid;
17791781
sg_param.align = 0;
1780-
if (map_writesg_phys_cpl(&u_ctx->lldi.pdev->dev, phys_cpl, dst,
1782+
if (map_writesg_phys_cpl(&u_ctx->lldi.pdev->dev, phys_cpl, reqctx->dst,
17811783
&sg_param))
17821784
goto dstmap_fail;
17831785

@@ -1809,8 +1811,7 @@ static struct sk_buff *create_gcm_wr(struct aead_request *req,
18091811
struct chcr_wr *chcr_req;
18101812
struct cpl_rx_phys_dsgl *phys_cpl;
18111813
struct phys_sge_parm sg_param;
1812-
struct scatterlist *src, *dst;
1813-
struct scatterlist src_sg[2], dst_sg[2];
1814+
struct scatterlist *src;
18141815
unsigned int frags = 0, transhdr_len;
18151816
unsigned int ivsize = AES_BLOCK_SIZE;
18161817
unsigned int dst_size = 0, kctx_len;
@@ -1832,13 +1833,14 @@ static struct sk_buff *create_gcm_wr(struct aead_request *req,
18321833
if (sg_nents_for_len(req->src, req->assoclen + req->cryptlen) < 0)
18331834
goto err;
18341835

1835-
src = scatterwalk_ffwd(src_sg, req->src, req->assoclen);
1836-
dst = src;
1836+
src = scatterwalk_ffwd(reqctx->srcffwd, req->src, req->assoclen);
1837+
reqctx->dst = src;
18371838
if (req->src != req->dst) {
18381839
err = chcr_copy_assoc(req, aeadctx);
18391840
if (err)
18401841
return ERR_PTR(err);
1841-
dst = scatterwalk_ffwd(dst_sg, req->dst, req->assoclen);
1842+
reqctx->dst = scatterwalk_ffwd(reqctx->dstffwd, req->dst,
1843+
req->assoclen);
18421844
}
18431845

18441846
if (!req->cryptlen)
@@ -1848,7 +1850,7 @@ static struct sk_buff *create_gcm_wr(struct aead_request *req,
18481850
crypt_len = AES_BLOCK_SIZE;
18491851
else
18501852
crypt_len = req->cryptlen;
1851-
reqctx->dst_nents = sg_nents_for_len(dst, req->cryptlen +
1853+
reqctx->dst_nents = sg_nents_for_len(reqctx->dst, req->cryptlen +
18521854
(op_type ? -authsize : authsize));
18531855
if (reqctx->dst_nents <= 0) {
18541856
pr_err("GCM:Invalid Destination sg entries\n");
@@ -1923,7 +1925,7 @@ static struct sk_buff *create_gcm_wr(struct aead_request *req,
19231925
sg_param.obsize = req->cryptlen + (op_type ? -authsize : authsize);
19241926
sg_param.qid = qid;
19251927
sg_param.align = 0;
1926-
if (map_writesg_phys_cpl(&u_ctx->lldi.pdev->dev, phys_cpl, dst,
1928+
if (map_writesg_phys_cpl(&u_ctx->lldi.pdev->dev, phys_cpl, reqctx->dst,
19271929
&sg_param))
19281930
goto dstmap_fail;
19291931

@@ -1937,7 +1939,8 @@ static struct sk_buff *create_gcm_wr(struct aead_request *req,
19371939
write_sg_to_skb(skb, &frags, src, req->cryptlen);
19381940
} else {
19391941
aes_gcm_empty_pld_pad(req->dst, authsize - 1);
1940-
write_sg_to_skb(skb, &frags, dst, crypt_len);
1942+
write_sg_to_skb(skb, &frags, reqctx->dst, crypt_len);
1943+
19411944
}
19421945

19431946
create_wreq(ctx, chcr_req, req, skb, kctx_len, size, 1,
@@ -2189,8 +2192,8 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key,
21892192
unsigned int ck_size;
21902193
int ret = 0, key_ctx_size = 0;
21912194

2192-
if (get_aead_subtype(aead) ==
2193-
CRYPTO_ALG_SUB_TYPE_AEAD_RFC4106) {
2195+
if (get_aead_subtype(aead) == CRYPTO_ALG_SUB_TYPE_AEAD_RFC4106 &&
2196+
keylen > 3) {
21942197
keylen -= 4; /* nonce/salt is present in the last 4 bytes */
21952198
memcpy(aeadctx->salt, key + keylen, 4);
21962199
}

drivers/crypto/chelsio/chcr_core.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,22 @@ static struct cxgb4_uld_info chcr_uld_info = {
5252
int assign_chcr_device(struct chcr_dev **dev)
5353
{
5454
struct uld_ctx *u_ctx;
55+
int ret = -ENXIO;
5556

5657
/*
5758
* Which device to use if multiple devices are available TODO
5859
* May be select the device based on round robin. One session
5960
* must go to the same device to maintain the ordering.
6061
*/
6162
mutex_lock(&dev_mutex); /* TODO ? */
62-
u_ctx = list_first_entry(&uld_ctx_list, struct uld_ctx, entry);
63-
if (!u_ctx) {
64-
mutex_unlock(&dev_mutex);
65-
return -ENXIO;
63+
list_for_each_entry(u_ctx, &uld_ctx_list, entry)
64+
if (u_ctx && u_ctx->dev) {
65+
*dev = u_ctx->dev;
66+
ret = 0;
67+
break;
6668
}
67-
68-
*dev = u_ctx->dev;
6969
mutex_unlock(&dev_mutex);
70-
return 0;
70+
return ret;
7171
}
7272

7373
static int chcr_dev_add(struct uld_ctx *u_ctx)
@@ -202,10 +202,8 @@ static int chcr_uld_state_change(void *handle, enum cxgb4_state state)
202202

203203
static int __init chcr_crypto_init(void)
204204
{
205-
if (cxgb4_register_uld(CXGB4_ULD_CRYPTO, &chcr_uld_info)) {
205+
if (cxgb4_register_uld(CXGB4_ULD_CRYPTO, &chcr_uld_info))
206206
pr_err("ULD register fail: No chcr crypto support in cxgb4");
207-
return -1;
208-
}
209207

210208
return 0;
211209
}

drivers/crypto/chelsio/chcr_crypto.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ struct ablk_ctx {
158158
};
159159
struct chcr_aead_reqctx {
160160
struct sk_buff *skb;
161+
struct scatterlist *dst;
162+
struct scatterlist srcffwd[2];
163+
struct scatterlist dstffwd[2];
161164
short int dst_nents;
162165
u16 verify;
163166
u8 iv[CHCR_MAX_CRYPTO_IV_LEN];

drivers/crypto/qat/qat_c62x/adf_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
233233
&hw_data->accel_capabilities_mask);
234234

235235
/* Find and map all the device's BARS */
236-
i = 0;
236+
i = (hw_data->fuses & ADF_DEVICE_FUSECTL_MASK) ? 1 : 0;
237237
bar_mask = pci_select_bars(pdev, IORESOURCE_MEM);
238238
for_each_set_bit(bar_nr, (const unsigned long *)&bar_mask,
239239
ADF_PCI_MAX_BARS * 2) {

drivers/crypto/qat/qat_common/adf_accel_devices.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#define ADF_ERRSOU5 (0x3A000 + 0xD8)
7070
#define ADF_DEVICE_FUSECTL_OFFSET 0x40
7171
#define ADF_DEVICE_LEGFUSE_OFFSET 0x4C
72+
#define ADF_DEVICE_FUSECTL_MASK 0x80000000
7273
#define ADF_PCI_MAX_BARS 3
7374
#define ADF_DEVICE_NAME_LENGTH 32
7475
#define ADF_ETR_MAX_RINGS_PER_BANK 16

drivers/crypto/qat/qat_common/qat_hal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ static int qat_hal_init_esram(struct icp_qat_fw_loader_handle *handle)
456456
unsigned int csr_val;
457457
int times = 30;
458458

459-
if (handle->pci_dev->device == ADF_C3XXX_PCI_DEVICE_ID)
459+
if (handle->pci_dev->device != ADF_DH895XCC_PCI_DEVICE_ID)
460460
return 0;
461461

462462
csr_val = ADF_CSR_RD(csr_addr, 0);
@@ -716,7 +716,7 @@ int qat_hal_init(struct adf_accel_dev *accel_dev)
716716
(void __iomem *)((uintptr_t)handle->hal_cap_ae_xfer_csr_addr_v +
717717
LOCAL_TO_XFER_REG_OFFSET);
718718
handle->pci_dev = pci_info->pci_dev;
719-
if (handle->pci_dev->device != ADF_C3XXX_PCI_DEVICE_ID) {
719+
if (handle->pci_dev->device == ADF_DH895XCC_PCI_DEVICE_ID) {
720720
sram_bar =
721721
&pci_info->pci_bars[hw_data->get_sram_bar_id(hw_data)];
722722
handle->hal_sram_addr_v = sram_bar->virt_addr;

0 commit comments

Comments
 (0)