linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.10 01/25] Revert "evm: Fix memleak in init_desc"
@ 2022-07-20  1:15 Sasha Levin
  2022-07-20  1:15 ` [PATCH AUTOSEL 5.10 02/25] ARM: rockchip: Add missing of_node_put() in rockchip_suspend_init() Sasha Levin
                   ` (23 more replies)
  0 siblings, 24 replies; 27+ messages in thread
From: Sasha Levin @ 2022-07-20  1:15 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Xiu Jianfeng, Guozihua, Mimi Zohar, Sasha Levin, dmitry.kasatkin,
	jmorris, serge, linux-integrity, linux-security-module

From: Xiu Jianfeng <xiujianfeng@huawei.com>

[ Upstream commit 51dd64bb99e4478fc5280171acd8e1b529eadaf7 ]

This reverts commit ccf11dbaa07b328fa469415c362d33459c140a37.

Commit ccf11dbaa07b ("evm: Fix memleak in init_desc") said there is
memleak in init_desc. That may be incorrect, as we can see, tmp_tfm is
saved in one of the two global variables hmac_tfm or evm_tfm[hash_algo],
then if init_desc is called next time, there is no need to alloc tfm
again, so in the error path of kmalloc desc or crypto_shash_init(desc),
It is not a problem without freeing tmp_tfm.

And also that commit did not reset the global variable to NULL after
freeing tmp_tfm and this makes *tfm a dangling pointer which may cause a
UAF issue.

Reported-by: Guozihua (Scott) <guozihua@huawei.com>
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 security/integrity/evm/evm_crypto.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index a6dd47eb086d..168c3b78ac47 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -73,7 +73,7 @@ static struct shash_desc *init_desc(char type, uint8_t hash_algo)
 {
 	long rc;
 	const char *algo;
-	struct crypto_shash **tfm, *tmp_tfm = NULL;
+	struct crypto_shash **tfm, *tmp_tfm;
 	struct shash_desc *desc;
 
 	if (type == EVM_XATTR_HMAC) {
@@ -118,16 +118,13 @@ static struct shash_desc *init_desc(char type, uint8_t hash_algo)
 alloc:
 	desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(*tfm),
 			GFP_KERNEL);
-	if (!desc) {
-		crypto_free_shash(tmp_tfm);
+	if (!desc)
 		return ERR_PTR(-ENOMEM);
-	}
 
 	desc->tfm = *tfm;
 
 	rc = crypto_shash_init(desc);
 	if (rc) {
-		crypto_free_shash(tmp_tfm);
 		kfree(desc);
 		return ERR_PTR(rc);
 	}
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2022-07-20 16:37 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20  1:15 [PATCH AUTOSEL 5.10 01/25] Revert "evm: Fix memleak in init_desc" Sasha Levin
2022-07-20  1:15 ` [PATCH AUTOSEL 5.10 02/25] ARM: rockchip: Add missing of_node_put() in rockchip_suspend_init() Sasha Levin
2022-07-20  1:15 ` [PATCH AUTOSEL 5.10 03/25] x86/kvm/vmx: Make noinstr clean Sasha Levin
2022-07-20  1:15 ` [PATCH AUTOSEL 5.10 04/25] objtool: Treat .text.__x86.* as noinstr Sasha Levin
2022-07-20  1:15 ` [PATCH AUTOSEL 5.10 05/25] x86/bugs: Report AMD retbleed vulnerability Sasha Levin
2022-07-20  7:48   ` Greg KH
2022-07-20 16:37     ` Sasha Levin
2022-07-20  1:15 ` [PATCH AUTOSEL 5.10 06/25] x86/bugs: Keep a per-CPU IA32_SPEC_CTRL value Sasha Levin
2022-07-20  1:15 ` [PATCH AUTOSEL 5.10 07/25] x86/bugs: Optimize SPEC_CTRL MSR writes Sasha Levin
2022-07-20  1:15 ` [PATCH AUTOSEL 5.10 08/25] x86/cpu/amd: Add Spectral Chicken Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 09/25] x86/speculation: Fix RSB filling with CONFIG_RETPOLINE=n Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 10/25] wifi: mac80211: check skb_shared in ieee80211_8023_xmit() Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 11/25] wifi: mac80211: do not wake queues on a vif that is being stopped Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 12/25] wifi: cfg80211: Allow P2P client interface to indicate port authorization Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 13/25] drm: panel-orientation-quirks: Add quirk for the Lenovo Yoga Tablet 2 830 Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 14/25] nilfs2: fix incorrect masking of permission flags for symlinks Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 15/25] ASoC: ti: omap-mcbsp: duplicate sysfs error Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 16/25] ASoC: tlv320adcx140: Fix tx_mask check Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 17/25] ASoC: wm8998: Fix event generation for input mux Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 18/25] ASoC: cs47l92: Fix event generation for OUT1 demux Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 19/25] ASoC: arizona: Update arizona_aif_cfg_changed to use RX_BCLK_RATE Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 20/25] scsi: target: Fix WRITE_SAME No Data Buffer crash Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 21/25] platform/x86: asus-wmi: Add key mappings Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 22/25] platform/x86: intel_atomisp2_led: Also turn off the always-on camera LED on the Asus T100TAF Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 23/25] scsi: ufs: core: Fix missing clk change notification on host reset Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 24/25] scsi: pm80xx: Fix 'Unknown' max/min linkrate Sasha Levin
2022-07-20  1:16 ` [PATCH AUTOSEL 5.10 25/25] scsi: pm80xx: Set stopped phy's linkrate to Disabled Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).