Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3545533pxb; Mon, 24 Jan 2022 11:54:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTPuq6YGcBgpdMne307dsmWpRetTW2aLDnozGl5Rvu4JfvJ9jeVCAlYb5x6FZ8fIRcJKIk X-Received: by 2002:a05:6a00:1794:b0:4ca:7659:e27a with SMTP id s20-20020a056a00179400b004ca7659e27amr1955408pfg.71.1643054063088; Mon, 24 Jan 2022 11:54:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054063; cv=none; d=google.com; s=arc-20160816; b=Yx0IpyO6IAScpBhUng9zBgHQ7X/1yllm3M/XhswYg94f/QuTj7ZdBgFnOKLw6DCxQD MrmV9V1kOobcx9kD3hZU8/HMehpgMzhPEaGRerJG+4cpmXPvUbe2aVJCv2Mw1GurUS6c 35ldvR81q4YGEo3ZjBdKH+5NNmiqjHi+1M1/wNdIoFLbweBK4NbCCXjPCN19Fomf4xsI siad72ZyCo3IJb39BqRU2WkEgjgzSF4CAHBkjIFZkgQPqB93f4Bsxq5QpzZktDC78YHT EPAcGUBdqU9FTN5RcUAr0xeeDgjxcAwmF9j/42PxLRhKrbHqTuadPTOIzRx7V2dWtnBe MnAQ== 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=rqSIOkl5YyvXziVEGmjhyyDEpmgKoXMBCIKUT0kTJq8=; b=q5SOzbhwP3nSUT7/iY/vjN5HL0HUkEK51CQ3jz/zl8iMmJs0lSCMOS5Ezkp6dcI+ie 9YLGsYp++zBeonLGFVYUlJ90rXE0UltkHGoYYar7KJqz/wvZOJpQl7oc8DgeTJgM6Jbh msu0eUGTbTV9hU+oSzHhx+faO2JW5YA+CqJxEnDwIUZm45zri00BryqAMOPsD3iRo8i5 36G77itYZoPbVbhDpH+I1mJMg7pRjaOqtmnxekwHMtGMQ7b9KdDb7AGvK/yHPtxiMsR4 yvR5TVLx9j8Xvl5oxv70/B5CupZfc3m42Iksnp75T1utDtpdl4SYdC9LHVPM7kEH2B2+ lZRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YmDrmxUQ; 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 x12si13684990plr.27.2022.01.24.11.54.10; Mon, 24 Jan 2022 11:54:23 -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=YmDrmxUQ; 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 S236115AbiAXStu (ORCPT + 99 others); Mon, 24 Jan 2022 13:49:50 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:47814 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245347AbiAXSs4 (ORCPT ); Mon, 24 Jan 2022 13:48:56 -0500 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 17389614D2; Mon, 24 Jan 2022 18:48:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0BC7C340E5; Mon, 24 Jan 2022 18:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050135; bh=26YtHU7kqqE3DgJGlBPSWEyd8gKGzX2a6Y5MUgSk8X0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YmDrmxUQYJ6T3auYIM8cTPolyTzQQsJnnpgoSCMgIzztnsiSEU5PS1PPWhn7ICXLL dmSA13z5lZROmWjElZ8xsOfCqTgsDcIKFh2pHVxox8aU+qmZnUoeyqjbfIpVPryeuw xF7De/IcZ/cF7aS0/TpFknsbu2WW0P/eISCmxcv4= 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.4 022/114] crypto: qce - fix uaf on qce_ahash_register_one Date: Mon, 24 Jan 2022 19:41:57 +0100 Message-Id: <20220124183927.812284771@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183927.095545464@linuxfoundation.org> References: <20220124183927.095545464@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 0c9973ec80ebd..da2e4c193953a 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -539,8 +539,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