mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: dhowells@redhat.com
Cc: ard.biesheuvel@linaro.org, keyrings@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: verify_pefile_signature() and a message field of MZ header in pe.h
Date: Tue, 30 May 2017 16:10:23 +0900	[thread overview]
Message-ID: <20170530071022.GB26483@linaro.org> (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

             reply	other threads:[~2017-05-30  7:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-30  7:10 AKASHI Takahiro [this message]
2017-05-30  9:41 ` Ard Biesheuvel
2017-05-30 15:47 ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170530071022.GB26483@linaro.org \
    --to=takahiro.akashi@linaro.org \
    --cc=ard.biesheuvel@linaro.org \
    --cc=dhowells@redhat.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®