Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3638140pxb; Mon, 24 Jan 2022 14:07:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNjakPyX1szRQwWI5D3x5ZQXmWu7OLj1T3d1S5LZEZ6VtPcutC2Cftf7c1KyrXQ9BUChEN X-Received: by 2002:a63:1a66:: with SMTP id a38mr13186650pgm.466.1643062060307; Mon, 24 Jan 2022 14:07:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643062060; cv=none; d=google.com; s=arc-20160816; b=GrtnKEuAqohgvBNXgv5JHZ5rag47C0q8TITGcooV+LKdBgXl0DuE8YL+EiOXfJGr4w Cb0wttG9IKjk/8Q1Z0yQNUHM7VQlVuZsm8ZPK4A5Bl12LMvfdaWbtdKxPilvc6KbVoQN TqwSN/oHDbv4qDZD4gmdp5qI7loGMX0yQixDdCXFqSiRwjOMZdkWKIi/5f9Iyj9OGVfw tKwLfCRcqc1r4w595OIXNIar2V8Xg9cfsP3xFCL5JZ9EO12tWXuG5YopEksegJzbHh1d QITjAHnYBRVHGb0l7MHGhCOELfGz/8SSsJdw+doyVsdBUVK8dFBmZbxBG01AriFocZuH HBcg== 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=h5RV5j0Rq6+N9LAAJkK6SJp5V5l4dt63e6iKyVHvqic=; b=mwCJORwZVl/MtTOMPFApOVswEQnXChoMv5KYQEvic9gi4JmHRtPN82nPHouSWYdDm0 Ul4c8vSgkLuz5OpUNrOFdqpEYWA/I7dgxONInNCzQsfwpG5OXAT1roQqrkM7eXqIwcdy zTqDpBJ4v1/Dt3mmyfKIHtX+a9A9E64C47WfB2eKYIZJ1nNfVVVPRMlitgCuq8h8GTz1 04u3gErk5fM4vWBkbMW03fsx4IMZ8OkQxzc4EHyPW9oa2sRaIWXA5Zv7ivl09gdDL3g7 GBs3lubweeyj1fVmcnju+4i+iMMCPblUVPjIvpQuix1rO8wrgAfCtTE1OJ3WXHE90P0s NxHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RCJUdZHQ; 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 az9si260640plb.510.2022.01.24.14.07.21; Mon, 24 Jan 2022 14:07:40 -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=RCJUdZHQ; 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 S1576750AbiAXV4O (ORCPT + 99 others); Mon, 24 Jan 2022 16:56:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1450901AbiAXVVn (ORCPT ); Mon, 24 Jan 2022 16:21:43 -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 77369C0604E5; Mon, 24 Jan 2022 12:16:48 -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 180D5611CD; Mon, 24 Jan 2022 20:16:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E82FFC340E5; Mon, 24 Jan 2022 20:16:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055407; bh=bCeEhGuG5ikUYPFJUmhaGVS1E5RTYSCU4SD7VpkViHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RCJUdZHQ/pLiC5PAvPba2/YO0C/1Y3alcNai5qdaD9JTUf0txpquER3CWSab2snNH l/nD4VrCaH7Nq826tZPAebWGiDivbBQcZ9LRaKz4FVD8AJCirBD/mPjl2P8pLGPvw3 FswC6swmSiOmT1RvufpUVOPJ6TD2Om9a6GEeDuGw= 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 5.15 140/846] crypto: qce - fix uaf on qce_skcipher_register_one Date: Mon, 24 Jan 2022 19:34:17 +0100 Message-Id: <20220124184105.818639792@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 e9c195aaeed1b45c9012adbe29dedb6031e85aa8 ] Pointer alg points to sub field of tmpl, it is dereferenced after tmpl is freed. Fix this by accessing alg 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/skcipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 8ff10928f581d..3d27cd5210ef5 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -484,8 +484,8 @@ static int qce_skcipher_register_one(const struct qce_skcipher_def *def, ret = crypto_register_skcipher(alg); if (ret) { - kfree(tmpl); dev_err(qce->dev, "%s registration failed\n", alg->base.cra_name); + kfree(tmpl); return ret; } -- 2.34.1