From e4f6a1bfa31a2299612bbf9dae402bb38d38b1df Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Fri, 1 Dec 2017 06:37:12 +0000 Subject: [PATCH] loader.efi: efipart should exclude iPXE stub block protocol iPXE does insert stub BLOCK IO protocol handle to rework other issues, this handle is not usable as it does not provide actual implementation. We can detect this situation by checking and validating the BlockSize property, so this update does make sure we have BlockSize at least 512B and its value is power of 2. PR: 223969 Reported by: Jeff Pieper Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D13297 --- stand/efi/libefi/efipart.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stand/efi/libefi/efipart.c b/stand/efi/libefi/efipart.c index 1e161c2bb39..a5a1a822060 100644 --- a/stand/efi/libefi/efipart.c +++ b/stand/efi/libefi/efipart.c @@ -257,6 +257,14 @@ efipart_hdd(EFI_DEVICE_PATH *dp) !blkio->Media->MediaPresent) { return (false); } + + /* + * We assume the block size 512 or greater power of 2. + */ + if (blkio->Media->BlockSize < 512 || + !powerof2(blkio->Media->BlockSize)) { + return (false); + } } return (true); }