All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ondrej Mosnacek <omosnace@redhat.com>
To: selinux@vger.kernel.org, Paul Moore <paul@paul-moore.com>
Cc: selinux@tycho.nsa.gov, Stephen Smalley <sds@tycho.nsa.gov>,
	Ondrej Mosnacek <omosnace@redhat.com>
Subject: [PATCH 0/2] Fix ENOMEM errors during policy reload
Date: Wed, 31 Oct 2018 13:27:16 +0100	[thread overview]
Message-ID: <20181031122718.18735-1-omosnace@redhat.com> (raw)

This patchset revamps the SID table implementation to fix ENOMEM errors returned from sidtab_context_to_sid() during policy reload.

The first patch prepares the way for the second one by moving the handling of initial SIDs to a separate table. This is needed since the second patch will do the sidtab conversion in-place and handling the initial SIDs would complicate things too much.

The second patch changes the way that sidtab is transitioned to the new policy so that it does not need to be frozen for modifications during the conversion of entries to the new policy.

See individual patches for more details.

Resolves: https://github.com/SELinuxProject/selinux-kernel/issues/38
Testing:
 - passed selinux-testsuite
 - verified using the reproducer from GH issue
 - tested with the following stress test on SMP (with lock debugging enabled):

function rand_cat() {
	echo $(( $RANDOM % 1024 ))
}

function do_work() {
	while runcon -l s0:c$(rand_cat),c$(rand_cat) echo -n x; do :; done
}

do_work >/dev/null &
do_work >/dev/null &
do_work >/dev/null &

while load_policy; do echo -n .; sleep 0.1; done

kill %1
kill %2
kill %3

--
Ondrej Mosnacek (2):
  selinux: use separate table for initial SID lookup
  selinux: fix ENOMEM errors during policy reload

 security/selinux/include/security.h |   3 +
 security/selinux/ss/mls.c           |  22 +-
 security/selinux/ss/mls.h           |   5 +-
 security/selinux/ss/policydb.c      |  24 ++-
 security/selinux/ss/policydb.h      |  26 ++-
 security/selinux/ss/services.c      | 314 +++++++++++++---------------
 security/selinux/ss/services.h      |   1 +
 security/selinux/ss/sidtab.c        | 141 +++++++------
 security/selinux/ss/sidtab.h        |  26 +--
 9 files changed, 296 insertions(+), 266 deletions(-)

-- 
2.17.2


             reply	other threads:[~2018-10-31 12:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-31 12:27 Ondrej Mosnacek [this message]
2018-10-31 12:27 ` [PATCH 1/2] selinux: use separate table for initial SID lookup Ondrej Mosnacek
2018-10-31 17:12   ` Stephen Smalley
2018-11-02 15:35     ` Ondrej Mosnacek
2018-11-05 20:47       ` Paul Moore
2018-10-31 12:27 ` [PATCH 2/2] selinux: fix ENOMEM errors during policy reload Ondrej Mosnacek
2018-10-31 15:24   ` Ondrej Mosnacek
2018-10-31 15:38     ` Ondrej Mosnacek
2018-10-31 20:31   ` Stephen Smalley
2018-11-01 13:17     ` Stephen Smalley
2018-11-02 16:17       ` Ondrej Mosnacek
2018-11-02 16:02     ` Ondrej Mosnacek

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=20181031122718.18735-1-omosnace@redhat.com \
    --to=omosnace@redhat.com \
    --cc=paul@paul-moore.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    --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.