netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] af_packet: fix raw sockets over 6in4 tunnel
@ 2019-01-11 14:43 Nicolas Dichtel
  2019-01-11 21:29 ` Willem de Bruijn
  0 siblings, 1 reply; 17+ messages in thread
From: Nicolas Dichtel @ 2019-01-11 14:43 UTC (permalink / raw)
  To: davem; +Cc: netdev, Nicolas Dichtel, Willem de Bruijn

Since commit cb9f1b783850, scapy (which uses an AF_PACKET socket in
SOCK_RAW mode) is unable to send a basic icmp packet over a sit tunnel:

Here is a example of the setup:
$ ip link set ntfp2 up
$ ip addr add 10.125.0.1/24 dev ntfp2
$ ip tunnel add tun1 mode sit ttl 64 local 10.125.0.1 remote 10.125.0.2 dev ntfp2
$ ip addr add fd00:cafe:cafe::1/128 dev tun1
$ ip link set dev tun1 up
$ ip route add fd00:200::/64 dev tun1
$ scapy
>>> p = []
>>> p += IPv6(src='fd00:100::1', dst='fd00:200::1')/ICMPv6EchoRequest()
>>> send(p, count=1, inter=0.1)
>>> quit()
$ ip -s link ls dev tun1 | grep -A1 "TX.*errors"
    TX: bytes  packets  errors  dropped carrier collsns
    0          0        1       0       0       0

The problem is that the network offset is set to the hard_header_len of the
output device (tun1, ie 14 + 20) and in our case, because the packet is
small (48 bytes) the pskb_inet_may_pull() fails (it tries to pull 40 bytes
(ipv6 header) starting from the network offset). Let's reset the network
offset so that it points to the beginning of the L3 data, ie skb->data.

Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=993675a3100b1
Fixes: cb9f1b783850 ("ip: validate header length on virtual device xmit")
CC: Willem de Bruijn <willemb@google.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/packet/af_packet.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index d0945253f43b..911c3870e66d 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2887,8 +2887,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
 			goto out_free;
 	} else if (reserve) {
 		skb_reserve(skb, -reserve);
-		if (len < reserve)
-			skb_reset_network_header(skb);
+		skb_reset_network_header(skb);
 	}
 
 	/* Returns -EFAULT on error */
-- 
2.18.0

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

end of thread, other threads:[~2019-02-25  8:55 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-11 14:43 [PATCH net] af_packet: fix raw sockets over 6in4 tunnel Nicolas Dichtel
2019-01-11 21:29 ` Willem de Bruijn
2019-01-12 18:00   ` Willem de Bruijn
2019-01-14 14:51     ` Nicolas Dichtel
2019-01-14 15:15       ` Willem de Bruijn
2019-01-14 15:38         ` Willem de Bruijn
2019-01-15  9:49           ` Nicolas Dichtel
2019-01-15 16:20             ` Willem de Bruijn
2019-01-17 10:27               ` [PATCH net v2] " Nicolas Dichtel
2019-01-17 15:09                 ` Willem de Bruijn
2019-01-17 23:55                 ` David Miller
2019-02-18 15:57                   ` Sasha Levin
2019-02-20 18:39                     ` Willem de Bruijn
2019-02-20 19:33                       ` David Miller
2019-02-22 19:50                       ` David Miller
2019-02-22 23:53                         ` Willem de Bruijn
2019-02-25  8:55                           ` Nicolas Dichtel

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