Skip to contentSkip to conversation

selinux: suppress warning flood for retired DCCP netlink messages

PATCH Superseded Yafang Shao 4 participants 6 messages Jun 29 – Jul 2 SELinux security module

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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].

Since this is a retired feature rather than an invalid operation, return -ENOENT instead of -EINVAL. This suppresses the warning flood while maintaining correct error semantics for user space.

Fixes 2a63dd0edf38 ("net: Retire DCCP socket.")
Cc Kuniyuki Iwashima <[email protected]>
---
 security/selinux/nlmsgtab.c | 3 +++
 1 file changed, 3 insertions(+)
security/selinux/nlmsgtab.c +3 -0
index 655d2616c9d2..812961a847bc 100644
@@ -192,6 +192,9 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm)
 				  sizeof(nlmsg_route_perms));
 		break;
 	case SECCLASS_NETLINK_TCPDIAG_SOCKET:
+		/* DCCPDIAG_GETSOCK has already been deprecated */
+		if (nlmsg_type == DCCPDIAG_GETSOCK)
+			return -ENOENT;
 		if (selinux_policycap_netlink_xperm()) {
 			*perm = NETLINK_TCPDIAG_SOCKET__NLMSG;
 			return 0;
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

Since this is a retired feature rather than an invalid operation, return -ENOENT instead of -EINVAL. This suppresses the warning flood while maintaining correct error semantics for user space.

Fixes 2a63dd0edf38 ("net: Retire DCCP socket.")

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
#2 lore raw
In reply to Yafang Shao
Quoted 4 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:

Please update ss instead of reviving dead code in kernel.

Quoted 39 lines
  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].

Since this is a retired feature rather than an invalid operation, return -ENOENT instead of -EINVAL. This suppresses the warning flood while maintaining correct error semantics for user space.

Fixes 2a63dd0edf38 ("net: Retire DCCP socket.")
Cc Kuniyuki Iwashima <[email protected]>
---
 security/selinux/nlmsgtab.c | 3 +++
 1 file changed, 3 insertions(+)
security/selinux/nlmsgtab.c +3 -1
index 655d2616c9d2..812961a847bc 100644
@@ -192,6 +192,9 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm)
                                  sizeof(nlmsg_route_perms));
                break;
        case SECCLASS_NETLINK_TCPDIAG_SOCKET:
+               /* DCCPDIAG_GETSOCK has already been deprecated */
+               if (nlmsg_type == DCCPDIAG_GETSOCK)
+                       return -ENOENT;
                if (selinux_policycap_netlink_xperm()) {
                        *perm = NETLINK_TCPDIAG_SOCKET__NLMSG;
                        return 0;
--

2.52.0

#3 lore raw
Quoted 8 lines · Kuniyuki Iwashima
Quoted 4 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:

Please update ss instead of reviving dead code in kernel.

I will submit a patch to update ss shortly. However, I suspect other tools may also invoke this deprecated interface, which could flood the kernel log. It would be preferable to suppress these warnings in the kernel to maintain compatibility with existing tools.

Signature · 2 lines
Regards
Yafang
maintainer
#4 lore raw
Quoted 7 lines · Yafang Shao
Quoted 6 lines · Kuniyuki Iwashima
Quoted 4 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:

Quoted 6 lines
Quoted 1 line

Please update ss instead of reviving dead code in kernel.

I will submit a patch to update ss shortly. However, I suspect other tools may also invoke this deprecated interface, which could flood the kernel log. It would be preferable to suppress these warnings in the kernel to maintain compatibility with existing tools.

I think there is a middle ground where we still output an error message to the console, but we only do it once. Yes, we are adding a couple lines of code to check for DCCP netlink messages and print the error, but I think that is preferable to log spam.

Yafang Shao, could you update your patch to check for DCCPDIAG_GETSOCK in the -EINVAL error handling code in selinux_netlink_send() and use a pr_warn_once() to output an error?

  pr_warn_once("SELinux: DCCP has been removed, pid=%d comm=%s\n", ...);
Signature · 1 line
paul-moore.com
#5 lore raw
Quoted 21 lines · Paul Moore
Quoted 7 lines · Yafang Shao
Quoted 6 lines · Kuniyuki Iwashima
Quoted 4 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:

Quoted 6 lines
Quoted 1 line

Please update ss instead of reviving dead code in kernel.

I will submit a patch to update ss shortly. However, I suspect other tools may also invoke this deprecated interface, which could flood the kernel log. It would be preferable to suppress these warnings in the kernel to maintain compatibility with existing tools.

I think there is a middle ground where we still output an error message to the console, but we only do it once. Yes, we are adding a couple lines of code to check for DCCP netlink messages and print the error, but I think that is preferable to log spam.

Quoted 5 lines

Yafang Shao, could you update your patch to check for DCCPDIAG_GETSOCK in the -EINVAL error handling code in selinux_netlink_send() and use a pr_warn_once() to output an error?

  pr_warn_once("SELinux: DCCP has been removed, pid=%d comm=%s\n", ...);

Thanks for your suggestion.
I will update it.

Signature · 2 lines
Regards
Yafang