]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - security/security.c
Sync to mainline for security submaintainers to work against
[karo-tx-linux.git] / security / security.c
index b9fea3999cf85f7181eceb5041468117f1376f32..38316bb28b16a65589d16e12e53d6fc798d5d11a 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/mount.h>
 #include <linux/personality.h>
 #include <linux/backing-dev.h>
+#include <linux/string.h>
 #include <net/flow.h>
 
 #define MAX_LSM_EVM_XATTR      2
@@ -86,6 +87,21 @@ static int __init choose_lsm(char *str)
 }
 __setup("security=", choose_lsm);
 
+static bool match_last_lsm(const char *list, const char *lsm)
+{
+       const char *last;
+
+       if (WARN_ON(!list || !lsm))
+               return false;
+       last = strrchr(list, ',');
+       if (last)
+               /* Pass the comma, strcmp() will check for '\0' */
+               last++;
+       else
+               last = list;
+       return !strcmp(last, lsm);
+}
+
 static int lsm_append(char *new, char **result)
 {
        char *cp;
@@ -93,6 +109,9 @@ static int lsm_append(char *new, char **result)
        if (*result == NULL) {
                *result = kstrdup(new, GFP_KERNEL);
        } else {
+               /* Check if it is the last registered name */
+               if (match_last_lsm(*result, new))
+                       return 0;
                cp = kasprintf(GFP_KERNEL, "%s,%s", *result, new);
                if (cp == NULL)
                        return -ENOMEM;