diff options
author | Maxim Mikityanskiy <maximmi@mellanox.com> | 2019-02-21 12:39:57 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-02-22 12:55:31 -0800 |
commit | d2aa125d629080c4f3e31f23b7f612ef6b8492ac (patch) | |
tree | 85cd897e246a879c33393582949935cb26ad1784 /include/linux/skbuff.h | |
parent | 5328b633c9b3c3af38bec8cb70120658c0866e0a (diff) | |
download | linux-d2aa125d629080c4f3e31f23b7f612ef6b8492ac.tar.gz linux-d2aa125d629080c4f3e31f23b7f612ef6b8492ac.tar.bz2 linux-d2aa125d629080c4f3e31f23b7f612ef6b8492ac.zip |
net: Don't set transport offset to invalid value
If the socket was created with socket(AF_PACKET, SOCK_RAW, 0),
skb->protocol will be unset, __skb_flow_dissect() will fail, and
skb_probe_transport_header() will fall back to the offset_hint, making
the resulting skb_transport_offset incorrect.
If, however, there is no transport header in the packet,
transport_header shouldn't be set to an arbitrary value.
Fix it by leaving the transport offset unset if it couldn't be found, to
be explicit rather than to fill it with some wrong value. It changes the
behavior, but if some code relied on the old behavior, it would be
broken anyway, as the old one is incorrect.
Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r-- | include/linux/skbuff.h | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 2069fb90a559..27beb549ffbe 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2429,8 +2429,7 @@ static inline void skb_pop_mac_header(struct sk_buff *skb) skb->mac_header = skb->network_header; } -static inline void skb_probe_transport_header(struct sk_buff *skb, - const int offset_hint) +static inline void skb_probe_transport_header(struct sk_buff *skb) { struct flow_keys_basic keys; @@ -2439,8 +2438,6 @@ static inline void skb_probe_transport_header(struct sk_buff *skb, if (skb_flow_dissect_flow_keys_basic(skb, &keys, NULL, 0, 0, 0, 0)) skb_set_transport_header(skb, keys.control.thoff); - else if (offset_hint >= 0) - skb_set_transport_header(skb, offset_hint); } static inline void skb_mac_header_rebuild(struct sk_buff *skb) |