From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-by2nam01on0109.outbound.protection.outlook.com ([104.47.34.109]:29568 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032121AbeCAP0e (ORCPT ); Thu, 1 Mar 2018 10:26:34 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Kevin Cernekee , "David S . Miller" , Sasha Levin Subject: [added to the 4.1 stable tree] netlink: Add netns check on taps Date: Thu, 1 Mar 2018 15:23:22 +0000 Message-ID: <20180301152116.1486-87-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Kevin Cernekee This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 93c647643b48f0131f02e45da3bd367d80443291 ] Currently, a nlmon link inside a child namespace can observe systemwide netlink activity. Filter the traffic so that nlmon can only sniff netlink messages from its own netns. Test case: vpnns -- bash -c "ip link add nlmon0 type nlmon; \ ip link set nlmon0 up; \ tcpdump -i nlmon0 -q -w /tmp/nlmon.pcap -U" & sudo ip xfrm state add src 10.1.1.1 dst 10.1.1.2 proto esp \ spi 0x1 mode transport \ auth sha1 0x6162633132330000000000000000000000000000 \ enc aes 0x00000000000000000000000000000000 grep --binary abc123 /tmp/nlmon.pcap Signed-off-by: Kevin Cernekee Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/netlink/af_netlink.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 8daf2e44595a..66c340bc0553 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -259,6 +259,9 @@ static int __netlink_deliver_tap_skb(struct sk_buff *sk= b, struct sock *sk =3D skb->sk; int ret =3D -ENOMEM; =20 + if (!net_eq(dev_net(dev), sock_net(sk))) + return 0; + dev_hold(dev); =20 if (netlink_skb_is_mmaped(skb) || is_vmalloc_addr(skb->head)) --=20 2.14.1