diff options
author | Guillaume Nault <g.nault@alphalink.fr> | 2017-08-25 16:22:17 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-08-28 11:28:33 -0700 |
commit | 9ee369a405c57613d7c83a3967780c3e30c52ecc (patch) | |
tree | 9b11954e5446349cf84b7d1eedcf939fe74bb5f1 /net/l2tp | |
parent | 4c22868264516fe0c42817a87f37efb44254e7a9 (diff) | |
download | talos-obmc-linux-9ee369a405c57613d7c83a3967780c3e30c52ecc.tar.gz talos-obmc-linux-9ee369a405c57613d7c83a3967780c3e30c52ecc.zip |
l2tp: initialise session's refcount before making it reachable
Sessions must be fully initialised before calling
l2tp_session_add_to_tunnel(). Otherwise, there's a short time frame
where partially initialised sessions can be accessed by external users.
Fixes: dbdbc73b4478 ("l2tp: fix duplicate session creation")
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/l2tp')
-rw-r--r-- | net/l2tp/l2tp_core.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index b0c2d4ae781d..f363669eae47 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c @@ -1844,6 +1844,8 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn l2tp_session_set_header_len(session, tunnel->version); + refcount_set(&session->ref_count, 1); + err = l2tp_session_add_to_tunnel(tunnel, session); if (err) { kfree(session); @@ -1851,10 +1853,6 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn return ERR_PTR(err); } - /* Bump the reference count. The session context is deleted - * only when this drops to zero. - */ - refcount_set(&session->ref_count, 1); l2tp_tunnel_inc_refcount(tunnel); /* Ensure tunnel socket isn't deleted */ |