linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <kees@outflux.net>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: keescook@chromium.org, jmorris@namei.org,
	linux-kernel@vger.kernel.org, james.l.morris@oracle.com,
	casey@schaufler-ca.com, linux-security-module@vger.kernel.org,
	rusty@rustcorp.com.au
Subject: Re: [PATCH] LSM: ModPin LSM for module loading restrictions
Date: Thu, 3 Oct 2013 14:36:25 -0700	[thread overview]
Message-ID: <20131003213625.GH5729@outflux.net> (raw)
In-Reply-To: <201310040631.IIF39022.OVFOFQOtJSFHLM@I-love.SAKURA.ne.jp>

On Fri, Oct 04, 2013 at 06:31:42AM +0900, Tetsuo Handa wrote:
> Kees Cook wrote:
> > +static int modpin_load_module(struct file *file)
> > +{
> > +   struct dentry *module_root;
> > +
> > +   if (!file) {
> > +           if (!modpin_enforced) {
> > +                   report_load_module(NULL, "old-api-pinning-ignored");
> > +                   return 0;
> > +           }
> > +
> > +           report_load_module(NULL, "old-api-denied");
> > +           return -EPERM;
> > +   }
> > +
> > +   module_root = file->f_path.mnt->mnt_root;
> > +
> > +   /* First loaded module defines the root for all others. */
> > +   spin_lock(&pinned_root_spinlock);
> > +   if (!pinned_root) {
> > +           pinned_root = dget(module_root);
> > +           /*
> > +            * Unlock now since it's only pinned_root we care about.
> > +            * In the worst case, we will (correctly) report pinning
> > +            * failures before we have announced that pinning is
> > +            * enabled. This would be purely cosmetic.
> > +            */
> > +           spin_unlock(&pinned_root_spinlock);
> > +           check_pinning_enforcement();
> > +           report_load_module(&file->f_path, "pinned");
> > +           return 0;
> > +   }
> > +   spin_unlock(&pinned_root_spinlock);
> 
> Firstly loaded module is usually in initramfs whereas subsequently loaded
> modules are usually on a hard disk partition.
> 
> This module is not meant for PC servers, is it?

This LSM is what Chrome OS uses for the module pinning logic. We do not use
an initramfs. This LSM could also be used for devices booting entirely from
CDROM or other R/O media.

I'm open to improvements, obviously. I imagine things like delayed
activation, where the initramfs triggers pinning in some way once it is
done loading modules from its filesystem, etc. But since I don't have any
real life examples of this, I'm writing the LSM as it currently is, used
without an initramfs. :)

-Kees

-- 
Kees Cook                                            @outflux.net

  reply	other threads:[~2013-10-03 21:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-20 20:35 [PATCH] LSM: ModPin LSM for module loading restrictions Kees Cook
2013-09-24  1:24 ` James Morris
2013-09-24  1:28   ` James Morris
2013-09-24  1:45     ` Kees Cook
2013-10-03 20:55       ` Kees Cook
2013-10-03 21:31         ` Tetsuo Handa
2013-10-03 21:36           ` Kees Cook [this message]
2013-10-23  2:55             ` Lucas De Marchi
2013-10-16 15:18       ` Kees Cook
2013-10-16 20:47         ` Tetsuo Handa
2013-10-16 21:42           ` Casey Schaufler
2013-10-16 22:43             ` Kees Cook
2013-10-17  0:37               ` Tetsuo Handa
2013-10-26 13:51                 ` Tetsuo Handa
2013-11-02 19:39                   ` Casey Schaufler
2013-10-18  2:25               ` Casey Schaufler
2013-10-17  8:02 ` James Morris
2013-10-17 11:30   ` Jarkko Sakkinen
2013-10-17 21:00     ` Kees Cook
2013-10-17 17:26   ` Casey Schaufler
2013-10-17 21:09     ` Kees Cook
2013-10-23  0:02     ` James Morris
2013-10-23  1:03       ` Casey Schaufler

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=20131003213625.GH5729@outflux.net \
    --to=kees@outflux.net \
    --cc=casey@schaufler-ca.com \
    --cc=james.l.morris@oracle.com \
    --cc=jmorris@namei.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=rusty@rustcorp.com.au \
    /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).