Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp630039pxv; Thu, 15 Jul 2021 11:58:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW0u2ocU0j0n8EYh28Ixt3qukdj9aKbszbVG+u+69I360E2HaZ+4zFW1Mx8JIEbO2lqUSy X-Received: by 2002:a05:6e02:669:: with SMTP id l9mr3899963ilt.244.1626375523293; Thu, 15 Jul 2021 11:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375523; cv=none; d=google.com; s=arc-20160816; b=W5FgpwHhL9mqjCELpMcWS6V7+w1YR+Lv7WkG960hD+rON/PpkmTopuJyJjjY3ydzzs QRfaz81n2iVQYbWnNioDQSVfBZ5S+sGbONonZH3EMmAAnPFfXpBfuXlix9fp6w5sJe49 oMwL325j1kVbAhwg0sd703AZ9nitstlweY0Rrk6TeNK2em/MqSiJkb7vd5R5oi1hV6Pl l63FqEaKlDt8ogYVgooaFdlr7mw6uwDaW9TAmlOATE35V8lISjYhN4pVz4N0y5YcqhUo R5PJhJmMFLtrtN1bb8rEVhHppsxQkvhTX8RXzwkFUTedHd/z0SBs6OwSkWQl4OznmuNE G/Lg== 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=gEEzwrf7rkRzAkCWhKTOZEG56Cxq1fu4SRPbzb1+CRelo3wzhKaegJYFmHL1wKiS4P XCWx9r96s4Y6rz7QZllPFzd1bRHFvWytT32HLVPPhhQfaL6dY1Koso/roQDAO8K4bOAm KQmQ0Ifch+U/cvk50sOldcCupwRKZkNBVLDkaCPEdzmjQFNMPtq+s+hGFR8RYMQ2v36j KT9gy9U3c9pxT4vw1Cn3u/iRJCiZUUpLy6cADLTeLBY5q7VQHbQxAD4MiWEEgiUuAEfn JDmpFhcGDOQ9jxsXZ8yE11O9lppZ1NVEwReYG2IKxkNci3hww0Ig2zx2kl1rwzVmmSyt drPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=a3va5pJX; 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 e1si8477777ile.16.2021.07.15.11.58.30; Thu, 15 Jul 2021 11:58:43 -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=a3va5pJX; 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 S243102AbhGOTAM (ORCPT + 99 others); Thu, 15 Jul 2021 15:00:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:57764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237084AbhGOSx2 (ORCPT ); Thu, 15 Jul 2021 14:53:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 008E8613D6; Thu, 15 Jul 2021 18:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375034; bh=tMnwuOqsKetrJOZHCxfof29wQdNfyrd0hr/fLSioJSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a3va5pJXwBap0Yc6qkAq/CVL7Lj+bJ/hcxEDLuTEZ5uDsYtihFGkNIVB81UIMmZgo /PcTowf4vz2dIQnJcczS+yo6v7r3ZjjI100NPsyWpk/5JBFQWZclxUW5NEMjZ1ay1M dl9mVIZ3uiKSL2cf9CI/Bm9ZlYV+3+DFptJu4mt8= 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.10 130/215] sctp: add size validation when walking chunks Date: Thu, 15 Jul 2021 20:38:22 +0200 Message-Id: <20210715182622.598521276@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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