aboutsummaryrefslogtreecommitdiffstats
path: root/security/security.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/security.c')
-rw-r--r--security/security.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/security/security.c b/security/security.c
index b9fea3999cf8..38316bb28b16 100644
--- a/security/security.c
+++ b/security/security.c
@@ -25,6 +25,7 @@
25#include <linux/mount.h> 25#include <linux/mount.h>
26#include <linux/personality.h> 26#include <linux/personality.h>
27#include <linux/backing-dev.h> 27#include <linux/backing-dev.h>
28#include <linux/string.h>
28#include <net/flow.h> 29#include <net/flow.h>
29 30
30#define MAX_LSM_EVM_XATTR 2 31#define MAX_LSM_EVM_XATTR 2
@@ -86,6 +87,21 @@ static int __init choose_lsm(char *str)
86} 87}
87__setup("security=", choose_lsm); 88__setup("security=", choose_lsm);
88 89
90static bool match_last_lsm(const char *list, const char *lsm)
91{
92 const char *last;
93
94 if (WARN_ON(!list || !lsm))
95 return false;
96 last = strrchr(list, ',');
97 if (last)
98 /* Pass the comma, strcmp() will check for '\0' */
99 last++;
100 else
101 last = list;
102 return !strcmp(last, lsm);
103}
104
89static int lsm_append(char *new, char **result) 105static int lsm_append(char *new, char **result)
90{ 106{
91 char *cp; 107 char *cp;
@@ -93,6 +109,9 @@ static int lsm_append(char *new, char **result)
93 if (*result == NULL) { 109 if (*result == NULL) {
94 *result = kstrdup(new, GFP_KERNEL); 110 *result = kstrdup(new, GFP_KERNEL);
95 } else { 111 } else {
112 /* Check if it is the last registered name */
113 if (match_last_lsm(*result, new))
114 return 0;
96 cp = kasprintf(GFP_KERNEL, "%s,%s", *result, new); 115 cp = kasprintf(GFP_KERNEL, "%s,%s", *result, new);
97 if (cp == NULL) 116 if (cp == NULL)
98 return -ENOMEM; 117 return -ENOMEM;