bug - bootflow: grub efi crashes when bootflow selected explicitly
Simon Glass
sjg at chromium.org
Thu Nov 16 02:39:07 CET 2023
Hi Heinrich,
On Wed, 15 Nov 2023 at 18:25, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
> On 11/15/23 23:46, Heinrich Schuchardt wrote:
> >
> >
> > Am 15. November 2023 23:15:46 MEZ schrieb Simon Glass <sjg at chromium.org>:
> >> Hi Shantur,
> >>
> >> On Wed, 15 Nov 2023 at 15:13, Shantur Rathore <i at shantur.com> wrote:
> >>>
> >>> Hi Simon,
> >>>
> >>> I have figured out the cause of the crash.
> >>> It happens here -
> >>> https://github.com/u-boot/u-boot/blob/master/boot/bootflow.c#L470
> >>> while doing - free(bflow->buf)
>
> Unfortunately the description of the field bflow->buf is deceptively wrong:
>
> @buf: Bootflow file contents (allocated)
>
> The EFI bootflow never allocates this buffer but uses the address
> $kernel_addr_r without allocation.
>
> We must not call free on an address that we never allocated via malloc().
>
> Doesn't this also explain the error you experienced before writing
>
> [PATCH v4 05/12] usb: Avoid unbinding devices in use by bootflows
> https://lore.kernel.org/u-boot/CAHc5_t3v23k_Xbws5o-g9iQfoQ7fhpKScf89XDaaAgo+bu8tbQ@mail.gmail.com/T/#m992e20fb25fe0f2f0047e901a76e78628e59da7a
Yes that is indeed the bug report from Shantur. I just sent a patch.
I still would like the USB patch to go in though, as it is wrong to
unbind devices before boot. We have a special device_remove() flag for
handling this and it should be used with all devices, including USB.
[..]
Regards,
Simon
More information about the U-Boot
mailing list