]> www.infradead.org Git - users/dwmw2/linux.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Sep 2018 06:39:36 +0000 (08:39 +0200)
[ 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>
security/security.c

index 68f46d849abea30d148dac3942d833c8ef80e114..4e572b38937d8923ea3ec06eff7a6cab7420bc1e 100644 (file)
@@ -118,6 +118,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))