Skip to content

Commit

Permalink
netfilter: nfnetlink_queue: un-break NF_REPEAT
Browse files Browse the repository at this point in the history
[ Upstream commit f82777e ]

Only override userspace verdict if the ct hook returns something
other than ACCEPT.

Else, this replaces NF_REPEAT (run all hooks again) with NF_ACCEPT
(move to next hook).

Fixes: 6291b3a ("netfilter: conntrack: convert nf_conntrack_update to netfilter verdicts")
Reported-by: l.6diay@passmail.com
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Florian Westphal authored and gregkh committed Feb 16, 2024
1 parent 383182d commit 3c0c0cf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions net/netfilter/nfnetlink_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,25 @@ static void nfqnl_reinject(struct nf_queue_entry *entry, unsigned int verdict)
if (verdict == NF_ACCEPT ||
verdict == NF_REPEAT ||
verdict == NF_STOP) {
unsigned int ct_verdict = verdict;

rcu_read_lock();
ct_hook = rcu_dereference(nf_ct_hook);
if (ct_hook)
verdict = ct_hook->update(entry->state.net, entry->skb);
ct_verdict = ct_hook->update(entry->state.net, entry->skb);
rcu_read_unlock();

switch (verdict & NF_VERDICT_MASK) {
switch (ct_verdict & NF_VERDICT_MASK) {
case NF_ACCEPT:
/* follow userspace verdict, could be REPEAT */
break;
case NF_STOLEN:
nf_queue_entry_free(entry);
return;
default:
verdict = ct_verdict & NF_VERDICT_MASK;
break;
}

}
nf_reinject(entry, verdict);
}
Expand Down

0 comments on commit 3c0c0cf

Please sign in to comment.