lkml.org 
[lkml]   [2021]   [Jan]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1] net/ipv4: add IPv4_is_multicast() check in ip_mc_leave_group().
Date
From: Yingjie Wang <wangyingjie55@126.com>

There is no IPv4_is_multicast() check added to ip_mc_leave_group()
to determine whether imr->imr_multiaddr.s_addr is a multicast address.
If not a multicast address, it may result in an error.
In some cases, the callers of ip_mc_leave_group don't check
whether it is multicast address or not such as do_ip_setsockopt().
So I suggest added the ipv4_is_multicast() check to the
ip_mc_leave_group function to prevent this from happening.

Fixes: d519aa299494 ("net/ipv4: add IPv4_is_multicast() check in ip_mc_leave_group().")
Signed-off-by: Yingjie Wang <wangyingjie55@126.com>
---
net/ipv4/igmp.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 7b272bbed2b4..1b6f91271cfd 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -2248,6 +2248,9 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr)
u32 ifindex;
int ret = -EADDRNOTAVAIL;

+ if (!ipv4_is_multicast(group))
+ return -EINVAL;
+
ASSERT_RTNL();

in_dev = ip_mc_find_dev(net, imr);
--
2.7.4
\
 
 \ /
  Last update: 2021-01-12 09:51    [W:0.222 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site