klzgrad / naiveproxy

Make a fortune quietly
BSD 3-Clause "New" or "Revised" License
6.58k stars 877 forks source link

naiveproxy crash with openwrt master X64 #555

Closed openips closed 10 months ago

openips commented 1 year ago

naiveproxy version v116.0.5845.92-2 x64 with openwrt x64 master X64 linux kernel 5.15.127 config here: { "listen": "socks://127.0.0.1:1080", "proxy": "https://123:4563@789.com", "log": "", "padding": "true" } system log below:

[187903.188587] traps: naive[5946] general protection fault ip:5611df7e165c sp:7fff7d3c7880 error:0 in naive[5611df5d5000+4d4000]
[219275.540946] traps: naive[5943] general protection fault ip:556e0a8e365c sp:7ffec66265a0 error:0 in naive[556e0a6d7000+4d4000]
[238567.821995] traps: naive[12947] general protection fault ip:5568cf40665c sp:7fff8147a060 error:0 in naive[5568cf1fa000+4d4000]

给一个symbol_level=1的naive 自己编译老提示失败

谢谢

klzgrad commented 1 year ago

默认的symbol已经足以定位问题,需要保存coredump查看问题发生的指令位置。上面dmesg因为有ALSR看不出问题发生在哪

openips commented 1 year ago

好的 我开启 有了dump在发出来

openips commented 1 year ago

观察了几天 终于crash了 相关日志为

