linux

package
v0.0.0-...-fed3a35 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package linux provides a kernel that wants to separate the running process from the host system.

Index

Constants

View Source
const (
	ELF_AT_NULL = iota
	ELF_AT_IGNORE
	ELF_AT_EXECFD
	ELF_AT_PHDR
	ELF_AT_PHENT
	ELF_AT_PHNUM
	ELF_AT_PAGESZ
	ELF_AT_BASE
	ELF_AT_FLAGS
	ELF_AT_ENTRY
	ELF_AT_NOTELF
	ELF_AT_UID
	ELF_AT_EUID
	ELF_AT_GID
	ELF_AT_EGID
	ELF_AT_PLATFORM
	ELF_AT_HWCAP
	ELF_AT_CLKTCK       = 17
	ELF_AT_RANDOM       = 25
	ELF_AT_SYSINFO      = 32
	ELF_AT_SYSINFO_EHDR = 33
)
View Source
const (
	STACK_BASE = 0xbf800000
	STACK_SIZE = 0x00800000
	// MinusOne represents -1 when interpreted as signed integer.
	// This is often used to indicate an error.
	MinusOne = 0xFFFFFFFFFFFFFFFF
)
View Source
const (
	FUTEX_WAIT            = 0
	FUTEX_WAKE            = 1
	FUTEX_FD              = 2
	FUTEX_REQUEUE         = 3
	FUTEX_CMP_REQUEUE     = 4
	FUTEX_WAKE_OP         = 5
	FUTEX_LOCK_PI         = 6
	FUTEX_UNLOCK_PI       = 7
	FUTEX_TRYLOCK_PI      = 8
	FUTEX_WAIT_BITSET     = 9
	FUTEX_WAKE_BITSET     = 10
	FUTEX_WAIT_REQUEUE_PI = 11
	FUTEX_CMP_REQUEUE_PI  = 12
)
View Source
const (
	FUTEX_PRIVATE_FLAG   = 128
	FUTEX_CLOCK_REALTIME = 256
	FUTEX_CMD_MASK       = ^(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
)
View Source
const (
	// PageSize that the memory must be aligned
	PageSize = 0x1000
)

Variables

View Source
var ENOSYS = 33

Functions

func HandleStat

func HandleStat(buf co.Obuf, stat *LinuxStat64_x86, u models.Usercorn, large bool) uint64

func NewDarwinStat

func NewDarwinStat(stat *LinuxStat64_x86, bits uint, large bool) interface{}

func NewLinuxStat_generic

func NewLinuxStat_generic(stat *LinuxStat64_x86, bits uint, large bool) interface{}

func NewLinuxStat_x86

func NewLinuxStat_x86(stat *LinuxStat64_x86, bits uint, large bool) interface{}

func PackAddrs

func PackAddrs(u models.Usercorn, addrs []uint64) ([]byte, error)

func PushStrings

func PushStrings(u models.Usercorn, args ...string) ([]uint64, error)

func SetupElfAuxv

func SetupElfAuxv(u models.Usercorn) ([]byte, error)

func StackInit

func StackInit(u models.Usercorn, args, env []string) error

func Unpack

func Unpack(k co.Kernel, arg interface{}, vals []interface{}) error

Types

type DarwinStat

type DarwinStat struct {
}

type DarwinStat64

type DarwinStat64 struct {
	Dev   int32  /* [XSI] ID of device containing file */
	Mode  uint16 /* [XSI] Mode of file (see below) */
	Nlink uint16 /* [XSI] Number of hard links */
	Ino   uint64 /* [XSI] File serial number */
	Uid   uint32 /* [XSI] User ID of the file */
	Gid   uint32 /* [XSI] Group ID of the file */
	Rdev  int32  /* [XSI] Device ID */
	Pad0  int32  /* padding to align the embedded structs */

	Atime         int64 /* time of last access */
	AtimeNsec     int64 /* time of last access */
	Mtime         int64 /* time of last data modification */
	MtimeNsec     int64 /* time of last data modification */
	Ctime         int64 /* time of last status change */
	CtimeNsec     int64 /* time of last status change */
	Birthtime     int64 /* time of file creation(birth) */
	BirthtimeNsec int64 /* time of file creation(birth) */

	Size    int64 /* [XSI] file size, in bytes */
	Blkcnt  int64 /* [XSI] blocks allocated for file */
	Blksize int32 /* [XSI] optimal blocksize for I/O */
	// contains filtered or unexported fields
}

type ElfAuxv

type ElfAuxv struct {
	Type, Val uint64 `struc:"size_t"`
}

type File

type File interface {
	io.ReadWriter
	io.Closer
	Stat() (os.FileInfo, error)
	Truncate(int64) error
}

type Iovec32

type Iovec32 struct {
	Base uint32
	Len  uint32
}

type Iovec64

type Iovec64 struct {
	Base uint64
	Len  uint64
}

type Linux32Stat64_x86

type Linux32Stat64_x86 struct {
	Dev  uint64
	Pad0 [4]byte
	Ino  uint32

	Mode     uint32
	Nlink    uint32
	Uid, Gid uint32
	Rdev     uint64
	Pad3     [4]byte

	Size    int64
	Blksize uint32
	Blkcnt  uint64

	Atime     uint32
	AtimeNsec uint32
	Mtime     uint32
	MtimeNsec uint32
	Ctime     uint32
	CtimeNsec uint32

	LongIno uint64
}

type Linux32Stat_x86

type Linux32Stat_x86 struct {
	Dev      uint32
	Ino      uint32
	Mode     uint16
	Nlink    uint16
	Uid, Gid uint32
	Rdev     uint32
	Size     uint32
	Blksize  uint32
	Blkcnt   uint32

	Atime     uint32
	AtimeNsec uint32
	Mtime     uint32
	MtimeNsec uint32
	Ctime     uint32
	CtimeNsec uint32

	Reserved4 uint32
	Reserved5 uint32
}

type LinuxKernel

type LinuxKernel struct {
	*co.KernelBase
	Unpack func(co.Buf, interface{})
	Fs     *ramfs.Filesystem
	Fds    map[co.Fd]File // Open file descriptors
	// contains filtered or unexported fields
}

LinuxKernel is a kernel that isolates processes from the host.

func NewKernel

func NewKernel(fs *ramfs.Filesystem) *LinuxKernel

NewKernel creates a Linux Kernel that is isolated from the operating system.

func (*LinuxKernel) Access

func (k *LinuxKernel) Access(path string, mode uint32) uint64

Access syscall

func (*LinuxKernel) Alarm

func (k *LinuxKernel) Alarm(uint64)

Alarm syscall (not implemented)

func (*LinuxKernel) Brk

func (k *LinuxKernel) Brk(addr uint64) uint64

Brk syscall

func (*LinuxKernel) Close

func (k *LinuxKernel) Close(fd co.Fd) uint64

Close syscall

func (*LinuxKernel) Exit

func (k *LinuxKernel) Exit(code uint64)

Exit sycall

func (*LinuxKernel) ExitGroup

func (k *LinuxKernel) ExitGroup(code uint64)

ExitGroup syscall

func (*LinuxKernel) Fstat

func (k *LinuxKernel) Fstat(fd co.Fd, buf co.Obuf) uint64

Fstat syscall

func (*LinuxKernel) Futex

func (k *LinuxKernel) Futex(uaddr co.Buf, op, val int, timeout, uaddr2 co.Buf, val3 uint64) int

Futex syscall Timeout is a co.Buf here because some forms of futex don't pass it

func (*LinuxKernel) Getrlimit

func (k *LinuxKernel) Getrlimit()

Getrlimit syscall (not implemented)

func (*LinuxKernel) Mmap

func (k *LinuxKernel) Mmap(addrHint, size uint64, prot enum.MmapProt, flags enum.MmapFlag, fd co.Fd, off co.Off) uint64

Mmap syscall

func (*LinuxKernel) Mprotect

func (k *LinuxKernel) Mprotect(addr, size uint64, prot uint64) uint64

Mprotect syscall

func (*LinuxKernel) Open

func (k *LinuxKernel) Open(path string, flags enum.OpenFlag, mode uint64) uint64

Open syscall

func (*LinuxKernel) Read

func (k *LinuxKernel) Read(fd co.Fd, buf co.Obuf, size co.Len) uint64

Read syscall

func (k *LinuxKernel) Readlink(path string, buf co.Obuf, size co.Len) uint64

Readlink syscall

func (*LinuxKernel) RtSigaction

func (k *LinuxKernel) RtSigaction()

RtSigaction syscall (not implemented)

func (*LinuxKernel) RtSigprocmask

func (k *LinuxKernel) RtSigprocmask()

RtSigprocmask syscall (not implemented)

func (*LinuxKernel) SetRobustList

func (k *LinuxKernel) SetRobustList(tid int, head co.Buf)

SetRobustList syscall (not implemented)

func (*LinuxKernel) SetTidAddress

func (k *LinuxKernel) SetTidAddress(tidptr co.Buf) uint64

SetTidAddress syscall (not implemented)

func (*LinuxKernel) Stat

func (k *LinuxKernel) Stat(path string, buf co.Obuf) uint64

Stat syscall

func (*LinuxKernel) StdinOutPort

func (k *LinuxKernel) StdinOutPort(port int) error

StdinOutPort redirects stdin and stout to the connection that connects to the specified port.

func (*LinuxKernel) Ugetrlimit

func (k *LinuxKernel) Ugetrlimit()

Ugetrlimit syscall (not implemented)

func (*LinuxKernel) Uname

func (k *LinuxKernel) Uname(buf co.Buf)

Uname syscall

func (*LinuxKernel) Write

func (k *LinuxKernel) Write(fd co.Fd, buf co.Buf, size co.Len) uint64

Write syscall

func (*LinuxKernel) Writev

func (k *LinuxKernel) Writev(fd co.Fd, iov co.Buf, count uint64) uint64

Writev syscall

type LinuxStat64_x86

type LinuxStat64_x86 struct {
	Dev      uint64
	Ino      uint64
	Nlink    uint64
	Mode     uint32
	Uid, Gid uint32
	Pad0     uint32
	Rdev     uint64
	Size     int64
	Blksize  int64
	Blkcnt   int64

	Atime     uint64
	AtimeNsec uint64
	Mtime     uint64
	MtimeNsec uint64
	Ctime     uint64
	CtimeNsec uint64

	Reserved3 [3]uint64
}

type LinuxStat_generic

type LinuxStat_generic struct {
	Dev uint32
	Ino uint64

	Mode     uint32
	Nlink    uint32
	Uid, Gid uint32
	Rdev     uint32
	Pad0     [4]byte

	Size    int64
	Blksize uint32
	Pad1    [4]byte
	Blkcnt  uint64

	Atime     uint32
	AtimeNsec uint32
	Mtime     uint32
	MtimeNsec uint32
	Ctime     uint32
	CtimeNsec uint32

	Reserved [8]byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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