-
Notifications
You must be signed in to change notification settings - Fork 37
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
Fix potential segfault with stream iterators. #1923
base: main
Are you sure you want to change the base?
Conversation
@evantypanski can you see if this fixes the issue from #1918? It's now raining an exception ( |
Sure I'll take a look on my reproducers tomorrow, I'll be driving for the rest of the day :) Thanks for looking at this, I figured it'd take me a little longer just to figure out the generated code |
@rsmmr this indeed fixes the use-after-free in the reproducers I have |
Great, thanks for confirming. Is it now reporting an exception ( |
I see no discernable difference end-to-end for cases that only had a UAF with the sanitizer but didn't segfault. The verbose logs are exactly the same and any logs that Zeek output are exactly the same in every case I tried. In other cases that did segfault, it's hard to track down that exact exception - they have lots of them anyway since they're trying to parse data that doesn't fit. so - maybe?
Well, I'll say that everything end-to-end seems to be as expected: cases that only saw UAF but no segfault work the same, then cases that saw a segfault no longer segfault. Cases that segfaulted also seem to have more of that exception in analyzer.log (compared to just removing the So - it's pretty tough for me to tell, but at least this doesn't seem to do anything bad and fixes the segfault so I see that as correct. If you have a specific test I can do that too. The HTTP examples in the issue seem to be representative of the problem |
That sounds good enough to me. I'll get this ready for review & merge then. Thanks! |
When trimming off the beginning of a stream, an existing iterator could end up dereferencing its internal chunk pointer even if the chunk now no longer existed. The issue was inside the increment/decrement operations, which didn't check if the *current* iterator offset was still valid (because only then the current chunk is guaranteed to be valid too). Closes #1918.
3e703eb
to
e88650c
Compare
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.
Thanks a bunch for looking at this, it looks good to me. And a lot simpler than what I was afraid of :)
When trimming off the beginning of a stream, an existing iterator
could end up dereferencing its internal chunk pointer even if the
chunk now no longer existed. The issue was inside the
increment/decrement operations, which didn't check if the current
iterator offset was still valid (because only then the current chunk
is guaranteed to be valid too).
Closes #1918.