lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211203072515.345503-1-zhang.yunkai@zte.com.cn>
Date:   Fri,  3 Dec 2021 07:25:15 +0000
From:   cgel.zte@...il.com
To:     davem@...emloft.net
Cc:     kuba@...nel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Zhang Yunkai <zhang.yunkai@....com.cn>
Subject: [PATCH linux-next] macvlan: judge ACCEPT_LOCAL before broadcast

From: Zhang Yunkai <zhang.yunkai@....com.cn>

When macvlan send broadcast,it need judge accept_local.If you don’t do
this, it will be received in the same namespace and treated as an
invalid source address.If open log_martians,it will also print an error
like this:
IPv4: martian source 173.254.95.16 from 173.254.100.109,
on dev eth0
ll header: 00000000: ff ff ff ff ff ff 40 00 ad fe 64 6d
08 06        ......@...dm..
IPv4: martian source 173.254.95.16 from 173.254.100.109,
on dev eth1
ll header: 00000000: ff ff ff ff ff ff 40 00 ad fe 64 6d
08 06        ......@...dm..

Modify the sender, or modify the receiver, or modify the printing error,
this is not an invalid source address, or it is clearly stated in the
RFC1812 whether this is an invalid source address.

Signed-off-by: Zhang Yunkai <zhang.yunkai@....com.cn>
---
 drivers/net/macvlan.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index d2f830ec2969..3a16139e7b47 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -19,6 +19,7 @@
 #include <linux/rculist.h>
 #include <linux/notifier.h>
 #include <linux/netdevice.h>
+#include <linux/inetdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/net_tstamp.h>
 #include <linux/ethtool.h>
@@ -268,6 +269,7 @@ static void macvlan_broadcast(struct sk_buff *skb,
 	unsigned int i;
 	int err;
 	unsigned int hash;
+	struct in_device *in_dev;
 
 	if (skb->protocol == htons(ETH_P_PAUSE))
 		return;
@@ -280,6 +282,18 @@ static void macvlan_broadcast(struct sk_buff *skb,
 		if (!test_bit(hash, vlan->mc_filter))
 			continue;
 
+		rcu_read_lock();
+		if (src && net_eq(dev_net(vlan->dev), dev_net(src))) {
+			in_dev = __in_dev_get_rcu(src);
+			if (!IN_DEV_ACCEPT_LOCAL(in_dev)) {
+				in_dev_put(in_dev);
+				rcu_read_unlock();
+				continue;
+			}
+			in_dev_put(in_dev);
+		}
+		rcu_read_unlock();
+
 		err = NET_RX_DROP;
 		nskb = skb_clone(skb, GFP_ATOMIC);
 		if (likely(nskb))
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