Thread (2 messages) 2 messages, 2 authors, 2018-07-18
DORMANTno replies

[PATCH] security: check for kstrdup() failure in lsm_append()

From: jmorris@namei.org (James Morris)
Date: 2018-07-18 04:28:40

On Tue, 17 Jul 2018, Eric Biggers wrote:
quoted hunk ↗ jump to hunk
lsm_append() should return -ENOMEM if memory allocation failed.

Fixes: d69dece5f5b6 ("LSM: Add /sys/kernel/security/lsm")
Signed-off-by: Eric Biggers <redacted>
---
 security/security.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/security/security.c b/security/security.c
index 03e98be76d58..259ff593d543 100644
--- a/security/security.c
+++ b/security/security.c
@@ -121,6 +121,8 @@ static int lsm_append(char *new, char **result)
 
 	if (*result == NULL) {
 		*result = kstrdup(new, GFP_KERNEL);
+		if (*result == NULL)
+			return -ENOMEM;
 	} else {
 		/* Check if it is the last registered name */
 		if (match_last_lsm(*result, new))
Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next-general


-- 
James Morris
[off-list ref]

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help