Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2328250ybb; Sun, 5 Apr 2020 04:51:37 -0700 (PDT) X-Google-Smtp-Source: APiQypLqD1VJ7xyfzJRZFm+jqLOcZtiG2hyl75mwWdYdH4pVlh9Qj5cMhPEziZW4xJft/pXpub6W X-Received: by 2002:a4a:aece:: with SMTP id v14mr13432430oon.48.1586087497492; Sun, 05 Apr 2020 04:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586087497; cv=none; d=google.com; s=arc-20160816; b=oIUT3hKffKpMo/3trUVxciKnvBT7cL6veBm3UMSLUpIed11Doilfth3pLmKhmxKApA E9I20tqzfARI7zdkAuwPln6yb+b6gm6hVS/vXMCg2xjrktzeVB95aIwcv793j/6VqE8g aXC857EAcdArOvHZDd5HGEZVYC1zcMD5U/SABawHmwzvmHOYXucYkvkutY3njNHsLY2m 8C+XWXN9qeeUqIXgBUKwehyG0/tUUcM2q+cs0deCXQXJOYYUy/Hz+Q/SfWspRYBVCuxq mQzGm5fIlKbetiMUbnjGWX/ip2mRV3cdQ5BJ7e2aPdX3N0PEHz51XFfX0kCY3GC/AEgW MrTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=O7Qw973Cl2ckb8zGRpvRyR1idarL5n/14hLKLcm8Szc=; b=XTGhFmSrVwZxdWACGEm7DvoVmQF7u4acymjTY8GFAhPQmE+DS/F0M7INUZrQ/lZuna tWwOqzQZwXPf53A+d0CVqh7mWISYivB1RFpW/jD777ArSEg31FoAyZDwqHTEr7bPioDq DA8xmyjOj2hpiO78U6AA1YPLGaULJOwgFLKAflJYC6d9OD5/GHy8iOpvh64OVeBjHf3E Ow1l274jRU6tJfjNULA7lf3rnbNUEnF0K/39IN8CxRStBPE6WuVCsC1LcyOQgbLlxQOG jGRZSKhxZC8QY5wriTw4MzKzGac09U6TxqAYWpu94dg9JKG/0ExNSG3VJBm6sTDUtbWA JLLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x74si6216019oif.119.2020.04.05.04.51.26; Sun, 05 Apr 2020 04:51:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726575AbgDELuo (ORCPT + 99 others); Sun, 5 Apr 2020 07:50:44 -0400 Received: from inva021.nxp.com ([92.121.34.21]:38574 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726550AbgDELuo (ORCPT ); Sun, 5 Apr 2020 07:50:44 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id D906E2008F4; Sun, 5 Apr 2020 13:50:42 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id CD0242008F3; Sun, 5 Apr 2020 13:50:42 +0200 (CEST) Received: from lorenz.ea.freescale.net (lorenz.ea.freescale.net [10.171.71.5]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 5FB5B20466; Sun, 5 Apr 2020 13:50:42 +0200 (CEST) From: Iuliana Prodan To: Herbert Xu , Horia Geanta , Aymen Sghaier Cc: "David S. Miller" , Silvano Di Ninno , Franck Lenormand , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx , Iuliana Prodan Subject: [PATCH 2/4] crypto: caam - fix use-after-free KASAN issue for AEAD algorithms Date: Sun, 5 Apr 2020 14:50:09 +0300 Message-Id: <1586087411-8505-3-git-send-email-iuliana.prodan@nxp.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1586087411-8505-1-git-send-email-iuliana.prodan@nxp.com> References: <1586087411-8505-1-git-send-email-iuliana.prodan@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Here's the KASAN report: BUG: KASAN: use-after-free in aead_crypt_done+0x60/0xd8 Read of size 1 at addr ffff00002303f014 by task swapper/0/0 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.6.0-rc1-00163-gd88dd5c-dirty #18 Hardware name: LS1046A RDB Board (DT) Call trace: dump_backtrace+0x0/0x260 show_stack+0x14/0x20 dump_stack+0xe8/0x144 print_address_description.isra.11+0x64/0x348 __kasan_report+0x11c/0x230 kasan_report+0xc/0x18 __asan_load1+0x5c/0x68 aead_crypt_done+0x60/0xd8 caam_jr_dequeue+0x390/0x608 ... Fixes: 1c2402266713 ("crypto: caam - add crypto_engine support for AEAD algorithms") Signed-off-by: Iuliana Prodan --- drivers/crypto/caam/caamalg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 5538539..6d746ef 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -973,8 +973,6 @@ static void aead_crypt_done(struct device *jrdev, u32 *desc, u32 err, aead_unmap(jrdev, edesc, req); - kfree(edesc); - /* * If no backlog flag, the completion of the request is done * by CAAM, not crypto engine. @@ -983,6 +981,8 @@ static void aead_crypt_done(struct device *jrdev, u32 *desc, u32 err, aead_request_complete(req, ecode); else crypto_finalize_aead_request(jrp->engine, req, ecode); + + kfree(edesc); } static void skcipher_crypt_done(struct device *jrdev, u32 *desc, u32 err, -- 2.1.0