GELI BIOS weirdness

Eric McCorkle eric at metricspace.net
Mon Feb 13 20:24:19 UTC 2017


Hello everyone,

I ran into an apparent bug while trying to test a patch related to some
GELI boot work.  This particular patch involves *BIOS* GELI-on-root (not
EFI).

I created an image for qemu with a single gpt disk having a freebsd-boot
and freebsd-ufs partition, with the freebsd-ufs partition actually
having a GELI volume.

The gptboot phase crashes with an illegal instruction.  I tracked this
down to eli_metadata_softc (defined in sys/geom/eli/g_eli.h),
specifically to the mod operation near the end.  Code here:

> if (!(sc->sc_flags & G_ELI_FLAG_AUTH))
>         sc->sc_mediasize -= (sc->sc_mediasize % sc->sc_sectorsize);
> else {

This crash also occurs on a build from master.

The crash dump shows eip pointing to the following code:

66 0f 38 f6 f0 31 c6 8b - 4d 14 89 cf c1 ff 1f 8b

The the first 5 bytes of this looks like it's supposed to be an extended
DIV instruction, which is what I would expect, except the opcode is
wrong (it's adc instead), which doesn't end up corresponding to any
valid form of an extended instruction (the 66 prefix).  Examination of
the disassembly confirms this, and the surrounding instructions match
what you would expect from the C code.


Unless I'm missing something, this would seem to indicate a compiler
bug.  More importantly, it would seem to indicate that anyone building
GELI-enabled gptboot from master will end up with a nonfunctional binary.


Can someone else please confirm this, and if so, I think it's probably
time to file a bug report.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20170213/20e6c326/attachment.sig>


More information about the freebsd-hackers mailing list