github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/vm/vmimpl/linux.go (about)

     1  // Copyright 2020 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package vmimpl
     5  
     6  import (
     7  	"regexp"
     8  	"strings"
     9  
    10  	"github.com/google/syzkaller/pkg/report"
    11  )
    12  
    13  // DiagnoseLinux diagnoses some Linux kernel bugs over the provided ssh callback.
    14  func DiagnoseLinux(rep *report.Report, ssh func(args ...string) ([]byte, error)) (output []byte, wait, handled bool) {
    15  	if !strings.Contains(rep.Title, "MAX_LOCKDEP") {
    16  		return nil, false, false
    17  	}
    18  	// Dump /proc/lockdep* files on BUG: MAX_LOCKDEP_{KEYS,ENTRIES,CHAINS,CHAIN_HLOCKS} too low!
    19  	output, err := ssh("cat", "/proc/lockdep_stats", "/proc/lockdep", "/proc/lockdep_chains")
    20  	if err != nil {
    21  		output = append(output, err.Error()...)
    22  	}
    23  	// Remove mangled pointer values, they take lots of space but don't add any value.
    24  	output = regexp.MustCompile(` *\[?[0-9a-f]{8,}\]?\s*`).ReplaceAll(output, nil)
    25  	return output, false, true
    26  }