Received: from list by lists.gnu.org with archive (Exim 4.71) id 1gHTqG-0006UU-Jl for mharc-grub-devel@gnu.org; Tue, 30 Oct 2018 09:13:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHTq7-0006Lu-Dr for grub-devel@gnu.org; Tue, 30 Oct 2018 09:13:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHTq3-0006bR-LG for grub-devel@gnu.org; Tue, 30 Oct 2018 09:13:47 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:48192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHTq3-0006X4-8T for grub-devel@gnu.org; Tue, 30 Oct 2018 09:13:43 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9UD9VKa056166; Tue, 30 Oct 2018 13:13:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=nr5XysscAurB+niFi/nuNfD8C5nuB6ALDH/d77zXIVA=; b=vQ5MP+xoT9P1XqegQ7oSp3IwS6yQuBlZHmXUf7ycdK3b+wPkJbfvG2VRsuhbXDsaMyI/ 0sGbK+cx0nirtS8ezud1zRklvL31slSaW390Ll+LOM4VIIBD68C2N/11V7pPfVtdXoDX LoGXx7JYx3g9HcabUpnKR3CiUH1ITul/SfDgCuetAPAPl1JlaKNV2rO/a6grEAVdtqsI L1m/v/3uzJbBsIVbl/X7ZXnAXHrseYCLlWsLz1J3EdcpMbbRMpCfr0iYtQEqvY9jR8j0 lxBcS438N/0R98WacR9e+LWjQOeW/YRmsEiuo87yfer09BBy190J9BcxsIMXz1Pv1tZ9 +Q== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2ncfypv3rs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Oct 2018 13:13:35 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9UDDTVB009375 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Oct 2018 13:13:29 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9UDDTJK022316; Tue, 30 Oct 2018 13:13:29 GMT Received: from olila.i.net-space.pl (/10.175.193.238) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 30 Oct 2018 06:13:28 -0700 From: Daniel Kiper To: grub-devel@gnu.org Cc: dpsmith.dev@gmail.com, eric.snowberg@oracle.com, javierm@redhat.com, jonmccune@google.com, kanth.ghatraju@oracle.com, keng-yu.lin@hpe.com, konrad.wilk@oracle.com, leif.lindholm@linaro.org, mjg59@srcf.ucam.org, phcoder@gmail.com, philip.b.tricca@intel.com, ross.philipson@oracle.com Subject: [PATCH v4 5/9] verifiers: Add possibility to defer verification to other verifiers Date: Tue, 30 Oct 2018 14:12:54 +0100 Message-Id: <1540905178-28655-6-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1540905178-28655-1-git-send-email-daniel.kiper@oracle.com> References: <1540905178-28655-1-git-send-email-daniel.kiper@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9061 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810300115 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Oct 2018 13:13:51 -0000 This way if a verifier requires verification of a given file it can defer task to another verifier (another authority) if it is not able to do it itself. E.g. shim_lock verifier, posted as a subsequent patch, is able to verify only PE files. This means that it is not able to verify any of GRUB2 modules which have to be trusted on UEFI systems with secure boot enabled. So, it can defer verification to other verifier, e.g. PGP one. I silently assume that other verifiers are trusted and will do good job for us. Or at least they will not do any harm. Signed-off-by: Daniel Kiper --- v4 - suggestions/fixes: - s/GRUB_VERIFY_FLAGS_DEFER/GRUB_VERIFY_FLAGS_DEFER_AUTH/, - improve comments (suggested by Ross Philipson), - improve commit message (suggested by Ross Philipson). --- grub-core/commands/verifiers.c | 23 ++++++++++++++++++++--- include/grub/verify.h | 4 +++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/grub-core/commands/verifiers.c b/grub-core/commands/verifiers.c index 59ea418..c638d5f 100644 --- a/grub-core/commands/verifiers.c +++ b/grub-core/commands/verifiers.c @@ -83,6 +83,7 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type) void *context; grub_file_t ret = 0; grub_err_t err; + int defer = 0; grub_dprintf ("verify", "file: %s type: %d\n", io->name, type); @@ -102,13 +103,27 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type) err = ver->init (io, type, &context, &flags); if (err) goto fail_noclose; + if (flags & GRUB_VERIFY_FLAGS_DEFER_AUTH) + { + defer = 1; + continue; + } if (!(flags & GRUB_VERIFY_FLAGS_SKIP_VERIFICATION)) break; } if (!ver) - /* No verifiers wanted to verify. Just return underlying file. */ - return io; + { + if (defer) + { + grub_error (GRUB_ERR_ACCESS_DENIED, + N_("verification requested but nobody cares: %s"), io->name); + goto fail_noclose; + } + + /* No verifiers wanted to verify. Just return underlying file. */ + return io; + } ret = grub_malloc (sizeof (*ret)); if (!ret) @@ -160,7 +175,9 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type) err = ver->init (io, type, &context, &flags); if (err) goto fail_noclose; - if (flags & GRUB_VERIFY_FLAGS_SKIP_VERIFICATION) + if (flags & GRUB_VERIFY_FLAGS_SKIP_VERIFICATION || + /* Verification done earlier. So, we are happy here. */ + flags & GRUB_VERIFY_FLAGS_DEFER_AUTH) continue; err = ver->write (context, verified->buf, ret->size); if (err) diff --git a/include/grub/verify.h b/include/grub/verify.h index 9f892d8..79022b4 100644 --- a/include/grub/verify.h +++ b/include/grub/verify.h @@ -22,7 +22,9 @@ enum grub_verify_flags { GRUB_VERIFY_FLAGS_SKIP_VERIFICATION = 1, - GRUB_VERIFY_FLAGS_SINGLE_CHUNK = 2 + GRUB_VERIFY_FLAGS_SINGLE_CHUNK = 2, + /* Defer verification to another authority. */ + GRUB_VERIFY_FLAGS_DEFER_AUTH = 4 }; enum grub_verify_string_type -- 1.7.10.4