* [PATCH] packet: Do not leak dev refcounts on error exit
@ 2019-01-08 23:27 Jason Gunthorpe
2019-01-08 23:48 ` Willem de Bruijn
2019-01-09 2:59 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2019-01-08 23:27 UTC (permalink / raw)
To: David S. Miller, linux-rdma@vger.kernel.org,
netdev@vger.kernel.org
Cc: Willem de Bruijn, Leon Romanovsky
'dev' is non NULL when the addr_len check triggers so it must goto a label
that does the dev_put otherwise dev will have a leaked refcount.
This bug causes the ib_ipoib module to become unloadable when using
systemd-network as it triggers this check on InfiniBand links.
Fixes: 99137b7888f4 ("packet: validate address length")
Reported-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
---
net/packet/af_packet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
This patch should go to -rc please. Thanks
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index eedacdebcd4c61..d0945253f43b3e 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2628,7 +2628,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
addr = saddr->sll_halen ? saddr->sll_addr : NULL;
dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex);
if (addr && dev && saddr->sll_halen < dev->addr_len)
- goto out;
+ goto out_put;
}
err = -ENXIO;
@@ -2828,7 +2828,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
addr = saddr->sll_halen ? saddr->sll_addr : NULL;
dev = dev_get_by_index(sock_net(sk), saddr->sll_ifindex);
if (addr && dev && saddr->sll_halen < dev->addr_len)
- goto out;
+ goto out_unlock;
}
err = -ENXIO;
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] packet: Do not leak dev refcounts on error exit
2019-01-08 23:27 [PATCH] packet: Do not leak dev refcounts on error exit Jason Gunthorpe
@ 2019-01-08 23:48 ` Willem de Bruijn
2019-01-09 2:59 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Willem de Bruijn @ 2019-01-08 23:48 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: David S. Miller, linux-rdma@vger.kernel.org,
netdev@vger.kernel.org, Willem de Bruijn, Leon Romanovsky
On Tue, Jan 8, 2019 at 6:41 PM Jason Gunthorpe <jgg@mellanox.com> wrote:
>
> 'dev' is non NULL when the addr_len check triggers so it must goto a label
> that does the dev_put otherwise dev will have a leaked refcount.
>
> This bug causes the ib_ipoib module to become unloadable when using
> systemd-network as it triggers this check on InfiniBand links.
>
> Fixes: 99137b7888f4 ("packet: validate address length")
> Reported-by: Leon Romanovsky <leonro@mellanox.com>
> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Argh, indeed. Thanks for the fix.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] packet: Do not leak dev refcounts on error exit
2019-01-08 23:27 [PATCH] packet: Do not leak dev refcounts on error exit Jason Gunthorpe
2019-01-08 23:48 ` Willem de Bruijn
@ 2019-01-09 2:59 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-01-09 2:59 UTC (permalink / raw)
To: jgg; +Cc: linux-rdma, netdev, willemb, leonro
From: Jason Gunthorpe <jgg@mellanox.com>
Date: Tue, 8 Jan 2019 23:27:06 +0000
> 'dev' is non NULL when the addr_len check triggers so it must goto a label
> that does the dev_put otherwise dev will have a leaked refcount.
>
> This bug causes the ib_ipoib module to become unloadable when using
> systemd-network as it triggers this check on InfiniBand links.
>
> Fixes: 99137b7888f4 ("packet: validate address length")
> Reported-by: Leon Romanovsky <leonro@mellanox.com>
> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-09 2:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-08 23:27 [PATCH] packet: Do not leak dev refcounts on error exit Jason Gunthorpe
2019-01-08 23:48 ` Willem de Bruijn
2019-01-09 2:59 ` David Miller
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).