Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2828225pxb; Mon, 1 Nov 2021 02:40:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWGwDZTUK9Qbp/Ow3bGJ050Ch8tiP3W5laA7xV9zZ+UGgqQUpBTUYFe774yJikSBckF4P2 X-Received: by 2002:a17:907:7f1a:: with SMTP id qf26mr1832538ejc.543.1635759636093; Mon, 01 Nov 2021 02:40:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635759636; cv=none; d=google.com; s=arc-20160816; b=oXobX63gZrfsUC1z0Y+MAz0MSOEZW+o87px8+qB1Pogh4UsSABZ8yTkuEUFaMCvx5r UYhVLh91vzW+JruZJ52V+sPFES4/2P9+DCay3HKJPr+/hQGi3UzAAoiGdJ/tRm7orAVn AJl6CTJlatnBF2FuDM8C/sL52LVMIgUIJR9iPU/uOcz9S9gT17Qv+NRJcunl/8h0iBgE /e1r62t4laS7WwSecRDIVL99u2dk3t2yLHMv8KhwITutE2ToWmJr1XCGMlX+FXQ04Qyd MZ/CR1mbduerEtzE/J2eoY8G6BCsSQI5j1ImlD91lKNC5t8R4isGjy+0jnC/zlZlR9/c +HmA== 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=0azxJeoyHWjL5o1PzHx2wgAbI4U5DSOtatU2AQXmHws=; b=jCeZyoD/HcCpnw/x4FmUismm1c+PEfhjQc8pFfzhdsFd4JvNitWt+upQ4/gPYexh67 tt/2oWkCTC4Eudm4GxylGIti/i04zp24yiUscsa1kEmuAbZQt5P4peaIGJJfQnqOPfVK GxJLFukGbM8MZOLZprdQCyQt8IjmQWmGAvMFLIjX3TnfZM98tntRyJT1ag+GH5rPLdam KiFdfOSszYnUh+fqHRRP3ufP9WE4tTGSDBFnSpb53kI/czaqQhK2KdUGEtECOSppcWrm dYyB7FlsmjIZQVkuqFzhNmE1qpP4PxwWWOOM4/y0Q8sDE0oEIr4eFaSB02d+ZvXTj/qv 2SFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L9LvMGVn; 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 j23si23468181eje.501.2021.11.01.02.40.12; Mon, 01 Nov 2021 02:40:36 -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=L9LvMGVn; 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 S232253AbhKAJkW (ORCPT + 99 others); Mon, 1 Nov 2021 05:40:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:43768 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233269AbhKAJiB (ORCPT ); Mon, 1 Nov 2021 05:38:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5195460C40; Mon, 1 Nov 2021 09:27:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635758830; bh=Jvpik9FvINvRHA6J9D7wbfFQIuxv3Q3TRsZeMkd0GXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L9LvMGVn1qBeO+lqbrSHKubix/FO4cZ4BO/fr3yUJ2JGvoYn/1HMxuZ8iFL9D4Wi8 0sJY1xxT8NiRdk/1d7rOaLMUcqHj2Y+GuD7ff1b4I/eq2M2jPz180MtPygUVyyKpMh 38zbJAj13GUP87UDHi4TvhYREZv0cXxo+Vj2IWZc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Long , Marcelo Ricardo Leitner , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 69/77] sctp: add vtag check in sctp_sf_do_8_5_1_E_sa Date: Mon, 1 Nov 2021 10:17:57 +0100 Message-Id: <20211101082526.027989800@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211101082511.254155853@linuxfoundation.org> References: <20211101082511.254155853@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: Xin Long [ Upstream commit ef16b1734f0a176277b7bb9c71a6d977a6ef3998 ] sctp_sf_do_8_5_1_E_sa() is called when processing SHUTDOWN_ACK chunk in cookie_wait and cookie_echoed state. The vtag in the chunk's sctphdr should be verified, otherwise, as later in chunk length check, it may send abort with the existent asoc's vtag, which can be exploited by one to cook a malicious chunk to terminate a SCTP asoc. Note that when fails to verify the vtag from SHUTDOWN-ACK chunk, SHUTDOWN COMPLETE message will still be sent back to peer, but with the vtag from SHUTDOWN-ACK chunk, as said in 5) of rfc4960#section-8.4. While at it, also remove the unnecessary chunk length check from sctp_sf_shut_8_4_5(), as it's already done in both places where it calls sctp_sf_shut_8_4_5(). Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Xin Long Acked-by: Marcelo Ricardo Leitner Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sctp/sm_statefuns.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 324c0222d9e6..82a76fda226b 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -3683,12 +3683,6 @@ static enum sctp_disposition sctp_sf_shut_8_4_5( SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); - /* If the chunk length is invalid, we don't want to process - * the reset of the packet. - */ - if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) - return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); - /* We need to discard the rest of the packet to prevent * potential bomming attacks from additional bundled chunks. * This is documented in SCTP Threats ID. @@ -3716,6 +3710,9 @@ enum sctp_disposition sctp_sf_do_8_5_1_E_sa(struct net *net, { struct sctp_chunk *chunk = arg; + if (!sctp_vtag_verify(chunk, asoc)) + asoc = NULL; + /* Make sure that the SHUTDOWN_ACK chunk has a valid length. */ if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, -- 2.33.0