From: Fernando Fernandez Mancera <fmancera@suse.de>
To: "Remy D. Farley" <one-d-wide@protonmail.com>,
Florian Westphal <fw@strlen.de>
Cc: "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>
Subject: Re: iptables: zero dereference parsing bitwise operations
Date: Mon, 13 Oct 2025 11:04:28 +0200 [thread overview]
Message-ID: <dae7551c-c18e-46ea-b490-1b7310a40195@suse.de> (raw)
In-Reply-To: <e2mf5Q5IBD50dFQcvIXCNkQCKwghz-hLmCunP33gaZy33srxWrQKdcL1J3GKA8a0H05T6p4kZGFpR910g7JBZusbg_AmEZKPD1UvW_mEheQ=@protonmail.com>
On 10/11/25 10:15 PM, Remy D. Farley wrote:
> On Saturday, October 11th, 2025 at 13:58, Florian Westphal <fw@strlen.de> wrote:
>
>> Remy D. Farley one-d-wide@protonmail.com wrote:
>>
>>> While messing around with manually encoding nftables expressions, I noticed
>>> that iptables binary v1.8.11 segfaults with -L and -D <chain> options, if
>>> there's a rule containing a bitwise operation of a type other than
>>> mask-and-xor. As I understand, iptables and nft tools only generate rules with
>>> mask-xor, though the kernel seems to happily accept other types as well.
>>
>>
>> No, nftables supports this, but iptables does not.
>
>
> Hmm, when I run `nft list ruleset` it terminates successfully, but it does
> report some errors at the end if the rule from the example is present.
>
>> netlink: Error: Invalid source register 0
>> netlink: Error: Bitwise expression has no right-hand expression
>> netlink: Error: Relational expression has no left hand side
>
> But I'm not completely sure whether it's not me incorrectly encoding the rule.
>
Hi Remy, could you share the full output of:
'nft --debug=netlink list ruleset'
This will allow me to understand what is the generated bytecode and an
easy way to reproduce this with libnftnl. I am happy to investigate/fix
this on the nft/libnftnl/kernel side :)
> For some context, that's how it renders the rule:
>
>> chain example-chain {
>> accept
>> }
>
>
>> iptables should not segfault, however. Care to make a patch?
>
>
> Sure. I think it's fine for now to just check for the operation type and
> error with something like "unsupported bitwise operation", like seems to be the
> case with nft tool, since this issue appears to be extremely uncommon, if it
> hasn't been spotted before.
>
next prev parent reply other threads:[~2025-10-13 9:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-10 21:16 iptables: zero dereference parsing bitwise operations Remy D. Farley
2025-10-11 13:58 ` Florian Westphal
2025-10-11 20:15 ` Remy D. Farley
2025-10-12 16:46 ` Florian Westphal
2025-10-13 9:04 ` Fernando Fernandez Mancera [this message]
2025-10-13 11:43 ` Remy D. Farley
2025-10-14 15:14 ` Fernando Fernandez Mancera
2025-10-14 15:29 ` 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=dae7551c-c18e-46ea-b490-1b7310a40195@suse.de \
--to=fmancera@suse.de \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=one-d-wide@protonmail.com \
/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).