Skip to content
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

Segmentation Fault occured after calling setcap to v2ray #59

Closed
ghost opened this issue Sep 19, 2019 · 4 comments
Closed

Segmentation Fault occured after calling setcap to v2ray #59

ghost opened this issue Sep 19, 2019 · 4 comments
Labels
Documentations Something about the documentations platform/linux Issue related to Linux t/runtime Issue occured in runtime, not compile-time Upstream Upstream Qt, v2ray-core, GLIBC or golang related bugs.

Comments

@ghost
Copy link

ghost commented Sep 19, 2019

getcap ./v2ray
----> (no output)

./v2ray                                      
----> V2Ray 4.20.0 (V2Fly, a community-driven edition of V2Ray.) Custom
----> A unified platform for anti-censorship......
----> (blablablabla.............)

sudo setcap CAP_NET_ADMIN,CAP_NET_RAW,CAP_NET_BIND_SERVICE=eip ./v2ray

getcap ./v2ray
----> ./v2ray = cap_net_bind_service,cap_net_admin,cap_net_raw+eip

./v2ray                                      
----> [1]    75971 segmentation fault  ./v2ray

Originally posted by @lhy0403 in #57 (comment)

@ghost
Copy link
Author

ghost commented Sep 19, 2019

解决方案:

sudo sysctl fs.suid_dumpable=1

@ghost
Copy link
Author

ghost commented Sep 19, 2019

For future refrence: yggdrasil-network/yggdrasil-go#403 (comment)

@ghost ghost added From-v2ray-Interaction platform/linux Issue related to Linux t/runtime Issue occured in runtime, not compile-time labels Sep 19, 2019
@iusearch
Copy link
Contributor

Write this into doc.

@ghost ghost added the Documentations Something about the documentations label Sep 19, 2019
@ghost
Copy link
Author

ghost commented Sep 19, 2019

After a short talk on IRC, we came to this conclusion:

This is caused by vsyscall=none being passed to the kernel command line, and the go runtime relying on the legacy vsyscall table being present.

The go runtime is attempting to call gettimeofday() using the vdso page.

278  LEAQ 0(SP), DI
279  MOVQ $0, SI
280  MOVQ runtime·vdsoGettimeofdaySym(SB), AX
281  CALL AX
282  MOVQ 0(SP), AX // sec

However, since the legacy vsyscall table is disabled in the kernel, this ends up failing and causing a segfault.

[559159.574164] yggdrasil[1562] vsyscall attempted with vsyscall=none ip:ffffffffff600000 cs:33 sp:7ffd6f0c3e78 ax:ffffffffff600000 si:0 di:7ffd6f0c3e80
[559159.574174] yggdrasil[1562]: segfault at ffffffffff600000 ip ffffffffff600000 sp 00007ffd6f0c3e78 error 15
[559159.574178] Code: Bad RIP value.

Modern programs shouldn't rely on the vsyscall table being present and should link to linux-vdso.so.1

Edit:
The normal output of ldd yggdrasilshould be something like this

linux-vdso.so.1 (0x00007ffc3eeef000)   //this should be present 
ibpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f5df3a01000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f5df383d000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f5df3fd8000)

Error analyzed from: yggdrasil-network/yggdrasil-go#403 (comment)

@ghost ghost changed the title setcap 后出现 segmentation fault Segmentation Fault occured after calling setcap to v2ray Sep 19, 2019
@ghost ghost added the Upstream Upstream Qt, v2ray-core, GLIBC or golang related bugs. label Sep 19, 2019
@ghost ghost closed this as completed in d7a3375 Sep 21, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentations Something about the documentations platform/linux Issue related to Linux t/runtime Issue occured in runtime, not compile-time Upstream Upstream Qt, v2ray-core, GLIBC or golang related bugs.
Development

No branches or pull requests

1 participant