Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5972678ybl; Tue, 10 Dec 2019 14:44:44 -0800 (PST) X-Google-Smtp-Source: APXvYqyxhsUEhZEktHucQSlX9XFUDQVGO4cJYScP12eDRT32KQkla6hKS8t/7GkXGPRfIhBdSz7b X-Received: by 2002:aca:758c:: with SMTP id q134mr348217oic.33.1576017884327; Tue, 10 Dec 2019 14:44:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576017884; cv=none; d=google.com; s=arc-20160816; b=ekdLuU7/LbVy5NqVTm4/5y/UWoaaBp9yPgZvcumfh5NqsOTtOIWGJz7WPOUhlxDm4o bJggxd8H6iEjBPzbPspOANwEO1Ck1n+D7y57aFxMTd3F36ZJGM431S/132K2Mz7EE51y fNJoCd5xPbWGTHvomLG+OuSn6vayJzu1uK7uV8vQLfgEbdA4+PC19/DwNksb5D3+ERtA re9Ph/+X5LCywoNcB5dG3wGPs6TqLPgZhjmweueBbGSGlF/bQtJl0L9k5Bx3yO4l75K5 zFmDeHlJWuTCGmSY0W4YmgQTdpnMbPVPic8YHtp1cvMGfqHMjs8hDFE+Ya1fCsvaqvJN Oo6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:cc:to:from:subject; bh=8hLRKBE6LkIWoc4iDx6zvjuuRP1pm6lm+xek7AXVrZw=; b=aGu5j07c5RKuAt8YRMcNuGap01f/W2k4Tfpjh60YEBi16vHB7rLhx7gavtHBM2wrUn I1ziDFq8mdK+RJe9EAziItzHLSdmn2J+kmpK5C3UuFquHhDyHsWwODaQNMtsN4bw+mN2 Y/erTOMJWQtAq7NqC9tGuIhTVsohWqQE2GWzKqA3tqnn7mXX3t3kKq0jacbdKIcfGtPC Srvpc1Dy+LNYfdruQeov2meFAO1xtvU2rcOMdr3xVVC6Cq+814S+4VXAvIXSytxXoryT jcop8+bw36c6Bcf/X3QQx9V7RNpP9BnE1SCDHmTzPL1NhdFAL6+xEfcYcxzqxfK30h7w al5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w64si1797oib.185.2019.12.10.14.44.32; Tue, 10 Dec 2019 14:44:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728988AbfLJWn0 (ORCPT + 99 others); Tue, 10 Dec 2019 17:43:26 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:64400 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727265AbfLJWnX (ORCPT ); Tue, 10 Dec 2019 17:43:23 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xBAMbYfZ131423 for ; Tue, 10 Dec 2019 17:43:22 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wrt12snuh-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 10 Dec 2019 17:43:22 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Dec 2019 22:43:20 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 10 Dec 2019 22:43:16 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xBAMhF5l39190700 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2019 22:43:15 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5FCCCA405E; Tue, 10 Dec 2019 22:43:15 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 46F9DA4069; Tue, 10 Dec 2019 22:43:14 +0000 (GMT) Received: from localhost.localdomain (unknown [9.80.214.111]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 10 Dec 2019 22:43:14 +0000 (GMT) Subject: Re: [PATCH v10 4/6] KEYS: Call the IMA hook to measure keys From: Mimi Zohar To: Lakshmi Ramasubramanian , linux-integrity@vger.kernel.org Cc: eric.snowberg@oracle.com, dhowells@redhat.com, mathew.j.martineau@linux.intel.com, matthewgarrett@google.com, sashal@kernel.org, jamorris@linux.microsoft.com, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org Date: Tue, 10 Dec 2019 17:43:13 -0500 In-Reply-To: <20191204224131.3384-5-nramas@linux.microsoft.com> References: <20191204224131.3384-1-nramas@linux.microsoft.com> <20191204224131.3384-5-nramas@linux.microsoft.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 19121022-0012-0000-0000-00000373A035 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19121022-0013-0000-0000-000021AF748C Message-Id: <1576017793.4579.43.camel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-12-10_07:2019-12-10,2019-12-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 suspectscore=2 impostorscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912100186 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2019-12-04 at 14:41 -0800, Lakshmi Ramasubramanian wrote: > Call the IMA hook from key_create_or_update() function to measure > the payload when a new key is created or an existing key is updated. > > This patch adds the call to the IMA hook from key_create_or_update() > function to measure the key on key create or update. > > Signed-off-by: Lakshmi Ramasubramanian Please Cc the key/keyring maintainers, here, immediately following your tag. Cc: David Howells Cc: Jarkko Sakkinen Reviewed-by: Mimi Zohar > --- > include/linux/ima.h | 14 ++++++++++++++ > security/keys/key.c | 10 ++++++++++ > 2 files changed, 24 insertions(+) > > diff --git a/include/linux/ima.h b/include/linux/ima.h > index 6d904754d858..3b89136bc218 100644 > --- a/include/linux/ima.h > +++ b/include/linux/ima.h > @@ -101,6 +101,20 @@ static inline void ima_add_kexec_buffer(struct kimage *image) > {} > #endif > > +#if defined(CONFIG_IMA) && defined(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) > +extern void ima_post_key_create_or_update(struct key *keyring, > + struct key *key, > + const void *payload, size_t plen, > + unsigned long flags, bool create); > +#else > +static inline void ima_post_key_create_or_update(struct key *keyring, > + struct key *key, > + const void *payload, > + size_t plen, > + unsigned long flags, > + bool create) {} > +#endif /* CONFIG_IMA && CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE */ > + > #ifdef CONFIG_IMA_APPRAISE > extern bool is_ima_appraise_enabled(void); > extern void ima_inode_post_setattr(struct dentry *dentry); > diff --git a/security/keys/key.c b/security/keys/key.c > index 764f4c57913e..718bf7217420 100644 > --- a/security/keys/key.c > +++ b/security/keys/key.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > #include > #include "internal.h" > > @@ -936,6 +937,9 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref, > goto error_link_end; > } > > + ima_post_key_create_or_update(keyring, key, payload, plen, > + flags, true); > + > key_ref = make_key_ref(key, is_key_possessed(keyring_ref)); > > error_link_end: > @@ -965,6 +969,12 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref, > } > > key_ref = __key_update(key_ref, &prep); > + > + if (!IS_ERR(key_ref)) > + ima_post_key_create_or_update(keyring, key, > + payload, plen, > + flags, false); > + > goto error_free_prep; > } > EXPORT_SYMBOL(key_create_or_update);