efi_loader: image_loader: replace debug to EFI_PRINT
Just for style consistency, replace all the uses of debug() to EFI_PRINT() in efi_image_loader.c. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
		
							parent
							
								
									ce3c3865b0
								
							
						
					
					
						commit
						1b6c08548c
					
				|  | @ -325,8 +325,8 @@ bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, | ||||||
| 		authoff = opt->DataDirectory[ctidx].VirtualAddress; | 		authoff = opt->DataDirectory[ctidx].VirtualAddress; | ||||||
| 		authsz = opt->DataDirectory[ctidx].Size; | 		authsz = opt->DataDirectory[ctidx].Size; | ||||||
| 	} else { | 	} else { | ||||||
| 		debug("%s: Invalid optional header magic %x\n", __func__, | 		EFI_PRINT("%s: Invalid optional header magic %x\n", __func__, | ||||||
| 		      nt->OptionalHeader.Magic); | 			  nt->OptionalHeader.Magic); | ||||||
| 		goto err; | 		goto err; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -336,7 +336,7 @@ bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, | ||||||
| 			    nt->FileHeader.SizeOfOptionalHeader); | 			    nt->FileHeader.SizeOfOptionalHeader); | ||||||
| 	sorted = calloc(sizeof(IMAGE_SECTION_HEADER *), num_sections); | 	sorted = calloc(sizeof(IMAGE_SECTION_HEADER *), num_sections); | ||||||
| 	if (!sorted) { | 	if (!sorted) { | ||||||
| 		debug("%s: Out of memory\n", __func__); | 		EFI_PRINT("%s: Out of memory\n", __func__); | ||||||
| 		goto err; | 		goto err; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -355,13 +355,13 @@ bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, | ||||||
| 		efi_image_region_add(regs, efi + sorted[i]->PointerToRawData, | 		efi_image_region_add(regs, efi + sorted[i]->PointerToRawData, | ||||||
| 				     efi + sorted[i]->PointerToRawData + size, | 				     efi + sorted[i]->PointerToRawData + size, | ||||||
| 				     0); | 				     0); | ||||||
| 		debug("section[%d](%s): raw: 0x%x-0x%x, virt: %x-%x\n", | 		EFI_PRINT("section[%d](%s): raw: 0x%x-0x%x, virt: %x-%x\n", | ||||||
| 		      i, sorted[i]->Name, | 			  i, sorted[i]->Name, | ||||||
| 		      sorted[i]->PointerToRawData, | 			  sorted[i]->PointerToRawData, | ||||||
| 		      sorted[i]->PointerToRawData + size, | 			  sorted[i]->PointerToRawData + size, | ||||||
| 		      sorted[i]->VirtualAddress, | 			  sorted[i]->VirtualAddress, | ||||||
| 		      sorted[i]->VirtualAddress | 			  sorted[i]->VirtualAddress | ||||||
| 			+ sorted[i]->Misc.VirtualSize); | 			    + sorted[i]->Misc.VirtualSize); | ||||||
| 
 | 
 | ||||||
| 		bytes_hashed += size; | 		bytes_hashed += size; | ||||||
| 	} | 	} | ||||||
|  | @ -369,8 +369,8 @@ bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, | ||||||
| 
 | 
 | ||||||
