Skip to content

fix(simple-dns): segfaults in WireFormat::parse()#40

Closed
Nuhvi wants to merge 2 commits intoballiegojr:mainfrom
Nuhvi:test/fuzz
Closed

fix(simple-dns): segfaults in WireFormat::parse()#40
Nuhvi wants to merge 2 commits intoballiegojr:mainfrom
Nuhvi:test/fuzz

Conversation

@Nuhvi
Copy link
Copy Markdown
Contributor

@Nuhvi Nuhvi commented Jan 9, 2025

I have repeatedly got a reports for segfaults caused by simple-dns, so I figured adding a fuzz test might be helpful to add more confidence in simple-dns.

I also fixed all the thread panics I have seen from the fuzz test.

You can see more by installing cargo-fuzz and running cargo fuzz run packet_parse

@Nuhvi Nuhvi changed the title test(simple-dns): fuzz fix(simple-dns): segfaults in WireFormat::parse() Jan 9, 2025
@Arqu
Copy link
Copy Markdown

Arqu commented Jan 9, 2025

Can confirm this fixes segfaults I've been seeing. ref n0-computer/iroh#2844

@balliegojr
Copy link
Copy Markdown
Owner

Thanks for the great addition.

I am closing this PR in favor of #41, since I needed to fix some clippy warnings (not related to your changes) and add some changes to the github workflow.

The fuzz tests are going to run in the github actions for 5 minutes for every new PR, I don't know if this is enough time or not, so please let me know if you think this value should be increased.

I am also working to add bind9 compatibility tests on #39

@balliegojr balliegojr closed this Jan 10, 2025
@Nuhvi
Copy link
Copy Markdown
Contributor Author

Nuhvi commented Jan 11, 2025

I don't know if this is enough time or not

I think more than enough, as soon as I passed fuzz tests for more than a minute everything was fixed and it run for 30 minutes with no panics.

I am also working to add bind9 compatibility tests on #39

Noticed that and I think the Service Params enum is probably a good idea, but until then, a new release would be appreciated.

lexnv pushed a commit to paritytech/litep2p that referenced this pull request Nov 12, 2025
Upgrades simple-dns from 0.9.3 to 0.11.0. The reason being that we
detected segfaults when using this version of simple-dns, here the
backtrace

```
Thread 2 "tokio-runtime-w" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff71ff6c0 (LWP 662)]
0x00005555590fa234 in simple_dns::dns::packet::Packet::parse_section::hcaf780141803b06c ()
(gdb) bt
#0  0x00005555590fa234 in simple_dns::dns::packet::Packet::parse_section::hcaf780141803b06c ()
#1  0x0000555558586eb3 in litep2p::protocol::mdns::Mdns::start::{{closure}}::h9dfcac24f1cf526c ()
#2  0x0000555558582ff0 in litep2p::Litep2p::new::{{closure}}::h7e8ab961e0597d4d ()
#3  0x00005555568998cf in <tracing_futures::Instrumented<T> as core::future::future::Future>::poll::h14f8d5a4cd2280a5 ()
#4  0x0000555556623186 in tokio::runtime::task::raw::poll::h20b62065a828f381 ()
#5  0x00005555597c242e in tokio::runtime::scheduler::multi_thread::worker::Context::run_task::hd2657bfbfd77fdd7 ()
#6  0x00005555597c0a60 in tokio::runtime::scheduler::multi_thread::worker::run::hff59903bb30ee69e ()
#7  0x00005555597c6b05 in tokio::runtime::task::raw::poll::hd94431bf703a75c4 ()
#8  0x00005555597af0f8 in std::sys::backtrace::__rust_begin_short_backtrace::h5776829e2c5e1158 ()
#9  0x00005555597b3af8 in core::ops::function::FnOnce::call_once{{vtable.shim}}::hd2821905ea35840e ()
#10 0x00005555593e4abb in std::sys::pal::unix::thread::Thread::new::thread_start::h1822d22fde68314f ()
#11 0x00007ffff7c4d1f5 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#12 0x00007ffff7ccd8dc in ?? () from /lib/x86_64-linux-gnu/libc.so.6
```

We believe it is related to this PR at least partially
balliegojr/simple-dns#40 whose changes were
introduced here: balliegojr/simple-dns#41

we have confirmed that using 0.11.0 removes the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants