From: Daniel Axtens <dja@axtens.net>
To: netdev@vger.kernel.org
Cc: Daniel Axtens <dja@axtens.net>,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Subject: [PATCH 6/6] net: filter: refuse to change gso_size of SCTP packets
Date: Wed, 28 Feb 2018 00:04:07 +1100 [thread overview]
Message-ID: <20180227130407.22498-7-dja@axtens.net> (raw)
In-Reply-To: <20180227130407.22498-1-dja@axtens.net>
An eBPF tc action on a veth pair can be passed an SCTP GSO skb, which
has gso_size of GSO_BY_FRAGS.
If that action calls bpf_skb_change_proto(), bpf_skb_net_grow()
or bpf_skb_net_shrink(), the code will unconditionally attempt to
increment or decrement the gso_size to some nonsense value.
It's not clear how this could be done correctly, so simply refuse
to operate on SCTP GSO skbs.
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
---
Marcelo - I am not an SCTP expert by any means, so if this code should
be doing something else, please let me know.
---
net/core/filter.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/net/core/filter.c b/net/core/filter.c
index d9684d8a3ac7..f189c988962e 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2096,6 +2096,10 @@ static int bpf_skb_proto_4_to_6(struct sk_buff *skb)
return ret;
if (skb_is_gso(skb)) {
+ /* SCTP uses GSO_BY_FRAGS, cannot adjust */
+ if (unlikely(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP))
+ return -ENOTSUPP;
+
/* SKB_GSO_TCPV4 needs to be changed into
* SKB_GSO_TCPV6.
*/
@@ -2132,6 +2136,10 @@ static int bpf_skb_proto_6_to_4(struct sk_buff *skb)
return ret;
if (skb_is_gso(skb)) {
+ /* SCTP uses GSO_BY_FRAGS, cannot adjust */
+ if (unlikely(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP))
+ return -ENOTSUPP;
+
/* SKB_GSO_TCPV6 needs to be changed into
* SKB_GSO_TCPV4.
*/
@@ -2252,6 +2260,10 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 len_diff)
return ret;
if (skb_is_gso(skb)) {
+ /* SCTP uses GSO_BY_FRAGS, cannot adjust */
+ if (unlikely(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP))
+ return -ENOTSUPP;
+
/* Due to header grow, MSS needs to be downgraded. */
skb_decrease_gso_size(skb, len_diff);
/* Header must be checked, and gso_segs recomputed. */
@@ -2276,6 +2288,10 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 len_diff)
return ret;
if (skb_is_gso(skb)) {
+ /* SCTP uses GSO_BY_FRAGS, cannot adjust */
+ if (unlikely(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP))
+ return -ENOTSUPP;
+
/* Due to header shrink, MSS can be upgraded. */
skb_increase_gso_size(skb, len_diff);
/* Header must be checked, and gso_segs recomputed. */
--
2.14.1
prev parent reply other threads:[~2018-02-27 13:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-27 13:04 [PATCH 0/6]GSO_BY_FRAGS correctness improvements Daniel Axtens
2018-02-27 13:04 ` [PATCH 1/6] net: rename skb_gso_validate_mtu -> skb_gso_validate_network_len Daniel Axtens
2018-02-27 13:04 ` [PATCH 2/6] net: sched: tbf: handle GSO_BY_FRAGS case in enqueue Daniel Axtens
2018-02-27 13:04 ` [PATCH 3/6] net: xfrm: use skb_gso_validate_network_len() to check gso sizes Daniel Axtens
2018-02-27 13:04 ` [PATCH 4/6] net: make skb_gso_*_seglen functions private Daniel Axtens
2018-02-28 15:53 ` David Miller
2018-02-27 13:04 ` [PATCH 5/6] net: add and use helpers when adjusting gso_size Daniel Axtens
2018-02-28 15:56 ` David Miller
2018-02-28 16:21 ` Daniel Borkmann
2018-03-01 0:17 ` Daniel Axtens
2018-03-01 0:47 ` Daniel Borkmann
2018-02-27 13:04 ` Daniel Axtens [this message]
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=20180227130407.22498-7-dja@axtens.net \
--to=dja@axtens.net \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
/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