xjasonlyu / tun2socks

tun2socks - powered by gVisor TCP/IP stack
https://github.com/xjasonlyu/tun2socks/wiki
GNU General Public License v3.0
2.86k stars 407 forks source link

tun2socks panic: unaligned 64-bit atomic operation #35

Closed atong027 closed 3 years ago

atong027 commented 3 years ago

root@p722:/online # ./tun2socks -device tun://tun0 -mtu 1500 -proxy socks5://127.0.0.1:10808

INFO[0000] [STACK] tun://tun0 <-> socks5://127.0.0.1:10808 panic: unaligned 64-bit atomic operation

goroutine 19 [running]: runtime/internal/atomic.panicUnaligned() runtime/internal/atomic/unaligned.go:8 +0x24 runtime/internal/atomic.Store64(0x86ed1c, 0x100000, 0x0) runtime/internal/atomic/asm_arm.s:278 +0x14 gvisor.dev/gvisor/pkg/tcpip.(SocketOptions).SetSendBufferSize(0x86ecb0, 0x100000, 0x0, 0x6b387200) gvisor.dev/gvisor@v0.0.0-20210220013851-93fc09248a2f/pkg/tcpip/socketops.go:607 +0x17c gvisor.dev/gvisor/pkg/tcpip/transport/tcp.newEndpoint(0x85d500, 0x800, 0x80b2a0, 0x4) gvisor.dev/gvisor@v0.0.0-20210220013851-93fc09248a2f/pkg/tcpip/transport/tcp/endpoint.go:890 +0x1d0 gvisor.dev/gvisor/pkg/tcpip/transport/tcp.(listenContext).createConnectingEndpoint(0x8de000, 0x894280, 0x6284333a, 0xb4a08e89, 0x91df74, 0x80b2a0, 0x841f1789, 0x6284333a, 0x0) gvisor.dev/gvisor@v0.0.0-20210220013851-93fc09248a2f/pkg/tcpip/transport/tcp/accept.go:214 +0xac gvisor.dev/gvisor/pkg/tcpip/transport/tcp.(listenContext).startHandshake(0x8de000, 0x894280, 0x91df74, 0x80b2a0, 0x0, 0x0, 0x0, 0x0, 0x0) gvisor.dev/gvisor@v0.0.0-20210220013851-93fc09248a2f/pkg/tcpip/transport/tcp/accept.go:249 +0x84 gvisor.dev/gvisor/pkg/tcpip/transport/tcp.(listenContext).performHandshake(0x8de000, 0x894280, 0x91df74, 0x80b2a0, 0x0, 0x0, 0x18, 0xb6f80088, 0x18) gvisor.dev/gvisor@v0.0.0-20210220013851-93fc09248a2f/pkg/tcpip/transport/tcp/accept.go:317 +0x48 gvisor.dev/gvisor/pkg/tcpip/transport/tcp.(ForwarderRequest).CreateEndpoint(0x8463f0, 0x80b2a0, 0x0, 0x0, 0x0, 0x0) gvisor.dev/gvisor@v0.0.0-20210220013851-93fc09248a2f/pkg/tcpip/transport/tcp/forwarder.go:155 +0xe8 github.com/xjasonlyu/tun2socks/core/stack.withTCPHandler.func1.1(0x8463f0) github.com/xjasonlyu/tun2socks/core/stack/tcp.go:40 +0x8c created by gvisor.dev/gvisor/pkg/tcpip/transport/tcp.(Forwarder).HandlePacket gvisor.dev/gvisor@v0.0.0-20210220013851-93fc09248a2f/pkg/tcpip/transport/tcp/forwarder.go:94 +0x204

busybox uname -a Linux localhost 3.10.100+ #1 PREEMPT Wed Nov 29 12:49:06 CST 2017 armv7l GNU/Linux

im using armv7 from latest release

xjasonlyu commented 3 years ago

TRY v2.1.4

xiaolei0125 commented 3 years ago

I have same issue on raspi2(armv7) with v2.1.3 root@p1:~# uname -a Linux p1 5.3.0-1037-raspi2 #39-Ubuntu SMP Fri Jan 29 22:26:21 UTC 2021 armv7l armv7l armv7l GNU/Linux root@p1:~# tun2socks -device tun://tun0 -proxy socks5://192.168.0.115:1080 -loglevel debug

Now just test v2.1.4 on pi, it can working on raspi2 .

Working with iptables and ipset, tun2socks is a simple and efficient transparent proxy tool, I like it very much.

Thanks @xjasonlyu

xjasonlyu commented 3 years ago

@xiaolei0125 😉

Maybe you can see this docker script, iptables is unnecessary.

atong027 commented 3 years ago

TRY v2.1.4

Thank you @xjasonlyu it's working fine now

xiaolei0125 commented 3 years ago

@xjasonlyu 嗯,我用systemd启动tun2socks的脚本就是参考过你写的docker script, 不过我的使用场景可能有点不一样。 我使用dnsmasq/overture这类支持ipset的DNS工具进行分流, 需要使用iptables + ipset给分流的流量打上mark.