Skip to content

Commit e3aa43a

Browse files
rleonklassert
authored andcommitted
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: Leon Romanovsky <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 4e41231 commit e3aa43a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

net/xfrm/xfrm_user.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ static inline int verify_replay(struct xfrm_usersa_info *p,
178178
"Replay seq and seq_hi should be 0 for output SA");
179179
return -EINVAL;
180180
}
181+
if (rs->oseq_hi && !(p->flags & XFRM_STATE_ESN)) {
182+
NL_SET_ERR_MSG(
183+
extack,
184+
"Replay oseq_hi should be 0 in non-ESN mode for output SA");
185+
return -EINVAL;
186+
}
181187
if (rs->bmp_len) {
182188
NL_SET_ERR_MSG(extack, "Replay bmp_len should 0 for output SA");
183189
return -EINVAL;
@@ -190,6 +196,12 @@ static inline int verify_replay(struct xfrm_usersa_info *p,
190196
"Replay oseq and oseq_hi should be 0 for input SA");
191197
return -EINVAL;
192198
}
199+
if (rs->seq_hi && !(p->flags & XFRM_STATE_ESN)) {
200+
NL_SET_ERR_MSG(
201+
extack,
202+
"Replay seq_hi should be 0 in non-ESN mode for input SA");
203+
return -EINVAL;
204+
}
193205
}
194206

195207
return 0;

0 commit comments

Comments
 (0)