Re: [PATCH v2] efi_loader: Fix memory corruption on 32bit systems

2023-07-27 Thread Heinrich Schuchardt
Am 28. Juli 2023 03:51:55 MESZ schrieb Simon Glass : >Hi, > >On Thu, 27 Jul 2023 at 08:36, Dan Carpenter wrote: >> >> On Thu, Jul 27, 2023 at 11:22:15AM +0300, Ilias Apalodimas wrote: >> > Hi Dan, >> > >> > [...] >> > >> > > @@ -313,7 +313,7 @@ static int cmp_pe_section(const void *arg1, const

Re: [PATCH v2] efi_loader: Fix memory corruption on 32bit systems

2023-07-27 Thread Simon Glass
Hi, On Thu, 27 Jul 2023 at 08:36, Dan Carpenter wrote: > > On Thu, Jul 27, 2023 at 11:22:15AM +0300, Ilias Apalodimas wrote: > > Hi Dan, > > > > [...] > > > > > @@ -313,7 +313,7 @@ static int cmp_pe_section(const void *arg1, const > > > void *arg2) > > > * > > > * Return: valid pointer to a

Re: [PATCH v2] efi_loader: Fix memory corruption on 32bit systems

2023-07-27 Thread Dan Carpenter
On Thu, Jul 27, 2023 at 11:22:15AM +0300, Ilias Apalodimas wrote: > Hi Dan, > > [...] > > > @@ -313,7 +313,7 @@ static int cmp_pe_section(const void *arg1, const void > > *arg2) > > * > > * Return: valid pointer to a image, return NULL if allocation fails. > > */ > > -void *efi_prepare_al

[PATCH v2] efi_loader: Fix memory corruption on 32bit systems

2023-07-27 Thread Dan Carpenter
The issue is this line: new_efi = efi_prepare_aligned_image(efi, (u64 *)&efi_size); The efi_size variable is type size_t and on a 32 bit system that's 32 bits. The u64 type is obviously 64 bits. So we write 8 bytes to a 4 byte buffer which corrupts memory. Fix this by changing the type

Re: [PATCH v2] efi_loader: Fix memory corruption on 32bit systems

2023-07-27 Thread Ilias Apalodimas
Hi Dan, [...] > @@ -313,7 +313,7 @@ static int cmp_pe_section(const void *arg1, const void > *arg2) > * > * Return: valid pointer to a image, return NULL if allocation fails. > */ > -void *efi_prepare_aligned_image(void *efi, u64 *efi_size) > +void *efi_prepare_aligned_image(void *efi,