Re: Crashing net/microsocks if DNS being proxied

2020-08-10 Thread Pavel Timofeev
вс, 9 авг. 2020 г. в 16:30, Pavel Timofeev :

>
>  Pavel Timofeev :
>
>> 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:
>>
>> .
>>
>> Find the GDB manual and other documentation resources online at:
>>
>>
>> .
>>
>>
>>
>> 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  0x0008003e5467 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  0x0008003e5467 in _getht (hostf=0x7fffdfffd238,
>> name=0x7fffdfffda20 "freebsd.org", pai=0x7fffdfffd5a0,
>> cur=0x7fffdfffd240) at /usr/src/lib/libc/net/getaddrinfo.c:2476
>> #1  0x0008003e4990 in _files_getaddrinfo (rv=0x7fffdfffd670,
>> cb_data=, ap=) at
>> /usr/src/lib/libc/net/getaddrinfo.c:2515
>> #2  0x00080040df6c in _nsdispatch (retval=0x7fffdfffd670,
>> disp_tab=0x8004482e0, database=, method_name=0x8002bafb7
>> "getaddrinfo", defaults=)
>> at /usr/src/lib/libc/net/nsdispatch.c:716
>> #3  0x0008003e30b3 in explore_fqdn (pai=0x1, hostname=> out>, servname=0x7fffdfffd860 "80", res=) at
>> /usr/src/lib/libc/net/getaddrinfo.c:1945
>> #4  getaddrinfo (hostname=, servname=0x7fffdfffd860 "80",
>> hints=, res=0x7fffdfffda18) at
>> /usr/src/lib/libc/net/getaddrinfo.c:576
>> #5  0x002037f6 in resolve (host=0x7fffdfffda20 "freebsd.org",
>> port=80, addr=0x7fffdfffda18) at server.c:14
>> #6  0x002030e8 in connect_socks_target (buf=0x7fffdfffdba0
>> "\005\001", n=18, client=0x800689038) at sockssrv.c:136
>> #7  0x002029e3 in clientthread (data=0x800689030) at
>> sockssrv.c:317
>> #8  0x00080025a736 in thread_start (curthread=0x800683500) at
>> /usr/src/lib/libthr/thread/thr_create.c:292
>> #9  0x in ?? ()
>> Backtrace stopped: Cannot access memory at address 0x7fffdfffe000
>> (gdb) f 5
>> #5  0x002037f6 in resolve (host=0x7fffdfffda20 "freebsd.org",
>> port=80, addr=0x7fffdfffda18) at server.c:14
>> 14  return getaddrinfo(host, port_buf, , 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, , 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.
>


Ahh, it fiddles with PTHREAD_STACK_MIN. It's the root cause.
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: Crashing net/microsocks if DNS being proxied

2020-08-09 Thread Pavel Timofeev
 Pavel Timofeev :

> 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:
>
> .
>
> Find the GDB manual and other documentation resources online at:
>
>
> .
>
>
>
> 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  0x0008003e5467 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  0x0008003e5467 in _getht (hostf=0x7fffdfffd238,
> name=0x7fffdfffda20 "freebsd.org", pai=0x7fffdfffd5a0,
> cur=0x7fffdfffd240) at /usr/src/lib/libc/net/getaddrinfo.c:2476
> #1  0x0008003e4990 in _files_getaddrinfo (rv=0x7fffdfffd670,
> cb_data=, ap=) at
> /usr/src/lib/libc/net/getaddrinfo.c:2515
> #2  0x00080040df6c in _nsdispatch (retval=0x7fffdfffd670,
> disp_tab=0x8004482e0, database=, method_name=0x8002bafb7
> "getaddrinfo", defaults=)
> at /usr/src/lib/libc/net/nsdispatch.c:716
> #3  0x0008003e30b3 in explore_fqdn (pai=0x1, hostname=,
> servname=0x7fffdfffd860 "80", res=) at
> /usr/src/lib/libc/net/getaddrinfo.c:1945
> #4  getaddrinfo (hostname=, servname=0x7fffdfffd860 "80",
> hints=, res=0x7fffdfffda18) at
> /usr/src/lib/libc/net/getaddrinfo.c:576
> #5  0x002037f6 in resolve (host=0x7fffdfffda20 "freebsd.org",
> port=80, addr=0x7fffdfffda18) at server.c:14
> #6  0x002030e8 in connect_socks_target (buf=0x7fffdfffdba0
> "\005\001", n=18, client=0x800689038) at sockssrv.c:136
> #7  0x002029e3 in clientthread (data=0x800689030) at sockssrv.c:317
> #8  0x00080025a736 in thread_start (curthread=0x800683500) at
> /usr/src/lib/libthr/thread/thr_create.c:292
> #9  0x in ?? ()
> Backtrace stopped: Cannot access memory at address 0x7fffdfffe000
> (gdb) f 5
> #5  0x002037f6 in resolve (host=0x7fffdfffda20 "freebsd.org",
> port=80, addr=0x7fffdfffda18) at server.c:14
> 14  return getaddrinfo(host, port_buf, , 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, , 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.
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Crashing net/microsocks if DNS being proxied

2020-08-06 Thread Pavel Timofeev
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 


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:

.

Find the GDB manual and other documentation resources online at:


.



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  0x0008003e5467 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  0x0008003e5467 in _getht (hostf=0x7fffdfffd238, name=0x7fffdfffda20
"freebsd.org", pai=0x7fffdfffd5a0, cur=0x7fffdfffd240) at
/usr/src/lib/libc/net/getaddrinfo.c:2476
#1  0x0008003e4990 in _files_getaddrinfo (rv=0x7fffdfffd670,
cb_data=, ap=) at
/usr/src/lib/libc/net/getaddrinfo.c:2515
#2  0x00080040df6c in _nsdispatch (retval=0x7fffdfffd670,
disp_tab=0x8004482e0, database=, method_name=0x8002bafb7
"getaddrinfo", defaults=)
at /usr/src/lib/libc/net/nsdispatch.c:716
#3  0x0008003e30b3 in explore_fqdn (pai=0x1, hostname=,
servname=0x7fffdfffd860 "80", res=) at
/usr/src/lib/libc/net/getaddrinfo.c:1945
#4  getaddrinfo (hostname=, servname=0x7fffdfffd860 "80",
hints=, res=0x7fffdfffda18) at
/usr/src/lib/libc/net/getaddrinfo.c:576
#5  0x002037f6 in resolve (host=0x7fffdfffda20 "freebsd.org",
port=80, addr=0x7fffdfffda18) at server.c:14
#6  0x002030e8 in connect_socks_target (buf=0x7fffdfffdba0
"\005\001", n=18, client=0x800689038) at sockssrv.c:136
#7  0x002029e3 in clientthread (data=0x800689030) at sockssrv.c:317
#8  0x00080025a736 in thread_start (curthread=0x800683500) at
/usr/src/lib/libthr/thread/thr_create.c:292
#9  0x in ?? ()
Backtrace stopped: Cannot access memory at address 0x7fffdfffe000
(gdb) f 5
#5  0x002037f6 in resolve (host=0x7fffdfffda20 "freebsd.org",
port=80, addr=0x7fffdfffda18) at server.c:14
14  return getaddrinfo(host, port_buf, , 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, , 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!
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"