Hi Kent,
On Tue, Oct 29, 2024 at 3:36 AM Kent Overstreet
<
kent.ov...@linux.dev> wrote:
>
> On Mon, Oct 28, 2024 at 07:03:18PM +0100, Aleksandr Nogikh wrote:
> > Hi Kent,
> >
> > There's a guide on how to reproduce a bug using the assets shared by syzbot:
> >
https://github.com/google/syzkaller/blob/master/docs/syzbot_assets.md
> >
> > If you need to use a locally built kernel instead, it will only differ
> > in that you would take the `.config` file shared in the bug report and
> > build the kernel image with it.
> >
> > > Just running the C reproducer isn't enough, it seems to need the disk images too
> >
> > Do you mean the images that are mounted by the reproducer or the disk
> > image for the VM itself? The former are already included in the C/syz
> > reproducers and for the latter we use Buildroot-based images:
> >
https://github.com/google/syzkaller/blob/master/tools/create-buildroot-image.sh
>
> I'm still reading your docs and grokking syzbot, but I believe I just
> want the image mounted by the reproducer - ktest has its own root image,
> and I'd just add any syzbot specific tools to that.
>
> What I'm mainly looking for is a standard way to set up the test
> environment - presumably you have that as scripts in your VM root image,
> and I'm wondering if it's subsystem dependent? The docs don't say too
> much about the image mounted by the reproducer.
It's all subsystem independent. When we handle a #syz test command, we
build the kernel at the required revision, create and boot a VM with
it, upload the compiled program (for C repros) and syzkaller binaries
(for syz repro), then we run the program and monitor the console log
for the signs of crash reports. We only substitute the bzImage to the
VM root image, the rest is done externally.
C reproducers are intended to be fully self-contained -- if you look
closely at the source code, you will notice that they enclose the raw
disk images that they will mount (though in a compressed format to
keep the total size sane). You just need to compile them and run on an
instrumented kernel. Same for Syz reproducers, but they are more
tricky as they also require a specific syzkaller revision to be
checked out and built.
We extract the mounted images only to simplify debugging. Because of
compression, it's not very straightforward to get the raw binary image
from the C file, so we do this automatically just in case someone
needs those blobs.
Ah, interesting!
Thanks for sharing the links.
>
> > In any case, if it makes life easier, we can try to generate ktest
> > files on the syzbot side.
>
> What I have in mind is a syzbot.ktest in the ktest repo, and then you'd
> pass a commandline argument to that, which would be a syzkaller ID, then
> syzbot.ktest would fetch the c reproducer and disk image (if
> applicable).
By ID you mean the bug ID, right?
We have a JSON API on our syzbot dashboard. For example, if you want
some machine-readable info for
https://syzkaller.appspot.com/bug?extid=8761afeaaf2249358b14, you can
query
https://syzkaller.appspot.com/bug?extid=8761afeaaf2249358b14&json=1.
It does not include links to the downloadable assets, but that can be
quickly fixed if needed.
Note that we have request throttling (max 15 requests per 15 seconds
from the same IP). Though if you just want to use the ktest for
debugging purposes, that should not be a problem at all.
>
> But I'm not seeing anything to tie the C reproducer to the disk image,
> so maybe you could supply a metadata file that describes that?
As mentioned above, there's no need to do anything to tie them. They
are already tied as much as possible :)
>
> The other thing to consider is the kernel .config. It should work to
> just use your .config and just overlay any ktest-specific kconfig
> dependencies (we probably configure qemu a bit differently than you),
> but I wonder if the ktest code for declaratively specifying a kernel
> config would be of interest to you:
>
>
https://evilpiepirate.org/git/ktest.git/tree/tests/kconfig.sh
> That's the base, then tests can do their own require-kernel-config or
> require-kernel-config-soft to pull in e.g. CONFIG_FS_BCACHEFS.
On our side, we have our custom tool for mass-generating .config files
depending for all of our different syzkaller instances:
https://github.com/google/syzkaller/tree/master/dashboard/config/linux
https://github.com/google/syzkaller/blob/master/dashboard/config/linux/main.yml
Since we fuzz all kernel subsystems at the same time, our .config
files are very heavy and take a lot of time to build even on a
powerful machine. If you just want to debug bcachefs findings, you
might be better off enabling some limited set of options. Here's what
might be related:
https://github.com/google/syzkaller/blob/master/dashboard/config/linux/bits/filesystems.yml#L198
https://github.com/google/syzkaller/blob/master/dashboard/config/linux/bits/kasan.yml
https://github.com/google/syzkaller/blob/master/dashboard/config/linux/bits/lockdep.yml
--
Aleksandr