github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/docs/syzbot.md (about)

     1  # syzbot
     2  
     3  `syzbot` system continuously fuzzes main Linux kernel branches and automatically
     4  reports found bugs to kernel mailing lists.
     5  [syzbot dashboard](https://syzkaller.appspot.com) shows current statuses of
     6  bugs. All `syzbot`-reported bugs are also CCed to
     7  [syzkaller-bugs mailing list](https://groups.google.com/forum/#!forum/syzkaller-bugs).
     8  Direct all questions to `syzkaller@googlegroups.com`.
     9  
    10  <!-- These anchors are used in external links , don't touch, is there a better syntax for this? -->
    11  <div id="bug-status-tracking"/>
    12  <div id="status"/>
    13  
    14  ## Bug status tracking
    15  
    16  `syzbot` needs to know when a bug is fixed in order to (1) verify that it is
    17  in fact fixed and (2) be able to report other similarly-looking crashes
    18  (while a bug is considered open all similarly-looking crashes are merged into
    19  the existing bug). To understand when a bug is fixed `syzbot` needs to know
    20  what commit fixes the bug; once `syzbot` knows the commit it will track when
    21  the commit reaches all kernel builds on all tracked branches. Only when the
    22  commit reaches all builds, the bug is considered closed (new similarly-looking
    23  crashes create a new bug).
    24  
    25  ## Communication with syzbot
    26  
    27  If you fix a bug reported by `syzbot`, please add the provided `Reported-by`
    28  tag to the commit. You can also communicate with `syzbot` by replying
    29  to its emails. The commands are:
    30  
    31  - to attach a fixing commit to the bug (if you forgot to add `Reported-by` tag):
    32  ```
    33  #syz fix: exact-commit-title
    34  ````
    35  It's enough that the commit is merged into any tree or you are reasonably sure
    36  about its final title, in particular, you don't need to wait for the commit to
    37  be merged into upstream tree. `syzbot` only needs to know the title by which
    38  it will appear in tested trees. In case of an error or a title change, you can
    39  override the commit simply by sending another `#syz fix` command.
    40  - to undo a previous fix command and remove any fixing commits:
    41  ```
    42  #syz unfix
    43  ````
    44  - to mark the bug as a duplicate of another `syzbot` bug:
    45  ```
    46  #syz dup: exact-subject-of-another-report
    47  ```
    48  - to undo a previous dup command and turn it into an independent bug again:
    49  ```
    50  #syz undup
    51  ```
    52  - to mark the bug as a one-off invalid report (e.g. induced by a previous memory corruption):
    53  ```
    54  #syz invalid
    55  ```
    56  **Note**: if the crash happens again, it will cause creation of a new bug report.
    57  
    58  **Note**: all commands must start from beginning of the line.
    59  
    60  **Note**: please keep at least `syzkaller-bugs@googlegroups.com` mailing list in CC.
    61  It serves as a history of what happened with each bug report. Keeping the main kernel
    62  mailing list (e.g. `linux-kernel@vger.kernel.org `) in CC is useful as well so that
    63  it's searchable in those archives as well.
    64  
    65  **Note**: `syzbot` identifies bugs by the `HASH` in the `syzbot+HASH@` receiver email address.
    66  So, strictly saying, you don't need to *reply* to emails (e.g. if you did not receive them),
    67  you can send a new email to the `syzbot+HASH@` email address, which you can find as `Sender`
    68  in email archives or as `Reported-by` email on the dashboard page for each bug.
    69  
    70  <div id="testing-patches"/>
    71  
    72  ## Testing patches
    73  
    74  `syzbot` can test patches for bugs *with reproducers*. This can be used for
    75  testing of fix patches, or just for debugging (i.e. adding additional checks to
    76  code and testing with them), or to check if the bug still happens. To test on
    77  a particular git tree and branch reply with:
    78  ```
    79  #syz test: git://repo/address.git branch
    80  ```
    81  or alternatively, to test on exact commit reply with:
    82  ```
    83  #syz test: git://repo/address.git commit-hash
    84  ```
    85  
    86  You can also completely omit these parameters:
    87  ```
    88  #syz test
    89  ```
    90  
    91  In this case, syzbot will check out the latest commit from the branch where the
    92  issue was detected.
    93  
    94  If you also provide a patch with the email, `syzbot` will apply it on top of the
    95  tree before testing. The patch can be provided inline in email text or as
    96  a text attachment (which is more reliable if your email client messes with
    97  whitespaces).
    98  
    99  If you want to include the patch directly in the email body, just paste the diff
   100  somewhere under the `#syz test` command line, e.g.
   101  
   102  ```
   103  #syz test: git://repo/address.git branch
   104  
   105  --- a/mm/kasan/kasan.c
   106  +++ b/mm/kasan/kasan.c
   107  -       current->kasan_depth++;
   108  +       current->kasan_depth--;
   109  ```
   110  
   111  [Here](https://groups.google.com/g/syzkaller-bugs/search?q=%22%23syz%20test%22) are
   112  some real examples of `#syz test` commands for syzbot-reported bugs.
   113  
   114  If you don't provide a patch, `syzbot` will test the tree as is.
   115  This is useful if this is your own tree which already contains the patch,
   116  or to check if the bug is already fixed by some recent commit.
   117  
   118  After sending an email you should typically get a reply email with results within
   119  an hour.
   120  
   121  **Note**: you may send the request only to `syzbot` email address, as patches sent
   122  to some mailing lists (e.g. netdev, netfilter-devel) will trigger patchwork.
   123  
   124  **Note**: when testing a patch, syzbot uses the newest reproducer and the matching
   125  kernel config that are listed on the dashboard for this bug. As a result, specifying
   126  a repo, branch or commit id that are different from the ones that were used for
   127  reproducing, can result in false-positive Tested-by responses. For example this
   128  happens, when the bug is not reproducible on a specified kernel tree, with or without
   129  the supplied patch.
   130  
   131  **Note**: see [below](#kmsan-bugs) for `KMSAN` bugs testing.
   132  
   133  **Note**: see [below](#usb-bugs) for `USB` bugs testing.
   134  
   135  ## Subsystems
   136  
   137  For all its bugs, `syzbot` automatically assigns kernel subsystems tags. For Linux,
   138  the predefined list of kernel subsystems can be found at
   139  https://syzkaller.appspot.com/upstream/subsystems.
   140  
   141  By clicking on a name in the subsystem list or by following a tag after a bug's
   142  title, you can get the full list of bugs belonging to the subsystem. For example,
   143  all `nfc` bugs are listed here: https://syzkaller.appspot.com/upstream/s/nfc.
   144  
   145  `syzbot` includes subsystem tags into email subject as well, with `?` indicating
   146  that it's an automatic guess: `[syzbot] [ntfs?] kernel BUG in ntfs_iget`.
   147  
   148  Over time, as we improve the classification rules or as syzbot obtains more
   149  information about the bug (e.g. finds a reproducer), `syzbot` will update tags.
   150  
   151  You can also manually override the automatic guess by replying to the `syzbot` email:
   152  
   153  ```
   154  #syz set subsystems: net, mm
   155  ```
   156  
   157  Names of subsystems must be taken from the subsystem list page on the syzbot web
   158  dashboard.
   159  
   160  <div id="labels"/>
   161  
   162  ## Bug labels
   163  
   164  It is possible to assign labels to syzkaller-reported bugs. These labels
   165  are displayed near bug titles on the bug lists and on individual bug pages.
   166  
   167  There are two types of labels:
   168  * Flags
   169    * Send `#syz set <label>` to set the flag.
   170    * Send `#syz unset <label>` to drop the flag.
   171  * Label with values
   172    * Send `#syz set <label>: <value>[, <value2> ...]`  to overwrite the value list.
   173    * `#syz unset <label>` would drop the label with all its values.
   174  
   175  There's a fixed list of supported labels (*). Most important ones:
   176  | Key | Description | Values | Example |
   177  | - | - | - | - |
   178  | `subsystems` | A comma-separated list of subsystems of the bug | See [the list](https://syzkaller.appspot.com/upstream/subsystems) on the syzbot dashboard | `#syz set subsystems: mm, reiserfs` |
   179  | `prio` | The priority of the bug | One of `low`, `normal`, `high` | `#syz set prio: low`<br>`#syz unset prio` |
   180  | `no-reminders` | Don't include the bug into monthly reminders | No values, just a flag |  `#syz set no-reminders`<br>`#syz unset no-reminders` |
   181  
   182  It is also possible to set and unset labels for individual bugs from a monthly
   183  subsystem report. Let's consider an example.
   184  
   185  ```
   186  Some of the still happening issues:
   187  
   188  Ref Crashes Repro Title
   189  <1> 10      No    WARNING in __brelse (2)
   190                    https://syzkaller.appspot.com/bug?id=cd9cb7a620dcfbf46a5eaf201031acaf3aeda28e
   191  <2> 3       No    WARNING in kernfs_get (4)
   192                    https://syzkaller.appspot.com/bug?id=b4278401038872458a20f08210e46f3ab519b786
   193  ```
   194  
   195  One can send the following email to disable reminders for the first bug and to
   196  change the subsystem of the second bug:
   197  
   198  ```
   199  #syz set <1> no-reminders
   200  #syz set <2> subsystems: kernfs
   201  ```
   202  
   203  (*) If you need other labels to facilitate your work, feel free to contact us.
   204  
   205  <div id="amend"/>
   206  <div id="linux-next"/>
   207  
   208  ## Rebuilt trees/amended patches
   209  
   210  There are several additional aspects if the tree is rebuilt/rebased or contains
   211  amended/folded patches (namely, `linux-next`).
   212  
   213  First, adding `Reported-by` tags to amended commits may be misleading.
   214  A `Reported-by` tag suggests that the commit fixes a bug in some previous
   215  commit, but here it's not the case (it only fixes a bug in a previous version
   216  of itself which is not in the tree). In such case it's recommended to include
   217  a `Tested-by` or a `Reviewed-by` tag with the hash instead. Technically,
   218  `syzbot` accepts any tag, so `With-inputs-from` would work too.
   219  
   220  Then, if the guilty commit is completely dropped (actually removed from the
   221  tree during rebuild), then there is effectively no fixing commit. There is no
   222  good way to handle such cases at the moment. One possibility is to mark them
   223  with `#syz invalid`. However this needs to be done only when `syzbot` picks up
   224  the new tree in all builds (current kernel commits can be seen on dashboard).
   225  Otherwise, the occurrences of the crash that are still happening in the current
   226  build will immediately create a new bug report. Another possibility is to mark
   227  it as fixed with some unrelated later commit using
   228  `#syz fix: some-later-commit`. This way `syzbot` will wait until the commit
   229  propagates to all tested trees automatically.
   230  
   231  In any case the relation between the report and the fix can later be fixed up
   232  using `#syz fix: commit-title` commands.
   233  
   234  <div id="bisection"/>
   235  
   236  ## Bisection
   237  
   238  `syzbot` bisects bugs with reproducers to find commit that introduced the bug.
   239  `syzbot` starts with the commit on which the bug was discovered, ensures that it
   240  can reproduce the bug and then goes back release-by-release to find the first
   241  release where kernel does not crash. Once such release is found, `syzbot` starts
   242  bisection on that range. `syzbot` has limitation of how far back in time it can
   243  go (currently `v4.19`), going back in time is [very hard](/pkg/vcs/linux.go)
   244  because of incompatible compiler/linker/asm/perl/make/libc/etc, kernel
   245  build/boot breakages and large amounts of bugs.
   246  
   247  The predicate for bisection is binary (crash/doesn't crash), `syzbot` does not
   248  look at the exact crash and does not try to differentiate them. This is
   249  intentional because lots of bugs can manifest in different ways (sometimes 50+
   250  different ways). For each revision `syzbot` repeats testing 10 times and
   251  a single crash marks revision as bad (lots of bugs are due to races and are
   252  hard to trigger).
   253  
   254  During bisection `syzbot` uses different compilers depending on kernel revision
   255  (a single compiler can't build all revisions). These compilers are available
   256  [here](https://storage.googleapis.com/syzkaller/bisect_bin.tar.gz).
   257  Exact compiler used to test a particular revision is specified in the bisection
   258  log.
   259  
   260  Bisection is best-effort and may not find the right commit for multiple reasons,
   261  including:
   262  
   263  - hard to reproduce bugs that trigger with very low probability
   264  - bug being introduced before the tool that reliably detects it (LOCKDEP, KASAN,
   265    FAULT_INJECTION, WARNING, etc);\
   266    such bugs may be bisection to the addition/improvement of the tool
   267  - kernel build/boot errors that force skipping revisions
   268  - some kernel configs are [disabled](/pkg/vcs/linux.go) as bisection goes back
   269    in time because they build/boot break release tags;\
   270    bugs in these subsystems may be bisected to release tags
   271  - reproducers triggering multiple kernel bugs at once
   272  - unrelated kernel bugs that break even simple programs
   273  
   274  A single incorrect decision during bisection leads to an incorrect result,
   275  so please treat the results with understanding. You may consult the provided
   276  `bisection log` to see how/why `syzbot` has arrived to a particular commit.
   277  Suggestions and patches that improve bisection quality for common cases are
   278  [welcome](https://github.com/google/syzkaller/issues/1051).
   279  
   280  `syzbot` supports cause bisection (find the commit that introduces a bug) and
   281  fix bisection (find the commit that fixes a bug).
   282  
   283  The web UI for a specific kernel
   284  (say [upstream linux](https://syzkaller.appspot.com/upstream)) shows the
   285  `Bisected` status for all bugs.
   286  
   287  <div id="fix-bisection"/>
   288  
   289  ### Fix bisection
   290  `syzbot` will perform fix bisection on bugs that meet the following criterion:
   291  - The kernel tree corresponding to the bug has fix bisection enabled (for
   292  instance, fix bisection might be disabled on kernel trees that have commits
   293  which are force pushed).
   294  - The bug must have a reproducer.
   295  - The bug must not have occurred for at least 30 days. If the bug still occurs
   296  on HEAD upon fix bisection, it will be retried in another 30 days.
   297  
   298  If you receive an email with fix bisection results you think is correct, please
   299  reply with a `#syz fix: commit-title` so that syzbot can close the bug report.
   300  
   301  <div id="syzkaller-reproducers"/>
   302  
   303  ## Running reproducers
   304  
   305  *Detailed instructions on running reproducers can be found [here](/docs/reproducing_crashes.md).*
   306  
   307  `syzbot` aims at providing stand-alone C reproducers for all reported bugs.
   308  However, sometimes it can't extract a reproducer at all, or can only extract a
   309  syzkaller reproducer. syzkaller reproducers are programs in a special syzkaller
   310  notation and they can be executed on the target system with a little bit more
   311  effort.
   312  
   313  A syskaller program can also give you an idea as to what syscalls with what
   314  arguments were executed (note that some calls can actually be executed in
   315  parallel).
   316  
   317  A syzkaller program can be converted to an almost equivalent C source using
   318  `syz-prog2c` utility. `syz-prog2c` has lots of flags in common with
   319  [syz-execprog](/docs/reproducing_crashes.md#from-execution-logs),
   320  e.g. `-threaded` which controls if the syscalls are executed sequentially or
   321  concurrently.
   322  
   323  An example invocation:
   324  
   325  ```
   326  syz-prog2c -prog repro.syz.txt -enable=all -threaded -repeat -procs=8 -sandbox=namespace -segv -tmpdir -waitrepeat
   327  ```
   328  
   329  However, note that if `syzbot` did not provide a C reproducer, it wasn't able to
   330  trigger the bug using the C program (it might also be the case that the bug is
   331  triggered by a rare race condition).
   332  
   333  ## Downloadable assets
   334  
   335  Syzbot shares links to the bootable disk image, kernel object file and other
   336  relevant files that can be used to reproduce and debug the issue locally.
   337  
   338  See [this tutorial](/docs/syzbot_assets.md) on how to use them.
   339  
   340  ## Crash does not reproduce?
   341  
   342  If the provided reproducer does not work for you, most likely it is related to the
   343  fact that you have slightly different setup than `syzbot`. `syzbot` has obtained
   344  the provided crash report on the provided reproducer on a freshly-booted
   345  machine, so the reproducer worked for it somehow.
   346  
   347  Note: if the report contains `userspace arch: i386`,
   348  then the program needs to be built with `-m32` flag.
   349  
   350  `syzbot` uses GCE VMs for testing, but *usually* it is not important.
   351  
   352  If the reproducer exits quickly, try to run it several times, or in a loop.
   353  There can be some races involved.
   354  
   355  Sometimes it might be important to build the kernel using the exact same
   356  compiler that was used by syzbot. Normally that information is included in every
   357  email report, e.g.:
   358  
   359  ```
   360  compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
   361  ```
   362  
   363  The latest compilers used by syzbot are contained in the
   364  `gcr.io/syzkaller/syzbot` docker image. For in-tree kernel build in current
   365  directory it can be used as follows:
   366  
   367  ```
   368  docker pull gcr.io/syzkaller/syzbot
   369  docker run -it --user $(id -u ${USER}):$(id -g ${USER}) \
   370  	--volume "$PWD:/syzkaller/pwd" --workdir /syzkaller/pwd \
   371  	gcr.io/syzkaller/syzbot:latest
   372  make
   373  ```
   374  
   375  For an out-of-tree build one needs to proxy more host directories using `--volume` flag.
   376  
   377  Older compilers used by `syzbot` can be found here:
   378  - [gcc 7.1.1 20170620](https://storage.googleapis.com/syzkaller/gcc-7.tar.gz) (245MB)
   379  - [gcc 8.0.1 20180301](https://storage.googleapis.com/syzkaller/gcc-8.0.1-20180301.tar.gz) (286MB)
   380  - [gcc 8.0.1 20180412](https://storage.googleapis.com/syzkaller/gcc-8.0.1-20180412.tar.gz) (33MB)
   381  - [gcc 9.0.0 20181231](https://storage.googleapis.com/syzkaller/gcc-9.0.0-20181231.tar.gz) (30MB)
   382  - [gcc 10.1.0-syz (20200507)](https://storage.googleapis.com/syzkaller/gcc-10.1.0-syz.tar.xz) (220MB)
   383  - [gcc 10.2.0](https://storage.googleapis.com/syzkaller/gcc-10.2.0.tar.gz) (165MB)
   384  - [clang 7.0.0 (trunk 329060)](https://storage.googleapis.com/syzkaller/clang-kmsan-329060.tar.gz) (44MB)
   385  - [clang 7.0.0 (trunk 334104)](https://storage.googleapis.com/syzkaller/clang-kmsan-334104.tar.gz) (44MB)
   386  - [clang 8.0.0 (trunk 343298)](https://storage.googleapis.com/syzkaller/clang-kmsan-343298.tar.gz) (45MB)
   387  - [clang 10.0.0 (c2443155)](https://storage.googleapis.com/syzkaller/clang_install_c2443155.tar.gz)
   388  - [clang 11.0.0 (git ca2dcbd030e)](https://storage.googleapis.com/syzkaller/clang-11-prerelease-ca2dcbd030e.tar.xz) (682MB)
   389  - [clang 11.0.1](https://github.com/llvm/llvm-project/releases/tag/llvmorg-11.0.1)
   390  
   391  A QEMU-suitable Debian Stretch image can be found
   392  [here](https://storage.googleapis.com/syzkaller/images/stretch-amd64.img.gz) (241 MB).
   393  A reference `qemu` command line to run it is as follows:
   394  ```
   395  qemu-system-x86_64 -smp 2 -m 4G -enable-kvm -cpu host \
   396      -net nic -net user,hostfwd=tcp::10022-:22 \
   397      -kernel arch/x86/boot/bzImage -nographic \
   398      -device virtio-scsi-pci,id=scsi \
   399      -device scsi-hd,bus=scsi.0,drive=d0 \
   400      -drive file=stretch-amd64.img,format=raw,if=none,id=d0 \
   401      -append "root=/dev/sda1 console=ttyS0 earlyprintk=serial"
   402  ```
   403  And then you can ssh into it using:
   404  ```
   405  ssh -p 10022 root@localhost
   406  ```
   407  
   408  Note: before March 25th 2020 Debian Wheezy image was used for testing, so some of the bugs reported before that date
   409  might only be reproducible on Wheezy. That image is [here](https://storage.googleapis.com/syzkaller/wheezy.img)
   410  and the key for it is [here](https://storage.googleapis.com/syzkaller/wheezy.img.key).
   411  
   412  ## No reproducer at all?
   413  
   414  Reproducers are best-effort. `syzbot` always tries to create reproducers, and
   415  once it has one it adds it to the bug. If there is no reproducer referenced in a
   416  bug, a reproducer does not exist. There are multiple reasons why `syzbot` can
   417  fail to create a reproducer: some crashes are caused by subtle races and are
   418  very hard to reproduce in general; some crashes are caused by global accumulated
   419  state in kernel (e.g. lockdep reports); some crashes are caused by
   420  non-reproducible coincidences (e.g. an integer `0x12345` happened to reference an
   421  existing IPC object) and there is long tail of other reasons.
   422  
   423  ## Moderation queue
   424  
   425  Bugs with reproducers are automatically reported to kernel mailing lists.
   426  Bugs without reproducers are first staged in moderation queue to filter out
   427  invalid, unactionable or duplicate reports. Staged bugs are shown on dashboard
   428  in [moderation](https://syzkaller.appspot.com/upstream#moderation2) section
   429  and mailed to
   430  [syzkaller-upstream-moderation](https://groups.google.com/forum/#!forum/syzkaller-upstream-moderation)
   431  mailing list. Staged bugs accept all commands supported for reported bugs
   432  (`fix`, `dup`, `invalid`) with a restriction that bugs reported upstream
   433  can't be `dup`-ed onto bugs in moderation queue. Additionally, staged bugs
   434  accept upstream command:
   435  ```
   436  #syz upstream
   437  ```
   438  which sends the bug to kernel mailing lists.
   439  
   440  ## KMSAN bugs
   441  
   442  `KMSAN` is a dynamic, compiler-based tool (similar to `KASAN`) that detects
   443  uses of uninitialized values. As compared to (now deleted) `KMEMCHECK` which
   444  simply detected loads of non-stored-to memory, `KMSAN` tracks precise
   445  propagation of uninitialized values through memory and registers and only flags
   446  actual eventual uses of uninitialized values. For example, `KMSAN` will detect
   447  a branch on or a `copy_to_user()` of values that transitively come from
   448  uninitialized memory created by heap/stack allocations. This ensures
   449  /theoretical/ absence of both false positives and false negatives (with some
   450  implementation limitations of course). Note that `KMSAN` requires `clang` compiler.
   451  
   452  `KMSAN` is not upstream yet, though, we want to upstream it later. For now,
   453  it lives in [github.com/google/kmsan](https://github.com/google/kmsan) and is
   454  based on a reasonably fresh upstream tree. As the result, any patch testing
   455  requests for `KMSAN` bugs need to go to `KMSAN` tree
   456  (`https://github.com/google/kmsan.git` repo, `master` branch).
   457  A standard way for triggering the test with `KMSAN` tree is to send an
   458  email to `syzbot+HASH` address containing the following line:
   459  ```
   460  #syz test: https://github.com/google/kmsan.git master
   461  ```
   462  and attach/inline your test patch in the same email.
   463  
   464  Report explanation. The first call trace points to the `use` of the uninit value
   465  (which is usually a branching or copying it to userspace). Then there are 0 or
   466  more "Uninit was stored to memory at:" stacks which denote how the unint value
   467  traveled through memory. Finally there is a "Uninit was created at:"
   468  section which points either to a heap allocation or a stack variable which
   469  is the original source of uninitialized-ness.
   470  
   471  ## USB bugs
   472  
   473  syzkaller has an ability to perform fuzzing of the Linux kernel USB stack, see
   474  the details [here](/docs/linux/external_fuzzing_usb.md). As of now all kernel
   475  changes required for USB fuzzing have been merged into the mainline (the last one
   476  during the 5.8-rc1 merge window), so the USB fuzzing instance has been switched
   477  to target the [usb-testing](https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/log/?h=usb-testing) tree.
   478  
   479  Testing kernel patches on the USB instance follows the same principle as on the
   480  mainline instances, with a few caveats:
   481  
   482  1. You may specify any kernel tree for `syz test` as long as it includes all
   483  mainline patches up to 5.8-rc1.
   484  
   485  2. Some of the bugs have reproducers generated on kernel versions with custom
   486  kernel (when fuzzing was performed with non-yet-mainlined kernel patches), thus
   487  those reproducers might no longer work. The recommended workflow is to: first,
   488  execute a `syz test` command on a target tree to make sure that the bug
   489  reproduces, and then execute a `syz test` command with a fix/debug patch.
   490  
   491  If the bug was triggered on the `KMSAN` tree, follow the [instructions above](#kmsan-bugs),
   492  with the exception that you must also use `commit-hash` instead of the `master`
   493  branch when testing patches.
   494  
   495  ## Memory leaks
   496  
   497  `syzbot` uses `KMEMLEAK` to find memory leaks in the Linux kernel.
   498  `KMEMLEAK` kernel config is stored [here](/dashboard/config/linux/upstream-leak.config).
   499  See `KMEMLEAK` [docs](https://www.kernel.org/doc/html/latest/dev-tools/kmemleak.html)
   500  for general info, algorithm overview and usage instructions.
   501  
   502  Memory leaks may be tricky to debug because we have only the allocation stack,
   503  but we don't see where kernel code forgot to free the object or drop a reference.
   504  `KMEMLEAK` can have some false positives on tricky kernel code that hides
   505  pointers to live objects and due to memory scanning non-atomicity.
   506  But don't write off everything to false positives right away, the rate of
   507  false positives is observed to be very low. In particular, `KMEMLEAK` is
   508  [not confused](https://elixir.bootlin.com/linux/v5.2-rc1/source/mm/kmemleak.c#L1426)
   509  by pointers stored in a middle of another object; and it's
   510  [not confused](https://elixir.bootlin.com/linux/v5.2-rc1/source/mm/kmemleak.c#L440)
   511  if several pointer low bits are used as flags because a pointer into
   512  a middle of an object also marks the target as reachable.
   513  
   514  A useful litmus test is to remove `KMEMLEAK` code from the reproducer
   515  and run it for longer and/or multiple times. If memory consumption and number
   516  of live objects in `/proc/slabinfo` steadily grow, most likely the leak is real.
   517  
   518  ## KCSAN bugs
   519  
   520  [The Kernel Concurrency Sanitizer (KCSAN)](https://github.com/google/ktsan/wiki/KCSAN)
   521  is a dynamic data-race detector. Reproduction of data-races is currently
   522  unsupported, and syzbot is unable to test patches.
   523  
   524  ## No custom patches
   525  
   526  While `syzbot` can test patches that fix bugs, it does not support applying
   527  custom patches during fuzzing. It always tests vanilla unmodified git trees.
   528  There are several reasons for this:
   529  
   530  - custom patches may not apply tomorrow
   531  - custom patches may not apply to all of the tested git trees
   532  - it's hard to communicate exact state of the code with bug reports (not just hash anymore)
   533  - line numbers won't match in reports (which always brings suspicion as to the quality of reports)
   534  - custom patches can also introduce bugs, and even if they don't a developer may (rightfully)
   535    question validity of and may not want to spend time on reports obtained
   536    with a number of out-of-tree patches
   537  - order of patch application generally matters, and at some point patches
   538    need to be removed, there is nobody to manage this
   539  
   540  We've experimented with application of custom patches in the past and it lead
   541  to unrecoverable mess. If you want `syzbot` to pick up patches sooner,
   542  ask tree maintainers for priority handling.
   543  
   544  However, syzbot kernel config always includes `CONFIG_DEBUG_AID_FOR_SYZBOT=y` setting,
   545  which is not normally present in kernel. What was used for particularly elusive bugs in the past
   546  is temporary merging some additional debugging code into `linux-next` under this config setting
   547  (e.g. more debug checks and/or debug output) and waiting for new crash reports from syzbot.
   548  
   549  One can also always run syzkaller locally on any kernel for better stress testing
   550  of a particular subsystem and/or patch.
   551  
   552  ## Kernel configs
   553  
   554  Kernel configs, sysctls and command line arguments that `syzbot` uses are available in [/dashboard/config](/dashboard/config).
   555  
   556  ## Is syzbot code available?
   557  
   558  Yes, it is [here](/dashboard/app).