Coder Social home page Coder Social logo

Comments (8)

Ralith avatar Ralith commented on July 20, 2024

This also partially defeats the protections added in #330.

from quinn.

fairingrey avatar fairingrey commented on July 20, 2024

Not sure if this is the fastest for your uses, but I've tried tackling this issue through https://github.com/fairingrey/byte_sequencer.

It makes one assumption:

  • The stream isn't corrupted -- That is, duplicate bytes received in a stream frame will always remain the same

It also won't pop redundant chunks from the binary heap in the case that a larger surrounding chunk is received (this is another worst case scenario). If a chunk of bytes in the range [2,3) is received first, and then a chunk of bytes from [1,4) or [0,5) is received afterwards, then the sequencer will continue to write both to the buffer despite the redundant information in the first chunk (it will write the second first, as it has an offset closer to 0).

Would love some improvement and review if possible, since I don't often write high-performance components...

from quinn.

Ralith avatar Ralith commented on July 20, 2024

The stream isn't corrupted -- That is, duplicate bytes received in a stream frame will always remain the same

This assumption is endorsed by the QUIC draft, so as long as resource consumption remains sane and behavior remains well-defined, relying on it is just fine.

from quinn.

Ralith avatar Ralith commented on July 20, 2024

Per discussion on the rust community discord, as of this writing the above code can be induced by an attacker to consume O(nĀ²) space, which is better than unbounded but still not ideal.

from quinn.

djc avatar djc commented on July 20, 2024

I'm guessing we should maybe introduce a different mode here, where we switch to a different approach when we detect that the peer is doing something that might result in bad performance. I suppose we can still get rid of the duplicate data without a large performance penalty, but then we potentially still have the problem fragmented memory slices keeping many largish allocations alive.

from quinn.

Ralith avatar Ralith commented on July 20, 2024

I think an adequate solution to that would be copying stream data into fresh allocations whenever it's less than, say, half the size of the UDP buffer it was read into.

from quinn.

Ralith avatar Ralith commented on July 20, 2024

I suspect both of these were fixed by #598, but we should verify carefully.

from quinn.

Ralith avatar Ralith commented on July 20, 2024

I've reviewed the current behavior. The first case was indeed fixed by #598, but the latter case (roughly) remains. Closing in favor of #735 which describes the remaining issue in greater detail.

from quinn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.