All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next] netfilter: nftables: introduce table ownership
Date: Mon, 1 Feb 2021 13:24:55 +0100	[thread overview]
Message-ID: <20210201122455.GE12443@breakpoint.cc> (raw)
In-Reply-To: <20210127021928.2444-1-pablo@netfilter.org>

Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> A userspace daemon like firewalld might need to monitor for netlink
> updates to detect its ruleset removal by the (global) flush ruleset
> command to ensure ruleset persistence. This adds extra complexity from
> userspace and, for some little time, the firewall policy is not in
> place.
> 
> This patch adds the NFT_MSG_SETOWNER netlink command which allows a
> userspace program to own the table that creates in exclusivity.
> 
> Tables that are owned...
> 
> - can only be updated and removed by the owner, non-owners hit EPERM if
>   they try to update it or remove it.
> - are destroyed when the owner send the NFT_MSG_UNSETOWNER command,
>   or the netlink socket is closed or the process is gone (implicit
>   netlink socket closure).
> - are skipped by the global flush ruleset command.
> - are listed in the global ruleset.
> 
> The userspace process that sends the new NFT_MSG_SETOWNER command need
> to leave open the netlink socket.
> 
> The NFTA_TABLE_OWNER netlink attribute specifies the netlink port ID to
> identify the owner.

At least for systemd use case, there would be a need to allow
add/removal of set elements from other user.

At the moment, table is created by systemd-networkd which will update
the masquerade set.

In case systemd-nspawn is used and configured to expose container
services via dnat that will need to add the translation map:

add table ip io.systemd.nat
add chain ip io.systemd.nat prerouting { type nat hook prerouting priority dstnat + 1; policy accept; }
[..]
# new generation 2 by process 1378 (systemd-network)
add element ip io.systemd.nat masq_saddr { 192.168.159.192/28 }
# new generation 3 by process 1378 (systemd-network)
add element ip io.systemd.nat map_port_ipport { tcp . 2222 : 192.168.159.201 . 22 }
# new generation 4 by process 1512 (systemd-nspawn)

> +struct nft_owner {
> +	struct list_head	list;
> +	possible_net_t		net;
> +	u32			nlpid;
> +};

I don't see why this is needed.
Isn't it enough to record the nlpid in the table and set a flag that the table is
owned by that pid?

> +		    nft_active_genmask(table, genmask)) {
> +			if (nlpid && table->nlpid && table->nlpid != nlpid)
> +				return ERR_PTR(-EPERM);
> +

i.e., (table->flags & OWNED) && table->nlpid != nlpid)?

On netlink sk destruction the owner flag could be cleared or table
could be auto-zapped.

  reply	other threads:[~2021-02-01 12:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27  2:19 [PATCH nf-next] netfilter: nftables: introduce table ownership Pablo Neira Ayuso
2021-02-01 12:24 ` Florian Westphal [this message]
2021-02-01 13:48   ` Pablo Neira Ayuso
2021-02-01 14:13     ` Florian Westphal
  -- strict thread matches above, loose matches on Subject: below --
2021-01-27  1:52 Pablo Neira Ayuso

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=20210201122455.GE12443@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.