kconfig-hardened-check.git
14 months agobackport: Fix the bug in OptCheck.check() introduced in cb779a71bf57d95b v0.6.1-fixes v0.6.1
Alexander Popov [Mon, 6 Mar 2023 08:13:07 +0000 (11:13 +0300)]
backport: Fix the bug in OptCheck.check() introduced in cb779a71bf57d95b

Use 'elif' instead of 'if' to avoid wrong self.result when
self.state is 'off'.

We need unit-tests for the engine checking the correctness: #79

15 months agoUpdate the README
Alexander Popov [Sun, 22 Jan 2023 00:37:51 +0000 (03:37 +0300)]
Update the README

Ready for release 0.6.1.

15 months agoFix the 'decision' for the slub_merge check
Alexander Popov [Sun, 22 Jan 2023 22:16:52 +0000 (01:16 +0300)]
Fix the 'decision' for the slub_merge check

15 months agoFix the pylint R1714 issues
Alexander Popov [Sun, 22 Jan 2023 00:16:01 +0000 (03:16 +0300)]
Fix the pylint R1714 issues

No functional changes

15 months agoAdd the check for the 'kvm.nx_huge_pages' cmdline parameter
Alexander Popov [Sat, 21 Jan 2023 22:52:33 +0000 (01:52 +0300)]
Add the check for the 'kvm.nx_huge_pages' cmdline parameter

15 months agoAdd the check for the slub_merge cmdline parameter
Alexander Popov [Sat, 21 Jan 2023 22:41:43 +0000 (01:41 +0300)]
Add the check for the slub_merge cmdline parameter

15 months agoRename the file with the KSPP cmdline recommendations to avoid breaking the CI
Alexander Popov [Sat, 21 Jan 2023 22:07:42 +0000 (01:07 +0300)]
Rename the file with the KSPP cmdline recommendations to avoid breaking the CI

15 months agoClean up the comments
Alexander Popov [Sat, 21 Jan 2023 22:00:31 +0000 (01:00 +0300)]
Clean up the comments

15 months agoAdd the check for the iommu cmdline option
Alexander Popov [Sat, 21 Jan 2023 21:58:41 +0000 (00:58 +0300)]
Add the check for the iommu cmdline option

Refers to #76

15 months agoAdd the KSPP cmdline recommendations for x86_64
Alexander Popov [Sat, 21 Jan 2023 12:30:56 +0000 (15:30 +0300)]
Add the KSPP cmdline recommendations for x86_64

15 months agoInclude parsed_cmdline_options in the print_unknown_options() call
Alexander Popov [Sat, 21 Jan 2023 12:23:13 +0000 (15:23 +0300)]
Include parsed_cmdline_options in the print_unknown_options() call

15 months agoRename the files with the KSPP recommendations
Alexander Popov [Sat, 21 Jan 2023 10:53:39 +0000 (13:53 +0300)]
Rename the files with the KSPP recommendations

15 months agoDrop get-nix-kconfig.py (`nix-build get-nixos-kconfig.nix` does the job)
Alexander Popov [Thu, 19 Jan 2023 15:54:49 +0000 (18:54 +0300)]
Drop get-nix-kconfig.py (`nix-build get-nixos-kconfig.nix` does the job)

Refers to #77 and #63.

15 months agoAdd the NixOS kernel configs
Alexander Popov [Thu, 19 Jan 2023 15:34:12 +0000 (18:34 +0300)]
Add the NixOS kernel configs

Refers to #77

15 months agoMerge branch 'from-o8opi-2'
Alexander Popov [Thu, 19 Jan 2023 15:10:54 +0000 (18:10 +0300)]
Merge branch 'from-o8opi-2'

Thanks, @o8opi

15 months agoUpdate the VMAP_STACK check: it is available for ARM
Alexander Popov [Sun, 15 Jan 2023 21:10:12 +0000 (00:10 +0300)]
Update the VMAP_STACK check: it is available for ARM

15 months agoFix the arch condition for the SCHED_CORE check (II)
Alexander Popov [Sun, 15 Jan 2023 20:06:20 +0000 (23:06 +0300)]
Fix the arch condition for the SCHED_CORE check (II)

15 months agoUpdate the KSPP recommendations
Alexander Popov [Sat, 14 Jan 2023 15:46:45 +0000 (18:46 +0300)]
Update the KSPP recommendations

