netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fernando Fernandez Mancera <fmancera@suse.de>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft v2] support for afl++ (american fuzzy lop++) fuzzer
Date: Mon, 20 Oct 2025 16:11:43 +0200	[thread overview]
Message-ID: <a2686aa3-adc4-4684-9442-ab4ad9654c69@suse.de> (raw)
In-Reply-To: <aPTzD7qoSIQ5AXB-@strlen.de>



On 10/19/25 4:17 PM, Florian Westphal wrote:
>> In addition I noticed that when a kernel splat happens the ruleset that
>> triggered it isn't saved anywhere, it would be nice to save them so we have
>> a reproducer right away.
> 
> I had such code but removed it for this version.
> 
> I can send a followup patch to re-add it but I think that it is better
> for kernel fuzzing to extend knft acordingly, as nft is restricted by
> the input grammar wrt. the nonsense that it can create.
> 

That is fine for me, I still have pending to try knft which I might do 
this week if I have time. If we do not want to save which ruleset 
generated the kernel splat I would drop netlink-rw mode completely..

>> I have a server at home that I am not using.. I would love to automate a
>> script to run this in multiple VMs and generate reports :)
> 
> Yes, that would be good.  Note that I still primarily use it with
> netlink-ro mode to not exercise he kernel, its easy to make graph
> validation (or abort path) take very long to finish.
> 
> There is still a patch series in the queue to limit jumps in nftables
> and I did not yet have time in looking at the abort path, Its simply not
> an issue for normal cases (you assume the input is going to be
> committed...).  But for faster netlink-rw/knft fuzzing it would make
> sense to look into async abort (like we do for commit cleanup).
> 

Yes, it seems we found the same issue. I do not have a solution on the 
control plane although I was about to send this patch for data plane.

diff --git a/net/netfilter/nf_tables_core.c b/net/netfilter/nf_tables_core.c
index 6557a4018c09..ddc4943d082c 100644
--- a/net/netfilter/nf_tables_core.c
+++ b/net/netfilter/nf_tables_core.c
@@ -251,10 +251,10 @@ nft_do_chain(struct nft_pktinfo *pkt, void *priv)
  {
         const struct nft_chain *chain = priv, *basechain = chain;
         const struct net *net = nft_net(pkt);
+       unsigned int stackptr = 0, jumps = 0;
         const struct nft_expr *expr, *last;
         const struct nft_rule_dp *rule;
         struct nft_regs regs;
-       unsigned int stackptr = 0;
         struct nft_jumpstack jumpstack[NFT_JUMP_STACK_SIZE];
         bool genbit = READ_ONCE(net->nft.gencursor);
         struct nft_rule_blob *blob;
@@ -314,6 +314,9 @@ nft_do_chain(struct nft_pktinfo *pkt, void *priv)

         switch (regs.verdict.code) {
         case NFT_JUMP:
+               jumps++;
+               if (WARN_ON_ONCE(jumps > 256))
+                       return NF_DROP;
                 if (WARN_ON_ONCE(stackptr >= NFT_JUMP_STACK_SIZE))
                         return NF_DROP;
                 jumpstack[stackptr].rule = nft_rule_next(rule);

Currently with enough jumps chained together and traffic generated, CPU 
can get stuck on nft_do_chain() triggering a kernel splat. If there is a 
solution on data plane it would be much better than this of course.

  reply	other threads:[~2025-10-20 14:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-17 11:51 [PATCH nft v2] support for afl++ (american fuzzy lop++) fuzzer Florian Westphal
2025-10-19  9:34 ` Fernando Fernandez Mancera
2025-10-19 14:17   ` Florian Westphal
2025-10-20 14:11     ` Fernando Fernandez Mancera [this message]
2025-10-20 14:24       ` Florian Westphal
2025-10-20 15:23         ` Fernando Fernandez Mancera
2025-10-20 18:35           ` Pablo Neira Ayuso
2025-10-20 19:07             ` Pablo Neira Ayuso
2025-10-20 21:48               ` Pablo Neira Ayuso
2025-10-20 22:20                 ` Florian Westphal
2025-10-20 22:24                   ` Pablo Neira Ayuso
2025-10-20 22: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=a2686aa3-adc4-4684-9442-ab4ad9654c69@suse.de \
    --to=fmancera@suse.de \
    --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 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).