netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netfilter: nfnetlink: fix potential dead lock in nfnetlink_rcv_msg()
@ 2022-11-03  1:12 Ziyang Xuan
  2022-11-03 11:03 ` Florian Westphal
  0 siblings, 1 reply; 2+ messages in thread
From: Ziyang Xuan @ 2022-11-03  1:12 UTC (permalink / raw)
  To: pablo, kadlec, fw, davem, edumazet, kuba, pabeni, netfilter-devel
  Cc: coreteam, netdev, linux-kernel

When type is NFNL_CB_MUTEX and -EAGAIN error occur in nfnetlink_rcv_msg(),
it does not execute nfnl_unlock(). That would trigger potential dead lock.

Fixes: 50f2db9e368f ("netfilter: nfnetlink: consolidate callback types")
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
---
 net/netfilter/nfnetlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 9c44518cb70f..6d18fb346868 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -294,6 +294,7 @@ static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
 			nfnl_lock(subsys_id);
 			if (nfnl_dereference_protected(subsys_id) != ss ||
 			    nfnetlink_find_client(type, ss) != nc) {
+				nfnl_unlock(subsys_id);
 				err = -EAGAIN;
 				break;
 			}
-- 
2.25.1


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

* Re: [PATCH] netfilter: nfnetlink: fix potential dead lock in nfnetlink_rcv_msg()
  2022-11-03  1:12 [PATCH] netfilter: nfnetlink: fix potential dead lock in nfnetlink_rcv_msg() Ziyang Xuan
@ 2022-11-03 11:03 ` Florian Westphal
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2022-11-03 11:03 UTC (permalink / raw)
  To: Ziyang Xuan
  Cc: pablo, kadlec, fw, davem, edumazet, kuba, pabeni, netfilter-devel,
	coreteam, netdev, linux-kernel

Ziyang Xuan <william.xuanziyang@huawei.com> wrote:
> When type is NFNL_CB_MUTEX and -EAGAIN error occur in nfnetlink_rcv_msg(),
> it does not execute nfnl_unlock(). That would trigger potential dead lock.
>
> Fixes: 50f2db9e368f ("netfilter: nfnetlink: consolidate callback types")

Applied to nf:testing, thanks.

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

end of thread, other threads:[~2022-11-03 11:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-03  1:12 [PATCH] netfilter: nfnetlink: fix potential dead lock in nfnetlink_rcv_msg() Ziyang Xuan
2022-11-03 11:03 ` Florian Westphal

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