lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 22 Jan 2019 17:08:14 +0800
From:   Jacob Wen <jian.w.wen@...cle.com>
To:     netdev@...r.kernel.org
Subject: [PATCH] net: l2tp: fix reading optional fields

Use pskb_may_pull() to make sure the optional fields are in skb linear
parts.

Signed-off-by: Jacob Wen <jian.w.wen@...cle.com>
---
 net/l2tp/l2tp_core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index 26f1d435696a..7df927bd4202 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -627,6 +627,8 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
 
 	/* Parse and check optional cookie */
 	if (session->peer_cookie_len > 0) {
+		if (!pskb_may_pull(skb, ptr - optr + session->peer_cookie_len))
+			goto discard;
 		if (memcmp(ptr, &session->peer_cookie[0], session->peer_cookie_len)) {
 			l2tp_info(tunnel, L2TP_MSG_DATA,
 				  "%s: cookie mismatch (%u/%u). Discarding.\n",
@@ -649,6 +651,8 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
 	L2TP_SKB_CB(skb)->has_seq = 0;
 	if (tunnel->version == L2TP_HDR_VER_2) {
 		if (hdrflags & L2TP_HDRFLAG_S) {
+			if (!pskb_may_pull(skb, ptr - optr + 4))
+				goto discard;
 			ns = ntohs(*(__be16 *) ptr);
 			ptr += 2;
 			nr = ntohs(*(__be16 *) ptr);
@@ -663,6 +667,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
 				 session->name, ns, nr, session->nr);
 		}
 	} else if (session->l2specific_type == L2TP_L2SPECTYPE_DEFAULT) {
+		if (!pskb_may_pull(skb, ptr - optr + 4))
+			goto discard;
+
 		u32 l2h = ntohl(*(__be32 *) ptr);
 
 		if (l2h & 0x40000000) {
@@ -729,6 +736,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
 	if (tunnel->version == L2TP_HDR_VER_2) {
 		/* If offset bit set, skip it. */
 		if (hdrflags & L2TP_HDRFLAG_O) {
+			if (!pskb_may_pull(skb, ptr - optr + 2))
+				goto discard;
+
 			offset = ntohs(*(__be16 *)ptr);
 			ptr += 2 + offset;
 		}
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