Skip to content

Commit

Permalink
xfrm: Fix xfrm_input() to verify state is valid when (encap_type < 0)
Browse files Browse the repository at this point in the history
[ Upstream commit 4ce3dbe ]

Code path when (encap_type < 0) does not verify the state is valid
before progressing.

This will result in a crash if, for instance, x->km.state ==
XFRM_STATE_ACQ.

Fixes: 7785bba ("esp: Add a software GRO codepath")
Signed-off-by: Aviv Heller <avivh@mellanox.com>
Signed-off-by: Yevgeny Kliteynik <kliteyn@mellanox.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Aviv Heller authored and gregkh committed Feb 25, 2018
1 parent 05fc2b8 commit c232fd3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion net/xfrm/xfrm_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
xfrm_address_t *daddr;
struct xfrm_mode *inner_mode;
u32 mark = skb->mark;
unsigned int family;
unsigned int family = AF_UNSPEC;
int decaps = 0;
int async = 0;
bool xfrm_gro = false;
Expand All @@ -216,6 +216,16 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)

if (encap_type < 0) {
x = xfrm_input_state(skb);

if (unlikely(x->km.state != XFRM_STATE_VALID)) {
if (x->km.state == XFRM_STATE_ACQ)
XFRM_INC_STATS(net, LINUX_MIB_XFRMACQUIREERROR);
else
XFRM_INC_STATS(net,
LINUX_MIB_XFRMINSTATEINVALID);
goto drop;
}

family = x->outer_mode->afinfo->family;

/* An encap_type of -1 indicates async resumption. */
Expand Down

0 comments on commit c232fd3

Please sign in to comment.