BACKPORT: xfrm: Fix return value check of copy_sec_ctx.

A recent commit added an output_mark. When copying
this output_mark, the return value of copy_sec_ctx
is overwitten without a check. Fix this by copying
the output_mark before the security context.

Fixes: 077fbac405 ("net: xfrm: support setting an output mark.")
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
(cherry picked from commit 8598112d04)

Change-Id: I25e9ac6cf79dc8d0ee599bbd23e9d5b5f34a4284
This commit is contained in:
Steffen Klassert
2017-08-31 10:37:00 +02:00
committed by Dmitry Shmidt
parent d2c57b6056
commit 2a5cc53ea1

View File

@@ -872,13 +872,13 @@ static int copy_to_user_state_extra(struct xfrm_state *x,
&x->replay);
if (ret)
goto out;
if (x->security)
ret = copy_sec_ctx(x->security, skb);
if (x->props.output_mark) {
ret = nla_put_u32(skb, XFRMA_OUTPUT_MARK, x->props.output_mark);
if (ret)
goto out;
}
if (x->security)
ret = copy_sec_ctx(x->security, skb);
out:
return ret;
}