Skip to contentSkip to conversation

Oops in sidtab_context_to_sid

BUG Paul Moore 3 participants 4 messages Apr 3, 2021 – Apr 5, 2021 1 message not in the archive SELinux security module

lore
Share & tools
lore

Paul Moore

author maintainer
#1 lore raw
In reply to a message not in the archive
Quoted 6 lines · Vijay Balakrishna

Seeing oops in 5.4.83 sidtab_context_to_sid(). I checked with Tyler (copied), he said it might be

https://lore.kernel.org/selinux/CAFqZXNu8s5edDbSZuSutetTsy58i08vPuP2h-n9=kT34HcPc4w@mail.gmail.com/

Ondrej, can you confirm? Unfortunately, we don't have a on demand repro.

I'm guessing this may be the problem that Tyler reported earlier and which appeared to be fixed by the patch below:

https://lore.kernel.org/selinux/[email protected]

... which was merged into Linus' tree during the v5.12-rcX development phase, any chance you could try that patch to see if it resolves your issue? There are still some issues to be sorted out, but if you aren't reloading policy it shouldn't be a concern.

Tyler, since both of you are at Microsoft, do you have a patched kernel that Vijay could try?

Signature · 2 lines
paul moore
www.paul-moore.com
#2 lore raw
Quoted 5 lines · Paul Moore
Quoted 3 lines · Vijay Balakrishna

Seeing oops in 5.4.83 sidtab_context_to_sid(). I checked with Tyler (copied), he said it might be

Quoted 8 lines
Quoted 3 lines

https://lore.kernel.org/selinux/CAFqZXNu8s5edDbSZuSutetTsy58i08vPuP2h-n9=kT34HcPc4w@mail.gmail.com/

Ondrej, can you confirm? Unfortunately, we don't have a on demand repro.

I'm guessing this may be the problem that Tyler reported earlier and which appeared to be fixed by the patch below:

https://lore.kernel.org/selinux/[email protected]

Nope, if that's really 5.4.83 with no extra backports, then it can't be this issue as it has been introduced only in v5.10.

Looking at the code in 5.4.83, my initial guess is that it could be a memory ordering race between sidtab_reverse_lookup()/sidtab_rcache_push() and sidtab_rcache_search(). I think the sidtab_rcache_push() call at security/selinux/ss/security.c:326 should in fact be after the smp_store_release() call. Note that the sidtab_rcache_*() functions have been replaced in commit 66f8e2f03c02 ("selinux: sidtab reverse lookup hash table") with a different mechanism, which AFAICT doesn't have the same issue.

If that's really it, it will likely be *very* hard to reproduce, so you may be unable to verify the fix.

Signature · 3 lines
Ondrej Mosnacek
Software Engineer, Linux Security - SELinux kernel
Red Hat, Inc.
author maintainer
#3 lore raw
Quoted 10 lines · Ondrej Mosnacek
Quoted 9 lines · Paul Moore
Quoted 6 lines · Vijay Balakrishna

Seeing oops in 5.4.83 sidtab_context_to_sid(). I checked with Tyler (copied), he said it might be

https://lore.kernel.org/selinux/CAFqZXNu8s5edDbSZuSutetTsy58i08vPuP2h-n9=kT34HcPc4w@mail.gmail.com/

Ondrej, can you confirm? Unfortunately, we don't have a on demand repro.

Quoted 7 lines
Quoted 4 lines

I'm guessing this may be the problem that Tyler reported earlier and which appeared to be fixed by the patch below:

https://lore.kernel.org/selinux/[email protected]

Nope, if that's really 5.4.83 with no extra backports, then it can't be this issue as it has been introduced only in v5.10.

Of course, good catch.

Signature · 2 lines
paul moore
www.paul-moore.com
#4 lore raw
In reply to Ondrej Mosnacek
Quoted 28 lines · Ondrej Mosnacek
Quoted 5 lines · Paul Moore
Quoted 3 lines · Vijay Balakrishna

Seeing oops in 5.4.83 sidtab_context_to_sid(). I checked with Tyler (copied), he said it might be

Quoted 8 lines
Quoted 3 lines

https://lore.kernel.org/selinux/CAFqZXNu8s5edDbSZuSutetTsy58i08vPuP2h-n9=kT34HcPc4w@mail.gmail.com/

Ondrej, can you confirm? Unfortunately, we don't have a on demand repro.

I'm guessing this may be the problem that Tyler reported earlier and which appeared to be fixed by the patch below:

https://lore.kernel.org/selinux/[email protected]

Nope, if that's really 5.4.83 with no extra backports, then it can't be this issue as it has been introduced only in v5.10.

Looking at the code in 5.4.83, my initial guess is that it could be a memory ordering race between sidtab_reverse_lookup()/sidtab_rcache_push() and sidtab_rcache_search(). I think the sidtab_rcache_push() call at security/selinux/ss/security.c:326 should in fact be after the smp_store_release() call. Note that the sidtab_rcache_*() functions have been replaced in commit 66f8e2f03c02 ("selinux: sidtab reverse lookup hash table") with a different mechanism, which AFAICT doesn't have the same issue.

Quoted 3 lines

If that's really it, it will likely be *very* hard to reproduce, so you may be unable to verify the fix.

Thank you Ondrej. We may rebase our kernel in a couple of months.