diff options
author | Christian Weisgerber <naddy@cvs.openbsd.org> | 2019-04-25 20:19:31 +0000 |
---|---|---|
committer | Christian Weisgerber <naddy@cvs.openbsd.org> | 2019-04-25 20:19:31 +0000 |
commit | 067d66c3df4fa5cfa4bd0d4023efdc8bff96b601 (patch) | |
tree | 77693399e75481b45fa12627ce68913b35c56692 /sys/arch/armv7/stand | |
parent | 83d0562ddfd20cee3ae28eda48eb1753f9b84abf (diff) |
Add a check to tftp_open() that we are actually opening a TFTP device.
When reading a file from a non-TFTP device, clear the bootmac variable
to prevent the kernel from going into netboot mode.
This allows loading a kernel from a disk device after having booted
efiboot from PXE.
style tweak and ok kettenis@
Diffstat (limited to 'sys/arch/armv7/stand')
-rw-r--r-- | sys/arch/armv7/stand/efiboot/efiboot.c | 10 | ||||
-rw-r--r-- | sys/arch/armv7/stand/efiboot/efipxe.c | 8 |
2 files changed, 16 insertions, 2 deletions
diff --git a/sys/arch/armv7/stand/efiboot/efiboot.c b/sys/arch/armv7/stand/efiboot/efiboot.c index ebd8bbb7921..f6ccb141b87 100644 --- a/sys/arch/armv7/stand/efiboot/efiboot.c +++ b/sys/arch/armv7/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.23 2018/08/25 00:12:14 yasuoka Exp $ */ +/* $OpenBSD: efiboot.c,v 1.24 2019/04/25 20:19:30 naddy Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -607,6 +607,14 @@ devopen(struct open_file *f, const char *fname, char **file) dp = &devsw[dev]; f->f_dev = dp; + if (strcmp("tftp", dp->dv_name) != 0) { + /* + * Clear bootmac, to signal that we loaded this file from a + * non-network device. + */ + bootmac = NULL; + } + return (*dp->dv_open)(f, unit, part); } diff --git a/sys/arch/armv7/stand/efiboot/efipxe.c b/sys/arch/armv7/stand/efiboot/efipxe.c index 166474b04f1..7013a5bb7ee 100644 --- a/sys/arch/armv7/stand/efiboot/efipxe.c +++ b/sys/arch/armv7/stand/efiboot/efipxe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efipxe.c,v 1.1 2018/03/31 18:19:12 patrick Exp $ */ +/* $OpenBSD: efipxe.c,v 1.2 2019/04/25 20:19:30 naddy Exp $ */ /* * Copyright (c) 2017 Patrick Wildt <patrick@blueri.se> * @@ -157,6 +157,9 @@ mtftp_open(char *path, struct open_file *f) EFI_STATUS status; UINT64 size; + if (strcmp("tftp", f->f_dev->dv_name) != 0) + return ENXIO; + if (PXE == NULL) return ENXIO; @@ -295,6 +298,9 @@ mtftp_readdir(struct open_file *f, char *name) int efitftp_open(char *path, struct open_file *f) { + if (strcmp("tftp", f->f_dev->dv_name) != 0) + return ENXIO; + if (NET == NULL || PXE == NULL) return ENXIO; |