Skip to contentSkip to conversation

selinux: suppress warning flood for retired DCCP netlink messages

PATCH Applied Yafang Shao 4 participants 4 messages Jul 9 – Jul 13 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 selinux: suppress warning flood for retired DCCP netlink messages

When deploying linux-6.18.y stable kernel to production servers, we observed kernel dmesg being flooded with SELinux warnings when running ss -l:

  SELinux: unrecognized netlink message: protocol=4 nlmsg_type=19 \
    sclass=netlink_tcpdiag_socket pid=188945 comm=ss

The root cause is that DCCP support was retired in
commit 2a63dd0edf38 ("net: Retire DCCP socket."). Consequently, DCCPDIAG_GETSOCK was removed from nlmsg_tcpdiag_perms. This causes nlmsg_perm() to return -EINVAL, triggering the SELinux warning for every ss -l invocation [0].

Use pr_warn_once() for the retired DCCPDIAG_GETSOCK to prevent message flooding.

Fixes 2a63dd0edf38 ("net: Retire DCCP socket.")
Cc Kuniyuki Iwashima <[email protected]>
Cc Stephen Smalley <[email protected]>
---
 security/selinux/hooks.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

v2->v3: check also the sclass (sashiko-bot, Stephen) v1->v2: use pr_warn_once for the removed DCCPDIAG_GETSOCK (Paul)

security/selinux/hooks.c +12 -6
index 1a713d96206f..8a9ec06e40ab 100644
@@ -94,6 +94,7 @@
 #include <linux/io_uring/cmd.h>
 #include <uapi/linux/lsm.h>
 #include <linux/memfd.h>
+#include <uapi/linux/inet_diag.h>
 
 #include "initcalls.h"
 #include "avc.h"
