Skip to content

Commit 09dcdba

Browse files
committed
Merge tag 'v6.8-p6' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu: "Fix potential use-after-frees in rk3288 and sun8i-ce" * tag 'v6.8-p6' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: crypto: rk3288 - Fix use after free in unprepare crypto: sun8i-ce - Fix use after free in unprepare
2 parents 5847c97 + c0afb6b commit 09dcdba

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -299,22 +299,6 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req
299299
return err;
300300
}
301301

302-
static void sun8i_ce_cipher_run(struct crypto_engine *engine, void *areq)
303-
{
304-
struct skcipher_request *breq = container_of(areq, struct skcipher_request, base);
305-
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(breq);
306-
struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);
307-
struct sun8i_ce_dev *ce = op->ce;
308-
struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(breq);
309-
int flow, err;
310-
311-
flow = rctx->flow;
312-
err = sun8i_ce_run_task(ce, flow, crypto_tfm_alg_name(breq->base.tfm));
313-
local_bh_disable();
314-
crypto_finalize_skcipher_request(engine, breq, err);
315-
local_bh_enable();
316-
}
317-
318302
static void sun8i_ce_cipher_unprepare(struct crypto_engine *engine,
319303
void *async_req)
320304
{
@@ -360,6 +344,23 @@ static void sun8i_ce_cipher_unprepare(struct crypto_engine *engine,
360344
dma_unmap_single(ce->dev, rctx->addr_key, op->keylen, DMA_TO_DEVICE);
361345
}
362346

347+
static void sun8i_ce_cipher_run(struct crypto_engine *engine, void *areq)
348+
{
349+
struct skcipher_request *breq = container_of(areq, struct skcipher_request, base);
350+
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(breq);
351+
struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);
352+
struct sun8i_ce_dev *ce = op->ce;
353+
struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(breq);
354+
int flow, err;
355+
356+
flow = rctx->flow;
357+
err = sun8i_ce_run_task(ce, flow, crypto_tfm_alg_name(breq->base.tfm));
358+
sun8i_ce_cipher_unprepare(engine, areq);
359+
local_bh_disable();
360+
crypto_finalize_skcipher_request(engine, breq, err);
361+
local_bh_enable();
362+
}
363+
363364
int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq)
364365
{
365366
int err = sun8i_ce_cipher_prepare(engine, areq);
@@ -368,7 +369,6 @@ int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq)
368369
return err;
369370

370371
sun8i_ce_cipher_run(engine, areq);
371-
sun8i_ce_cipher_unprepare(engine, areq);
372372
return 0;
373373
}
374374

drivers/crypto/rockchip/rk3288_crypto_ahash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,12 @@ static int rk_hash_run(struct crypto_engine *engine, void *breq)
332332
theend:
333333
pm_runtime_put_autosuspend(rkc->dev);
334334

335+
rk_hash_unprepare(engine, breq);
336+
335337
local_bh_disable();
336338
crypto_finalize_hash_request(engine, breq, err);
337339
local_bh_enable();
338340

339-
rk_hash_unprepare(engine, breq);
340-
341341
return 0;
342342
}
343343

0 commit comments

Comments
 (0)