-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Socks: Fix buffer full panic when encoding large UDP packets #5252
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
Conversation
Refactor EncodeUDPPacket to use header buffer and handle packet size dynamically.
Add test for encoding and decoding UDP packets with large payloads.
|
我觉得可能静默丢弃才是对的 我们不能迁就无限大的data( |
The silent truncation was eliminated by the maintainers in version v25.8.29, when |
|
以前也会看情况丢弃UDP包 大多数UDP程序可能都需要自己探测MTU 8KB已经够大了 QUIC的最低不低于1200字节就行了 |
|
In this case (look panic log) the panic wasnt triggered by a typical oversized or malformed UDP datagram it occurred when Firefox attempted to establish a QUIC connection to a website. During the initial handshake the QUIC packets exceeded 8 KB, which caused the EncodeUDPPacket function to hit the fixed-size buffer limit and panic, effectively halting the core. This regression doesnt occur in kernel version v25.8.3, where the buffer behavior still tolerated such payloads (albeit with silent truncation). The newer versions correctly surface the buffer overflow but exposed the underlying logic flaw in the SOCKS UDP handler |
|
一个8KB甚至大于8KB的UDP包跑到公网上基本也会被丢弃 哪怕是分片也是极其不好的 这绝对是错误的 (如果说的是真的)Firefox很可能是读取了loopback接口的MTU 65536才发出这样的包 |
Refactor EncodeUDPPacket to simplify buffer handling and improve memory management.
bug
Description:
panic: common/buf: buffer is fullThis issue occurred in the SOCKS inbound proxy when processing large UDP packets (e.g., QUIC handshake packets >8KB).
The regression was introduced after the upstream change around v25.8.29, when the behavior of
(*buf.Buffer).Writewas modified:Before v25.8.29 (<= v25.8.3) –
Writesilently truncated data exceeding buffer capacity (causing silent corruption).After v25.8.29 –
Writenow correctly returnsErrBufferFull, preventing silent data loss but exposing logic errors.EncodeUDPPacketused a fixed-size buffer viabuf.New()andcommon.Must2(b.Write(data)), causing a panic when large packets exceeded the buffer capacity.Fix:
common.Must2with proper error handling.TestEncodeUDPPacketLargePayloadto ensure stability for large datagrams.Error log: