SELinux Archive on lore.kernel.org
 help / color / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: Ondrej Mosnacek <omosnace@redhat.com>
Cc: selinux@vger.kernel.org, Jann Horn <jannh@google.com>,
	NitinGote <nitin.r.gote@intel.com>,
	Kees Cook <keescook@chromium.org>
Subject: Re: [PATCH v2] selinux: avoid atomic_t usage in sidtab
Date: Tue, 27 Aug 2019 13:33:37 -0400
Message-ID: <CAHC9VhRb1==sCoNxKZN09-rhs+yHiDXbd4Lw+fRZGen5d1A2uA@mail.gmail.com> (raw)
In-Reply-To: <20190814133320.28516-1-omosnace@redhat.com>

On Wed, Aug 14, 2019 at 9:33 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
>
> As noted in Documentation/atomic_t.txt, if we don't need the RMW atomic
> operations, we should only use READ_ONCE()/WRITE_ONCE() +
> smp_rmb()/smp_wmb() where necessary (or the combined variants
> smp_load_acquire()/smp_store_release()).
>
> This patch converts the sidtab code to use regular u32 for the counter
> and reverse lookup cache and use the appropriate operations instead of
> atomic_get()/atomic_set(). Note that when reading/updating the reverse
> lookup cache we don't need memory barriers as it doesn't need to be
> consistent or accurate. We can now also replace some atomic ops with
> regular loads (when under spinlock) and stores (for conversion target
> fields that are always accessed under the master table's spinlock).
>
> We can now also bump SIDTAB_MAX to U32_MAX as we can use the full u32
> range again.
>
> Suggested-by: Jann Horn <jannh@google.com>
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> Reviewed-by: Jann Horn <jannh@google.com>
> ---
>
> v2: Added comments detailing access semantics of sidtab fields.
>
>  security/selinux/ss/sidtab.c | 48 ++++++++++++++++--------------------
>  security/selinux/ss/sidtab.h | 19 ++++++++++----
>  2 files changed, 35 insertions(+), 32 deletions(-)

Sorry for the delay on this, it was a casualty of LSS-NA.  Regardless,
this looks better, I just merged it into selinux/next - thanks!

-- 
paul moore
www.paul-moore.com

      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14 13:33 Ondrej Mosnacek
2019-08-27 17:33 ` Paul Moore [this message]

Reply instructions:

You may reply publically 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='CAHC9VhRb1==sCoNxKZN09-rhs+yHiDXbd4Lw+fRZGen5d1A2uA@mail.gmail.com' \
    --to=paul@paul-moore.com \
    --cc=jannh@google.com \
    --cc=keescook@chromium.org \
    --cc=nitin.r.gote@intel.com \
    --cc=omosnace@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

SELinux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/selinux/0 selinux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 selinux selinux/ https://lore.kernel.org/selinux \
		selinux@vger.kernel.org selinux@archiver.kernel.org
	public-inbox-index selinux

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.selinux


AGPL code for this site: git clone https://public-inbox.org/ public-inbox