diff options
| author | Space Meyer <spm@google.com> | 2022-11-08 18:03:50 +0000 |
|---|---|---|
| committer | Space Meyer <git@the-space.agency> | 2022-11-09 14:27:51 +0100 |
| commit | bebca8b73c0c4bc5151de9575a4a8a1ea609eb19 (patch) | |
| tree | fc6e277aa612809e4bd7f354fbe437fb9c748d88 /tools | |
| parent | 5fa28208c2c93deee8f0fba4243b8ca0ff802bc3 (diff) | |
syz-kconf: execute shell snippets in reverse loading order
Background:
- syz-kconf loads and overlays config fragments to form a final kernel
config. Fragments are loaded top to bottom as defined in the includes
section of main.yml or your downstream syz-kconf config.
- A config fragment loaded later can override kconf options set by an
earlier loaded fragment. However the override keyword can only be used
if an earlier fragment really did set the same option. Otherweise an
error is raised.
- With this in mind it makes sense to load fragments from broadest scope
to most specific e.g. base -> x86_64 -> chromeos, so that chromeos can
override a setting usually enabled on x86_64 machines.
The Problem:
- Before this change shell snippets were executed in order they were
loaded from the fragments.
- This is unfortunate as the broad fragments like x86_64.yml expect to
operate on an existing .config with their shell snippets. Meanwhile
some downstream distros like icebreaker generate their config using
such a shell snippet.
- Hence ordering the fragments like base -> x86_64 -> icebreaker results
in an error about the x86_64 not finding a .config without this
change. Meanwhile ordering icebreaker -> base -> x86_64 works, but
means the icebreaker fragment can't override x86_64 kconf options.
The Solution:
- This change resolves the problem outlined above by reversing the order
shell snippets are executed. Now shell snippets will be executed
starting with the most recently loaded fragment. This way the proposed
fragment order base -> x86_64 -> icebreaker becomes viable.
- Luckily the shell section isn't heavily used, so this change didn't
result in meaningfull final config changes.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/syz-kconf/parser.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/syz-kconf/parser.go b/tools/syz-kconf/parser.go index 00455c3e5..b2ac82e74 100644 --- a/tools/syz-kconf/parser.go +++ b/tools/syz-kconf/parser.go @@ -197,16 +197,18 @@ func mergeFile(inst *Instance, raw *rawFile, file string, errs *Errors) { } inst.Linker = raw.Linker } + prependShell := []Shell{} for _, node := range raw.Shell { cmd, _, constraints, err := parseNode(node) if err != nil { errs.push("%v:%v: %v", file, node.Line, err) } - inst.Shell = append(inst.Shell, Shell{ + prependShell = append(prependShell, Shell{ Cmd: cmd, Constraints: constraints, }) } + inst.Shell = append(prependShell, inst.Shell...) if raw.Verbatim != "" { inst.Verbatim = append(append(inst.Verbatim, strings.TrimSpace(raw.Verbatim)...), '\n') } |
