summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/stand
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@cvs.openbsd.org>2019-04-25 20:19:31 +0000
committerChristian Weisgerber <naddy@cvs.openbsd.org>2019-04-25 20:19:31 +0000
commit067d66c3df4fa5cfa4bd0d4023efdc8bff96b601 (patch)
tree77693399e75481b45fa12627ce68913b35c56692 /sys/arch/amd64/stand
parent83d0562ddfd20cee3ae28eda48eb1753f9b84abf (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/amd64/stand')
-rw-r--r--sys/arch/amd64/stand/efiboot/efipxe.c5
-rw-r--r--sys/arch/amd64/stand/libsa/dev_i386.c12
2 files changed, 15 insertions, 2 deletions
diff --git a/sys/arch/amd64/stand/efiboot/efipxe.c b/sys/arch/amd64/stand/efiboot/efipxe.c
index 38ae4c7823c..dfaa60d1a29 100644
--- a/sys/arch/amd64/stand/efiboot/efipxe.c
+++ b/sys/arch/amd64/stand/efiboot/efipxe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: efipxe.c,v 1.3 2018/01/30 20:19:06 naddy Exp $ */
+/* $OpenBSD: efipxe.c,v 1.4 2019/04/25 20:19:30 naddy Exp $ */
/*
* Copyright (c) 2017 Patrick Wildt <patrick@blueri.se>
*
@@ -127,6 +127,9 @@ tftp_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;
diff --git a/sys/arch/amd64/stand/libsa/dev_i386.c b/sys/arch/amd64/stand/libsa/dev_i386.c
index 308da2d08f6..47f1c8b9dee 100644
--- a/sys/arch/amd64/stand/libsa/dev_i386.c
+++ b/sys/arch/amd64/stand/libsa/dev_i386.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev_i386.c,v 1.21 2017/11/25 19:02:07 patrick Exp $ */
+/* $OpenBSD: dev_i386.c,v 1.22 2019/04/25 20:19:30 naddy Exp $ */
/*
* Copyright (c) 1996-1999 Michael Shalayeff
@@ -78,6 +78,16 @@ devopen(struct open_file *f, const char *fname, char **file)
#endif
if ((rc = (*dp->dv_open)(f, file)) == 0) {
f->f_dev = dp;
+#ifdef EFIBOOT
+ if (strcmp("TFTP", dp->dv_name) != 0) {
+ /*
+ * Clear bootmac, to signal that we loaded
+ * this file from a non-network device.
+ */
+ extern char *bootmac;
+ bootmac = NULL;
+ }
+#endif
return 0;
}
#ifdef DEBUG