From owner-freebsd-ports@freebsd.org Mon Aug 10 08:04:52 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 BBFBA379CAC for ; Mon, 10 Aug 2020 08:04:52 +0000 (UTC) (envelope-from timp87@gmail.com) Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) (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 4BQ7mM3VS0z3gSr for ; Mon, 10 Aug 2020 08:04:51 +0000 (UTC) (envelope-from timp87@gmail.com) Received: by mail-ej1-x62d.google.com with SMTP id g19so8405975ejc.9 for ; Mon, 10 Aug 2020 01:04:51 -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=2mTm4kEWY+ZXijk2TlHJxegcFaBLExCFVIR2eRDFe28=; b=aMzRtDP0YO9nsY8Ce2+IN94JsE0dw80vrcnZt2xOIbrS6VrM9RHoEdje9RyfUWT0a+ 3tCqphC8fj7rCc+yG6V94XLm7GKNvSr4ZZj+JuKi2bCuDQRXo6VE5rqEwI+rFgh1gVHD U1/Ra7UJakyZqOK8FPv7c252wLFkgf9UVHFUgFTrZHamCfDqicWvHu01SDY2uFVNi1py mFm0SKYjxcnWF9iod03i657v5xAoAK35SRq+L6UfoPkTVqqpH24EC8lHX3m8gXc1aaOa 7ShTxhs7v8Z8v696aUwnwiTUQD/wENMzm2cTX6/qsBYqPQBytaNyqo6mGCpvQT4LyTJw WBng== 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=2mTm4kEWY+ZXijk2TlHJxegcFaBLExCFVIR2eRDFe28=; b=hlvaChnjLykOVggp81ValypKQ8paGNrFsNWcQAJGjrGmXz2ePoGIIawCAKvKZEWYZd UDZqm8JpXbSI3MD/tCCh9uKFHMdmtzddfPPRL0G0CRTd1+6HZAgS+dVnl/mBgy7KHagz kaj+FgDukOkBmzevvxufnuytkUL4wNsT+Ape4TEQZE4WTLECJSnU4gDE/E6fbrjWu85d 57NWZdezJ5yxIPMY70v21FHgoyyH+IF7KmRK0CI3fs/Y9iOxKP5i5qitfG10OcV/CrcQ z3SfBVQN35On738lr0RCc4T8JtQ/bMLqkEwWGzzhisespyLeS7dSHt+RxSyugs06+grp X/bQ== X-Gm-Message-State: AOAM5303w9uszl/P4MsFJJn7112IBeUX3sqt2uFpNmX+n9AocvDb74fJ uoufl9iHkVO0GFYZbyGR6bje2PSaJzQcUwCxyhdlYzrRQnw= X-Google-Smtp-Source: ABdhPJxDUUSiDRjqRdkna7rjGkpKhiXyq5nZ+apNYtMCpHjUmVk/fZCpcpxChfw55ZE11CdPK8pwncwexd4NlWftJJw= X-Received: by 2002:a17:906:248f:: with SMTP id e15mr19465996ejb.296.1597046689761; Mon, 10 Aug 2020 01:04:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Pavel Timofeev Date: Mon, 10 Aug 2020 11:02:09 +0300 Message-ID: Subject: Re: Crashing net/microsocks if DNS being proxied To: ports-list freebsd X-Rspamd-Queue-Id: 4BQ7mM3VS0z3gSr X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=aMzRtDP0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of timp87@gmail.com designates 2a00:1450:4864:20::62d as permitted sender) smtp.mailfrom=timp87@gmail.com X-Spamd-Result: default: False [-2.39 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.03)[-1.033]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; FREEMAIL_FROM(0.00)[gmail.com]; 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::62d:from]; NEURAL_HAM_SHORT(-0.52)[-0.516]; TO_MATCH_ENVRCPT_ALL(0.00)[]; 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" Content-Transfer-Encoding: quoted-printable 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: Mon, 10 Aug 2020 08:04:52 -0000 =D0=B2=D1=81, 9 =D0=B0=D0=B2=D0=B3. 2020 =D0=B3. =D0=B2 16:30, Pavel Timofe= ev : > > 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 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: >> >> . >> >> 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=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, ap=3D) at >> /usr/src/lib/libc/net/getaddrinfo.c:2515 >> #2 0x000000080040df6c in _nsdispatch (retval=3D0x7fffdfffd670, >> disp_tab=3D0x8004482e0, database=3D, method_name=3D0x8002= bafb7 >> "getaddrinfo", defaults=3D) >> at /usr/src/lib/libc/net/nsdispatch.c:716 >> #3 0x00000008003e30b3 in explore_fqdn (pai=3D0x1, hostname=3D> out>, servname=3D0x7fffdfffd860 "80", res=3D) at >> /usr/src/lib/libc/net/getaddrinfo.c:1945 >> #4 getaddrinfo (hostname=3D, servname=3D0x7fffdfffd860 "= 80", >> hints=3D, 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.