Merge branch 'master' into scs_pac 131/head
authorJulien Voisin <jvoisin@users.noreply.github.com>
Sun, 19 May 2024 19:17:19 +0000 (19:17 +0000)
committerGitHub <noreply@github.com>
Sun, 19 May 2024 19:17:19 +0000 (19:17 +0000)
1  2 
kernel_hardening_checker/checks.py

index e0caab63e10f6d31e4122e5884fa05170c70e049,f2e4c34fd6da0a81a046563329dd5e2736a09f46..672ea7e5df389cab8eedcc004e4587aa44d78cf7
@@@ -8,13 -8,14 +8,14 @@@ Author: Alexander Popov <alex.popov@lin
  This module contains knowledge for checks.
  """
  
- # pylint: disable=missing-function-docstring,line-too-long,invalid-name
+ # pylint: disable=missing-function-docstring,line-too-long
  # pylint: disable=too-many-branches,too-many-statements,too-many-locals
  
- from .engine import KconfigCheck, CmdlineCheck, SysctlCheck, VersionCheck, OR, AND
+ from typing import List
+ from .engine import StrOrNone, ChecklistObjType, KconfigCheck, CmdlineCheck, SysctlCheck, VersionCheck, OR, AND
  
  
- def add_kconfig_checks(l, arch):
+ def add_kconfig_checks(l: List[ChecklistObjType], arch: str) -> None:
      assert(arch), 'empty arch'
  
      # Calling the KconfigCheck class constructor:
      if arch == 'ARM64':
          l += [KconfigCheck('self_protection', 'kspp', 'ARM64_SW_TTBR0_PAN', 'y')]
          l += [KconfigCheck('self_protection', 'kspp', 'SHADOW_CALL_STACK', 'y')]
 +        l += [KconfigCheck('self_protection', 'kspp', 'UNWIND_PATCH_PAC_INTO_SCS', 'y')]
          l += [KconfigCheck('self_protection', 'kspp', 'KASAN_HW_TAGS', 'y')] # see also: kasan=on, kasan.stacktrace=off, kasan.fault=panic
      if arch == 'X86_32':
          l += [KconfigCheck('self_protection', 'kspp', 'PAGE_TABLE_ISOLATION', 'y')]
          l += [KconfigCheck('harden_userspace', 'a13xp0p0v', 'X86_USER_SHADOW_STACK', 'y')]
  
  
- def add_cmdline_checks(l, arch):
+ def add_cmdline_checks(l: List[ChecklistObjType], arch: str) -> None:
      assert(arch), 'empty arch'
  
      # Calling the CmdlineCheck class constructor:
@@@ -631,7 -631,7 +632,7 @@@ no_kstrtobool_options = 
  ]
  
  
- def normalize_cmdline_options(option, value):
+ def normalize_cmdline_options(option: str, value: str) -> str:
      # Don't normalize the cmdline option values if
      # the Linux kernel doesn't use kstrtobool() for them
      if option in no_kstrtobool_options:
      return value
  
  
- # TODO: draft of security hardening sysctls:
+ # Ideas of security hardening sysctls:
  #    what about bpf_jit_enable?
  #    vm.mmap_min_addr has a good value
  #    nosmt sysfs control file
  #    kernel.warn_limit (think about a proper value)
  #    net.ipv4.tcp_syncookies=1 (?)
  
- def add_sysctl_checks(l, _arch):
+ def add_sysctl_checks(l: List[ChecklistObjType], _arch: StrOrNone) -> None:
  # This function may be called with arch=None
  
  # Calling the SysctlCheck class constructor: