Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1342060pxb; Sun, 17 Jan 2021 05:39:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMMZ0GAr2gAFV3PVepxOenbbSb6+Ax3Q11YG5wG0H8xcWOKDmPfi0akHtJSozp8IerPTzI X-Received: by 2002:aa7:ca51:: with SMTP id j17mr4478608edt.124.1610890753601; Sun, 17 Jan 2021 05:39:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610890753; cv=none; d=google.com; s=arc-20160816; b=bZzcS8LIiZ2OABcQgrKpEDeLnKbUlxawQfYPdInheRrPuIJuzo3Ql1W+a2gdzudr19 mfYdbv079XitVdu36N/i78GnvsGiLdllVTJgnDEWmLVP8SuDwUniz/7iEeIuGl9536r+ Yr3qBCBxH9xvIcisg+qiFQAYRi+THqcWxHcfaQlvvprhtNsOQ5ARiW9gxWv5VXkubih5 HshVExOq8mUyQnEA43yWMa1I3tR0Yl4ZepEImTbPxgFHiAI3MuRbnJVudMm4RLXow5fw uhGeog28B6DW3ENkkH2F3RwvN5kd6WnsvGrBmeIZHHhBhibsf9DFrNgB4ZuahaLRQmpp M7Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=eWwIs7/QmCK2QierLPnFAEWKUmsS+o3HHAvwtkjkxe0=; b=NYuJu5xKCuJts9kiLmNZLbuwMUj3k0b9HKF3tPzrNels3MP5w0+/CI4WTE/LCfI4Dk FV2da/nOAV+hzba/WiOOi++lkCvWfGUluB1MIXJFG6ZXFrgwusPP2CwPO8VqbM35mGMi GbgGF0PADRFB58w5s8wTk10zjhbCRjOH8X+3/vA1ptcJz8JcS+Fl5Dqf9iJXg8+IhDGE yl78A4pPud7U/lpP4xZrvsEwXe28DizOYde+9mqCxWnNz2iMFdNt+TPBvWrgXCPesiA/ j04MEWDnaZTUNN06mwV2SqxjJLNqPnfTex6FEYofC1MszSrM0nzl+NVxnFyXO5ABfjnG QSjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b="b2IA/FtK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gg14si3272259ejb.367.2021.01.17.05.38.50; Sun, 17 Jan 2021 05:39:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b="b2IA/FtK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728812AbhAQNhq (ORCPT + 99 others); Sun, 17 Jan 2021 08:37:46 -0500 Received: from m15111.mail.126.com ([220.181.15.111]:37183 "EHLO m15111.mail.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726209AbhAQNhc (ORCPT ); Sun, 17 Jan 2021 08:37:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=eWwIs7/QmCK2QierLP nFAEWKUmsS+o3HHAvwtkjkxe0=; b=b2IA/FtKcOsXnrjQJh9XlHxmIvhTRq36bG VktxpjPjhOI2EFj0unj59EKCy2yByV8jNA6bqvzGBmaSQRW5jjVQPr1tT7Bmw3wh jiN7n7BIgjvkN2hI1Tmcoy8m3VNH+Vkkn7lxMC6JOUwIQVARClnJlfb3NgdQg7kz aokqUx6xU= Received: from localhost.localdomain (unknown [106.18.67.121]) by smtp1 (Coremail) with SMTP id C8mowAB3fVHiPARgP38_Nw--.64554S2; Sun, 17 Jan 2021 21:34:29 +0800 (CST) From: wangyingjie55@126.com To: davem@davemloft.net, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, wangyingjie55@126.com Subject: [PATCH v1] ipv4: add iPv4_is_multicast() check in ip_mc_leave_group(). Date: Sun, 17 Jan 2021 05:34:16 -0800 Message-Id: <1610890456-42846-1-git-send-email-wangyingjie55@126.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: C8mowAB3fVHiPARgP38_Nw--.64554S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrZr1rtr43AF1rJF4xJw4ruFg_yoWDurg_t3 WkAr18JrWfAr1Ikw47Z3Z3Ja98X398Crn3WrsF9Fy3Ja40ywnruas7XrySvr1xGa9rGFWU Zasrtry5Ga10yjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUnaNt3UUUUU== X-Originating-IP: [106.18.67.121] X-CM-SenderInfo: 5zdqw5xlqjyxrhvvqiyswou0bp/1tbi7gUdp1tC5n0SnQAAsc Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yingjie Wang There is no iPv4_is_multicast() check added to ip_mc_leave_group() to check if 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 before calling such as do_ip_setsockopt(). So I suggest adding the ipv4_is_multicast() check to the ip_mc_leave_group() to prevent this from happening. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Yingjie Wang --- 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