aboutsummaryrefslogtreecommitdiffstats
path: root/net/netlink/af_netlink.c
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-12-23 08:35:55 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-31 14:31:43 -0500
commit73bfd370c878d3feb3c3111cc17af066dc1f455b (patch)
tree960d9bac33fcc8406831ba09e0c662fa65ef1114 /net/netlink/af_netlink.c
parent89ba52bd933898e8da78d4a3469dc23cb8acbecd (diff)
netlink: only do not deliver to tap when both sides are kernel sks
We should also deliver packets to nlmon devices when we are in netlink_unicast_kernel(), and only one of the {src,dst} sockets is user sk and the other one kernel sk. That's e.g. the case in netlink diag, netlink route, etc. Still, forbid to deliver messages from kernel to kernel sks. Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: Jakub Zawadzki <darkjames-ws@darkjames.pl> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink/af_netlink.c')
-rw-r--r--net/netlink/af_netlink.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index bca50b95c182..56e09d8a55fd 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -239,6 +239,13 @@ static void netlink_deliver_tap(struct sk_buff *skb)
239 rcu_read_unlock(); 239 rcu_read_unlock();
240} 240}
241 241
242static void netlink_deliver_tap_kernel(struct sock *dst, struct sock *src,
243 struct sk_buff *skb)
244{
245 if (!(netlink_is_kernel(dst) && netlink_is_kernel(src)))
246 netlink_deliver_tap(skb);
247}
248
242static void netlink_overrun(struct sock *sk) 249static void netlink_overrun(struct sock *sk)
243{ 250{
244 struct netlink_sock *nlk = nlk_sk(sk); 251 struct netlink_sock *nlk = nlk_sk(sk);
@@ -1697,14 +1704,10 @@ static int netlink_unicast_kernel(struct sock *sk, struct sk_buff *skb,
1697 1704
1698 ret = -ECONNREFUSED; 1705 ret = -ECONNREFUSED;
1699 if (nlk->netlink_rcv != NULL) { 1706 if (nlk->netlink_rcv != NULL) {
1700 /* We could do a netlink_deliver_tap(skb) here as well
1701 * but since this is intended for the kernel only, we
1702 * should rather let it stay under the hood.
1703 */
1704
1705 ret = skb->len; 1707 ret = skb->len;
1706 netlink_skb_set_owner_r(skb, sk); 1708 netlink_skb_set_owner_r(skb, sk);
1707 NETLINK_CB(skb).sk = ssk; 1709 NETLINK_CB(skb).sk = ssk;
1710 netlink_deliver_tap_kernel(sk, ssk, skb);
1708 nlk->netlink_rcv(skb); 1711 nlk->netlink_rcv(skb);
1709 consume_skb(skb); 1712 consume_skb(skb);
1710 } else { 1713 } else {