15 months agoFix the IOMMU_DEFAULT_DMA_STRICT check: it is in defconfig for arm64 and arm
Alexander Popov [Sat, 14 Jan 2023 15:07:29 +0000 (18:07 +0300)]
Fix the IOMMU_DEFAULT_DMA_STRICT check: it is in defconfig for arm64 and arm

15 months agoAdd the COMPAT and X86_X32_ABI checks
Alexander Popov [Sat, 14 Jan 2023 10:47:21 +0000 (13:47 +0300)]
Add the COMPAT and X86_X32_ABI checks

KSPP has added them to the recommendations.

Refers to #74.

15 months agoFix the WERROR check: it is in defconfig for X86_64 and X86_32 now
Alexander Popov [Sat, 14 Jan 2023 10:39:49 +0000 (13:39 +0300)]
Fix the WERROR check: it is in defconfig for X86_64 and X86_32 now

15 months agoFix the DEBUG_WX check: it is in defconfig for X86_64 and X86_32 now
Alexander Popov [Sat, 14 Jan 2023 10:33:33 +0000 (13:33 +0300)]
Fix the DEBUG_WX check: it is in defconfig for X86_64 and X86_32 now

15 months agoAdd defconfigs for Linux v6.1
Alexander Popov [Fri, 13 Jan 2023 19:12:22 +0000 (22:12 +0300)]
Add defconfigs for Linux v6.1

16 months agoadd get-nixos-kconfig nix script 77/head
o8opi [Thu, 29 Dec 2022 09:02:02 +0000 (10:02 +0100)]
add get-nixos-kconfig nix script

16 months agoAdd the repository mirrors 64/head
Alexander Popov [Mon, 26 Dec 2022 09:58:06 +0000 (12:58 +0300)]
Add the repository mirrors

16 months agoBackup the pull requests and issues into a Markdown file using gh2md
Alexander Popov [Sun, 25 Dec 2022 18:03:04 +0000 (21:03 +0300)]
Backup the pull requests and issues into a Markdown file using gh2md

That would allow to have more information in the mirror repositories.

I used the mattduck/gh2md tool for that purpose.
It employs https://api.github.com/graphql, so I had to generate
a GitHub personal access token (classic) with public access.

16 months agoRemove the AIO check
Alexander Popov [Fri, 16 Dec 2022 23:35:43 +0000 (02:35 +0300)]
Remove the AIO check

Currently GrapheneOS doesn't have it.

16 months agoRemember about the nosmt sysfs control file
Alexander Popov [Sat, 10 Dec 2022 18:25:13 +0000 (21:25 +0300)]
Remember about the nosmt sysfs control file

16 months agoDrop the comment about mitigations of CPU vulnerabilities
Alexander Popov [Sat, 10 Dec 2022 18:24:42 +0000 (21:24 +0300)]
Drop the comment about mitigations of CPU vulnerabilities

The corresponding checks have been developed.

16 months agoSave the list of disabled mitigations of CPU vulnerabilities (for history)
Alexander Popov [Sat, 10 Dec 2022 18:18:34 +0000 (21:18 +0300)]
Save the list of disabled mitigations of CPU vulnerabilities (for history)

16 months agoAdd the nospectre_bhb check
Alexander Popov [Sat, 10 Dec 2022 17:44:23 +0000 (20:44 +0300)]
Add the nospectre_bhb check

16 months agoAdd the kpti check
Alexander Popov [Sat, 10 Dec 2022 08:01:16 +0000 (11:01 +0300)]
Add the kpti check

1. Don't add an exception to normalize_cmdline_options() since strtobool()
is used for kpti

2. Use new '0' check of 'is not off'

16 months agoCompare against '0' in the 'is not off' check
Alexander Popov [Sat, 10 Dec 2022 07:47:05 +0000 (10:47 +0300)]
Compare against '0' in the 'is not off' check

16 months agoAdd the tsx check
Alexander Popov [Sat, 10 Dec 2022 07:08:23 +0000 (10:08 +0300)]
Add the tsx check

16 months agoChange the 'decision' of X86_INTEL_TSX_MODE_OFF check to defconfig
Alexander Popov [Sat, 10 Dec 2022 07:07:10 +0000 (10:07 +0300)]
Change the 'decision' of X86_INTEL_TSX_MODE_OFF check to defconfig

16 months agoAdd the nomte check
Alexander Popov [Sat, 10 Dec 2022 06:33:43 +0000 (09:33 +0300)]
Add the nomte check

16 months agoAdd the nopauth check
Alexander Popov [Sat, 10 Dec 2022 06:32:51 +0000 (09:32 +0300)]
Add the nopauth check

16 months agoAdd the nobti check
Alexander Popov [Sat, 10 Dec 2022 06:32:21 +0000 (09:32 +0300)]
Add the nobti check

16 months agoAdd the sysrq_always_enabled check
Alexander Popov [Fri, 9 Dec 2022 18:00:08 +0000 (21:00 +0300)]
Add the sysrq_always_enabled check

16 months agoAdd the ssbd check
Alexander Popov [Fri, 9 Dec 2022 17:37:49 +0000 (20:37 +0300)]
Add the ssbd check

17 months agoAvoid the YAML parsing mistake
Alexander Popov [Thu, 8 Dec 2022 22:38:05 +0000 (01:38 +0300)]
Avoid the YAML parsing mistake

3.10 is parsed as a number and it is trimmed to 3.1.
That is expected behavior for numbers, but it's crazy for versions.

17 months agoFix `python-version` in the GitHub Actions
Alexander Popov [Thu, 8 Dec 2022 22:29:03 +0000 (01:29 +0300)]
Fix `python-version` in the GitHub Actions

Current `ubuntu-latest` (Ubuntu 22.04 for x86_64) provides the following
versions of Python:
 - 3.10.8
 - 3.11.0
 - 3.7.15
 - 3.8.15
 - 3.9.15

17 months agoReorder some checks, no functional changes
Alexander Popov [Thu, 8 Dec 2022 21:59:38 +0000 (00:59 +0300)]
Reorder some checks, no functional changes

17 months agoAdd the srbds check
Alexander Popov [Thu, 17 Nov 2022 16:39:32 +0000 (19:39 +0300)]
Add the srbds check

17 months agoAdd the retbleed check
Alexander Popov [Thu, 17 Nov 2022 16:29:26 +0000 (19:29 +0300)]
Add the retbleed check

17 months agoAdd the mmio_stale_data check
Alexander Popov [Thu, 17 Nov 2022 16:23:55 +0000 (19:23 +0300)]
Add the mmio_stale_data check

17 months agoAdd the tsx_async_abort check
Alexander Popov [Thu, 17 Nov 2022 16:19:55 +0000 (19:19 +0300)]
Add the tsx_async_abort check

17 months agoAdd the mds check
Alexander Popov [Thu, 17 Nov 2022 14:34:24 +0000 (17:34 +0300)]
Add the mds check

17 months agoAdd the l1tf check
Alexander Popov [Thu, 17 Nov 2022 14:28:28 +0000 (17:28 +0300)]
Add the l1tf check

17 months agoAdd the spectre_v2_user check
Alexander Popov [Thu, 17 Nov 2022 14:19:21 +0000 (17:19 +0300)]
Add the spectre_v2_user check

17 months agoDo refactoring in normalize_cmdline_options()
Alexander Popov [Thu, 17 Nov 2022 13:57:25 +0000 (16:57 +0300)]
Do refactoring in normalize_cmdline_options()

17 months agoAdd the spec_store_bypass_disable check
Alexander Popov [Thu, 17 Nov 2022 13:56:18 +0000 (16:56 +0300)]
Add the spec_store_bypass_disable check

17 months agoAdd the spectre_v2 check
Alexander Popov [Thu, 17 Nov 2022 13:42:30 +0000 (16:42 +0300)]
Add the spectre_v2 check

17 months agoIntroduce the 'is present' check instead of expected=None constructor parameter
Alexander Popov [Thu, 17 Nov 2022 12:23:55 +0000 (15:23 +0300)]
Introduce the 'is present' check instead of expected=None constructor parameter

17 months agoAdd the 'mitigations' check
Alexander Popov [Fri, 11 Nov 2022 14:39:19 +0000 (17:39 +0300)]
Add the 'mitigations' check

The default value for the 'mitigations' option is 'auto'.

So this option should be enabled ('is not off') or not set at all.

17 months agoAdd the nosmt check
Alexander Popov [Wed, 9 Nov 2022 15:32:52 +0000 (18:32 +0300)]
Add the nosmt check

17 months agoAdd a special 'desired val' -- 'is not off'
Alexander Popov [Wed, 9 Nov 2022 15:24:52 +0000 (18:24 +0300)]
Add a special 'desired val' -- 'is not off'

This check gives FAIL if the option value is 'off' or
the option is not found. In other cases this check gives OK.

This feature is needed for checking that the CPU vulnerability mitigations
are not disabled. Let's see how it works and maybe improve it in future.

17 months agoImprove the result descriptions
Alexander Popov [Wed, 9 Nov 2022 14:46:38 +0000 (17:46 +0300)]
Improve the result descriptions

17 months agoAdd assertions to check arguments of the Class constructors
Alexander Popov [Tue, 8 Nov 2022 21:31:16 +0000 (00:31 +0300)]
Add assertions to check arguments of the Class constructors

18 months agoUpdate the README
Alexander Popov [Sun, 23 Oct 2022 17:08:29 +0000 (20:08 +0300)]
Update the README

18 months agoAdd the ARM64_E0PD check
Alexander Popov [Sun, 23 Oct 2022 16:31:16 +0000 (19:31 +0300)]
Add the ARM64_E0PD check

18 months agoFix the SCHED_CORE check: it's now available for ARM64 and ARM
Alexander Popov [Sun, 23 Oct 2022 16:14:46 +0000 (19:14 +0300)]
Fix the SCHED_CORE check: it's now available for ARM64 and ARM

18 months agoUpdate the self-protection checks adopted by KSPP (part V)
Alexander Popov [Sun, 23 Oct 2022 15:23:55 +0000 (18:23 +0300)]
Update the self-protection checks adopted by KSPP (part V)

Thanks to @kees

18 months agoUpdate the self-protection checks adopted by KSPP (part IV): IOMMU
Alexander Popov [Sat, 22 Oct 2022 21:05:45 +0000 (00:05 +0300)]
Update the self-protection checks adopted by KSPP (part IV): IOMMU

Thanks to @kees

18 months agoUpdate the self-protection checks adopted by KSPP (part III)
Alexander Popov [Sat, 22 Oct 2022 21:02:55 +0000 (00:02 +0300)]
Update the self-protection checks adopted by KSPP (part III)

Thanks to @kees

18 months agoUpdate the KSPP recommendations again
Alexander Popov [Sat, 22 Oct 2022 18:34:56 +0000 (21:34 +0300)]
Update the KSPP recommendations again

18 months agoUpdate the self-protection checks adopted by KSPP (part II)
Alexander Popov [Thu, 13 Oct 2022 16:33:11 +0000 (19:33 +0300)]
Update the self-protection checks adopted by KSPP (part II)

Thanks to @kees

18 months agoUpdate the self-protection checks adopted by KSPP (part I)
Alexander Popov [Thu, 13 Oct 2022 15:24:41 +0000 (18:24 +0300)]
Update the self-protection checks adopted by KSPP (part I)

Thanks to @kees

18 months agoUpdate the HW_RANDOM_TPM check
Alexander Popov [Thu, 13 Oct 2022 15:07:14 +0000 (18:07 +0300)]
Update the HW_RANDOM_TPM check

Clip OS says that RANDOM_TRUST_BOOTLOADER and RANDOM_TRUST_CPU should be
disabled if HW_RANDOM_TPM is enabled. The Clip OS description:
  Do not credit entropy included in Linux’s entropy pool when generated
  by the CPU manufacturer’s HWRNG, the bootloader or the UEFI firmware.
  Fast and robust initialization of Linux’s CSPRNG is instead achieved
  thanks to the TPM’s HWRNG.

At the same time KSPP recommends to enable RANDOM_TRUST_BOOTLOADER and
RANDOM_TRUST_CPU anyway:
  Get as much entropy as possible from external sources. The Chacha mixer
  isn't vulnerable to injected entropy, so even malicious sources
  should not cause problems.

In this situation, I think kconfig-hardened-check should check
only HW_RANDOM_TPM (there is no contradiction about it)
and leave the decision about RANDOM_TRUST_BOOTLOADER and
RANDOM_TRUST_CPU to the owner of the system.

