Skip to contentSkip to conversation

selinux: Print 'sclass' as string when unrecognized netlink message occurs

PATCH Applied Marek Milkovic 3 participants 4 messages Apr 2, 2015 – May 4, 2015 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux: Print 'sclass' as string when unrecognized netlink message occurs

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.

---
 security/selinux/hooks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/selinux/hooks.c +2 -2
index 87a9156..d75f525 100644
@@ -4712,8 +4712,8 @@ 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;
 		}
Signature · 1 line
2.1.0
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Marek Milkovic

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.

Quoted 20 lines
---
 security/selinux/hooks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/selinux/hooks.c +2 -2
index 87a9156..d75f525 100644
@@ -4712,8 +4712,8 @@ 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;
 		}
maintainer
#2 lore raw
In reply to Marek Milkovic
Quoted 7 lines · Marek Milkovic

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.

---
 security/selinux/hooks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Thanks Marek, this looks good. I'm adding this to the next queue for after the merge window.

Quoted 23 lines
security/selinux/hooks.c +2 -3
index 87a9156..d75f525 100644
@@ -4712,8 +4712,8 @@ 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;
                }
--

2.1.0

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

Signature · 2 lines
paul moore
www.paul-moore.com
maintainer Applied
#3 lore raw
Quoted 5 lines · Paul Moore
Quoted 4 lines · Marek Milkovic

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.

Quoted 8 lines
Quoted 5 lines

---

 security/selinux/hooks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Thanks Marek, this looks good. I'm adding this to the next queue for after the merge window.

Merged into next with a minor reformat to fit the code into an 80-char wide terminal.

Quoted 34 lines
Quoted 34 lines
security/selinux/hooks.c +0 -0
index 87a9156..d75f525 100644
@@ -4712,8 +4712,8 @@ 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;
                
                }

--
2.1.0

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

Signature · 2 lines
paul moore
www.paul-moore.com