From nobody Sat Dec 21 14:25:36 2024 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AB0810EA for ; Sat, 7 Jan 2023 01:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673054410; x=1704590410; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QbP122LMPjgCQtrQbA4fnDNOgEeN9MtQDCEXBp1A+go=; b=YREAhmUhEX2ZWHjXJInrx3pDYcLID6/YhfX+oh/vgZ+lmUAPlV4KelWl OHyVyO25PamkYGuzljyuoBYph1lo4osm4FvqRIeJf21aFax6j/KyVFd0N S5C9ADcuZL1/H2uDM7Zvodw5cHy7xNXwV1tyaR3nZyjSk8ipYGzJAxtNm /JyxDCWfz6naLtA4+vxSOCdkVKYlpiuymDIFJntXtY93qRlYCiG5Fsg1m q9wnpEo46AgqCThW8gBnfYEAyt00ReqVzb8hgsyjaRGG+JYrVFFWdcunZ Lo+tZW1UUCsA+sHAUg5tXB3R3YEdgepKIauqk2KUNFshVDxxAVWJEvezC A==; X-IronPort-AV: E=McAfee;i="6500,9779,10582"; a="322672302" X-IronPort-AV: E=Sophos;i="5.96,307,1665471600"; d="scan'208";a="322672302" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2023 17:20:08 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10582"; a="649475320" X-IronPort-AV: E=Sophos;i="5.96,307,1665471600"; d="scan'208";a="649475320" Received: from mechevar-mobl.amr.corp.intel.com (HELO mjmartin-desk2.intel.com) ([10.209.66.63]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2023 17:20:07 -0800 From: Mat Martineau To: stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Matthieu Baerts , pabeni@redhat.com, mptcp@lists.linux.dev, Mat Martineau , Jakub Kicinski Subject: [PATCH 5.15 2/2] mptcp: use proper req destructor for IPv6 Date: Fri, 6 Jan 2023 17:19:58 -0800 Message-Id: <20230107011959.448249-3-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230107011959.448249-1-mathew.j.martineau@linux.intel.com> References: <20230107011959.448249-1-mathew.j.martineau@linux.intel.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Matthieu Baerts commit d3295fee3c756ece33ac0d935e172e68c0a4161b upstream. Before, only the destructor from TCP request sock in IPv4 was called even if the subflow was IPv6. It is important to use the right destructor to avoid memory leaks with some advanced IPv6 features, e.g. when the request socks contain specific IPv6 options. Fixes: 79c0949e9a09 ("mptcp: Add key generation and token tree") Reviewed-by: Mat Martineau Cc: stable@vger.kernel.org # 5.15 Signed-off-by: Matthieu Baerts Signed-off-by: Mat Martineau Signed-off-by: Jakub Kicinski --- net/mptcp/subflow.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index c1d76ec65c42..ba4241d7c5ef 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -45,7 +45,6 @@ static void subflow_req_destructor(struct request_sock *r= eq) sock_put((struct sock *)subflow_req->msk); =20 mptcp_token_destroy_request(req); - tcp_request_sock_ops.destructor(req); } =20 static void subflow_generate_hmac(u64 key1, u64 key2, u32 nonce1, u32 nonc= e2, @@ -504,6 +503,12 @@ static int subflow_v4_conn_request(struct sock *sk, st= ruct sk_buff *skb) return 0; } =20 +static void subflow_v4_req_destructor(struct request_sock *req) +{ + subflow_req_destructor(req); + tcp_request_sock_ops.destructor(req); +} + #if IS_ENABLED(CONFIG_MPTCP_IPV6) static struct request_sock_ops mptcp_subflow_v6_request_sock_ops __ro_afte= r_init; static struct tcp_request_sock_ops subflow_request_sock_ipv6_ops __ro_afte= r_init; @@ -535,6 +540,12 @@ static int subflow_v6_conn_request(struct sock *sk, st= ruct sk_buff *skb) tcp_listendrop(sk); return 0; /* don't send reset */ } + +static void subflow_v6_req_destructor(struct request_sock *req) +{ + subflow_req_destructor(req); + tcp6_request_sock_ops.destructor(req); +} #endif =20 struct request_sock *mptcp_subflow_reqsk_alloc(const struct request_sock_o= ps *ops, @@ -1806,8 +1817,6 @@ static int subflow_ops_init(struct request_sock_ops *= subflow_ops) if (!subflow_ops->slab) return -ENOMEM; =20 - subflow_ops->destructor =3D subflow_req_destructor; - return 0; } =20 @@ -1815,6 +1824,8 @@ void __init mptcp_subflow_init(void) { mptcp_subflow_v4_request_sock_ops =3D tcp_request_sock_ops; mptcp_subflow_v4_request_sock_ops.slab_name =3D "request_sock_subflow_v4"; + mptcp_subflow_v4_request_sock_ops.destructor =3D subflow_v4_req_destructo= r; + if (subflow_ops_init(&mptcp_subflow_v4_request_sock_ops) !=3D 0) panic("MPTCP: failed to init subflow v4 request sock ops\n"); =20 @@ -1839,6 +1850,8 @@ void __init mptcp_subflow_init(void) =20 mptcp_subflow_v6_request_sock_ops =3D tcp6_request_sock_ops; mptcp_subflow_v6_request_sock_ops.slab_name =3D "request_sock_subflow_v6"; + mptcp_subflow_v6_request_sock_ops.destructor =3D subflow_v6_req_destructo= r; + if (subflow_ops_init(&mptcp_subflow_v6_request_sock_ops) !=3D 0) panic("MPTCP: failed to init subflow v6 request sock ops\n"); =20 --=20 2.39.0