func AssetLD(rela elf.Rela64, imageOffset map[string]int, imageContent *[]byte, sym elf.Symbol, byteorder binary.ByteOrder)
func FindVDSOEntry(program *ptrace.TracedProgram) (*mapreader.Entry, error)
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 chaos-mesh/chaosd or watchmaker.
type Config struct {
// contains filtered or unexported fields
}
func NewConfig(deltaSeconds int64, deltaNanoSeconds int64, clockIDsMask uint64) Config
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 (c *Config) DeepCopy() tasks.Object
func (c *Config) Merge(a tasks.Mergeable) error
Merge implement how to merge time skew tasks.
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 struct { Logger logr.Logger Config Config PodProcessMap *tasks.PodContainerNameProcessMap }
FakeImage introduce the replacement of VDSO ELF entry and customizable variables. FakeImage could be constructed by LoadFakeImageFromEmbedFs(), and then used by FakeClockInjector.
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 }
func LoadFakeImageFromEmbedFs(filename string, symbolName string, logger logr.Logger) (*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(symbolName string, content []byte, offset map[string]int, logger logr.Logger) *FakeImage
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 (it *FakeImage) FindInjectedImage(program *ptrace.TracedProgram, varNum int) (*mapreader.Entry, error)
FindInjectedImage find injected image to avoid redundant inject.
func (it *FakeImage) InjectFakeImage(program *ptrace.TracedProgram, vdsoEntry *mapreader.Entry) (*mapreader.Entry, error)
InjectFakeImage Usage CheckList: When error : TryReWriteFakeImage after InjectFakeImage.
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 (it *FakeImage) SetVarUint64(program *ptrace.TracedProgram, entry *mapreader.Entry, symbol string, value uint64) error
func (it *FakeImage) TryReWriteFakeImage(program *ptrace.TracedProgram) error
Skew implements ChaosOnProcessGroup. We locked Skew injecting and recovering to avoid conflict.
type Skew struct { SkewConfig Config // contains filtered or unexported fields }
func GetSkew(logger logr.Logger, c Config) (Skew, error)
func (s *Skew) Assign(injectable tasks.Injectable) error
func (s *Skew) Fork() (tasks.ChaosOnProcessGroup, error)
func (s *Skew) Inject(pid tasks.IsID) error
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.