From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, Willem de Bruijn <willemb@google.com>
Subject: [PATCH net] packet: reset network header if packet shorter than ll reserved space
Date: Wed, 11 Jul 2018 12:00:45 -0400 [thread overview]
Message-ID: <20180711160046.198091-2-willemdebruijn.kernel@gmail.com> (raw)
In-Reply-To: <20180711160046.198091-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemb@google.com>
If variable length link layer headers result in a packet shorter
than dev->hard_header_len, reset the network header offset. Else
skb->mac_len may exceed skb->len after skb_mac_reset_len.
packet_sendmsg_spkt already has similar logic.
Fixes: b84bbaf7a6c8 ("packet: in packet_snd start writing at link layer allocation")
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
net/packet/af_packet.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 57634bc3da74..9b27d0cd766d 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2878,6 +2878,8 @@ 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);
}
/* Returns -EFAULT on error */
--
2.18.0.203.gfac676dfb9-goog
next prev parent reply other threads:[~2018-07-11 16:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-11 16:00 [PATCH net] nsh: set mac len based on inner packet Willem de Bruijn
2018-07-11 16:00 ` Willem de Bruijn [this message]
2018-07-12 23:57 ` [PATCH net] packet: reset network header if packet shorter than ll reserved space David Miller
2018-07-11 16:00 ` [PATCH net] selftests: in udpgso_bench do not test udp zerocopy Willem de Bruijn
2018-07-12 23:57 ` David Miller
2018-07-12 7:28 ` [PATCH net] nsh: set mac len based on inner packet Jiri Benc
2018-07-12 23:57 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180711160046.198091-2-willemdebruijn.kernel@gmail.com \
--to=willemdebruijn.kernel@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).