Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5975817ybc; Wed, 27 Nov 2019 12:43:49 -0800 (PST) X-Google-Smtp-Source: APXvYqwziX2uYd527f5ivSOQmXpa4VUy90XEX+uY9GxR1ywygIQ+0zNFQGqerap5sd8iMpNPlbSd X-Received: by 2002:aa7:c2d3:: with SMTP id m19mr2976455edp.136.1574887429872; Wed, 27 Nov 2019 12:43:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574887429; cv=none; d=google.com; s=arc-20160816; b=oLpwQqNbsMmS5+hwutB9bBCUPMyGVE6wU/mjpLBHhzlgs/neKY92JEZsr+a1p6CfBB w1MIsSM8MvorSSIIsRYPSJ7n2AVt+P2OiO3shZJ8oIscL0xAEbjvll+6hHgiTrGu21kB GRzXnruPOo1bbOZq8DXvd3xki57EOAsv+/m3wpRv3KEM/LbsPdkZbloy+eBUIErm2Luo bw+Xv/sDfxLRu+B1MgVqeEChKP+igrXqWESnx/OsXKItQPSEH43RChvN3UP5TJ/UqvBV rI+0s9JNkGO5zb8A3a26P5Iw9Nf9dQMJtKGxNcJPZGIz26Fx3Vs28C60Jb82P/mwret7 2HmA== 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=s9LGrd1KxCaWFtcX3qzr7eo9SBCf3OndmXQ+L69h6vo=; b=jJdc+2ZYn+lk8NwmGqLEtHAMsjURQzxfRvCfGTE7AQ2OBZDRvdQDda0o3tXinS+4dJ FOmgxZJXMBdTc+HNID5KNkGgKLE/FZxpLuRZlpr+7vaHI+SngUA03ZzRobeFVb6MY6MG /iL6VQHR8ajoRkCtQpEtYzcXry1/3zpqNXNg+w7Z0wrMOkxyrmva3SDWn3HIrbQ8bCyF W6gKH69NgNda4jcYItSUBFI9UkEA3kqflhbLAT6RrAFnH/njyOoItvG2rN6aPInYH5UD K0URJJVMNjnfP1vbeeO0bDhg8Z9TXgUooNEhUrONgiA0QacX+L8us2Crph/UIOndJbbq ycFA== 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 z12si10904340edx.47.2019.11.27.12.43.25; Wed, 27 Nov 2019 12:43:49 -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 S1728045AbfK0UjI (ORCPT + 99 others); Wed, 27 Nov 2019 15:39:08 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:42952 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728028AbfK0UjH (ORCPT ); Wed, 27 Nov 2019 15:39:07 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xARKapsm011375 for ; Wed, 27 Nov 2019 15:39:05 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2whcxr0xej-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Nov 2019 15:39:05 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Nov 2019 20:39:03 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 27 Nov 2019 20:39:00 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xARKcxtt59375626 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Nov 2019 20:38:59 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 685C7A404D; Wed, 27 Nov 2019 20:38:59 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 52D1BA4051; Wed, 27 Nov 2019 20:38:58 +0000 (GMT) Received: from dhcp-9-31-103-87.watson.ibm.com (unknown [9.31.103.87]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 27 Nov 2019 20:38:58 +0000 (GMT) Subject: Re: [PATCH v0 1/2] IMA: Defined queue functions From: Mimi Zohar To: Lakshmi Ramasubramanian , linux-integrity@vger.kernel.org Cc: eric.snowberg@oracle.com, dhowells@redhat.com, matthewgarrett@google.com, sashal@kernel.org, jamorris@linux.microsoft.com, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, Janne Karhunen Date: Wed, 27 Nov 2019 15:38:57 -0500 In-Reply-To: <20191127025212.3077-2-nramas@linux.microsoft.com> References: <20191127025212.3077-1-nramas@linux.microsoft.com> <20191127025212.3077-2-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: 8bit X-TM-AS-GCONF: 00 x-cbid: 19112720-0008-0000-0000-0000033918B0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112720-0009-0000-0000-00004A58227A Message-Id: <1574887137.4793.346.camel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-27_04:2019-11-27,2019-11-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 suspectscore=3 spamscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911270166 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lakshmi, Janne Karhunen is defining an IMA workqueue in order to more frequently update the on disk security xattrs.  The Subject line on this patch needs to be more explicit (eg. define workqueue for early boot "key" measurements). On Tue, 2019-11-26 at 18:52 -0800, Lakshmi Ramasubramanian wrote: > Keys created or updated in the system before IMA is initialized Keys created or updated before a custom policy is loaded are currently not measured. > should be queued up. And, keys (including any queued ones) > should be processed when IMA initialization is completed. > > This patch defines functions to queue and dequeue keys for > measurement. A flag namely ima_process_keys_for_measurement > is used to check if the key should be queued or should be > processed immediately. > > ima_policy_flag cannot be relied upon to make queuing decision > because ima_policy_flag will be set to 0 when either IMA is > not initialized or when the IMA policy itself is empty. I'm not sure why you want to differentiate between IMA being initialized vs. an empty policy.  I would think you would want to know when a custom policy has been loaded. Until ima_update_policy() is called, "ima_rules" points to the architecture specific and configured policy rules, which are persistent, and the builtin policy rules.  Once a custom policy is loaded, "ima_rules" points to the architecture specific, configured, and custom policy rules. I would define a function that determines whether or not a custom policy has been loaded. (I still need to review adding/removing from the queue.) > > @@ -27,14 +154,14 @@ > * The payload data used to instantiate or update the key is measured. > */ > void ima_post_key_create_or_update(struct key *keyring, struct key *key, > - const void *payload, size_t plen, > + const void *payload, size_t payload_len, > unsigned long flags, bool create) This "hunk" and subsequent one seem to be just a variable name change.  It has nothing to do with queueing "key" measurements and shouldn't be included in this patch. Mimi > { > /* Only asymmetric keys are handled by this hook. */ > if (key->type != &key_type_asymmetric) > return; > > - if (!payload || (plen == 0)) > + if (!payload || (payload_len == 0)) > return; > > /* > @@ -52,7 +179,7 @@ void ima_post_key_create_or_update(struct key *keyring, struct key *key, > * if the IMA policy is configured to measure a key linked > * to the given keyring. > */ > - process_buffer_measurement(payload, plen, > + process_buffer_measurement(payload, payload_len, > keyring->description, KEY_CHECK, 0, > keyring->description); > }