keys, trusted: fix: *do not* allow duplicate key options
[cascardo/linux.git] / security / keys / trusted.c
index 903dace..7c183c7 100644 (file)
@@ -736,11 +736,14 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
        int res;
        unsigned long handle;
        unsigned long lock;
+       unsigned long token_mask = 0;
 
        while ((p = strsep(&c, " \t"))) {
                if (*p == '\0' || *p == ' ' || *p == '\t')
                        continue;
                token = match_token(p, key_tokens, args);
+               if (test_and_set_bit(token, &token_mask))
+                       return -EINVAL;
 
                switch (token) {
                case Opt_pcrinfo: