tpbase

package
v0.0.0-...-b755a7c Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unspec int = iota
	TSDBase
	TSDElementBase
	TSDIndex
	TSDValue
	TSDConstant
)

Variables

This section is empty.

Functions

func AnalyzeAoutDumpDebugregs

func AnalyzeAoutDumpDebugregs(code []byte) (uint32, error)

AnalyzeAoutDumpDebugregs looks at the assembly of the `aout_dump_debugregs` function in the kernel in order to compute the offset of `fsbase` into `task_struct`.

func AnalyzeTLSSetARM64

func AnalyzeTLSSetARM64(code []byte) (uint32, error)

AnalyzeTLSSet looks at the assembly of the `tls_set` function in the kernel in order to compute the offset of `tp_value` into `task_struct`.

func AnalyzeX86fsbaseWriteTask

func AnalyzeX86fsbaseWriteTask(code []byte) (uint32, error)

AnalyzeX86fsbaseWriteTask looks at the assembly of the function x86_fsbase_write_task which is ideal because it only writes the argument to the fsbase function. We can get the fsbase offset directly from the assembly here. Available since kernel version 4.20.

func IsPotentialTSDDSO

func IsPotentialTSDDSO(filename string) bool

IsPotentialTSDDSO determines if the DSO filename potentially contains pthread code

Types

type Analyzer

type Analyzer struct {
	// FunctionName is the kernel function which can be analyzed
	FunctionName string

	// Analyze can inspect the kernel function mentioned above for the Thread Pointer Base
	Analyze func([]byte) (uint32, error)
}

func GetAnalyzers

func GetAnalyzers() []Analyzer

type TSDInfo

type TSDInfo struct {
	// Offset is the pointer difference from "tpbase" pointer to the C-library
	// specific struct pthread's member containing the thread specific data:
	// .tsd (musl) or .specific (glibc).
	// Note: on x86_64 it's positive value, and arm64 it is negative value as
	// "tpbase" register has different purpose and pointer value per platform ABI.
	Offset int16

	// Multiplier is the TSD specific value array element size.
	// Typically 8 bytes on 64bit musl and 16 bytes on 64bit glibc
	Multiplier uint8

	// Indirect is a flag indicating if the "tpbase + Offset" points to a member
	// which is a pointer the array (musl) and not the array itself (glibc).
	Indirect uint8
}

TSDInfo contains information to access C-library's Thread Specific Data from eBPF

func ExtractTSDInfo

func ExtractTSDInfo(ef *pfelf.File) (*TSDInfo, error)

ExtractTSDInfo extracts the introspection data for pthread thread specific data.

func ExtractTSDInfoARM64

func ExtractTSDInfoARM64(code []byte) (TSDInfo, error)

func ExtractTSDInfoNative

func ExtractTSDInfoNative(code []byte) (TSDInfo, error)

func ExtractTSDInfoX64_64

func ExtractTSDInfoX64_64(code []byte) (TSDInfo, error)

Jump to

Keyboard shortcuts

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