Skip to content

Commit da1aeb2

Browse files
committed
Merge: netfilter: nft_ct: sanitize layer 3 and 4 protocol number in custom expectations
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4059 CVE: CVE-2024-26673 JIRA: https://issues.redhat.com/browse/RHEL-31345 Upstream Status: All upstream in linus.git Patch 1 fixes the bug, patch 2 is a follow-up to fix a side-effect of the first one. Signed-off-by: Phil Sutter <psutter@redhat.com> Approved-by: Florian Westphal <fwestpha@redhat.com> Approved-by: Antoine Tenart <atenart@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents 6a4df8d + 2ad5c3e commit da1aeb2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

net/netfilter/nft_ct.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,30 @@ static int nft_ct_expect_obj_init(const struct nft_ctx *ctx,
11901190
if (tb[NFTA_CT_EXPECT_L3PROTO])
11911191
priv->l3num = ntohs(nla_get_be16(tb[NFTA_CT_EXPECT_L3PROTO]));
11921192

1193+
switch (priv->l3num) {
1194+
case NFPROTO_IPV4:
1195+
case NFPROTO_IPV6:
1196+
if (priv->l3num == ctx->family || ctx->family == NFPROTO_INET)
1197+
break;
1198+
1199+
return -EINVAL;
1200+
case NFPROTO_INET: /* tuple.src.l3num supports NFPROTO_IPV4/6 only */
1201+
default:
1202+
return -EAFNOSUPPORT;
1203+
}
1204+
11931205
priv->l4proto = nla_get_u8(tb[NFTA_CT_EXPECT_L4PROTO]);
1206+
switch (priv->l4proto) {
1207+
case IPPROTO_TCP:
1208+
case IPPROTO_UDP:
1209+
case IPPROTO_UDPLITE:
1210+
case IPPROTO_DCCP:
1211+
case IPPROTO_SCTP:
1212+
break;
1213+
default:
1214+
return -EOPNOTSUPP;
1215+
}
1216+
11941217
priv->dport = nla_get_be16(tb[NFTA_CT_EXPECT_DPORT]);
11951218
priv->timeout = nla_get_u32(tb[NFTA_CT_EXPECT_TIMEOUT]);
11961219
priv->size = nla_get_u8(tb[NFTA_CT_EXPECT_SIZE]);

0 commit comments

Comments
 (0)