Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp710154pxv; Thu, 15 Jul 2021 14:07:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyT0CeGPNhxKifDtYiK5lPI8J+oC54TSRFu4LlKm97jvEBEf2dRE/m1kDSJqVn2N6Vf7UTa X-Received: by 2002:a05:6402:895:: with SMTP id e21mr9642113edy.9.1626383244084; Thu, 15 Jul 2021 14:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383244; cv=none; d=google.com; s=arc-20160816; b=nSbCYlksf9qnj4fX+TvcC31Ap2kmidp8Q87ucMxiwNduo+q1LWtxa0Cdpz/KsF4YJ0 9hDiTk21saYmUPcXLYKySi0WP9heCYPH3DkVbPuUdoPjNiIpMfvHQYSPlaQtVjuadtSb D9Prk248uixQhjGHkDRqkRU1dAycWu/AM4adFUVxdW5Nwym4SlCx7i+fYnqTCXUpAdpg As8xWIaW2Dr51cazuimKJbP/R0sAqo+yUTeR0llHqCHuKQg05fzg46FbG5ZjOwxYIGvH 3U5fooKOesoFRSNrml29KiareTrAB8t5FPCA38BOfBPYsATQ6rPoNsfNpFDvCH4/toT2 SnyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OBwkJ5ZJvy6PW24WV4/tlH7H5x+49CpdAJyPjEB0FrU=; b=KVt3QghF6vC01/ySHbTLxsSyZbm+IcDIb4igJlWsWTqEfUIc5P5s4BlR1UgYUpG/ZR uBXuvu7Tinh1tf41Wm6dTL6l72coYHBeVRxbZD0aqoMxcdckL8XrOKM2ci/sTvDChTnH GDd2JBSELRlrSiyy3SHrpK01SO721hIKz45E3DJuReB+mKAv7z++W+jvdx3dCFgSWmDl 15C7LLMZHAJ3vgBDr1DFxwf9ZJd22Os/lucc4i7vtY7i0e4EAFgfU4QvHLsakamExRfh UQMZ0Izj4QWUS2ZvHUafWNAnayWbrkv6/kIytWQnCJDO2UJv60cLL3iN5dLZRgR1CZ9k uTQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DHaJG57d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o17si7863784eji.157.2021.07.15.14.07.01; Thu, 15 Jul 2021 14:07:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DHaJG57d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244868AbhGOTSt (ORCPT + 99 others); Thu, 15 Jul 2021 15:18:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:39498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243249AbhGOTET (ORCPT ); Thu, 15 Jul 2021 15:04:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 36F17613FB; Thu, 15 Jul 2021 18:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375588; bh=tMnwuOqsKetrJOZHCxfof29wQdNfyrd0hr/fLSioJSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DHaJG57d6IbHBbkBrG49zXRfr0vChmU1DnKOxmip2anRIeIznD2WmYlUv4M9AeZ0e +qT/ggXgEXdzfoFDIKo3i9yYcMaR/p2EDsTT7DFZpqjM4NaPx6d/KNnLCrUTTm2Iva ehX5/eeE+uFiqwwVhCcahCBwnf14T2iXvM8cPygA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilja Van Sprundel , Marcelo Ricardo Leitner , "David S. Miller" , Sasha Levin Subject: [PATCH 5.12 150/242] sctp: add size validation when walking chunks Date: Thu, 15 Jul 2021 20:38:32 +0200 Message-Id: <20210715182619.611498349@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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 [ Upstream commit 50619dbf8db77e98d821d615af4f634d08e22698 ] The first chunk in a packet is ensured to be present at the beginning of sctp_rcv(), as a packet needs to have at least 1 chunk. But the second one, may not be completely available and ch->length can be over uninitialized memory. Fix here is by only trying to walk on the next chunk if there is enough to hold at least the header, and then proceed with the ch->length validation that is already there. Reported-by: Ilja Van Sprundel Signed-off-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sctp/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sctp/input.c b/net/sctp/input.c index 8924e2e142c8..f72bff93745c 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c @@ -1247,7 +1247,7 @@ static struct sctp_association *__sctp_rcv_walk_lookup(struct net *net, ch = (struct sctp_chunkhdr *)ch_end; chunk_num++; - } while (ch_end < skb_tail_pointer(skb)); + } while (ch_end + sizeof(*ch) < skb_tail_pointer(skb)); return asoc; } -- 2.30.2