Page MenuHomeFreeBSD

D62089.1795753585.diff
No OneTemporary

Authored By
Unknown
Size
12 KB
Referenced Files
None
Subscribers
None

D62089.1795753585.diff

diff --git a/stand/arm64/libarm64/cache.c b/stand/arm64/libarm64/cache.c
--- a/stand/arm64/libarm64/cache.c
+++ b/stand/arm64/libarm64/cache.c
@@ -144,4 +144,10 @@
printf("usage: cache_flags set <value>\n");
return (CMD_ERROR);
}
+
+/*
+ * Not lockdown-safe: this only ever adds cache maintenance, but it's an
+ * undocumented workaround for misreporting hardware that isn't expected to
+ * be needed, so we just deny it.
+ */
COMMAND_SET(cache_flags, "cache_flags", "Set cache flags", command_cache_flags);
diff --git a/stand/common/bcache.c b/stand/common/bcache.c
--- a/stand/common/bcache.c
+++ b/stand/common/bcache.c
@@ -500,7 +500,8 @@
}
#ifndef BOOT2
-COMMAND_SET(bcachestat, "bcachestat", "get disk block cache stats", command_bcache);
+COMMAND_SET_RDONLY(bcachestat, "bcachestat", "get disk block cache stats",
+ command_bcache);
static int
command_bcache(int argc, char *argv[] __unused)
diff --git a/stand/common/boot.c b/stand/common/boot.c
--- a/stand/common/boot.c
+++ b/stand/common/boot.c
@@ -47,8 +47,12 @@
/*
* The user wants us to boot.
+ *
+ * Lockdown-safe only because the kernel will refuse unrestricted debugger
+ * entry in lockdown; boot flags are otherwise passed through as-is.
*/
-COMMAND_SET(boot, "boot", "boot a file or loaded kernel", command_boot);
+COMMAND_SET_FLAGS(boot, "boot", "boot a file or loaded kernel", command_boot,
+ CMDF_LOCKDOWN);
static int
command_boot(int argc, char *argv[])
@@ -122,9 +126,12 @@
/*
* Autoboot after a delay
+ *
+ * Lockdown-safe only because the kernel will refuse unrestricted debugger
+ * entry in lockdown; boot flags are otherwise passed through as-is.
*/
-
-COMMAND_SET(autoboot, "autoboot", "boot automatically after a delay", command_autoboot);
+COMMAND_SET_FLAGS(autoboot, "autoboot", "boot automatically after a delay",
+ command_autoboot, CMDF_LOCKDOWN);
static int
command_autoboot(int argc, char *argv[])
diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h
--- a/stand/common/bootstrap.h
+++ b/stand/common/bootstrap.h
@@ -339,6 +339,10 @@
#define COMMAND_SET(tag, key, desc, func) \
COMMAND_SET_FLAGS(tag, key, desc, func, 0)
+/* Commands that only inspect state are always lockdown-safe. */
+#define COMMAND_SET_RDONLY(tag, key, desc, func) \
+ COMMAND_SET_FLAGS(tag, key, desc, func, CMDF_LOCKDOWN)
+
SET_DECLARE(Xcommand_set, struct bootblk_command);
/*
diff --git a/stand/common/commands.c b/stand/common/commands.c
--- a/stand/common/commands.c
+++ b/stand/common/commands.c
@@ -1,6 +1,10 @@
/*-
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
+ * Copyright (c) 2026 The FreeBSD Foundation
+ *
+ * Portions of this software were developed by Klara, Inc. under sponsorship
+ * from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -55,7 +59,7 @@
*
* If no argument(s) are supplied by the user, the help for 'help' is displayed.
*/
-COMMAND_SET(help, "help", "detailed help", command_help);
+COMMAND_SET_RDONLY(help, "help", "detailed help", command_help);
static int
help_getnext(int fd, char **topic, char **subtopic, char **desc)
@@ -214,7 +218,7 @@
return (CMD_OK);
}
-COMMAND_SET(commandlist, "?", "list commands", command_commandlist);
+COMMAND_SET_RDONLY(commandlist, "?", "list commands", command_commandlist);
/*
* Please note: although we use the pager for the list of commands,
@@ -255,7 +259,7 @@
* substitution happening.
*/
-COMMAND_SET(show, "show", "show variable(s)", command_show);
+COMMAND_SET_RDONLY(show, "show", "show variable(s)", command_show);
static int
command_show(int argc, char *argv[])
@@ -291,7 +295,11 @@
return (CMD_OK);
}
-COMMAND_SET(set, "set", "set a variable", command_set);
+/*
+ * Lockdown-safe only because the environment enforces its own policy on
+ * which variables may be modified in lockdown.
+ */
+COMMAND_SET_FLAGS(set, "set", "set a variable", command_set, CMDF_LOCKDOWN);
static int
command_set(int argc, char *argv[])
@@ -325,7 +333,12 @@
return (CMD_OK);
}
-COMMAND_SET(unset, "unset", "unset a variable", command_unset);
+/*
+ * Lockdown-safe only because the environment enforces its own policy on
+ * which variables may be modified in lockdown.
+ */
+COMMAND_SET_FLAGS(unset, "unset", "unset a variable", command_unset,
+ CMDF_LOCKDOWN);
static int
command_unset(int argc, char *argv[])
@@ -356,7 +369,7 @@
return (CMD_OK);
}
-COMMAND_SET(echo, "echo", "echo arguments", command_echo);
+COMMAND_SET_RDONLY(echo, "echo", "echo arguments", command_echo);
static int
command_echo(int argc, char *argv[])
@@ -395,7 +408,12 @@
* A passable emulation of the sh(1) command of the same name.
*/
-COMMAND_SET(read, "read", "read input from the terminal", command_read);
+/*
+ * Lockdown-safe only because the environment enforces its own policy on
+ * which variables may be modified in lockdown.
+ */
+COMMAND_SET_FLAGS(read, "read", "read input from the terminal", command_read,
+ CMDF_LOCKDOWN);
static int
command_read(int argc, char *argv[])
@@ -454,7 +472,7 @@
/*
* File pager
*/
-COMMAND_SET(more, "more", "show contents of a file", command_more);
+COMMAND_SET_RDONLY(more, "more", "show contents of a file", command_more);
static int
command_more(int argc, char *argv[])
@@ -500,7 +518,7 @@
/*
* List all disk-like devices
*/
-COMMAND_SET(lsdev, "lsdev", "list all devices", command_lsdev);
+COMMAND_SET_RDONLY(lsdev, "lsdev", "list all devices", command_lsdev);
static int
command_lsdev(int argc, char *argv[])
@@ -570,7 +588,7 @@
return (CMD_OK);
}
-COMMAND_SET(readtest, "readtest", "Time a file read", command_readtest);
+COMMAND_SET_RDONLY(readtest, "readtest", "Time a file read", command_readtest);
static int
command_quit(int argc, char *argv[])
@@ -579,4 +597,4 @@
return (CMD_OK);
}
-COMMAND_SET(quit, "quit", "exit the loader", command_quit);
+COMMAND_SET_FLAGS(quit, "quit", "exit the loader", command_quit, CMDF_LOCKDOWN);
diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c
--- a/stand/common/gfx_fb.c
+++ b/stand/common/gfx_fb.c
@@ -3029,7 +3029,8 @@
TSEXIT();
}
-COMMAND_SET(load_font, "loadfont", "load console font from file", command_font);
+COMMAND_SET_FLAGS(load_font, "loadfont", "load console font from file",
+ command_font, CMDF_LOCKDOWN);
static int
command_font(int argc, char *argv[])
diff --git a/stand/common/install.c b/stand/common/install.c
--- a/stand/common/install.c
+++ b/stand/common/install.c
@@ -41,7 +41,9 @@
extern int pkgfs_init(const char *, struct fs_ops *);
extern void pkgfs_cleanup(void);
-COMMAND_SET(install, "install", "install software package", command_install);
+/* Lockdown-safe only because kernel and module loads are verified. */
+COMMAND_SET_FLAGS(install, "install", "install software package",
+ command_install, CMDF_LOCKDOWN);
static char *inst_kernel;
static char **inst_modules;
diff --git a/stand/common/interp.c b/stand/common/interp.c
--- a/stand/common/interp.c
+++ b/stand/common/interp.c
@@ -104,7 +104,12 @@
* Commands may be prefixed with '@' (so they aren't displayed) or '-' (so
* that the script won't stop if they fail).
*/
-COMMAND_SET(include, "include", "read commands from a file", command_include);
+/*
+ * Lockdown-safe only because each command read from the file is checked
+ * individually as it is executed.
+ */
+COMMAND_SET_FLAGS(include, "include", "read commands from a file",
+ command_include, CMDF_LOCKDOWN);
static int
command_include(int argc, char *argv[])
diff --git a/stand/common/ls.c b/stand/common/ls.c
--- a/stand/common/ls.c
+++ b/stand/common/ls.c
@@ -50,7 +50,7 @@
static int ls_getdir(char **pathp);
-COMMAND_SET(ls, "ls", "list files", command_ls);
+COMMAND_SET_RDONLY(ls, "ls", "list files", command_ls);
static int
command_ls(int argc, char *argv[])
diff --git a/stand/common/module.c b/stand/common/module.c
--- a/stand/common/module.c
+++ b/stand/common/module.c
@@ -1,6 +1,10 @@
/*-
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
+ * Copyright (c) 2026 The FreeBSD Foundation
+ *
+ * Portions of this software were developed by Klara, Inc. under sponsorship
+ * from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -104,7 +108,9 @@
* load <path> <options>
*/
-COMMAND_SET(load, "load", "load a kernel or module", command_load);
+/* Lockdown-safe only because kernel and module loads are verified. */
+COMMAND_SET_FLAGS(load, "load", "load a kernel or module", command_load,
+ CMDF_LOCKDOWN);
static int
command_load(int argc, char *argv[])
@@ -230,7 +236,8 @@
}
#ifdef LOADER_GELI_SUPPORT
-COMMAND_SET(load_geli, "load_geli", "load a geli key", command_load_geli);
+COMMAND_SET_FLAGS(load_geli, "load_geli", "load a geli key", command_load_geli,
+ CMDF_LOCKDOWN);
static int
command_load_geli(int argc, char *argv[])
@@ -284,7 +291,8 @@
unsetenv("kernelname");
}
-COMMAND_SET(unload, "unload", "unload all modules", command_unload);
+COMMAND_SET_FLAGS(unload, "unload", "unload all modules", command_unload,
+ CMDF_LOCKDOWN);
static int
command_unload(int argc, char *argv[])
@@ -293,7 +301,7 @@
return(CMD_OK);
}
-COMMAND_SET(lsmod, "lsmod", "list loaded modules", command_lsmod);
+COMMAND_SET_RDONLY(lsmod, "lsmod", "list loaded modules", command_lsmod);
static int
command_lsmod(int argc, char *argv[])
@@ -360,7 +368,8 @@
return(CMD_OK);
}
-COMMAND_SET(pnpmatch, "pnpmatch", "list matched modules based on pnpinfo", command_pnpmatch);
+COMMAND_SET_RDONLY(pnpmatch, "pnpmatch",
+ "list matched modules based on pnpinfo", command_pnpmatch);
static int pnp_dump_flag = 0;
static int pnp_unbound_flag = 0;
@@ -407,7 +416,9 @@
return (CMD_OK);
}
-COMMAND_SET(pnpload, "pnpload", "load matched modules based on pnpinfo", command_pnpload);
+/* Lockdown-safe only because kernel and module loads are verified. */
+COMMAND_SET_FLAGS(pnpload, "pnpload", "load matched modules based on pnpinfo",
+ command_pnpload, CMDF_LOCKDOWN);
static int
command_pnpload(int argc, char *argv[])
@@ -502,7 +513,9 @@
#endif
};
-COMMAND_SET(pnpautoload, "pnpautoload", "auto load modules based on pnpinfo", command_pnpautoload);
+/* Lockdown-safe only because kernel and module loads are verified. */
+COMMAND_SET_FLAGS(pnpautoload, "pnpautoload",
+ "auto load modules based on pnpinfo", command_pnpautoload, CMDF_LOCKDOWN);
static int
command_pnpautoload(int argc, char *argv[])
diff --git a/stand/common/nvstore.c b/stand/common/nvstore.c
--- a/stand/common/nvstore.c
+++ b/stand/common/nvstore.c
@@ -36,7 +36,8 @@
#include "nvstore.h"
#include "bootstrap.h"
-COMMAND_SET(nvstore, "nvstore", "manage non-volatile data", command_nvstore);
+COMMAND_SET_FLAGS(nvstore, "nvstore", "manage non-volatile data",
+ command_nvstore, CMDF_LOCKDOWN);
static void
nvstore_usage(const char *me)
diff --git a/stand/common/pnp.c b/stand/common/pnp.c
--- a/stand/common/pnp.c
+++ b/stand/common/pnp.c
@@ -24,7 +24,8 @@
* Perform complete enumeration sweep
*/
-COMMAND_SET(pnpscan, "pnpscan", "scan for PnP devices", pnp_scan);
+COMMAND_SET_FLAGS(pnpscan, "pnpscan", "scan for PnP devices", pnp_scan,
+ CMDF_LOCKDOWN);
static int
pnp_scan(int argc, char *argv[])
diff --git a/stand/common/vdisk.c b/stand/common/vdisk.c
--- a/stand/common/vdisk.c
+++ b/stand/common/vdisk.c
@@ -81,7 +81,9 @@
return (vd);
}
-COMMAND_SET(map_vdisk, "map-vdisk", "map file as virtual disk", command_mapvd);
+/* Lockdown-safe only because kernel and module loads are verified. */
+COMMAND_SET_FLAGS(map_vdisk, "map-vdisk", "map file as virtual disk",
+ command_mapvd, CMDF_LOCKDOWN);
static int
command_mapvd(int argc, char *argv[])
@@ -181,7 +183,8 @@
return (CMD_OK);
}
-COMMAND_SET(unmap_vdisk, "unmap-vdisk", "unmap virtual disk", command_unmapvd);
+COMMAND_SET_FLAGS(unmap_vdisk, "unmap-vdisk", "unmap virtual disk",
+ command_unmapvd, CMDF_LOCKDOWN);
/*
* unmap-vdisk vdiskX
diff --git a/stand/common/zfs_cmd.c b/stand/common/zfs_cmd.c
--- a/stand/common/zfs_cmd.c
+++ b/stand/common/zfs_cmd.c
@@ -36,8 +36,8 @@
#include "bootstrap.h"
#include "libzfs.h"
-COMMAND_SET(lszfs, "lszfs", "list child datasets of a zfs dataset",
- command_lszfs);
+COMMAND_SET_RDONLY(lszfs, "lszfs", "list child datasets of a zfs dataset",
+ command_lszfs);
static int
command_lszfs(int argc, char *argv[])
@@ -57,8 +57,10 @@
return (CMD_OK);
}
-COMMAND_SET(reloadbe, "reloadbe", "refresh the list of ZFS Boot Environments",
- command_reloadbe);
+/* Lockdown-safe only because kernel and module loads are verified. */
+COMMAND_SET_FLAGS(reloadbe, "reloadbe",
+ "refresh the list of ZFS Boot Environments", command_reloadbe,
+ CMDF_LOCKDOWN);
static int
command_reloadbe(int argc, char *argv[])

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 27, 4:26 AM (19 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42035057
Default Alt Text
D62089.1795753585.diff (12 KB)

Event Timeline