* [PATCH] net/packet: fix missing net_device reference release
@ 2017-05-12 18:19 Douglas Caetano dos Santos
2017-05-12 20:11 ` Soheil Hassas Yeganeh
2017-05-15 18:25 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Douglas Caetano dos Santos @ 2017-05-12 18:19 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Daniel Borkmann, Willem de Bruijn,
Jarno Rajahalme, Andrey Konovalov, Anoob Soman, Sowmini Varadhan,
Philip Pettersson, Mike Rapoport
When using a TX ring buffer, if an error occurs processing a control
message (e.g. invalid message), the net_device reference is not
released.
Fixes c14ac9451c348 ("sock: enable timestamping using control messages")
Signed-off-by: Douglas Caetano dos Santos <douglascs@taghos.com.br>
---
net/packet/af_packet.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index f4001763134d..e3eeed19cc7a 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2658,13 +2658,6 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex);
}
- sockc.tsflags = po->sk.sk_tsflags;
- if (msg->msg_controllen) {
- err = sock_cmsg_send(&po->sk, msg, &sockc);
- if (unlikely(err))
- goto out;
- }
-
err = -ENXIO;
if (unlikely(dev == NULL))
goto out;
@@ -2672,6 +2665,13 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
if (unlikely(!(dev->flags & IFF_UP)))
goto out_put;
+ sockc.tsflags = po->sk.sk_tsflags;
+ if (msg->msg_controllen) {
+ err = sock_cmsg_send(&po->sk, msg, &sockc);
+ if (unlikely(err))
+ goto out_put;
+ }
+
if (po->sk.sk_socket->type == SOCK_RAW)
reserve = dev->hard_header_len;
size_max = po->tx_ring.frame_size
--
2.12.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net/packet: fix missing net_device reference release
2017-05-12 18:19 [PATCH] net/packet: fix missing net_device reference release Douglas Caetano dos Santos
@ 2017-05-12 20:11 ` Soheil Hassas Yeganeh
2017-05-15 18:25 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Soheil Hassas Yeganeh @ 2017-05-12 20:11 UTC (permalink / raw)
To: Douglas Caetano dos Santos
Cc: netdev, David S. Miller, Eric Dumazet, Daniel Borkmann,
Willem de Bruijn, Jarno Rajahalme, Andrey Konovalov, Anoob Soman,
Sowmini Varadhan, Philip Pettersson, Mike Rapoport
On Fri, May 12, 2017 at 2:19 PM, Douglas Caetano dos Santos
<douglascs@taghos.com.br> wrote:
> When using a TX ring buffer, if an error occurs processing a control
> message (e.g. invalid message), the net_device reference is not
> released.
>
> Fixes c14ac9451c348 ("sock: enable timestamping using control messages")
> Signed-off-by: Douglas Caetano dos Santos <douglascs@taghos.com.br>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
> ---
> net/packet/af_packet.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index f4001763134d..e3eeed19cc7a 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
> @@ -2658,13 +2658,6 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
> dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex);
> }
>
> - sockc.tsflags = po->sk.sk_tsflags;
> - if (msg->msg_controllen) {
> - err = sock_cmsg_send(&po->sk, msg, &sockc);
> - if (unlikely(err))
> - goto out;
> - }
> -
> err = -ENXIO;
> if (unlikely(dev == NULL))
> goto out;
> @@ -2672,6 +2665,13 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
> if (unlikely(!(dev->flags & IFF_UP)))
> goto out_put;
>
> + sockc.tsflags = po->sk.sk_tsflags;
> + if (msg->msg_controllen) {
> + err = sock_cmsg_send(&po->sk, msg, &sockc);
> + if (unlikely(err))
> + goto out_put;
> + }
> +
> if (po->sk.sk_socket->type == SOCK_RAW)
> reserve = dev->hard_header_len;
> size_max = po->tx_ring.frame_size
> --
> 2.12.2
>
Thank you, for the fix.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net/packet: fix missing net_device reference release
2017-05-12 18:19 [PATCH] net/packet: fix missing net_device reference release Douglas Caetano dos Santos
2017-05-12 20:11 ` Soheil Hassas Yeganeh
@ 2017-05-15 18:25 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-05-15 18:25 UTC (permalink / raw)
To: douglascs
Cc: netdev, edumazet, daniel, willemb, jarno, andreyknvl,
anoob.soman, sowmini.varadhan, philip.pettersson, rppt
From: Douglas Caetano dos Santos <douglascs@taghos.com.br>
Date: Fri, 12 May 2017 15:19:15 -0300
> When using a TX ring buffer, if an error occurs processing a control
> message (e.g. invalid message), the net_device reference is not
> released.
>
> Fixes c14ac9451c348 ("sock: enable timestamping using control messages")
> Signed-off-by: Douglas Caetano dos Santos <douglascs@taghos.com.br>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-15 18:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-12 18:19 [PATCH] net/packet: fix missing net_device reference release Douglas Caetano dos Santos
2017-05-12 20:11 ` Soheil Hassas Yeganeh
2017-05-15 18:25 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.