Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2603467ybg; Thu, 24 Oct 2019 12:14:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRJtgmaGqwiPMaLhnBGrb9kDxhCjm63NE8palywlELuhNtr9lOlK/w38d1paycwUVsREvp X-Received: by 2002:a05:6402:134e:: with SMTP id y14mr46710793edw.55.1571944466875; Thu, 24 Oct 2019 12:14:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571944466; cv=none; d=google.com; s=arc-20160816; b=jGsRKDOdrkSU8qly8Fxp4A4yKBpfs4pArSnLC4ReLHl9P3bkV9H9I7syw0WHZT3i7l IfoWyp2VbFz1BcHYbQ90SqZk3gugI2SMl8v4jnZinAI2YMzXl0eKADNIB5PCXp0bn9Jy b4924eHWUxvZZG3QedSNPOq9yfN8v1zaye9rIR28uHISntIdIuwFN9IXLDOGkBtpM4Z3 aYcn2Vm5ONw1dnDIqJ+Q47QJK2taoCRF8SadunufqCvedUwy8QfDOBPiCE2704shOc3t 6r9sgvAGs5vAZIk/OLgXfZPho1/vFNOgENv8P3tvM/bA/ARWdHnBAMfGsSF7cdzHE25h B9jQ== 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:subject:cc:to:from; bh=/ZqlPiVOQhOWIj6zTFlyFff5FSxcnklRucQLtvFNGWY=; b=xDsp/kI9Af3yZNfgq1sO7ktiiKwdpa4y0rJJlK0OSAi9pf8tRBrU/QL6VUfUyiUm0r UK0+tmsm+EpWPvM0ZgpZUVzbJARnu9/nHK5qQFtRSILYsg7lqyU6Hv2Al7kn5KFG/6+s 3CHLNtspjowT2lAHhtQnEpEH73ZWoXSwgcyokTf1FecmNKmDz0dw8WHkh3KeDDh4LDeA 8g//zNYR9uxuJDXS77D/w3eHM8EUAH+lsLNgMGH/Mcj7DPviBffyn6nudJ5XiPaRcKsV 27+CwvT8ITkRY5FPaR4kXvCk4MD1ftweO6iONCzLbC8O5Gz2T0dtn0UbWRp/jOfdAJUO Xtdg== 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 i24si15542412ejh.35.2019.10.24.12.14.02; Thu, 24 Oct 2019 12:14:26 -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 S2437396AbfJXDsN (ORCPT + 99 others); Wed, 23 Oct 2019 23:48:13 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50450 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392947AbfJXDsM (ORCPT ); Wed, 23 Oct 2019 23:48:12 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x9O3l6VF123089 for ; Wed, 23 Oct 2019 23:48:11 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vu1k7mnu1-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 23 Oct 2019 23:48:11 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 24 Oct 2019 04:48:09 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 24 Oct 2019 04:48:03 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x9O3m1pk38469726 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 03:48:01 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8226AE053; Thu, 24 Oct 2019 03:48:01 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DF66BAE04D; Thu, 24 Oct 2019 03:47:58 +0000 (GMT) Received: from localhost.localdomain (unknown [9.40.192.65]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 24 Oct 2019 03:47:58 +0000 (GMT) From: Nayna Jain To: 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 , Mimi Zohar , Greg Kroah-Hartman , Claudio Carvalho , George Wilson , Elaine Palmer , Eric Ricther , "Oliver O'Halloran" , Nayna Jain , Prakhar Srivastava , Lakshmi Ramasubramanian Subject: [PATCH v9 6/8] certs: add wrapper function to check blacklisted binary hash Date: Wed, 23 Oct 2019 22:47:15 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024034717.70552-1-nayna@linux.ibm.com> References: <20191024034717.70552-1-nayna@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19102403-0028-0000-0000-000003AE77C9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19102403-0029-0000-0000-00002470A830 Message-Id: <20191024034717.70552-7-nayna@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-24_02:,, 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-1910240033 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The -EKEYREJECTED error returned by existing is_hash_blacklisted() is misleading when called for checking against blacklisted hash of a binary. This patch adds a wrapper function is_binary_blacklisted() to return -EPERM error if binary is blacklisted. Signed-off-by: Nayna Jain Reviewed-by: Mimi Zohar --- certs/blacklist.c | 9 +++++++++ include/keys/system_keyring.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/certs/blacklist.c b/certs/blacklist.c index ec00bf337eb6..6514f9ebc943 100644 --- a/certs/blacklist.c +++ b/certs/blacklist.c @@ -135,6 +135,15 @@ int is_hash_blacklisted(const u8 *hash, size_t hash_len, const char *type) } EXPORT_SYMBOL_GPL(is_hash_blacklisted); +int is_binary_blacklisted(const u8 *hash, size_t hash_len) +{ + if (is_hash_blacklisted(hash, hash_len, "bin") == -EKEYREJECTED) + return -EPERM; + + return 0; +} +EXPORT_SYMBOL_GPL(is_binary_blacklisted); + /* * Initialise the blacklist */ diff --git a/include/keys/system_keyring.h b/include/keys/system_keyring.h index c1a96fdf598b..fb8b07daa9d1 100644 --- a/include/keys/system_keyring.h +++ b/include/keys/system_keyring.h @@ -35,12 +35,18 @@ extern int restrict_link_by_builtin_and_secondary_trusted( extern int mark_hash_blacklisted(const char *hash); extern int is_hash_blacklisted(const u8 *hash, size_t hash_len, const char *type); +extern int is_binary_blacklisted(const u8 *hash, size_t hash_len); #else static inline int is_hash_blacklisted(const u8 *hash, size_t hash_len, const char *type) { return 0; } + +static inline int is_binary_blacklisted(const u8 *hash, size_t hash_len) +{ + return 0; +} #endif #ifdef CONFIG_IMA_BLACKLIST_KEYRING -- 2.20.1