From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752093AbbLMPmq (ORCPT ); Sun, 13 Dec 2015 10:42:46 -0500 Received: from mga01.intel.com ([192.55.52.88]:15324 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751904AbbLMPmn (ORCPT ); Sun, 13 Dec 2015 10:42:43 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,422,1444719600"; d="scan'208";a="617283015" From: Jarkko Sakkinen To: Peter Huewe , Marcel Selhorst , David Howells , Mimi Zohar , Jonathan Corbet Cc: Jarkko Sakkinen , David Safford , James Morris , "Serge E. Hallyn" , linux-security-module@vger.kernel.org (open list:KEYS-TRUSTED), keyrings@vger.kernel.org (open list:KEYS-TRUSTED), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 1/3] keys, trusted: fix: *do not* allow duplicate key options Date: Sun, 13 Dec 2015 17:42:29 +0200 Message-Id: <1450021353-8775-2-git-send-email-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1450021353-8775-1-git-send-email-jarkko.sakkinen@linux.intel.com> References: <1450021353-8775-1-git-send-email-jarkko.sakkinen@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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: -- 2.5.0