Changeset 99536 in vbox
- Timestamp:
- Apr 26, 2023 7:04:57 PM (19 months ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/installer/vboxadd.sh
r99525 r99536 397 397 kernel_get_config_opt() 398 398 { 399 opt_name="$1" 399 kern_ver="$1" 400 opt_name="$2" 401 402 [ -n "$kern_ver" ] || return 400 403 [ -n "$opt_name" ] || return 401 404 402 405 # Check if there is a kernel tool which can extract config option. 403 if test -x /lib/modules/"$ KERN_VER"/build/scripts/config; then404 /lib/modules/"$ KERN_VER"/build/scripts/config \405 --file /lib/modules/"$ KERN_VER"/build/.config \406 if test -x /lib/modules/"$kern_ver"/build/scripts/config; then 407 /lib/modules/"$kern_ver"/build/scripts/config \ 408 --file /lib/modules/"$kern_ver"/build/.config \ 406 409 --state "$opt_name" 2>/dev/null 407 elif test -f /lib/modules/"$ KERN_VER"/build/.config; then410 elif test -f /lib/modules/"$kern_ver"/build/.config; then 408 411 # Extract config option manually. 409 grep "$opt_name " /lib/modules/"$KERN_VER"/build/.config | sed -e "s/^$opt_name=//" -e "s/\"//g"412 grep "$opt_name=" /lib/modules/"$kern_ver"/build/.config | sed -e "s/^$opt_name=//" -e "s/\"//g" 410 413 fi 411 414 } … … 414 417 kernel_module_sig_hash() 415 418 { 416 kernel_get_config_opt "CONFIG_MODULE_SIG_HASH" 419 kern_ver="$1" 420 [ -n "$kern_ver" ] || return 421 422 kernel_get_config_opt "$kern_ver" "CONFIG_MODULE_SIG_HASH" 417 423 } 418 424 … … 434 440 } 435 441 442 # Check if kernel configuration requires modules signature. 443 kernel_requires_module_signature() 444 { 445 kern_ver="$1" 446 vbox_sys_lockdown_path="/sys/kernel/security/lockdown" 447 448 [ -n "$kern_ver" ] || return 449 450 requires="" 451 # We consider that if kernel is running in the following configurations, 452 # it will require modules to be signed. 453 if [ "$(kernel_get_config_opt "$kern_ver" "CONFIG_MODULE_SIG")" = "y" ]; then 454 455 # Modules signature verification is hardcoded in kernel config. 456 [ "$(kernel_get_config_opt "$kern_ver" "CONFIG_MODULE_SIG_FORCE")" = "y" ] && requires="1" 457 458 # Unsigned modules loading is restricted by "lockdown" feature in runtime. 459 if [ "$(kernel_get_config_opt "$kern_ver" "CONFIG_SECURITY_LOCKDOWN_LSM")" = "y" \ 460 -o "$(kernel_get_config_opt "$kern_ver" "CONFIG_SECURITY_LOCKDOWN_LSM_EARLY")" = "y" ]; then 461 462 # Once lockdown level is set to something different from "none" (e.g., "integrity" 463 # or "confidentiality"), kernel will reject unsigned modules loading. 464 if [ -r "$vbox_sys_lockdown_path" ]; then 465 [ -n "$(cat "$vbox_sys_lockdown_path" | grep "\[integrity\]")" ] && requires="1" 466 [ -n "$(cat "$vbox_sys_lockdown_path" | grep "\[confidentiality\]")" ] && requires="1" 467 fi 468 469 # This configuration is used by a number of modern Linux distributions and restricts 470 # unsigned modules loading when Secure Boot mode is enabled. 471 [ "$(kernel_get_config_opt "$kern_ver" "CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT")" = "y" -a -n "$HAVE_SEC_BOOT" ] && requires="1" 472 fi 473 fi 474 475 [ -n "$requires" ] && echo "1" 476 } 477 436 478 sign_modules() 437 479 { … … 444 486 [ -f "/lib/modules/"$KERN_VER"/misc/vboxvideo.ko" ] && MODULE_LIST="$MODULE_LIST vboxvideo" 445 487 446 # S ecure boot on Ubuntu, Debian and Oracle Linux.447 if test -n "$HAVE_SEC_BOOT"; then488 # Sign kernel modules if kernel configuration requires it. 489 if test "$(kernel_requires_module_signature $KERN_VER)" = "1"; then 448 490 begin "Signing VirtualBox Guest Additions kernel modules" 449 491 … … 475 517 476 518 # Get kernel signature hash algorithm from kernel config and validate it. 477 sig_hashalgo=$(kernel_module_sig_hash )519 sig_hashalgo=$(kernel_module_sig_hash "$KERN_VER") 478 520 [ "$(module_sig_hash_supported $sig_hashalgo)" = "1" ] \ 479 521 || fail "Unsupported kernel signature hash algorithm $sig_hashalgo" … … 532 574 # Detect if kernel was built with clang. 533 575 unset LLVM 534 vbox_cc_is_clang=$(kernel_get_config_opt " CONFIG_CC_IS_CLANG")576 vbox_cc_is_clang=$(kernel_get_config_opt "$KERN_VER" "CONFIG_CC_IS_CLANG") 535 577 if test "${vbox_cc_is_clang}" = "y"; then 536 578 info "Using clang compiler." … … 795 837 [ "$mod_dir" = "misc" ] || return 796 838 797 # In case if system is running in Secure Boot mode, check if module is signed. 798 if test -n "$HAVE_SEC_BOOT"; then 839 # In case if kernel configuration (for currently loaded kernel) requires 840 # module signature, check if module is signed. 841 if test "$(kernel_requires_module_signature $(uname -r))" = "1"; then 799 842 [ "$(module_signed "$mod")" = "1" ] || return 800 843 fi … … 903 946 904 947 # Warn if Secure Boot setup not yet complete. 905 if test -n "$HAVE_SEC_BOOT" && test -z "$DEB_KEY_ENROLLED"; then948 if test "$(kernel_requires_module_signature)" = "1" && test -z "$DEB_KEY_ENROLLED"; then 906 949 if test -n "$HAVE_DEB_KEY"; then 907 950 info "You must re-start your system to finish secure boot set-up." -
trunk/src/VBox/Installer/linux/vboxdrv.sh
r98565 r99536 355 355 elif test -f /lib/modules/"$KERN_VER"/build/.config; then 356 356 # Extract config option manually. 357 grep "$opt_name " /lib/modules/"$KERN_VER"/build/.config | sed -e "s/^$opt_name=//" -e "s/\"//g"357 grep "$opt_name=" /lib/modules/"$KERN_VER"/build/.config | sed -e "s/^$opt_name=//" -e "s/\"//g" 358 358 fi 359 359 } … … 380 380 381 381 echo "1" 382 } 383 384 # Check if kernel configuration requires modules signature. 385 kernel_requires_module_signature() 386 { 387 vbox_sys_lockdown_path="/sys/kernel/security/lockdown" 388 389 requires="" 390 # We consider that if kernel is running in the following configurations, 391 # it will require modules to be signed. 392 if [ "$(kernel_get_config_opt "CONFIG_MODULE_SIG")" = "y" ]; then 393 394 # Modules signature verification is hardcoded in kernel config. 395 [ "$(kernel_get_config_opt "CONFIG_MODULE_SIG_FORCE")" = "y" ] && requires="1" 396 397 # Unsigned modules loading is restricted by "lockdown" feature in runtime. 398 if [ "$(kernel_get_config_opt "CONFIG_SECURITY_LOCKDOWN_LSM")" = "y" \ 399 -o "$(kernel_get_config_opt "CONFIG_SECURITY_LOCKDOWN_LSM_EARLY")" = "y" ]; then 400 401 # Once lockdown level is set to something different than "none" (e.g., "integrity" 402 # or "confidentiality"), kernel will reject unsigned modules loading. 403 if [ -r "$vbox_sys_lockdown_path" ]; then 404 [ -n "$(cat "$vbox_sys_lockdown_path" | grep "\[integrity\]")" ] && requires="1" 405 [ -n "$(cat "$vbox_sys_lockdown_path" | grep "\[confidentiality\]")" ] && requires="1" 406 fi 407 408 # This configuration is used by a number of modern Linux distributions and restricts 409 # unsigned modules loading when Secure Boot mode is enabled. 410 [ "$(kernel_get_config_opt "CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT")" = "y" -a -n "$HAVE_SEC_BOOT" ] && requires="1" 411 fi 412 fi 413 414 [ -n "$requires" ] && echo "1" 382 415 } 383 416 … … 467 500 [ "$mod_dir" = "misc" ] || return 468 501 469 # In case if system is running in Secure Boot mode, check if module is signed.470 if test -n "$HAVE_SEC_BOOT"; then502 # In case if kernel configuration requires module signature, check if module is signed. 503 if test "$(kernel_requires_module_signature)" = "1"; then 471 504 [ "$(module_signed "$mod")" = "1" ] || return 472 505 fi … … 492 525 failure "Running VirtualBox in a Xen environment is not supported" 493 526 fi 494 if test -n "$HAVE_SEC_BOOT" && test -z "$DEB_KEY_ENROLLED"; then527 if test "$(kernel_requires_module_signature)" = "1" && test -z "$DEB_KEY_ENROLLED"; then 495 528 if test -n "$HAVE_DEB_KEY"; then 496 529 begin_msg "You must re-start your system to finish Debian secure boot set-up." console … … 553 586 fi 554 587 # Create the /dev/vboxusb directory if the host supports that method 555 # of USB access. The USB code checks for the exist ance of that path.588 # of USB access. The USB code checks for the existence of that path. 556 589 if grep -q usb_device /proc/devices; then 557 590 mkdir -p -m 0750 /dev/vboxusb 2>/dev/null … … 701 734 failure "Look at $LOG to find out what went wrong" 702 735 fi 703 log "Building the net adapt or module."736 log "Building the net adapter module." 704 737 if ! myerr=`$BUILDINTMP \ 705 738 --use-module-symvers /tmp/vboxdrv-Module.symvers \ … … 726 759 succ_msg "VirtualBox kernel modules built" 727 760 728 # S ecure boot on Ubuntu, Debian and Oracle Linux.729 if test -n "$HAVE_SEC_BOOT"; then761 # Sign kernel modules if kernel configuration requires it. 762 if test "$(kernel_requires_module_signature)" = "1"; then 730 763 begin_msg "Signing VirtualBox kernel modules" console 731 764
Note:
See TracChangeset
for help on using the changeset viewer.