summaryrefslogtreecommitdiff
path: root/sys/arch
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
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')
-rw-r--r--sys/arch/amd64/stand/efiboot/efipxe.c5
-rw-r--r--sys/arch/amd64/stand/libsa/dev_i386.c12
-rw-r--r--sys/arch/arm64/stand/efiboot/efiboot.c10
-rw-r--r--sys/arch/arm64/stand/efiboot/efipxe.c8
-rw-r--r--sys/arch/armv7/stand/efiboot/efiboot.c10
-rw-r--r--sys/arch/armv7/stand/efiboot/efipxe.c8
6 files changed, 47 insertions, 6 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
diff --git a/sys/arch/arm64/stand/efiboot/efiboot.c b/sys/arch/arm64/stand/efiboot/efiboot.c
index c99d7e0efca..f0650aa1a75 100644
--- a/sys/arch/arm64/stand/efiboot/efiboot.c
+++ b/sys/arch/arm64/stand/efiboot/efiboot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: efiboot.c,v 1.22 2019/01/31 14:35:06 patrick Exp $ */
+/* $OpenBSD: efiboot.c,v 1.23 2019/04/25 20:19:30 naddy Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@@ -749,6 +749,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/arm64/stand/efiboot/efipxe.c b/sys/arch/arm64/stand/efiboot/efipxe.c
index f71a03ddab9..176f65b4c0d 100644
--- a/sys/arch/arm64/stand/efiboot/efipxe.c
+++ b/sys/arch/arm64/stand/efiboot/efipxe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: efipxe.c,v 1.4 2018/03/31 17:43:53 patrick Exp $ */
+/* $OpenBSD: efipxe.c,v 1.5 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;
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;