-
Notifications
You must be signed in to change notification settings - Fork 18k
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
syscall: panic when syscall.ParseSocketControlMessage called #41522
Comments
Thank you for your issue. To be able to investigate we will need a way to reproduce what you see. Can you please provide a stand alone program which demonstrates the panic you see. Thank you |
@davecheney code snippet likes below: func Run(listenAddr string) {
uaddr, _ := net.ResolveUDPAddr("udp", listenAddr)
conn, _ := net.ListenUDP("udp", uaddr)
fds, _ := conn.File()
defer fds.Close()
fd := int(fds.Fd())
syscall.SetsockoptInt(fd, syscall.SOL_IP, syscall.IP_TRANSPARENT, 1)
syscall.SetsockoptInt(fd, syscall.SOL_IP, syscall.IP_RECVORIGDSTADDR, 1)
for {
buf := make([]byte, 4096)
scmBuf := make([]byte, 4096)
n, scmn, _, src, err := conn.ReadMsgUDP(buf, scmBuf)
if err != nil {
log.Printf("[TProxy] Read packet from UDP error: %v\n", err)
continue
}
go handleTProxyUDPPacket(src, n, buf, scmBuf[0:scmn])
}
}
func handleTProxyUDPPacket(src *net.UDPAddr, n int, buf []byte, scm []byte) {
msgs, err := syscall.ParseSocketControlMessage(scm)
...
} |
Seems Linux Kernel or |
syscall.ParseSocketControlMessage
I have more information:
|
I cannot reproduce this on func TestParseSocketControlMessage(t *testing.T) {
for _, tc := range [][]byte{
{1, 31, 65, 55, 214, 142, 234, 242, 235, 176, 145, 153, 234, 178, 2, 177, 238, 111, 87, 28, 84, 157, 20, 223, 14, 118, 21, 61, 176, 39, 113, 172},
{1, 2, 11, 46, 119, 211, 135, 230, 134, 164, 122, 177, 135, 166, 111, 165, 131, 123, 58, 8, 57, 137, 121, 203, 99, 98, 120, 41, 221, 51, 28, 184},
{1, 15, 176, 48, 199, 181, 23, 145, 22, 211, 111, 200, 23, 209, 255, 210, 19, 12, 170, 127, 169, 254, 233, 188, 243, 21, 232, 94, 77, 68, 140, 207},
{1, 43, 111, 48, 214, 55, 188, 180, 189, 246, 163, 107, 188, 244, 84, 247, 184, 41, 1, 90, 2, 219, 66, 153, 88, 48, 67, 123, 230, 97, 39, 234},
{1, 33, 185, 7, 158, 109, 173, 219, 172, 153, 161, 4, 173, 155, 69, 152, 169, 70, 16, 53, 19, 180, 83, 246, 73, 95, 82, 20, 247, 14, 54, 133},
{1, 62, 215, 26, 79, 218, 126, 130, 127, 192, 142, 142, 126, 194, 150, 193, 122, 31, 195, 108, 192, 237, 128, 175, 154, 6, 129, 77, 36, 87, 229, 220},
{1, 2, 166, 7, 6, 238, 42, 207, 43, 141, 12, 220, 42, 143, 194, 140, 46, 82, 151, 33, 148, 160, 212, 226, 206, 75, 213, 0, 112, 26, 177, 145},
{1, 16, 130, 36, 213, 6, 159, 238, 158, 172, 179, 79, 159, 174, 119, 173, 155, 115, 34, 0, 33, 129, 97, 195, 123, 106, 96, 33, 197, 59, 4, 176},
{1, 12, 50, 4, 187, 36, 199, 216, 198, 154, 141, 105, 199, 152, 47, 155, 195, 69, 122, 54, 121, 183, 57, 245, 35, 92, 56, 23, 157, 13, 92, 134},
} {
_, err := syscall.ParseSocketControlMessage(tc)
if err != nil && err != syscall.EINVAL {
t.Errorf("ParseSocketControlMessage: %v", err)
}
}
} This never |
@tklauser I run the build at MacOS 10.15.6 and the build command is |
@tklauser Finally I found the reason. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?Running at Linux AMD64
go env
OutputWhat did you do?
Got panic on
syscall.ParseSocketControlMessage
.Before line 43
h, dbuf, err := socketControlMessageHeaderAndData(b[i:])
we should check variablei
is not a negative number.What did you expect to see?
No panic
What did you see instead?
Got panic
The text was updated successfully, but these errors were encountered: