Skip to contentSkip to conversation

selinux: correct the return value when loads initial sids

PATCH Superseded Xiu Jianfeng 2 participants 3 messages Jul 28, 2021 – Jul 31, 2021 SELinux security module

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux: correct the return value when loads initial sids

It should not return 0 when SID 0 is assigned to isids. This patch fixes it.

Fixes e3e0b582c321a ("selinux: remove unused initial SIDs and improve handling")
---
 security/selinux/ss/policydb.c | 1 +
 1 file changed, 1 insertion(+)
security/selinux/ss/policydb.c +1 -0
index defc5ef35c66..ad1183e18ce0 100644
@@ -884,6 +884,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s)
 
 		if (sid == SECSID_NULL) {
 			pr_err("SELinux:  SID 0 was assigned a context.\n");
+			rc = -EINVAL;
 			sidtab_destroy(s);
 			goto out;
 		}
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 15 lines · Xiu Jianfeng

It should not return 0 when SID 0 is assigned to isids. This patch fixes it.

Fixes e3e0b582c321a ("selinux: remove unused initial SIDs and improve handling")
---
 security/selinux/ss/policydb.c | 1 +
 1 file changed, 1 insertion(+)
security/selinux/ss/policydb.c +0 -0
index defc5ef35c66..ad1183e18ce0 100644

security/selinux/ss/policydb.c int policydb_load_isids(struct policydb *p, struct sidtab *s) · line 890

Quoted 7 lines
security/selinux/ss/policydb.c +1 -0
@@ -884,6 +884,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s)
 
                if (sid == SECSID_NULL) {
                        pr_err("SELinux:  SID 0 was assigned a context.\n");
+                       rc = -EINVAL;
                        sidtab_destroy(s);
                        goto out;
                }

Hi Xiu Jianfeng,

Thanks for the patch, but since you are fixing the error handling in policydb_load_isids(), would you mind respinning this patch to get rid of the "out" label and just have all of the associated callers return directly instead? I generally dislike jump targets that do nothing else other than return a value; those 'goto X;' statements can easily be converted into 'return Y;' statements.

Thanks.

Signature · 2 lines
paul moore
www.paul-moore.com
#2 lore raw
Quoted 24 lines · Paul Moore
Quoted 14 lines · Xiu Jianfeng

It should not return 0 when SID 0 is assigned to isids. This patch fixes it.

Fixes e3e0b582c321a ("selinux: remove unused initial SIDs and improve handling")
---
  security/selinux/ss/policydb.c | 1 +
  1 file changed, 1 insertion(+)
security/selinux/ss/policydb.c +0 -0
index defc5ef35c66..ad1183e18ce0 100644

security/selinux/ss/policydb.c int policydb_load_isids(struct policydb *p, struct sidtab *s) · line 890

Quoted 7 lines
security/selinux/ss/policydb.c +1 -0
@@ -884,6 +884,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s)
 
                 if (sid == SECSID_NULL) {
                         pr_err("SELinux:  SID 0 was assigned a context.\n");
+                       rc = -EINVAL;
                         sidtab_destroy(s);
                         goto out;
                 }

Hi Xiu Jianfeng,

Quoted 6 lines

Thanks for the patch, but since you are fixing the error handling in policydb_load_isids(), would you mind respinning this patch to get rid of the "out" label and just have all of the associated callers return directly instead? I generally dislike jump targets that do nothing else other than return a value; those 'goto X;' statements can easily be converted into 'return Y;' statements.

no problem, please check the v2 patch.

Quoted 3 lines

Thanks.