diff mbox series

[v1] net/ipv4: add IPv4_is_multicast() check in ip_mc_leave_group().

Message ID 1610441229-13195-1-git-send-email-wangyingjie55@126.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [v1] net/ipv4: add IPv4_is_multicast() check in ip_mc_leave_group(). | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes fail Link
netdev/checkpatch warning WARNING: Unknown commit id 'd519aa299494', maybe rebased or not pulled?
netdev/build_allmodconfig_warn success Errors and warnings before: 5 this patch: 5
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Yingjie Wang Jan. 12, 2021, 8:47 a.m. UTC
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(+)

Comments

Jakub Kicinski Jan. 13, 2021, 2:17 a.m. UTC | #1
On Tue, 12 Jan 2021 00:47:09 -0800 wangyingjie55@126.com wrote:
> 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>

Same story with the fixes tag as on your other submission.

The fixes tag is supposed to refer to the commit which introduced 
the bug. It helps the backporters determine whether they need to
backport given fix to their trees. In case the commit which added 
the bug predates git history you can refer to the first commit in
the history.

HTH
diff mbox series

Patch

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);