Skip to contentSkip to conversation

SELinux: silence build warning when !CONFIG_BUG

PATCH In review Eric Paris 2 participants 4 messages Apr 20, 2011 SELinux security module

lore
Share & tools
lore

Eric Paris

author
#0 lore raw

PATCH 1/2 SELinux: silence build warning when !CONFIG_BUG

If one builds a kernel without CONFIG_BUG there are a number of 'may be used uninitialized' warnings. Silence these by returning after the BUG().

---

 security/selinux/hooks.c   |    2 ++
 security/selinux/netnode.c |    1 +
 2 files changed, 3 insertions(+), 0 deletions(-)
security/selinux/hooks.c +2 -0
index 722cc0e..5b762a7 100644
@@ -992,6 +992,7 @@ static void selinux_write_opts(struct seq_file *m,
 			continue;
 		default:
 			BUG();
+			return;
 		};
 		/* we need a comma before each option */
 		seq_putc(m, ',');
@@ -1445,6 +1446,7 @@ static int task_has_capability(struct task_struct *tsk,
 		printk(KERN_ERR
 		       "SELinux:  out of range capability %d\n", cap);
 		BUG();
+		return -EINVAL;
 	}
 
 	rc = avc_has_perm_noaudit(sid, sid, sclass, av, 0, &avd);
security/selinux/netnode.c +1 -0
index 65ebfe9..3618251 100644
@@ -141,6 +141,7 @@ static struct sel_netnode *sel_netnode_find(const void *addr, u16 family)
 		break;
 	default:
 		BUG();
+		return NULL;
 	}
 
 	list_for_each_entry_rcu(node, &sel_netnode_hash[idx].list, list)

--
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

PATCH 2/2 SELinux: security_read_policy should take a size_t not ssize_t

The len should be an size_t but is a ssize_t. Easy enough fix to silence build warnings. We have no need for signed-ness.

---

 security/selinux/include/security.h |    2 +-
 security/selinux/ss/services.c      |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
security/selinux/include/security.h +1 -1
index 2cf6708..3ba4feb 100644
@@ -86,7 +86,7 @@ extern int selinux_policycap_openperm;
 int security_mls_enabled(void);
 
 int security_load_policy(void *data, size_t len);
-int security_read_policy(void **data, ssize_t *len);
+int security_read_policy(void **data, size_t *len);
 size_t security_policydb_len(void);
 
 int security_policycap_supported(unsigned int req_cap);
security/selinux/ss/services.c +1 -1
index cc5f116..5072aa7 100644
@@ -3189,7 +3189,7 @@ out:
  * @len: length of data in bytes
  *
  */
-int security_read_policy(void **data, ssize_t *len)
+int security_read_policy(void **data, size_t *len)
 {
 	int rc;
 	struct policy_file fp;

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

Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] SELinux: security_read_policy should take a size_t not ssize_t

Quoted 4 lines · Eric Paris

The len should be an size_t but is a ssize_t. Easy enough fix to silence build warnings. We have no need for signed-ness.

Signature · 7 lines
James Morris
<[email protected]>

--
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.
Reviewed-by on v1 1/2
#3 lore raw
In reply to Eric Paris
Quoted 4 lines · Eric Paris

If one builds a kernel without CONFIG_BUG there are a number of 'may be used uninitialized' warnings. Silence these by returning after the BUG().

Signature · 7 lines
James Morris
<[email protected]>

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