public inbox for netfilter-devel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] netfilter: nfnetlink_cthelper: fix expect policy update copying only first class values to all classes
@ 2026-04-13  8:48 Dudu Lu
  2026-04-13 17:27 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Dudu Lu @ 2026-04-13  8:48 UTC (permalink / raw)
  To: netfilter-devel; +Cc: pablo, fw, Dudu Lu

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)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-13 17:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-13  8:48 [PATCH] netfilter: nfnetlink_cthelper: fix expect policy update copying only first class values to all classes Dudu Lu
2026-04-13 17:27 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox