diff options
author | Guillaume Nault <g.nault@alphalink.fr> | 2018-04-23 16:15:14 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-04-29 07:45:28 +0200 |
commit | 115af4416bfd3cb811a01a2444f5203e59dca03d (patch) | |
tree | a8d0ebfd0cd0798992e4363746a6eb42834c3b42 | |
parent | 1f6945bbbfb3c6565e2c7fd244849ceb18d5bd0a (diff) | |
download | linux-stable-115af4416bfd3cb811a01a2444f5203e59dca03d.tar.gz linux-stable-115af4416bfd3cb811a01a2444f5203e59dca03d.tar.bz2 linux-stable-115af4416bfd3cb811a01a2444f5203e59dca03d.zip |
l2tp: check sockaddr length in pppol2tp_connect()
[ Upstream commit eb1c28c05894a4b1f6b56c5bf072205e64cfa280 ]
Check sockaddr_len before dereferencing sp->sa_protocol, to ensure that
it actually points to valid data.
Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Reported-by: syzbot+a70ac890b23b1bf29f5c@syzkaller.appspotmail.com
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | net/l2tp/l2tp_ppp.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index 447843b24d7d..c1e41fb6456e 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -608,6 +608,13 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr, lock_sock(sk); error = -EINVAL; + + if (sockaddr_len != sizeof(struct sockaddr_pppol2tp) && + sockaddr_len != sizeof(struct sockaddr_pppol2tpv3) && + sockaddr_len != sizeof(struct sockaddr_pppol2tpin6) && + sockaddr_len != sizeof(struct sockaddr_pppol2tpv3in6)) + goto end; + if (sp->sa_protocol != PX_PROTO_OL2TP) goto end; |