diff options
author | Guillaume Nault <g.nault@alphalink.fr> | 2018-04-19 10:20:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-04-22 14:46:35 -0400 |
commit | 5411b6187adf62909e3b998ac782e722904c7487 (patch) | |
tree | 6436022361ecbc67d743c3aa22e00696b1ce71f2 | |
parent | 353697e6e688c361af71fe921b89bbe71189d0ce (diff) |
l2tp: fix {pppol2tp, l2tp_dfs}_seq_stop() in case of seq_file overflow
Commit 0e0c3fee3a59 ("l2tp: hold reference on tunnels printed in pppol2tp proc file")
assumed that if pppol2tp_seq_stop() was called with non-NULL private
data (the 'v' pointer), then pppol2tp_seq_start() would not be called
again. It turns out that this isn't guaranteed, and overflowing the
seq_file's buffer in pppol2tp_seq_show() is a way to get into this
situation.
Therefore, pppol2tp_seq_stop() needs to reset pd->tunnel, so that
pppol2tp_seq_start() won't drop a reference again if it gets called.
We also have to clear pd->session, because the rest of the code expects
a non-NULL tunnel when pd->session is set.
The l2tp_debugfs module has the same issue. Fix it in the same way.
Fixes: 0e0c3fee3a59 ("l2tp: hold reference on tunnels printed in pppol2tp proc file")
Fixes: f726214d9b23 ("l2tp: hold reference on tunnels printed in l2tp/tunnels debugfs file")
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/l2tp/l2tp_debugfs.c | 5 | ||||
-rw-r--r-- | net/l2tp/l2tp_ppp.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/net/l2tp/l2tp_debugfs.c b/net/l2tp/l2tp_debugfs.c index b8f9d45bfeb1..7f1e842ef05a 100644 --- a/net/l2tp/l2tp_debugfs.c +++ b/net/l2tp/l2tp_debugfs.c | |||
@@ -106,8 +106,11 @@ static void l2tp_dfs_seq_stop(struct seq_file *p, void *v) | |||
106 | return; | 106 | return; |
107 | 107 | ||
108 | /* Drop reference taken by last invocation of l2tp_dfs_next_tunnel() */ | 108 | /* Drop reference taken by last invocation of l2tp_dfs_next_tunnel() */ |
109 | if (pd->tunnel) | 109 | if (pd->tunnel) { |
110 | l2tp_tunnel_dec_refcount(pd->tunnel); | 110 | l2tp_tunnel_dec_refcount(pd->tunnel); |
111 | pd->tunnel = NULL; | ||
112 | pd->session = NULL; | ||
113 | } | ||
111 | } | 114 | } |
112 | 115 | ||
113 | static void l2tp_dfs_seq_tunnel_show(struct seq_file *m, void *v) | 116 | static void l2tp_dfs_seq_tunnel_show(struct seq_file *m, void *v) |
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index 7d0c963680e6..1404bc1c1bb7 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c | |||
@@ -1618,8 +1618,11 @@ static void pppol2tp_seq_stop(struct seq_file *p, void *v) | |||
1618 | return; | 1618 | return; |
1619 | 1619 | ||
1620 | /* Drop reference taken by last invocation of pppol2tp_next_tunnel() */ | 1620 | /* Drop reference taken by last invocation of pppol2tp_next_tunnel() */ |
1621 | if (pd->tunnel) | 1621 | if (pd->tunnel) { |
1622 | l2tp_tunnel_dec_refcount(pd->tunnel); | 1622 | l2tp_tunnel_dec_refcount(pd->tunnel); |
1623 | pd->tunnel = NULL; | ||
1624 | pd->session = NULL; | ||
1625 | } | ||
1623 | } | 1626 | } |
1624 | 1627 | ||
1625 | static void pppol2tp_seq_tunnel_show(struct seq_file *m, void *v) | 1628 | static void pppol2tp_seq_tunnel_show(struct seq_file *m, void *v) |