From: Florian Westphal <fw@strlen.de>
To: Sriram Rajagopalan <bglsriram@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: iptables-nft: Wrong payload merge of rule filter - "! --sport xx ! --dport xx"
Date: Fri, 8 Mar 2024 14:37:18 +0100 [thread overview]
Message-ID: <20240308133718.GC22451@breakpoint.cc> (raw)
In-Reply-To: <CAPtndGDEJVWXcggRkw66YLjhu3QyUjJ5j4YEbvJLj-qbPkQaPg@mail.gmail.com>
Sriram Rajagopalan <bglsriram@gmail.com> wrote:
> diff --git a/src/rule.c b/src/rule.c
> index 342c43fb..5def185d 100644
> --- a/src/rule.c
> +++ b/src/rule.c
> @@ -2661,8 +2661,13 @@ static void payload_do_merge(struct stmt *sa[],
> unsigned int n)
> for (j = 0, i = 1; i < n; i++) {
> stmt = sa[i];
> this = stmt->expr;
> -
> - if (!payload_can_merge(last->left, this->left) ||
> + /* We should not be merging two OP_NEQs. For example -
> + * tcp sport != 22 tcp dport != 23 should not result in
> + * [ payload load 4b @ transport header + 0 => reg 1 ]
> + * [ cmp neq reg 1 0x17001600 ]
> + */
> + if (this->op == OP_NEQ ||
> + !payload_can_merge(last->left, this->left) ||
> !relational_ops_match(last, this)) {
> last = this;
> j = i;
>
> Please review the patches above and provide your feedback. Please let
> me know of any questions/clarifications.
Probably better to do:
diff --git a/src/rule.c b/src/rule.c
--- a/src/rule.c
+++ b/src/rule.c
@@ -2766,7 +2766,6 @@ static void stmt_reduce(const struct rule *rule)
switch (stmt->expr->op) {
case OP_EQ:
case OP_IMPLICIT:
- case OP_NEQ:
break;
default:
continue;
next prev parent reply other threads:[~2024-03-08 13:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-08 9:19 iptables-nft: Wrong payload merge of rule filter - "! --sport xx ! --dport xx" Sriram Rajagopalan
2024-03-08 11:30 ` Phil Sutter
2024-03-13 9:01 ` Sriram Rajagopalan
2024-03-08 13:37 ` Florian Westphal [this message]
2024-03-12 10:24 ` Sriram Rajagopalan
2024-03-12 10:34 ` Florian Westphal
2024-03-13 9:02 ` Sriram Rajagopalan
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=20240308133718.GC22451@breakpoint.cc \
--to=fw@strlen.de \
--cc=bglsriram@gmail.com \
--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.