Skip to content

Commit

Permalink
netfilter: ctnetlink: must check mark attributes vs NULL
Browse files Browse the repository at this point in the history
else we will oops (null deref) when the attributes aren't present.

Also add back the EOPNOTSUPP in case MARK filtering is requested but
kernel doesn't support it.

Fixes: 59c08c6 ("netfilter: ctnetlink: Support L3 protocol-filter on flush")
Reported-by: syzbot+e45eda8eda6e93a03959@syzkaller.appspotmail.com
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Florian Westphal authored and Pablo Neira Ayuso committed Sep 21, 2018
1 parent 0de22ba commit 9306425
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions net/netfilter/nf_conntrack_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,15 +832,22 @@ ctnetlink_alloc_filter(const struct nlattr * const cda[], u8 family)
{
struct ctnetlink_filter *filter;

#ifndef CONFIG_NF_CONNTRACK_MARK
if (cda[CTA_MARK] && cda[CTA_MARK_MASK])
return ERR_PTR(-EOPNOTSUPP);
#endif

filter = kzalloc(sizeof(*filter), GFP_KERNEL);
if (filter == NULL)
return ERR_PTR(-ENOMEM);

filter->family = family;

#ifdef CONFIG_NF_CONNTRACK_MARK
filter->mark.val = ntohl(nla_get_be32(cda[CTA_MARK]));
filter->mark.mask = ntohl(nla_get_be32(cda[CTA_MARK_MASK]));
if (cda[CTA_MARK] && cda[CTA_MARK_MASK]) {
filter->mark.val = ntohl(nla_get_be32(cda[CTA_MARK]));
filter->mark.mask = ntohl(nla_get_be32(cda[CTA_MARK_MASK]));
}
#endif
return filter;
}
Expand Down

0 comments on commit 9306425

Please sign in to comment.