Skip to content

Commit 7595b66

Browse files
committed
Merge tag 'selinux-pr-20250624' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux
Pull selinux fix from Paul Moore: "Another small SELinux patch to fix a problem seen by the dracut-ng folks during early boot when SELinux is enabled, but the policy has yet to be loaded" * tag 'selinux-pr-20250624' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux: selinux: change security_compute_sid to return the ssid or tsid on match
2 parents 78f4e73 + fde46f6 commit 7595b66

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

security/selinux/ss/services.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,11 +1909,17 @@ static int security_compute_sid(u32 ssid,
19091909
goto out_unlock;
19101910
}
19111911
/* Obtain the sid for the context. */
1912-
rc = sidtab_context_to_sid(sidtab, &newcontext, out_sid);
1913-
if (rc == -ESTALE) {
1914-
rcu_read_unlock();
1915-
context_destroy(&newcontext);
1916-
goto retry;
1912+
if (context_equal(scontext, &newcontext))
1913+
*out_sid = ssid;
1914+
else if (context_equal(tcontext, &newcontext))
1915+
*out_sid = tsid;
1916+
else {
1917+
rc = sidtab_context_to_sid(sidtab, &newcontext, out_sid);
1918+
if (rc == -ESTALE) {
1919+
rcu_read_unlock();
1920+
context_destroy(&newcontext);
1921+
goto retry;
1922+
}
19171923
}
19181924
out_unlock:
19191925
rcu_read_unlock();

0 commit comments

Comments
 (0)