linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sds@tycho.nsa.gov (Stephen Smalley)
To: linux-security-module@vger.kernel.org
Subject: [PATCH selinux-next] selinux: Annotate lockdep for services locks
Date: Tue, 20 Feb 2018 08:59:02 -0500	[thread overview]
Message-ID: <1519135142.10331.12.camel@tycho.nsa.gov> (raw)
In-Reply-To: <20180219151800.14442-1-peter.enderborg@sony.com>

On Mon, 2018-02-19 at 16:18 +0100, Peter Enderborg wrote:
> From: Peter <peter.enderborg@sony.com>
> 
> The locks are moved to dynamic allocation, we need to
> help the lockdep system to classify the locks.
> This adds to lockdep annotation for the page mutex and
> for the ss lock.
> 
> Signed-off-by: Peter Enderborg <peter.enderborg@sony.com>
> ---
> This is the rebase of suggested patches from selinuxns tree
> and are intended to be applyed on top of:
> selinux: wrap global selinux state
> from Stephen Smalley
> 
>  security/selinux/ss/services.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/security/selinux/ss/services.c
> b/security/selinux/ss/services.c
> index 3698352213d7..a741552e22b5 100644
> --- a/security/selinux/ss/services.c
> +++ b/security/selinux/ss/services.c
> @@ -81,11 +81,15 @@ char
> *selinux_policycap_names[__POLICYDB_CAPABILITY_MAX] = {
>  };
>  
>  static struct selinux_ss selinux_ss;
> +static struct lock_class_key selinux_ss_class_key;
> +static struct lock_class_key selinux_status_class_key;
>  
>  void selinux_ss_init(struct selinux_ss **ss)
>  {
>  	rwlock_init(&selinux_ss.policy_rwlock);
> +	lockdep_set_class(&selinux_ss.policy_rwlock,
> &selinux_ss_class_key);
>  	mutex_init(&selinux_ss.status_lock);
> +	lockdep_set_class(&selinux_ss.status_lock,
> &selinux_status_class_key);
>  	*ss = &selinux_ss;
>  }

Pardon my ignorance, but can you explain why we need an explicit call
to lockdep_set_class() here?  I see it used for e.g. the inode i_lock,
but there the class is per-file_system_type.  It doesn't seem to be
always be used for all locks when they are dynamically initialized or
allocated, e.g. get_empty_filp does not call lockdep_set_class() for
struct file's f_owner.lock or f_lock even though they are dynamically
allocated and initialized.  What makes this case different?

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2018-02-20 13:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-19 15:18 [PATCH selinux-next] selinux: Annotate lockdep for services locks Peter Enderborg
2018-02-20 13:59 ` Stephen Smalley [this message]
2018-02-20 15:58   ` Stephen Smalley
2018-02-21  9:31     ` peter enderborg

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=1519135142.10331.12.camel@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=linux-security-module@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 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).