Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1679325pxu; Sun, 6 Dec 2020 03:49:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwScpgZSnr0+FVUf2DsNqEHBRjwc6UX+zMzex+3H5c12phre8HujS1FlDuNpLLnGYFlu8nE X-Received: by 2002:aa7:cccf:: with SMTP id y15mr10418391edt.112.1607255372231; Sun, 06 Dec 2020 03:49:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607255372; cv=none; d=google.com; s=arc-20160816; b=fNxrXgOWQB7pvVYjq9fWeYHxcxh4dv+nqWFleMJsxiJ57HL4fSg7vS4SJIJXVMou3L UvqCRp7N+O5KvF5JmPP77Y43lLAL6hjAvEbr090wf7tjGpIHg8f59dFN4bclSxAjxgrg bjZ2db33Ii+EjJBd3NeI1cUoT+l2WCEqKupwLlXUIRtUFl6jHA7VdBHms7jXsQmDo0lE 4cf3U56qwRcsrdEK4CcMETNXuKVTE8evj8D2gWdhZcPVqkOngWVfPVXZ9LT2+nTrjSeJ UGa8mRh4N3OwukPQVZ6aBEg7nMQHLsZ9iuXGpgZtTXQ6Z6t53EMltt2e4qo1vAkDK62p wijg== 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; bh=6djj2addQkJrq7gkfz6e7UUtPLPBc3BQBfL80QNcYDQ=; b=e+Ta4ywwc0dL/bWsSxqnWlmSdZMvagwMs/TtufqG9iYPRX4VOvBGSpnW1HerGVAzey 5ZCWqMS1gr+uxLkfFBIxsQ0BQzHfzNptl/0Uo7YFndYJe/GGCWpUHereKTraz3s/uIqf M/TkGXRuDvyZJ5cwdsvTpjppfOEPFR4zLVxLF3Ag7yPoPPoJUcldWCYmtTqysGsM0Zmm VbmSqbAkQgztf4IiZoJgVkqSysmU0ZJh2D8Kjgy+XiXwpaafNH2WwFocWvZnoFXfEA7J e8UBKVz16pRZ2FBhsQurVyvErfTNpe+xRjxJ+Njdz3YhZPgc/wR5vJcBgZTEVSyDIa7y mR2Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 d26si4149850ejy.617.2020.12.06.03.49.09; Sun, 06 Dec 2020 03:49:32 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729569AbgLFLpr (ORCPT + 99 others); Sun, 6 Dec 2020 06:45:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:46162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgLFLpq (ORCPT ); Sun, 6 Dec 2020 06:45:46 -0500 From: Greg Kroah-Hartman Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Davide Caratti , Paolo Abeni , Matthieu Baerts , Jakub Kicinski Subject: [PATCH 5.9 14/46] mptcp: fix NULL ptr dereference on bad MPJ Date: Sun, 6 Dec 2020 12:17:22 +0100 Message-Id: <20201206111557.147478069@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201206111556.455533723@linuxfoundation.org> References: <20201206111556.455533723@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: Paolo Abeni [ Upstream commit d3ab78858f1451351221061a1c365495df196500 ] If an msk listener receives an MPJ carrying an invalid token, it will zero the request socket msk entry. That should later cause fallback and subflow reset - as per RFC - at subflow_syn_recv_sock() time due to failing hmac validation. Since commit 4cf8b7e48a09 ("subflow: introduce and use mptcp_can_accept_new_subflow()"), we unconditionally dereference - in mptcp_can_accept_new_subflow - the subflow request msk before performing hmac validation. In the above scenario we hit a NULL ptr dereference. Address the issue doing the hmac validation earlier. Fixes: 4cf8b7e48a09 ("subflow: introduce and use mptcp_can_accept_new_subflow()") Tested-by: Davide Caratti Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Link: https://lore.kernel.org/r/03b2cfa3ac80d8fc18272edc6442a9ddf0b1e34e.1606400227.git.pabeni@redhat.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/mptcp/subflow.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -542,9 +542,8 @@ create_msk: fallback = true; } else if (subflow_req->mp_join) { mptcp_get_options(skb, &mp_opt); - if (!mp_opt.mp_join || - !mptcp_can_accept_new_subflow(subflow_req->msk) || - !subflow_hmac_valid(req, &mp_opt)) { + if (!mp_opt.mp_join || !subflow_hmac_valid(req, &mp_opt) || + !mptcp_can_accept_new_subflow(subflow_req->msk)) { SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINACKMAC); fallback = true; }