Skip to content

Commit 42596ea

Browse files
gtrentalanciaxjamesmorris
authored andcommitted
selinux: load the initial SIDs upon every policy load
Always load the initial SIDs, even in the case of a policy reload and not just at the initial policy load. This comes particularly handy after the introduction of a recent patch for enabling runtime switching between different policy types, although this patch is in theory independent from that feature. Signed-off-by: Guido Trentalancia <guido@trentalancia.com> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org>
1 parent b6cac5a commit 42596ea

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎security/selinux/ss/services.c‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,10 @@ static int clone_sid(u32 sid,
15061506
{
15071507
struct sidtab *s = arg;
15081508

1509-
return sidtab_insert(s, sid, context);
1509+
if (sid > SECINITSID_NUM)
1510+
return sidtab_insert(s, sid, context);
1511+
else
1512+
return 0;
15101513
}
15111514

15121515
static inline int convert_context_handle_invalid_context(struct context *context)
@@ -1552,7 +1555,10 @@ static int convert_context(u32 key,
15521555
struct user_datum *usrdatum;
15531556
char *s;
15541557
u32 len;
1555-
int rc;
1558+
int rc = 0;
1559+
1560+
if (key <= SECINITSID_NUM)
1561+
goto out;
15561562

15571563
args = p;
15581564

@@ -1712,9 +1718,11 @@ int security_load_policy(void *data, size_t len)
17121718
if (policydb_read(&newpolicydb, fp))
17131719
return -EINVAL;
17141720

1715-
if (sidtab_init(&newsidtab)) {
1721+
rc = policydb_load_isids(&newpolicydb, &newsidtab);
1722+
if (rc) {
1723+
printk(KERN_ERR "SELinux: unable to load the initial SIDs\n");
17161724
policydb_destroy(&newpolicydb);
1717-
return -ENOMEM;
1725+
return rc;
17181726
}
17191727

17201728
if (selinux_set_mapping(&newpolicydb, secclass_map,

0 commit comments

Comments
 (0)