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: v4.14.72~54 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=55bdb77aa991c2dfd107c4805e334ad571f73a4f;p=users%2Fjedix%2Flinux-maple.git security: check for kstrdup() failure in lsm_append() [ 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 --- diff --git a/security/security.c b/security/security.c index 4bf0f571b4ef..95a1a0f52880 100644 --- a/security/security.c +++ b/security/security.c @@ -111,6 +111,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))