[ipxe-devel] [PATCH 1/1] [efi] avoid unaligned read in efi_devpath_end()

Heinrich Schuchardt xypron.glpk at gmx.de
Wed Mar 28 19:11:13 UTC 2018


On 03/28/2018 08:49 PM, Heinrich Schuchardt wrote:
> The old coding resulted in a "data abort" when compiled with gcc 6.3 for
> armhf and run on an Allwinner A20 SOC.
> 
> The unaligned access occured when path->Length was on an uneven address.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
>  src/interface/efi/efi_utils.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/interface/efi/efi_utils.c b/src/interface/efi/efi_utils.c
> index 4dc75414..dd59613b 100644
> --- a/src/interface/efi/efi_utils.c
> +++ b/src/interface/efi/efi_utils.c
> @@ -39,12 +39,15 @@ FILE_LICENCE ( GPL2_OR_LATER );
>   * @ret path_end	End of device path
>   */
>  EFI_DEVICE_PATH_PROTOCOL * efi_devpath_end ( EFI_DEVICE_PATH_PROTOCOL *path ) {
> +	EFI_DEVICE_PATH_PROTOCOL path_c;
>  
> -	while ( path->Type != END_DEVICE_PATH_TYPE ) {
> +	memcpy(&path_c, path, sizeof(EFI_DEVICE_PATH_PROTOCOL));
> +	while ( path_c.Type != END_DEVICE_PATH_TYPE ) {
>  		path = ( ( ( void * ) path ) +
>  			 /* There's this amazing new-fangled thing known as
>  			  * a UINT16, but who wants to use one of those? */
> -			 ( ( path->Length[1] << 8 ) | path->Length[0] ) );
> +			 ( ( path_c.Length[1] << 8 ) | path_c.Length[0] ) );
> +		memcpy(&path_c, path, sizeof(EFI_DEVICE_PATH_PROTOCOL));
>  	}
>  
>  	return path;
> 


Hello Michael,

with the patch above I reach the iPXE prompt on a BananaPi. But when
executing the dhcp command I see another "data abort", see below.

I am trying to track down, in which routine this happens. The error
occurs in monojob_wait(). Where do I find the job-code that is executed
in monojob_wait?

Best regards

Heinrich

iPXE> dhcp


hci/commands/ifmgmt_cmd.c(219) ifconf_payload:
SNP net0 could not set station address before initialising: Error
0x7f594083 (http://ipxe.org/7f594083)
ethernet at 01c50000 Waiting for PHY auto negotiation to complete...... done
Speed: 1000, full duplex


SNP net0 could not set station address after initialising: Error
0x7f594083 (http://ipxe.org/7f594083)
SNP net0 could not set receive filters 0x00 (have 0x00): Error
0x7f594083 (http://ipxe.org/7f594083)

SNP net0 could not set receive filters 0x07 (have 0x00): Error
0x7f594083 (http://ipxe.org/7f594083)

SNP net0 could not set receive filters 0x05 (have 0x00): Error
0x7f594083 (http://ipxe.org/7f594083)

SNP net0 could not set receive filters 0x01 (have 0x00): Error
0x7f594083 (http://ipxe.org/7f594083)

SNPDEV 0x79eaaa64 link is up
net/udp/dhcp.c(1348) start_dhcp:
INTF 0x79eab014+18 opening (SOCK_DGRAM,AF_INET) socket


net/udp/dhcp.c(1354) start_dhcp:


DHCP 0x79eab014 entering discovery state
net/udp/dhcp.c(1356) start_dhcp:
Configuring (net0 02:49:04:c2:32:99)usr/ifmgmt.c(300) ifconf:
usr/ifmgmt.c(189) ifpoller_wait:
core/monojob.c(97) monojob_wait:
...data abort
pc : [<79e979a8>]          lr : [<79e83713>]
reloc pc : [<44f329a8>]    lr : [<44f1e713>]
sp : 7af3a438  ip : 7af3a448     fp : 7af3a458
r10: 00000005  r9 : 7af3a4c4     r8 : 00000000
r7 : 00000000  r6 : 79ea9ee8     r5 : 79e978c9  r4 : 7af3a4c4
r3 : 79eaa9f0  r2 : 00000005     r1 : 00000000  r0 : 7af3a4c4
Flags: nZCv  IRQs off  FIQs off  Mode SVC_32
Resetting CPU ...

resetting ...



More information about the ipxe-devel mailing list