From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-05-20 09:45:39
Hi David,
The following patchset contains nftables fixes for your net tree, they
are:
1) Fix crash when using the goto action in a rule by making sure that
we always fall back on the base chain. Otherwise, this may try to
access the counter memory area of non-base chains, which does not
exists.
2) Fix several aspects of the rule tracing that are currently broken:
* Reset rule number counter after goto/jump action, otherwise the
tracing reports a bogus rule number.
* Fix tracing of the goto action.
* Fix bogus rule number counter after goto.
* Fix missing return trace after finishing the walk through the
non-base chain.
* Fix missing trace when matching non-terminal rule.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks!
----------------------------------------------------------------
The following changes since commit a8951d5814e1373807a94f79f7ccec7041325470:
netfilter: Fix potential use after free in ip6_route_me_harder() (2014-05-09 02:36:39 +0200)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git master
for you to fetch changes up to 3b084e99a3fabaeb0f9c65a0806cde30f0b2835e:
netfilter: nf_tables: fix trace of matching non-terminal rule (2014-05-15 19:44:20 +0200)
----------------------------------------------------------------
Pablo Neira Ayuso (6):
netfilter: nf_tables: reset rule number counter after jump and goto
netfilter: nf_tables: fix goto action
netfilter: nf_tables: fix tracing of the goto action
netfilter: nf_tables: fix bogus rulenum after goto action
netfilter: nf_tables: fix missing return trace at the end of non-base chain
netfilter: nf_tables: fix trace of matching non-terminal rule
net/netfilter/nf_tables_core.c | 49 +++++++++++++++++++---------------------
1 file changed, 23 insertions(+), 26 deletions(-)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-05-20 09:45:21
Otherwise we start incrementing the rule number counter from the
previous chain iteration.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
@@ -171,8 +171,12 @@ next_rule:jumpstack[stackptr].rule=rule;jumpstack[stackptr].rulenum=rulenum;stackptr++;-/* fall through */+chain=data[NFT_REG_VERDICT].chain;+gotodo_chain;caseNFT_GOTO:+if(unlikely(pkt->skb->nf_trace))+nft_trace_packet(pkt,chain,rulenum,NFT_TRACE_RULE);+chain=data[NFT_REG_VERDICT].chain;gotodo_chain;caseNFT_RETURN:
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-05-20 09:45:24
After returning from the chain that we just went to with no matchings,
we get a bogus rule number in the trace. To fix this, we would need
to iterate over the list of remaining rules in the chain to update the
rule number counter.
Patrick suggested to set this to the maximum value since the default
base chain policy is the very last action when the processing the base
chain is over.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-05-20 09:45:25
Display "return" for implicit rule at the end of a non-base chain,
instead of when popping chain from the stack.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_core.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
@@ -182,18 +182,16 @@ next_rule:caseNFT_RETURN:if(unlikely(pkt->skb->nf_trace))nft_trace_packet(pkt,chain,rulenum,NFT_TRACE_RETURN);--/* fall through */+break;caseNFT_CONTINUE:+if(unlikely(pkt->skb->nf_trace&&!(chain->flags&NFT_BASE_CHAIN)))+nft_trace_packet(pkt,chain,++rulenum,NFT_TRACE_RETURN);break;default:WARN_ON(1);}if(stackptr>0){-if(unlikely(pkt->skb->nf_trace))-nft_trace_packet(pkt,chain,++rulenum,NFT_TRACE_RETURN);-stackptr--;chain=jumpstack[stackptr].chain;rule=jumpstack[stackptr].rule;
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-05-20 09:45:42
This patch fixes a crash when trying to access the counters and the
default chain policy from the non-base chain that we have reached
via the goto chain. Fix this by falling back on the original base
chain after returning from the custom chain.
While fixing this, kill the inline function to account chain statistics
to improve source code readability.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_core.c | 28 ++++++++++------------------
1 file changed, 10 insertions(+), 18 deletions(-)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-05-20 09:45:45
Add the corresponding trace if we have a full match in a non-terminal
rule. Note that the traces will look slightly different than in
x_tables since the log message after all expressions have been
evaluated (contrary to x_tables, that emits it before the target
action). This manifests in two differences in nf_tables wrt. x_tables:
1) The rule that enables the tracing is included in the trace.
2) If the rule emits some log message, that is shown before the
trace log message.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
@@ -144,8 +144,10 @@ next_rule:switch(data[NFT_REG_VERDICT].verdict){caseNFT_BREAK:data[NFT_REG_VERDICT].verdict=NFT_CONTINUE;-/* fall through */+continue;caseNFT_CONTINUE:+if(unlikely(pkt->skb->nf_trace))+nft_trace_packet(pkt,chain,rulenum,NFT_TRACE_RULE);continue;}break;