From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web11.1420.1579201650331384007 for ; Thu, 16 Jan 2020 11:07:30 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Fr/9eBju; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579201649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qwi7v4j0RJT2hL/yJI3vgtGJ9Pkulqa124x5VHE8c6w=; b=Fr/9eBjuXdQryUU+RA15scpYKdUY6wL+9uA1ebuO3y9vhauZLTMoRrUutjaSvR/NNzfBs+ ZV2vBkFzx8FaXsJjAGm1o8a9uno1HxkK18haA+TqynAhptxw408n41eIJgI802v6OgZfHr GnyRdSsxh311zGY66W9Jd3KqbnTvqAI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-366-cQYBxeI7M-u1WgQoqkX72w-1; Thu, 16 Jan 2020 14:07:26 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 140D8DB23; Thu, 16 Jan 2020 19:07:25 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-120.ams2.redhat.com [10.36.116.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBD9180890; Thu, 16 Jan 2020 19:07:23 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Chao Zhang , Jian J Wang , Jiewen Yao Subject: [PATCH 11/11] SecurityPkg/DxeImageVerificationHandler: fix "defer" vs. "deny" policies Date: Thu, 16 Jan 2020 20:07:05 +0100 Message-Id: <20200116190705.18816-12-lersek@redhat.com> In-Reply-To: <20200116190705.18816-1-lersek@redhat.com> References: <20200116190705.18816-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: cQYBxeI7M-u1WgQoqkX72w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: base64 SW4gRHhlSW1hZ2VWZXJpZmljYXRpb25IYW5kbGVyKCksIHdlIHNob3VsZCByZXR1cm4gRUZJX1NF Q1VSSVRZX1ZJT0xBVElPTgpmb3IgYSByZWplY3RlZCBpbWFnZSBvbmx5IGlmIHRoZSBwbGF0Zm9y bSBzZXRzCkRFRkVSX0VYRUNVVEVfT05fU0VDVVJJVFlfVklPTEFUSU9OIGFzIHRoZSBwb2xpY3kg Zm9yIHRoZSBpbWFnZSdzIHNvdXJjZS4KT3RoZXJ3aXNlLCBFRklfQUNDRVNTX0RFTklFRCBtdXN0 IGJlIHJldHVybmVkLgoKUmlnaHQgbm93LCBFRklfU0VDVVJJVFlfVklPTEFUSU9OIGlzIHJldHVy bmVkIGZvciBhbGwgcmVqZWN0ZWQgaW1hZ2VzLAp3aGljaCBpcyB3cm9uZyAtLSBpdCBjYXVzZXMg TG9hZEltYWdlKCkgdG8gaG9sZCBvbiB0byByZWplY3RlZCBpbWFnZXMgKGluCnVudHJ1c3RlZCBz dGF0ZSksIGZvciBmdXJ0aGVyIHBsYXRmb3JtIGFjdGlvbnMuIEhvd2V2ZXIsIGlmIGEgcGxhdGZv cm0KYWxyZWFkeSBzZXQgREVOWV9FWEVDVVRFX09OX1NFQ1VSSVRZX1ZJT0xBVElPTiwgdGhlIHBs YXRmb3JtIHdpbGwgbm90CmV4c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R4ZUlt YWdlVmVyaWZpY2F0aW9uTGliLmMKQEAgLTEzODUsMTcwICsxMzg1LDE3MSBAQCBCT09MRUFOCiBJ c0FsbG93ZWRCeURiICgNCiAgIElOIFVJTlQ4ICAgICAgICAgICAgICAqQXV0aERhdGEsDQogICBJ TiBVSU5UTiAgICAgICAgICAgICAgQXV0aERhdGFTaXplDQogICApDQogew0KICAgRUZJX1NUQVRV UyAgICAgICAgICAgICAgICBTdGF0dXM7DQogICBCT09MRUFOICAgICAgICAgICAgICAgICAgIFZl cmlmeVN0YXR1czsNCiAgIEVGSV9TSUdOQVRVUkVfTElTVCAgICAgICAgKkNlcnRMaXN0Ow0KICAg RUZJX1NJR05BVFVSRV9EQVRBICAgICAgICAqQ2VydERhdGE7DQogICBVSU5UTiAgICAgICAgICAg ICAgICAgICAgIERhdGFTaXplOw0KICAgVUlOVDggICAgICAgICAgICAgICAgICAgICAqRGF0YTsN CiAgIFVJTlQ4ICAgICAgICAgICAgICAgICAgICAgKlJvb3RDZXJ0Ow0KICAgVUlOVE4gICAgICAg ICAgICAgICAgICAgICBSb290Q2VydFNpemU7DQogICBVSU5UTiAgICAgICAgICAgICAgICAgICAg IEluZGV4Ow0KICAgVUlOVE4gICAgICAgICAgICAgICAgICAgICBDZXJ0Q291bnQ7DQogICBVSU5U TiAgICAgICAgICAgICAgICAgICAgIERieERhdGFTaXplOw0KICAgVUlOVDggICAgICAgICAgICAg ICAgICAgICAqRGJ4RGF0YTsNCiAgIEVGSV9USU1FICAgICAgICAgICAgICAgICAgUmV2b2NhdGlv blRpbWU7DQogDQogICBEYXRhICAgICAgICAgICAgICA9IE5VTEw7DQogICBDZXJ0TGlzdCAgICAg ICAgICA9IE5VTEw7DQogICBDZXJ0RGF0YSAgICAgICAgICA9IE5VTEw7DQogICBSb290Q2VydCAg ICAgICAgICA9IE5VTEw7DQogICBEYnhEYXRhICAgICAgICAgICA9IE5VTEw7DQogICBSb290Q2Vy dFNpemUgICAgICA9IDA7DQogICBWZX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IHsNCiAgICAgICAgIENl cnREYXRhICA9IChFRklfU0lHTkFUVVJFX0RBVEEgKikgKChVSU5UOCAqKSBDZXJ0TGlzdCArIHNp emVvZiAoRUZJX1NJR05BVFVSRV9MSVNUKSArIENlcnRMaXN0LT5TaWduYXR1cmVIZWFkZXJTaXpl KTsNCiAgICAgICAgIENlcnRDb3VudCA9IChDZXJ0TGlzdC0+U2lnbmF0dXJlTGlzdFNpemUgLSBz aXplb2YgKEVGSV9TSUdOQVRVUkVfTElTVCkgLSBDZXJ0TGlzdC0+U2lnbmF0dXJlSGVhZGVyU2l6 ZSkgLyBDZXJ0TGlzdC0+U2lnbmF0dXJlU2l6ZTsNCiANCiAgICAgICAgIGZvciAoSW5kZXggPSAw OyBJbmRleCA8IENlcnRDb3VudDsgSW5kZXgrKykgew0KICAgICAgICAgICAvLw0KICAgICAgICAg ICAvLyBJdGVyYXRlIGVhY2ggU2lnbmF0dXJlIERhdGEgTm9kZSB3aXRoaW4gdGhpcyBDZXJ0TGlz dCBmb3IgdmVyaWZ5Lg0KICAgICAgICAgICAvLw0KICAgICAgICAgICBSb290Q2VydCAgICAgPSBD ZXJ0RGF0YS0+U2lnbmF0dXJlRGF0YTsNCiAgICAgICAgICAgUm9vdENlcnRTaXplID0gQ2VydExp c3QtPlNpZ25hdHVyZVNpemUgLSBzaXplb2YgKEVGSV9HVUlEKTsNCiANCiAgICAgICAgICAgLy8N CiAgICAgICAgICAgLy8gQ2FsbCBBdXRoZW50aWNvZGVWZXJpZnkgbGlicmFyeSB0byBWZXJpZnkg QXV0aGVudGljb2RlIHN0cnVjdC4NCiAgICAgICAgICAgLy8NCiAgICAgICAgICAgVmVyaWZ5U3Rh dHVzID0gQXV0aGVudGljb2RlVmVyaWZ5ICgNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBB dXRoRGF0YSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBdXRoRGF0YVNpemUsDQogICAg ICAgICAgICAgICAgICAgICAgICAgICAgUm9vdENlcnQsDQogICAgICAgICAgICAgICAgICAgICAg ICAgICAgUm9vdENlcnRTaXplLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1JbWFnZURp Z2VzdCwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtSW1hZ2VEaWdlc3RTaXplDQogICAg ICAgICAgICAgICAgICAgICAgICAgICAgKTsNCiAgICAgICAgICAgaWYgKFZlcmlmeVN0YXR1cykg ew0KICAgICAgICAgICAgIC8vDQogICAgICAgICAgICAgLy8gSGVyZSBXZSBzdGlsbCBuZWVkIHRv IGNoZWNrIGlmIHRoaXMgUm9vdENlcnQncyBIYXNoIGlzIHJldm9rZWQNCiAgICAgICAgICAgICAv Lw0KICAgICAgICAgICAgIFN0YXR1cyAgID0gZ1JULT5HZXRWYXJpYWJsZSAoRUZJX0lNQUdFX1NF Q1VSSVRZX0RBVEFCQVNFMSwgJmdFZmlJbWFnZVNlY3VyaXR5RGF0YWJhc2VHdWlkLCBOVUxMLCAm RGJ4RGF0YVNpemUsIE5VTEwpOw0KICAgICAgICAgICAgIGlmIChTdGF0dXMgPT0gRUZJX0JVRkZF Ul9UT09fU01BTEwpIHsNCiAgICAgICAgICAgICAgIGdvdG8gRG9uZTsNCiAgICAgICAgICAgICB9 DQogICAgICAgICAgICAgRGJ4RGF0YSA9IChVSU5UOCAqKSBBbGxvY2F0ZVplcm9Qb29sIChEYnhE YXRhU2l6ZSk7DQogICAgICAgICAgICAgaWYgKERieERhdGEgPT0gTlVMTCkgew0KICAgICAgICAg ICAgICAgZ290byBEb25lOw0KICAgICAgICAgICAgIH0NCiANCiAgICAgICAgICAgICBTdGF0dXMg PSBnUlQtPkdldFZhcmlhYmxlIChFRklfSU1BR0VfU0VDVVJJVFlfREFUQUJBU0UxLCAmZ0VmaUlt YWdlU2VjdXJpdHlEYXRhYmFzZUd1aWQsIE5VTEwsICZEYnhEYXRhU2l6ZSwgKFZPSUQgKikgRGJ4 RGF0YSk7DQogICAgICAgICAgICAgaWYgKEVGSV9FUlJPUiAoU3RhdHVzKSkgew0KICAgICAgICAg ICAgICAgZ290byBEb25lOw0KICAgICAgICAgICAgIH0NCiANCiAgICAgICAgICAgICBpZiAoSXND ZXJ0SGFzaEZvdW5kSW5EYXRhYmFzZSAoUm9vdENlcnQsIFJvb3RDZXJ0U2l6ZSwgKEVGSV9TSUdO QVRVUkVfTElTVCAqKURieERhdGEsIERieERhdGFTaXplLCAmUmV2b2NhdGlvblRpbWUpKSB7DQog ICAgICAgICAgICAgICAvLw0KICAgICAgICAgICAgICAgLy8gQ2hlY2sgdGhlIHRpbWVzdGFtcCBz aWduYXR1cmUgYW5kIHNpZ25pbmcgdGltZSB0byBkZXRlcm1pbmUgaWYgdGhlIFJvb3RDZXJ0IGNh biBiZSB0cnVzdGVkLg0KICAgICAgICAgICAgICAgLy8NCiAgICAgICAgICAgICAgIFZlcmlmeVN0 YXR1cyA9IFBhc3NUaW1lc3RhbXBDaGVjayAoQXV0aERhdGEsIEF1dGhEYXRhU2l6ZSwgJlJldm9j YXRpb25UaW1lKTsNCiAgICAgICAgICAgICAgIGlmICghVmVyaWZ5U3RhdHVzKSB7DQogICAgICAg ICAgICAgICAgIERFQlVHICgoREVCVUdfSU5GTywgIkR4ZUltYWdlVmVyaWZpY2F0aW9uTGliOiBJ bWFnZSBpcyBzaWduZWQgYW5kIHNpZ25hdHVyZSBpcyBhY2NlcHRlZCBieSBEQiwgYnV0IGl0cyBy b290IGNlcnQgZmFpbGVkIHRoZSB0aW1lc3RhbXAgY2hlY2suXG4iKSk7DQogICAgICAgICAgICAg ICB9DQogICAgICAgICAgICAgfQ0KIA0KICAgICAgICAgICAgIGdvdG8gRG9uZTsNCiAgICAgICAg ICAgfQ0KIA0KICAgICAgICAgICBDZXJ0RGF0YSA9IChFRklfU0lHTkFUVVJFX0RBVEEgKikgKChV SU5UOCAqKSBDZXJ0RGF0YSArIENlcnRMaXN0LT5TaWduYXR1cmVTaXplKTsNCiAgICAgICAgIH0N CiAgICA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gIHRoYXQgdGhlIERY RSBGb3VuZGF0aW9uIG1heSB1c2UgdGhlIGZpbGUuDQogICBAcmV0dmFsIEVGSV9TVUNDRVNTICAg ICAgICAgICAgVGhlIGRldmljZSBwYXRoIHNwZWNpZmllZCBieSBOVUxMIGRldmljZSBwYXRoIERl dmljZVBhdGgNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmQgbm9uLU5VTEwg RmlsZUJ1ZmZlciBkaWQgYXV0aGVudGljYXRlLCBhbmQgdGhlIHBsYXRmb3JtDQogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgcG9saWN5IGRpY3RhdGVzIHRoYXQgdGhlIERYRSBGb3Vu ZGF0aW9uIG1heSBleGVjdXRlIHRoZSBpbWFnZSBpbg0KICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIEZpbGVCdWZmZXIuDQogICBAcmV0dmFsIEVGSV9TRUNVUklUWV9WSU9MQVRJT04g VGhlIGZpbGUgc3BlY2lmaWVkIGJ5IEZpbGUgZGlkIG5vdCBhdXRoZW50aWNhdGUsIGFuZA0KICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoZSBwbGF0Zm9ybSBwb2xpY3kgZGljdGF0 ZXMgdGhhdCBGaWxlIHNob3VsZCBiZSBwbGFjZWQNCiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICBpbiB0aGUgdW50cnVzdGVkIHN0YXRlLiBUaGUgaW1hZ2UgaGFzIGJlZW4gYWRkZWQg dG8gdGhlIGZpbGUNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleGVjdXRpb24g dGFibGUuDQogICBAcmV0dmFsIEVGSV9BQ0NFU1NfREVOSUVEICAgICAgVGhlIGZpbGUgc3BlY2lm aWVkIGJ5IEZpbGUgYW5kIEZpbGVCdWZmZXIgZGlkIG5vdA0KICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIGF1dGhlbnRpY2F0ZSwgYW5kIHRoZSBwbGF0Zm9ybSBwb2xpY3kgZGljdGF0 ZXMgdGhhdCB0aGUgRFhFDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRm91bmRh dGlvbiBtYW55IG5vdCB1c2UgRmlsZS4NCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBGb3VuZGF0aW9uIG1heSBub3QgdXNlIEZpbGUuIFRoZSBpbWFnZSBoYXMNCisgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICBiZWVuIGFkZGVkIHRvIHRoZSBmaWxlIGV4ZWN1dGlvbiB0 YWJsZS4NCiANCiAqKi8NCiBFRklfU1RBVFVTDQpAQCAtMTU1NiwzNDQgKzE1NTcsMzQ4IEBAIEVG SUFQSQogRHhlSW1hZ2VWZXJpZmljYXRpb25IYW5kbGVyICgNCiAgIElOICBVSU5UMzIgICAgICAg ICAgICAgICAgICAgICAgICAgICBBdXRoZW50aWNhdGlvblN0YXR1cywNCiAgIElOICBDT05TVCBF RklfREVWSUNFX1BBVEhfUFJPVE9DT0wgICAqRmlsZSwNCiAgIElOICBWT0lEICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAqRmlsZUJ1ZmZlciwNCiAgIElOICBVSU5UTiAgICAgICAgICAgICAg ICAgICAgICAgICAgICBGaWxlU2l6ZSwNCiAgIElOICBCT09MRUFOICAgICAgICAgICAgICAgICAg ICAgICAgICBCb290UG9saWN5DQogICApDQogew0KICAgRUZJX0lNQUdFX0RPU19IRUFERVIgICAg ICAgICAgICAgICAgICpEb3NIZHI7DQogICBCT09MRUFOICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgSXNWZXJpZmllZDsNCiAgIEVGSV9TSUdOQVRVUkVfTElTVCAgICAgICAgICAgICAgICAg ICAqU2lnbmF0dXJlTGlzdDsNCiAgIFVJTlROICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBTaWduYXR1cmVMaXN0U2l6ZTsNCiAgIEVGSV9TSUdOQVRVUkVfREFUQSAgICAgICAgICAgICAg ICAgICAqU2lnbmF0dXJlOw0KICAgRUZJX0lNQUdFX0VYRUNVVElPTl9BQ1RJT04gICAgICAgICAg IEFjdGlvbjsNCiAgIFdJTl9DRVJUSUZJQ0FURSAgICAgICAgICAgICAgICAgICAgICAqV2luQ2Vy dGlmaWNhdGU7DQogICBVSU5UMzIgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUG9saWN5 Ow0KICAgVUlOVDggICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICpTZWN1cmVCb290Ow0K ICAgUEVfQ09GRl9MT0FERVJfSU1BR0VfQ09OVEVYVCAgICAgICAgIEltYWdlQ29udGV4dDsNCiAg IFVJTlQzMiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBOdW1iZXJPZlJ2YUFuZFNpemVz Ow0KICAgV0lOX0NFUlRJRklDQVRFX0VGSV9QS0NTICAgICAgICAgICAgICpQa2NzQ2VydERhdGE7 DQogICBXSU5fQ0VSVElGSUNBVEVfVUVGSV9HVUlEICAgICAgICAgICAgKldpbkNlcnRVZWZpR3Vp ZDsNCiAgIFVJTlQ4ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqQXV0aERhdGE7DQog ICBVSU5UTiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQXV0aERhdGFTaXplOw0KICAg RUZJX0lNQUdFX0RBVEFfRElSRUNUT1JZICAgICAgICAgICAgICpTZWNEYXRhRGlyOw0KICAgVUlO VDMyICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9mZlNldDsNCiAgIENIQVIxNiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAqTmFtZVN0cjsNCiAgIFJFVFVSTl9TVEFUVVMgICAg ICAgICAgICAgICAgICAgICAgICBQZUNvZmZTdGF0dXM7DQogICBFRklfU1RBVFVTICAgICAgICAg ICAgICAgICAgICAgICAgICAgSGFzaFN0YXR1czsNCiANCiAgIFNpZ25hdHVyZUxpc3QgICAgID0g TlVMTDsNC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