summaryrefslogtreecommitdiff
path: root/sys/stand
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2023-02-23 19:48:23 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2023-02-23 19:48:23 +0000
commit4ca89ee078d7814e763d9fe45a5893e726032e4f (patch)
tree90f170446adb3af0500515ee30fee6f83a8ab432 /sys/stand
parent9a17c74c7944052ae6405993a3f46aab37c9599d (diff)
Remove dangerous user-settable "addr" variable from MI boot loader, and
only compile tty-related code (stty command, tty variable) on platforms where it makes sense for the boot loader to control it, rather than the PROM/firmware/whatever.
Diffstat (limited to 'sys/stand')
-rw-r--r--sys/stand/boot/boot.c5
-rw-r--r--sys/stand/boot/cmd.c8
-rw-r--r--sys/stand/boot/cmd.h3
-rw-r--r--sys/stand/boot/vars.c20
4 files changed, 17 insertions, 19 deletions
diff --git a/sys/stand/boot/boot.c b/sys/stand/boot/boot.c
index 5525723090b..e090a0d0180 100644
--- a/sys/stand/boot/boot.c
+++ b/sys/stand/boot/boot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot.c,v 1.56 2021/10/26 16:29:49 deraadt Exp $ */
+/* $OpenBSD: boot.c,v 1.57 2023/02/23 19:48:22 miod Exp $ */
/*
* Copyright (c) 2003 Dale Rahn
@@ -75,7 +75,6 @@ boot(dev_t bootdev)
strlcpy(cmd.image, kernelfile, sizeof(cmd.image));
cmd.boothowto = 0;
cmd.conf = "/etc/boot.conf";
- cmd.addr = (void *)DEFAULT_KERNEL_ADDRESS;
cmd.timeout = boottimeout;
if (upgrade()) {
@@ -125,7 +124,7 @@ boot(dev_t bootdev)
bootprompt = 1; /* allow reselect should we fail */
printf("booting %s: ", cmd.path);
- marks[MARK_START] = (u_long)cmd.addr;
+ marks[MARK_START] = 0;
if ((fd = loadfile(cmd.path, marks, LOAD_ALL)) != -1) {
/* Prevent re-upgrade: chmod a-x bsd.upgrade */
diff --git a/sys/stand/boot/cmd.c b/sys/stand/boot/cmd.c
index c11c7e9f204..00e9e46bda4 100644
--- a/sys/stand/boot/cmd.c
+++ b/sys/stand/boot/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.69 2022/06/27 20:22:26 miod Exp $ */
+/* $OpenBSD: cmd.c,v 1.70 2023/02/23 19:48:22 miod Exp $ */
/*
* Copyright (c) 1997-1999 Michael Shalayeff
@@ -43,7 +43,9 @@ static int Xhexdump(void);
static int Xls(void);
static int Xnop(void);
static int Xreboot(void);
+#ifdef BOOT_STTY
static int Xstty(void);
+#endif
static int Xtime(void);
#ifdef MACHINE_CMD
static int Xmachine(void);
@@ -70,7 +72,9 @@ const struct cmd_table cmd_table[] = {
#endif
{"reboot", CMDT_CMD, Xreboot},
{"set", CMDT_SET, Xset},
+#ifdef BOOT_STTY
{"stty", CMDT_CMD, Xstty},
+#endif
{"time", CMDT_CMD, Xtime},
{NULL, 0},
};
@@ -389,6 +393,7 @@ Xecho(void)
return 0;
}
+#ifdef BOOT_STTY
static int
Xstty(void)
{
@@ -417,6 +422,7 @@ Xstty(void)
}
return 0;
}
+#endif
static int
Xtime(void)
diff --git a/sys/stand/boot/cmd.h b/sys/stand/boot/cmd.h
index 494d0bce6f3..5045f052b8b 100644
--- a/sys/stand/boot/cmd.h
+++ b/sys/stand/boot/cmd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.h,v 1.18 2019/05/10 12:49:58 claudio Exp $ */
+/* $OpenBSD: cmd.h,v 1.19 2023/02/23 19:48:22 miod Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -45,7 +45,6 @@ struct cmd_state {
char image[MAXPATHLEN - 16]; /* image */
int boothowto; /* howto */
char *conf; /* /etc/boot.conf normally */
- void *addr; /* load here */
int timeout;
char path[MAXPATHLEN]; /* buffer for pathname compose */
diff --git a/sys/stand/boot/vars.c b/sys/stand/boot/vars.c
index 861920ef6a7..6093179c760 100644
--- a/sys/stand/boot/vars.c
+++ b/sys/stand/boot/vars.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vars.c,v 1.15 2014/07/11 12:33:12 jasper Exp $ */
+/* $OpenBSD: vars.c,v 1.16 2023/02/23 19:48:22 miod Exp $ */
/*
* Copyright (c) 1998-2000 Michael Shalayeff
@@ -37,7 +37,6 @@ extern char prog_ident[];
extern int debug;
int db_console = -1;
-static int Xaddr(void);
static int Xdevice(void);
#ifdef DEBUG
static int Xdebug(void);
@@ -45,19 +44,22 @@ static int Xdebug(void);
static int Xdb_console(void);
static int Ximage(void);
static int Xhowto(void);
+#ifdef BOOT_STTY
static int Xtty(void);
+#endif
static int Xtimeout(void);
int Xset(void);
int Xenv(void);
const struct cmd_table cmd_set[] = {
- {"addr", CMDT_VAR, Xaddr},
{"howto", CMDT_VAR, Xhowto},
#ifdef DEBUG
{"debug", CMDT_VAR, Xdebug},
#endif
{"device", CMDT_VAR, Xdevice},
+#ifdef BOOT_STTY
{"tty", CMDT_VAR, Xtty},
+#endif
{"image", CMDT_VAR, Ximage},
{"timeout",CMDT_VAR, Xtimeout},
{"db_console", CMDT_VAR, Xdb_console},
@@ -149,16 +151,7 @@ Ximage(void)
return 0;
}
-static int
-Xaddr(void)
-{
- if (cmd.argc != 2)
- printf("%p\n", cmd.addr);
- else
- cmd.addr = (void *)strtol(cmd.argv[1], NULL, 0);
- return 0;
-}
-
+#ifdef BOOT_STTY
static int
Xtty(void)
{
@@ -181,6 +174,7 @@ Xtty(void)
}
return 0;
}
+#endif
static int
Xhowto(void)