@@ -272,6 +272,10 @@ Creates initial ramdisk images for preloading modules
272
272
Use [FILE] as a splash image when creating an UEFI
273
273
executable. Requires bitmap (.bmp) image format.
274
274
--kernel-image [FILE] Location of the kernel image.
275
+ --sbat [PARAMETERS] The SBAT parameters to be added to .sbat.
276
+ The string "sbat,1,SBAT Version,sbat,1,
277
+ https://github.com/rhboot/shim/blob/main/SBAT.md" is
278
+ already added by default.
275
279
--regenerate-all Regenerate all initramfs images at the default location
276
280
for the kernel versions found on the system.
277
281
-p, --parallel Use parallel processing if possible (currently only
@@ -463,6 +467,7 @@ rearrange_params() {
463
467
--long uefi-stub: \
464
468
--long uefi-splash-image: \
465
469
--long kernel-image: \
470
+ --long sbat: \
466
471
--long no-hostonly-i18n \
467
472
--long hostonly-i18n \
468
473
--long hostonly-nics: \
@@ -840,6 +845,11 @@ while :; do
840
845
PARMS_TO_STORE+=" '$2 '"
841
846
shift
842
847
;;
848
+ --sbat)
849
+ sbat_l=" $2 "
850
+ PARMS_TO_STORE+=" '$2 '"
851
+ shift
852
+ ;;
843
853
--no-machineid)
844
854
machine_id_l=" no"
845
855
;;
@@ -1079,6 +1089,7 @@ drivers_dir="${drivers_dir%"${drivers_dir##*[!/]}"}"
1079
1089
[[ $uefi_stub_l ]] && uefi_stub=" $uefi_stub_l "
1080
1090
[[ $uefi_splash_image_l ]] && uefi_splash_image=" $uefi_splash_image_l "
1081
1091
[[ $kernel_image_l ]] && kernel_image=" $kernel_image_l "
1092
+ [[ $sbat_l ]] && sbat=" $sbat_l "
1082
1093
[[ $machine_id_l ]] && machine_id=" $machine_id_l "
1083
1094
1084
1095
if ! [[ $outfile ]]; then
@@ -2452,6 +2463,24 @@ fi
2452
2463
2453
2464
umask 077
2454
2465
2466
+ SBAT_DEFAULT=" sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md"
2467
+ sbat_out=$uefi_outdir /uki.sbat
2468
+
2469
+ clean_sbat_string () {
2470
+ local inp=$1
2471
+ local temp=$uefi_outdir /temp.sbat
2472
+ sed " /${SBAT_DEFAULT// \/ / \\ / } /d" " $inp " > " $temp "
2473
+ [[ -s $temp ]] && cat " $temp " >> " $sbat_out "
2474
+ rm " $temp "
2475
+ }
2476
+
2477
+ get_sbat_string () {
2478
+ local inp=$1
2479
+ local out=$uefi_outdir /$2
2480
+ objcopy -O binary --only-section=.sbat " $inp " " $out "
2481
+ clean_sbat_string " $out "
2482
+ }
2483
+
2455
2484
if [[ $uefi == yes ]]; then
2456
2485
if [[ $kernel_cmdline ]]; then
2457
2486
echo -n " $kernel_cmdline " > " $uefi_outdir /cmdline.txt"
@@ -2506,6 +2535,16 @@ if [[ $uefi == yes ]]; then
2506
2535
unset uefi_splash_image
2507
2536
fi
2508
2537
2538
+ echo " $SBAT_DEFAULT " > " $sbat_out "
2539
+ if [[ -n $sbat ]]; then
2540
+ echo " $sbat " | sed " /${SBAT_DEFAULT// \/ / \\ / } /d" >> " $sbat_out "
2541
+ fi
2542
+ get_sbat_string " $kernel_image " kernel.sbat
2543
+ get_sbat_string " $uefi_stub " stub.sbat
2544
+
2545
+ uefi_sbat_offs=" ${offs} "
2546
+ offs=$(( offs + $(stat - Lc% s "$sbat_out ")) )
2547
+ offs=$(( offs + "$align " - offs % "$align "))
2509
2548
uefi_linux_offs=" ${offs} "
2510
2549
offs=$(( offs + $(stat - Lc% s "$kernel_image ")) )
2511
2550
offs=$(( offs + "$align " - offs % "$align "))
@@ -2517,14 +2556,19 @@ if [[ $uefi == yes ]]; then
2517
2556
exit 1
2518
2557
fi
2519
2558
2559
+ tmp_uefi_stub=$uefi_outdir /elf.stub
2560
+ cp " $uefi_stub " " $tmp_uefi_stub "
2561
+ objcopy --remove-section .sbat " $tmp_uefi_stub " & > /dev/null
2562
+
2520
2563
if objcopy \
2521
2564
${uefi_osrelease: +--add-section .osrel=" $uefi_osrelease " --change-section-vma .osrel=$(printf 0x% x " $uefi_osrelease_offs " )} \
2522
2565
${uefi_cmdline: +--add-section .cmdline=" $uefi_cmdline " --change-section-vma .cmdline=$(printf 0x% x " $uefi_cmdline_offs " )} \
2523
2566
${uefi_splash_image: +--add-section .splash=" $uefi_splash_image " --change-section-vma .splash=$(printf 0x% x " $uefi_splash_offs " )} \
2567
+ --add-section .sbat=" $sbat_out " --change-section-vma .sbat=" $( printf 0x%x " $uefi_sbat_offs " ) " \
2524
2568
--add-section .linux=" $kernel_image " --change-section-vma .linux=" $( printf 0x%x " $uefi_linux_offs " ) " \
2525
2569
--add-section .initrd=" ${DRACUT_TMPDIR} /initramfs.img" --change-section-vma .initrd=" $( printf 0x%x " $uefi_initrd_offs " ) " \
2526
2570
--image-base=" $( printf 0x%x " $base_image " ) " \
2527
- " $uefi_stub " " ${uefi_outdir} /linux.efi" ; then
2571
+ " $tmp_uefi_stub " " ${uefi_outdir} /linux.efi" ; then
2528
2572
if [[ -n ${uefi_secureboot_key} && -n ${uefi_secureboot_cert} ]]; then
2529
2573
if sbsign \
2530
2574
${uefi_secureboot_engine: +--engine " $uefi_secureboot_engine " } \
0 commit comments