Skip to contentSkip to conversation

selinux: fix problems in netnode when BUG() is compiled out

PATCH In review Paul Moore 1 participant 3 messages Apr 4, 2013 – May 24, 2013 SELinux security module

lore
Share & tools
lore

Paul Moore

author
#0 lore raw

PATCH v3 1/1 selinux: fix problems in netnode when BUG() is compiled out

When the BUG() macro is disabled at compile time it can cause some problems in the SELinux netnode code: invalid return codes and uninitialized variables. This patch fixes this by making sure we take some corrective action after the BUG() macro.

---

In the process of cleaning up a local git tree I realized I had this patch still sitting in my tree that for some reason hadn't been merged upstream. Originally sent back on December 5, 2012.

---
 security/selinux/netnode.c |    2 ++
 1 file changed, 2 insertions(+)
security/selinux/netnode.c +2 -0
index c5454c0..03a72c3 100644
@@ -166,6 +166,7 @@ static void sel_netnode_insert(struct sel_netnode *node)
 		break;
 	default:
 		BUG();
+		return;
 	}
 
 	/* we need to impose a limit on the growth of the hash table so check
@@ -225,6 +226,7 @@ static int sel_netnode_sid_slow(void *addr, u16 family, u32 *sid)
 		break;
 	default:
 		BUG();
+		ret = -EINVAL;
 	}
 	if (ret != 0)
 		goto out;

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

author
#1 lore raw
Quoted 30 lines · Paul Moore

When the BUG() macro is disabled at compile time it can cause some problems in the SELinux netnode code: invalid return codes and uninitialized variables. This patch fixes this by making sure we take some corrective action after the BUG() macro.

---

In the process of cleaning up a local git tree I realized I had this patch still sitting in my tree that for some reason hadn't been merged upstream. Originally sent back on December 5, 2012.

---
 security/selinux/netnode.c |    2 ++
 1 file changed, 2 insertions(+)
security/selinux/netnode.c +1 -0
index c5454c0..03a72c3 100644
@@ -166,6 +166,7 @@ static void sel_netnode_insert(struct sel_netnode *node)
 break;
 	default:
 		BUG();
+		return;
 	}
 
 	/* we need to impose a limit on the growth of the hash table so check

security/selinux/netnode.c static int sel_netnode_sid_slow(void *addr, u16 family, · line 232

Quoted 7 lines
security/selinux/netnode.c +1 -0
@@ -225,6 +226,7 @@ static int sel_netnode_sid_slow(void *addr, u16 family,
 u32 *sid) break;
 	default:
 		BUG();
+		ret = -EINVAL;
 	}
 	if (ret != 0)
 		goto out;

It would be nice to get this into 3.10.

Signature · 8 lines
paul moore
security and virtualization @ redhat


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
author
#2 lore raw
Quoted 42 lines · Paul Moore
Quoted 41 lines · Paul Moore

When the BUG() macro is disabled at compile time it can cause some problems in the SELinux netnode code: invalid return codes and uninitialized variables. This patch fixes this by making sure we take some corrective action after the BUG() macro.

---

In the process of cleaning up a local git tree I realized I had this patch still sitting in my tree that for some reason hadn't been merged upstream. Originally sent back on December 5, 2012.
---

 security/selinux/netnode.c |    2 ++
 1 file changed, 2 insertions(+)
security/selinux/netnode.c +1 -0
index c5454c0..03a72c3 100644
@@ -166,6 +166,7 @@ static void sel_netnode_insert(struct sel_netnode
 *node) break;
 
 	default:
 		BUG();
 
+		return;
 
security/selinux/netnode.c +0 -0
 	}
 
 	/* we need to impose a limit on the growth of the hash table so check
@@ -225,6 +226,7 @@ static int sel_netnode_sid_slow(void *addr, u16
 family,
 u32 *sid) break;
 
 	default:
 		BUG();
 
Quoted 8 lines

security/selinux/netnode.c static int sel_netnode_sid_slow(void *addr, u16 family, u32 *sid) · line 232

Quoted 6 lines
security/selinux/netnode.c +1 -0
+		ret = -EINVAL;
security/selinux/netnode.c +0 -0
 	}
 	if (ret != 0)
 
 		goto out;

It would be nice to get this into 3.10.

*COUGH*
Hello? 3.10? Hello?
*COUGH*

Signature · 8 lines
paul moore
security and virtualization @ redhat


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.