efi: skip iPXE block device.

iPXE adds Simple File System Protocol to loaded image handle, as side
effect it also adds Block IO protocol (according to comments, to work
around some bugs in EDK2). GRUB assumes that every device with Block IO
is disk and skips network initialization entirely. But iPXE Block IO
implementation is just a stub which always fails for every operation
so cannot be used. Attempt to detect and skip such devices.

We are using media ID which iPXE sets to "iPXE" and block IO size in
hope that no real device would announce 1B block ...

Closes: 50518
This commit is contained in:
Andrei Borzenkov 2017-03-14 04:12:32 +00:00 committed by Vladimir Serbinenko
parent bcf3c55531
commit c42cb97f08
1 changed files with 9 additions and 0 deletions

View File

@ -80,6 +80,15 @@ make_devices (void)
/* This should not happen... Why? */
continue;
/* iPXE adds stub Block IO protocol to loaded image device handle. It is
completely non-functional and simply returns an error for every method.
So attempt to detect and skip it. Magic number is literal "iPXE" and
check block size as well */
/* FIXME: shoud we close it? We do not do it elsewhere */
if (bio->media && bio->media->media_id == 0x69505845U &&
bio->media->block_size == 1)
continue;
d = grub_malloc (sizeof (*d));
if (! d)
{