Re: [SECURITY PATCH 108/117] util/mkimage: Refactor section setup to use a helper

2021-03-23 Thread Daniel Kiper
Hi Adrian,

On Tue, Mar 23, 2021 at 08:16:43PM +0100, John Paul Adrian Glaubitz wrote:
> Hello!
>
> On 3/18/21 9:38 AM, John Paul Adrian Glaubitz wrote:
> > On 3/2/21 7:01 PM, Daniel Kiper wrote:
> >> From: Peter Jones 
> >>
> >> Add a init_pe_section() helper function to setup PE sections. This makes
> >> the code simpler and easier to read.
> >>
> >> Signed-off-by: Peter Jones 
> >> Signed-off-by: Javier Martinez Canillas 
> >> Reviewed-by: Daniel Kiper 
> >
> > This change broke GRUB on ia64 for me. It now fails to perform any basic 
> > commands:
>
> Any chance someone could have a look at this? As explained in the follow-up 
> mails,
> the problem is that the pointer pointing to the modules location in the core 
> image
> deviate from the actual modules location as the former was updated but the 
> former
> not.

I chatted about that with Javier yesterday. He told me he will take
a look at the issue...

Daniel



Re: [SECURITY PATCH 108/117] util/mkimage: Refactor section setup to use a helper

2021-03-23 Thread John Paul Adrian Glaubitz
Hi Daniel!

On 3/23/21 8:35 PM, Daniel Kiper wrote:
>> Any chance someone could have a look at this? As explained in the follow-up 
>> mails,
>> the problem is that the pointer pointing to the modules location in the core 
>> image
>> deviate from the actual modules location as the former was updated but the 
>> former
>> not.
> 
> I chatted about that with Javier yesterday. He told me he will take
> a look at the issue...

Great, thanks.

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913



Re: [SECURITY PATCH 108/117] util/mkimage: Refactor section setup to use a helper

2021-03-23 Thread John Paul Adrian Glaubitz
Hello!

On 3/18/21 9:38 AM, John Paul Adrian Glaubitz wrote:
> On 3/2/21 7:01 PM, Daniel Kiper wrote:
>> From: Peter Jones 
>>
>> Add a init_pe_section() helper function to setup PE sections. This makes
>> the code simpler and easier to read.
>>
>> Signed-off-by: Peter Jones 
>> Signed-off-by: Javier Martinez Canillas 
>> Reviewed-by: Daniel Kiper 
> 
> This change broke GRUB on ia64 for me. It now fails to perform any basic 
> commands:

Any chance someone could have a look at this? As explained in the follow-up 
mails,
the problem is that the pointer pointing to the modules location in the core 
image
deviate from the actual modules location as the former was updated but the 
former
not.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913



Re: [SECURITY PATCH 108/117] util/mkimage: Refactor section setup to use a helper

2021-03-20 Thread John Paul Adrian Glaubitz
On 3/20/21 4:05 PM, John Paul Adrian Glaubitz wrote:
> However, the modules are still located at the same address in memory which is 
> why
> the module loader can no longer find them.

And the new address where the loader is looking for the modules is located at 
0x39000
but the modules are still located at 0x384E0. Thus, mkimage should be patched 
to move
the modules to 39000 so that the loader can find them.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913



Re: [SECURITY PATCH 108/117] util/mkimage: Refactor section setup to use a helper

2021-03-20 Thread John Paul Adrian Glaubitz
Hello!

On 3/18/21 9:38 AM, John Paul Adrian Glaubitz wrote:
> This change broke GRUB on ia64 for me. It now fails to perform any basic 
> commands:
> 
> Loading.: grub  
> Starting: grub  
> Welcome to GRUB!  
>   
>   
>
> error: unknown filesystem.
> Entering rescue mode...
> grub rescue> insmod ext2
> error: unknown filesystem.
> grub rescue> help
> Unknown command `help'.
> grub rescue> ?
> Unknown command `?'.
> grub rescue> linux
> Unknown command `linux'.
> grub rescue>

The problem seems that the module loader tries to load the modules from the 
address
mentioned in the PE header which has changed before this patch was introduced.

However, the modules are still located at the same address in memory which is 
why
the module loader can no longer find them.

For reference, here is a hex diff of core.efi for the working and non-working 
builds
(without and with the patch):

--- grub-working.txt2021-03-20 15:45:43.788950935 +0100
+++ grub-broken.txt 2021-03-20 15:46:05.55451 +0100
@@ -25,10 +25,10 @@
 0180:     2e74 6578 7400   .text...
 0190: 00e0 0100 0010  00e0 0100 0010   
 01a0:       2000 0060   ..`
-01b0: 2e64 6174 6100  e094 0100 00f0 0100  .data...
-01c0: e094 0100 00f0 0100      
+01b0: 2e64 6174 6100  00a0 0100 00f0 0100  .data...
+01c0: 00a0 0100 00f0 0100      
 01d0:   4000 00c0 6d6f 6473    @...mods
-01e0: 206b  e084 0300 206b  e084 0300   k.. k..
+01e0: 0060  0090 0300 0060  0090 0300  .`...`..
 01f0:       4000 00c0  @...
 0200: 2e72 656c 6f63  0010  00f0 0300  .reloc..
 0210: 0010  00f0 0300      

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913



Re: [SECURITY PATCH 108/117] util/mkimage: Refactor section setup to use a helper

2021-03-18 Thread John Paul Adrian Glaubitz
Hi!

On 3/2/21 7:01 PM, Daniel Kiper wrote:
> From: Peter Jones 
> 
> Add a init_pe_section() helper function to setup PE sections. This makes
> the code simpler and easier to read.
> 
> Signed-off-by: Peter Jones 
> Signed-off-by: Javier Martinez Canillas 
> Reviewed-by: Daniel Kiper 

This change broke GRUB on ia64 for me. It now fails to perform any basic 
commands:

Loading.: grub  
Starting: grub  
Welcome to GRUB!


 
error: unknown filesystem.
Entering rescue mode...
grub rescue> insmod ext2
error: unknown filesystem.
grub rescue> help
Unknown command `help'.
grub rescue> ?
Unknown command `?'.
grub rescue> linux
Unknown command `linux'.
grub rescue>

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913