dccp: limit sk_filter trim to payload
authorWillem de Bruijn <willemb@google.com>
Tue, 12 Jul 2016 22:18:57 +0000 (18:18 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 23 Feb 2017 03:51:05 +0000 (03:51 +0000)
commit9b2e057859a2edb5daef515f70fb3db2d3915192
tree39db68309db51cccf2b1dc3bb390b7b88bce2fd8
parentd0e04e049a62ad9e7371bbd6897f17e56900c48f
dccp: limit sk_filter trim to payload

commit 4f0c40d94461cfd23893a17335b2ab78ecb333c8 upstream.

Dccp verifies packet integrity, including length, at initial rcv in
dccp_invalid_packet, later pulls headers in dccp_enqueue_skb.

A call to sk_filter in-between can cause __skb_pull to wrap skb->len.
skb_copy_datagram_msg interprets this as a negative value, so
(correctly) fails with EFAULT. The negative length is reported in
ioctl SIOCINQ or possibly in a DCCP_WARN in dccp_close.

Introduce an sk_receive_skb variant that caps how small a filter
program can trim packets, and call this in dccp with the header
length. Excessively trimmed packets are now processed normally and
queued for reception as 0B payloads.

Fixes: 7c657876b63c ("[DCCP]: Initial implementation")
Signed-off-by: Willem de Bruijn <willemb@google.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
include/net/sock.h
net/core/sock.c
net/dccp/ipv4.c
net/dccp/ipv6.c