Skip to contentSkip to conversation

tipc: compare remote and local protocols in tipc_udp_enable()

PATCH In review Cong Wang 3 participants 3 messages Dec 10, 2018 – Dec 14, 2018

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 tipc: compare remote and local protocols in tipc_udp_enable()

When TIPC_NLA_UDP_REMOTE is an IPv6 mcast address but TIPC_NLA_UDP_LOCAL is an IPv4 address, a NULL-ptr deref is triggered as the UDP tunnel sock is initialized to IPv4 or IPv6 sock merely based on the protocol in local address.

We should just error out when the remote address and local address have different protocols.

---
 net/tipc/udp_media.c | 5 +++++
 1 file changed, 5 insertions(+)
net/tipc/udp_media.c +5 -0
index 1b1ba1310ea7..4d85d71f16e2 100644
@@ -679,6 +679,11 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
 	if (err)
 		goto err;
 
+	if (remote.proto != local.proto) {
+		err = -EINVAL;
+		goto err;
+	}
+
 	/* Checking remote ip address */
 	rmcast = tipc_udp_is_mcast_addr(&remote);
 
Signature · 1 line
2.19.2
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines

-----Original Message-----
From: Cong Wang <[email protected]>
Sent: 10-Dec-18 18:24
To: [email protected]
Cc: Cong Wang <[email protected]>; Ying Xue <[email protected]>; Jon Maloy <[email protected]>
Subject: [Patch net] tipc: compare remote and local protocols in tipc_udp_enable()

Quoted 7 lines

When TIPC_NLA_UDP_REMOTE is an IPv6 mcast address but TIPC_NLA_UDP_LOCAL is an IPv4 address, a NULL-ptr deref is triggered as the UDP tunnel sock is initialized to IPv4 or IPv6 sock merely based on the protocol in local address.

We should just error out when the remote address and local address have different protocols.

Thank you for your help, Cong.

Quoted 28 lines
---
 net/tipc/udp_media.c | 5 +++++
 1 file changed, 5 insertions(+)
net/tipc/udp_media.c index renamed from net/tipc/udp_media.c +0 -0

1b1ba1310ea7..4d85d71f16e2 100644

net/tipc/udp_media.c +5 -1
@@ -679,6 +679,11 @@ static int tipc_udp_enable(struct net *net, struct
 tipc_bearer *b,
 	if (err)
 		goto err;
 
+	if (remote.proto != local.proto) {
+		err = -EINVAL;
+		goto err;
+	}
+
 	/* Checking remote ip address */
 	rmcast = tipc_udp_is_mcast_addr(&remote);
 
--

2.19.2

maintainer
#2 lore raw
In reply to Cong Wang

From: Cong Wang <[email protected]>
Date: Mon, 10 Dec 2018 15:23:30 -0800

Quoted 5 lines

When TIPC_NLA_UDP_REMOTE is an IPv6 mcast address but TIPC_NLA_UDP_LOCAL is an IPv4 address, a NULL-ptr deref is triggered as the UDP tunnel sock is initialized to IPv4 or IPv6 sock merely based on the protocol in local address.

Quoted 7 lines

We should just error out when the remote address and local address have different protocols.

Applied and queued up for -stable, thanks.