fuzz-tests: add a test for handle_peer_error_or_warning()#8304
fuzz-tests: add a test for handle_peer_error_or_warning()#8304rustyrussell merged 3 commits intoElementsProject:masterfrom
handle_peer_error_or_warning()#8304Conversation
The FUZZ_COMMON_OBJS list roughly follows lexicographic order. Make it adhere strictly to the order. This makes adding and reviewing changes to the file easier.
|
@morehouse , I think this test has exposed a bug, although I'm not 100% confident. We're injecting the fuzzer input as and that works without any breakage. |
|
Hey @morehouse, like we discussed earlier, I investigated the breakage caused by this test: And it looks like the breakage occurs due to I've faced this issue in a couple of other targets that I'm working on as well, and it doesn't take a lot of fuzzing time to pop up so I'm not sure if this is an actual bug or if I'm missing something in the target setup. I'd appreciate it if you could take a look. |
I ran the fuzz target with common/daemon_conn.c:161:18: runtime error: member access within null pointer of type 'struct daemon_conn'
#0 in daemon_conn_send common/daemon_conn.c:161:18
#1 in status_vfmt common/status.c:154:2
#2 in status_fmt common/status.c:165:2
#3 in handle_peer_error_or_warning common/read_peer_msg.c:29:3
#4 in run tests/fuzz/fuzz-error-warning.c:14:5 From this it's clear the initialized global is I think probably you need to add the following lines to the target's lightning/tests/fuzz/connectd_handshake.h Lines 73 to 75 in ad2dc97 |
|
This test is now ready to review. |
morehouse
left a comment
There was a problem hiding this comment.
Looking closer at this target, I'm not sure how much benefit it really provides.
handle_peer_error_or_warning seems like a relatively simple function. I'm not sure it's worth adding ~200 new files to test it... WDYT?
tests/fuzz/fuzz-error-warning.c
Outdated
| void peer_failed_connection_lost(void) | ||
| { longjmp(exit_jmp, 1); } |
There was a problem hiding this comment.
I can't find any place where peer_failed_connection_lost is called from this fuzz target. Perhaps we can just abort if it does get called?
Right, makes me wonder why this happens though. Shouldn't the corpus for a relatively simpler target like this be smaller as well? |
Changelog-None: `handle_peer_error_or_warning()` in
`common/read_peer_message.{c, h}` is responsible for parsing any
incoming `error` or `warning` messages as defined in BOLT #1.
Add a test for it.
Add a minimal input set as a seed corpus for the newly introduced test. This leads to discovery of interesting code paths faster.
Yes, simpler targets should generally have smaller corpora. Other fuzz targets for CLN have corpus sizes that range from ~50 inputs to ~2000 inputs, so 200 isn't abnormal. If libFuzzer used only coverage metrics to pick corpus elements, the corpora would be smaller. But libFuzzer also takes other input "features" into consideration, which increases corpus sizes. The one thing we can do to decrease corpus sizes is use |
handle_peer_error_or_warning()incommon/read_peer_messageis responsible for parsing any incomingerrororwarningmessages as defined in BOLT #1. Add a test for it.Checklist
Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked: