time

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetLD

func AssetLD(rela elf.Rela64, imageOffset map[string]int, imageContent *[]byte, sym elf.Symbol, byteorder binary.ByteOrder)

func CalculateOffset

func CalculateOffset(offsetStr string) (time.Duration, error)

func FindVDSOEntry

func FindVDSOEntry(program *ptrace.TracedProgram) (*mapreader.Entry, error)

Types

type Config

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

Config is the summary config of get_time_of_day and clock_get_time. Config here is only for injector of k8s pod. We divide group injector on linux process , pod injector for k8s and the base injector , so we can simply create another config struct just for linux process for watchmaker.

func NewConfig

func NewConfig(deltaSeconds int64, deltaNanoSeconds int64, clockIDsMask uint64) Config

func (*Config) Assign

func (c *Config) Assign(injectable tasks.Injectable) error

Assign assumes the input injectable is *tasks.PodHandler. We also assume the SubProcess of podHandler is *tasks.ProcessGroupHandler and the LeaderProcess of ProcessGroupHandler is *Skew.

func (*Config) DeepCopy

func (c *Config) DeepCopy() tasks.Object

func (*Config) Merge

func (c *Config) Merge(a tasks.Mergeable) error

Merge implement how to merge time skew tasks.

func (*Config) New

func (c *Config) New(values interface{}) (tasks.Injectable, error)

New assumes we get ConfigCreatorParas from values. New will init a struct just like PodHandler(ProcessGroupHandler(Skew))

type ConfigCreatorParas

type ConfigCreatorParas struct {
	Config        Config
	PodProcessMap *tasks.PodContainerNameProcessMap
}

type FakeImage

type FakeImage struct {

	// OriginFuncCode stores the raw func code like getTimeOfDay & ClockGetTime.
	OriginFuncCode []byte
	// OriginAddress stores the origin address of OriginFuncCode.
	OriginAddress uint64
	// contains filtered or unexported fields
}

FakeImage introduce the replacement of VDSO ELF entry and customizable variables. FakeImage could be constructed by LoadFakeImageFromEmbedFs(), and then used by FakeClockInjector.

func LoadFakeImageFromEmbedFs

func LoadFakeImageFromEmbedFs(filename string, symbolName string) (*FakeImage, error)

LoadFakeImageFromEmbedFs builds FakeImage from the embed filesystem. It parses the ELF file and extract the variables from the relocation section, reserves the space for them at the end of content, then calculates and saves offsets as "manually relocation"

func NewFakeImage

func NewFakeImage(symbolName string, content []byte, offset map[string]int) *FakeImage

func (*FakeImage) AttachToProcess

func (it *FakeImage) AttachToProcess(pid int, variables map[string]uint64) (err error)

AttachToProcess would use ptrace to replace the VDSO ELF entry with FakeImage. Each item in parameter "variables" needs a corresponding entry in FakeImage.offset.

func (*FakeImage) FindInjectedImage

func (it *FakeImage) FindInjectedImage(program *ptrace.TracedProgram, varNum int) (*mapreader.Entry, error)

FindInjectedImage find injected image to avoid redundant inject.

func (*FakeImage) InjectFakeImage

func (it *FakeImage) InjectFakeImage(program *ptrace.TracedProgram,
	vdsoEntry *mapreader.Entry) (*mapreader.Entry, error)

InjectFakeImage Usage CheckList: When error : TryReWriteFakeImage after InjectFakeImage.

func (*FakeImage) Recover

func (it *FakeImage) Recover(pid int, vars map[string]uint64) error

Recover the injected image. If injected image not found , Recover will not return error.

func (*FakeImage) SetVarUint64

func (it *FakeImage) SetVarUint64(program *ptrace.TracedProgram, entry *mapreader.Entry, symbol string, value uint64) error

func (*FakeImage) TryReWriteFakeImage

func (it *FakeImage) TryReWriteFakeImage(program *ptrace.TracedProgram) error

type Skew

type Skew struct {
	SkewConfig Config
	// contains filtered or unexported fields
}

Skew implements ProcessGroup. We locked Skew injecting and recovering to avoid conflict.

func GetSkew

func GetSkew(c Config) (Skew, error)

func (*Skew) Assign

func (s *Skew) Assign(injectable tasks.Injectable) error

func (*Skew) Fork

func (s *Skew) Fork() (tasks.ChaosOnProcessGroup, error)

func (*Skew) Inject

func (s *Skew) Inject(pid tasks.IsID) error

func (*Skew) Recover

func (s *Skew) Recover(pid tasks.IsID) error

Recover clock_get_time & get_time_of_day one by one , if error comes from clock_get_time.Recover we will continue recover another fake image and merge errors.

Directories

Path Synopsis
Package dateparse parses date-strings without knowing the format in advance, using a fast lex based approach to eliminate shotgun attempts.
Package dateparse parses date-strings without knowing the format in advance, using a fast lex based approach to eliminate shotgun attempts.

Jump to

Keyboard shortcuts

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