18 months agoUpdate the UBSAN checks according to the KSPP recommendations
Alexander Popov [Thu, 13 Oct 2022 14:19:23 +0000 (17:19 +0300)]
Update the UBSAN checks according to the KSPP recommendations

Thanks to @kees

18 months agoUpdate the security policy checks adopted by KSPP
Alexander Popov [Thu, 13 Oct 2022 13:54:02 +0000 (16:54 +0300)]
Update the security policy checks adopted by KSPP

Thanks to @kees

18 months agoUpdate the KSPP recommendations
Alexander Popov [Thu, 13 Oct 2022 13:17:58 +0000 (16:17 +0300)]
Update the KSPP recommendations

18 months agoImprove the README
Alexander Popov [Wed, 12 Oct 2022 18:49:23 +0000 (21:49 +0300)]
Improve the README

18 months agoUpdate the README
Alexander Popov [Sun, 9 Oct 2022 22:10:48 +0000 (01:10 +0300)]
Update the README

18 months agoDrop some of my security policy recommendations
Alexander Popov [Sun, 9 Oct 2022 21:55:21 +0000 (00:55 +0300)]
Drop some of my security policy recommendations

18 months agoCheck SECURITY_SELINUX_DEVELOP (recommended by Clip OS)
Alexander Popov [Sun, 9 Oct 2022 18:31:25 +0000 (21:31 +0300)]
Check SECURITY_SELINUX_DEVELOP (recommended by Clip OS)

Clip OS description: it "will eventually be n".

18 months agoCheck SECURITY_SELINUX_BOOTPARAM (recommended by Clip OS)
Alexander Popov [Sun, 9 Oct 2022 18:25:33 +0000 (21:25 +0300)]
Check SECURITY_SELINUX_BOOTPARAM (recommended by Clip OS)

18 months agoImprove the HW_RANDOM_TPM check
Alexander Popov [Sun, 9 Oct 2022 18:04:19 +0000 (21:04 +0300)]
Improve the HW_RANDOM_TPM check

RANDOM_TRUST_BOOTLOADER and RANDOM_TRUST_CPU should be disabled if
HW_RANDOM_TPM is enabled.

The Clip OS description:
Do not credit entropy included in Linux’s entropy pool when generated
by the CPU manufacturer’s HWRNG, the bootloader or the UEFI firmware.
Fast and robust initialization of Linux’s CSPRNG is instead achieved
thanks to the TPM’s HWRNG.

18 months agoCheck COREDUMP (recommended by Clip OS)
Alexander Popov [Sun, 9 Oct 2022 17:49:58 +0000 (20:49 +0300)]
Check COREDUMP (recommended by Clip OS)

Disabling COREDUMP is needed for cutting userspace attack surface.

18 months agoCheck CONFIG_HW_RANDOM_TPM (recommended by Clip OS)
Alexander Popov [Sun, 9 Oct 2022 12:49:13 +0000 (15:49 +0300)]
Check CONFIG_HW_RANDOM_TPM (recommended by Clip OS)

18 months agoCheck X86_MCE, X86_MCE_INTEL, X86_MCE_AMD (recommended by Clip OS)
Alexander Popov [Sun, 9 Oct 2022 12:32:55 +0000 (15:32 +0300)]
Check X86_MCE, X86_MCE_INTEL, X86_MCE_AMD (recommended by Clip OS)

These options are enabled by default.

18 months agoImprove the README
Alexander Popov [Sun, 9 Oct 2022 11:23:20 +0000 (14:23 +0300)]
Improve the README

19 months agoUpdate the README
Alexander Popov [Wed, 5 Oct 2022 13:56:28 +0000 (16:56 +0300)]
Update the README

19 months agoAlso check 'nospectre_v2' with 'spectre_v2'
Alexander Popov [Sun, 2 Oct 2022 18:45:13 +0000 (21:45 +0300)]
Also check 'nospectre_v2' with 'spectre_v2'

19 months agoChange the reason for the 'nopti' check
Alexander Popov [Sun, 2 Oct 2022 18:44:47 +0000 (21:44 +0300)]
Change the reason for the 'nopti' check

