From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F880C433F5 for ; Fri, 24 Sep 2021 12:46:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9DF661261 for ; Fri, 24 Sep 2021 12:46:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344069AbhIXMsN (ORCPT ); Fri, 24 Sep 2021 08:48:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:42988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344014AbhIXMrD (ORCPT ); Fri, 24 Sep 2021 08:47:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0E89561260; Fri, 24 Sep 2021 12:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632487530; bh=jPrAIjOnE9U32AaHjKoe+pTOn1XGU5OSULffrCeTEmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OKjz24yZJG9xwg5JQnJKK77ZH3Fenl7qBeda2gyq/H9rpI5eoboFwgveGolappSrn 3B5JE2SgdGlAP75DUxun+CIM0tbOQZFURZG0f4mnp27cfHXSVU0K4FZUh82LWj+RhJ NWer/7t0yTfMklnY/3lz6tBlYH4BTVwO9EmBADSw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marcelo Ricardo Leitner , "David S. Miller" Subject: [PATCH 4.9 05/26] sctp: validate chunk size in __rcv_asconf_lookup Date: Fri, 24 Sep 2021 14:43:53 +0200 Message-Id: <20210924124328.526180315@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210924124328.336953942@linuxfoundation.org> References: <20210924124328.336953942@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marcelo Ricardo Leitner commit b6ffe7671b24689c09faa5675dd58f93758a97ae upstream. In one of the fallbacks that SCTP has for identifying an association for an incoming packet, it looks for AddIp chunk (from ASCONF) and take a peek. Thing is, at this stage nothing was validating that the chunk actually had enough content for that, allowing the peek to happen over uninitialized memory. Similar check already exists in actual asconf handling in sctp_verify_asconf(). Signed-off-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sctp/input.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/sctp/input.c +++ b/net/sctp/input.c @@ -1087,6 +1087,9 @@ static struct sctp_association *__sctp_r union sctp_addr_param *param; union sctp_addr paddr; + if (ntohs(ch->length) < sizeof(*asconf) + sizeof(struct sctp_paramhdr)) + return NULL; + /* Skip over the ADDIP header and find the Address parameter */ param = (union sctp_addr_param *)(asconf + 1);