]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: cgroup: Guard users of sock_cgroup_classid()
authorMichal Koutný <mkoutny@suse.com>
Tue, 1 Apr 2025 11:57:31 +0000 (13:57 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 24 Apr 2025 14:04:02 +0000 (16:04 +0200)
Exclude code that relies on sock_cgroup_classid() as preparation of
removal of the function.

Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/ipv4/inet_diag.c
net/netfilter/xt_cgroup.c

index 907bad776b4236cba5dd10c0b53cd0fe3ba00cb4..1d1d6ad53f4c9173cbcb644a301bfbc2f2d5925c 100644 (file)
@@ -160,7 +160,7 @@ int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
            ext & (1 << (INET_DIAG_TCLASS - 1))) {
                u32 classid = 0;
 
-#ifdef CONFIG_SOCK_CGROUP_DATA
+#ifdef CONFIG_CGROUP_NET_CLASSID
                classid = sock_cgroup_classid(&sk->sk_cgrp_data);
 #endif
                /* Fallback to socket priority if class id isn't set.
index 66915bf0d89ad132e2b0faa0e593e0a34e035ca8..c437fbd59ec130ab6a823a3a01c154d682ec5587 100644 (file)
@@ -117,6 +117,7 @@ static int cgroup_mt_check_v2(const struct xt_mtchk_param *par)
 static bool
 cgroup_mt_v0(const struct sk_buff *skb, struct xt_action_param *par)
 {
+#ifdef CONFIG_CGROUP_NET_CLASSID
        const struct xt_cgroup_info_v0 *info = par->matchinfo;
        struct sock *sk = skb->sk;
 
@@ -125,6 +126,8 @@ cgroup_mt_v0(const struct sk_buff *skb, struct xt_action_param *par)
 
        return (info->id == sock_cgroup_classid(&skb->sk->sk_cgrp_data)) ^
                info->invert;
+#endif
+       return false;
 }
 
 static bool cgroup_mt_v1(const struct sk_buff *skb, struct xt_action_param *par)
@@ -140,9 +143,12 @@ static bool cgroup_mt_v1(const struct sk_buff *skb, struct xt_action_param *par)
        if (ancestor)
                return cgroup_is_descendant(sock_cgroup_ptr(skcd), ancestor) ^
                        info->invert_path;
+#ifdef CONFIG_CGROUP_NET_CLASSID
        else
                return (info->classid == sock_cgroup_classid(skcd)) ^
                        info->invert_classid;
+#endif
+       return false;
 }
 
 static bool cgroup_mt_v2(const struct sk_buff *skb, struct xt_action_param *par)
@@ -158,9 +164,12 @@ static bool cgroup_mt_v2(const struct sk_buff *skb, struct xt_action_param *par)
        if (ancestor)
                return cgroup_is_descendant(sock_cgroup_ptr(skcd), ancestor) ^
                        info->invert_path;
+#ifdef CONFIG_CGROUP_NET_CLASSID
        else
                return (info->classid == sock_cgroup_classid(skcd)) ^
                        info->invert_classid;
+#endif
+       return false;
 }
 
 static void cgroup_mt_destroy_v1(const struct xt_mtdtor_param *par)