Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178009234
D62092.1795753157.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
7 KB
Referenced Files
None
Subscribers
None
D62092.1795753157.diff
View Options
diff --git a/stand/efi/libefi/env.c b/stand/efi/libefi/env.c
--- a/stand/efi/libefi/env.c
+++ b/stand/efi/libefi/env.c
@@ -429,7 +429,8 @@
env_setenv("efi-version", EV_VOLATILE, var, env_noset, env_nounset);
}
-COMMAND_SET(efishow, "efi-show", "print some or all EFI variables", command_efi_show);
+COMMAND_SET_RDONLY(efishow, "efi-show", "print some or all EFI variables",
+ command_efi_show);
static int
efi_print_other_value(uint8_t *data, UINTN datasz)
@@ -1019,6 +1020,11 @@
return (rv);
}
+/*
+ * Not lockdown-safe: the loader runs before ExitBootServices() and may
+ * write or delete boot-services-only variables that the OS cannot, so
+ * this would hand out a capability that root does not have.
+ */
COMMAND_SET(efiset, "efi-set", "set EFI variables", command_efi_set);
static int
@@ -1058,6 +1064,11 @@
return (CMD_OK);
}
+/*
+ * Not lockdown-safe: the loader runs before ExitBootServices() and may
+ * write or delete boot-services-only variables that the OS cannot, so
+ * this would hand out a capability that root does not have.
+ */
COMMAND_SET(efiunset, "efi-unset", "delete / unset EFI variables", command_efi_unset);
static int
diff --git a/stand/efi/loader/arch/amd64/trap.c b/stand/efi/loader/arch/amd64/trap.c
--- a/stand/efi/loader/arch/amd64/trap.c
+++ b/stand/efi/loader/arch/amd64/trap.c
@@ -450,6 +450,11 @@
printf("failed\n");
return (CMD_OK);
}
+
+/*
+ * Not lockdown-safe: debugging aid with no use in a locked-down
+ * deployment, so we just deny it.
+ */
COMMAND_SET(grab_faults, "grab_faults", "grab faults", command_grab_faults);
static int
@@ -459,6 +464,11 @@
efi_unredirect_exceptions();
return (CMD_OK);
}
+
+/*
+ * Not lockdown-safe: debugging aid with no use in a locked-down
+ * deployment, so we just deny it.
+ */
COMMAND_SET(ungrab_faults, "ungrab_faults", "ungrab faults",
command_ungrab_faults);
@@ -469,4 +479,9 @@
__asm("ud2");
return (CMD_OK);
}
+
+/*
+ * Not lockdown-safe: debugging aid with no use in a locked-down
+ * deployment, so we just deny it.
+ */
COMMAND_SET(fault, "fault", "generate fault", command_fault);
diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c
--- a/stand/efi/loader/copy.c
+++ b/stand/efi/loader/copy.c
@@ -241,7 +241,13 @@
command_errmsg = "usage: copy_staging enable|disable|auto";
return (CMD_ERROR);
}
-COMMAND_SET(copy_staging, "copy_staging", "copy staging", command_copy_staging);
+
+/*
+ * Lockdown-safe only because changing the mode unloads the kernel, and
+ * the reload is verified again.
+ */
+COMMAND_SET_FLAGS(copy_staging, "copy_staging", "copy staging",
+ command_copy_staging, CMDF_LOCKDOWN);
#endif
static int
@@ -273,8 +279,13 @@
command_errmsg = "invalid slop value";
return (CMD_ERROR);
}
-COMMAND_SET(staging_slop, "staging_slop", "set staging slop",
- command_staging_slop);
+
+/*
+ * Lockdown-safe only because changing the slop unloads the kernel, and
+ * the reload is verified again.
+ */
+COMMAND_SET_FLAGS(staging_slop, "staging_slop", "set staging slop",
+ command_staging_slop, CMDF_LOCKDOWN);
#if defined(__amd64__) || defined(__i386__)
/*
diff --git a/stand/efi/loader/framebuffer.c b/stand/efi/loader/framebuffer.c
--- a/stand/efi/loader/framebuffer.c
+++ b/stand/efi/loader/framebuffer.c
@@ -851,7 +851,8 @@
return (text_autoresize());
}
-COMMAND_SET(efi_autoresize, "efi-autoresizecons", "EFI Auto-resize Console", command_autoresize);
+COMMAND_SET_FLAGS(efi_autoresize, "efi-autoresizecons",
+ "EFI Auto-resize Console", command_autoresize, CMDF_LOCKDOWN);
static int
command_autoresize(int argc, char *argv[])
@@ -882,7 +883,8 @@
return (text_autoresize());
}
-COMMAND_SET(gop, "gop", "graphics output protocol", command_gop);
+COMMAND_SET_FLAGS(gop, "gop", "graphics output protocol", command_gop,
+ CMDF_LOCKDOWN);
static int
command_gop(int argc, char *argv[])
@@ -989,7 +991,8 @@
return (CMD_ERROR);
}
-COMMAND_SET(uga, "uga", "universal graphics adapter", command_uga);
+COMMAND_SET_FLAGS(uga, "uga", "universal graphics adapter", command_uga,
+ CMDF_LOCKDOWN);
static int
command_uga(int argc, char *argv[])
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -4,6 +4,10 @@
* All rights reserved.
*
* Copyright (c) 2016-2019 Netflix, Inc. written by M. Warner Losh
+ * 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
@@ -1640,7 +1644,8 @@
return (EFI_SUCCESS); /* keep compiler happy */
}
-COMMAND_SET(efi_seed_entropy, "efi-seed-entropy", "try to get entropy from the EFI RNG", command_seed_entropy);
+COMMAND_SET_FLAGS(efi_seed_entropy, "efi-seed-entropy",
+ "try to get entropy from the EFI RNG", command_seed_entropy, CMDF_LOCKDOWN);
static int
command_seed_entropy(int argc, char *argv[])
@@ -1713,8 +1718,10 @@
return (CMD_OK);
}
-COMMAND_SET(poweroff, "poweroff", "power off the system", command_poweroff);
-COMMAND_SET(halt, "halt", "power off the system", command_poweroff);
+COMMAND_SET_FLAGS(poweroff, "poweroff", "power off the system",
+ command_poweroff, CMDF_LOCKDOWN);
+COMMAND_SET_FLAGS(halt, "halt", "power off the system", command_poweroff,
+ CMDF_LOCKDOWN);
static int
command_poweroff(int argc __unused, char *argv[] __unused)
@@ -1731,7 +1738,8 @@
return (CMD_ERROR);
}
-COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot);
+COMMAND_SET_FLAGS(reboot, "reboot", "reboot the system", command_reboot,
+ CMDF_LOCKDOWN);
static int
command_reboot(int argc, char *argv[])
@@ -1748,7 +1756,7 @@
return (CMD_ERROR);
}
-COMMAND_SET(memmap, "memmap", "print memory map", command_memmap);
+COMMAND_SET_RDONLY(memmap, "memmap", "print memory map", command_memmap);
static int
command_memmap(int argc __unused, char *argv[] __unused)
@@ -1821,7 +1829,7 @@
return (CMD_OK);
}
-COMMAND_SET(configuration, "configuration", "print configuration tables",
+COMMAND_SET_RDONLY(configuration, "configuration", "print configuration tables",
command_configuration);
static int
@@ -1852,7 +1860,8 @@
}
-COMMAND_SET(mode, "mode", "change or display EFI text modes", command_mode);
+COMMAND_SET_FLAGS(mode, "mode", "change or display EFI text modes",
+ command_mode, CMDF_LOCKDOWN);
static int
command_mode(int argc, char *argv[])
@@ -1901,7 +1910,7 @@
return (CMD_OK);
}
-COMMAND_SET(lsefi, "lsefi", "list EFI handles", command_lsefi);
+COMMAND_SET_RDONLY(lsefi, "lsefi", "list EFI handles", command_lsefi);
static void
lsefi_print_handle_info(EFI_HANDLE handle)
@@ -2010,7 +2019,9 @@
return (command_fdt_internal(argc, argv));
}
-COMMAND_SET(fdt, "fdt", "flattened device tree handling", command_fdt);
+/* Subcommands that modify the blob check lockdown themselves. */
+COMMAND_SET_FLAGS(fdt, "fdt", "flattened device tree handling",
+ command_fdt, CMDF_LOCKDOWN);
#endif
/*
@@ -2189,6 +2200,7 @@
}
-COMMAND_SET(netserver, "netserver", "change or display netserver URI",
- command_netserver);
+/* Lockdown-safe only because kernel and module loads are verified. */
+COMMAND_SET_FLAGS(netserver, "netserver", "change or display netserver URI",
+ command_netserver, CMDF_LOCKDOWN);
#endif
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 27, 4:19 AM (19 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42035029
Default Alt Text
D62092.1795753157.diff (7 KB)
Attached To
Mode
D62092: loader: efi: annotate commands that are safe in lockdown
Attached
Detach File
Event Timeline