qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>,
	Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH 2/2] linux-user/gen-vdso: Don't write off the end of buf[]
Date: Thu, 10 Jul 2025 20:31:15 +0100	[thread overview]
Message-ID: <CAFEAcA9y3GNTr5o2LPMH=jgnABSgLC7MBxo58aacmTTxScHGig@mail.gmail.com> (raw)
In-Reply-To: <20250710170707.1299926-3-peter.maydell@linaro.org>

On Thu, 10 Jul 2025 at 18:07, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> In gen-vdso we load in a file and assume it's a valid ELF file.  In
> particular we assume it's big enough to be able to read the ELF
> information in e_ident in the ELF header.
>
> Add a check that the total file length is at least big enough for all
> the e_ident bytes, which is good enough for the code in gen-vdso.c.
> This will catch the most obvious possible bad input file (truncated)
> and allow us to run the sanity checks like "not actually an ELF file"
> without potentially crashing.
>
> The code in elf32_process() and elf64_process() still makes
> assumptions about the file being well-formed, but this is OK because
> we only run it on the vdso binaries that we create ourselves in the
> build process by running the compiler.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Hardening all of elf*_process() seems like overkill, but this is
> an easy check to add.

Subject line should say "read off the end", of course.

-- PMM


  parent reply	other threads:[~2025-07-10 19:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-10 17:07 [PATCH 0/2] linux-user/gen-vdso: minor error handling improvements Peter Maydell
2025-07-10 17:07 ` [PATCH 1/2] linux-user/gen-vdso: Handle fseek() failure Peter Maydell
2025-07-10 17:43   ` Richard Henderson
2025-07-10 17:07 ` [PATCH 2/2] linux-user/gen-vdso: Don't write off the end of buf[] Peter Maydell
2025-07-10 17:46   ` Richard Henderson
2025-07-10 19:31   ` Peter Maydell [this message]
2025-07-10 17:58 ` [PATCH 0/2] linux-user/gen-vdso: minor error handling improvements Richard Henderson
2025-07-10 19:31   ` Peter Maydell

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='CAFEAcA9y3GNTr5o2LPMH=jgnABSgLC7MBxo58aacmTTxScHGig@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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;
as well as URLs for NNTP newsgroup(s).