UPSTREAM: xfrm_user: validate XFRM_MSG_NEWAE incoming ESN size harder

Kees Cook has pointed out that xfrm_replay_state_esn_len() is subject to
wrapping issues.  To ensure we are correctly ensuring that the two ESN
structures are the same size compare both the overall size as reported
by xfrm_replay_state_esn_len() and the internal length are the same.

Signed-off-by: Andy Whitcroft <>
Acked-by: Steffen Klassert <>
Signed-off-by: Linus Torvalds <>
Signed-off-by: Andrey Ulanov <>

(chery picked from f843ee6dd019bcece3e74e76ad9df0155655d0df)

TEST=kernel compiles

Change-Id: Ifc49ff10d8e8ed8337fa61b5a7129db569892e89
Commit-Ready: Andrey Ulanov <>
Tested-by: Andrey Ulanov <>
Reviewed-by: Guenter Roeck <>
1 file changed