]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selinux: Print 'sclass' as string when unrecognized netlink message occurs
authorMarek Milkovic <mmilkovi@redhat.com>
Thu, 4 Jun 2015 20:22:16 +0000 (16:22 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 11 Jun 2020 18:05:39 +0000 (19:05 +0100)
commit cded3fffbeab777e6ad2ec05d4a3b62c5caca0f3 upstream.

This prints the 'sclass' field as string instead of index in unrecognized netlink message.
The textual representation makes it easier to distinguish the right class.

Signed-off-by: Marek Milkovic <mmilkovi@redhat.com>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
[PM: 80-char width fixes]
Signed-off-by: Paul Moore <pmoore@redhat.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
security/selinux/hooks.c

index ba090b1ae8eb9f5ff5fa277718f3e738f8b57e92..99814b6807c49c16d8c99a3b739939237cf2815a 100644 (file)
@@ -4685,8 +4685,9 @@ static int selinux_nlmsg_perm(struct sock *sk, struct sk_buff *skb)
                if (err == -EINVAL) {
                        printk(KERN_WARNING
                               "SELinux: unrecognized netlink message:"
-                              " protocol=%hu nlmsg_type=%hu sclass=%hu\n",
-                              sk->sk_protocol, nlh->nlmsg_type, sksec->sclass);
+                              " protocol=%hu nlmsg_type=%hu sclass=%s\n",
+                              sk->sk_protocol, nlh->nlmsg_type,
+                              secclass_map[sksec->sclass - 1].name);
                        if (!selinux_enforcing || security_get_allow_unknown())
                                err = 0;
                }