Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1297845ybg; Sat, 26 Oct 2019 17:14:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCwyylm7fqXNoVfOE+9Ihdl+4BcfafBsZn71ma5bjUK9TRyRovlRyoaQ+txhYQqI6ge5BP X-Received: by 2002:aa7:df85:: with SMTP id b5mr11871154edy.298.1572135291065; Sat, 26 Oct 2019 17:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572135291; cv=none; d=google.com; s=arc-20160816; b=pIJ4D7evTtjgBoJrx7v72c+Y/L/TDInM23ZNqncDh/fEThPJk7Ok8DprVp2ZQIR6JX kz0Dma03TrIdm7KUhAqrHQd8Puht0uBxWg7Tf6DYj17aO8YeAdHFtfRk1EAeQQJi2Ivo 6ieJAZXm2BciH6rC+eL0LBH1aUgxztbySvA9gdVi/sUioWFuR3zXdjuKwcWnim4D90sP 0Sq2wwwwyrRkBid/ngY615WUdzgnLU0zGmrpAZzsSK/VM9YKwaP9n4oLB6DiIWtbY9TI /oeu3GEIexbt3g+SI37oaHT/FUe8dnqNNmcbIeYgxs/3juvEIEVyjUOKzYX+fMnWtCOR FBMA== 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=vMqtxlAqo4zmGWbbhWjos7tCtmfXqsmU10c/uXA/HIo=; b=tofNBhaBMECQ5i1is1lak2NjvJv5aTwCxKzTwTrLztMmOlhL8s3IXBmAJpelPmlrpx V3k7TwHkuB1rPrNIoep9b/Nrx7UTlVUXV1l28woZr7KwwiYYwFs0njaskyOSjDL+jCBc 7sKD8o7RDvTwDXhYCaa6srUto53GA2yid1Gx1Ra6KbO9YbMBCpaRxMeqUOtfLGjC3bez pVMhiVQtGf9XfiQKDbSlF2XedO5dffvKTqlSFCYTftLUFbLmLlbFanUThhi/BdpC+XHB gJrcclOY8j11DcnKvWFHGLVSwd7mzVqsEixYsUwSxABVnBrP9Z1Rsh2TpD0FUIQ6oP40 FWiQ== 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 x12si4915330edi.301.2019.10.26.17.14.24; Sat, 26 Oct 2019 17:14: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 S1726563AbfJ0ANg (ORCPT + 99 others); Sat, 26 Oct 2019 20:13:36 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:27522 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726491AbfJ0ANf (ORCPT ); Sat, 26 Oct 2019 20:13:35 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x9R06vrj004951 for ; Sat, 26 Oct 2019 20:13:34 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2vvf2txa6m-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 26 Oct 2019 20:13:33 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 27 Oct 2019 01:13:32 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Sun, 27 Oct 2019 01:13:27 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x9R0DPid18350156 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 27 Oct 2019 00:13:25 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A612E4C04A; Sun, 27 Oct 2019 00:13:25 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 720E34C040; Sun, 27 Oct 2019 00:13:23 +0000 (GMT) Received: from localhost.localdomain (unknown [9.85.187.251]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Sun, 27 Oct 2019 00:13:23 +0000 (GMT) Subject: Re: [PATCH v9 5/8] ima: make process_buffer_measurement() generic From: Mimi Zohar To: Lakshmi Ramasubramanian , Nayna Jain , Nayna Jain , linuxppc-dev@ozlabs.org, linux-efi@vger.kernel.org, linux-integrity@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Ard Biesheuvel , Jeremy Kerr , Matthew Garret , Greg Kroah-Hartman , Claudio Carvalho , George Wilson , Elaine Palmer , Eric Ricther , "Oliver O'Halloran" , Prakhar Srivastava Date: Sat, 26 Oct 2019 20:13:22 -0400 In-Reply-To: <8a97301a-0e25-2718-bd81-d778cb58e1d3@linux.microsoft.com> References: <20191024034717.70552-1-nayna@linux.ibm.com> <20191024034717.70552-6-nayna@linux.ibm.com> <1ae56786-4d5c-ba8e-e30c-ced1e15ccb9c@linux.microsoft.com> <24cf44d5-a1f0-f59e-9884-c026b1ee2d3b@linux.vnet.ibm.com> <8a97301a-0e25-2718-bd81-d778cb58e1d3@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: 19102700-0020-0000-0000-0000037EF37D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19102700-0021-0000-0000-000021D54469 Message-Id: <1572135202.4532.88.camel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-26_07:,, 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-1910270000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2019-10-25 at 10:32 -0700, Lakshmi Ramasubramanian wrote: > > On 10/25/2019 10:24 AM, Nayna Jain wrote: > > > > On 10/24/19 10:20 AM, Lakshmi Ramasubramanian wrote: > >> On 10/23/19 8:47 PM, Nayna Jain wrote: > >> > >> Hi Nayna, > >> > >>> +void process_buffer_measurement(const void *buf, int size, > >>> +                const char *eventname, enum ima_hooks func, > >>> +                int pcr) > >>>   { > >>>       int ret = 0; > >>>       struct ima_template_entry *entry = NULL; > >> > >>> +    if (func) { Let's comment this line.  Perhaps something like /*Unnecessary for auxiliary buffer measurements */ > >>> +        security_task_getsecid(current, &secid); > >>> +        action = ima_get_action(NULL, current_cred(), secid, 0, func, > >>> +                    &pcr, &template); > >>> +        if (!(action & IMA_MEASURE)) > >>> +            return; > >>> +    } > >> > >> In your change set process_buffer_measurement is called with NONE for > >> the parameter func. So ima_get_action (the above if block) will not be > >> executed. > >> > >> Wouldn't it better to update ima_get_action (and related functions) to > >> handle the ima policy (func param)? > > > > > > The idea is to use ima-buf template for the auxiliary measurement > > record. The auxiliary measurement record is an additional record to the > > one already created based on the existing policy. When func is passed as > > NONE, it represents it is an additional record. I am not sure what you > > mean by updating ima_get_action, it is already handling the ima policy. > > > > I was referring to using "func" in process_buffer_measurement to > determine ima action. In my opinion, process_buffer_measurement should > be generic. > > ima_get_action() should instead determine the required ima action, > template, pcr, etc. based on "func" passed to it. Nayna's original patch moved ima_get_action() into the caller, but that resulted in code duplication in each of the callers.  This solution differentiates between the initial, which requires calling ima_get_action(), and auxiliary buffer measurement records. Mimi