ipv6: sr: fix TLVs not being copied using setsockopt
authorMathieu Xhonneux <m.xhonneux@gmail.com>
Wed, 10 Jan 2018 13:35:49 +0000 (13:35 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Jan 2018 08:45:23 +0000 (09:45 +0100)
commit0c21439334069b0cf8cac9f9115918b9b3a11287
treed79fa43ee87b30734fdf6d5aef94c10652f9e7e7
parent71e7f85e10f189f4aa0162d6eea4a7163a48e3a6
ipv6: sr: fix TLVs not being copied using setsockopt

[ Upstream commit ccc12b11c5332c84442ef120dcd631523be75089 ]

Function ipv6_push_rthdr4 allows to add an IPv6 Segment Routing Header
to a socket through setsockopt, but the current implementation doesn't
copy possible TLVs at the end of the SRH received from userspace.

Therefore, the execution of the following branch if (sr_has_hmac(sr_phdr))
{ ... } will never complete since the len and type fields of a possible
HMAC TLV are not copied, hence seg6_get_tlv_hmac will return an error,
and the HMAC will not be computed.

This commit adds a memcpy in case TLVs have been appended to the SRH.

Fixes: a149e7c7ce81 ("ipv6: sr: add support for SRH injection through setsockopt")
Acked-by: David Lebrun <dlebrun@google.com>
Signed-off-by: Mathieu Xhonneux <m.xhonneux@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv6/exthdrs.c