From: Phil Sutter <phil@nwl.cc>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next 0/3] netfilter: nf_tables: reject loads from uninitialized registers
Date: Fri, 5 May 2023 16:14:26 +0200 [thread overview]
Message-ID: <ZFUPQv6IrFKz42sS@orbyte.nwl.cc> (raw)
In-Reply-To: <20230505134655.GC6126@breakpoint.cc>
On Fri, May 05, 2023 at 03:46:55PM +0200, Florian Westphal wrote:
> Phil Sutter <phil@nwl.cc> wrote:
> > On Fri, May 05, 2023 at 01:16:53PM +0200, Florian Westphal wrote:
> > > Keep a per-rule bitmask that tracks registers that have seen a store,
> > > then reject loads when the accessed registers haven't been flagged.
> > >
> > > This changes uabi contract, because we previously allowed this.
> > > Neither nftables nor iptables-nft create such rules.
> >
> > Did you consider keeping this bitmask on a per base-chain level? One had
> > to perform this for each base chain of a table upon each rule change and
> > traverse the tree of chains jumped to from there. I guess the huge
> > overhead disqualifies this, though.
>
> Yes, but its very hard task, because in that case we also need to prove
> that a write *WILL* happen, rather than *might happen*.
>
> Consider:
>
> rule1:
> ip protocol tcp iifname "eth0" ...
> reg1 := ip protocol
> cmp reg1
> reg2 := meta iifname
>
> rule2:
> iifname "eth1" ...
> cmp reg2 "eth0"
>
> rule 2 has to be rejected because reg2 might be unitialized for != tcp.
>
> Even if we can handle this some way, we now also need to revalidate the
> ruleset on deletes, because we'd have to detect when a register write
> we depend on goes away.
Ah, right. I forgot about "partial" rule execution again. Same thing
which broke expression reduction for us.
Maybe one could introduce a "chain optimizer" creating an initial
meta-rule which just populates registers with packet/meta data rules
may need. Not something I would want to rely upon regarding kernel info
leaks, though.
Cheers, Phil
next prev parent reply other threads:[~2023-05-05 14:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-05 11:16 [PATCH nf-next 0/3] netfilter: nf_tables: reject loads from uninitialized registers Florian Westphal
2023-05-05 11:16 ` [PATCH nf-next 1/3] netfilter: nf_tables: pass context structure to nft_parse_register_load Florian Westphal
2023-05-05 11:16 ` [PATCH nf-next 2/3] netfilter: nf_tables: validate register loads never access unitialised registers Florian Westphal
2023-05-30 23:49 ` Pablo Neira Ayuso
2023-05-31 9:51 ` Florian Westphal
2023-05-05 11:16 ` [PATCH nf-next 3/3] netfilter: nf_tables: don't initialize registers in nft_do_chain() Florian Westphal
2023-05-05 13:16 ` [PATCH nf-next 0/3] netfilter: nf_tables: reject loads from uninitialized registers Phil Sutter
2023-05-05 13:46 ` Florian Westphal
2023-05-05 14:14 ` Phil Sutter [this message]
2023-05-05 14:32 ` Pablo Neira Ayuso
2023-05-05 14:51 ` Florian Westphal
2023-05-05 15:34 ` Pablo Neira Ayuso
2023-05-07 11:22 ` Florian Westphal
2023-05-10 7:56 ` Pablo Neira Ayuso
2023-05-10 8:06 ` Florian Westphal
2023-05-10 15:46 ` Florian Westphal
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=ZFUPQv6IrFKz42sS@orbyte.nwl.cc \
--to=phil@nwl.cc \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.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.