netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Thomas Haller <thaller@redhat.com>
Cc: NetFilter <netfilter-devel@vger.kernel.org>
Subject: Re: [nft PATCH v4 2/6] src: add input flag NFT_CTX_INPUT_NO_DNS to avoid blocking
Date: Wed, 16 Aug 2023 18:01:59 +0200	[thread overview]
Message-ID: <ZNzy9+OPzBiYVnvT@orbyte.nwl.cc> (raw)
In-Reply-To: <7f3848f6d52a2521df8bd1ee01b2fdb0af9b57a1.camel@redhat.com>

On Thu, Aug 10, 2023 at 10:43:38AM +0200, Thomas Haller wrote:
> Hi Phil,
> 
> On Thu, 2023-08-10 at 09:45 +0200, Phil Sutter wrote:
> > On Wed, Aug 09, 2023 at 09:17:36PM +0200, Thomas Haller wrote:
> > 
> > 
> > > 
> > > It seems prudent that libnftables provides a mode of operation so
> > > that
> > > it doesn't block the calling application. Otherwise, it is a
> > > problem
> > > for applications that care about that.
> > 
> > Hmm. In that case, one might also have to take care of calls to
> > getprotobyname() and maybe others (getaddrinfo()?). Depending on
> > nsswitch.conf it may block, too, right?
> 
> getaddrinfo() is avoided by NFT_CTX_INPUT_NO_DNS.
> 
> ... except at one place in `inet_service_type_parse()`, where
> getaddrinfo() is used to parse the service. I don't think that has any
> reason to block(*), has it?.
> 
> getprotobyname() also should not block(*)  as it merely reads
> /etc/protocols (in musl it's even hard-coded).
> 
> 
> (*) reading from /etc or talking netlink to kernel is sufficiently fast
> so I consider it "non-blocking".

I think these functions support /etc/nsswitch.conf, so feeding them
names is not necessarily only a local lookup. But anyway, this doesn't
quite matter: /etc/nsswitch.conf is in control of the user, just as is
the input fed into run_cmd_from_*(). So for the sake of the discussion
here, it doesn't make a difference.

> In the first version, the flag was called NFT_CTX_NO_BLOCK. It had the
> goal to avoid any significant blocking. The flag got renamed to
> NFT_CTX_INPUT_NO_DNS, which on the surface has the different goal to
> only accept plain IP addresses.
> 
> If there are other places that still can block, they should be
> identified and addressed. But that's then separate from NO_DNS flag.

Yes, I believe the various name to number lookups are the only potential
blockers.

> > > > > And that the application doesn't make a mistake with that
> > > > > ([1]).
> > > > > 
> > > > > [1]
> > > > > https://github.com/firewalld/firewalld/commit/4db89e316f2d60f3cf856a7025a96a61e40b1e5a
> > > > 
> > > > This is just a bug in firewall-cmd, missing to convert ranges
> > > > into
> > > > JSON
> > > > format. I don't see the benefit for users which no longer may use
> > > > host
> > > > names in that spot.
> > > 
> > > Which spot do you mean? /sbin/nft is not affected, unless it opts-
> > > in to
> > > the new flag. firewalld never supported hostnames at that spot
> > > anyway
> > > (or does it?).
> > 
> > I'm pretty sure it does, albeit maybe not officially.
> 
> That would be important to verify. I will check, thank you.

Did you find time for it already?

Cheers, Phil

  reply	other threads:[~2023-08-16 16:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03 19:35 [nft PATCH v4 0/6] add input flags and "no-dns"/"json" flags Thomas Haller
2023-08-03 19:35 ` [nft PATCH v4 1/6] src: add input flags for nft_ctx Thomas Haller
2023-08-16 15:49   ` Phil Sutter
2023-08-03 19:35 ` [nft PATCH v4 2/6] src: add input flag NFT_CTX_INPUT_NO_DNS to avoid blocking Thomas Haller
2023-08-08 13:24   ` Phil Sutter
2023-08-08 20:05     ` Thomas Haller
2023-08-09 10:20       ` Phil Sutter
2023-08-09 19:17         ` Thomas Haller
2023-08-10  7:45           ` Phil Sutter
2023-08-10  8:43             ` Thomas Haller
2023-08-16 16:01               ` Phil Sutter [this message]
2023-08-18  9:45                 ` Thomas Haller
2023-08-16 16:02   ` Phil Sutter
2023-08-03 19:35 ` [nft PATCH v4 3/6] src: add input flag NFT_CTX_INPUT_JSON to enable JSON parsing Thomas Haller
2023-08-16 16:02   ` Phil Sutter
2023-08-03 19:35 ` [nft PATCH v4 4/6] py: fix exception during cleanup of half-initialized Nftables Thomas Haller
2023-08-16 16:03   ` Phil Sutter
2023-08-03 19:35 ` [nft PATCH v4 5/6] py: extract flags helper functions for set_debug()/get_debug() Thomas Haller
2023-08-16 16:04   ` Phil Sutter
2023-08-03 19:35 ` [nft PATCH v4 6/6] py: add Nftables.{get,set}_input() API Thomas Haller
2023-08-08 14:04   ` Phil Sutter
2023-08-08 20:07     ` Thomas Haller
2023-08-16 16:10   ` Phil Sutter
2023-08-18  9:45     ` Thomas Haller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZNzy9+OPzBiYVnvT@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=thaller@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).