From owner-freebsd-ports@freebsd.org Sun Aug 9 13:33:40 2020 Return-Path: Delivered-To: freebsd-ports@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4AF343B5E8F for ; Sun, 9 Aug 2020 13:33:40 +0000 (UTC) (envelope-from timp87@gmail.com) Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BPg695F1fz44j0 for ; Sun, 9 Aug 2020 13:33:37 +0000 (UTC) (envelope-from timp87@gmail.com) Received: by mail-ej1-x629.google.com with SMTP id qc22so6781194ejb.4 for ; Sun, 09 Aug 2020 06:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=3JfBnjhQ0SGIAvxZW4edVKCkO7DaG4zxVmySqOWJ67E=; b=ueOlDtmjgsaZpgTuTSc1l0Pr+mt7UXk4n8dV6vZGyA/a4FRnnfWffGM9iUSIk6uFP7 AeXJF0QSa+xbewY5OHqHR451NTdMRP4eXVNSgw9g/sEPy6rQ1go0fCcwt18IjpCxSurj /mAWJyuQAzy+kV/+XvyXNLK+5frtvP+MV9i7BnkGVGEpfWvCFmPfsUBrbUO8E9T3BabY 1yD7fueIoK55qnFwlktrz7DrWs2gD6KZUckDhlotRJNDdXgZzfuw8v+4JzGaKBNbJYHI Dqbp46rtA0OFS1Hqj2L4FOrpettDDI1couyrdaCqbtW1JjUQ6YXbX4ZY+B4MOAPY0F/Q 9J3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=3JfBnjhQ0SGIAvxZW4edVKCkO7DaG4zxVmySqOWJ67E=; b=c6dTg0gdHjlGBGeTaJ5Gnt5kLf6AnY+zfAjFSqlPpb8OC4EI3yJ4eKpemdWekNrH48 oEhgs3347NHYxHLceM7hfMAeUel4Ue7gsP5DqOXKd5gKQ/ZVy1V3Vr5gPNNmwnfB+Min FfXLQBUFJhkKWZ+0KdheraZy+eINIDVWD3hRxXe1szjd/ls8T9+Y3xEro0NC3o0ofeza 90xvunAckLUP2+AlYUYLXvGJbRuGwlcyg9No8HYoP6RYmB0obunUa2r7ZJhiBy0tXm1I 153WWW5Bf23qFdZiDJ/OOkzNpJk6nSPgOOk195LsMmj5d3mUtQKWf1z0kCB2+0/wiiKc zrKA== X-Gm-Message-State: AOAM531CPX+aBUuPDJJAWBDMJrxSARV2+DjLpRlzYwtS9Vv6DwWv8nP1 KcZwOGpDP400gaewvznBHDW+kgu8SJofEfq8iW09+HYA X-Google-Smtp-Source: ABdhPJw1fAiMlJh0U/Rg8I+72LDe8cg31TOdc6nf7o3gZA4YSbdt56i5s6f5wFQ3FDcrRON9tNcULNOP3Rx1oN25Amg= X-Received: by 2002:a17:906:70c:: with SMTP id y12mr16495886ejb.231.1596980015188; Sun, 09 Aug 2020 06:33:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Pavel Timofeev Date: Sun, 9 Aug 2020 16:30:56 +0300 Message-ID: Subject: Re: Crashing net/microsocks if DNS being proxied To: ports-list freebsd X-Rspamd-Queue-Id: 4BPg695F1fz44j0 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=ueOlDtmj; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of timp87@gmail.com designates 2a00:1450:4864:20::629 as permitted sender) smtp.mailfrom=timp87@gmail.com X-Spamd-Result: default: False [-2.11 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.06)[-1.061]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-ports@freebsd.org]; NEURAL_HAM_LONG(-0.94)[-0.941]; URI_COUNT_ODD(1.00)[13]; RCPT_COUNT_ONE(0.00)[1]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; MIME_BASE64_TEXT(0.10)[]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::629:from]; NEURAL_HAM_SHORT(-0.21)[-0.209]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Aug 2020 13:33:40 -0000 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 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=, ap=) at > /usr/src/lib/libc/net/getaddrinfo.c:2515 > #2 0x000000080040df6c in _nsdispatch (retval=0x7fffdfffd670, > disp_tab=0x8004482e0, database=, method_name=0x8002bafb7 > "getaddrinfo", defaults=) > at /usr/src/lib/libc/net/nsdispatch.c:716 > #3 0x00000008003e30b3 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 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.