[PPP] L2TP: Disallow non-UDP datagram sockets
With the addition of UDP-Lite we need to refine the socket check so that only genuine UDP sockets are allowed through. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
21d0c83302
commit
a14d6abc94
@ -1326,12 +1326,14 @@ static struct sock *pppol2tp_prepare_tunnel_socket(int fd, u16 tunnel_id,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sk = sock->sk;
|
||||||
|
|
||||||
/* Quick sanity checks */
|
/* Quick sanity checks */
|
||||||
err = -ESOCKTNOSUPPORT;
|
err = -EPROTONOSUPPORT;
|
||||||
if (sock->type != SOCK_DGRAM) {
|
if (sk->sk_protocol != IPPROTO_UDP) {
|
||||||
PRINTK(-1, PPPOL2TP_MSG_CONTROL, KERN_ERR,
|
PRINTK(-1, PPPOL2TP_MSG_CONTROL, KERN_ERR,
|
||||||
"tunl %hu: fd %d wrong type, got %d, expected %d\n",
|
"tunl %hu: fd %d wrong protocol, got %d, expected %d\n",
|
||||||
tunnel_id, fd, sock->type, SOCK_DGRAM);
|
tunnel_id, fd, sk->sk_protocol, IPPROTO_UDP);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
err = -EAFNOSUPPORT;
|
err = -EAFNOSUPPORT;
|
||||||
@ -1343,7 +1345,6 @@ static struct sock *pppol2tp_prepare_tunnel_socket(int fd, u16 tunnel_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = -ENOTCONN;
|
err = -ENOTCONN;
|
||||||
sk = sock->sk;
|
|
||||||
|
|
||||||
/* Check if this socket has already been prepped */
|
/* Check if this socket has already been prepped */
|
||||||
tunnel = (struct pppol2tp_tunnel *)sk->sk_user_data;
|
tunnel = (struct pppol2tp_tunnel *)sk->sk_user_data;
|
||||||
|
Loading…
Reference in New Issue
Block a user