Received: by 10.213.65.68 with SMTP id h4csp183341imn; Wed, 21 Mar 2018 15:48:38 -0700 (PDT) X-Google-Smtp-Source: AG47ELuhkklrYcBJj911g+q1lrR7IlhG9e+Xp9Lr77VOMRGdsE6Kmaqn4uNXD3Wm5s4cTNc9YFQU X-Received: by 2002:a17:902:d807:: with SMTP id a7-v6mr22549809plz.218.1521672518931; Wed, 21 Mar 2018 15:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521672518; cv=none; d=google.com; s=arc-20160816; b=BohZ3fKxbK5Md7KR1zpmMccgXKGbxyOJqtpQcyT4FtuoZBPFrGt6M8V4EQl50hiVJJ w7ILHsNCI42EE8OtxmyyrmWDcw7XcIkDLrBq3DzQecAt8Ds1/KanzZPs85/1XssYFiyq TcXfWacPHFrcjYBMgRz119HIseSXqBXykd6UwCSP0zBB6/3Rz/v3nzsmOnQAqMMF9rcl xAdiv58FaQs+QOpC6t892IR3CuLHLksb2wDEg20NrL2ZbqVtYHxf+qgTX2KyMWtidh+w Nn5r3c7ZO8qobj9Uw0YKeBowTIb4cpdbDlSpw1+NjbGUWB2T5PeZ+RYWcokuWDUnWps2 Q7IQ== 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=xYp+0OS8eb3jaDntEselQpVUblpgYuSwevXAZmOoKOY=; b=ztg7Q7+OENNRJrkFkwwIs2gDYWGzto48R/qbkQZTjK0tPOBxwj2JNFxDJExocZWOPe ZYV6D6Ut+YG3YPvE24JU5oUuL2t7SczdcBbX22Qv7rFE5/z/QRId2ekDaJgLmDZkePUo vnYeWazoOTEaLN+OXpNnv5rrQdM2l5OUHsJOjhxWdO6rEKn8H2+F92g4lg6B2w7j8b82 ddHQOTsqdgyh3SgPv6XdVEAeeiWV8tE1IC1YJu2a2G4icuaVDdfwgB1Q3B2Fe8g9rO5+ qmfEOfZQdjRiY2SZH7F7f5Vu1NnT2W17HJ2/M9ofcDIsCuzfwse1/NIpcGG0YSF7FLqs znLA== 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 u191si3469406pgc.725.2018.03.21.15.48.24; Wed, 21 Mar 2018 15:48:38 -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 S1754079AbeCUWrH (ORCPT + 99 others); Wed, 21 Mar 2018 18:47:07 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54830 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753691AbeCUWrB (ORCPT ); Wed, 21 Mar 2018 18:47:01 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2LMiRu3138578 for ; Wed, 21 Mar 2018 18:47:00 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gux53n06b-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 21 Mar 2018 18:47:00 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Mar 2018 22:46:58 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 21 Mar 2018 22:46:54 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2LMksju52756658; Wed, 21 Mar 2018 22:46:54 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D8FDE52043; Wed, 21 Mar 2018 21:38:16 +0000 (GMT) Received: from localhost.localdomain (unknown [9.80.103.4]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id E704F52041; Wed, 21 Mar 2018 21:38:14 +0000 (GMT) Subject: Re: [PATCH v6 05/12] integrity: Introduce integrity_keyring_from_id() 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: Wed, 21 Mar 2018 18:46:51 -0400 In-Reply-To: <20180316203837.10174-6-bauerman@linux.vnet.ibm.com> References: <20180316203837.10174-1-bauerman@linux.vnet.ibm.com> <20180316203837.10174-6-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: 7bit X-TM-AS-GCONF: 00 x-cbid: 18032122-0040-0000-0000-00000443ED90 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18032122-0041-0000-0000-000020E7134C Message-Id: <1521672411.3848.219.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-21_12:,, 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-1803210259 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: > IMA will need to obtain the keyring used to verify file signatures so that > it can verify the module-style signature appended to files. > > Signed-off-by: Thiago Jung Bauermann Signed-off-by: Mimi Zohar > --- > security/integrity/digsig.c | 28 +++++++++++++++++++++------- > security/integrity/integrity.h | 6 ++++++ > 2 files changed, 27 insertions(+), 7 deletions(-) > > diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c > index 6f9e4ce568cd..e641a67b9fc7 100644 > --- a/security/integrity/digsig.c > +++ b/security/integrity/digsig.c > @@ -48,11 +48,10 @@ static bool init_keyring __initdata; > #define restrict_link_to_ima restrict_link_by_builtin_trusted > #endif > > -int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen, > - const char *digest, int digestlen) > +struct key *integrity_keyring_from_id(const unsigned int id) > { > - if (id >= INTEGRITY_KEYRING_MAX || siglen < 2) > - return -EINVAL; > + if (id >= INTEGRITY_KEYRING_MAX) > + return ERR_PTR(-EINVAL); > > if (!keyring[id]) { > keyring[id] = > @@ -61,17 +60,32 @@ int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen, > int err = PTR_ERR(keyring[id]); > pr_err("no %s keyring: %d\n", keyring_name[id], err); > keyring[id] = NULL; > - return err; > + return ERR_PTR(err); > } > } > > + return keyring[id]; > +} > + > +int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen, > + const char *digest, int digestlen) > +{ > + struct key *keyring; > + > + if (siglen < 2) > + return -EINVAL; > + > + keyring = integrity_keyring_from_id(id); > + if (IS_ERR(keyring)) > + return PTR_ERR(keyring); > + > switch (sig[1]) { > case 1: > /* v1 API expect signature without xattr type */ > - return digsig_verify(keyring[id], sig + 1, siglen - 1, > + return digsig_verify(keyring, sig + 1, siglen - 1, > digest, digestlen); > case 2: > - return asymmetric_verify(keyring[id], sig, siglen, > + return asymmetric_verify(keyring, sig, siglen, > digest, digestlen); > } > > diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h > index 79799a0d9195..2d245f44ca26 100644 > --- a/security/integrity/integrity.h > +++ b/security/integrity/integrity.h > @@ -150,6 +150,7 @@ int integrity_kernel_read(struct file *file, loff_t offset, > > #ifdef CONFIG_INTEGRITY_SIGNATURE > > +struct key *integrity_keyring_from_id(const unsigned int id); > int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen, > const char *digest, int digestlen); > > @@ -157,6 +158,11 @@ int __init integrity_init_keyring(const unsigned int id); > int __init integrity_load_x509(const unsigned int id, const char *path); > #else > > +static inline struct key *integrity_keyring_from_id(const unsigned int id) > +{ > + return ERR_PTR(-EINVAL); > +} > + > static inline int integrity_digsig_verify(const unsigned int id, > const char *sig, int siglen, > const char *digest, int digestlen) >