Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1355855ybg; Wed, 23 Oct 2019 14:29:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIDok7CCnfe9/BSdpgAmZPCGYHOpD9Ydgdqf3alWzlqPOqB8c/BgzrWNQy36vtkdPkeF1j X-Received: by 2002:a17:906:1c87:: with SMTP id g7mr27709428ejh.189.1571866191317; Wed, 23 Oct 2019 14:29:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571866191; cv=none; d=google.com; s=arc-20160816; b=UL/wce7k51RGswhX8IOR1fWra0l2q9pgRP+4HPQ2neU61TpbT77FHE8UJH60h/RdAp X4oBad8Vsoq85F1mOOpCfHTDnfPsJa1b4qoyY8oPcQmzrF6Z/fR2mJqYIM8KacRQgO/n qft17feB+QhQz0NdOci4raj2li3mJYf8lnaCeYjZ1djPxkg8mqwG4OLePwSUw+6ii1oG ubVoECsknT7lfzW+J02tVzfW6dUbwEBADiJT/H5OPbBLhVBOo3WKnkCLBEQChv6VzJ17 Mg14veCnUAkdPvQQiBpN+SjjQOkRK/TB3hVmlSGlVwU5HVMEPUuh+2qf+J+hqU9C9cj4 9kAw== 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:to:from:subject; bh=n+fapZZnZxhj4R1ldAGgDXwfjURbTo7CFzH3jiz0NY4=; b=tE/v7wwZ+XuWh+dTS8AglDAQnI8rWvvQLXQaPo176CnWEH1Y+UbEGuMA9GAlOQ1OgQ RG4Pmi7ZKFumxW14w3vbwlqw0be/xKUdZFJcueP7F8Lnhj1n0GZeffbeUe8JyXPGd25x coVrkdjr4blhJRt/0IbwVl5p5mIiZWtdvHRi8xn/CRQy8Gsit07Ka+ppwY+QjgWGJiYq lhLIF6lQD3/NRzWzxu+l//kP9l5FlJiW8HTgN5XkibV2zzYiGqlfp8HYlDDuqKIvehbi aVb/S9rAGRYL8jJx+UfPylEpG2TRHzgIMMxXhq7eCHn4AUakYzQxskvo9EpPYyqQlWHT a49Q== 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 h12si5923693ejd.17.2019.10.23.14.29.27; Wed, 23 Oct 2019 14:29:51 -0700 (PDT) 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 S2405661AbfJWNVg (ORCPT + 99 others); Wed, 23 Oct 2019 09:21:36 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54558 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2405626AbfJWNVf (ORCPT ); Wed, 23 Oct 2019 09:21:35 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x9NDL2vc054501 for ; Wed, 23 Oct 2019 09:21:34 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vtqhygbvb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 23 Oct 2019 09:21:33 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 23 Oct 2019 14:21:30 +0100 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 23 Oct 2019 14:21:27 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x9NDKrEH20054288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Oct 2019 13:20:53 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 29B6911C05B; Wed, 23 Oct 2019 13:21:26 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE5F111C050; Wed, 23 Oct 2019 13:21:24 +0000 (GMT) Received: from localhost.localdomain (unknown [9.85.184.174]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 23 Oct 2019 13:21:24 +0000 (GMT) Subject: Re: [PATCH v1 2/6] KEYS: ima: Refactored process_buffer_measurement function so that it can measure any buffer (and not just KEXEC_CMDLINE one) From: Mimi Zohar To: Lakshmi Ramasubramanian , dhowells@redhat.com, casey@schaufler-ca.com, sashal@kernel.org, jamorris@linux.microsoft.com, linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org Date: Wed, 23 Oct 2019 09:21:24 -0400 In-Reply-To: <20191023001818.3684-3-nramas@linux.microsoft.com> References: <20191023001818.3684-1-nramas@linux.microsoft.com> <20191023001818.3684-3-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: 19102313-4275-0000-0000-000003762A74 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19102313-4276-0000-0000-0000388951C0 Message-Id: <1571836884.5104.94.camel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-23_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910230136 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-10-22 at 17:18 -0700, Lakshmi Ramasubramanian wrote: > diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c > index 584019728660..8e965d18fb21 100644 > --- a/security/integrity/ima/ima_main.c > +++ b/security/integrity/ima/ima_main.c > @@ -610,14 +610,14 @@ int ima_load_data(enum kernel_load_data_id id) > * @buf: pointer to the buffer that needs to be added to the log. > * @size: size of buffer(in bytes). > * @eventname: event name to be used for the buffer entry. > - * @cred: a pointer to a credentials structure for user validation. > - * @secid: the secid of the task to be validated. > + * @pcr: pcr to extend the measurement > + * @template_desc: template description > * > * Based on policy, the buffer is measured into the ima log. > */ > -static void process_buffer_measurement(const void *buf, int size, > - const char *eventname, > - const struct cred *cred, u32 secid) > +void process_buffer_measurement(const void *buf, int size, > + const char *eventname, int pcr, > + struct ima_template_desc *template_desc) > { > int ret = 0; > struct ima_template_entry *entry = NULL; > @@ -626,19 +626,11 @@ static void process_buffer_measurement(const void *buf, int size, > .filename = eventname, > .buf = buf, > .buf_len = size}; > - struct ima_template_desc *template_desc = NULL; > struct { > struct ima_digest_data hdr; > char digest[IMA_MAX_DIGEST_SIZE]; > } hash = {}; > int violation = 0; > - int pcr = CONFIG_IMA_MEASURE_PCR_IDX; > - int action = 0; > - > - action = ima_get_action(NULL, cred, secid, 0, KEXEC_CMDLINE, &pcr, > - &template_desc); > - if (!(action & IMA_MEASURE)) > - return; > > iint.ima_hash = &hash.hdr; > iint.ima_hash->algo = ima_hash_algo; This patch is based on Nayna's version of this change, without any acknowledgment.  Moving this code out of process_buffer_measurement is going to result in code duplication.  Nayna has posted a newer version of this patch without the code duplication.  As soon as she posts the patch with an updated patch description, I plan on picking up that version. Mimi > @@ -670,12 +662,19 @@ static void process_buffer_measurement(const void *buf, int size, > */ > void ima_kexec_cmdline(const void *buf, int size) > { > + int pcr = CONFIG_IMA_MEASURE_PCR_IDX; > + struct ima_template_desc *template_desc = ima_template_desc_current(); > + int action; > u32 secid; > > if (buf && size != 0) { > security_task_getsecid(current, &secid); > - process_buffer_measurement(buf, size, "kexec-cmdline", > - current_cred(), secid); > + action = ima_get_action(NULL, current_cred(), secid, 0, > + KEXEC_CMDLINE, &pcr, &template_desc); > + if (!(action & IMA_MEASURE)) > + return; > + process_buffer_measurement(buf, size, "kexec-cmdline", pcr, > + template_desc); > } > } >