diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-04-16 10:04:45 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-04-24 15:23:14 +0000 |
| commit | 7009aebcd4c978e0f9d7cbb1f45c482104ff3019 (patch) | |
| tree | 23f0df5110b6dc308c48c7d02a321e9f430c3bde /pkg | |
| parent | 4bf1b40dbb879b2f7b28511b0adbd0a1ff16e4a0 (diff) | |
pkg/vminfo: add package
This moves significant part of logic from the target to host (#1541),
eventually this will allow us to switch target code from Go to C++.
Currnetly syz-fuzzer parses a number of system files (/proc/cpuinfo)
in non-trivial ways and passes that info to the host.
This is problematic to recreate in C++.
So instead make the fuzzer part as simple as possible:
now it merely reads the gives set of files and returns contents.
The rest of the parsing happens on the host (the new vminfo package).
Package vminfo extracts information about the target VM.
The package itself runs on the host, which may be a different OS/arch.
User of the package first requests set of files that needs to be fetched from the VM
(Checker.RequiredFiles), then fetches these files, and calls Checker.MachineInfo
to parse the files and extract information about the VM.
The information includes information about kernel modules and OS-specific info
(for Linux that includes things like parsed /proc/cpuinfo).
This also requires changing RPC flow between fuzzer and manager.
Currently, Check call is optional and happens only for first VMs.
With this change Check is always done because we need to return
contents of the requested files always.
The plan is to switch the rest of the pkg/host package to this scheme later:
instead of some complex custom logic, we need to express it as some
simple operations on the target (checking file presence, etc), and the rest
of the logic on the host.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/host/machine_info.go | 82 | ||||
| -rw-r--r-- | pkg/host/machine_info_linux.go | 157 | ||||
| -rw-r--r-- | pkg/host/machine_info_linux_test.go | 383 | ||||
| -rw-r--r-- | pkg/rpctype/rpctype.go | 18 | ||||
| -rw-r--r-- | pkg/vminfo/linux.go | 148 | ||||
| -rw-r--r-- | pkg/vminfo/linux_test.go | 359 | ||||
| -rw-r--r-- | pkg/vminfo/vminfo.go | 130 | ||||
| -rw-r--r-- | pkg/vminfo/vminfo_test.go | 52 |
8 files changed, 745 insertions, 584 deletions
diff --git a/pkg/host/machine_info.go b/pkg/host/machine_info.go index 3c04becab..c32a0cf3b 100644 --- a/pkg/host/machine_info.go +++ b/pkg/host/machine_info.go @@ -4,40 +4,11 @@ package host import ( - "bytes" - "fmt" "os" + "path/filepath" "strings" ) -func CollectMachineInfo() ([]byte, error) { - buf := new(bytes.Buffer) - for _, pair := range machineInfoFuncs { - pos0 := buf.Len() - fmt.Fprintf(buf, "[%s]\n", pair.name) - pos1 := buf.Len() - err := pair.fn(buf) - if err != nil { - if !os.IsNotExist(err) { - return nil, err - } - } - if buf.Len() == pos1 { - buf.Truncate(pos0) - continue - } - fmt.Fprintf(buf, "\n%v\n\n", strings.Repeat("-", 80)) - } - return buf.Bytes(), nil -} - -func CollectModulesInfo() ([]KernelModule, error) { - if machineModulesInfo == nil { - return nil, nil - } - return machineModulesInfo() -} - func CollectGlobsInfo(globs map[string]bool) (map[string][]string, error) { if machineGlobsInfo == nil { return nil, nil @@ -45,17 +16,54 @@ func CollectGlobsInfo(globs map[string]bool) (map[string][]string, error) { return machineGlobsInfo(globs) } -var machineInfoFuncs []machineInfoFunc -var machineModulesInfo func() ([]KernelModule, error) var machineGlobsInfo func(map[string]bool) (map[string][]string, error) -type machineInfoFunc struct { - name string - fn func(*bytes.Buffer) error -} - type KernelModule struct { Name string `json:"Name"` Addr uint64 `json:"Addr"` Size uint64 `json:"Size"` } + +type FileInfo struct { + Name string + Exists bool + Error string + Data []byte +} + +func ReadFiles(files []string) []FileInfo { + var res []FileInfo + for _, glob := range files { + glob = filepath.FromSlash(glob) + if !strings.Contains(glob, "*") { + res = append(res, readFile(glob)) + continue + } + matches, err := filepath.Glob(glob) + if err != nil { + res = append(res, FileInfo{ + Name: glob, + Error: err.Error(), + }) + continue + } + for _, file := range matches { + res = append(res, readFile(file)) + } + } + return res +} + +func readFile(file string) FileInfo { + data, err := os.ReadFile(file) + exists, errStr := true, "" + if err != nil { + exists, errStr = os.IsNotExist(err), err.Error() + } + return FileInfo{ + Name: file, + Exists: exists, + Error: errStr, + Data: data, + } +} diff --git a/pkg/host/machine_info_linux.go b/pkg/host/machine_info_linux.go index 8bb5e8188..fceb3ab78 100644 --- a/pkg/host/machine_info_linux.go +++ b/pkg/host/machine_info_linux.go @@ -4,171 +4,14 @@ package host import ( - "bufio" - "bytes" - "fmt" - "os" "path/filepath" - "regexp" - "strconv" "strings" ) func init() { - machineInfoFuncs = []machineInfoFunc{ - {"CPU Info", readCPUInfo}, - {"KVM", readKVMInfo}, - } - machineModulesInfo = getModulesInfo machineGlobsInfo = getGlobsInfo } -func readCPUInfo(buffer *bytes.Buffer) error { - file, err := os.Open("/proc/cpuinfo") - if err != nil { - return err - } - defer file.Close() - - scanner := bufio.NewScanner(file) - scanCPUInfo(buffer, scanner) - return nil -} - -func scanCPUInfo(buffer *bytes.Buffer, scanner *bufio.Scanner) { - keyIndices := make(map[string]int) - type keyValues struct { - key string - values []string - } - var info []keyValues - - for scanner.Scan() { - splitted := strings.Split(scanner.Text(), ":") - if len(splitted) != 2 { - continue - } - key := strings.TrimSpace(splitted[0]) - val := strings.TrimSpace(splitted[1]) - - if idx, ok := keyIndices[key]; !ok { - idx = len(keyIndices) - keyIndices[key] = idx - info = append(info, keyValues{key, []string{val}}) - } else { - info[idx].values = append(info[idx].values, val) - } - } - - for _, kv := range info { - // It is guaranteed that len(vals) >= 1 - key := kv.key - vals := kv.values - if allEqual(vals) { - fmt.Fprintf(buffer, "%-20s: %s\n", key, vals[0]) - } else { - fmt.Fprintf(buffer, "%-20s: %s\n", key, strings.Join(vals, ", ")) - } - } -} - -func allEqual(slice []string) bool { - if len(slice) == 0 { - return true - } - for i := 1; i < len(slice); i++ { - if slice[i] != slice[0] { - return false - } - } - return true -} - -func readKVMInfo(buffer *bytes.Buffer) error { - files, err := os.ReadDir("/sys/module/") - if err != nil { - return err - } - - for _, file := range files { - name := file.Name() - if !strings.HasPrefix(name, "kvm") { - continue - } - - paramPath := filepath.Join("/sys", "module", name, "parameters") - params, err := os.ReadDir(paramPath) - if err != nil { - if os.IsNotExist(err) { - continue - } - return err - } - - if len(params) == 0 { - continue - } - - fmt.Fprintf(buffer, "/sys/module/%s:\n", name) - for _, key := range params { - keyName := key.Name() - data, err := os.ReadFile(filepath.Join(paramPath, keyName)) - if err != nil { - return err - } - fmt.Fprintf(buffer, "\t%s: ", keyName) - buffer.Write(data) - } - buffer.WriteByte('\n') - } - return nil -} - -func getModuleTextAddr(moduleName string) (uint64, error) { - addrPath := filepath.Join("/sys", "module", moduleName, "sections", ".text") - addrContent, err := os.ReadFile(addrPath) - if err != nil { - return 0, fmt.Errorf("could not read module .text address file: %w", err) - } - addrString := strings.TrimSpace(string(addrContent)) - addr, err := strconv.ParseUint(addrString, 0, 64) - if err != nil { - return 0, fmt.Errorf("address parsing error in %v: %w", moduleName, err) - } - return addr, nil -} - -func getModulesInfo() ([]KernelModule, error) { - var modules []KernelModule - re := regexp.MustCompile(`(\w+) ([0-9]+) .*(0[x|X][a-fA-F0-9]+)[^\n]*`) - modulesText, _ := os.ReadFile("/proc/modules") - for _, m := range re.FindAllSubmatch(modulesText, -1) { - name := string(m[1]) - modAddr, err := strconv.ParseUint(string(m[3]), 0, 64) - if err != nil { - // /proc/modules is broken, bail out. - return nil, fmt.Errorf("address parsing error in /proc/modules: %w", err) - } - textAddr, err := getModuleTextAddr(name) - if err != nil { - // Module address unavailable, .text is probably 0. Skip this module. - continue - } - modSize, err := strconv.ParseUint(string(m[2]), 0, 64) - if err != nil { - // /proc/modules is broken, bail out. - return nil, fmt.Errorf("module size parsing error in /proc/modules: %w", err) - } - offset := modAddr - textAddr - modules = append(modules, KernelModule{ - Name: string(m[1]), - Addr: textAddr, - Size: modSize - offset, - }) - } - return modules, nil -} - func getGlobsInfo(globs map[string]bool) (map[string][]string, error) { var err error files := make(map[string][]string, len(globs)) diff --git a/pkg/host/machine_info_linux_test.go b/pkg/host/machine_info_linux_test.go index 4782a1aac..789f34969 100644 --- a/pkg/host/machine_info_linux_test.go +++ b/pkg/host/machine_info_linux_test.go @@ -4,389 +4,13 @@ package host import ( - "bufio" - "bytes" - "fmt" - "io" "path/filepath" - "runtime" - "strings" "testing" "github.com/google/go-cmp/cmp" "github.com/google/syzkaller/pkg/osutil" - "github.com/google/syzkaller/sys/targets" - "github.com/stretchr/testify/assert" ) -func TestCollectMachineInfo(t *testing.T) { - info, err := CollectMachineInfo() - if err != nil { - t.Fatal(err) - } - t.Logf("machine info:\n%s", info) -} - -func TestReadCPUInfoLinux(t *testing.T) { - buf := new(bytes.Buffer) - if err := readCPUInfo(buf); err != nil { - t.Fatal(err) - } - checkCPUInfo(t, buf.Bytes(), runtime.GOARCH) -} - -func TestCannedCPUInfoLinux(t *testing.T) { - for i, test := range cpuInfoTests { - t.Run(fmt.Sprint(i), func(t *testing.T) { - buf := new(bytes.Buffer) - scanCPUInfo(buf, bufio.NewScanner(strings.NewReader(test.data))) - checkCPUInfo(t, buf.Bytes(), test.arch) - }) - } -} - -func checkCPUInfo(t *testing.T, data []byte, arch string) { - t.Logf("input data:\n%s", data) - keys := make(map[string]bool) - s := longScanner(bytes.NewReader(data)) - for s.Scan() { - splitted := strings.Split(s.Text(), ":") - if len(splitted) != 2 { - t.Fatalf("the format of line %q is not correct", s.Text()) - } - key := strings.TrimSpace(splitted[0]) - keys[key] = true - } - assert.Nil(t, s.Err(), "scanner failed reading the CpuInfo: %v", s.Err()) - - importantKeys := map[string][]string{ - targets.PPC64LE: {"cpu", "revision", "platform", "model", "machine"}, - targets.AMD64: {"vendor_id", "model", "flags"}, - targets.S390x: {"vendor_id", "processor 0", "features"}, - targets.I386: {"vendor_id", "model", "flags"}, - targets.ARM64: {"CPU implementer", "CPU part", "Features"}, - targets.ARM: {"CPU implementer", "CPU part", "Features"}, - targets.MIPS64LE: {"system type", "cpu model", "ASEs implemented"}, - targets.RiscV64: {"processor", "isa", "mmu"}, - } - archKeys := importantKeys[arch] - if len(archKeys) == 0 { - t.Fatalf("unknown arch %v", arch) - } - for _, name := range archKeys { - if !keys[name] { - t.Fatalf("key %q not found", name) - } - } -} - -func TestReadKVMInfoLinux(t *testing.T) { - buf := new(bytes.Buffer) - if err := readKVMInfo(buf); err != nil { - t.Fatal(err) - } - for s := bufio.NewScanner(buf); s.Scan(); { - line := s.Text() - if line == "" { - continue - } - splitted := strings.Split(line, ":") - if len(splitted) != 2 { - t.Fatalf("the format of line \"%s\" is not correct", line) - } - key := strings.TrimSpace(splitted[0]) - if key == "" { - t.Fatalf("empty key") - } - if key[0] != '/' { - continue - } - - if !strings.HasPrefix(key, "/sys/module/kvm") { - t.Fatalf("the directory does not match /sys/module/kvm*") - } - } -} - -func TestScanCPUInfo(t *testing.T) { - input := `A: a -B: b - -C: c1 -D: d -C: c1 -D: d -C: c2 -D: d -` - - output := []struct { - key, val string - }{ - {"A", "a"}, - {"B", "b"}, - {"C", "c1, c1, c2"}, - {"D", "d"}, - } - scanner := bufio.NewScanner(strings.NewReader(input)) - buffer := new(bytes.Buffer) - scanCPUInfo(buffer, scanner) - result := bufio.NewScanner(buffer) - - idx := 0 - for result.Scan() { - line := result.Text() - splitted := strings.Split(line, ":") - if len(splitted) != 2 { - t.Fatalf("the format of line \"%s\" is not correct", line) - } - key := strings.TrimSpace(splitted[0]) - val := strings.TrimSpace(splitted[1]) - if idx >= len(output) { - t.Fatalf("additional line \"%s: %s\"", key, val) - } - expected := output[idx] - if key != expected.key || val != expected.val { - t.Fatalf("expected \"%s: %s\", got \"%s: %s\"", - expected.key, expected.val, key, val) - } - idx++ - } - if idx < len(output) { - expected := output[idx] - t.Fatalf("expected \"%s: %s\", got end of output", - expected.key, expected.val) - } -} - -func TestGetModulesInfo(t *testing.T) { - modules, err := getModulesInfo() - if err != nil { - t.Fatal(err) - } - t.Logf("modules:\n%v", modules) -} - -type cannedTest struct { - arch string - data string -} - -// nolint:lll -var cpuInfoTests = []cannedTest{ - { - arch: targets.PPC64LE, - data: ` -processor : 0 -cpu : POWER8 (architected), altivec supported -clock : 3425.000000MHz -revision : 2.1 (pvr 004b 0201) - -processor : 1 -cpu : POWER8 (architected), altivec supported -clock : 3425.000000MHz -revision : 2.1 (pvr 004b 0201) - -processor : 2 -cpu : POWER8 (architected), altivec supported -clock : 3425.000000MHz -revision : 2.1 (pvr 004b 0201) - -processor : 3 -cpu : POWER8 (architected), altivec supported -clock : 3425.000000MHz -revision : 2.1 (pvr 004b 0201) - -timebase : 512000000 -platform : pSeries -model : IBM pSeries (emulated by qemu) -machine : CHRP IBM pSeries (emulated by qemu) -MMU : Hash -`, - }, - { - arch: targets.PPC64LE, - data: ` -processor : 0 -cpu : POWER8 (architected), altivec supported -clock : 3425.000000MHz -revision : 2.1 (pvr 004b 0201) - -<insert 62 more processors here> - -processor : 63 -cpu : POWER8 (architected), altivec supported -clock : 3425.000000MHz -revision : 2.1 (pvr 004b 0201) - -timebase : 512000000 -platform : pSeries -model : IBM,8247-22L -machine : CHRP IBM,8247-22L -MMU : Hash -`, - }, - { - arch: targets.PPC64LE, - data: ` -processor : 0 -cpu : POWER8E, altivec supported -clock : 3358.000000MHz -revision : 2.1 (pvr 004b 0201) - -processor : 8 -cpu : POWER8E, altivec supported -clock : 3358.000000MHz -revision : 2.1 (pvr 004b 0201) - -processor : 16 -cpu : POWER8E, altivec supported -clock : 3358.000000MHz -revision : 2.1 (pvr 004b 0201) - -processor : 24 -cpu : POWER8E, altivec supported -clock : 3358.000000MHz -revision : 2.1 (pvr 004b 0201) - -processor : 32 -cpu : POWER8E, altivec supported -clock : 3358.000000MHz -revision : 2.1 (pvr 004b 0201) - -processor : 40 -cpu : POWER8E, altivec supported -clock : 3358.000000MHz -revision : 2.1 (pvr 004b 0201) - -timebase : 512000000 -platform : PowerNV -model : 8286-41A -machine : PowerNV 8286-41A -firmware : OPAL -MMU : Hash -`, - }, - { - arch: targets.AMD64, - data: ` -processor : 0 -vendor_id : GenuineIntel -cpu family : 6 -model : 142 -model name : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz -stepping : 10 -microcode : 0xd6 -cpu MHz : 2015.517 -cache size : 8192 KB -physical id : 0 -siblings : 8 -core id : 0 -cpu cores : 4 -apicid : 0 -initial apicid : 0 -fpu : yes -fpu_exception : yes -cpuid level : 22 -wp : yes -flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d -vmx flags : vnmi preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest ple shadow_vmcs pml ept_mode_based_exec -bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit srbds -bogomips : 4199.88 -clflush size : 64 -cache_alignment : 64 -address sizes : 39 bits physical, 48 bits virtual -power management: - -processor : 1 -vendor_id : GenuineIntel -cpu family : 6 -model : 142 -model name : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz -stepping : 10 -microcode : 0xd6 -cpu MHz : 1384.935 -cache size : 8192 KB -physical id : 0 -siblings : 8 -core id : 1 -cpu cores : 4 -apicid : 2 -initial apicid : 2 -fpu : yes -fpu_exception : yes -cpuid level : 22 -wp : yes -flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d -vmx flags : vnmi preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest ple shadow_vmcs pml ept_mode_based_exec -bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit srbds -bogomips : 4199.88 -clflush size : 64 -cache_alignment : 64 -address sizes : 39 bits physical, 48 bits virtual -power management: -`, - }, - { - arch: targets.AMD64, - data: ` -processor : 0 -vendor_id : GenuineIntel -cpu family : 6 -model : 85 -model name : Intel(R) Xeon(R) CPU @ 2.00GHz -stepping : 3 -microcode : 0x1 -cpu MHz : 2000.166 -cache size : 56320 KB -physical id : 0 -siblings : 64 -core id : 0 -cpu cores : 32 -apicid : 0 -initial apicid : 0 -fpu : yes -fpu_exception : yes -cpuid level : 13 -wp : yes -flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves -bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs -bogomips : 4000.33 -clflush size : 64 -cache_alignment : 64 -address sizes : 46 bits physical, 48 bits virtual -power management: - -processor : 1 -vendor_id : GenuineIntel -cpu family : 6 -model : 85 -model name : Intel(R) Xeon(R) CPU @ 2.00GHz -stepping : 3 -microcode : 0x1 -cpu MHz : 2000.166 -cache size : 56320 KB -physical id : 0 -siblings : 64 -core id : 1 -cpu cores : 32 -apicid : 2 -initial apicid : 2 -fpu : yes -fpu_exception : yes -cpuid level : 13 -wp : yes -flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves -bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs -bogomips : 4000.33 -clflush size : 64 -cache_alignment : 64 -address sizes : 46 bits physical, 48 bits virtual -power management: -`, - }, -} - func TestGetGlobsInfo(t *testing.T) { dir := t.TempDir() if err := osutil.MkdirAll(filepath.Join(dir, "a", "b", "c", "d")); err != nil { @@ -418,10 +42,3 @@ func TestGetGlobsInfo(t *testing.T) { t.Fatal(diff) } } - -func longScanner(r io.Reader) *bufio.Scanner { - const newMaxTokenSize = 1 * 1024 * 1024 - s := bufio.NewScanner(r) - s.Buffer(nil, newMaxTokenSize) - return s -} diff --git a/pkg/rpctype/rpctype.go b/pkg/rpctype/rpctype.go index 07a217e05..4fd0014f5 100644 --- a/pkg/rpctype/rpctype.go +++ b/pkg/rpctype/rpctype.go @@ -77,9 +77,7 @@ type ExecTask struct { } type ConnectArgs struct { - Name string - MachineInfo []byte - Modules []host.KernelModule + Name string } type ConnectRes struct { @@ -88,10 +86,9 @@ type ConnectRes struct { TargetRevision string AllSandboxes bool // This is forwarded from CheckArgs, if checking was already done. - Features *host.Features - MemoryLeakFrames []string - DataRaceFrames []string - CoverFilterBitmap []byte + Features *host.Features + // Fuzzer reads these files inside of the VM and returns contents in CheckArgs.Files. + ReadFiles []string } type CheckArgs struct { @@ -101,6 +98,13 @@ type CheckArgs struct { DisabledCalls map[string][]SyscallReason Features *host.Features GlobFiles map[string][]string + Files []host.FileInfo +} + +type CheckRes struct { + MemoryLeakFrames []string + DataRaceFrames []string + CoverFilterBitmap []byte } type SyscallReason struct { diff --git a/pkg/vminfo/linux.go b/pkg/vminfo/linux.go new file mode 100644 index 000000000..c9cd1a3db --- /dev/null +++ b/pkg/vminfo/linux.go @@ -0,0 +1,148 @@ +// Copyright 2024 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package vminfo + +import ( + "bufio" + "bytes" + "fmt" + "io" + "path" + "regexp" + "strconv" + "strings" + + "github.com/google/syzkaller/pkg/host" +) + +type linux int + +func (linux) RequiredFiles() []string { + return []string{ + "/proc/cpuinfo", + "/proc/modules", + "/sys/module/*/sections/.text", + "/sys/module/kvm*/parameters/*", + } +} + +func (linux) machineInfos() []machineInfoFunc { + return []machineInfoFunc{ + linuxReadCPUInfo, + linuxReadKVMInfo, + } +} + +func (linux) parseModules(files filesystem) ([]host.KernelModule, error) { + var modules []host.KernelModule + re := regexp.MustCompile(`(\w+) ([0-9]+) .*(0[x|X][a-fA-F0-9]+)[^\n]*`) + modulesText, _ := files.ReadFile("/proc/modules") + for _, match := range re.FindAllSubmatch(modulesText, -1) { + name := string(match[1]) + modAddr, err := strconv.ParseUint(string(match[3]), 0, 64) + if err != nil { + // /proc/modules is broken, bail out. + return nil, fmt.Errorf("module %v address parsing error: %w", name, err) + } + textAddr, err := linuxModuleTextAddr(files, name) + if err != nil { + // Module address unavailable, .text is probably 0. Skip this module. + continue + } + modSize, err := strconv.ParseUint(string(match[2]), 0, 64) + if err != nil { + // /proc/modules is broken, bail out. + return nil, fmt.Errorf("module %v size parsing error: %w", name, err) + } + offset := modAddr - textAddr + modules = append(modules, host.KernelModule{ + Name: name, + Addr: textAddr, + Size: modSize - offset, + }) + } + return modules, nil +} + +func linuxModuleTextAddr(files filesystem, module string) (uint64, error) { + data, err := files.ReadFile("/sys/module/" + module + "/sections/.text") + if err != nil { + return 0, fmt.Errorf("could not read module %v .text address file: %w", module, err) + } + addrString := strings.TrimSpace(string(data)) + addr, err := strconv.ParseUint(addrString, 0, 64) + if err != nil { + return 0, fmt.Errorf("address parsing error in %v: %w", module, err) + } + return addr, nil +} + +func linuxReadCPUInfo(files filesystem, w io.Writer) (string, error) { + data, err := files.ReadFile("/proc/cpuinfo") + if err != nil { + return "", fmt.Errorf("error reading CPU info:: %w", err) + } + + keyIndices := make(map[string]int) + type keyValues struct { + key string + values []string + } + var info []keyValues + for s := bufio.NewScanner(bytes.NewReader(data)); s.Scan(); { + splitted := strings.Split(s.Text(), ":") + if len(splitted) != 2 { + continue + } + key := strings.TrimSpace(splitted[0]) + val := strings.TrimSpace(splitted[1]) + if idx, ok := keyIndices[key]; !ok { + idx = len(keyIndices) + keyIndices[key] = idx + info = append(info, keyValues{key, []string{val}}) + } else { + info[idx].values = append(info[idx].values, val) + } + } + + for _, kv := range info { + // It is guaranteed that len(vals) >= 1 + key := kv.key + vals := kv.values + if allEqual(vals) { + fmt.Fprintf(w, "%-20s: %s\n", key, vals[0]) + } else { + fmt.Fprintf(w, "%-20s: %s\n", key, strings.Join(vals, ", ")) + } + } + return "CPU Info", nil +} + +func allEqual(slice []string) bool { + for i := 1; i < len(slice); i++ { + if slice[i] != slice[0] { + return false + } + } + return true +} + +func linuxReadKVMInfo(files filesystem, w io.Writer) (string, error) { + for _, module := range files.ReadDir("/sys/module") { + if !strings.HasPrefix(module, "kvm") { + continue + } + paramPath := path.Join("/sys", "module", module, "parameters") + fmt.Fprintf(w, "/sys/module/%s:\n", module) + for _, param := range files.ReadDir(paramPath) { + data, err := files.ReadFile(path.Join(paramPath, param)) + if err != nil { + return "", fmt.Errorf("error reading KVM info: %w", err) + } + fmt.Fprintf(w, "\t%s: %s", param, data) + } + w.Write([]byte{'\n'}) + } + return "KVM", nil +} diff --git a/pkg/vminfo/linux_test.go b/pkg/vminfo/linux_test.go new file mode 100644 index 000000000..bdc018c11 --- /dev/null +++ b/pkg/vminfo/linux_test.go @@ -0,0 +1,359 @@ +// Copyright 2024 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package vminfo + +import ( + "bufio" + "bytes" + "fmt" + "os" + "runtime" + "strings" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/syzkaller/pkg/host" + "github.com/google/syzkaller/sys/targets" + "github.com/stretchr/testify/assert" +) + +func TestReadKVMInfo(t *testing.T) { + if runtime.GOOS != "linux" { + t.Skip("not linux") + } + _, files := hostChecker() + fs := createVirtualFilesystem(files) + buf := new(bytes.Buffer) + if _, err := linuxReadKVMInfo(fs, buf); err != nil { + t.Fatal(err) + } + for s := bufio.NewScanner(buf); s.Scan(); { + line := s.Text() + if line == "" { + continue + } + splitted := strings.Split(line, ":") + if len(splitted) != 2 { + t.Fatalf("the format of line \"%s\" is not correct", line) + } + key := strings.TrimSpace(splitted[0]) + if key == "" { + t.Fatalf("empty key") + } + if key[0] != '/' { + continue + } + + if !strings.HasPrefix(key, "/sys/module/kvm") { + t.Fatalf("the directory does not match /sys/module/kvm*") + } + } +} + +func TestCannedCPUInfoLinux(t *testing.T) { + tests := cpuInfoTests + if runtime.GOOS == "linux" { + data, err := os.ReadFile("/proc/cpuinfo") + if err != nil { + t.Fatal(err) + } + tests = append(tests, cannedTest{ + arch: runtime.GOARCH, + data: string(data), + }) + } + for i, test := range tests { + t.Run(fmt.Sprint(i), func(t *testing.T) { + files := createVirtualFilesystem([]host.FileInfo{{ + Name: "/proc/cpuinfo", + Exists: true, + Data: []byte(test.data), + }}) + buf := new(bytes.Buffer) + if _, err := linuxReadCPUInfo(files, buf); err != nil { + t.Fatal(err) + } + if test.want != "" { + if diff := cmp.Diff(buf.String(), test.want); diff != "" { + t.Fatal(diff) + } + return + } + checkCPUInfo(t, buf.Bytes(), test.arch) + }) + } +} + +func checkCPUInfo(t *testing.T, data []byte, arch string) { + keys := make(map[string]bool) + s := bufio.NewScanner(bytes.NewReader(data)) + s.Buffer(nil, 1<<20) + for s.Scan() { + splitted := strings.Split(s.Text(), ":") + if len(splitted) != 2 { + t.Fatalf("the format of line %q is not correct", s.Text()) + } + key := strings.TrimSpace(splitted[0]) + keys[key] = true + } + assert.Nil(t, s.Err(), "scanner failed reading the CpuInfo: %v", s.Err()) + + importantKeys := map[string][]string{ + targets.PPC64LE: {"cpu", "revision", "platform", "model", "machine"}, + targets.AMD64: {"vendor_id", "model", "flags"}, + targets.S390x: {"vendor_id", "processor 0", "features"}, + targets.I386: {"vendor_id", "model", "flags"}, + targets.ARM64: {"CPU implementer", "CPU part", "Features"}, + targets.ARM: {"CPU implementer", "CPU part", "Features"}, + targets.MIPS64LE: {"system type", "cpu model", "ASEs implemented"}, + targets.RiscV64: {"processor", "isa", "mmu"}, + } + archKeys := importantKeys[arch] + if len(archKeys) == 0 { + t.Fatalf("unknown arch %v", arch) + } + for _, name := range archKeys { + if !keys[name] { + t.Fatalf("key %q not found", name) + } + } +} + +type cannedTest struct { + arch string + data string + want string +} + +// nolint:lll +var cpuInfoTests = []cannedTest{ + { + arch: targets.PPC64LE, + data: ` +processor : 0 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 1 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 2 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 3 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +timebase : 512000000 +platform : pSeries +model : IBM pSeries (emulated by qemu) +machine : CHRP IBM pSeries (emulated by qemu) +MMU : Hash +`, + }, + { + arch: targets.PPC64LE, + data: ` +processor : 0 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +<insert 62 more processors here> + +processor : 63 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +timebase : 512000000 +platform : pSeries +model : IBM,8247-22L +machine : CHRP IBM,8247-22L +MMU : Hash +`, + }, + { + arch: targets.PPC64LE, + data: ` +processor : 0 +cpu : POWER8E, altivec supported +clock : 3358.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 8 +cpu : POWER8E, altivec supported +clock : 3358.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 16 +cpu : POWER8E, altivec supported +clock : 3358.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 24 +cpu : POWER8E, altivec supported +clock : 3358.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 32 +cpu : POWER8E, altivec supported +clock : 3358.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 40 +cpu : POWER8E, altivec supported +clock : 3358.000000MHz +revision : 2.1 (pvr 004b 0201) + +timebase : 512000000 +platform : PowerNV +model : 8286-41A +machine : PowerNV 8286-41A +firmware : OPAL +MMU : Hash +`, + }, + { + arch: targets.AMD64, + data: ` +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 142 +model name : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz +stepping : 10 +microcode : 0xd6 +cpu MHz : 2015.517 +cache size : 8192 KB +physical id : 0 +siblings : 8 +core id : 0 +cpu cores : 4 +apicid : 0 +initial apicid : 0 +fpu : yes +fpu_exception : yes +cpuid level : 22 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d +vmx flags : vnmi preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest ple shadow_vmcs pml ept_mode_based_exec +bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit srbds +bogomips : 4199.88 +clflush size : 64 +cache_alignment : 64 +address sizes : 39 bits physical, 48 bits virtual +power management: + +processor : 1 +vendor_id : GenuineIntel +cpu family : 6 +model : 142 +model name : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz +stepping : 10 +microcode : 0xd6 +cpu MHz : 1384.935 +cache size : 8192 KB +physical id : 0 +siblings : 8 +core id : 1 +cpu cores : 4 +apicid : 2 +initial apicid : 2 +fpu : yes +fpu_exception : yes +cpuid level : 22 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d +vmx flags : vnmi preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest ple shadow_vmcs pml ept_mode_based_exec +bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit srbds +bogomips : 4199.88 +clflush size : 64 +cache_alignment : 64 +address sizes : 39 bits physical, 48 bits virtual +power management: +`, + }, + { + arch: targets.AMD64, + data: ` +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 85 +model name : Intel(R) Xeon(R) CPU @ 2.00GHz +stepping : 3 +microcode : 0x1 +cpu MHz : 2000.166 +cache size : 56320 KB +physical id : 0 +siblings : 64 +core id : 0 +cpu cores : 32 +apicid : 0 +initial apicid : 0 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves +bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs +bogomips : 4000.33 +clflush size : 64 +cache_alignment : 64 +address sizes : 46 bits physical, 48 bits virtual +power management: + +processor : 1 +vendor_id : GenuineIntel +cpu family : 6 +model : 85 +model name : Intel(R) Xeon(R) CPU @ 2.00GHz +stepping : 3 +microcode : 0x1 +cpu MHz : 2000.166 +cache size : 56320 KB +physical id : 0 +siblings : 64 +core id : 1 +cpu cores : 32 +apicid : 2 +initial apicid : 2 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves +bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs +bogomips : 4000.33 +clflush size : 64 +cache_alignment : 64 +address sizes : 46 bits physical, 48 bits virtual +power management: +`, + }, + { + data: `A: a +B: b + +C: c1 +D: d +C: c1 +D: d +C: c2 +D: d +`, + want: `A : a +B : b +C : c1, c1, c2 +D : d +`, + }, +} diff --git a/pkg/vminfo/vminfo.go b/pkg/vminfo/vminfo.go new file mode 100644 index 000000000..2b94cec19 --- /dev/null +++ b/pkg/vminfo/vminfo.go @@ -0,0 +1,130 @@ +// Copyright 2024 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +// Package vminfo extracts information about the target VM. +// The package itself runs on the host, which may be a different OS/arch. +// User of the package first requests set of files that needs to be fetched from the VM +// (Checker.RequiredFiles), then fetches these files, and calls Checker.MachineInfo +// to parse the files and extract information about the VM. +// The information includes information about kernel modules and OS-specific info +// (for Linux that includes things like parsed /proc/cpuinfo). +package vminfo + +import ( + "bytes" + "errors" + "fmt" + "io" + "io/fs" + "os" + "strings" + + "github.com/google/syzkaller/pkg/host" + "github.com/google/syzkaller/pkg/mgrconfig" + "github.com/google/syzkaller/sys/targets" +) + +type Checker struct { + checker +} + +func New(cfg *mgrconfig.Config) *Checker { + switch { + case cfg.TargetOS == targets.Linux: + return &Checker{new(linux)} + default: + return &Checker{new(stub)} + } +} + +func (checker *Checker) MachineInfo(fileInfos []host.FileInfo) ([]host.KernelModule, []byte, error) { + files := createVirtualFilesystem(fileInfos) + modules, err := checker.parseModules(files) + if err != nil { + return nil, nil, err + } + info := new(bytes.Buffer) + tmp := new(bytes.Buffer) + for _, fn := range checker.machineInfos() { + tmp.Reset() + name, err := fn(files, tmp) + if err != nil { + if !os.IsNotExist(err) { + return nil, nil, err + } + continue + } + if tmp.Len() == 0 { + continue + } + fmt.Fprintf(info, "[%v]\n%s\n%v\n\n", name, tmp.Bytes(), strings.Repeat("-", 80)) + } + return modules, info.Bytes(), nil +} + +type machineInfoFunc func(files filesystem, w io.Writer) (string, error) + +type checker interface { + RequiredFiles() []string + parseModules(files filesystem) ([]host.KernelModule, error) + machineInfos() []machineInfoFunc +} + +type filesystem map[string]host.FileInfo + +func createVirtualFilesystem(fileInfos []host.FileInfo) filesystem { + files := make(filesystem) + for _, file := range fileInfos { + if file.Exists { + files[file.Name] = file + } + } + return files +} + +func (files filesystem) ReadFile(name string) ([]byte, error) { + file, ok := files[name] + if !ok { + return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrNotExist} + } + if file.Error != "" { + return nil, errors.New(file.Error) + } + return file.Data, nil +} + +func (files filesystem) ReadDir(dir string) []string { + var res []string + dedup := make(map[string]bool) + for _, file := range files { + if len(file.Name) < len(dir)+2 || + !strings.HasPrefix(file.Name, dir) || + file.Name[len(dir)] != '/' { + continue + } + name := file.Name[len(dir)+1:] + if slash := strings.Index(name, "/"); slash != -1 { + name = name[:slash] + } + if dedup[name] { + continue + } + dedup[name] = true + res = append(res, name) + } + return res +} + +type stub int + +func (stub) RequiredFiles() []string { + return nil +} + +func (stub) parseModules(files filesystem) ([]host.KernelModule, error) { + return nil, nil +} + +func (stub) machineInfos() []machineInfoFunc { + return nil +} diff --git a/pkg/vminfo/vminfo_test.go b/pkg/vminfo/vminfo_test.go new file mode 100644 index 000000000..e4dc1bfb8 --- /dev/null +++ b/pkg/vminfo/vminfo_test.go @@ -0,0 +1,52 @@ +// Copyright 2024 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package vminfo + +import ( + "runtime" + "strings" + "testing" + + "github.com/google/syzkaller/pkg/host" + "github.com/google/syzkaller/pkg/mgrconfig" +) + +func TestHostMachineInfo(t *testing.T) { + checker, files := hostChecker() + dups := make(map[string]bool) + for _, file := range files { + if file.Name[0] != '/' || file.Name[len(file.Name)-1] == '/' || strings.Contains(file.Name, "\\") { + t.Errorf("malformed file %q", file.Name) + } + // Reading duplicate files leads to duplicate work. + if dups[file.Name] { + t.Errorf("duplicate file %q", file.Name) + } + dups[file.Name] = true + if file.Error != "" { + t.Logf("failed to read %q: %s", file.Name, file.Error) + } + } + modules, info, err := checker.MachineInfo(files) + if err != nil { + t.Fatal(err) + } + t.Logf("machine info:\n%s", info) + for _, module := range modules { + t.Logf("module %q: addr 0x%x size %v", module.Name, module.Addr, module.Size) + } +} + +func hostChecker() (*Checker, []host.FileInfo) { + cfg := &mgrconfig.Config{ + Derived: mgrconfig.Derived{ + TargetOS: runtime.GOOS, + TargetArch: runtime.GOARCH, + TargetVMArch: runtime.GOARCH, + }, + } + checker := New(cfg) + files := host.ReadFiles(checker.RequiredFiles()) + return checker, files +} |
