Skip to content

Commit 0561c72

Browse files
committed
Fix possible out-of-bounds read in tcp_options fix
Out-of-bound read could happen in `p[i] < 2` before boundary of `i` is checked. Basically it's returning previous code except for a fix and early zeroing of `ret`. Fixes: a1386af ("tcp options: fix possible shift-out-of-bounds") Signed-off-by: ABC <[email protected]>
1 parent faf869c commit 0561c72

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ipt_NETFLOW.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -4852,12 +4852,16 @@ static inline __u32 tcp_options(const struct sk_buff *skb, const unsigned int pt
48524852
for (i = 0; likely(i < optsize); ) {
48534853
u_int8_t opt = p[i++];
48544854

4855-
if (likely(opt < 32))
4855+
if (likely(opt < 32)) {
4856+
/* IANA doc is messed up, see above. */
48564857
ret |= 1 << (31 - opt);
4857-
if (likely(opt == 0) || unlikely(p[i] < 2))
4858+
}
4859+
if (likely(i >= optsize || opt == 0))
48584860
break;
4859-
if (unlikely(opt == 1))
4861+
else if (unlikely(opt == 1))
48604862
continue;
4863+
else if (unlikely(p[i] < 2)) /* "silly options" */
4864+
break;
48614865
else
48624866
i += p[i] - 1;
48634867
}

0 commit comments

Comments
 (0)