github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/docs/adding_new_os_support.md (about)

     1  # Adding new OS support
     2  
     3  Here are the common parts of syzkaller to edit in order to make syzkaller support a new OS kernel. However, there may be some specific changes that will be required for a given kernel (for example, gathering coverage from a given kernel, or some errors that might pop up and give a hint about what to tweak).
     4  
     5  ## syz-executor
     6  
     7  For each OS, there is this file `executor/executor_GOOS.h` where GOOS is the OS name. This file contains two important functions:
     8  
     9  - `os_init` which is responsible for mapping a virtual address space for the calling process,
    10  - `execute_syscall` which is responsible for executing system calls for a particular OS kernel.
    11  
    12  These two functions, are called in `executor/executor.cc`, which is mainly responsible for executing the syscalls programs, and managing the threads in which the programs run.
    13  
    14  `executor_GOOS.h` also contains functions related to that operating system such as functions that allow it to gather coverage information, detect bitness, etc. (Example: [executor_linux.h](/executor/executor_linux.h) ).
    15  
    16  The intended function will be called according to the target kernel as defined by the macros in the `executor/executor.cc` file.
    17  
    18  ## Build files `pkg/`
    19  
    20  - The OS name is added to `pkg/build/build.go` along with the supported architecture
    21  - Creating a file that builds the image for the targeted kernel under `pkg/build/`. This file contains functions for configuring the build of the bootable image, for building it, and for generate SSH keys which will be used by Syzkaller in order to access the VM. There is a file per each of the supported OSes by Syzkaller where the name pattern is `GOOS.go`.
    22  
    23  - Adding the given target to the `s/makefile/Makefile/`.
    24  
    25  ## Report files `pkg/report/`
    26  
    27  Creating a file that reports build errors  for the targeted kernel under `pkg/report/`. There is a file per each of the supported OSes by Syzkaller where the name pattern is `GOOS.go`.
    28  
    29  ## Editing `pkg/host/`
    30  
    31  - implement `isSupported` function that returns true for a supported syscall, it is located under `pkg/host/GOOS`.
    32  
    33  ## Creating a file under `sys/GOOS/`
    34  
    35  Creating a file `init.go` for the targeted kernel under `sys/GOOS/`that included the function `initTarget` that initializes the target and the different supported architectures.
    36  
    37  ## Editing `sys/syz-extract`
    38  
    39  Adding the new kernel name with already existing supported kernels to the file `sys/syz-extract/extract.go`.
    40  
    41  ## Editing `sys/targets`
    42  
    43  Adding the new kernel name with already existing supported kernels to the file `targets.go` which is located under`sys/targets`.
    44  
    45  ## Editing `vm/qemu`
    46  
    47  Adding the new kernel name with already existing supported kernels to the file `qemo.go` which is located under `vm/qemu`.
    48  
    49  ## Syzkaller description & pseudo-syscalls
    50  
    51  Check [descriptions](/docs/syscall_descriptions.md), and [pseudo-syscalls](/docs/pseudo_syscalls.md).