Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1652872

verify_pefile_signature() and a message field of MZ header in pe.h

From AKASHI Takahiro <takahiro.akashi@linaro.org>
Newsgroups linux.kernel
Subject verify_pefile_signature() and a message field of MZ header in pe.h
Date 2017-05-30 09:10 +0200
Message-ID <tMJrX-44F-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Hi David,

Struct mz_hdr in include/linux/pe.h contains a message[] field.
Should it be part of this structure?
(I googled "MZ format," but didn't find out the exact definition.)

I'm now working on kexec_file_load support on arm64. As arm64's
Image binary can be seen as in PE format, verify_pefile_signature()
is used to assure integrity as on x86.
But this attempt fails (ELIBBAD) at pefile_parse_binary():

        ---8<---
#define chkaddr(base, x, s)                                             \
        do {                                                            \
                if ((x) < base || (s) >= datalen || (x) > datalen - (s)) \
                        return -ELIBBAD;                                \
        } while (0)

        ...

        cursor = sizeof(*mz);

        chkaddr(cursor, mz->peaddr, sizeof(*pe)); <-- Here
        pe = pebuf + mz->peaddr;
        if (pe->magic != PE_MAGIC)
                return -ELIBBAD;
        --->8---

because our Image doesn't have message[] in a pseudo header and so
mz->peaddr is not beyond sizeof(*mz).

I think we can fix this issue, either
(a) remove message[] from struct mz_hdr
(b) modify a check by chkaddr() macro
(c) add a dummy pad into arm64's binary

Which one should we follow here?

Thanks,
-Takahiro AKASHI

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

verify_pefile_signature() and a message field of MZ header in pe.h AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-05-30 09:10 +0200
  Re: verify_pefile_signature() and a message field of MZ header in pe.h Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-05-30 11:50 +0200
  Re: verify_pefile_signature() and a message field of MZ header in pe.h David Howells <dhowells@redhat.com> - 2017-05-30 17:50 +0200

csiph-web