Crashing net/microsocks if DNS being proxied

Pavel Timofeev timp87 at gmail.com
Sun Aug 9 13:33:40 UTC 2020


 Pavel Timofeev <timp87 at 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 it.
> 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=0x7fffdfffd238,
> name=0x7fffdfffda20 "freebsd.org",
>
>
>     pai=0x7fffdfffd5a0, cur=0x7fffdfffd240) at
> /usr/src/lib/libc/net/getaddrinfo.c:2476
>
>
> 2476    {
> [Current thread is 1 (LWP 100579)]
>
> (gdb) bt
> #0  0x00000008003e5467 in _getht (hostf=0x7fffdfffd238,
> name=0x7fffdfffda20 "freebsd.org", pai=0x7fffdfffd5a0,
> cur=0x7fffdfffd240) at /usr/src/lib/libc/net/getaddrinfo.c:2476
> #1  0x00000008003e4990 in _files_getaddrinfo (rv=0x7fffdfffd670,
> cb_data=<optimized out>, ap=<optimized out>) at
> /usr/src/lib/libc/net/getaddrinfo.c:2515
> #2  0x000000080040df6c in _nsdispatch (retval=0x7fffdfffd670,
> disp_tab=0x8004482e0, database=<optimized out>, method_name=0x8002bafb7
> "getaddrinfo", defaults=<optimized out>)
>     at /usr/src/lib/libc/net/nsdispatch.c:716
> #3  0x00000008003e30b3 in explore_fqdn (pai=0x1, hostname=<optimized out>,
> servname=0x7fffdfffd860 "80", res=<optimized out>) at
> /usr/src/lib/libc/net/getaddrinfo.c:1945
> #4  getaddrinfo (hostname=<optimized out>, servname=0x7fffdfffd860 "80",
> hints=<optimized out>, res=0x7fffdfffda18) at
> /usr/src/lib/libc/net/getaddrinfo.c:576
> #5  0x00000000002037f6 in resolve (host=0x7fffdfffda20 "freebsd.org",
> port=80, addr=0x7fffdfffda18) at server.c:14
> #6  0x00000000002030e8 in connect_socks_target (buf=0x7fffdfffdba0
> "\005\001", n=18, client=0x800689038) at sockssrv.c:136
> #7  0x00000000002029e3 in clientthread (data=0x800689030) at sockssrv.c:317
> #8  0x000000080025a736 in thread_start (curthread=0x800683500) 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=0x7fffdfffda20 "freebsd.org",
> port=80, addr=0x7fffdfffda18) at server.c:14
> 14              return getaddrinfo(host, port_buf, &hints, addr);
> (gdb) p host
> $1 = 0x7fffdfffda20 "freebsd.org"
> (gdb) p port_buf
> $2 = "80\000\000\b\000\000"
> (gdb) p hints
> $3 = {ai_flags = 1, ai_family = 0, ai_socktype = 1, ai_protocol = 0,
> ai_addrlen = 0, ai_canonname = 0x0, ai_addr = 0x0, ai_next = 0x0}
> (gdb) p *addr
> $4 = (struct addrinfo *) 0x0
> (gdb) list
> 9                       .ai_socktype = SOCK_STREAM,
> 10                      .ai_flags = 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 != 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 which
way to dig probably.


More information about the freebsd-ports mailing list