Commit e3aa43a5 authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Steffen Klassert
Browse files

xfrm: prevent high SEQ input in non-ESN mode



In non-ESN mode, the SEQ numbers are limited to 32 bits and seq_hi/oseq_hi
are not used. So make sure that user gets proper error message, in case
such assignment occurred.

Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent 4e412312
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -178,6 +178,12 @@ static inline int verify_replay(struct xfrm_usersa_info *p,
				       "Replay seq and seq_hi should be 0 for output SA");
			return -EINVAL;
		}
		if (rs->oseq_hi && !(p->flags & XFRM_STATE_ESN)) {
			NL_SET_ERR_MSG(
				extack,
				"Replay oseq_hi should be 0 in non-ESN mode for output SA");
			return -EINVAL;
		}
		if (rs->bmp_len) {
			NL_SET_ERR_MSG(extack, "Replay bmp_len should 0 for output SA");
			return -EINVAL;
@@ -190,6 +196,12 @@ static inline int verify_replay(struct xfrm_usersa_info *p,
				       "Replay oseq and oseq_hi should be 0 for input SA");
			return -EINVAL;
		}
		if (rs->seq_hi && !(p->flags & XFRM_STATE_ESN)) {
			NL_SET_ERR_MSG(
				extack,
				"Replay seq_hi should be 0 in non-ESN mode for input SA");
			return -EINVAL;
		}
	}

	return 0;