Linux Netfilter development
 help / color / mirror / Atom feed
* [PATCH nf 1/1] netfilter: xt_connmark: reject invalid shift parameters
       [not found] <cover.1782853619.git.bronzed_45_vested@icloud.com>
@ 2026-07-03  5:04 ` Ren Wei
  2026-07-03  9:00   ` Phil Sutter
  0 siblings, 1 reply; 2+ messages in thread
From: Ren Wei @ 2026-07-03  5:04 UTC (permalink / raw)
  To: netfilter-devel
  Cc: pablo, fw, phil, davem, edumazet, pabeni, horms, jack.ma,
	yuantan098, zcliangcn, dstsmallbird, bronzed_45_vested,
	enjou1224z

From: Wyatt Feng <bronzed_45_vested@icloud.com>

Revision 2 of the CONNMARK target accepts user-controlled shift
parameters and applies them to 32-bit mark values in
connmark_tg_shift().

A shift_bits value of 32 or more triggers an undefined-shift bug when
the rule is evaluated. Invalid shift_dir values are also accepted and
silently fall back to the left-shift path.

Reject invalid revision-2 shift parameters in connmark_tg_check() so
malformed rules fail at installation time, before they can reach the
packet path.

Fixes: 472a73e00757 ("netfilter: xt_conntrack: Support bit-shifting for CONNMARK & MARK targets.")
Cc: stable@vger.kernel.org
Reported-by: Yuan Tan <yuantan098@gmail.com>
Reported-by: Zhengchuan Liang <zcliangcn@gmail.com>
Reported-by: Xin Liu <dstsmallbird@foxmail.com>
Assisted-by: Codex:GPT-5.4
Signed-off-by: Wyatt Feng <bronzed_45_vested@icloud.com>
Reviewed-by: Ren Wei <enjou1224z@gmail.com>
---
 net/netfilter/xt_connmark.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/netfilter/xt_connmark.c b/net/netfilter/xt_connmark.c
index 4277084de2e7..b7fdc3e9d423 100644
--- a/net/netfilter/xt_connmark.c
+++ b/net/netfilter/xt_connmark.c
@@ -103,8 +103,14 @@ connmark_tg_v2(struct sk_buff *skb, const struct xt_action_param *par)
 
 static int connmark_tg_check(const struct xt_tgchk_param *par)
 {
+	const struct xt_connmark_tginfo2 *info = par->targinfo;
 	int ret;
 
+	if (par->target->revision == 2) {
+		if (info->shift_dir > D_SHIFT_RIGHT || info->shift_bits >= 32)
+			return -EINVAL;
+	}
+
 	ret = nf_ct_netns_get(par->net, par->family);
 	if (ret < 0)
 		pr_info_ratelimited("cannot load conntrack support for proto=%u\n",
-- 
2.47.3

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

* Re: [PATCH nf 1/1] netfilter: xt_connmark: reject invalid shift parameters
  2026-07-03  5:04 ` [PATCH nf 1/1] netfilter: xt_connmark: reject invalid shift parameters Ren Wei
@ 2026-07-03  9:00   ` Phil Sutter
  0 siblings, 0 replies; 2+ messages in thread
From: Phil Sutter @ 2026-07-03  9:00 UTC (permalink / raw)
  To: Ren Wei
  Cc: netfilter-devel, pablo, fw, davem, edumazet, pabeni, horms,
	jack.ma, yuantan098, zcliangcn, dstsmallbird, bronzed_45_vested

On Fri, Jul 03, 2026 at 01:04:46PM +0800, Ren Wei wrote:
> From: Wyatt Feng <bronzed_45_vested@icloud.com>
> 
> Revision 2 of the CONNMARK target accepts user-controlled shift
> parameters and applies them to 32-bit mark values in
> connmark_tg_shift().
> 
> A shift_bits value of 32 or more triggers an undefined-shift bug when
> the rule is evaluated. Invalid shift_dir values are also accepted and
> silently fall back to the left-shift path.
> 
> Reject invalid revision-2 shift parameters in connmark_tg_check() so
> malformed rules fail at installation time, before they can reach the
> packet path.
> 
> Fixes: 472a73e00757 ("netfilter: xt_conntrack: Support bit-shifting for CONNMARK & MARK targets.")
> Cc: stable@vger.kernel.org
> Reported-by: Yuan Tan <yuantan098@gmail.com>
> Reported-by: Zhengchuan Liang <zcliangcn@gmail.com>
> Reported-by: Xin Liu <dstsmallbird@foxmail.com>
> Assisted-by: Codex:GPT-5.4
> Signed-off-by: Wyatt Feng <bronzed_45_vested@icloud.com>
> Reviewed-by: Ren Wei <enjou1224z@gmail.com>

Reviewed-by: Phil Sutter <phil@nwl.cc>

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

end of thread, other threads:[~2026-07-03  9:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1782853619.git.bronzed_45_vested@icloud.com>
2026-07-03  5:04 ` [PATCH nf 1/1] netfilter: xt_connmark: reject invalid shift parameters Ren Wei
2026-07-03  9:00   ` Phil Sutter

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