@@ -6272,12 +6273,17 @@ static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb)
 				return rc;
 		} else if (rc == -EINVAL) {
 			/* -EINVAL is a missing msg/perm mapping */
-			pr_warn_ratelimited("SELinux: unrecognized netlink"
-				" message: protocol=%hu nlmsg_type=%hu sclass=%s"
-				" pid=%d comm=%s\n",
-				sk->sk_protocol, nlh->nlmsg_type,
-				secclass_map[sclass - 1].name,
-				task_pid_nr(current), current->comm);
+			if (sclass == SECCLASS_NETLINK_TCPDIAG_SOCKET &&
+			    nlh->nlmsg_type == DCCPDIAG_GETSOCK)
+				pr_warn_once("SELinux: DCCP has been removed, pid=%d comm=%s\n",
+					     task_pid_nr(current), current->comm);
+			else
+				pr_warn_ratelimited("SELinux: unrecognized netlink"
+					" message: protocol=%hu nlmsg_type=%hu sclass=%s"
+					" pid=%d comm=%s\n",
+					sk->sk_protocol, nlh->nlmsg_type,
+					secclass_map[sclass - 1].name,
+					task_pid_nr(current), current->comm);
 			if (enforcing_enabled() &&
 			    !security_get_allow_unknown())
 				return rc;
Signature · 1 line
2.52.0
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 13 lines

When deploying linux-6.18.y stable kernel to production servers, we observed kernel dmesg being flooded with SELinux warnings when running ss -l:

  SELinux: unrecognized netlink message: protocol=4 nlmsg_type=19 \
    sclass=netlink_tcpdiag_socket pid=188945 comm=ss

The root cause is that DCCP support was retired in
commit 2a63dd0edf38 ("net: Retire DCCP socket."). Consequently, DCCPDIAG_GETSOCK was removed from nlmsg_tcpdiag_perms. This causes nlmsg_perm() to return -EINVAL, triggering the SELinux warning for every ss -l invocation [0].

Quoted 7 lines

Use pr_warn_once() for the retired DCCPDIAG_GETSOCK to prevent message flooding.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Acked-by on v3 1/1
#2 lore raw
In reply to Yafang Shao
Quoted 17 lines · Yafang Shao

When deploying linux-6.18.y stable kernel to production servers, we observed kernel dmesg being flooded with SELinux warnings when running ss -l:

  SELinux: unrecognized netlink message: protocol=4 nlmsg_type=19 \
    sclass=netlink_tcpdiag_socket pid=188945 comm=ss

The root cause is that DCCP support was retired in
commit 2a63dd0edf38 ("net: Retire DCCP socket."). Consequently, DCCPDIAG_GETSOCK was removed from nlmsg_tcpdiag_perms. This causes nlmsg_perm() to return -EINVAL, triggering the SELinux warning for every ss -l invocation [0].

Use pr_warn_once() for the retired DCCPDIAG_GETSOCK to prevent message flooding.

Quoted 6 lines
Fixes 2a63dd0edf38 ("net: Retire DCCP socket.")
Cc Kuniyuki Iwashima <[email protected]>
Cc Stephen Smalley <[email protected]>
Quoted 46 lines
---
 security/selinux/hooks.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

v2->v3: check also the sclass (sashiko-bot, Stephen) v1->v2: use pr_warn_once for the removed DCCPDIAG_GETSOCK (Paul)

security/selinux/hooks.c +12 -7
index 1a713d96206f..8a9ec06e40ab 100644
@@ -94,6 +94,7 @@
 #include <linux/io_uring/cmd.h>
 #include <uapi/linux/lsm.h>
 #include <linux/memfd.h>
+#include <uapi/linux/inet_diag.h>
 
 #include "initcalls.h"
 #include "avc.h"
@@ -6272,12 +6273,17 @@ static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb)
                                return rc;
                } else if (rc == -EINVAL) {
                        /* -EINVAL is a missing msg/perm mapping */
-                       pr_warn_ratelimited("SELinux: unrecognized netlink"
-                               " message: protocol=%hu nlmsg_type=%hu sclass=%s"
-                               " pid=%d comm=%s\n",
-                               sk->sk_protocol, nlh->nlmsg_type,
-                               secclass_map[sclass - 1].name,
-                               task_pid_nr(current), current->comm);
+                       if (sclass == SECCLASS_NETLINK_TCPDIAG_SOCKET &&
+                           nlh->nlmsg_type == DCCPDIAG_GETSOCK)
+                               pr_warn_once("SELinux: DCCP has been removed, pid=%d comm=%s\n",
+                                            task_pid_nr(current), current->comm);
+                       else
+                               pr_warn_ratelimited("SELinux: unrecognized netlink"
+                                       " message: protocol=%hu nlmsg_type=%hu sclass=%s"
+                                       " pid=%d comm=%s\n",
+                                       sk->sk_protocol, nlh->nlmsg_type,
+                                       secclass_map[sclass - 1].name,
+                                       task_pid_nr(current), current->comm);
                        if (enforcing_enabled() &&
                            !security_get_allow_unknown())
                                return rc;
--

2.52.0

maintainer Applied
#3 lore raw
In reply to Yafang Shao
Quoted 24 lines · On Jul 9, 2026 Yafang Shao <[email protected]> wrote:

When deploying linux-6.18.y stable kernel to production servers, we observed kernel dmesg being flooded with SELinux warnings when running ss -l:

  SELinux: unrecognized netlink message: protocol=4 nlmsg_type=19 \
    sclass=netlink_tcpdiag_socket pid=188945 comm=ss

The root cause is that DCCP support was retired in
commit 2a63dd0edf38 ("net: Retire DCCP socket."). Consequently, DCCPDIAG_GETSOCK was removed from nlmsg_tcpdiag_perms. This causes nlmsg_perm() to return -EINVAL, triggering the SELinux warning for every ss -l invocation [0].

Use pr_warn_once() for the retired DCCPDIAG_GETSOCK to prevent message flooding.

Fixes 2a63dd0edf38 ("net: Retire DCCP socket.")
Cc Kuniyuki Iwashima <[email protected]>
Cc Stephen Smalley <[email protected]>
Quoted 6 lines
---
 security/selinux/hooks.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

v2->v3: check also the sclass (sashiko-bot, Stephen) v1->v2: use pr_warn_once for the removed DCCPDIAG_GETSOCK (Paul)

Merged into selinux/dev, thanks!

--
paul-moore.com