Netdev List
 help / color / mirror / Atom feed
From: Tom Parkin <tparkin@katalix.com>
To: netdev@vger.kernel.org
Cc: Tom Parkin <tparkin@katalix.com>, James Chapman <jchapman@katalix.com>
Subject: [PATCH 4/4] l2tp: clear tunnel socket field as soon as we release it
Date: Wed,  9 Jan 2013 18:36:23 +0000	[thread overview]
Message-ID: <1357756583-22535-5-git-send-email-tparkin@katalix.com> (raw)
In-Reply-To: <1357756583-22535-1-git-send-email-tparkin@katalix.com>

L2TP's struct l2tp_tunnel is freed and removed from the tunnel list
by the socket destructor, which may or may not run when we release our
reference to the socket in l2tp_tunnel_delete.  To prevent any chance of
accidentally reusing the socket after it is released, clear out the field
in l2tp_tunnel_delete.

Signed-off-by: Tom Parkin <tparkin@katalix.com>
Signed-off-by: James Chapman <jchapman@katalix.com>
---
 net/l2tp/l2tp_core.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index 5922eac..0cfc701 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -1668,6 +1668,7 @@ int l2tp_tunnel_delete(struct l2tp_tunnel *tunnel)
 	 * sessions are removed via. the socket destructor.
 	 */
 	if (sock != NULL) {
+		tunnel->sock = NULL;
 		if (sock->file == NULL) {
 			kernel_sock_shutdown(sock, SHUT_RDWR);
 			sk_release_kernel(sock->sk);
-- 
1.7.9.5

  parent reply	other threads:[~2013-01-09 18:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-09 18:36 [PATCH 0/4] l2tp: fix up network namespace use in l2tp_core Tom Parkin
2013-01-09 18:36 ` [PATCH 1/4] l2tp: set netnsok flag for netlink messages Tom Parkin
2013-01-09 18:36 ` [PATCH 2/4] l2tp: prevent tunnel creation on netns mismatch Tom Parkin
2013-01-09 18:36 ` [PATCH 3/4] l2tp: don't pin network namespaces with tunnel sockets Tom Parkin
2013-01-09 18:36 ` Tom Parkin [this message]
2013-01-10 16:48 ` [PATCH 0/4] l2tp: fix up network namespace use in l2tp_core Tom Parkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1357756583-22535-5-git-send-email-tparkin@katalix.com \
    --to=tparkin@katalix.com \
    --cc=jchapman@katalix.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox