linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tomoyo: Avoid potential null pointer access
@ 2020-11-25 12:10 Zheng Zengkai
  2020-11-25 12:25 ` Tetsuo Handa
  0 siblings, 1 reply; 6+ messages in thread
From: Zheng Zengkai @ 2020-11-25 12:10 UTC (permalink / raw)
  To: takedakn, penguin-kernel, jmorris, serge
  Cc: linux-security-module, linux-kernel, zhengzengkai

Calls to kzalloc() should be null-checked in order to avoid
any potential failures or unnecessary code execution.
Fix this by adding null checks for _entry_ right after allocation.

Fixes: 57c2590fb7fd ("TOMOYO: Update profile structure")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
---
 security/tomoyo/common.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
index 4bee32bfe16d..99b4fafcb100 100644
--- a/security/tomoyo/common.c
+++ b/security/tomoyo/common.c
@@ -499,6 +499,8 @@ static struct tomoyo_profile *tomoyo_assign_profile
 	if (ptr)
 		return ptr;
 	entry = kzalloc(sizeof(*entry), GFP_NOFS);
+	if (!entry)
+		return NULL;
 	if (mutex_lock_interruptible(&tomoyo_policy_lock))
 		goto out;
 	ptr = ns->profile_ptr[profile];
-- 
2.20.1


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

end of thread, other threads:[~2020-11-27 10:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 12:10 [PATCH] tomoyo: Avoid potential null pointer access Zheng Zengkai
2020-11-25 12:25 ` Tetsuo Handa
2020-11-26  6:33   ` Zheng Zengkai
2020-11-26  6:57     ` Tetsuo Handa
2020-11-27  7:17       ` Zheng Zengkai
2020-11-27 10:52         ` Tetsuo Handa

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).