Date: Mon, 10 Aug 2020 11:02:09 +0300 From: Pavel Timofeev <timp87@gmail.com> To: ports-list freebsd <freebsd-ports@freebsd.org> Subject: Re: Crashing net/microsocks if DNS being proxied Message-ID: <CAAoTqfs_R%2Bwc3=rf06FnW0YLDCCHTW-O5a4A-rUaUeZfvUUQxw@mail.gmail.com> In-Reply-To: <CAAoTqfvqAq5p_uXx35PSSWK-14zxXK4SdJ=b1fGhfW_%2BS443Gw@mail.gmail.com> References: <CAAoTqftaQsiUhvR9tG13QpL6Reris1B6Z1wr8srMnPDUadtFPA@mail.gmail.com> <CAAoTqfvqAq5p_uXx35PSSWK-14zxXK4SdJ=b1fGhfW_%2BS443Gw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
=D0=B2=D1=81, 9 =D0=B0=D0=B2=D0=B3. 2020 =D0=B3. =D0=B2 16:30, Pavel Timofe= ev <timp87@gmail.com>: > > Pavel Timofeev <timp87@gmail.com>: > >> Hello >> >> I'd like to take advantage of net/microsocks port - a small SOCKSv5 >> server. >> It's v1.0.1 (https://github.com/rofl0r/microsocks/tree/v1.0.1) under >> 12.1 RELEASE amd64. >> It works OK with firefox until I ask firefox to proxy DNS via socks also= . >> It cashes after getaddrinfo() call. >> I have quite poor C knowledge and I can't understand what's wrong with i= t. >> Parameters passed to getaddrinfo() looks OK >> Can anybody advise where to look at also? >> >> >> >> $ gdb92 microsocks microsocks.core >> >> >> GNU gdb (GDB) 9.2 [GDB v9.2 for FreeBSD] >> >> Copyright (C) 2020 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-portbld-freebsd12.1". >> >> >> Type "show configuration" for configuration details. >> >> For bug reporting instructions, please see: >> >> <http://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 microsocks... >> >> [New LWP 100579] >> [New LWP 100347] >> Core was generated by `./microsocks'. >> >> Program terminated with signal SIGSEGV, Segmentation fault. >> >> >> #0 0x00000008003e5467 in _getht (hostf=3D0x7fffdfffd238, >> name=3D0x7fffdfffda20 "freebsd.org", >> >> >> pai=3D0x7fffdfffd5a0, cur=3D0x7fffdfffd240) at >> /usr/src/lib/libc/net/getaddrinfo.c:2476 >> >> >> 2476 { >> [Current thread is 1 (LWP 100579)] >> >> (gdb) bt >> #0 0x00000008003e5467 in _getht (hostf=3D0x7fffdfffd238, >> name=3D0x7fffdfffda20 "freebsd.org", pai=3D0x7fffdfffd5a0, >> cur=3D0x7fffdfffd240) at /usr/src/lib/libc/net/getaddrinfo.c:2476 >> #1 0x00000008003e4990 in _files_getaddrinfo (rv=3D0x7fffdfffd670, >> cb_data=3D<optimized out>, ap=3D<optimized out>) at >> /usr/src/lib/libc/net/getaddrinfo.c:2515 >> #2 0x000000080040df6c in _nsdispatch (retval=3D0x7fffdfffd670, >> disp_tab=3D0x8004482e0, database=3D<optimized out>, method_name=3D0x8002= bafb7 >> "getaddrinfo", defaults=3D<optimized out>) >> at /usr/src/lib/libc/net/nsdispatch.c:716 >> #3 0x00000008003e30b3 in explore_fqdn (pai=3D0x1, hostname=3D<optimized >> out>, servname=3D0x7fffdfffd860 "80", res=3D<optimized out>) at >> /usr/src/lib/libc/net/getaddrinfo.c:1945 >> #4 getaddrinfo (hostname=3D<optimized out>, servname=3D0x7fffdfffd860 "= 80", >> hints=3D<optimized out>, res=3D0x7fffdfffda18) at >> /usr/src/lib/libc/net/getaddrinfo.c:576 >> #5 0x00000000002037f6 in resolve (host=3D0x7fffdfffda20 "freebsd.org", >> port=3D80, addr=3D0x7fffdfffda18) at server.c:14 >> #6 0x00000000002030e8 in connect_socks_target (buf=3D0x7fffdfffdba0 >> "\005\001", n=3D18, client=3D0x800689038) at sockssrv.c:136 >> #7 0x00000000002029e3 in clientthread (data=3D0x800689030) at >> sockssrv.c:317 >> #8 0x000000080025a736 in thread_start (curthread=3D0x800683500) at >> /usr/src/lib/libthr/thread/thr_create.c:292 >> #9 0x0000000000000000 in ?? () >> Backtrace stopped: Cannot access memory at address 0x7fffdfffe000 >> (gdb) f 5 >> #5 0x00000000002037f6 in resolve (host=3D0x7fffdfffda20 "freebsd.org", >> port=3D80, addr=3D0x7fffdfffda18) at server.c:14 >> 14 return getaddrinfo(host, port_buf, &hints, addr); >> (gdb) p host >> $1 =3D 0x7fffdfffda20 "freebsd.org" >> (gdb) p port_buf >> $2 =3D "80\000\000\b\000\000" >> (gdb) p hints >> $3 =3D {ai_flags =3D 1, ai_family =3D 0, ai_socktype =3D 1, ai_protocol = =3D 0, >> ai_addrlen =3D 0, ai_canonname =3D 0x0, ai_addr =3D 0x0, ai_next =3D 0x0= } >> (gdb) p *addr >> $4 =3D (struct addrinfo *) 0x0 >> (gdb) list >> 9 .ai_socktype =3D SOCK_STREAM, >> 10 .ai_flags =3D AI_PASSIVE, >> 11 }; >> 12 char port_buf[8]; >> 13 snprintf(port_buf, sizeof port_buf, "%u", port); >> 14 return getaddrinfo(host, port_buf, &hints, addr); >> 15 } >> 16 >> 17 int server_bindtoip(const struct server *server, int fd) { >> 18 if(server->bindaddr.v4.sin_family !=3D AF_UNSPEC) >> >> >> >> However, it works OK under Linux no matter if DNS proxied or not. >> Thank you! >> > > > > I'm not asking for full debug session, just a few clues or an advice whic= h > way to dig probably. > Ahh, it fiddles with PTHREAD_STACK_MIN. It's the root cause.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAAoTqfs_R%2Bwc3=rf06FnW0YLDCCHTW-O5a4A-rUaUeZfvUUQxw>