Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3563813pxb; Mon, 24 Jan 2022 12:18:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3JSYrH04zPLZVpBznvXutYqJlHGPmDgHdcOAaZ5XnUTUPAmFp2vRmn9Sb/4M37VRBdmkR X-Received: by 2002:a17:903:230c:b0:14b:4c2d:e1fa with SMTP id d12-20020a170903230c00b0014b4c2de1famr6295010plh.24.1643055515609; Mon, 24 Jan 2022 12:18:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055515; cv=none; d=google.com; s=arc-20160816; b=ZxullkD4FEMBrc8yO9COa8miUeGVOWl9lTeZ1QLoG/ljGYnX5lLP2QZ/+DI40iYuip VA9lIfuQ4H2Sg4QVc7cQwGVX+cSAKq3gZOXC+qWGOqTJYlszN54sJzG9os+jsGD+7kl3 zEBvlm99R9Qs8mx5UuJESvxKaLDFc4a3NwJP+Du26/YNp5fDHQnWFssiojKdbZ/I3ECe J9SG4nE3a06rAT0F1C2NKzvxTafD6R3znZg6qbjtcVsMVrXepinmhN9+LorvAEhjpup2 CX9KhG7BPVnOnTo5vDPBpnkcW1SW1EruPDI7v0sSEntoxhtJouZj4+2gX6QFRI9028KQ 7CyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MuB1Qs+4D3iQHQEN/Cdsyx9qNOgj4SSVVrDN3u+t7O4=; b=JAqK7ShLdtefl+B8G/w5a6Rfs9rcFgYph1cwQEIdhO8pWwbbK7WtZmxMFLSJQaCzGK R5oPFPXIOQjNj8U8X3hz80VOZWaNjI7xC1zcwiSwDQFlacnWN2zgJpw/L2OV8+amh3pi mpscHWcEPT8UZswPwho/upPjOMhQjpGw7rUeAwikKlm1ELn8CtIMUwx+0q+6EzAHQEe0 3LujLgsmqZZlXqU+z7R5/Td2B0pHQSVH8ovK4HPL+Nm8xbMqlAZn4Ltottg4444uhpsY FTdvHwaU2lV1cz/+CncOweu9m2Hwg1s5wI+RjIrjSaGe28Kh9diHzkiE12nnPC5aCmMB /bng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SOmjTNJ1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d184si13173542pfa.118.2022.01.24.12.18.23; Mon, 24 Jan 2022 12:18:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SOmjTNJ1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345268AbiAXTXU (ORCPT + 99 others); Mon, 24 Jan 2022 14:23:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346472AbiAXTNY (ORCPT ); Mon, 24 Jan 2022 14:13:24 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C338C061763; Mon, 24 Jan 2022 11:05:57 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B02F7603DE; Mon, 24 Jan 2022 19:05:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E359C340E5; Mon, 24 Jan 2022 19:05:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051156; bh=2oJQ6ThJe2gdSrrrORMLu8Meow0HMdp7Eylv6Q47zng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SOmjTNJ1cDKyeNDilmDqnqy9zXJmSOudddDbFlINnjSAciBE5tWzUtc04UJnnPkVJ 0C4su13uolZcwy1wsKoo9jGJzjYWF7B/RAQrM8rZmaXXg0QfSKqFjKgUTq4VoDiMCV lnuh/J2i1tVd1N4LKVlu26Re3gvmyDvfFv8PdhLY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chengfeng Ye , Thara Gopinath , Herbert Xu , Sasha Levin Subject: [PATCH 4.14 040/186] crypto: qce - fix uaf on qce_ahash_register_one Date: Mon, 24 Jan 2022 19:41:55 +0100 Message-Id: <20220124183938.413364817@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chengfeng Ye [ Upstream commit b4cb4d31631912842eb7dce02b4350cbb7562d5e ] Pointer base points to sub field of tmpl, it is dereferenced after tmpl is freed. Fix this by accessing base before free tmpl. Fixes: ec8f5d8f ("crypto: qce - Qualcomm crypto engine driver") Signed-off-by: Chengfeng Ye Acked-by: Thara Gopinath Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/qce/sha.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 47e114ac09d01..ff1e788f92767 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -544,8 +544,8 @@ static int qce_ahash_register_one(const struct qce_ahash_def *def, ret = crypto_register_ahash(alg); if (ret) { - kfree(tmpl); dev_err(qce->dev, "%s registration failed\n", base->cra_name); + kfree(tmpl); return ret; } -- 2.34.1