From: Eric Biggers Date: Tue, 17 Jul 2018 17:36:04 +0000 (-0700) Subject: security: check for kstrdup() failure in lsm_append() X-Git-Tag: Ubuntu-4.15.0-56.62~1826 X-Git-Url: https://git.proxmox.com/?p=mirror_ubuntu-bionic-kernel.git;a=commitdiff_plain;h=cf5fe9803edc6fdfc6efb32a6ef1104199376a46 security: check for kstrdup() failure in lsm_append() BugLink: https://bugs.launchpad.net/bugs/1836117 [ Upstream commit 87ea58433208d17295e200d56be5e2a4fe4ce7d6 ] lsm_append() should return -ENOMEM if memory allocation failed. Fixes: d69dece5f5b6 ("LSM: Add /sys/kernel/security/lsm") Signed-off-by: Eric Biggers Signed-off-by: James Morris Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman Signed-off-by: Kamal Mostafa Signed-off-by: Kleber Sacilotto de Souza --- diff --git a/security/security.c b/security/security.c index 81b2336b533d..87a9abfbd705 100644 --- a/security/security.c +++ b/security/security.c @@ -186,6 +186,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))