Skip to content

Commit f843ee6

Browse files
Andy Whitcrofttorvalds
Andy Whitcroft
authored andcommitted
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. CVE-2017-7184 Signed-off-by: Andy Whitcroft <apw@canonical.com> Acked-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 677e806 commit f843ee6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: net/xfrm/xfrm_user.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,11 @@ static inline int xfrm_replay_verify_len(struct xfrm_replay_state_esn *replay_es
412412
up = nla_data(rp);
413413
ulen = xfrm_replay_state_esn_len(up);
414414

415-
if (nla_len(rp) < ulen || xfrm_replay_state_esn_len(replay_esn) != ulen)
415+
/* Check the overall length and the internal bitmap length to avoid
416+
* potential overflow. */
417+
if (nla_len(rp) < ulen ||
418+
xfrm_replay_state_esn_len(replay_esn) != ulen ||
419+
replay_esn->bmp_len != up->bmp_len)
416420
return -EINVAL;
417421

418422
if (up->replay_window > up->bmp_len * sizeof(__u32) * 8)

0 commit comments

Comments
 (0)