From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932570AbbLNNre (ORCPT ); Mon, 14 Dec 2015 08:47:34 -0500 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:43008 "EHLO e23smtp07.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932418AbbLNNrc (ORCPT ); Mon, 14 Dec 2015 08:47:32 -0500 X-IBM-Helo: d23dlp03.au.ibm.com X-IBM-MailFrom: zohar@linux.vnet.ibm.com X-IBM-RcptTo: keyrings@vger.kernel.org;linux-kernel@vger.kernel.org;linux-security-module@vger.kernel.org Message-ID: <1450100793.2702.42.camel@linux.vnet.ibm.com> Subject: Re: [PATCH v2 1/3] keys, trusted: fix: *do not* allow duplicate key options From: Mimi Zohar To: Jarkko Sakkinen Cc: Peter Huewe , Marcel Selhorst , David Howells , Jonathan Corbet , David Safford , James Morris , "Serge E. Hallyn" , "open list:KEYS-TRUSTED" , "open list:KEYS-TRUSTED" , open list Date: Mon, 14 Dec 2015 08:46:33 -0500 In-Reply-To: <1450021353-8775-2-git-send-email-jarkko.sakkinen@linux.intel.com> References: <1450021353-8775-1-git-send-email-jarkko.sakkinen@linux.intel.com> <1450021353-8775-2-git-send-email-jarkko.sakkinen@linux.intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.11 (3.12.11-1.fc21) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15121413-0025-0000-0000-00000295F685 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2015-12-13 at 17:42 +0200, Jarkko Sakkinen wrote: > The trusted keys option parsing allows specifying the same option > multiple times. The last option value specified is used. > > This can be seen as a regression because: > > * No gain. > * Could be problematic if there is be options dependent on other > options. Thanks, Jarkko. Although it should be obvious that patch limits the number of times an option can be specified, you should explicitly mention it in the patch description. Mimi > Reported-by: James Morris James Morris > Signed-off-by: Jarkko Sakkinen > --- > security/keys/trusted.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/security/keys/trusted.c b/security/keys/trusted.c > index 903dace..7c183c7 100644 > --- a/security/keys/trusted.c > +++ b/security/keys/trusted.c > @@ -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: