* [PATCH net-next] packet: fix match_fanout_group()
@ 2015-10-09 18:29 Eric Dumazet
2015-10-13 2:43 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2015-10-09 18:29 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Eric Leblond, Willem de Bruijn
From: Eric Dumazet <edumazet@google.com>
Recent TCP listener patches exposed a prior af_packet bug :
match_fanout_group() blindly assumes it is always safe
to cast sk to a packet socket to compare fanout with af_packet_priv
But SYNACK packets can be sent while attached to request_sock, which
are smaller than a "struct sock".
We can read non existent memory and crash.
Fixes: c0de08d04215 ("af_packet: don't emit packet on orig fanout group")
Fixes: ca6fb0651883 ("tcp: attach SYNACK messages to request sockets instead of listener")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Cc: Eric Leblond <eric@regit.org>
---
net/packet/af_packet.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 81c900fbc4a4..ccd1d4e9b151 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1519,10 +1519,10 @@ static void __fanout_unlink(struct sock *sk, struct packet_sock *po)
static bool match_fanout_group(struct packet_type *ptype, struct sock *sk)
{
- if (ptype->af_packet_priv == (void *)((struct packet_sock *)sk)->fanout)
- return true;
+ if (sk->sk_family != PF_PACKET)
+ return false;
- return false;
+ return ptype->af_packet_priv == pkt_sk(sk)->fanout;
}
static void fanout_init_data(struct packet_fanout *f)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] packet: fix match_fanout_group()
2015-10-09 18:29 [PATCH net-next] packet: fix match_fanout_group() Eric Dumazet
@ 2015-10-13 2:43 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-10-13 2:43 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev, eric, willemb
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 09 Oct 2015 11:29:32 -0700
> From: Eric Dumazet <edumazet@google.com>
>
> Recent TCP listener patches exposed a prior af_packet bug :
> match_fanout_group() blindly assumes it is always safe
> to cast sk to a packet socket to compare fanout with af_packet_priv
>
> But SYNACK packets can be sent while attached to request_sock, which
> are smaller than a "struct sock".
>
> We can read non existent memory and crash.
>
> Fixes: c0de08d04215 ("af_packet: don't emit packet on orig fanout group")
> Fixes: ca6fb0651883 ("tcp: attach SYNACK messages to request sockets instead of listener")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied, thanks Eric.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-13 2:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-09 18:29 [PATCH net-next] packet: fix match_fanout_group() Eric Dumazet
2015-10-13 2:43 ` 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.