linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netfilter: ipt_CLUSTERIP: fix refcount leak in clusterip_tg_check()
@ 2021-12-23  2:48 Xin Xiong
  2021-12-23 13:38 ` Florian Westphal
  2022-01-06  9:40 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 3+ messages in thread
From: Xin Xiong @ 2021-12-23  2:48 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	David S . Miller, Hideaki YOSHIFUJI, David Ahern, Jakub Kicinski,
	netfilter-devel, coreteam, netdev, linux-kernel
  Cc: yuanxzhang, Xin Xiong, Xiyu Yang, Xin Tan

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.

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>
---
 net/ipv4/netfilter/ipt_CLUSTERIP.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] netfilter: ipt_CLUSTERIP: fix refcount leak in clusterip_tg_check()
  2021-12-23  2:48 [PATCH] netfilter: ipt_CLUSTERIP: fix refcount leak in clusterip_tg_check() Xin Xiong
@ 2021-12-23 13:38 ` Florian Westphal
  2022-01-06  9:40 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2021-12-23 13:38 UTC (permalink / raw)
  To: Xin Xiong
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	David S . Miller, Hideaki YOSHIFUJI, David Ahern, Jakub Kicinski,
	netfilter-devel, coreteam, netdev, linux-kernel, yuanxzhang,
	Xiyu Yang, Xin Tan

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")


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] netfilter: ipt_CLUSTERIP: fix refcount leak in clusterip_tg_check()
  2021-12-23  2:48 [PATCH] netfilter: ipt_CLUSTERIP: fix refcount leak in clusterip_tg_check() Xin Xiong
  2021-12-23 13:38 ` Florian Westphal
@ 2022-01-06  9:40 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2022-01-06  9:40 UTC (permalink / raw)
  To: Xin Xiong
  Cc: Jozsef Kadlecsik, Florian Westphal, David S . Miller,
	Hideaki YOSHIFUJI, David Ahern, Jakub Kicinski, netfilter-devel,
	coreteam, netdev, linux-kernel, yuanxzhang, Xiyu Yang, Xin Tan

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-06  9:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-23  2:48 [PATCH] netfilter: ipt_CLUSTERIP: fix refcount leak in clusterip_tg_check() Xin Xiong
2021-12-23 13:38 ` Florian Westphal
2022-01-06  9:40 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).