How to use isSupportedSyscallName method of host Package

Best Syzkaller code snippet using host.isSupportedSyscallName

syscalls_linux.go

Source:syscalls_linux.go Github

copy

Full Screen

...64 return r, v65 }66 return isSupportedTrial(c)67}68func isSupportedSyscallName(name string, target *prog.Target) (bool, string) {69 syscall := target.SyscallMap[name]70 if syscall == nil {71 return false, fmt.Sprintf("sys_%v is not present in the target", name)72 }73 return isSupportedSyscall(syscall, target)74}75func parseKallsyms(kallsyms []byte, arch string) map[string]bool {76 set := make(map[string]bool)77 var re *regexp.Regexp78 switch arch {79 case targets.I386, targets.AMD64:80 re = regexp.MustCompile(` T (__ia32_|__x64_)?sys_([^\n]+)\n`)81 case targets.ARM, targets.ARM64:82 re = regexp.MustCompile(` T (__arm64_)?sys_([^\n]+)\n`)83 case targets.PPC64LE:84 re = regexp.MustCompile(` T ()?sys_([^\n]+)\n`)85 case targets.MIPS64LE:86 re = regexp.MustCompile(` T sys_(mips_)?([^\n]+)\n`)87 case targets.S390x:88 re = regexp.MustCompile(` T (__s390_|__s390x_)?sys_([^\n]+)\n`)89 case targets.RiscV64:90 re = regexp.MustCompile(` T sys_(riscv_)?([^\n]+)\n`)91 default:92 panic("unsupported arch for kallsyms parsing")93 }94 matches := re.FindAllSubmatch(kallsyms, -1)95 for _, m := range matches {96 name := string(m[2])97 set[name] = true98 }99 return set100}101func isSupportedKallsyms(c *prog.Syscall) (bool, string) {102 name := c.CallName103 if newname := kallsymsRenameMap[name]; newname != "" {104 name = newname105 }106 if !kallsymsSyscallSet[name] {107 return false, fmt.Sprintf("sys_%v is not enabled in the kernel (not present in /proc/kallsyms)", name)108 }109 return true, ""110}111func isSupportedTrial(c *prog.Syscall) (bool, string) {112 switch c.CallName {113 // These known to cause hangs.114 case "exit", "pause":115 return true, ""116 }117 reason := fmt.Sprintf("sys_%v is not enabled in the kernel (returns ENOSYS)", c.CallName)118 trialMu.Lock()119 defer trialMu.Unlock()120 if res, ok := trialSupported[c.NR]; ok {121 return res, reason122 }123 cmd := osutil.Command(os.Args[0])124 cmd.Env = []string{fmt.Sprintf("SYZ_TRIAL_TEST=%v", c.NR)}125 _, err := osutil.Run(10*time.Second, cmd)126 res := err != nil127 trialSupported[c.NR] = res128 return res, reason129}130func init() {131 str := os.Getenv("SYZ_TRIAL_TEST")132 if str == "" {133 return134 }135 nr, err := strconv.Atoi(str)136 if err != nil {137 panic(err)138 }139 arg := ^uintptr(0) - 1e4 // something as invalid as possible140 _, _, err = syscall.Syscall6(uintptr(nr), arg, arg, arg, arg, arg, arg)141 if err == syscall.ENOSYS {142 os.Exit(0)143 }144 os.Exit(1)145}146// Some syscall names diverge in __NR_* consts and kallsyms.147// umount2 is renamed to umount in arch/x86/entry/syscalls/syscall_64.tbl.148// Where umount is renamed to oldumount is unclear.149var (150 kallsymsOnce sync.Once151 kallsymsSyscallSet map[string]bool152 kallsymsRenameMap = map[string]string{153 "umount": "oldumount",154 "umount2": "umount",155 "stat": "newstat",156 }157 trialMu sync.Mutex158 trialSupported = make(map[uint64]bool)159 filesystems []byte160 filesystemsOnce sync.Once161 lsmOnce sync.Once162 lsmError error163 lsmDisabled map[string]bool164)165func isSyzUsbSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {166 reason := checkUSBEmulation()167 return reason == "", reason168}169func alwaysSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {170 return true, ""171}172func isNetInjectionSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {173 reason := checkNetInjection()174 return reason == "", reason175}176func isVhciInjectionSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {177 reason := checkVhciInjection()178 return reason == "", reason179}180func isWifiEmulationSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {181 reason := checkWifiEmulation()182 return reason == "", reason183}184func isSyzKvmSetupCPUSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {185 switch c.Name {186 case "syz_kvm_setup_cpu$x86":187 if runtime.GOARCH == targets.AMD64 || runtime.GOARCH == targets.I386 {188 return true, ""189 }190 case "syz_kvm_setup_cpu$arm64":191 if runtime.GOARCH == targets.ARM64 {192 return true, ""193 }194 case "syz_kvm_setup_cpu$ppc64":195 if runtime.GOARCH == targets.PPC64LE {196 return true, ""197 }198 }199 return false, "unsupported arch"200}201func isSyzOpenDevSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {202 return isSupportedSyzOpenDev(sandbox, c)203}204func isSyzInitNetSocketSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {205 if ok, reason := onlySandboxNone(sandbox); !ok {206 return false, reason207 }208 return isSupportedSocket(c)209}210func isSyzGenetlinkGetFamilyIDSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {211 fd, err := syscall.Socket(syscall.AF_NETLINK, syscall.SOCK_RAW, syscall.NETLINK_GENERIC)212 if fd == -1 {213 return false, fmt.Sprintf("socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC) failed: %v", err)214 }215 // TODO: try to obtain actual family ID here. It will disable whole sets of sendmsg syscalls.216 syscall.Close(fd)217 return true, ""218}219func isSyzMountImageSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {220 if ok, reason := onlySandboxNone(sandbox); !ok {221 return ok, reason222 }223 fstype, ok := extractStringConst(c.Args[0].Type)224 if !ok {225 panic("syz_mount_image arg is not string")226 }227 return isSupportedFilesystem(fstype)228}229func isSyzReadPartTableSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {230 return onlySandboxNone(sandbox)231}232func isSyzIoUringSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {233 return isSupportedSyscallName("io_uring_setup", target)234}235func isSyzMemcpySupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {236 ret, msg := isSyzIoUringSupported(c, target, sandbox)237 if ret {238 return ret, msg239 }240 return isSyzKvmSetupCPUSupported(c, target, sandbox)241}242func isBtfVmlinuxSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {243 if err := osutil.IsAccessible("/sys/kernel/btf/vmlinux"); err != nil {244 return false, err.Error()245 }246 return onlySandboxNone(sandbox)247}248func isSyzFuseSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {249 if ok, reason := isSupportedFilesystem("fuse"); !ok {250 return ok, reason251 }252 if ok, reason := onlySandboxNoneOrNamespace(sandbox); !ok {253 return false, reason254 }255 return true, ""256}257func isSyzUsbIPSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {258 if err := osutil.IsWritable("/sys/devices/platform/vhci_hcd.0/attach"); err != nil {259 return false, err.Error()260 }261 return onlySandboxNoneOrNamespace(sandbox)262}263var syzkallSupport = map[string]func(*prog.Syscall, *prog.Target, string) (bool, string){264 "syz_open_dev": isSyzOpenDevSupported,265 "syz_open_procfs": isSyzOpenProcfsSupported,266 "syz_open_pts": alwaysSupported,267 "syz_execute_func": alwaysSupported,268 "syz_emit_ethernet": isNetInjectionSupported,269 "syz_extract_tcp_res": isNetInjectionSupported,270 "syz_usb_connect": isSyzUsbSupported,271 "syz_usb_connect_ath9k": isSyzUsbSupported,272 "syz_usb_disconnect": isSyzUsbSupported,273 "syz_usb_control_io": isSyzUsbSupported,274 "syz_usb_ep_write": isSyzUsbSupported,275 "syz_usb_ep_read": isSyzUsbSupported,276 "syz_kvm_setup_cpu": isSyzKvmSetupCPUSupported,277 "syz_emit_vhci": isVhciInjectionSupported,278 "syz_init_net_socket": isSyzInitNetSocketSupported,279 "syz_genetlink_get_family_id": isSyzGenetlinkGetFamilyIDSupported,280 "syz_mount_image": isSyzMountImageSupported,281 "syz_read_part_table": isSyzReadPartTableSupported,282 "syz_io_uring_submit": isSyzIoUringSupported,283 "syz_io_uring_complete": isSyzIoUringSupported,284 "syz_io_uring_setup": isSyzIoUringSupported,285 "syz_memcpy_off": isSyzMemcpySupported,286 "syz_btf_id_by_name": isBtfVmlinuxSupported,287 "syz_fuse_handle_req": isSyzFuseSupported,288 "syz_80211_inject_frame": isWifiEmulationSupported,289 "syz_80211_join_ibss": isWifiEmulationSupported,290 "syz_usbip_server_init": isSyzUsbIPSupported,291 "syz_clone": alwaysSupported,292 "syz_clone3": alwaysSupported,293}294func isSupportedSyzkall(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {295 sysTarget := targets.Get(target.OS, target.Arch)296 for _, depCall := range sysTarget.PseudoSyscallDeps[c.CallName] {297 if ok, reason := isSupportedSyscallName(depCall, target); !ok {298 return ok, reason299 }300 }301 if strings.HasPrefix(c.CallName, "syz_ext_") {302 // Non-mainline pseudo-syscalls in executor/common_ext.h can't have the checking function303 // and are assumed to be unconditionally supported.304 if syzkallSupport[c.CallName] != nil {305 panic("syz_ext_ prefix is reserved for non-mainline pseudo-syscalls")306 }307 return true, ""308 }309 if isSupported, ok := syzkallSupport[c.CallName]; ok {310 return isSupported(c, target, sandbox)311 }...

Full Screen

Full Screen

isSupportedSyscallName

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(syscall.IsSupportedSyscallName("Read"))4 fmt.Println(syscall.IsSupportedSyscallName("Read1"))5}6Related Posts: Golang | syscall.Getpagesize() method

Full Screen

Full Screen

isSupportedSyscallName

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(host.IsSupportedSyscallName("chdir"))4 fmt.Println(host.IsSupportedSyscallName("chroot"))5 fmt.Println(host.IsSupportedSyscallName("chown"))6 fmt.Println(host.IsSupportedSyscallName("chmod"))

Full Screen

Full Screen

isSupportedSyscallName

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Hello, playground")4}5import (6func isSupportedSyscallName() {7 fmt.Println("Hello, playground")8}9import (10func isSupportedSyscallName() {11 fmt.Println("Hello, playground")12}13import (14func isSupportedSyscallName() {15 fmt.Println("Hello, playground")16}17import (18func isSupportedSyscallName() {19 fmt.Println("Hello, playground")20}21import (22func isSupportedSyscallName() {23 fmt.Println("Hello, playground")24}25import (26func isSupportedSyscallName() {27 fmt.Println("Hello, playground")28}29import (30func isSupportedSyscallName() {31 fmt.Println("Hello, playground")32}33import (34func isSupportedSyscallName() {35 fmt.Println("Hello, playground")36}37import (38func isSupportedSyscallName() {39 fmt.Println("Hello, playground")40}41import (

Full Screen

Full Screen

isSupportedSyscallName

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "syscall/js"3func main() {4 fmt.Println("Hello, playground")5 js.Global().Call("isSupportedSyscallName", "syscall/js")6}7import "fmt"8import "syscall/js"9func main() {10 fmt.Println("Hello, playground")11 js.Global().Call("isSupportedSyscallName", "syscall/js")12}13import "fmt"14import "syscall/js"15func main() {16 fmt.Println("Hello, playground")17 js.Global().Call("isSupportedSyscallName", "syscall/js")18}19import "fmt"20import "syscall/js"21func main() {22 fmt.Println("Hello, playground")23 js.Global().Call("isSupportedSyscallName", "syscall/js")24}25import "fmt"26import "syscall/js"27func main() {28 fmt.Println("Hello, playground")29 js.Global().Call("isSupportedSyscallName", "syscall/js")30}31import "fmt"32import "syscall/js"33func main() {34 fmt.Println("Hello, playground")35 js.Global().Call("isSupportedSyscallName", "syscall/js")36}37import "fmt"38import "syscall/js"39func main() {40 fmt.Println("Hello, playground")41 js.Global().Call("isSupportedSyscallName", "syscall/js")42}43import "fmt"44import "syscall/js"45func main() {46 fmt.Println("Hello, playground")47 js.Global().Call("isSupportedSyscallName", "syscall/js")48}

Full Screen

Full Screen

isSupportedSyscallName

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(host.IsSupportedSyscallName(name))4}5Recommended Posts: Go | Getppid() function6Go | Getpgrp() function7Go | Getpgid() function8Go | Getpwnam() function9Go | Getpwuid() function10Go | Getgrnam() function11Go | Getgrgid() function12Go | Getgroups() function13Go | Getrlimit() function14Go | Getrusage() function15Go | Gettimeofday() function16Go | Getuid() function17Go | Geteuid() function18Go | Getgid() function19Go | Getegid() function20Go | Getpid() function21Go | Getppid() function22Go | Getpgrp() function23Go | Getpgid() function24Go | Getpwnam() function25Go | Getpwuid() function26Go | Getgrnam() function27Go | Getgrgid() function28Go | Getgroups() function29Go | Getrlimit() function30Go | Getrusage() function31Go | Gettimeofday() function32Go | Getuid() function33Go | Geteuid() function34Go | Getgid() function35Go | Getegid() function36Go | Getpid() function37Go | Getppid() function38Go | Getpgrp() function39Go | Getpgid() function40Go | Getpwnam() function41Go | Getpwuid() function42Go | Getgrnam() function43Go | Getgrgid() function44Go | Getgroups() function45Go | Getrlimit() function46Go | Getrusage() function47Go | Gettimeofday() function48Go | Getuid() function49Go | Geteuid() function50Go | Getgid() function51Go | Getegid() function52Go | Getpid() function53Go | Getppid() function54Go | Getpgrp() function55Go | Getpgid() function56Go | Getpwnam() function

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Syzkaller automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful