From: Cong Wang Date: Mon, 10 Dec 2018 23:23:30 +0000 (-0800) Subject: tipc: compare remote and local protocols in tipc_udp_enable() X-Git-Tag: v5.4-rc1~2042^2~55 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb83ed496b9a654f60cd1d58a0e1e79ec5694808;p=platform%2Fkernel%2Flinux-rpi.git 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. Reported-by: syzbot+eb4da3a20fad2e52555d@syzkaller.appspotmail.com Cc: Ying Xue Cc: Jon Maloy Signed-off-by: Cong Wang Acked-by: Jon Maloy Signed-off-by: David S. Miller --- diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index 1b1ba13..4d85d71 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c @@ -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);