Skip to content

Commit 5208cc8

Browse files
author
Jarkko Sakkinen
committed
keys, trusted: fix: *do not* allow duplicate key options
The trusted keys option parsing allows specifying the same option multiple times. The last option value specified is used. This is problematic because: * No gain. * This makes complicated to specify options that are dependent on other options. This patch changes the behavior in a way that option can be specified only once. Reported-by: James Morris James Morris <jmorris@namei.org> Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Acked-by: Peter Huewe <peterhuewe@gmx.de>
1 parent 6674ff1 commit 5208cc8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

security/keys/trusted.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,11 +736,14 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
736736
int res;
737737
unsigned long handle;
738738
unsigned long lock;
739+
unsigned long token_mask = 0;
739740

740741
while ((p = strsep(&c, " \t"))) {
741742
if (*p == '\0' || *p == ' ' || *p == '\t')
742743
continue;
743744
token = match_token(p, key_tokens, args);
745+
if (test_and_set_bit(token, &token_mask))
746+
return -EINVAL;
744747

745748
switch (token) {
746749
case Opt_pcrinfo:

0 commit comments

Comments
 (0)