netfilter: ctnetlink: memleak in filter initialization error path
Release the filter object in case of error.
Fixes: cb8aa9a3af
("netfilter: ctnetlink: add kernel side filtering for dump")
Reported-by: syzbot+38b8b548a851a01793c5@syzkaller.appspotmail.com
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
Родитель
c3829285b2
Коммит
6c2d2176a8
|
@ -939,7 +939,8 @@ ctnetlink_alloc_filter(const struct nlattr * const cda[], u8 family)
|
|||
filter->mark.mask = 0xffffffff;
|
||||
}
|
||||
} else if (cda[CTA_MARK_MASK]) {
|
||||
return ERR_PTR(-EINVAL);
|
||||
err = -EINVAL;
|
||||
goto err_filter;
|
||||
}
|
||||
#endif
|
||||
if (!cda[CTA_FILTER])
|
||||
|
@ -947,15 +948,17 @@ ctnetlink_alloc_filter(const struct nlattr * const cda[], u8 family)
|
|||
|
||||
err = ctnetlink_parse_zone(cda[CTA_ZONE], &filter->zone);
|
||||
if (err < 0)
|
||||
return ERR_PTR(err);
|
||||
goto err_filter;
|
||||
|
||||
err = ctnetlink_parse_filter(cda[CTA_FILTER], filter);
|
||||
if (err < 0)
|
||||
return ERR_PTR(err);
|
||||
goto err_filter;
|
||||
|
||||
if (filter->orig_flags) {
|
||||
if (!cda[CTA_TUPLE_ORIG])
|
||||
return ERR_PTR(-EINVAL);
|
||||
if (!cda[CTA_TUPLE_ORIG]) {
|
||||
err = -EINVAL;
|
||||
goto err_filter;
|
||||
}
|
||||
|
||||
err = ctnetlink_parse_tuple_filter(cda, &filter->orig,
|
||||
CTA_TUPLE_ORIG,
|
||||
|
@ -963,23 +966,32 @@ ctnetlink_alloc_filter(const struct nlattr * const cda[], u8 family)
|
|||
&filter->zone,
|
||||
filter->orig_flags);
|
||||
if (err < 0)
|
||||
return ERR_PTR(err);
|
||||
goto err_filter;
|
||||
}
|
||||
|
||||
if (filter->reply_flags) {
|
||||
if (!cda[CTA_TUPLE_REPLY])
|
||||
return ERR_PTR(-EINVAL);
|
||||
if (!cda[CTA_TUPLE_REPLY]) {
|
||||
err = -EINVAL;
|
||||
goto err_filter;
|
||||
}
|
||||
|
||||
err = ctnetlink_parse_tuple_filter(cda, &filter->reply,
|
||||
CTA_TUPLE_REPLY,
|
||||
filter->family,
|
||||
&filter->zone,
|
||||
filter->orig_flags);
|
||||
if (err < 0)
|
||||
return ERR_PTR(err);
|
||||
if (err < 0) {
|
||||
err = -EINVAL;
|
||||
goto err_filter;
|
||||
}
|
||||
}
|
||||
|
||||
return filter;
|
||||
|
||||
err_filter:
|
||||
kfree(filter);
|
||||
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
static bool ctnetlink_needs_filter(u8 family, const struct nlattr * const *cda)
|
||||
|
|
Загрузка…
Ссылка в новой задаче