[U-Boot] pxe: clear Bootfile before returning

Tom Rini trini at ti.com
Mon Aug 11 00:21:52 CEST 2014


On Tue, Jul 22, 2014 at 06:06:46PM -0600, Stephen Warren wrote:

> From: Stephen Warren <swarren at nvidia.com>
> 
> When "pxe boot" downloads the initrd/kernel/DTB, netboot_common() saves
> the downloaded filename to global variable BootFile. If the boot
> operation is aborted, this global state is not cleared. If "dhcp" is
> executed later without any arguments, BootFile is not cleared, and when
> the DHCP response is received, BootpCopyNetParams() writes the value into
> environment variable bootfile.
> 
> This causes the following scenario:
> 
> * Boot script executes dhcp; pxe get; pxe boot
> 
> * User CTRL-C's the PXE menu, which causes the first menu item to be
>   booted, which causes some file to be downloaded.
> 
>   (This boot-on-CTRL-C behaviour is arguably a bug too, but it's a
>   separate bug and the bug this patch fixes would still exist if the user
>   simply waited to press CTRL-C until "pxe boot" started downloading
>   files)
> 
> * User CTRL-C's the file downloads, but the filename is still written to
>   the bootfile environment variable.
> 
> * User re-runs the boot command, which in my case executes "dhcp; pxe get;
>   pxe boot" again, and "dhcp" picks up the saved bootfile environment
>   variable and proceeds to download a file that it shouldn't.
> 
> To solve this, modify the implementation of "pxe get" to clear BootFile
> if the whole boot operation fails, which avoids this whole mess.
> 
> An alternative would be to modify netboot_common() such that the no-
> arguments case explicitly clears the global variable BootFile. However,
> that would prevent the following command sequences from working:
> 
> $ dhcp filename # downloads "filename"
> $ dhcp          # downloads $bootfile, i.e. "filename"
> 
> or:
> $ setenv bootfile filename
> $ dhcp          # downloads $bootfile, i.e. "filename"
> 
> ... and I assume someone relies on U-Boot working that way.
> 
> Signed-off-by: Stephen Warren <swarren at nvidia.com>
> Acked-by: Joe Hershberger <joe.hershberger at ni.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140810/432505eb/attachment.pgp>


More information about the U-Boot mailing list