gdb /usr/bin/naive core-naive-2087-1693749448
GNU gdb (GDB) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-openwrt-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/naive...
(No debugging symbols found in /usr/bin/naive)
[New LWP 2087]
[New LWP 2099]
[New LWP 2098]
[New LWP 2102]
[New LWP 2110]
Core was generated by `/usr/bin/naive /etc/naiveproxy/config_dc.json'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00005600c163665c in ?? ()
[Current thread is 1 (LWP 2087)]
(gdb) bt
#0  0x00005600c163665c in ?? ()
#1  0x0000000000000000 in ?? ()

config_dc.json内容为

 cat /etc/naiveproxy/config_dc.json
{
  "listen": "socks://127.0.0.1:1086",
  "proxy": "https://AAA:BBB@CCC.DDD.EEE",
  "log": "",
  "concurrency": "2"
}

AAA BBB CCC DDD EEE是我隐藏了配置的真实信息,配置文件正确可以正常使用 naiveproxy version v116.0.5845.92-2 x64 with openwrt x64 master X64 linux kernel 5.15.127 烦请查一下哪里有问题 谢谢

klzgrad commented 1 year ago

把core-naive-2087-1693749448压缩以后附件上来

sha256sum /usr/bin/naive是什么?

你的/usr/bin/naive是从哪里来的?有没有被strip?

这是一个默认Release编译的core的表现

$ gdb ./naive core
Reading symbols from ./naive...
(No debugging symbols found in ./naive)
[New LWP 12267]
[New LWP 12269]
[New LWP 12270]
[New LWP 12271]
[New LWP 12268]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./naive'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fc50dc82e26 in epoll_wait (epfd=3, events=0x287400058000, maxevents=32, timeout=4000)
    at ../sysdeps/unix/sysv/linux/epoll_wait.c:30
30  ../sysdeps/unix/sysv/linux/epoll_wait.c: No such file or directory.
[Current thread is 1 (Thread 0x7fc50db79680 (LWP 12267))]
(gdb) bt
#0  0x00007fc50dc82e26 in epoll_wait (epfd=3, events=0x287400058000, maxevents=32, timeout=4000)
    at ../sysdeps/unix/sysv/linux/epoll_wait.c:30
#1  0x0000565023ab3c50 in epoll_dispatch.fa565fa3c1e953c9ae4ecee0ae4a3ca0[cfi] ()
#2  0x0000565023ab217e in event_base_loop ()
#3  0x0000565023a6881f in base::MessagePumpLibevent::Run(base::MessagePump::Delegate*) ()
#4  0x00005650237e24da in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta) ()
#5  0x0000565023877e51 in base::RunLoop::Run(base::Location const&) ()
#6  0x000056502390d47e in main ()

如果被strip了,需要使用原来没有strip的二进制查看bt。

openips commented 1 year ago

感谢K大回复 core-naive-2087-1693749448日志为 core-naive-2087-1693749448.zip naive是我自己编译的,参考 https://github.com/xiaorouji/openwrt-passwall/blob/packages/naiveproxy/Makefile 修改naive的代码版本为 v116.0.5845.92-2

# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2021 ImmortalWrt.org

include $(TOPDIR)/rules.mk

PKG_NAME:=naiveproxy
PKG_VERSION:=116.0.5845.92-2
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/klzgrad/naiveproxy/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=1e027730e9abdb9cf02eb4e0b831072f437c66647a9df4389dbecd7364614592

PKG_LICENSE:=BSD 3-Clause
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>

PKG_BUILD_DEPENDS:=gn/host
ifneq ($(wildcard $(TOPDIR)/feeds/packages/devel/ninja/ninja.mk),)
PKG_BUILD_DEPENDS+= ninja/host
endif
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0

ifneq ($(CONFIG_CPU_TYPE)," ")
  CPU_TYPE:=$(word 1, $(subst +," ,$(CONFIG_CPU_TYPE)))
  CPU_SUBTYPE:=$(word 2, $(subst +, ",$(CONFIG_CPU_TYPE)))
  ifeq ($(CPU_SUBTYPE),)
    CPU_SUBTYPE:=""
  endif
else
  CPU_TYPE:=""
  CPU_SUBTYPE:=""
endif

include $(INCLUDE_DIR)/package.mk

define Package/naiveproxy
  SECTION:=net
  CATEGORY:=Network
  SUBMENU:=Web Servers/Proxies
  TITLE:=Make a fortune quietly
  URL:=https://github.com/klzgrad/naiveproxy
  DEPENDS:=@!(arc||armeb||mips||mips64||powerpc||riscv64||TARGET_gemini) +libatomic
endef

define Package/naiveproxy/description
  NaïveProxy uses Chrome's network stack to camouflage traffic with strong
  censorship resistance and low detectability. Reusing Chrome's stack also
  ensures best practices in performance and security.
endef

ifneq ($(CONFIG_CCACHE),)
  export CCACHE_SLOPPINESS=time_macros
  export CCACHE_BASEDIR=$(PKG_BUILD_DIR)/src
  export CCACHE_CPP2=yes
  export naive_ccache_flags=cc_wrapper="$(CCACHE)"
endif

CLANG_VER:=17-init-12166-g7586aeab-3
CLANG_FILE:=clang-llvmorg-$(CLANG_VER).tgz
define Download/CLANG
        URL:=https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64
        URL_FILE:=$(CLANG_FILE)
        FILE:=$(CLANG_FILE)
        HASH:=a3c744bef3e76c985b51f55f2c864f9bd10ac777b88a65a31d6cd85b6dda816b
endef

PGO_VER:=5845-1691722785-bee99d0dc25d78f4193491ad30759d668e3c9311
PGO_FILE:=chrome-linux-$(PGO_VER).profdata
define Download/PGO_PROF
        URL:=https://storage.googleapis.com/chromium-optimization-profiles/pgo_profiles
        URL_FILE:=$(PGO_FILE)
        FILE:=$(PGO_FILE)
        HASH:=e6693bb2d9257a1c0d56c8bbd7713387a47e8d0bea44a5946699ffb393911cb4
endef

define Build/Prepare
        $(call Build/Prepare/Default)

        ( \
                pushd $(PKG_BUILD_DIR)/src ; \
                mkdir -p "chrome/build/pgo_profiles" ; \
                $(CP) "$(DL_DIR)/$(PGO_FILE)" "chrome/build/pgo_profiles" ; \
                mkdir -p "third_party/llvm-build/Release+Asserts" ; \
                $(TAR) -xzf "$(DL_DIR)/$(CLANG_FILE)" -C "third_party/llvm-build/Release+Asserts" ; \
                echo -e "llvmorg-$(CLANG_VER)" > "third_party/llvm-build/Release+Asserts/cr_build_revision" ; \
                popd ; \
        )
endef

define Build/Configure
        ( \
                pushd "$(PKG_BUILD_DIR)/src" ; \
                . ../init_env.sh "$(ARCH)" $(CPU_TYPE) $(CPU_SUBTYPE) "$(TOOLCHAIN_DIR)" ; \
                export naive_flags+=" $$$${naive_ccache_flags}" ; \
                mkdir -p "out" ; \
                gn gen "out/Release" --args="$$$${naive_flags}" --script-executable="$(PYTHON)" ; \
                popd ; \
        )
endef

define Build/Compile
        ninja -C "$(PKG_BUILD_DIR)/src/out/Release" naive
endef

define Package/naiveproxy/install
        $(INSTALL_DIR) $(1)/usr/bin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/out/Release/naive $(1)/usr/bin/naive
endef

$(eval $(call Download,CLANG))
$(eval $(call Download,PGO_PROF))

$(eval $(call BuildPackage,naiveproxy))

编译后的naive为

sha256sum /usr/bin/naive
6b0518f4c77e32129058ff61a2515a9afdd69b9c280d1d97c05f4dce33fcea1c  /usr/bin/naive

我先用默认Release编译的naive客户端产生日志看看吧

klzgrad commented 1 year ago

把/usr/bin/naive也附件上来看看

openips commented 1 year ago

K大 附件是我自己编译的naive 116.0.5845.92 naive.zip

klzgrad commented 1 year ago

你的naive已经strip了symbol,看不了。

https://github.com/klzgrad/naiveproxy/releases/download/v116.0.5845.92-2/naiveproxy-v116.0.5845.92-2-openwrt-x86_64.tar.xz

未strip的应该有8.2MB,strip以后5.9MB

openips commented 1 year ago

收到 已经替换了官方客户端 跑几天试试看能否复现crash

klzgrad commented 10 months ago

未收到继续报告