Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp995954imu; Tue, 11 Dec 2018 10:52:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/WqLMQVpTIHEQ5+TUTUQfl8p4HiqxIen2BhcJmQOnDOf8KdbrBzbAwKq+xH7yvbeXsajQfU X-Received: by 2002:a17:902:108a:: with SMTP id c10mr17323596pla.131.1544554341401; Tue, 11 Dec 2018 10:52:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544554341; cv=none; d=google.com; s=arc-20160816; b=jWyA2ms9fQCdOz9NW96Z40T0y+0N5UiD0OInPsaatMwnV5bXN3Q92EABw4SDo0uYkF 8yB3KgeMmSQvl+uyuXX90U7tKHp4ySftbKmAhlAmQznrJ/WpGMVP1WpKA18cOektFhp2 MUpFUzpWWBDgLa2iYQ8kqu7FIGZHq4Q0uYUvJFwoqlbQ3SmcNCN94cQSD3X9dX8lf+nW 5n00I5ZONQ9hiWrGoFXcoMPiQy+iSH2yp64twl8VtDsdBBcK5W6tep58/l4Alux3GzdP fLYAVc0W5nZM2B3BocYuAUyfrHK9UdxY3MQEl3IO4IfwQRcwMnwugVPLL17OpacXDSDu TOlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=rChFWJsWbX1J/ZUOknE3hP25COzzIkVcbOCI61U3tbg=; b=X4OOuj9I7hur9psUombCco82vv5Hxosshq3ShMS2/pzTSkWBB0cyKcJVtvjq/+L11U Ijr/Cq7MiNCIA0Aa/TuT/L1gY95sLWPy3/cfuvzsnIlL95rzkKX0hL5ILZ+mUrahcQzl unAsxiCCoJCdC+muFN0iZVkEcclg3dprah3qZ4Ckcpk27zcre5WJ2ZfftgyyK+XoHEyV YGdoNWiI3m+qeuyI9dGt9Wy8Yeq29p/t5sthke40/5QRYCx3WReSdFeG1WNna7Z03m/K vrT5wjPpdaFf5q3lRkYlY3jkQ8DDwrq2MeIZxlViI0O0I/azQTwt0tWCwwHKN+FwkCxu tnZg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g2si12758071plp.130.2018.12.11.10.52.06; Tue, 11 Dec 2018 10:52:21 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726647AbeLKSsU (ORCPT + 99 others); Tue, 11 Dec 2018 13:48:20 -0500 Received: from namei.org ([65.99.196.166]:58982 "EHLO namei.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726350AbeLKSsU (ORCPT ); Tue, 11 Dec 2018 13:48:20 -0500 Received: from localhost (localhost [127.0.0.1]) by namei.org (8.14.4/8.14.4) with ESMTP id wBBIlw8s012640; Tue, 11 Dec 2018 18:47:58 GMT Date: Wed, 12 Dec 2018 05:47:58 +1100 (AEDT) From: James Morris To: Nayna Jain cc: linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, zohar@linux.ibm.com, dhowells@redhat.com, jforbes@redhat.com, seth.forshee@canonical.com, kexec@lists.infradead.org, keyrings@vger.kernel.org, vgoyal@redhat.com, ebiederm@xmission.com, mpe@ellerman.id.au, Josh Boyer Subject: Re: [PATCH v2 5/7] efi: Import certificates from UEFI Secure Boot In-Reply-To: <20181208202705.18673-6-nayna@linux.ibm.com> Message-ID: References: <20181208202705.18673-1-nayna@linux.ibm.com> <20181208202705.18673-6-nayna@linux.ibm.com> User-Agent: Alpine 2.21 (LRH 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 9 Dec 2018, Nayna Jain wrote: > +/* > + * Blacklist an X509 TBS hash. > + */ > +static __init void uefi_blacklist_x509_tbs(const char *source, > + const void *data, size_t len) > +{ > + char *hash, *p; > + > + hash = kmalloc(4 + len * 2 + 1, GFP_KERNEL); > + if (!hash) > + return; > + p = memcpy(hash, "tbs:", 4); > + p += 4; > + bin2hex(p, data, len); > + p += len * 2; > + *p = 0; > + > + mark_hash_blacklisted(hash); > + kfree(hash); > +} > + > +/* > + * Blacklist the hash of an executable. > + */ > +static __init void uefi_blacklist_binary(const char *source, > + const void *data, size_t len) > +{ > + char *hash, *p; > + > + hash = kmalloc(4 + len * 2 + 1, GFP_KERNEL); > + if (!hash) > + return; > + p = memcpy(hash, "bin:", 4); > + p += 4; > + bin2hex(p, data, len); > + p += len * 2; > + *p = 0; > + > + mark_hash_blacklisted(hash); > + kfree(hash); > +} > These could be refactored into one function. -- James Morris