From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH net v2] sctp: verify size of a new chunk in _sctp_make_chunk() Date: Fri, 09 Feb 2018 14:32:23 -0500 (EST) Message-ID: <20180209.143223.1410582840717699699.davem@davemloft.net> References: <1518186923-28650-1-git-send-email-alexey.kodanev@oracle.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, marcelo.leitner@gmail.com, nhorman@tuxdriver.com, vyasevich@gmail.com, linux-sctp@vger.kernel.org To: alexey.kodanev@oracle.com Return-path: Received: from shards.monkeyblade.net ([184.105.139.130]:49364 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752373AbeBITcY (ORCPT ); Fri, 9 Feb 2018 14:32:24 -0500 In-Reply-To: <1518186923-28650-1-git-send-email-alexey.kodanev@oracle.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Alexey Kodanev Date: Fri, 9 Feb 2018 17:35:23 +0300 > When SCTP makes INIT or INIT_ACK packet the total chunk length > can exceed SCTP_MAX_CHUNK_LEN which leads to kernel panic when > transmitting these packets, e.g. the crash on sending INIT_ACK: ... > Here the chunk size for INIT_ACK packet becomes too big, mostly > because of the state cookie (INIT packet has large size with > many address parameters), plus additional server parameters. > > Later this chunk causes the panic in skb_put_data(): > > skb_packet_transmit() > sctp_packet_pack() > skb_put_data(nskb, chunk->skb->data, chunk->skb->len); > > 'nskb' (head skb) was previously allocated with packet->size > from u16 'chunk->chunk_hdr->length'. > > As suggested by Marcelo we should check the chunk's length in > _sctp_make_chunk() before trying to allocate skb for it and > discard a chunk if its size bigger than SCTP_MAX_CHUNK_LEN. > > Signed-off-by: Alexey Kodanev Applied and queued up for -stable, thanks.