mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									6674ff145e
								
							
						
					
					
						commit
						5208cc8342
					
				
					 1 changed files with 3 additions and 0 deletions
				
			
		| 
						 | 
					@ -736,11 +736,14 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
	unsigned long handle;
 | 
						unsigned long handle;
 | 
				
			||||||
	unsigned long lock;
 | 
						unsigned long lock;
 | 
				
			||||||
 | 
						unsigned long token_mask = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while ((p = strsep(&c, " \t"))) {
 | 
						while ((p = strsep(&c, " \t"))) {
 | 
				
			||||||
		if (*p == '\0' || *p == ' ' || *p == '\t')
 | 
							if (*p == '\0' || *p == ' ' || *p == '\t')
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		token = match_token(p, key_tokens, args);
 | 
							token = match_token(p, key_tokens, args);
 | 
				
			||||||
 | 
							if (test_and_set_bit(token, &token_mask))
 | 
				
			||||||
 | 
								return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		switch (token) {
 | 
							switch (token) {
 | 
				
			||||||
		case Opt_pcrinfo:
 | 
							case Opt_pcrinfo:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue