From: Javier Martinez Canillas <fmartine@redhat.com>
To: The development of GNU GRUB <grub-devel@gnu.org>,
Daniel Kiper <daniel.kiper@oracle.com>,
linux-kernel@vger.kernel.org, x86@kernel.org
Cc: bp@alien8.de, eric.snowberg@oracle.com, hpa@zytor.com,
kanth.ghatraju@oracle.com, konrad.wilk@oracle.com,
mingo@redhat.com, phcoder@gmail.com, rdunlap@infradead.org,
ross.philipson@oracle.com
Subject: Re: [GRUB PATCH 1/1] loader/i386/linux: Fix an underflow in the setup_header length calculation
Date: Fri, 13 Dec 2019 13:57:26 +0100 [thread overview]
Message-ID: <74fdf9ed-814b-0fc8-d405-79eb1011b9ee@redhat.com> (raw)
In-Reply-To: <20191202172939.29271-1-daniel.kiper@oracle.com>
Hello Daniel,
On 12/2/19 6:29 PM, Daniel Kiper wrote:
> Recent work around x86 Linux kernel loader revealed an underflow in the
> setup_header length calculation and another related issue. Both lead to
> the memory overwrite and later machine crash.
>
> Currently when the GRUB copies the setup_header into the linux_params
> (struct boot_params, traditionally known as "zero page") it assumes the
> setup_header size as sizeof(linux_i386_kernel_header/lh). This is
> incorrect. It should use the value calculated accordingly to the Linux
> kernel boot protocol. Otherwise in case of pretty old kernel, to be
> exact Linux kernel boot protocol, the GRUB may write more into
> linux_params than it was expected to. Fortunately this is not very big
> issue. Though it has to be fixed. However, there is also an underflow
> which is grave. It happens when
>
> sizeof(linux_i386_kernel_header/lh) > "real size of the setup_header".
>
> Then len value wraps around and grub_file_read() reads whole kernel into
> the linux_params overwriting memory past it. This leads to the GRUB
> memory allocator breakage and finally to its crash during boot.
>
> The patch fixes both issues. Additionally, it moves the code not related to
> grub_memset(linux_params)/grub_memcpy(linux_params)/grub_file_read(linux_params)
> section outside of it to not confuse the reader.
>
Maybe you should add the following tag?
Fixes: e683cfb0cf5 ("loader/i386/linux: Calculate the setup_header length")
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
The patch looks good to me.
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Best regards,
--
Javier Martinez Canillas
Software Engineer - Desktop Hardware Enablement
Red Hat
next prev parent reply other threads:[~2019-12-13 20:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-02 17:29 Daniel Kiper
2019-12-08 22:43 ` Daniel Kiper
2019-12-08 22:47 ` hpa
2019-12-13 12:57 ` Javier Martinez Canillas [this message]
2019-12-13 18:43 ` Ross Philipson
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=74fdf9ed-814b-0fc8-d405-79eb1011b9ee@redhat.com \
--to=fmartine@redhat.com \
--cc=bp@alien8.de \
--cc=daniel.kiper@oracle.com \
--cc=eric.snowberg@oracle.com \
--cc=grub-devel@gnu.org \
--cc=hpa@zytor.com \
--cc=kanth.ghatraju@oracle.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=phcoder@gmail.com \
--cc=rdunlap@infradead.org \
--cc=ross.philipson@oracle.com \
--cc=x86@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®