Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp621199pxv; Thu, 15 Jul 2021 11:45:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxPiQNXR8cjkOOivkXcoh5/oKjOEY3/LrKKk9LN13YU8F/daODbMkRQsdH4RIjv2tQB9jP X-Received: by 2002:a02:620a:: with SMTP id d10mr5420056jac.22.1626374716315; Thu, 15 Jul 2021 11:45:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626374716; cv=none; d=google.com; s=arc-20160816; b=gnpR5sVDuAm1ijsxJJvGLRPOAjPB4s66txNuWg0cB2ovY+SSokpHHPTBmnH82qm0MY 7DREplcbmoqG1YNXVtEWuGEkiAgKLt73rlDaS9rDBoTCpgk5kJdUtSCR+sgtsK1LzcHS kXHqkb3eAKh8s66VpbnbLzGIeK0gxJUQObXfdtkRlvehdu5yMdhnwXojEkzutPzhwD+h 8pDyLeCYA8jnDix5o+jkpi3j3ypi5DDR46SNO7T93ucqjhvoEDrYX24OPFAu1joyLFoI qgL3zqwkXoHN4YSGor67EhJ33HcUBigw1C+ZLjswTAOsBovIxKisAzzIH7YQjOzmAfkV iNzw== 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=jVk7hC+kHW3HVjaAEhA9D3Kg+FOErhPs0E+LzPo9k5Y=; b=EzKPYMph0uOaaH1bpixYWv3mABmuoR8yTCC1bKkDhp+oONopy0fze2CDEHNBF6QKfS pEqugp+PAFjdnVK32Mis8SSH4lcH+eFENFrAyRepwlno719ohLtr9Up/cJxDwWXJ1RR3 1ZG4bt4puiXEpGcBa31zZa8eND+AZBVYqjHInOyXQBSmtB6d6JQay3ceU8U79ZLA0ycr jmtWOgvPRw2LPRsBEzTjSAVlORsIVH74KiLIgel4BzP8npKO9Ifb+8BvW48+8ifjamGx NOo6+RZK0jTkeU6uktv1KhV5Di0t5M+sL0EReW2gGy9PJlDdaipDSWTttnVVTw6zJkuZ UXfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="TZ99/b4D"; 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 r9si7784951jad.24.2021.07.15.11.45.03; Thu, 15 Jul 2021 11:45:16 -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="TZ99/b4D"; 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 S234996AbhGOSrQ (ORCPT + 99 others); Thu, 15 Jul 2021 14:47:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:47558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237977AbhGOSqW (ORCPT ); Thu, 15 Jul 2021 14:46:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7A7B1613CA; Thu, 15 Jul 2021 18:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374608; bh=CFfpxMYRtSFEtrkuK4v7XIcMIQZy/kBrY4eH87LdzPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TZ99/b4D2/zGWcVYALtzYS96RGG2Jyhi+QIGTXnVXcopiq+fu1O5h5VGUrZE71xXH /ttRMSwvl5Fu295rQSUNr+WjzOvQ7Zk74LWcyZMcRku1u9BH4m+fyMQ7QJhyrIdGw6 j5bJJ2IzBHjzRpyXJvahWL2OYyY9hZOBWG/gdyLs= 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.4 069/122] sctp: add size validation when walking chunks Date: Thu, 15 Jul 2021 20:38:36 +0200 Message-Id: <20210715182507.853408276@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182448.393443551@linuxfoundation.org> References: <20210715182448.393443551@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 a84523284777..ab84ebf1af4a 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