All of lore.kernel.org
 help / color / mirror / Atom feed
From: sargun@sargun.me (Sargun Dhillon)
To: linux-security-module@vger.kernel.org
Subject: [PATCH v2 0/2] Separate out mutable security hooks, and enable runtime (un)loading
Date: Wed, 28 Mar 2018 01:30:01 +0000	[thread overview]
Message-ID: <cover.1522185596.git.sargun@sargun.me> (raw)


This patchset includes a couple features, as well as security features.

Security Features
The biggest security benefit of this patchset is the introduction of
read-only heads. Currently, if you have any LSMs with mutable hooks
it will render all heads, and list nodes mutable. This is a prime
place to attack, because being able to manipulate those hooks is a
way to bypass all LSMs easily.

By moving to hlist_head, it keeps a singly-linked, non-circular list.
This can always be marked as read only because we add a mutable "null"
hook. All immutable LSMs should be installed as immutable hooks and
sit before the null hook.

+------+   +-----------+   +-----------+   +-----------+   +------------------+
|      |   |           |   |           |   |           |   |                  |
| HEAD +---> Immutable +---> Immutable +---> Null hook +--->   Mutable Hook   |
|      |   |  Hook 1   |   |  Hook 2   |   |           |   |                  |
+------+   +-----------+   +-----------+   +-----------+   +------------------+
                 |               |                                  |
                 v               v                                  v
             Callback        Callback                           Callback

If LSMs have a model to be unloaded, or are compled as modules,
they should mark themselves mutable at runtime.

In order to provide safe code-unloading, there is a shared SRCU between
all security hooks. This SRCU is very cheap for runtime overhead on
reads, but there is synchronization around it for unloads. There is
only a cost to pay at unload time, which is based on the execution time
of longest chain of callbacks after synchronization begins.

Because of all of this, we can now load LSMs at runtime, so those APIs
are exposed. It is up to the module author to check if
CONFIG_SECURITY_WRITABLE_HOOKS is enabled prior to trying to load.


Changes since:
v1:
	* Add SRCU to allow for code-unloading
	* Add concurrency control around hook mutation

Sargun Dhillon (2):
  security: convert security hooks to use hlist
  security: Add mechanism to safely (un)load LSMs after boot time

 include/linux/lsm_hooks.h  | 449 ++++++++++++++++++++++-----------------------
 security/Kconfig           |   2 +-
 security/apparmor/lsm.c    |   2 +-
 security/commoncap.c       |   2 +-
 security/security.c        | 286 ++++++++++++++++++++++++++---
 security/selinux/hooks.c   |   5 +-
 security/smack/smack_lsm.c |   3 +-
 security/tomoyo/tomoyo.c   |   3 +-
 security/yama/yama_lsm.c   |   2 +-
 9 files changed, 494 insertions(+), 260 deletions(-)

-- 
2.14.1

--
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-03-28  1:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28  1:30 Sargun Dhillon [this message]
2018-03-28  1:30 ` [PATCH v2 1/2] security: convert security hooks to use hlist Sargun Dhillon
2018-03-28 16:47   ` Casey Schaufler
     [not found]     ` <CAMp4zn-Pfj3gPH+ZW5EcTLUqHSEbHxQrF_X_FXHgLqwjNZWdPw@mail.gmail.com>
2018-03-28 23:58       ` James Morris
2018-03-28  1:30 ` [PATCH v2 2/2] security: Add mechanism to safely (un)load LSMs after boot time Sargun Dhillon
2018-03-28 10:27   ` Tetsuo Handa
2018-03-28 17:39   ` Casey Schaufler
2018-03-28 23:59     ` James Morris

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=cover.1522185596.git.sargun@sargun.me \
    --to=sargun@sargun.me \
    --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 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.