selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: Daniel Burgener <dburgener@linux.microsoft.com>
Cc: selinux@vger.kernel.org,
	Stephen Smalley <stephen.smalley.work@gmail.com>,
	Ondrej Mosnacek <omosnace@redhat.com>,
	linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk
Subject: Re: [PATCH v3 4/4] selinux: Create new booleans and class dirs out of tree
Date: Fri, 21 Aug 2020 09:44:34 -0400	[thread overview]
Message-ID: <CAHC9VhQDjN=hcyHewNGZhdakNQBKBav3TsnuqJ-jV_uCdzJL1A@mail.gmail.com> (raw)
In-Reply-To: <20200819195935.1720168-5-dburgener@linux.microsoft.com>

On Wed, Aug 19, 2020 at 3:59 PM Daniel Burgener
<dburgener@linux.microsoft.com> wrote:
>
> In order to avoid concurrency issues around selinuxfs resource availability
> during policy load, we first create new directories out of tree for
> reloaded resources, then swap them in, and finally delete the old versions.
>
> This fix focuses on concurrency in each of the two subtrees swapped, and
> not concurrency between the trees.  This means that it is still possible
> that subsequent reads to eg the booleans directory and the class directory
> during a policy load could see the old state for one and the new for the other.
> The problem of ensuring that policy loads are fully atomic from the perspective
> of userspace is larger than what is dealt with here.  This commit focuses on
> ensuring that the directories contents always match either the new or the old
> policy state from the perspective of userspace.
>
> In the previous implementation, on policy load /sys/fs/selinux is updated
> by deleting the previous contents of
> /sys/fs/selinux/{class,booleans} and then recreating them.  This means
> that there is a period of time when the contents of these directories do not
> exist which can cause race conditions as userspace relies on them for
> information about the policy.  In addition, it means that error recovery in
> the event of failure is challenging.
>
> In order to demonstrate the race condition that this series fixes, you
> can use the following commands:
>
> while true; do cat /sys/fs/selinux/class/service/perms/status
> >/dev/null; done &
> while true; do load_policy; done;
>
> In the existing code, this will display errors fairly often as the class
> lookup fails.  (In normal operation from systemd, this would result in a
> permission check which would be allowed or denied based on policy settings
> around unknown object classes.) After applying this patch series you
> should expect to no longer see such error messages.
>
> Signed-off-by: Daniel Burgener <dburgener@linux.microsoft.com>
> ---
>  security/selinux/selinuxfs.c | 113 ++++++++++++++++++++++++++++-------
>  1 file changed, 90 insertions(+), 23 deletions(-)

Merged into selinux/next, thanks!

-- 
paul moore
www.paul-moore.com

      parent reply	other threads:[~2020-08-21 13:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-19 19:59 [PATCH v3 0/4] Update SELinuxfs out of tree and then swapover Daniel Burgener
2020-08-19 19:59 ` [PATCH v3 1/4] selinux: Create function for selinuxfs directory cleanup Daniel Burgener
2020-08-20 14:53   ` Stephen Smalley
2020-08-21 13:43   ` Paul Moore
2020-08-19 19:59 ` [PATCH v3 2/4] selinux: Refactor selinuxfs directory populating functions Daniel Burgener
2020-08-20 14:55   ` Stephen Smalley
2020-08-21 13:43   ` Paul Moore
2020-08-19 19:59 ` [PATCH v3 3/4] selinux: Standardize string literal usage for selinuxfs directory names Daniel Burgener
2020-08-20 14:56   ` Stephen Smalley
2020-08-21 13:44   ` Paul Moore
2020-08-19 19:59 ` [PATCH v3 4/4] selinux: Create new booleans and class dirs out of tree Daniel Burgener
2020-08-20 15:23   ` Stephen Smalley
2020-08-21 13:44   ` Paul Moore [this message]

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='CAHC9VhQDjN=hcyHewNGZhdakNQBKBav3TsnuqJ-jV_uCdzJL1A@mail.gmail.com' \
    --to=paul@paul-moore.com \
    --cc=dburgener@linux.microsoft.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=omosnace@redhat.com \
    --cc=selinux@vger.kernel.org \
    --cc=stephen.smalley.work@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).