netfilter: xt_connmark: reject invalid shift parameters
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 netfilter: xt_connmark: reject invalid shift parameters
From: Wyatt Feng <[email protected]>
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.
--- net/netfilter/xt_connmark.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/netfilter/xt_connmark.c +6 -0
@@ -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",
Signature · 1 line
2.47.3
Quoted 14 lines · Ren Wei
From: Wyatt Feng <[email protected]>
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_bitsvalue of 32 or more triggers an undefined-shift bug when the rule is evaluated. Invalidshift_dirvalues 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.
Quoted 8 lines
Fixes 472a73e00757 ("netfilter: xt_conntrack: Support bit-shifting for CONNMARK & MARK targets.")Reported-by Yuan Tan <[email protected]>Reported-by Zhengchuan Liang <[email protected]>Reported-by Xin Liu <[email protected]>Assisted-by Codex:GPT-5.4Signed-off-by Wyatt Feng <[email protected]>Reviewed-by Ren Wei <[email protected]>