-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
syz-fuzzer: add NULL check in supported features #4763
base: master
Are you sure you want to change the base?
Conversation
Kernel supported features are detected using debugfs. However, if the filesystem is not mounted, `syz-fuzzer` panics without providing any clues as to why. ``` 2024/05/04 10:12:49 connecting to manager... 2024/05/04 10:12:49 fuzzer vm-1 connected 2024/05/04 10:12:49 checking machine... panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6019a8] goroutine 1 [running]: main.main() /home/alessandro/go/src/syzkaller/syz-fuzzer/fuzzer.go:169 +0x958 debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: free: client-session, nchannels 2 debug1: channel 1: free: 127.0.0.1, nchannels 1 Transferred: sent 5180, received 6532 bytes, in 2.5 seconds Bytes per second: sent 2097.7, received 2645.2 debug1: Exit status 2 ``` This simple patch prevents `syz-fuzzer` from crashing and allows it to terminate cleanly, while provides a possible cause why this issue is occurring. ``` 2024/05/04 10:15:14 connecting to manager... 2024/05/04 10:15:14 fuzzer vm-1 connected 2024/05/04 10:15:14 checking machine... 2024/05/04 10:15:14 SYZFATAL: The currently running kernel image seems not to support any required feature, have you forgotten to mount debugfs? debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: free: client-session, nchannels 2 debug1: channel 1: free: 127.0.0.1, nchannels 1 Transferred: sent 5160, received 5016 bytes, in 2.4 seconds Bytes per second: sent 2106.7, received 2047.9 debug1: Exit status 1 ``` Signed-off-by: Alessandro Carminati <[email protected]>
Hi Alessandro, Features are not returned as nil when debugfs is not mounted, the only case I see where we return nil features is this: syzkaller/pkg/host/features.go Line 89 in 610f2a5
Are you trying to enable coverage for OS that does not use shmem for executor communication? We should disable coverage feature in this case with the explanation, or detect this setting earlier then syz-manager starts. |
I hope you will forgive my unconventional debugging approach. My initial step was to set up a Linux environment and a filesystem for learning purposes.
My initial syzkaller run resulted in a panic.
By inserting print debugs in various locations, similar to what is demonstrated here:
I observed that:
Since I was confident that my features were enabled int the kernel, I investigated how syzkaller detected these features. My conclusion was that syzkaller couldn't identify the enabled features because debugfs wasn't mounted. Creating a new buildroot image with debugfs mounted prevented the panic. Have I overlooked anything significant in my analysis? |
Yes, use of KCOV requires DEBUGFS, but syzkaller shouldn't crash if DEBUGFS is not mounted. I see, we get nil r.Features if we get here: syzkaller/syz-fuzzer/fuzzer.go Line 154 in 610f2a5
and it crashes when printing here: syzkaller/syz-fuzzer/fuzzer.go Line 166 in 610f2a5
We probably could remove printing entirely, but I guess it will still crash here: syzkaller/syz-fuzzer/fuzzer.go Line 180 in 610f2a5
This part of the code is currently in flux and will need to change more significantly, but a reasonable local fix may be to do this:
then we shouldn't crash and pass the error to the manager to print to user. |
I understand. Given this, should I amend my PR with a more suitable solution, such as testing the one you proposed, or would it be more appropriate to close this PR altogether? What are your thoughts? |
Whatever you prefer. |
Please don't misunderstand me; I'm only asking because I see this as an opportunity for me to delve deeper into this code. I've tested the suggestion from your previous message, and here are the results:
Indeed, it doesn't panic, which is a positive outcome. However, it provides a message that might confuse the user:
Moreover, the final message the user receives indicates that syzkaller exited because the
However, based on our interaction, I understood |
If you want better error message, then it should be done here: syzkaller/pkg/host/features_linux.go Lines 45 to 56 in 69f2eab
I see it already checks for debugfs, so perhaps this function needs improvement: syzkaller/pkg/host/features_linux.go Lines 246 to 251 in 69f2eab
Using |
Hello again, In any case, if you manually provide an empty feature object as I interpret your suggestion in this thread, the fuzzer doesn't crash but eventually terminates, stating that KCOV is not enabled. In an effort to force execution without KCOV detection, I removed the code that populates the error field in
I might be about to say something very wrong, so please forgive me for that, but seems like this code is written assuming KCOV. In the meantime, I've rewritten the checkDebugFS() function to make it more robust, if you consider this worthy, I can open another PR for this.
Now is able to detect if |
As I mentioned this part is being changed almost completely. I finally got it to PR stage: #4790. |
Hello, I took a quick look at the changes you made to the codebase, and it has indeed changed significantly since the last time I reviewed it. Given these updates, my previous proposals are no longer relevant, so please feel free to close this PR as it is no longer applicable. Allow me to make one final remark:
Although it is possible to have |
I think we could try to mount debugfs during setup procedure in executor in setup_features. But we need to mount it before any features are checked, not just coverage, because debugfs is used by a number of features. We shouldn't fail if the mount fails and instead rely on the check for each feature. |
Kernel supported features are detected using debugfs. However, if the filesystem is not mounted,
syz-fuzzer
panics without providing any clues as to why.This simple patch prevents
syz-fuzzer
from crashing allowing it to terminate cleanly, while provides a possible cause why this issue is occurring.