From owner-freebsd-net@freebsd.org Sat Jan 9 17:25:59 2021 Return-Path: Delivered-To: freebsd-net@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 2E3294DD247 for ; Sat, 9 Jan 2021 17:25:59 +0000 (UTC) (envelope-from shamaz.mazum@gmail.com) Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) (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 4DCn1f0yNWz3lJy; Sat, 9 Jan 2021 17:25:57 +0000 (UTC) (envelope-from shamaz.mazum@gmail.com) Received: by mail-ot1-x332.google.com with SMTP id q25so12934726otn.10; Sat, 09 Jan 2021 09:25:57 -0800 (PST) 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 :cc; bh=1UXmTGEDr9xUDkQr5cm77vMWx72sVEP/+8W+CZEe70Q=; b=PEcDgdm44vuCrfjOoxwD9DNu38ek3ifAqB2Wzd8LHIC2b/9qozz35fwiK4C4UF2QJm at+RO30V4ScZOYofZtnguRqiS/6a8IhLUGQ3b/DDAkCTfdABaTvCH1RzBazI3fFf5orw 2ogd5Qz1jmQRCjLi4bjQ2k2Gt+doszgPyB4wrOittPzJyjCoFfaSr5XlvjTORECzSViX LPMxObKmEmsejMNq3W9UHLUMGqV1p6bg1HB0+QZGGIvUqV4phy5H3EQDy/p9C/M5pfPJ cVYt2xHak67SILDAun5bRBQzkK8UzZnxHhEgJOn1N5uj9ltDnnuJBqqt13utylUK6z/j Sk3g== 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:cc; bh=1UXmTGEDr9xUDkQr5cm77vMWx72sVEP/+8W+CZEe70Q=; b=DIMSU8PBiWFpDfJtTFkKy2amcFgr2n/gBERBwBbAGZfOszX+RF6QFphM+KJQr0hEhD KlTW7A3ncZFqGGtywjBirVm/8xrItIS0YSSi7feVTyKmCWPk5/pZ8tDYbSc71PdqE9Zg y3zOmBZJt5PI+5/TWDiP/uLnxUGrmgpUYqDRl12NRTkhykGxlc+TjPEm/Af2DrT5c0dG GD8wAp6zXp5YmBzaZ8PxEeF7ryORFNmuTgoKhbtvMXqAiSu93CmNuJPLPuGkmUOfsHMM B/CGkHMA5a2CSylqhFxenYbUdrbKdYtvD4bmv9JreSw3BaxRchxa1Na4BIMExnWE72K+ hUCA== X-Gm-Message-State: AOAM530yZymKQwTEOxso10EjAl93YrKKvCedwT95e2JbIXg16pIKEh3B bFi8YTLoQBgjG1y7m3tr8i0jzb5iBFORO2tjVXcZS+ux2Jtuiw== X-Google-Smtp-Source: ABdhPJwpdjAnoW4KLKAdD15Ub5cCp6uKtOh8ytfrqqsAj2zNuXx2XHmItnBiBYPHD7EO+n0fWxVtcKplp8c+ff8Izo8= X-Received: by 2002:a9d:37c4:: with SMTP id x62mr6499234otb.87.1610213157135; Sat, 09 Jan 2021 09:25:57 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Vasily Postnicov Date: Sat, 9 Jan 2021 20:25:46 +0300 Message-ID: Subject: Re: DNS using Name Service Switch module and Casper To: Mark Johnston Cc: freebsd-net@freebsd.org X-Rspamd-Queue-Id: 4DCn1f0yNWz3lJy X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=PEcDgdm4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of shamazmazum@gmail.com designates 2607:f8b0:4864:20::332 as permitted sender) smtp.mailfrom=shamazmazum@gmail.com X-Spamd-Result: default: False [0.70 / 15.00]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; HAS_ATTACHMENT(0.00)[]; MIME_BASE64_TEXT_BOGUS(1.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; MIME_BASE64_TEXT(0.10)[]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; TAGGED_FROM(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[2607:f8b0:4864:20::332:from]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-csrc]; MIME_BAD_ATTACHMENT(1.60)[c]; NEURAL_SPAM_SHORT(1.00)[1.000]; SPAMHAUS_ZRD(0.00)[2607:f8b0:4864:20::332:from:127.0.2.255]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::332:from]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-net] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jan 2021 17:25:59 -0000 Brilliant! It took me almost a day to dive into ZeroMQ to reassure myself that there is nothing wrong with it. When I tried to write minimal test programs which call fork after pthread_create() in all combinations. When I realized that NSS stub module is what I need. Instructions: 1) Compile NSS stub module: cc -shared -fPIC -pthread -o nss_zerodns.so.1 test.c (Note '.1' at the end). 2) Copy nss_zerodns.so.1 to /usr/local/lib 3) Apply the patch src_sbin_ping_main.c to ping source code. With this patch ping will not quit too early when the initial call to getaddrinfo() fails. 4) Add stub module to /etc/nsswitch.conf: edit 'hosts' line to be 'hosts: files dns zerodns' 5) Ping non-existent host, like 'ping foo.bar' 6) Ping will hang. The child process which it creates cannot be killed even with killall -9 ping =D1=81=D0=B1, 9 =D1=8F=D0=BD=D0=B2. 2021 =D0=B3. =D0=B2 19:46, Mark Johnsto= n : > > On Sat, Jan 09, 2021 at 04:16:49PM +0300, Vasily Postnicov wrote: > > Turns out, if you do not specify either -4 or -6 to ping, unsandboxed > > getaddrinfo() will be called in /usr/src/sbin/ping/main.c, line 139. > > (what's the point in sandboxing then, lol?) This somehow affects > > sandboxing. > > Indeed, that seems to be an issue with the recent merge of ping and > ping6. > > I guess the initial call to getaddrinfo() causes nsswitch.conf to be > parsed and your module is loaded before we fork(). The module is linked > with libthr but obviously ping itself is not. I'm sure this kind of > configuration worked at some point, there might have been a regression. > > If you can provide a stub NSS module that links libthr and demonstrates > the issue, it would be useful. > > > Look at the screenshot, it explains where fork() gets stuck. > > https://photos.app.goo.gl/T1B3Fo1hg6z7r3vZ6 > > And there are no other threads in the process?