Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2818626pxb; Mon, 1 Nov 2021 02:26:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4Tmc8XtEhWiCRiWduGZpl96uy1eQi3iLepxY8C6pJ88BCDk6BeAZCEU87hxZ58l6H+EXZ X-Received: by 2002:aa7:dbc1:: with SMTP id v1mr39168063edt.49.1635758790761; Mon, 01 Nov 2021 02:26:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635758790; cv=none; d=google.com; s=arc-20160816; b=qwovNtnAd4YxNcuR9SNic0w1voKTdBHIADOgw6vGLlV1amjmTE5QopOx01dgRnhT8V DOQXsSz8+1Y5h8zg0opCxErNcy/13/FRGCY3I2WZO0jpaUIE2mpRVAsY8JXNRGLVc2qY PoRCylba5FnVYY5QaBNZsroM5sAfFdp/8bC57V3JH0HVqZnsxeOMYXdlwjswfjy/UG4g baZ7v/KH9CDGrXMLHS2JeRZAQwC8YchgqkkTm04Lxo47Kbh3uuPS2t4gg8euoAuhny4g pv1OoTDzUfGtv8upD0X7Q07//HYruJ2p4PCo2WSri8/FLF+sCygi8MdASPtK0ZjzUaXB kfeg== 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=zuO1uUEBzYPpRYDhBxaui4Zog0c2cZK351/fMdP+SGY=; b=pb+g7ank2Ls50VJrYKeUpYsxZJ8mU6dOMEznbxGH49Ws475oj/+doG4CELNs1/he3z q7MbTbtvu/+xvkKEldCDUPAIE63bXrzeFqWLkTVHQlxiH7LhBinkdA+p/NtjUUX1Jprj /KP3tqncSzImtTF5yxLLDoaaozxTRa/yg4UgvY8pP9YX17/2xV0VN9L43XD6ZaqrFV0R hs7DnL+oJJbjO30N7ae1VvCF9kKBmfCCPpNcpjcVt0RABKkXLLWg9EmQYYqQ10BB5XHR c2v1zOFmfm2wzW5WAzgVbWY/gv+PgdtqV5G0uN6qBaYYWcHX61KI6ybtJM3vQEAlyYSi 2QvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Lq1nE0Uf; 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 13si19820340edw.157.2021.11.01.02.26.07; Mon, 01 Nov 2021 02:26:30 -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=Lq1nE0Uf; 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 S232048AbhKAJZu (ORCPT + 99 others); Mon, 1 Nov 2021 05:25:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:59000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232419AbhKAJXQ (ORCPT ); Mon, 1 Nov 2021 05:23:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1814861184; Mon, 1 Nov 2021 09:20:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635758436; bh=II7iTCVLEc2al9USodFxVDseblv1psbvsiNLubtJpHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lq1nE0Uf7Bs3rznp+/swCpfpH38v5+yy9GGLc6g29ptCjU162u1hi137QESIw27er fe4uPxujHa95IAPtUMuC+Ig6V3XOcSr8qB/MJj2ngBiWKS7Ky/G/lB4XqXV3Hknyam wpMLdErtMMRy8eIM7WJ6vEU3meLsggJIxGw/s0AQ= 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 4.14 22/25] sctp: fix the processing for COOKIE_ECHO chunk Date: Mon, 1 Nov 2021 10:17:34 +0100 Message-Id: <20211101082452.217520170@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211101082447.070493993@linuxfoundation.org> References: <20211101082447.070493993@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 a64b341b8695e1c744dd972b39868371b4f68f83 ] 1. In closed state: in sctp_sf_do_5_1D_ce(): When asoc is NULL, making packet for abort will use chunk's vtag in sctp_ootb_pkt_new(). But when asoc exists, vtag from the chunk should be verified before using peer.i.init_tag to make packet for abort in sctp_ootb_pkt_new(), and just discard it if vtag is not correct. 2. In the other states: in sctp_sf_do_5_2_4_dupcook(): asoc always exists, but duplicate cookie_echo's vtag will be handled by sctp_tietags_compare() and then take actions, so before that we only verify the vtag for the abort sent for invalid chunk length. 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 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index b1200c4122b0..4b519ec35ab7 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -704,6 +704,9 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net, struct sock *sk; int error = 0; + if (asoc && !sctp_vtag_verify(chunk, asoc)) + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + /* If the packet is an OOTB packet which is temporarily on the * control endpoint, respond with an ABORT. */ @@ -718,7 +721,8 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net, * in sctp_unpack_cookie(). */ if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) - return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, + commands); /* If the endpoint is not listening or if the number of associations * on the TCP-style socket exceed the max backlog, respond with an @@ -2080,9 +2084,11 @@ enum sctp_disposition sctp_sf_do_5_2_4_dupcook( * enough for the chunk header. Cookie length verification is * done later. */ - if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) - return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, - commands); + if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) { + if (!sctp_vtag_verify(chunk, asoc)) + asoc = NULL; + return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, commands); + } /* "Decode" the chunk. We have no optional parameters so we * are in good shape. -- 2.33.0