]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
security: check for kstrdup() failure in lsm_append()
authorEric Biggers <ebiggers@google.com>
Tue, 17 Jul 2018 17:36:04 +0000 (10:36 -0700)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:49:10 +0000 (19:49 -0600)
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 <ebiggers@google.com>
Signed-off-by: James Morris <james.morris@microsoft.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
security/security.c

index 81b2336b533de0d594bf970933a2f1145aace2e8..87a9abfbd705e0c0458c75e31d2425d1aa5867b9 100644 (file)
@@ -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))