l2tp: initialise session's refcount before making it reachable
authorGuillaume Nault <g.nault@alphalink.fr>
Thu, 21 May 2020 23:39:25 +0000 (00:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 May 2020 14:41:56 +0000 (16:41 +0200)
commit11a083724be9f877e9490b7c807cd897b9e6819d
tree1fe2bc12196113fc2d3b6bd98d99b8c37c45bbef
parentd4504d1eba9563ca60bf87194a68faee1e6fa11e
l2tp: initialise session's refcount before making it reachable

commit 9ee369a405c57613d7c83a3967780c3e30c52ecc upstream.

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.

Backporting Notes

l2tp_core.c: moving code that had been converted from atomic to
refcount_t by an earlier change (which isn't being included in this
patch series).

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>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/l2tp/l2tp_core.c