Received: by 10.213.65.68 with SMTP id h4csp1432481imn; Mon, 26 Mar 2018 07:26:50 -0700 (PDT) X-Google-Smtp-Source: AG47ELsxXI/+gWYv58aV1GB3B1A+ZWPuaKWIKdUBb+NgyA6/8J1+mDPZQcW7kV+Mgn87jUs/f1p0 X-Received: by 10.98.137.218 with SMTP id n87mr10977916pfk.48.1522074410347; Mon, 26 Mar 2018 07:26:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522074410; cv=none; d=google.com; s=arc-20160816; b=M6vM6GnR6AMv68763PZ9ld0zZD2kmq+EloIBK0AH8n58PDBEoEVYY1Hm2Zjvmus5Og v+G5Z/uCbZT9P9BzoZQt1FBVA8l+UVSEzWeHL0GECeRx1W+vjXpq32Cli9YtjyDT8jWo RaOuTs3PAFb26vUHQFiRlQe5dZ/TMpqqsXCNJwekvVJ5IdijBWv56zT7Fffdhty5ie9d aQ5D8hHj73HKFnbj/kwaszN5pgR2ou97KJF6MqCFMDLSnQhYJ5L+p4/7L23NjvHe0QE6 4o/JUny7zsHn2MOGtiD/uMvv8LZ2+NOPun6/0aKyhbUW89aL6E/CoTuUpSGHtH8jYBp8 zCSQ== 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 :arc-authentication-results; bh=y3ePw6JXd6XPu3o0NsR2p1Xmsi0oYm9JVm/WaJsEu1I=; b=bBGisdbY163dFoF8FH6cTUlDOAYp5NOrcbicenBN+7tRI4+ShkerXR/tN0FTg6tXhG 65OSo4WELQib7poQoYCE+ULplikZAnKiqh4sHq7ZMjr71y8qE0O3uBR3A0B6f55ADgcX IAZF5LofelYXxg56o145Xr4Elsuhs9eCROODRAiCl/ZgsRVUikoze9QiatI0Go44m/hn fO6cXpd74ND0yuCPAcXgFdpuadjDScBKA9hgsRC6ijY4Bl3iN934VWriR1CN/9XLMvap e+JCH+w3zxQPDBtJG7U1IRpowmn9d601rjqoFwMQIuh2tdH69tNXdgIZp2Kx2qZUGK+R ycKQ== 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 v21-v6si15513322ply.728.2018.03.26.07.26.26; Mon, 26 Mar 2018 07:26:50 -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 S1752183AbeCZOY7 (ORCPT + 99 others); Mon, 26 Mar 2018 10:24:59 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60120 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751890AbeCZOY5 (ORCPT ); Mon, 26 Mar 2018 10:24:57 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2QEO4Cb129524 for ; Mon, 26 Mar 2018 10:24:57 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gy07yfb8p-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Mon, 26 Mar 2018 10:24:56 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 26 Mar 2018 15:24:42 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 26 Mar 2018 15:24:36 +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 w2QEOawm63701202; Mon, 26 Mar 2018 14:24:36 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 61C1E4C059; Mon, 26 Mar 2018 15:17:38 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 699744C04E; Mon, 26 Mar 2018 15:17:36 +0100 (BST) Received: from localhost.localdomain (unknown [9.80.103.80]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 26 Mar 2018 15:17:36 +0100 (BST) Subject: Re: [PATCH v6 04/12] ima: Introduce is_ima_sig() From: Mimi Zohar To: Thiago Jung Bauermann , linux-integrity@vger.kernel.org Cc: linux-security-module@vger.kernel.org, keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , David Howells , David Woodhouse , Jessica Yu , Herbert Xu , "David S. Miller" , "AKASHI, Takahiro" Date: Mon, 26 Mar 2018 10:24:33 -0400 In-Reply-To: <20180316203837.10174-5-bauerman@linux.vnet.ibm.com> References: <20180316203837.10174-1-bauerman@linux.vnet.ibm.com> <20180316203837.10174-5-bauerman@linux.vnet.ibm.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: 18032614-0040-0000-0000-000004270BB1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18032614-0041-0000-0000-0000262A2020 Message-Id: <1522074273.3541.83.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-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 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803260152 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2018-03-16 at 17:38 -0300, Thiago Jung Bauermann wrote: > With the introduction of another IMA signature type (modsig), some places > will need to check for both of them. It is cleaner to do that if there's a > helper function to tell whether an xattr_value represents an IMA > signature. Initially the function name "is_ima_sig" is fine, since it reflects the 'imasig' type.  Having a more generic function name would be better when adding 'modsig' support.  As long as the function is locally define, we can drop 'ima' from the name.  Perhaps something like has_signature or is_signed() would be preferable. Mimi > > Suggested-by: Mimi Zohar > Signed-off-by: Thiago Jung Bauermann > --- > security/integrity/ima/ima.h | 5 +++++ > security/integrity/ima/ima_appraise.c | 7 +++---- > security/integrity/ima/ima_template_lib.c | 2 +- > 3 files changed, 9 insertions(+), 5 deletions(-) > > diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h > index 35fe91aa1fc9..4bafa6a97967 100644 > --- a/security/integrity/ima/ima.h > +++ b/security/integrity/ima/ima.h > @@ -155,6 +155,11 @@ unsigned long ima_get_binary_runtime_size(void); > int ima_init_template(void); > void ima_init_template_list(void); > > +static inline bool is_ima_sig(const struct evm_ima_xattr_data *xattr_value) > +{ > + return xattr_value && xattr_value->type == EVM_IMA_XATTR_DIGSIG; > +} > + > /* > * used to protect h_table and sha_table > */ > diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c > index a6b2995b7d0b..01172eab297b 100644 > --- a/security/integrity/ima/ima_appraise.c > +++ b/security/integrity/ima/ima_appraise.c > @@ -325,15 +325,14 @@ int ima_appraise_measurement(enum ima_hooks func, > } else if (status != INTEGRITY_PASS) { > /* Fix mode, but don't replace file signatures. */ > if ((ima_appraise & IMA_APPRAISE_FIX) && > - (!xattr_value || > - xattr_value->type != EVM_IMA_XATTR_DIGSIG)) { > + !is_ima_sig(xattr_value)) { > if (!ima_fix_xattr(dentry, iint)) > status = INTEGRITY_PASS; > } > > /* Permit new files with file signatures, but without data. */ > if (inode->i_size == 0 && iint->flags & IMA_NEW_FILE && > - xattr_value && xattr_value->type == EVM_IMA_XATTR_DIGSIG) { > + is_ima_sig(xattr_value)) { > status = INTEGRITY_PASS; > } > > @@ -448,7 +447,7 @@ int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name, > if (!xattr_value_len || (xvalue->type >= IMA_XATTR_LAST)) > return -EINVAL; > ima_reset_appraise_flags(d_backing_inode(dentry), > - xvalue->type == EVM_IMA_XATTR_DIGSIG); > + is_ima_sig(xvalue)); > result = 0; > } > return result; > diff --git a/security/integrity/ima/ima_template_lib.c b/security/integrity/ima/ima_template_lib.c > index 5afaa53decc5..afb52a90e532 100644 > --- a/security/integrity/ima/ima_template_lib.c > +++ b/security/integrity/ima/ima_template_lib.c > @@ -380,7 +380,7 @@ int ima_eventsig_init(struct ima_event_data *event_data, > { > struct evm_ima_xattr_data *xattr_value = event_data->xattr_value; > > - if ((!xattr_value) || (xattr_value->type != EVM_IMA_XATTR_DIGSIG)) > + if (!is_ima_sig(xattr_value)) > return 0; > > return ima_write_template_field_data(xattr_value, event_data->xattr_len, >