public inbox for linux-security-module@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] evm: zero-initialize the evm_xattrs read buffer
@ 2026-04-07  6:09 Pengpeng Hou
  2026-04-13 15:20 ` Roberto Sassu
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Pengpeng Hou @ 2026-04-07  6:09 UTC (permalink / raw)
  To: Mimi Zohar, Roberto Sassu
  Cc: Dmitry Kasatkin, Eric Snowberg, Paul Moore, James Morris,
	Serge Hallyn, linux-integrity, linux-security-module,
	linux-kernel, pengpeng

evm_read_xattrs() allocates size + 1 bytes, fills them from the list of
enabled xattrs and then passes strlen(temp) to simple_read_from_buffer().
When no configured xattrs are enabled, the fill loop stores nothing and
temp[0] remains uninitialized, so strlen() reads beyond initialized
memory.

Use kzalloc() so the empty-list case stays a valid empty C string.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 security/integrity/evm/evm_secfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/integrity/evm/evm_secfs.c b/security/integrity/evm/evm_secfs.c
index acd840461902..03d376fa36c2 100644
--- a/security/integrity/evm/evm_secfs.c
+++ b/security/integrity/evm/evm_secfs.c
@@ -145,7 +145,7 @@ static ssize_t evm_read_xattrs(struct file *filp, char __user *buf,
 		size += strlen(xattr->name) + 1;
 	}
 
-	temp = kmalloc(size + 1, GFP_KERNEL);
+	temp = kzalloc(size + 1, GFP_KERNEL);
 	if (!temp) {
 		mutex_unlock(&xattr_list_mutex);
 		return -ENOMEM;
-- 
2.50.1 (Apple Git-155)



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

end of thread, other threads:[~2026-04-24  8:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-07  6:09 [PATCH] evm: zero-initialize the evm_xattrs read buffer Pengpeng Hou
2026-04-13 15:20 ` Roberto Sassu
2026-04-17  3:06 ` Pengpeng Hou
2026-04-17 12:44 ` [PATCH v2] evm: terminate and bound " Pengpeng Hou
2026-04-17  8:30   ` Roberto Sassu
2026-04-23  9:31     ` Roberto Sassu
2026-04-23 15:30   ` [PATCH v3] " Pengpeng Hou
2026-04-24  8:13     ` Roberto Sassu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox