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
e2d73214
Commit
e2d73214
authored
Aug 15, 2022
by
Alexander Popov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement the normalization of cmdline options
parent
6a467438
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
__init__.py
kconfig_hardened_check/__init__.py
+22
-0
No files found.
kconfig_hardened_check/__init__.py
View file @
e2d73214
...
...
@@ -654,6 +654,9 @@ def add_cmdline_checks(l, arch):
# [!] Don't add CmdlineChecks in add_kconfig_checks() to avoid wrong results
# when the tool doesn't check the cmdline.
#
# [!] Make sure that values of the options in CmdlineChecks need normalization.
# For more info see normalize_cmdline_options().
#
# A common pattern for checking the 'param_x' cmdline parameter
# that __overrides__ the 'PARAM_X_DEFAULT' kconfig option:
# l += [OR(CmdlineCheck(reason, decision, 'param_x', '1'),
...
...
@@ -851,6 +854,24 @@ def parse_kconfig_file(parsed_options, fname):
parsed_options
[
option
]
=
value
def
normalize_cmdline_options
(
option
,
value
):
# Handle special cases
if
option
==
'pti'
:
# Don't normalize the pti value since
# the Linux kernel doesn't use kstrtobool() for pti.
# See pti_check_boottime_disable() in linux/arch/x86/mm/pti.c
return
value
# Implement a limited part of the kstrtobool() logic
if
value
in
(
'1'
,
'on'
,
'ON'
,
'y'
,
'Y'
):
return
'1'
if
value
in
(
'0'
,
'off'
,
'OFF'
,
'n'
,
'N'
):
return
'0'
# Preserve unique values
return
value
def
parse_cmdline_file
(
parsed_options
,
fname
):
with
open
(
fname
,
'r'
)
as
f
:
line
=
f
.
readline
()
...
...
@@ -866,6 +887,7 @@ def parse_cmdline_file(parsed_options, fname):
else
:
name
=
opt
value
=
''
# '' is not None
value
=
normalize_cmdline_options
(
name
,
value
)
parsed_options
[
name
]
=
value
...
...
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