X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=kconfig_hardened_check%2F__init__.py;h=8f261499d7e2f5529e91c5f0be1d5c5d7f4d5221;hb=fbaf5df462dd9e5efa6325158c47f415b38b10b5;hp=f82c07c45f3aa5f72e0d45dbdc7cfacfdbaf132e;hpb=1a789f4bc5276dfc41bedd60056f1c10c2adaab7;p=kconfig-hardened-check.git diff --git a/kconfig_hardened_check/__init__.py b/kconfig_hardened_check/__init__.py index f82c07c..8f26149 100644 --- a/kconfig_hardened_check/__init__.py +++ b/kconfig_hardened_check/__init__.py @@ -312,6 +312,7 @@ def construct_checklist(l, arch): VerCheck((5, 9))))] # HARDEN_EL2_VECTORS was included in RANDOMIZE_BASE in v5.9 l += [OptCheck('self_protection', 'defconfig', 'RODATA_FULL_DEFAULT_ENABLED', 'y')] l += [OptCheck('self_protection', 'defconfig', 'ARM64_PTR_AUTH', 'y')] + l += [OptCheck('self_protection', 'defconfig', 'ARM64_BTI_KERNEL', 'y')] if arch in ('X86_64', 'ARM64'): l += [OptCheck('self_protection', 'defconfig', 'VMAP_STACK', 'y')] if arch in ('X86_64', 'ARM64', 'X86_32'): @@ -351,10 +352,10 @@ def construct_checklist(l, arch): modules_not_set)] l += [OR(OptCheck('self_protection', 'kspp', 'MODULE_SIG_FORCE', 'y'), modules_not_set)] # refers to LOCKDOWN - l += [OR(OptCheck('self_protection', 'kspp', 'INIT_STACK_ALL', 'y'), + l += [OR(OptCheck('self_protection', 'kspp', 'INIT_STACK_ALL_ZERO', 'y'), OptCheck('self_protection', 'kspp', 'GCC_PLUGIN_STRUCTLEAK_BYREF_ALL', 'y'))] l += [OR(OptCheck('self_protection', 'kspp', 'INIT_ON_FREE_DEFAULT_ON', 'y'), - OptCheck('self_protection', 'kspp', 'PAGE_POISONING', 'y'))] # before v5.3 + OptCheck('self_protection', 'kspp', 'PAGE_POISONING_ZERO', 'y'))] # before v5.3 if arch in ('X86_64', 'ARM64', 'X86_32'): stackleak_is_set = OptCheck('self_protection', 'kspp', 'GCC_PLUGIN_STACKLEAK', 'y') l += [stackleak_is_set] @@ -395,11 +396,16 @@ def construct_checklist(l, arch): iommu_support_is_set)] # 'self_protection', 'my' + l += [AND(OptCheck('self_protection', 'my', 'UBSAN_BOUNDS', 'y'), + OptCheck('self_protection', 'my', 'UBSAN_MISC', 'is not set'), + OptCheck('self_protection', 'my', 'UBSAN_TRAP', 'y'))] l += [OptCheck('self_protection', 'my', 'SLUB_DEBUG_ON', 'y')] # TODO: is it better to set that via kernel cmd? l += [OptCheck('self_protection', 'my', 'RESET_ATTACK_MITIGATION', 'y')] # needs userspace support (systemd) if arch == 'X86_64': l += [AND(OptCheck('self_protection', 'my', 'AMD_IOMMU_V2', 'y'), iommu_support_is_set)] + if arch == 'ARM64': + l += [OptCheck('self_protection', 'my', 'SHADOW_CALL_STACK', 'y')] # 'security_policy' if arch in ('X86_64', 'ARM64', 'X86_32'): @@ -505,6 +511,7 @@ def construct_checklist(l, arch): l += [OptCheck('cut_attack_surface', 'lockdown', 'MMIOTRACE_TEST', 'is not set')] # refers to LOCKDOWN # 'cut_attack_surface', 'my' + l += [OptCheck('cut_attack_surface', 'my', 'TRIM_UNUSED_KSYMS', 'y')] l += [OptCheck('cut_attack_surface', 'my', 'MMIOTRACE', 'is not set')] # refers to LOCKDOWN (permissive) l += [OptCheck('cut_attack_surface', 'my', 'LIVEPATCH', 'is not set')] l += [OptCheck('cut_attack_surface', 'my', 'IP_DCCP', 'is not set')] @@ -594,22 +601,22 @@ def print_checklist(mode, checklist, with_results): def perform_check(opt, parsed_options, kernel_version): - if hasattr(opt, 'opts'): - # prepare ComplexOptCheck - for o in opt.opts: - if hasattr(o, 'opts'): - # Recursion for nested ComplexOptChecks - perform_check(o, parsed_options, kernel_version) - if hasattr(o, 'state'): - o.state = parsed_options.get(o.name, None) - if hasattr(o, 'ver'): - o.ver = kernel_version - else: - # prepare simple check, opt.state is mandatory - if not hasattr(opt, 'state'): - sys.exit('[!] ERROR: bad simple check {}'.format(vars(opt))) - opt.state = parsed_options.get(opt.name, None) - opt.check() + if hasattr(opt, 'opts'): + # prepare ComplexOptCheck + for o in opt.opts: + if hasattr(o, 'opts'): + # Recursion for nested ComplexOptChecks + perform_check(o, parsed_options, kernel_version) + if hasattr(o, 'state'): + o.state = parsed_options.get(o.name, None) + if hasattr(o, 'ver'): + o.ver = kernel_version + else: + # prepare simple check, opt.state is mandatory + if not hasattr(opt, 'state'): + sys.exit('[!] ERROR: bad simple check {}'.format(vars(opt))) + opt.state = parsed_options.get(opt.name, None) + opt.check() def perform_checks(checklist, parsed_options, kernel_version):