github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/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  ## syzkaller reproducers
   304  
   305  `syzbot` aims at providing stand-alone C reproducers for all reported bugs.
   306  However, sometimes it can't extract a reproducer at all, or can only extract a
   307  syzkaller reproducer. syzkaller reproducers are programs in a special syzkaller
   308  notation and they can be executed on the target system with a little bit more
   309  effort. See [this](/docs/executing_syzkaller_programs.md) for instructions.
   310  
   311  A syskaller program can also give you an idea as to what syscalls with what
   312  arguments were executed (note that some calls can actually be executed in
   313  parallel).
   314  
   315  A syzkaller program can be converted to an almost equivalent C source using `syz-prog2c` utility. `syz-prog2c`
   316  has lots of flags in common with [syz-execprog](/docs/executing_syzkaller_programs.md),
   317  e.g. `-threaded` which controls if the syscalls are executed sequentially or in parallel.
   318  An example invocation:
   319  
   320  ```
   321  syz-prog2c -prog repro.syz.txt -enable=all -threaded -repeat -procs=8 -sandbox=namespace -segv -tmpdir -waitrepeat
   322  ```
   323  
   324  However, note that if `syzbot` did not provide a C reproducer, it wasn't able to trigger the bug using the C program (though, it can be just because the bug is triggered by a subtle race condition).
   325  
   326  ## Downloadable assets
   327  
   328  Syzbot shares links to the bootable disk image, kernel object file and other
   329  relevant files that can be used to reproduce and debug the issue locally.
   330  
   331  See [this tutorial](/docs/syzbot_assets.md) on how to use them.
   332  
   333  ## Crash does not reproduce?
   334  
   335  If the provided reproducer does not work for you, most likely it is related to the
   336  fact that you have slightly different setup than `syzbot`. `syzbot` has obtained
   337  the provided crash report on the provided reproducer on a freshly-booted
   338  machine, so the reproducer worked for it somehow.
   339  
   340  Note: if the report contains `userspace arch: i386`,
   341  then the program needs to be built with `-m32` flag.
   342  
   343  `syzbot` uses GCE VMs for testing, but *usually* it is not important.
   344  
   345  If the reproducer exits quickly, try to run it several times, or in a loop.
   346  There can be some races involved.
   347  
   348  Latest compiler used by syzbot is contained in `gcr.io/syzkaller/syzbot:gcc-10.2.1` docker image.
   349  For in-tree kernel build in current directory it can be used as follows:
   350  
   351  ```
   352  docker pull gcr.io/syzkaller/syzbot:gcc-10.2.1
   353  docker run -it --user $(id -u ${USER}):$(id -g ${USER}) \
   354  	--volume "$PWD:/syzkaller/pwd" --workdir /syzkaller/pwd \
   355  	gcr.io/syzkaller/syzbot:gcc-10.2.1
   356  make
   357  ```
   358  
   359  For an out-of-tree build one needs to proxy more host directories using `--volume` flag.
   360  
   361  Older compilers used by `syzbot` can be found here:
   362  - [gcc 7.1.1 20170620](https://storage.googleapis.com/syzkaller/gcc-7.tar.gz) (245MB)
   363  - [gcc 8.0.1 20180301](https://storage.googleapis.com/syzkaller/gcc-8.0.1-20180301.tar.gz) (286MB)
   364  - [gcc 8.0.1 20180412](https://storage.googleapis.com/syzkaller/gcc-8.0.1-20180412.tar.gz) (33MB)
   365  - [gcc 9.0.0 20181231](https://storage.googleapis.com/syzkaller/gcc-9.0.0-20181231.tar.gz) (30MB)
   366  - [gcc 10.1.0-syz (20200507)](https://storage.googleapis.com/syzkaller/gcc-10.1.0-syz.tar.xz) (220MB)
   367  - [gcc 10.2.0](https://storage.googleapis.com/syzkaller/gcc-10.2.0.tar.gz) (165MB)
   368  - [clang 7.0.0 (trunk 329060)](https://storage.googleapis.com/syzkaller/clang-kmsan-329060.tar.gz) (44MB)
   369  - [clang 7.0.0 (trunk 334104)](https://storage.googleapis.com/syzkaller/clang-kmsan-334104.tar.gz) (44MB)
   370  - [clang 8.0.0 (trunk 343298)](https://storage.googleapis.com/syzkaller/clang-kmsan-343298.tar.gz) (45MB)
   371  - [clang 10.0.0 (c2443155)](https://storage.googleapis.com/syzkaller/clang_install_c2443155.tar.gz)
   372  - [clang 11.0.0 (git ca2dcbd030e)](https://storage.googleapis.com/syzkaller/clang-11-prerelease-ca2dcbd030e.tar.xz) (682MB)
   373  - [clang 11.0.1](https://github.com/llvm/llvm-project/releases/tag/llvmorg-11.0.1)
   374  
   375  A QEMU-suitable Debian Stretch image can be found
   376  [here](https://storage.googleapis.com/syzkaller/images/stretch-amd64.img.gz) (241 MB).
   377  A reference `qemu` command line to run it is as follows:
   378  ```
   379  qemu-system-x86_64 -smp 2 -m 4G -enable-kvm -cpu host \
   380      -net nic -net user,hostfwd=tcp::10022-:22 \
   381      -kernel arch/x86/boot/bzImage -nographic \
   382      -device virtio-scsi-pci,id=scsi \
   383      -device scsi-hd,bus=scsi.0,drive=d0 \
   384      -drive file=stretch-amd64.img,format=raw,if=none,id=d0 \
   385      -append "root=/dev/sda1 console=ttyS0 earlyprintk=serial"
   386  ```
   387  And then you can ssh into it using:
   388  ```
   389  ssh -p 10022 root@localhost
   390  ```
   391  
   392  Note: before March 25th 2020 Debian Wheezy image was used for testing, so some of the bugs reported before that date
   393  might only be reproducible on Wheezy. That image is [here](https://storage.googleapis.com/syzkaller/wheezy.img)
   394  and the key for it is [here](https://storage.googleapis.com/syzkaller/wheezy.img.key).
   395  
   396  ## No reproducer at all?
   397  
   398  Reproducers are best-effort. `syzbot` always tries to create reproducers, and
   399  once it has one it adds it to the bug. If there is no reproducer referenced in a
   400  bug, a reproducer does not exist. There are multiple reasons why `syzbot` can
   401  fail to create a reproducer: some crashes are caused by subtle races and are
   402  very hard to reproduce in general; some crashes are caused by global accumulated
   403  state in kernel (e.g. lockdep reports); some crashes are caused by
   404  non-reproducible coincidences (e.g. an integer `0x12345` happened to reference an
   405  existing IPC object) and there is long tail of other reasons.
   406  
   407  ## Moderation queue
   408  
   409  Bugs with reproducers are automatically reported to kernel mailing lists.
   410  Bugs without reproducers are first staged in moderation queue to filter out
   411  invalid, unactionable or duplicate reports. Staged bugs are shown on dashboard
   412  in [moderation](https://syzkaller.appspot.com/upstream#moderation2) section
   413  and mailed to
   414  [syzkaller-upstream-moderation](https://groups.google.com/forum/#!forum/syzkaller-upstream-moderation)
   415  mailing list. Staged bugs accept all commands supported for reported bugs
   416  (`fix`, `dup`, `invalid`) with a restriction that bugs reported upstream
   417  can't be `dup`-ed onto bugs in moderation queue. Additionally, staged bugs
   418  accept upstream command:
   419  ```
   420  #syz upstream
   421  ```
   422  which sends the bug to kernel mailing lists.
   423  
   424  ## KMSAN bugs
   425  
   426  `KMSAN` is a dynamic, compiler-based tool (similar to `KASAN`) that detects
   427  uses of uninitialized values. As compared to (now deleted) `KMEMCHECK` which
   428  simply detected loads of non-stored-to memory, `KMSAN` tracks precise
   429  propagation of uninitialized values through memory and registers and only flags
   430  actual eventual uses of uninitialized values. For example, `KMSAN` will detect
   431  a branch on or a `copy_to_user()` of values that transitively come from
   432  uninitialized memory created by heap/stack allocations. This ensures
   433  /theoretical/ absence of both false positives and false negatives (with some
   434  implementation limitations of course). Note that `KMSAN` requires `clang` compiler.
   435  
   436  `KMSAN` is not upstream yet, though, we want to upstream it later. For now,
   437  it lives in [github.com/google/kmsan](https://github.com/google/kmsan) and is
   438  based on a reasonably fresh upstream tree. As the result, any patch testing
   439  requests for `KMSAN` bugs need to go to `KMSAN` tree
   440  (`https://github.com/google/kmsan.git` repo, `master` branch).
   441  A standard way for triggering the test with `KMSAN` tree is to send an
   442  email to `syzbot+HASH` address containing the following line:
   443  ```
   444  #syz test: https://github.com/google/kmsan.git master
   445  ```
   446  and attach/inline your test patch in the same email.
   447  
   448  Report explanation. The first call trace points to the `use` of the uninit value
   449  (which is usually a branching or copying it to userspace). Then there are 0 or
   450  more "Uninit was stored to memory at:" stacks which denote how the unint value
   451  traveled through memory. Finally there is a "Uninit was created at:"
   452  section which points either to a heap allocation or a stack variable which
   453  is the original source of uninitialized-ness.
   454  
   455  ## USB bugs
   456  
   457  syzkaller has an ability to perform fuzzing of the Linux kernel USB stack, see
   458  the details [here](/docs/linux/external_fuzzing_usb.md). As of now all kernel
   459  changes required for USB fuzzing have been merged into the mainline (the last one
   460  during the 5.8-rc1 merge window), so the USB fuzzing instance has been switched
   461  to target the [usb-testing](https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/log/?h=usb-testing) tree.
   462  
   463  Testing kernel patches on the USB instance follows the same principle as on the
   464  mainline instances, with a few caveats:
   465  
   466  1. You may specify any kernel tree for `syz test` as long as it includes all
   467  mainline patches up to 5.8-rc1.
   468  
   469  2. Some of the bugs have reproducers generated on kernel versions with custom
   470  kernel (when fuzzing was performed with non-yet-mainlined kernel patches), thus
   471  those reproducers might no longer work. The recommended workflow is to: first,
   472  execute a `syz test` command on a target tree to make sure that the bug
   473  reproduces, and then execute a `syz test` command with a fix/debug patch.
   474  
   475  If the bug was triggered on the `KMSAN` tree, follow the [instructions above](#kmsan-bugs),
   476  with the exception that you must also use `commit-hash` instead of the `master`
   477  branch when testing patches.
   478  
   479  ## Memory leaks
   480  
   481  `syzbot` uses `KMEMLEAK` to find memory leaks in the Linux kernel.
   482  `KMEMLEAK` kernel config is stored [here](/dashboard/config/linux/upstream-leak.config).
   483  See `KMEMLEAK` [docs](https://www.kernel.org/doc/html/latest/dev-tools/kmemleak.html)
   484  for general info, algorithm overview and usage instructions.
   485  
   486  Memory leaks may be tricky to debug because we have only the allocation stack,
   487  but we don't see where kernel code forgot to free the object or drop a reference.
   488  `KMEMLEAK` can have some false positives on tricky kernel code that hides
   489  pointers to live objects and due to memory scanning non-atomicity.
   490  But don't write off everything to false positives right away, the rate of
   491  false positives is observed to be very low. In particular, `KMEMLEAK` is
   492  [not confused](https://elixir.bootlin.com/linux/v5.2-rc1/source/mm/kmemleak.c#L1426)
   493  by pointers stored in a middle of another object; and it's
   494  [not confused](https://elixir.bootlin.com/linux/v5.2-rc1/source/mm/kmemleak.c#L440)
   495  if several pointer low bits are used as flags because a pointer into
   496  a middle of an object also marks the target as reachable.
   497  
   498  A useful litmus test is to remove `KMEMLEAK` code from the reproducer
   499  and run it for longer and/or multiple times. If memory consumption and number
   500  of live objects in `/proc/slabinfo` steadily grow, most likely the leak is real.
   501  
   502  ## KCSAN bugs
   503  
   504  [The Kernel Concurrency Sanitizer (KCSAN)](https://github.com/google/ktsan/wiki/KCSAN)
   505  is a dynamic data-race detector. Reproduction of data-races is currently
   506  unsupported, and syzbot is unable to test patches.
   507  
   508  ## No custom patches
   509  
   510  While `syzbot` can test patches that fix bugs, it does not support applying
   511  custom patches during fuzzing. It always tests vanilla unmodified git trees.
   512  There are several reasons for this:
   513  
   514  - custom patches may not apply tomorrow
   515  - custom patches may not apply to all of the tested git trees
   516  - it's hard to communicate exact state of the code with bug reports (not just hash anymore)
   517  - line numbers won't match in reports (which always brings suspicion as to the quality of reports)
   518  - custom patches can also introduce bugs, and even if they don't a developer may (rightfully)
   519    question validity of and may not want to spend time on reports obtained
   520    with a number of out-of-tree patches
   521  - order of patch application generally matters, and at some point patches
   522    need to be removed, there is nobody to manage this
   523  
   524  We've experimented with application of custom patches in the past and it lead
   525  to unrecoverable mess. If you want `syzbot` to pick up patches sooner,
   526  ask tree maintainers for priority handling.
   527  
   528  However, syzbot kernel config always includes `CONFIG_DEBUG_AID_FOR_SYZBOT=y` setting,
   529  which is not normally present in kernel. What was used for particularly elusive bugs in the past
   530  is temporary merging some additional debugging code into `linux-next` under this config setting
   531  (e.g. more debug checks and/or debug output) and waiting for new crash reports from syzbot.
   532  
   533  One can also always run syzkaller locally on any kernel for better stress testing
   534  of a particular subsystem and/or patch.
   535  
   536  ## Kernel configs
   537  
   538  Kernel configs, sysctls and command line arguments that `syzbot` uses are available in [/dashboard/config](/dashboard/config).
   539  
   540  ## Is syzbot code available?
   541  
   542  Yes, it is [here](/dashboard/app).