espintcp: handle short messages instead of breaking the encap socket
authorSabrina Dubroca <sd@queasysnail.net>
Wed, 29 Jul 2020 16:38:42 +0000 (18:38 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Aug 2020 07:58:45 +0000 (09:58 +0200)
commit22e142108d34c5b802c37c7826799df41a11dafa
treea024fff300cd0a3b9bf15ae823b2097807be301b
parent82547aa3a8da8b672dd6c26a70d09d32d9bb6296
espintcp: handle short messages instead of breaking the encap socket

[ Upstream commit fadd1a63a7b4df295a01fa50b2f4e447542bee59 ]

Currently, short messages (less than 4 bytes after the length header)
will break the stream of messages. This is unnecessary, since we can
still parse messages even if they're too short to contain any usable
data. This is also bogus, as keepalive messages (a single 0xff byte),
though not needed with TCP encapsulation, should be allowed.

This patch changes the stream parser so that short messages are
accepted and dropped in the kernel. Messages that contain a valid SPI
or non-ESP header are processed as before.

Fixes: e27cca96cd68 ("xfrm: add espintcp (RFC 8229)")
Reported-by: Andrew Cagney <cagney@libreswan.org>
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/xfrm/espintcp.c