| 	/* 3. Extra data excluding Certificates Table */ | 	/* 3. Extra data excluding Certificates Table */ | ||||||
| 	if (bytes_hashed + authsz < len) { | 	if (bytes_hashed + authsz < len) { | ||||||
| 		debug("extra data for hash: %zu\n", | 		EFI_PRINT("extra data for hash: %lu\n", | ||||||
| 		      len - (bytes_hashed + authsz)); | 			  len - (bytes_hashed + authsz)); | ||||||
| 		efi_image_region_add(regs, efi + bytes_hashed, | 		efi_image_region_add(regs, efi + bytes_hashed, | ||||||
| 				     efi + len - authsz, 0); | 				     efi + len - authsz, 0); | ||||||
| 	} | 	} | ||||||
|  | @ -378,18 +378,19 @@ bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, | ||||||
| 	/* Return Certificates Table */ | 	/* Return Certificates Table */ | ||||||
| 	if (authsz) { | 	if (authsz) { | ||||||
| 		if (len < authoff + authsz) { | 		if (len < authoff + authsz) { | ||||||
| 			debug("%s: Size for auth too large: %u >= %zu\n", | 			EFI_PRINT("%s: Size for auth too large: %u >= %zu\n", | ||||||
| 			      __func__, authsz, len - authoff); | 				  __func__, authsz, len - authoff); | ||||||
| 			goto err; | 			goto err; | ||||||
| 		} | 		} | ||||||
| 		if (authsz < sizeof(*auth)) { | 		if (authsz < sizeof(*auth)) { | ||||||
| 			debug("%s: Size for auth too small: %u < %zu\n", | 			EFI_PRINT("%s: Size for auth too small: %u < %zu\n", | ||||||
| 			      __func__, authsz, sizeof(*auth)); | 				  __func__, authsz, sizeof(*auth)); | ||||||
| 			goto err; | 			goto err; | ||||||
| 		} | 		} | ||||||
| 		*auth = efi + authoff; | 		*auth = efi + authoff; | ||||||
| 		*auth_len = authsz; | 		*auth_len = authsz; | ||||||
| 		debug("WIN_CERTIFICATE: 0x%x, size: 0x%x\n", authoff, authsz); | 		EFI_PRINT("WIN_CERTIFICATE: 0x%x, size: 0x%x\n", authoff, | ||||||
|  | 			  authsz); | ||||||
| 	} else { | 	} else { | ||||||
| 		*auth = NULL; | 		*auth = NULL; | ||||||
| 		*auth_len = 0; | 		*auth_len = 0; | ||||||
|  | @ -423,19 +424,19 @@ static bool efi_image_unsigned_authenticate(struct efi_image_regions *regs) | ||||||
| 
 | 
 | ||||||
| 	dbx = efi_sigstore_parse_sigdb(L"dbx"); | 	dbx = efi_sigstore_parse_sigdb(L"dbx"); | ||||||
| 	if (!dbx) { | 	if (!dbx) { | ||||||
| 		debug("Getting signature database(dbx) failed\n"); | 		EFI_PRINT("Getting signature database(dbx) failed\n"); | ||||||
| 		goto out; | 		goto out; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	db = efi_sigstore_parse_sigdb(L"db"); | 	db = efi_sigstore_parse_sigdb(L"db"); | ||||||
| 	if (!db) { | 	if (!db) { | ||||||
| 		debug("Getting signature database(db) failed\n"); | 		EFI_PRINT("Getting signature database(db) failed\n"); | ||||||
| 		goto out; | 		goto out; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* try black-list first */ | 	/* try black-list first */ | ||||||
| 	if (efi_signature_verify_with_sigdb(regs, NULL, dbx, NULL)) { | 	if (efi_signature_verify_with_sigdb(regs, NULL, dbx, NULL)) { | ||||||
| 		debug("Image is not signed and rejected by \"dbx\"\n"); | 		EFI_PRINT("Image is not signed and rejected by \"dbx\"\n"); | ||||||
| 		goto out; | 		goto out; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -443,7 +444,7 @@ static bool efi_image_unsigned_authenticate(struct efi_image_regions *regs) | ||||||
| 	if (efi_signature_verify_with_sigdb(regs, NULL, db, NULL)) | 	if (efi_signature_verify_with_sigdb(regs, NULL, db, NULL)) | ||||||
| 		ret = true; | 		ret = true; | ||||||
| 	else | 	else | ||||||
| 		debug("Image is not signed and not found in \"db\" or \"dbx\"\n"); | 		EFI_PRINT("Image is not signed and not found in \"db\" or \"dbx\"\n"); | ||||||
| 
 | 
 | ||||||
| out: | out: | ||||||
| 	efi_sigstore_free(db); | 	efi_sigstore_free(db); | ||||||
|  | @ -504,7 +505,7 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) | ||||||
| 
 | 
 | ||||||
| 	if (!efi_image_parse(efi, efi_size, ®s, &wincerts, | 	if (!efi_image_parse(efi, efi_size, ®s, &wincerts, | ||||||
| 			     &wincerts_len)) { | 			     &wincerts_len)) { | ||||||
| 		debug("Parsing PE executable image failed\n"); | 		EFI_PRINT("Parsing PE executable image failed\n"); | ||||||
| 		goto err; | 		goto err; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -520,13 +521,13 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) | ||||||
| 	 */ | 	 */ | ||||||
| 	db = efi_sigstore_parse_sigdb(L"db"); | 	db = efi_sigstore_parse_sigdb(L"db"); | ||||||
| 	if (!db) { | 	if (!db) { | ||||||
| 		debug("Getting signature database(db) failed\n"); | 		EFI_PRINT("Getting signature database(db) failed\n"); | ||||||
| 		goto err; | 		goto err; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	dbx = efi_sigstore_parse_sigdb(L"dbx"); | 	dbx = efi_sigstore_parse_sigdb(L"dbx"); | ||||||
| 	if (!dbx) { | 	if (!dbx) { | ||||||
| 		debug("Getting signature database(dbx) failed\n"); | 		EFI_PRINT("Getting signature database(dbx) failed\n"); | ||||||
| 		goto err; | 		goto err; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -535,26 +536,27 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) | ||||||
| 	     (void *)wincert < (void *)wincerts + wincerts_len; | 	     (void *)wincert < (void *)wincerts + wincerts_len; | ||||||
| 	     wincert = (void *)wincert + ALIGN(wincert->dwLength, 8)) { | 	     wincert = (void *)wincert + ALIGN(wincert->dwLength, 8)) { | ||||||
| 		if (wincert->dwLength < sizeof(*wincert)) { | 		if (wincert->dwLength < sizeof(*wincert)) { | ||||||
| 			debug("%s: dwLength too small: %u < %zu\n", | 			EFI_PRINT("%s: dwLength too small: %u < %zu\n", | ||||||
| 			      __func__, wincert->dwLength, sizeof(*wincert)); | 				  __func__, wincert->dwLength, | ||||||
|  | 				  sizeof(*wincert)); | ||||||
| 			goto err; | 			goto err; | ||||||
| 		} | 		} | ||||||
| 		msg = pkcs7_parse_message((void *)wincert + sizeof(*wincert), | 		msg = pkcs7_parse_message((void *)wincert + sizeof(*wincert), | ||||||
| 					  wincert->dwLength - sizeof(*wincert)); | 					  wincert->dwLength - sizeof(*wincert)); | ||||||
| 		if (IS_ERR(msg)) { | 		if (IS_ERR(msg)) { | ||||||
| 			debug("Parsing image's signature failed\n"); | 			EFI_PRINT("Parsing image's signature failed\n"); | ||||||
| 			msg = NULL; | 			msg = NULL; | ||||||
| 			goto err; | 			goto err; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		/* try black-list first */ | 		/* try black-list first */ | ||||||
| 		if (efi_signature_verify_with_sigdb(regs, msg, dbx, NULL)) { | 		if (efi_signature_verify_with_sigdb(regs, msg, dbx, NULL)) { | ||||||
| 			debug("Signature was rejected by \"dbx\"\n"); | 			EFI_PRINT("Signature was rejected by \"dbx\"\n"); | ||||||
| 			goto err; | 			goto err; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (!efi_signature_verify_signers(msg, dbx)) { | 		if (!efi_signature_verify_signers(msg, dbx)) { | ||||||
| 			debug("Signer was rejected by \"dbx\"\n"); | 			EFI_PRINT("Signer was rejected by \"dbx\"\n"); | ||||||
| 			goto err; | 			goto err; | ||||||
| 		} else { | 		} else { | ||||||
| 			ret = true; | 			ret = true; | ||||||
|  | @ -562,14 +564,14 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) | ||||||
| 
 | 
 | ||||||
| 		/* try white-list */ | 		/* try white-list */ | ||||||
| 		if (!efi_signature_verify_with_sigdb(regs, msg, db, &cert)) { | 		if (!efi_signature_verify_with_sigdb(regs, msg, db, &cert)) { | ||||||
| 			debug("Verifying signature with \"db\" failed\n"); | 			EFI_PRINT("Verifying signature with \"db\" failed\n"); | ||||||
| 			goto err; | 			goto err; | ||||||
| 		} else { | 		} else { | ||||||
| 			ret = true; | 			ret = true; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (!efi_signature_verify_cert(cert, dbx)) { | 		if (!efi_signature_verify_cert(cert, dbx)) { | ||||||
| 			debug("Certificate was rejected by \"dbx\"\n"); | 			EFI_PRINT("Certificate was rejected by \"dbx\"\n"); | ||||||
| 			goto err; | 			goto err; | ||||||
| 		} else { | 		} else { | ||||||
| 			ret = true; | 			ret = true; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue