All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <stephen.smalley.work@gmail.com>
To: Paul Moore <paul@paul-moore.com>
Cc: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>,
	Sasha Levin <sashal@kernel.org>, James Morris <jmorris@namei.org>,
	SElinux list <selinux@vger.kernel.org>
Subject: Re: [PATCH v2] selinux: Add helper functions to get and set checkreqprot
Date: Fri, 11 Sep 2020 10:22:33 -0400	[thread overview]
Message-ID: <CAEjxPJ7Q+7mBh1hjY7sZiEAjX7Z8afrpzMP6UTwDrO3=pKVoRQ@mail.gmail.com> (raw)
In-Reply-To: <CAHC9VhSZiuHHg+oJPcaRLoZaDhARgiJ2PN5LiMHcVk1yB0a+ng@mail.gmail.com>

On Fri, Sep 11, 2020 at 10:07 AM Paul Moore <paul@paul-moore.com> wrote:
>
> On Wed, Sep 9, 2020 at 6:28 PM Lakshmi Ramasubramanian
> <nramas@linux.microsoft.com> wrote:
> >
> > checkreqprot data member in selinux_state struct is accessed directly by
> > SELinux functions to get and set. This could cause unexpected read or
> > write access to this data member due to compiler optimizations and/or
> > compiler's reordering of access to this field.
> >
> > Add helper functions to get and set checkreqprot data member in
> > selinux_state struct. These helper functions use READ_ONCE and
> > WRITE_ONCE macros to ensure atomic read or write of memory for
> > this data member.
> >
> > Signed-off-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>
> > Suggested-by: Stephen Smalley <stephen.smalley.work@gmail.com>
> > ---
> >  security/selinux/hooks.c            |  6 +++---
> >  security/selinux/include/security.h | 10 ++++++++++
> >  security/selinux/selinuxfs.c        |  5 +++--
> >  3 files changed, 16 insertions(+), 5 deletions(-)
>
> ...
>
> > diff --git a/security/selinux/include/security.h b/security/selinux/include/security.h
> > index cbdd3c7aff8b..cc29177c8858 100644
> > --- a/security/selinux/include/security.h
> > +++ b/security/selinux/include/security.h
> > @@ -143,6 +143,16 @@ static inline void enforcing_set(struct selinux_state *state, bool value)
> >  }
> >  #endif
> >
> > +static inline bool checkreqprot_enabled(const struct selinux_state *state)
> > +{
> > +       return READ_ONCE(state->checkreqprot);
> > +}
> > +
> > +static inline void checkreqprot_set(struct selinux_state *state, bool value)
> > +{
> > +       WRITE_ONCE(state->checkreqprot, value);
> > +}
>
> This is a nitpick, and I recognize that Stephen already suggested the
> use of "*_set()" and "*_enabled()" for names, but if we are going to
> name the setter "*_set()" let's also name the getter "*_get()".

I just suggested that we be consistent with the existing naming for
enforcing_*(), which I thought came from you?

  parent reply	other threads:[~2020-09-11 15:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-09 22:28 [PATCH v2] selinux: Add helper functions to get and set checkreqprot Lakshmi Ramasubramanian
2020-09-10 12:41 ` Stephen Smalley
2020-09-11 14:07 ` Paul Moore
2020-09-11 14:20   ` Lakshmi Ramasubramanian
2020-09-11 14:42     ` Paul Moore
2020-09-11 14:22   ` Stephen Smalley [this message]
2020-09-11 14:52     ` Paul Moore

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='CAEjxPJ7Q+7mBh1hjY7sZiEAjX7Z8afrpzMP6UTwDrO3=pKVoRQ@mail.gmail.com' \
    --to=stephen.smalley.work@gmail.com \
    --cc=jmorris@namei.org \
    --cc=nramas@linux.microsoft.com \
    --cc=paul@paul-moore.com \
    --cc=sashal@kernel.org \
    --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.