linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: bugzilla-daemon@bugzilla.kernel.org,
	linux-efi <linux-efi@vger.kernel.org>,
	Matthew Garrett <mjg59@google.com>
Subject: Re: [Bug 203761] New: efivar_ssdt_iter is subject to stack corruption when the input name_size is 0
Date: Fri, 31 May 2019 11:02:57 +0200	[thread overview]
Message-ID: <CAKv+Gu8vuTLGX6h2T=d_EnzQx-XirD+yTV5AX_zA9vdtP1qU7A@mail.gmail.com> (raw)
In-Reply-To: <bug-203761-199677@https.bugzilla.kernel.org/>

On Thu, 30 May 2019 at 18:04, <bugzilla-daemon@bugzilla.kernel.org> wrote:
>
> https://bugzilla.kernel.org/show_bug.cgi?id=203761
>
>             Bug ID: 203761
>            Summary: efivar_ssdt_iter is subject to stack corruption when
>                     the input name_size is 0
>            Product: EFI
>            Version: unspecified
>     Kernel Version: 4.18.0-20-generic
>           Hardware: Intel
>                 OS: Linux
>               Tree: Mainline
>             Status: NEW
>           Severity: high
>           Priority: P1
>          Component: Boot
>           Assignee: efi@kernel-bugs.osdl.org
>           Reporter: steven.yutang@gmail.com
>         Regression: No
>
> Reported also at https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1830951
>
> function efivar_ssdt_iter in efi.c has the following code:
>
>         char utf8_name[EFIVAR_SSDT_NAME_MAX];
>         int limit = min_t(unsigned long, EFIVAR_SSDT_NAME_MAX, name_size);
>         ucs2_as_utf8(utf8_name, name, limit - 1);
>
> In this short snippet of code, we can see typical issues due to unsigned long
> <-> int casting.
>
> 1. mismatch of signedness.
> 2. loss of precision.
>
> The input of name_size is signed long, gets compared against an unsigned long
> of a fixed size, then stored as a signed int (this is mostly okay because of
> the known max size), but it then gets passed to a function takes unsigned long
> without checking the range.
>
> Here, the input name_size is 0, limit also is 0, but limit - 1 = -1, and then
> casts to ULONGMAX to ucs2_as_utf8 and corrupts the stack storage with a size of
> only EFIVAR_SSDT_NAME_MAX.
>

       reply	other threads:[~2019-05-31  9:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-203761-199677@https.bugzilla.kernel.org/>
2019-05-31  9:02 ` Ard Biesheuvel [this message]
2019-05-31 19:44   ` [Bug 203761] New: efivar_ssdt_iter is subject to stack corruption when the input name_size is 0 Matthew Garrett

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='CAKv+Gu8vuTLGX6h2T=d_EnzQx-XirD+yTV5AX_zA9vdtP1qU7A@mail.gmail.com' \
    --to=ard.biesheuvel@linaro.org \
    --cc=bugzilla-daemon@bugzilla.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=mjg59@google.com \
    /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).