Message ID | 20211223024811.4519-1-xiongx18@fudan.edu.cn |
---|---|
State | Accepted |
Delegated to: | Pablo Neira |
Headers | show |
Series | netfilter: ipt_CLUSTERIP: fix refcount leak in clusterip_tg_check() | expand |
Xin Xiong <xiongx18@fudan.edu.cn> wrote: > The issue takes place in one error path of clusterip_tg_check(). When > memcmp() returns nonzero, the function simply returns the error code, > forgetting to decrease the reference count of a clusterip_config > object, which is bumped earlier by clusterip_config_find_get(). This > may incur reference count leak. > > Fix this issue by decrementing the refcount of the object in specific > error path. Fixes: 06aa151ad1fc74 ("netfilter: ipt_CLUSTERIP: check MAC address when duplicate config is set")
On Thu, Dec 23, 2021 at 10:48:12AM +0800, Xin Xiong wrote: > The issue takes place in one error path of clusterip_tg_check(). When > memcmp() returns nonzero, the function simply returns the error code, > forgetting to decrease the reference count of a clusterip_config > object, which is bumped earlier by clusterip_config_find_get(). This > may incur reference count leak. > > Fix this issue by decrementing the refcount of the object in specific > error path. Applied
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c index 8fd1aba8a..b518f20c9 100644 --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c @@ -520,8 +520,11 @@ static int clusterip_tg_check(const struct xt_tgchk_param *par) if (IS_ERR(config)) return PTR_ERR(config); } - } else if (memcmp(&config->clustermac, &cipinfo->clustermac, ETH_ALEN)) + } else if (memcmp(&config->clustermac, &cipinfo->clustermac, ETH_ALEN)) { + clusterip_config_entry_put(config); + clusterip_config_put(config); return -EINVAL; + } ret = nf_ct_netns_get(par->net, par->family); if (ret < 0) {