Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1381613 > unrolled thread

[PATCH] cls_cgroup: get sk_classid only from full sockets

Started byKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
First post2016-04-18 13:40 +0200
Last post2016-04-20 02:10 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] cls_cgroup: get sk_classid only from full sockets Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2016-04-18 13:40 +0200
    Re: [PATCH] cls_cgroup: get sk_classid only from full sockets Eric Dumazet <eric.dumazet@gmail.com> - 2016-04-18 14:20 +0200
    Re: [PATCH] cls_cgroup: get sk_classid only from full sockets David Miller <davem@davemloft.net> - 2016-04-20 02:10 +0200

#1381613 — [PATCH] cls_cgroup: get sk_classid only from full sockets

FromKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
Date2016-04-18 13:40 +0200
Subject[PATCH] cls_cgroup: get sk_classid only from full sockets
Message-ID<rpfH4-4Ou-11@gated-at.bofh.it>
skb->sk could point to timewait or request socket which has no sk_classid.
Detected as "BUG: KASAN: slab-out-of-bounds in cls_cgroup_classify".

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
 include/net/cls_cgroup.h |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/net/cls_cgroup.h b/include/net/cls_cgroup.h
index c0a92e2c286d..74c9693d4941 100644
--- a/include/net/cls_cgroup.h
+++ b/include/net/cls_cgroup.h
@@ -17,6 +17,7 @@
 #include <linux/hardirq.h>
 #include <linux/rcupdate.h>
 #include <net/sock.h>
+#include <net/inet_sock.h>
 
 #ifdef CONFIG_CGROUP_NET_CLASSID
 struct cgroup_cls_state {
@@ -63,11 +64,13 @@ static inline u32 task_get_classid(const struct sk_buff *skb)
 	 * softirqs always disables bh.
 	 */
 	if (in_serving_softirq()) {
+		struct sock *sk = skb_to_full_sk(skb);
+
 		/* If there is an sock_cgroup_classid we'll use that. */
-		if (!skb->sk)
+		if (!sk || !sk_fullsock(sk))
 			return 0;
 
-		classid = sock_cgroup_classid(&skb->sk->sk_cgrp_data);
+		classid = sock_cgroup_classid(&sk->sk_cgrp_data);
 	}
 
 	return classid;

[toc] | [next] | [standalone]


#1381651

FromEric Dumazet <eric.dumazet@gmail.com>
Date2016-04-18 14:20 +0200
Message-ID<rpgjN-5u2-21@gated-at.bofh.it>
In reply to#1381613
On Mon, 2016-04-18 at 14:37 +0300, Konstantin Khlebnikov wrote:
> skb->sk could point to timewait or request socket which has no sk_classid.
> Detected as "BUG: KASAN: slab-out-of-bounds in cls_cgroup_classify".
> 
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> ---

Acked-by: Eric Dumazet <edumazet@google.com>

Thanks !

[toc] | [prev] | [next] | [standalone]


#1382911

FromDavid Miller <davem@davemloft.net>
Date2016-04-20 02:10 +0200
Message-ID<rpNSp-7ey-1@gated-at.bofh.it>
In reply to#1381613
From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Date: Mon, 18 Apr 2016 14:37:10 +0300

> skb->sk could point to timewait or request socket which has no sk_classid.
> Detected as "BUG: KASAN: slab-out-of-bounds in cls_cgroup_classify".
> 
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>

Applied, thank you.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web