Received: from list by lists.gnu.org with archive (Exim 4.71) id 1g9sWc-0005Ux-3u for mharc-grub-devel@gnu.org; Tue, 09 Oct 2018 09:58:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g9sWZ-0005Um-TZ for grub-devel@gnu.org; Tue, 09 Oct 2018 09:58:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g9sWV-0007Bx-R8 for grub-devel@gnu.org; Tue, 09 Oct 2018 09:58:11 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:42206) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g9sWV-0007B5-Cl for grub-devel@gnu.org; Tue, 09 Oct 2018 09:58:07 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w99Drt5G110931; Tue, 9 Oct 2018 13:58:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=e4NdGXUdjOLQjteteIIrhugmwEFCNeXkF+wgQLpFuyk=; b=KgLqJh+RDddqd+3DaFjj63+HEuR8KWEiPu76o0t13s4X4XZO2T79d62t9w7KyBqTt5Ow 9asZRqrm4/xRloTw8F2LFZ1qI+l+P5Os7ROzsEqhNhBDeRaprSZOfW8dLOuYsEb2odux 1BSiRo/n7t4vBF/6STL1e0d9+3itaPHJNltUkrTUm2AeLSL+FRxhztUmVl5ZdYiPHAa0 ZQP1PVDcWc43DempxB+7JO3KbjN16BJPB8Ux7nD1bNaKzZJEa1uWtyI0Sjjhhbs9+p5g d/u2t7A9J469NPABbnbuTDcBGdV39Snp6D5Eqox2Rb6fm1NyXgATcqjJ8HGg8jmCeDZi 2Q== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2mxnpqwauv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Oct 2018 13:58:04 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w99Dw37E010219 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 Oct 2018 13:58:04 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w99Dw2Kg004607; Tue, 9 Oct 2018 13:58:02 GMT Received: from olila.i.net-space.pl (/10.175.174.86) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 09 Oct 2018 13:58:01 +0000 Date: Tue, 9 Oct 2018 15:57:56 +0200 From: Daniel Kiper To: Ross Philipson Cc: grub-devel@gnu.org, 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 Subject: Re: [PATCH v3 4/8] verifiers: Add possibility to defer verification to other verifiers Message-ID: <20181009135756.GE4472@olila.i.net-space.pl> References: <1538559415-6233-1-git-send-email-daniel.kiper@oracle.com> <1538559415-6233-5-git-send-email-daniel.kiper@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9040 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1810090138 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 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, 09 Oct 2018 13:58:13 -0000 On Fri, Oct 05, 2018 at 12:09:43PM -0400, Ross Philipson wrote: > On 10/03/2018 05:36 AM, Daniel Kiper wrote: > > This way if a verifier requires verification of a given file it can > > defer task to other verifier 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 > > --- > > grub-core/commands/verify_helper.c | 23 ++++++++++++++++++++--- > > include/grub/verify.h | 3 ++- > > 2 files changed, 22 insertions(+), 4 deletions(-) > > > > diff --git a/grub-core/commands/verify_helper.c b/grub-core/commands/verify_helper.c > > index 7effc5f..ba8b03d 100644 > > --- a/grub-core/commands/verify_helper.c > > +++ b/grub-core/commands/verify_helper.c > > @@ -83,6 +83,7 @@ grub_verify_helper_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_verify_helper_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) > > + { > > + 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; > > + } > > I don't really understand the logic here. Is the idea that if it was > deferred and no one in the chain verified it, it ends up being an error? Yep. > Why is that? Some verifiers may not be able to verify a given file themselves. So, they may require that it have to be done by somebody else. shim_lock verifier is good example. The commit message explains it. > Also defer has different meanings. I think in this context it means > defer verification to another authority as opposed to defer until later. Yes, exactly. I will improve the commit message. > > + /* No verifiers wanted to verify. Just return underlying file. */ > > + return io; > > + } > > > > ret = grub_malloc (sizeof (*ret)); > > if (!ret) > > @@ -160,7 +175,9 @@ grub_verify_helper_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) > > 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..c385e3d 100644 > > --- a/include/grub/verify.h > > +++ b/include/grub/verify.h > > @@ -22,7 +22,8 @@ > > enum grub_verify_flags > > { > > GRUB_VERIFY_FLAGS_SKIP_VERIFICATION = 1, > > - GRUB_VERIFY_FLAGS_SINGLE_CHUNK = 2 > > + GRUB_VERIFY_FLAGS_SINGLE_CHUNK = 2, > > + GRUB_VERIFY_FLAGS_DEFER = 4 > > What is the difference between skip verification and defer? Skip == I do not care here. Defer == "defer verification to another authority". Daniel