Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2829911pxb; Mon, 1 Nov 2021 02:43:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySEryyOngge/lVT82oJBBTfy6T0Wr3/fbqEhbDSshfNcO8hvIcKa+ymG2NB2MHGDvycKj1 X-Received: by 2002:a05:6602:2e8c:: with SMTP id m12mr19897675iow.91.1635759799645; Mon, 01 Nov 2021 02:43:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635759799; cv=none; d=google.com; s=arc-20160816; b=r1aL+4xvA1dsERUuLny06g97Euc2sTRpDBNJoxFS0m45OmKAy+BqFXNudhqGzb3SnZ qqDuGLgfnWt4bC2jivJbr7MTtUyDm0VUScQKusFMYVciAEYvXMlDrc39ZVLEA0hXDMXz 7n1/EUJUDpmiqCkIBAJlrnCmFTlmBoSjXW1Qww+I9bFZmRqURgtF7hVftXKXLVUu91AM 1ghGAtmoQYVeSsl8XTUFKkR7daJFKa+tDrrEzIsXNR3jvtZzbCD28UxQ7zmor5HF5VFq OAIPQPUT6VBSv+rpjBgZqWiT/rfdHoKrJz2ckvxxKRa0b44timdBM3EixI68raC0C5/7 HiIA== 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=rqtbTj1ZZC29KGrQib2Y2xXGg3b/gxwhEHNd7tHtdg0=; b=N0Vc5XHOKh+a9Ye2IijRyA2BRIxOgUVfxvFy8/1csiE0qe/+JVDLvWm7WqzEpX+mCI q8HVz18XAe2rbY8yvXmkfqDAxxxa3nZSAXzwfIRr02nqmJWbfjL/4textycAMZDTyNlB y0EGYhKQ7otychG7am/dzskSFEgau14jPYPiLm1PG9656yEMEHqHpPI7ABFDJf1av+aL /Gd+FeGSbxzIhkh51cHil0lZxBEK4dAOql08m2aWmZuPao0DXzd8N7Jd4uT2JB4I53V3 afPSg/xWGI7ZuDOpGFyo/Lfpwd5KItB8IgIAZxq2yaNdhgg91iTQGJW5zc8rbfzGBi2E POpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L8e2zykI; 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 p26si13705505iol.46.2021.11.01.02.43.05; Mon, 01 Nov 2021 02:43:19 -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=L8e2zykI; 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 S233548AbhKAJmU (ORCPT + 99 others); Mon, 1 Nov 2021 05:42:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:47858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233461AbhKAJjr (ORCPT ); Mon, 1 Nov 2021 05:39:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A7F66136A; Mon, 1 Nov 2021 09:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635758849; bh=z4AJk44OSZUO1j94BmUKDQATtrKwZA7TFPAG2yfyQ9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L8e2zykIujKksfxyahn4geTmskC8D1OMwvImsxNIQyo1Tt/MgN3eL546BCu0aJcWZ 3H+DzY/VeYIBGVE1jwB+BE0AhwidP7ZdafWPHSEMPdEsV3QAEAZnmGvfMbYDqMAhR8 TTMYpCQk35hSVkvS87NxJjyfM1rJC3qaHmgAj9dc= 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 67/77] sctp: fix the processing for COOKIE_ECHO chunk Date: Mon, 1 Nov 2021 10:17:55 +0100 Message-Id: <20211101082525.642290500@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 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 5063f9884367..0cfbf6046bf8 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -697,6 +697,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. */ @@ -711,7 +714,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 @@ -2141,9 +2145,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