Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kernel-hardening-checker
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
kernel-hardening-checker
Commits
33c6dcbf
Commit
33c6dcbf
authored
Jan 22, 2022
by
Alexander Popov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Print compactly
parent
5e9f4868
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
__init__.py
kconfig_hardened_check/__init__.py
+18
-18
No files found.
kconfig_hardened_check/__init__.py
View file @
33c6dcbf
...
@@ -109,9 +109,9 @@ class OptCheck:
...
@@ -109,9 +109,9 @@ class OptCheck:
class
KconfigCheck
(
OptCheck
):
class
KconfigCheck
(
OptCheck
):
def
table_print
(
self
,
_mode
,
with_results
):
def
table_print
(
self
,
_mode
,
with_results
):
print
(
'CONFIG_{:<3
8}|{:^13}|{:^10}|{:^20
}'
.
format
(
self
.
name
,
self
.
expected
,
self
.
decision
,
self
.
reason
),
end
=
''
)
print
(
'CONFIG_{:<3
3}|{:^11}|{:^10}|{:^18
}'
.
format
(
self
.
name
,
self
.
expected
,
self
.
decision
,
self
.
reason
),
end
=
''
)
if
with_results
:
if
with_results
:
print
(
'|
{}'
.
format
(
self
.
result
),
end
=
''
)
print
(
'| {}'
.
format
(
self
.
result
),
end
=
''
)
class
VerCheck
:
class
VerCheck
:
...
@@ -135,9 +135,9 @@ class VerCheck:
...
@@ -135,9 +135,9 @@ class VerCheck:
def
table_print
(
self
,
_mode
,
with_results
):
def
table_print
(
self
,
_mode
,
with_results
):
ver_req
=
'kernel version >= '
+
str
(
self
.
ver_expected
[
0
])
+
'.'
+
str
(
self
.
ver_expected
[
1
])
ver_req
=
'kernel version >= '
+
str
(
self
.
ver_expected
[
0
])
+
'.'
+
str
(
self
.
ver_expected
[
1
])
print
(
'{:<
91
}'
.
format
(
ver_req
),
end
=
''
)
print
(
'{:<
82
}'
.
format
(
ver_req
),
end
=
''
)
if
with_results
:
if
with_results
:
print
(
'|
{}'
.
format
(
self
.
result
),
end
=
''
)
print
(
'| {}'
.
format
(
self
.
result
),
end
=
''
)
class
PresenceCheck
:
class
PresenceCheck
:
...
@@ -154,9 +154,9 @@ class PresenceCheck:
...
@@ -154,9 +154,9 @@ class PresenceCheck:
return
True
return
True
def
table_print
(
self
,
_mode
,
with_results
):
def
table_print
(
self
,
_mode
,
with_results
):
print
(
'CONFIG_{:<
84
}'
.
format
(
self
.
name
+
' is present'
),
end
=
''
)
print
(
'CONFIG_{:<
75
}'
.
format
(
self
.
name
+
' is present'
),
end
=
''
)
if
with_results
:
if
with_results
:
print
(
'|
{}'
.
format
(
self
.
result
),
end
=
''
)
print
(
'| {}'
.
format
(
self
.
result
),
end
=
''
)
class
ComplexOptCheck
:
class
ComplexOptCheck
:
...
@@ -186,9 +186,9 @@ class ComplexOptCheck:
...
@@ -186,9 +186,9 @@ class ComplexOptCheck:
def
table_print
(
self
,
mode
,
with_results
):
def
table_print
(
self
,
mode
,
with_results
):
if
mode
==
'verbose'
:
if
mode
==
'verbose'
:
print
(
' {:
87
}'
.
format
(
'<<< '
+
self
.
__class__
.
__name__
+
' >>>'
),
end
=
''
)
print
(
' {:
78
}'
.
format
(
'<<< '
+
self
.
__class__
.
__name__
+
' >>>'
),
end
=
''
)
if
with_results
:
if
with_results
:
print
(
'|
{}'
.
format
(
self
.
result
),
end
=
''
)
print
(
'| {}'
.
format
(
self
.
result
),
end
=
''
)
for
o
in
self
.
opts
:
for
o
in
self
.
opts
:
print
()
print
()
o
.
table_print
(
mode
,
with_results
)
o
.
table_print
(
mode
,
with_results
)
...
@@ -196,7 +196,7 @@ class ComplexOptCheck:
...
@@ -196,7 +196,7 @@ class ComplexOptCheck:
o
=
self
.
opts
[
0
]
o
=
self
.
opts
[
0
]
o
.
table_print
(
mode
,
False
)
o
.
table_print
(
mode
,
False
)
if
with_results
:
if
with_results
:
print
(
'|
{}'
.
format
(
self
.
result
),
end
=
''
)
print
(
'| {}'
.
format
(
self
.
result
),
end
=
''
)
class
OR
(
ComplexOptCheck
):
class
OR
(
ComplexOptCheck
):
...
@@ -583,19 +583,19 @@ def construct_checklist(l, arch):
...
@@ -583,19 +583,19 @@ def construct_checklist(l, arch):
l
+=
[
KconfigCheck
(
'cut_attack_surface'
,
'my'
,
'VIDEO_VIVID'
,
'is not set'
)]
l
+=
[
KconfigCheck
(
'cut_attack_surface'
,
'my'
,
'VIDEO_VIVID'
,
'is not set'
)]
l
+=
[
KconfigCheck
(
'cut_attack_surface'
,
'my'
,
'INPUT_EVBUG'
,
'is not set'
)]
# Can be used as a keylogger
l
+=
[
KconfigCheck
(
'cut_attack_surface'
,
'my'
,
'INPUT_EVBUG'
,
'is not set'
)]
# Can be used as a keylogger
# '
userspace_hardening
'
# '
harden_userspace
'
if
arch
in
(
'X86_64'
,
'ARM64'
,
'X86_32'
):
if
arch
in
(
'X86_64'
,
'ARM64'
,
'X86_32'
):
l
+=
[
KconfigCheck
(
'
userspace_hardening
'
,
'defconfig'
,
'INTEGRITY'
,
'y'
)]
l
+=
[
KconfigCheck
(
'
harden_userspace
'
,
'defconfig'
,
'INTEGRITY'
,
'y'
)]
if
arch
==
'ARM'
:
if
arch
==
'ARM'
:
l
+=
[
KconfigCheck
(
'
userspace_hardening
'
,
'my'
,
'INTEGRITY'
,
'y'
)]
l
+=
[
KconfigCheck
(
'
harden_userspace
'
,
'my'
,
'INTEGRITY'
,
'y'
)]
if
arch
==
'ARM64'
:
if
arch
==
'ARM64'
:
l
+=
[
KconfigCheck
(
'
userspace_hardening
'
,
'defconfig'
,
'ARM64_MTE'
,
'y'
)]
l
+=
[
KconfigCheck
(
'
harden_userspace
'
,
'defconfig'
,
'ARM64_MTE'
,
'y'
)]
if
arch
in
(
'ARM'
,
'X86_32'
):
if
arch
in
(
'ARM'
,
'X86_32'
):
l
+=
[
KconfigCheck
(
'
userspace_hardening
'
,
'defconfig'
,
'VMSPLIT_3G'
,
'y'
)]
l
+=
[
KconfigCheck
(
'
harden_userspace
'
,
'defconfig'
,
'VMSPLIT_3G'
,
'y'
)]
if
arch
in
(
'X86_64'
,
'ARM64'
):
if
arch
in
(
'X86_64'
,
'ARM64'
):
l
+=
[
KconfigCheck
(
'
userspace_hardening
'
,
'clipos'
,
'ARCH_MMAP_RND_BITS'
,
'32'
)]
l
+=
[
KconfigCheck
(
'
harden_userspace
'
,
'clipos'
,
'ARCH_MMAP_RND_BITS'
,
'32'
)]
if
arch
in
(
'X86_32'
,
'ARM'
):
if
arch
in
(
'X86_32'
,
'ARM'
):
l
+=
[
KconfigCheck
(
'
userspace_hardening
'
,
'my'
,
'ARCH_MMAP_RND_BITS'
,
'16'
)]
l
+=
[
KconfigCheck
(
'
harden_userspace
'
,
'my'
,
'ARCH_MMAP_RND_BITS'
,
'16'
)]
# l += [KconfigCheck('feature_test', 'my', 'LKDTM', 'm')] # only for debugging!
# l += [KconfigCheck('feature_test', 'my', 'LKDTM', 'm')] # only for debugging!
...
@@ -630,9 +630,9 @@ def print_checklist(mode, checklist, with_results):
...
@@ -630,9 +630,9 @@ def print_checklist(mode, checklist, with_results):
if
with_results
:
if
with_results
:
sep_line_len
+=
30
sep_line_len
+=
30
print
(
'='
*
sep_line_len
)
print
(
'='
*
sep_line_len
)
print
(
'{:^4
5}|{:^13}|{:^10}|{:^20
}'
.
format
(
'kconfig option name'
,
'desired val'
,
'decision'
,
'reason'
),
end
=
''
)
print
(
'{:^4
0}|{:^11}|{:^10}|{:^18
}'
.
format
(
'kconfig option name'
,
'desired val'
,
'decision'
,
'reason'
),
end
=
''
)
if
with_results
:
if
with_results
:
print
(
'|
{}'
.
format
(
'check result'
),
end
=
''
)
print
(
'| {}'
.
format
(
'check result'
),
end
=
''
)
print
()
print
()
print
(
'='
*
sep_line_len
)
print
(
'='
*
sep_line_len
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment