Skip to content

Commit de9bada

Browse files
Guillaume Naultdavem330
authored andcommitted
l2tp: reject creation of non-PPP sessions on L2TPv2 tunnels
The /proc/net/pppol2tp handlers (pppol2tp_seq_*()) iterate over all L2TPv2 tunnels, and rightfully expect that only PPP sessions can be found there. However, l2tp_netlink accepts creating Ethernet sessions regardless of the underlying tunnel version. This confuses pppol2tp_seq_session_show(), which expects that l2tp_session_priv() returns a pppol2tp_session structure. When the session is an Ethernet pseudo-wire, a struct l2tp_eth_sess is returned instead. This leads to invalid memory access when pppol2tp_session_get_sock() later tries to dereference ps->sk. Fixes: d9e31d1 ("l2tp: Add L2TP ethernet pseudowire support") Signed-off-by: Guillaume Nault <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent eab9a2d commit de9bada

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/l2tp/l2tp_netlink.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,12 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
553553
goto out_tunnel;
554554
}
555555

556+
/* L2TPv2 only accepts PPP pseudo-wires */
557+
if (tunnel->version == 2 && cfg.pw_type != L2TP_PWTYPE_PPP) {
558+
ret = -EPROTONOSUPPORT;
559+
goto out_tunnel;
560+
}
561+
556562
if (tunnel->version > 2) {
557563
if (info->attrs[L2TP_ATTR_DATA_SEQ])
558564
cfg.data_seq = nla_get_u8(info->attrs[L2TP_ATTR_DATA_SEQ]);

0 commit comments

Comments
 (0)