android_kernel_samsung_msm8226/net/l2tp
Guillaume Nault a646afc6a9 l2tp: pass tunnel pointer to ->session_create()
commit f026bc29a8e093edfbb2a77700454b285c97e8ad upstream.

Using l2tp_tunnel_find() in pppol2tp_session_create() and
l2tp_eth_create() is racy, because no reference is held on the
returned session. These functions are only used to implement the
->session_create callback which is run by l2tp_nl_cmd_session_create().
Therefore searching for the parent tunnel isn't necessary because
l2tp_nl_cmd_session_create() already has a pointer to it and holds a
reference.

This patch modifies ->session_create()'s prototype to directly pass the
the parent tunnel as parameter, thus avoiding searching for it in
pppol2tp_session_create() and l2tp_eth_create().

Since we have to touch the ->session_create() call in
l2tp_nl_cmd_session_create(), let's also remove the useless conditional:
we know that ->session_create isn't NULL at this point because it's
already been checked earlier in this same function.

Finally, one might be tempted to think that the removed
l2tp_tunnel_find() calls were harmless because they would return the
same tunnel as the one held by l2tp_nl_cmd_session_create() anyway.
But that tunnel might be removed and a new one created with same tunnel
Id before the l2tp_tunnel_find() call. In this case l2tp_tunnel_find()
would return the new tunnel which wouldn't be protected by the
reference held by l2tp_nl_cmd_session_create().

Change-Id: Idd7ad474edeb23ece12800125f6a7a14badd638c
Fixes: 309795f4be ("l2tp: Add netlink control API for L2TP")
Fixes: d9e31d17ce ("l2tp: Add L2TP ethernet pseudowire support")
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
CVE-2018-9517
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2020-01-06 08:40:28 +01:00
..
Kconfig
Makefile
l2tp_core.c l2tp: prevent creation of sessions on terminated tunnels 2020-01-06 08:40:28 +01:00
l2tp_core.h l2tp: pass tunnel pointer to ->session_create() 2020-01-06 08:40:28 +01:00
l2tp_debugfs.c fix return values of l2tp_dfs_seq_open() 2011-06-05 14:11:09 -07:00
l2tp_eth.c l2tp: pass tunnel pointer to ->session_create() 2020-01-06 08:40:28 +01:00
l2tp_ip.c l2tp: fix race in l2tp_recv_common() 2020-01-06 08:40:27 +01:00
l2tp_netlink.c l2tp: pass tunnel pointer to ->session_create() 2020-01-06 08:40:28 +01:00
l2tp_ppp.c l2tp: pass tunnel pointer to ->session_create() 2020-01-06 08:40:28 +01:00