net: Don't set transport offset to invalid value
authorMaxim Mikityanskiy <maximmi@mellanox.com>
Thu, 21 Feb 2019 12:39:57 +0000 (12:39 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 22 Feb 2019 20:55:31 +0000 (12:55 -0800)
commitd2aa125d629080c4f3e31f23b7f612ef6b8492ac
tree85cd897e246a879c33393582949935cb26ad1784
parent5328b633c9b3c3af38bec8cb70120658c0866e0a
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>
drivers/net/tap.c
drivers/net/tun.c
drivers/net/xen-netback/netback.c
include/linux/skbuff.h
include/linux/virtio_net.h
net/packet/af_packet.c