Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
addingsyscalls [2021/11/18 18:39] – Update the 32-bit compat text and example to match the current implementation. Cover paired register padding for non-i386 32-bit targets. BrooksDavisaddingsyscalls [2023/05/19 01:46] (current) – BrooksDavis
Line 5: Line 5:
  
 **WARNING:  Incorrectly implemented system calls may present serious risks to system stability and security.  This document does not address many issues that must be considered when adding any new kernel interface and should not be considered complete.** **WARNING:  Incorrectly implemented system calls may present serious risks to system stability and security.  This document does not address many issues that must be considered when adding any new kernel interface and should not be considered complete.**
 +
 +===== BSDCan 2022 Guide =====
 +Consider watching [[https://www.youtube.com/watch?v=_5LF_0GIpi8&t=439s|So you want to add a system call]] by Brooks Davis for an extensive guide on adding %%FreeBSD%% syscalls in 2022. Much of this material is also presented as a paper at %%AsiaBSDCon%% 2023 {{addingsyscalls/so-you-want-to-add-a-system-call.pdf?linkonly|so-you-want-to-add-a-system-call.pdf}}
  
 ===== Registering a syscall ===== ===== Registering a syscall =====
Line 197: Line 200:
 ===== Committing ===== ===== Committing =====
 Syscalls may be committed in one or two steps.  Historically we have committed them separately as the generated files contained ''%%$FreeBSD%%'' strings from committed files.  This is no longer the case and committing in one or two steps is a matter of personal preference. Syscalls may be committed in one or two steps.  Historically we have committed them separately as the generated files contained ''%%$FreeBSD%%'' strings from committed files.  This is no longer the case and committing in one or two steps is a matter of personal preference.
 +
 +===== syzkaller =====
 +[[https://github.com/google/syzkaller|syzkaller]] is a coverage-guided kernel fuzzer which works primarily by fuzzing the system call interface.  It has found many bugs over the years and is excellent at catching non-trivial bugs, especially in conjunction with kernel sanitizers.  Google maintains a [[https://syzkaller.appspot.com/freebsd|public syzkaller instance]] which regularly pulls the latest %%FreeBSD%% sources, builds them, and tests the result.  Bugs causing a panic are detected and reported to a mailing list.
 +
 +syzkaller's effectiveness is improved when it has semantic knowledge of system call argument types.  It thus implements a DSL, syzlang, for describing system call interfaces (including multiplexed system calls such as ioctl(2) and setsockopt(2%%))%%.  When committing new system calls, it is highly recommended to commit syzlang definitions for the new interfaces to the [[https://github.com/google/syzkaller/tree/master/sys/freebsd|syzkaller repository]].  The existing definitions provide lots of examples to draw from; feel free to ask for help from markj@ or tuexen@.
  
 ===== MFCing ===== ===== MFCing =====
  • addingsyscalls.1637260773.txt.gz
  • Last modified: 2021/11/18 18:39
  • by BrooksDavis