From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC0CC3229 for ; Mon, 30 Jan 2023 14:25:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D0B2C4339C; Mon, 30 Jan 2023 14:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675088757; bh=82A5NxYoMy8hQMGvIa69v28WpoMI5DX2qkgAXOKUwFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OOqi4blXHHfKYN4x80ek0etpfYFf+OZq/Gx0eJec0+Xkr8FniY3Tgq+kykHTxIk/t lqhXpWI6LKk/+JbZ9An7qGSZ3Rtoh2y+xUVIfOe9GuHwkE+LhdgONIfmzdtPGXswPP 6csfetO3ZrKHMU2t4Y4A491AksWuU3ZcL4tUa0qs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Florian Westphal , Sriram Yagnaraman , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.10 126/143] netfilter: conntrack: fix bug in for_each_sctp_chunk Date: Mon, 30 Jan 2023 14:53:03 +0100 Message-Id: <20230130134312.038406099@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134306.862721518@linuxfoundation.org> References: <20230130134306.862721518@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Sriram Yagnaraman [ 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 Fixes: 9fb9cbb1082d ("[NETFILTER]: Add nf_conntrack subsystem.") Suggested-by: Florian Westphal Signed-off-by: Sriram Yagnaraman Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- 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 72d0aa603cd6..c0264bbc8466 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