From: Petr Lautrbach <lautrbach@redhat.com>
To: selinux@vger.kernel.org
Subject: In permissive setting labels that are not in host policy when running unprivileged fails with EINVAL
Date: Wed, 10 Jul 2024 15:32:24 +0200 [thread overview]
Message-ID: <87v81d74pj.fsf@redhat.com> (raw)
Hello,
this is originally reported at
https://github.com/SELinuxProject/selinux/issues/437
There a question why kernel blocks changing SELinux label to some
unknown label and requires CAP_MAC_ADMIN even in permissive mode?
Reproducer:
$ id -u
1000
$ getenforce
Permissive
$ chcon -t bin_t /var/lib/mock/fedora-rawhide-x86_64/root/usr/lib/systemd/system-generators/systemd-ssh-generator
$ chcon -t selinux_unknown_type_t /var/lib/mock/fedora-rawhide-x86_64/root/usr/lib/systemd/system-generators/systemd-ssh-generator
chcon: failed to change context of '/var/lib/mock/fedora-rawhide-x86_64/root/usr/lib/systemd/system-generators/systemd-ssh-generator' to ‘system_u:object_r:selinux_unknown_type_t:s0’: Invalid argument
Quotes from the issue:
This is happening on a system with SELinux in permissive mode. Applying
your suggestion does not change the result. I assume this is gated
behind CAP_MAC_ADMIN for unprivileged users. Is there any way to make
this work without needing root privileges?
Hmm so the kernel blocks unknown labels unless the user has
CAP_MAC_ADMIN in the initial user namespace. I'm assuming this is for a
good reason and it would be unsafe to allow any user to do this so I
don't think there's anything that can be done here
One thing that's not clear to me, why is an unprivileged user allowed to
write labels known by the host but not labels that are not known to the
host? What specifically is unsafe about unknown labels that's not an
issue with known labels?
Petr
next reply other threads:[~2024-07-10 13:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-10 13:32 Petr Lautrbach [this message]
2024-07-10 13:50 ` In permissive setting labels that are not in host policy when running unprivileged fails with EINVAL Stephen Smalley
2024-07-10 15:29 ` Paul Moore
2024-07-10 15:41 ` Petr Lautrbach
2024-07-10 17:40 ` Dominick Grift
2024-07-10 19:29 ` Stephen Smalley
2024-07-10 19:47 ` Dominick Grift
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v81d74pj.fsf@redhat.com \
--to=lautrbach@redhat.com \
--cc=selinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.