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

commit f4979fcea7fd36d8e2f556abef86f80e0d5af1ba upstream.

Sockets can have a filter program attached that drops or trims
incoming packets based on the filter program return value.

Rose requires data packets to have at least ROSE_MIN_LEN bytes. It
verifies this on arrival in rose_route_frame and unconditionally pulls
the bytes in rose_recvmsg. The filter can trim packets to below this
value in-between, causing pull to fail, leaving the partial header at
the time of skb_copy_datagram_msg.

Place a lower bound on the size to which sk_filter may trim packets
by introducing sk_filter_trim_cap and call this for rose packets.

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/linux/filter.h
net/core/filter.c
net/rose/rose_in.c