Skip to content

Commit bd0e06f

Browse files
Florian Westphalummakynes
authored andcommitted
Revert "netfilter: conntrack: fix bug in for_each_sctp_chunk"
There is no bug. If sch->length == 0, this would result in an infinite loop, but first caller, do_basic_checks(), errors out in this case. After this change, packets with bogus zero-length chunks are no longer detected as invalid, so revert & add comment wrt. 0 length check. Fixes: 98ee007 ("netfilter: conntrack: fix bug in for_each_sctp_chunk") Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 2b272bb commit bd0e06f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/netfilter/nf_conntrack_proto_sctp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,11 @@ static void sctp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
142142
}
143143
#endif
144144

145+
/* do_basic_checks ensures sch->length > 0, do not use before */
145146
#define for_each_sctp_chunk(skb, sch, _sch, offset, dataoff, count) \
146147
for ((offset) = (dataoff) + sizeof(struct sctphdr), (count) = 0; \
147-
((sch) = skb_header_pointer((skb), (offset), sizeof(_sch), &(_sch))) && \
148-
(sch)->length; \
148+
(offset) < (skb)->len && \
149+
((sch) = skb_header_pointer((skb), (offset), sizeof(_sch), &(_sch))); \
149150
(offset) += (ntohs((sch)->length) + 3) & ~3, (count)++)
150151

151152
/* Some validity checks to make sure the chunks are fine */

0 commit comments

Comments
 (0)