kfuzztest

package
v0.0.0-...-fb8b2c2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Copyright 2025 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.

Copyright 2025 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 kfuzztest exposes functions discovering KFuzzTest test cases from a vmlinux binary and parsing them into syzkaller-compatible formats. The general flow includes:

  • Creating an Extractor that extracts these test cases from the binary
  • Creating a Builder that takes the extractor's output and returns some compatible encoding of the test cases that were discovered

Copyright 2025 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.

Index

Constants

View Source
const KfuzzTestTargetPrefix string = syzKfuzzTestRun + "$"

Common prefix that all discriminated syz_kfuzztest_run pseudo-syscalls share.

Variables

This section is empty.

Functions

func ActivateKFuzzTargets

func ActivateKFuzzTargets(target *prog.Target, vmlinuxPath string) ([]*prog.Syscall, error)

ActivateKFuzzTargets extracts all KFuzzTest targets from a vmlinux binary and extends a target with the discovered pseudo-syscalls.

func ExtractDescription

func ExtractDescription(vmlinuxPath string) (string, error)

ExtractDescription returns a syzlang description of all discovered KFuzzTest targets, or an error on failure.

func GetInputFilepath

func GetInputFilepath(testName string) string

func GetTestName

func GetTestName(syscall *prog.Syscall) (string, bool)

Types

type AnnotationAttribute

type AnnotationAttribute uint8
const (
	AttributeLen AnnotationAttribute = iota
	AttributeString
	AttributeArray
)

func (AnnotationAttribute) String

func (a AnnotationAttribute) String() string

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(
	funcs []SyzFunc,
	structs []SyzStruct,
	constraints []SyzConstraint,
	annotations []SyzAnnotation,
) *Builder

func (*Builder) AddFunc

func (b *Builder) AddFunc(f SyzFunc)

func (*Builder) AddStruct

func (b *Builder) AddStruct(s SyzStruct)

func (*Builder) EmitSyzlangDescription

func (b *Builder) EmitSyzlangDescription() (string, error)

type ConstraintType

type ConstraintType uint8
const (
	ExpectEq ConstraintType = iota
	ExpectNe
	ExpectLt
	ExpectLe
	ExpectGt
	ExpectGe
	ExpectInRange
)

func (ConstraintType) String

func (c ConstraintType) String() string

type ExtractAllResult

type ExtractAllResult struct {
	VMLinuxPath string
	Funcs       []SyzFunc
	Structs     []SyzStruct
	Constraints []SyzConstraint
	Annotations []SyzAnnotation
}

func (*ExtractAllResult) String

func (e *ExtractAllResult) String() string

type Extractor

type Extractor struct {
	// contains filtered or unexported fields
}

Extractor's job is to extract all information relevant to KFuzzTest from a VMlinux binary.

func NewExtractor

func NewExtractor(vmlinuxPath string) (*Extractor, error)

func (*Extractor) Close

func (e *Extractor) Close()

func (*Extractor) ExtractAll

func (e *Extractor) ExtractAll() (ExtractAllResult, error)

type KFuzzTestData

type KFuzzTestData struct {
	Description string
	Calls       []*prog.Syscall
	Resources   []*prog.ResourceDesc
	Types       []prog.Type
}

func ExtractData

func ExtractData(vmlinuxPath string) (KFuzzTestData, error)

ExtractData extracts KFuzzTest data from a vmlinux binary. The return value of this call is cached so that it can be safely called multiple times without incurring a new scan of a vmlinux image. NOTE: the implementation assumes the existence of only one vmlinux image per process, i.e. no attempt is made to distinguish different vmlinux images based on their path.

type SyzAnnotation

type SyzAnnotation struct {
	InputType       string
	FieldName       string
	LinkedFieldName string
	Attribute       AnnotationAttribute
}

type SyzConstraint

type SyzConstraint struct {
	InputType string
	FieldName string
	Value1    uintptr
	Value2    uintptr
	ConstraintType
}

type SyzField

type SyzField struct {
	Name string
	// contains filtered or unexported fields
}

type SyzFunc

type SyzFunc struct {
	Name            string
	InputStructName string
}

type SyzStruct

type SyzStruct struct {
	Name   string
	Fields []SyzField
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL