aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAviv Heller <avivh@mellanox.com>2017-11-28 12:55:40 -0500
committerSteffen Klassert <steffen.klassert@secunet.com>2017-12-01 01:58:53 -0500
commit4ce3dbe397d7b6b15f272ae757c78c35e9e4b61d (patch)
tree4b8f0c23319487d8767d3611f9a6dedb1dee69e4
parente719135881f00c01ca400abb8a5dadaf297a24f9 (diff)
xfrm: Fix xfrm_input() to verify state is valid when (encap_type < 0)
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: 7785bba299a8 ("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>
-rw-r--r--net/xfrm/xfrm_input.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index 347ab31574d5..da6447389ffb 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -207,7 +207,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
207 xfrm_address_t *daddr; 207 xfrm_address_t *daddr;
208 struct xfrm_mode *inner_mode; 208 struct xfrm_mode *inner_mode;
209 u32 mark = skb->mark; 209 u32 mark = skb->mark;
210 unsigned int family; 210 unsigned int family = AF_UNSPEC;
211 int decaps = 0; 211 int decaps = 0;
212 int async = 0; 212 int async = 0;
213 bool xfrm_gro = false; 213 bool xfrm_gro = false;
@@ -216,6 +216,16 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
216 216
217 if (encap_type < 0) { 217 if (encap_type < 0) {
218 x = xfrm_input_state(skb); 218 x = xfrm_input_state(skb);
219
220 if (unlikely(x->km.state != XFRM_STATE_VALID)) {
221 if (x->km.state == XFRM_STATE_ACQ)
222 XFRM_INC_STATS(net, LINUX_MIB_XFRMACQUIREERROR);
223 else
224 XFRM_INC_STATS(net,
225 LINUX_MIB_XFRMINSTATEINVALID);
226 goto drop;
227 }
228
219 family = x->outer_mode->afinfo->family; 229 family = x->outer_mode->afinfo->family;
220 230
221 /* An encap_type of -1 indicates async resumption. */ 231 /* An encap_type of -1 indicates async resumption. */