Skip to contentSkip to conversation

SELinux: fix error return code in policydb_read()

PATCH In review Wei Yongjun 2 participants 2 messages Sep 10, 2016 – Sep 13, 2016 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SELinux: fix error return code in policydb_read()

From: Wei Yongjun <[email protected]>

Fix to return error code -EINVAL from the error handling case instead of 0(rc is overwrite to 0 when policyvers >= POLICYDB_VERSION_ROLETRANS), as done elsewhere in this function.

---
 security/selinux/ss/policydb.c | 1 +
 1 file changed, 1 insertion(+)
security/selinux/ss/policydb.c +1 -0
index 8c661f0..ace6838 100644
@@ -2417,6 +2417,7 @@ int policydb_read(struct policydb *p, void *fp)
 		} else
 			tr->tclass = p->process_class;
 
+		rc = -EINVAL;
 		if (!policydb_role_isvalid(p, tr->role) ||
 		    !policydb_type_isvalid(p, tr->type) ||
 		    !policydb_class_isvalid(p, tr->tclass) ||
maintainer
#1 lore raw
Quoted 10 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

Fix to return error code -EINVAL from the error handling case instead of 0(rc is overwrite to 0 when policyvers >= POLICYDB_VERSION_ROLETRANS), as done elsewhere in this function.

---
 security/selinux/ss/policydb.c | 1 +
 1 file changed, 1 insertion(+)

Nice catch, thanks for the patch; it has been merged into the selinux#next branch.

Quoted 13 lines
security/selinux/ss/policydb.c +1 -0
index 8c661f0..ace6838 100644
@@ -2417,6 +2417,7 @@ int policydb_read(struct policydb *p, void *fp)
                } else
                        tr->tclass = p->process_class;
 
+               rc = -EINVAL;
                if (!policydb_role_isvalid(p, tr->role) ||
                    !policydb_type_isvalid(p, tr->type) ||
                    !policydb_class_isvalid(p, tr->tclass) ||
Signature · 2 lines
paul moore
www.paul-moore.com