public inbox for netfilter-devel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dudu Lu <phx0fer@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org, fw@strlen.de, Dudu Lu <phx0fer@gmail.com>
Subject: [PATCH] netfilter: nfnetlink_cthelper: fix expect policy update copying only first class values to all classes
Date: Mon, 13 Apr 2026 16:48:22 +0800	[thread overview]
Message-ID: <20260413084822.70754-1-phx0fer@gmail.com> (raw)

In nfnl_cthelper_update_policy_all(), when updating the expect policies
of a multi-class conntrack helper, the loop iterates over all expect
classes but always reads from new_policy[0] instead of new_policy[i]:

    for (i = 0; i < helper->expect_class_max + 1; i++) {
        policy = &helper->expect_policy[i];
        policy->max_expected = new_policy->max_expected;  /* always [0] */
        policy->timeout      = new_policy->timeout;       /* always [0] */
    }

The new_policy array was correctly parsed per-class by
nfnl_cthelper_update_policy_one() in the validation loop above (line
336-342), with each new_policy[i] holding its respective class values.
However, the copy loop dereferences new_policy as a pointer
(new_policy->x) rather than indexing it as an array
(new_policy[i].x), creating a security vulnerability.

As a result, all expect classes of a multi-class helper get overwritten
with the values of class 0, discarding the per-class differentiation.

This affects helpers like H.323 which use multiple expect classes
(RTP, RTCP, T.120) with different max_expected and timeout values.
After a policy update, all classes get identical limits, breaking the
per-class expect enforcement.

Fix by indexing new_policy with the loop variable.

Fixes: 2c422257550f ("netfilter: nfnl_cthelper: fix runtime expectation policy updates")
Signed-off-by: Dudu Lu <phx0fer@gmail.com>
---
 net/netfilter/nfnetlink_cthelper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
index d545fa459455..1e605d77796d 100644
--- a/net/netfilter/nfnetlink_cthelper.c
+++ b/net/netfilter/nfnetlink_cthelper.c
@@ -346,8 +346,8 @@ static int nfnl_cthelper_update_policy_all(struct nlattr *tb[],
 	for (i = 0; i < helper->expect_class_max + 1; i++) {
 		policy = (struct nf_conntrack_expect_policy *)
 				&helper->expect_policy[i];
-		policy->max_expected = new_policy->max_expected;
-		policy->timeout	= new_policy->timeout;
+		policy->max_expected = new_policy[i].max_expected;
+		policy->timeout	= new_policy[i].timeout;
 	}
 
 err:
-- 
2.39.3 (Apple Git-145)


             reply	other threads:[~2026-04-13  8:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13  8:48 Dudu Lu [this message]
2026-04-13 17:27 ` [PATCH] netfilter: nfnetlink_cthelper: fix expect policy update copying only first class values to all classes Pablo Neira Ayuso

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=20260413084822.70754-1-phx0fer@gmail.com \
    --to=phx0fer@gmail.com \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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