Skip to content

Commit d71b789

Browse files
edumazetdavem330
authored andcommitted
netlabel: out of bound access in cipso_v4_validate()
syzkaller found another out of bound access in ip_options_compile(), or more exactly in cipso_v4_validate() Fixes: 20e2a86 ("cipso: handle CIPSO options correctly when NetLabel is disabled") Fixes: 446fda4 ("[NetLabel]: CIPSOv4 engine") Signed-off-by: Eric Dumazet <[email protected]> Reported-by: Dmitry Vyukov <[email protected]> Cc: Paul Moore <[email protected]> Acked-by: Paul Moore <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 34b2cef commit d71b789

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

include/net/cipso_ipv4.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ static inline int cipso_v4_validate(const struct sk_buff *skb,
309309
}
310310

311311
for (opt_iter = 6; opt_iter < opt_len;) {
312+
if (opt_iter + 1 == opt_len) {
313+
err_offset = opt_iter;
314+
goto out;
315+
}
312316
tag_len = opt[opt_iter + 1];
313317
if ((tag_len == 0) || (tag_len > (opt_len - opt_iter))) {
314318
err_offset = opt_iter + 1;

net/ipv4/cipso_ipv4.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,10 @@ int cipso_v4_validate(const struct sk_buff *skb, unsigned char **option)
15871587
goto validate_return_locked;
15881588
}
15891589

1590+
if (opt_iter + 1 == opt_len) {
1591+
err_offset = opt_iter;
1592+
goto validate_return_locked;
1593+
}
15901594
tag_len = tag[1];
15911595
if (tag_len > (opt_len - opt_iter)) {
15921596
err_offset = opt_iter + 1;

0 commit comments

Comments
 (0)