[PATCH net] netlink: avoid a double skb free in genlmsg_mcast()

Subsystems: networking [general], the rest

STALE3135d

2 messages, 2 authors, 2018-03-16 · open the first message on its own page

[PATCH net] netlink: avoid a double skb free in genlmsg_mcast()

From: Nicolas Dichtel <hidden>
Date: 2018-03-14 20:10:23

nlmsg_multicast() consumes always the skb, thus the original skb must be
freed only when this function is called with a clone.

Fixes: cb9f7a9a5c96 ("netlink: ensure to loop over all netns in genlmsg_multicast_allns()")
Reported-by: Ben Hutchings <redacted>
Signed-off-by: Nicolas Dichtel <redacted>
---
 net/netlink/genetlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 6f02499ef007..b9ce82c9440f 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -1106,7 +1106,7 @@ static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group,
 	if (!err)
 		delivered = true;
 	else if (err != -ESRCH)
-		goto error;
+		return err;
 	return delivered ? 0 : -ESRCH;
  error:
 	kfree_skb(skb);
-- 
2.15.1

Re: [PATCH net] netlink: avoid a double skb free in genlmsg_mcast()

From: David Miller <davem@davemloft.net>
Date: 2018-03-16 16:36:33

From: Nicolas Dichtel <redacted>
Date: Wed, 14 Mar 2018 21:10:23 +0100
nlmsg_multicast() consumes always the skb, thus the original skb must be
freed only when this function is called with a clone.

Fixes: cb9f7a9a5c96 ("netlink: ensure to loop over all netns in genlmsg_multicast_allns()")
Reported-by: Ben Hutchings <redacted>
Signed-off-by: Nicolas Dichtel <redacted>
Yeah these "clone until final send" loops can be tricky to manage.

Good catch, applied and queued up for -stable, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help