netfilter: ctnetlink: validate CTA_EXPECT_NAT_DIR value
Subsystems (2)
PATCH 1/1 netfilter: ctnetlink: validate CTA_EXPECT_NAT_DIR value
ctnetlink_parse_expect_nat() reads the CTA_EXPECT_NAT_DIR attribute from userspace via netlink and assigns it to exp->dir without checking whether it is a valid direction value. Since exp->dir is used as an array index into the 2-element tuplehash[] array, an out-of-range value causes an out-of-bounds access.
Add a bounds check to ensure the direction is less than IP_CT_DIR_MAX.
--- net/netfilter/nf_conntrack_netlink.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nf_conntrack_netlink.c +2 -0
@@ -3496,6 +3496,8 @@ ctnetlink_parse_expect_nat(const struct nlattr *attr, exp->saved_addr = nat_tuple.src.u3; exp->saved_proto = nat_tuple.src.u; exp->dir =ntohl (nla_get_be32 (tb[CTA_EXPECT_NAT_DIR ])); +if (exp->dir >=IP_CT_DIR_MAX ) +return -EINVAL ;return 0 ;#else
Signature · 1 line
2.34.1
Florian Westphal
maintainerQuoted 7 lines · Jenny Guanni Qu
ctnetlink_parse_expect_nat()reads theCTA_EXPECT_NAT_DIRattribute from userspace via netlink and assigns it toexp->dirwithout checking whether it is a valid direction value. Sinceexp->diris used as an array index into the 2-element tuplehash[] array, an out-of-range value causes an out-of-bounds access.Add a bounds check to ensure the direction is less than
IP_CT_DIR_MAX.
Please see:
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
We are seeing a massive influx of bug reports, and sometimes same issue is reported multiple times.
Due to the large backlog, we are unable to provide timely pull requests to the net tree anymore.
I hope I can make another pull request with pending patches this Friday.
We are aware that the conntrack expectation bugs remain unresolved.
This is because some of the proposed fixes are not sufficient and a further audit is going on.