selinux: suppress warning flood for retired DCCP netlink messages
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=ssThe 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.
--- security/selinux/nlmsgtab.c | 3 +++ 1 file changed, 3 insertions(+)
security/selinux/nlmsgtab.c +3 -0
@@ -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
[email protected]
AI reviewSashiko 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=ssThe root cause is that DCCP support was retired in
commit2a63dd0edf38("net: Retire DCCP socket."). Consequently,DCCPDIAG_GETSOCKwas removed fromnlmsg_tcpdiag_perms. This causesnlmsg_perm()to return-EINVAL, triggering the SELinux warning for everyss -linvocation [0].
Quoted 7 lines
Since this is a retired feature rather than an invalid operation, return
-ENOENTinstead of-EINVAL. This suppresses the warning flood while maintaining correct error semantics for user space.Fixes 2a63dd0edf38 ("net: Retire DCCP socket.")Signed-off-by Yafang Shao <[email protected]>
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
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=ssThe root cause is that DCCP support was retired in
commit2a63dd0edf38("net: Retire DCCP socket."). Consequently,DCCPDIAG_GETSOCKwas removed fromnlmsg_tcpdiag_perms. This causesnlmsg_perm()to return-EINVAL, triggering the SELinux warning for everyss -linvocation [0].Since this is a retired feature rather than an invalid operation, return
-ENOENTinstead of-EINVAL. This suppresses the warning flood while maintaining correct error semantics for user space.Fixes 2a63dd0edf38 ("net: Retire DCCP socket.")Signed-off-by Yafang Shao <[email protected]>Cc Kuniyuki Iwashima <[email protected]>--- security/selinux/nlmsgtab.c | 3 +++ 1 file changed, 3 insertions(+)security/selinux/nlmsgtab.c +3
-1@@ -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
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
Paul Moore
maintainerQuoted 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
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_GETSOCKin the-EINVALerror handling code inselinux_netlink_send()and use apr_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