Skip to content

Commit c7e3f9f

Browse files
committed
collect: capture the EFI marker and the bpf sysctl for replay
SF_EFI_PRESENT is decided by whether /sys/firmware/efi exists, probed with kasld_access rather than read, but grab copies file contents with cat and cannot capture a bare directory. No bundle has ever carried the path, so every replay resolved the captured host as non-EFI. Create the directory under sysroot/ when the live one exists. kernel.unprivileged_bpf_disabled was missing from the captured sysctl list, though environment.c reads it into the hardening state and the report gates a section on it. A replayed bundle therefore reported it unread where the capturing host had a value. Add it beside the other three hardening sysctls already collected. Set umask 077 for the capture as well. A bundle holds /proc/cmdline, dmesg, and with --kallsyms the kernel's real symbol addresses, and it sits in the working directory until it is reviewed and shared; the files inherited the ambient umask, so on a host with the common 002 they landed group-writable and world-readable.
1 parent e3aec53 commit c7e3f9f

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

extra/collect

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
# silent partial bundle. Fatal setup failures are checked explicitly.
2525
set -u
2626

27+
# A bundle holds /proc/cmdline, dmesg, and with --kallsyms the kernel's real
28+
# symbol addresses. It sits in the working directory until it is reviewed and
29+
# shared, so create it readable only by the user who ran the capture rather than
30+
# at whatever the ambient umask allows.
31+
umask 077
32+
2733
PROG=$(basename "$0")
2834
COLLECT_VERSION=2
2935

@@ -270,6 +276,7 @@ for f in \
270276
/proc/iomem /proc/modules /proc/version \
271277
/proc/sys/kernel/kptr_restrict /proc/sys/kernel/dmesg_restrict \
272278
/proc/sys/kernel/perf_event_paranoid /proc/sys/kernel/randomize_va_space \
279+
/proc/sys/kernel/unprivileged_bpf_disabled \
273280
/sys/kernel/security/lockdown \
274281
/sys/kernel/boot_params/data /sys/kernel/boot_params/setup_data \
275282
/sys/kernel/notes
@@ -320,7 +327,12 @@ committing this capture."
320327
echo "$w" >&2
321328
echo "$w" >> "$NOTES"
322329
fi
323-
[ -e /sys/firmware/efi ] && echo "present: /sys/firmware/efi" >> "$NOTES"
330+
# efi_present probes this path itself (kasld_access), so the directory must
331+
# exist in the sysroot; a bare directory cannot be captured by grab.
332+
if [ -e /sys/firmware/efi ]; then
333+
echo "present: /sys/firmware/efi" >> "$NOTES"
334+
mkdir -p "$OUT/sysroot/sys/firmware/efi"
335+
fi
324336

325337
# /boot: copy the config (small), mirror the big images as sparse placeholders.
326338
grab "/boot/config-$REL"

0 commit comments

Comments
 (0)