From patchwork Thu Nov 21 15:41:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1199013 X-Patchwork-Delegate: matthieu.baerts@tessares.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=198.145.21.10; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="TTlh+sTS"; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47JkMd43zTz9sPK for ; Fri, 22 Nov 2019 02:42:21 +1100 (AEDT) Received: from new-ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0821C100DC2C8; Thu, 21 Nov 2019 07:42:54 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=207.211.31.81; helo=us-smtp-delivery-1.mimecast.com; envelope-from=pabeni@redhat.com; receiver= Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1C70F100DC2C7 for ; Thu, 21 Nov 2019 07:42:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574350937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uc+5EE/QlV4CYO3dDX+3rXNTDPlYnUMCQeooJLLaxYs=; b=TTlh+sTSObinOGED4g6Cf6aKoEik6PE/xJH1LaPQcKfLO7Cdj/bhsYOxElBmuXQKIEC3OC rimstWpspMjSPGfgAO1bKhdLt37yO8GP7bhmaU59fTnCBDdDH8wnMYFTjWp1YbnU9jnGw1 X5IpBp/JiBKJfTkqR7dLwEyiWniA1TQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-417-4-_Bt-LvPa-dO9LI2_9INg-1; Thu, 21 Nov 2019 10:42:15 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D4F8F10CCE60; Thu, 21 Nov 2019 15:42:14 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21A125D6D6; Thu, 21 Nov 2019 15:42:13 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.01.org Cc: Matthieu Baerts Date: Thu, 21 Nov 2019 16:41:52 +0100 Message-Id: <6e2d1e5019b5e81d0de33a91d458929600e37a8a.1574350681.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: 4-_Bt-LvPa-dO9LI2_9INg-1 X-Mimecast-Spam-Score: 0 Message-ID-Hash: GZVQATNYBAE5IBYTVJOA6NPZMRJEKXNC X-Message-ID-Hash: GZVQATNYBAE5IBYTVJOA6NPZMRJEKXNC X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH 3/3] mptcp/ipv6: mptcp_v6_prot needs costom destroy. List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Otherwise we can leak memory on close, if user space does some setsockopt before connectiong/accepting. Note: the squash tag points to the commit currently introducing mptcp_destroy, but we likely want to move such function in another one - it's currently added as empty Squash-to: "mptcp: Add key generation and token tree" Signed-off-by: Paolo Abeni --- net/mptcp/protocol.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 3ae136f9e35c..9b384da910ce 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -974,6 +974,12 @@ void mptcp_proto_init(void) static struct proto_ops mptcp_v6_stream_ops; static struct proto mptcp_v6_prot; +static void mptcp_v6_destroy(struct sock *sk) +{ + mptcp_destroy(sk); + inet6_destroy_sock(sk); +} + static struct inet_protosw mptcp_v6_protosw = { .type = SOCK_STREAM, .protocol = IPPROTO_MPTCP, @@ -989,6 +995,7 @@ int mptcp_proto_v6_init(void) mptcp_v6_prot = mptcp_prot; strcpy(mptcp_v6_prot.name, "MPTCPv6"); mptcp_v6_prot.slab = NULL; + mptcp_v6_prot.destroy = mptcp_v6_destroy; mptcp_v6_prot.obj_size = sizeof(struct mptcp_sock) + sizeof(struct ipv6_pinfo);