19 months agoChange the reason for the 'nokaslr' check
Alexander Popov [Sun, 2 Oct 2022 17:52:47 +0000 (20:52 +0300)]
Change the reason for the 'nokaslr' check

KASLR is enabled by default.

19 months agoAdd the 'spectre_v2' check
Alexander Popov [Sun, 2 Oct 2022 11:27:03 +0000 (14:27 +0300)]
Add the 'spectre_v2' check

Don't normalize this cmdline option.

19 months agoAdd the 'nospectre_v2' check
Alexander Popov [Sun, 2 Oct 2022 11:23:19 +0000 (14:23 +0300)]
Add the 'nospectre_v2' check

19 months agoChange the reason for the 'nosmep' and 'nosmap' checks
Alexander Popov [Sun, 2 Oct 2022 11:04:10 +0000 (14:04 +0300)]
Change the reason for the 'nosmep' and 'nosmap' checks

SMEP and SMAP are enabled by default.

19 months agoAdd the 'nospectre_v1' check
Alexander Popov [Sun, 2 Oct 2022 10:39:38 +0000 (13:39 +0300)]
Add the 'nospectre_v1' check

19 months agoAdd the 'nopti' check
Alexander Popov [Sun, 2 Oct 2022 10:20:11 +0000 (13:20 +0300)]
Add the 'nopti' check

19 months agoAdd the comments: CC_IS_GCC and CC_IS_CLANG exist since v4.18
Alexander Popov [Sat, 24 Sep 2022 22:12:55 +0000 (01:12 +0300)]
Add the comments: CC_IS_GCC and CC_IS_CLANG exist since v4.18

19 months agoAdd the UBSAN_LOCAL_BOUNDS check for Clang build
Alexander Popov [Sat, 24 Sep 2022 21:51:25 +0000 (00:51 +0300)]
Add the UBSAN_LOCAL_BOUNDS check for Clang build

Explanations from the Linux kernel commit 6a6155f664e31c9be43cd:

When the kernel is compiled with Clang, -fsanitize=bounds expands to
-fsanitize=array-bounds and -fsanitize=local-bounds.

Enabling -fsanitize=local-bounds with Clang has the side-effect of
inserting traps.

That's why UBSAN_LOCAL_BOUNDS can enable the 'local-bounds' option
only when UBSAN_TRAP is enabled.

19 months agoUpdate the links to AOSP and GKI
Alexander Popov [Sun, 18 Sep 2022 13:02:23 +0000 (16:02 +0300)]
Update the links to AOSP and GKI

Android Open Source Project (AOSP):
https://source.android.com/docs/setup/build/building-kernels

Android Generic Kernel Image (GKI):
https://source.android.com/docs/core/architecture/kernel/gki-release-builds

Also add the GKI config `android13-5.10`.

Thanks to @h0t for the idea.

20 months agoUpdate the README
Alexander Popov [Fri, 2 Sep 2022 15:14:28 +0000 (18:14 +0300)]
Update the README

20 months agoDetect the compiler used for the kernel compilation
Alexander Popov [Fri, 2 Sep 2022 15:04:04 +0000 (18:04 +0300)]
Detect the compiler used for the kernel compilation

20 months agoDon't use CONFIG_CC_IS_GCC in the checks (it was introduced only in v4.18)
Alexander Popov [Fri, 2 Sep 2022 14:22:15 +0000 (17:22 +0300)]
Don't use CONFIG_CC_IS_GCC in the checks (it was introduced only in v4.18)

20 months agoMove get-nix-kconfig.py to kconfig_hardened_check/config_files/distros
Alexander Popov [Fri, 2 Sep 2022 11:50:39 +0000 (14:50 +0300)]
Move get-nix-kconfig.py to kconfig_hardened_check/config_files/distros

This script is still waiting for fixes from NixOS folks:
  Issue #63
  PR #64

20 months agoFix the X86_SMAP check: it is enabled by default since v5.19
Alexander Popov [Fri, 2 Sep 2022 11:38:18 +0000 (14:38 +0300)]
Fix the X86_SMAP check: it is enabled by default since v5.19

Refers to the issue #71

20 months agoCheck the nosmap and nosmep cmdline parameters
Alexander Popov [Fri, 2 Sep 2022 11:30:38 +0000 (14:30 +0300)]
Check the nosmap and nosmep cmdline parameters