Skip to content

Commit

Permalink
netfilter: ipt_CLUSTERIP: fix refcount leak in clusterip_tg_check()
Browse files Browse the repository at this point in the history
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: 06aa151 ("netfilter: ipt_CLUSTERIP: check MAC address when duplicate config is set")
Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Xin Xiong authored and Pablo Neira Ayuso committed Jan 5, 2022
1 parent 1d5a474 commit d94a69c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/ipv4/netfilter/ipt_CLUSTERIP.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d94a69c

Please sign in to comment.