Hi, On Mon, Jan 30, 2023 at 02:51:49PM +0100, Greg Kroah-Hartman wrote: > From: Sriram Yagnaraman <sriram.yagnaraman@xxxxxxxx> > > [ Upstream commit 98ee0077452527f971567db01386de3c3d97ce13 ] > > skb_header_pointer() will return NULL if offset + sizeof(_sch) exceeds > skb->len, so this offset < skb->len test is redundant. > > if sch->length == 0, this will end up in an infinite loop, add a check > for sch->length > 0 Please, keep back this patch. for_each_sctp_chunk() is fine because do_basic_checks() already make sure what sch->length is sane. A revert is scheduled for the net.git tree, the revert should show up in the next 6.2-rc release. Sorry for the inconvenience. > Fixes: 9fb9cbb1082d ("[NETFILTER]: Add nf_conntrack subsystem.") > Suggested-by: Florian Westphal <fw@xxxxxxxxx> > Signed-off-by: Sriram Yagnaraman <sriram.yagnaraman@xxxxxxxx> > Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> > Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> > --- > net/netfilter/nf_conntrack_proto_sctp.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c > index 3704d1c7d3c2..ee317f9a22e5 100644 > --- a/net/netfilter/nf_conntrack_proto_sctp.c > +++ b/net/netfilter/nf_conntrack_proto_sctp.c > @@ -155,8 +155,8 @@ static void sctp_print_conntrack(struct seq_file *s, struct nf_conn *ct) > > #define for_each_sctp_chunk(skb, sch, _sch, offset, dataoff, count) \ > for ((offset) = (dataoff) + sizeof(struct sctphdr), (count) = 0; \ > - (offset) < (skb)->len && \ > - ((sch) = skb_header_pointer((skb), (offset), sizeof(_sch), &(_sch))); \ > + ((sch) = skb_header_pointer((skb), (offset), sizeof(_sch), &(_sch))) && \ > + (sch)->length; \ > (offset) += (ntohs((sch)->length) + 3) & ~3, (count)++) > > /* Some validity checks to make sure the chunks are fine */ > -- > 2.39.0 > > >