From 067d66c3df4fa5cfa4bd0d4023efdc8bff96b601 Mon Sep 17 00:00:00 2001 From: Christian Weisgerber Date: Thu, 25 Apr 2019 20:19:31 +0000 Subject: 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@ --- sys/arch/armv7/stand/efiboot/efiboot.c | 10 +++++++++- sys/arch/armv7/stand/efiboot/efipxe.c | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'sys/arch/armv7/stand') 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 @@ -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 * @@ -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; -- cgit v1.2.3