-
Notifications
You must be signed in to change notification settings - Fork 1.3k
FUSE: increase code coverage #2001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi Stefano, It needs to be refactored somehow to reduce cyclomatic complexity. |
Codecov Report
|
|
My local instance running without syz_fuse_mount for 20h more now got to 61% of readdir.c. So it seems that the fuzzer is capable of getting all that coverage, maybe just somewhat slower. Slightly bumping priority of using the directory with a new pseudo-syscall does not look like a good RoI. And this helps only 1 filesystem out of 92, while applicable to all of them. I am thinking about some alternative approaches.
|
I was thinking that a lot more was going on inside syz_mount_image, but I guess that is not the case. I have refactored it and added what I was previously doing inside syz_fuse_mount.
Agreed. |
dvyukov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think overall we are close. There is a bunch of nits, but on high level this looks good. With a small change to syz_mount_image we improve fuzzing of all filesystems, which is good.
Currently fuse_in.unique and fuse_out.unique are not linked by any dependency chain. This causes the majority of the replies to the kernel to be dropped because not referring to a previously sent request. By defining them as a resource, we push the fuzzer in the right direction (i.e., try to respond using a previously issued unique value). The read syscall has been updated accordingly, it now expects and parses a fuse_in header and some additional data.
Instead of using a generic int32 for fuse_attr.mode, use the expected file mode flags.
|
The change looks good to me. |
At the moment syzkaller is able to respond to FUSE with a syntactically correct response using the specific write$FUSE_*() syscalls, but most of the times these responses are not related to the type of request that was received. With this pseudo-syscall we are able to provide the correct response type while still allowing the fuzzer to fuzz its content. This is done by requiring each type of response as an input parameter and then choosing the correct one based on the request opcode. Notice that the fuzzer is still free to mix write$FUSE_*() and syz_fuse_handle_req() syscalls, so it is not losing any degree of freedom. syz_fuse_handle_req() retrieves the FUSE request and resource fuse_unique internally (by performing a read() on the /dev/fuse file descriptor provided as input). For this reason, a new template argument has been added to fuse_out (renamed to _fuse_out) so that the unique field can be both an int64 (used by syz_fuse_handle_req()) and a fuse_unique resource (used by the write$FUSE_*() syscalls) without any code duplication.
Use the type bytelen instead of len to express the length of the data structure being pointed by the pointer passed to read$FUSE().
Refactor syz_mount_image() to support filesystems not requiring a backing device and filesystem image (e.g. FUSE). To do that, we check for the presence of the pointer to the array of struct fs_image_segment: if missingi, there is no need to setup the loop device and we can proceed directly with the mount() syscall. Add syz_mount_image$fuse() (specialization for FUSE) inside sys/linux/fs_fuse.txt.
Add syzkaller program which correctly handles a getdents64() syscall on a FUSE directory. Here the related comment/discussion google#2001 (comment).
All conflicts should be resolved now. Thanks for suggesting |
This patch set increases the total FUSE code coverage by adding a pseudo-syscalls (and some other stuff) which helps syzkaller mimics a FUSE daemon behavior.
Note:
make presubmitfails at themake lintwith the following error messagepkg/host/syscalls_linux.go:173:1: cyclomatic complexity 27 of func "isSupportedSyzkall" is high (> 24). This seems to be due to the additional branches in the "isSupportedSyzkall", does anyone have any solution for that?I have run
make test,make presubmit_archandmake presubmit_racemanually and they pass.CC: @balsini