All of lore.kernel.org
 help / color / mirror / Atom feed
From: penguin-kernel@I-love.SAKURA.ne.jp (Tetsuo Handa)
To: linux-security-module@vger.kernel.org
Subject: [PATCH] security: convert security hooks to use hlist
Date: Mon, 26 Mar 2018 20:07:48 +0900	[thread overview]
Message-ID: <201803262007.BDF21886.OJOFLVMHFQSFOt@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <39e2dfa9-8063-1aa5-cd69-5a57d4b8a231@schaufler-ca.com>

Casey Schaufler wrote:
> On 3/25/2018 3:08 AM, Sargun Dhillon wrote:
> > This changes security_hook_heads to use hlist_heads instead of
> > the circular doubly-linked list heads. This should cut down
> > the size of the struct by about half.
> 
> My only concern is with the possibility of making
> security modules dynamically loadable and unloadable.
> I know that Tetsuo is still hoping to have that, and
> I have worked to make sure that we don't do anything
> to preclude it. If he has no objection, I don't either.
> 

Changing from "struct list_head" to "struct hlist_head" does not affect LKM-based LSMs.
If Sargun makes that change, please fold below changes because

  for (i = 0; i < sizeof(security_hook_heads) / sizeof(struct hlist_head); i++) INIT_HLIST_HEAD(&list[i]);

is equivalent to

  memset(&security_hook_heads, 0, sizeof(security_hook_heads));

which is not required because security_hook_heads is automatically initialized with 0,
and we can also revert commit fd466e068e5adef5 ("randstruct: Whitelist struct
security_hook_heads cast").
---
 scripts/gcc-plugins/randomize_layout_plugin.c | 2 --
 security/security.c                           | 6 ------
 2 files changed, 8 deletions(-)

diff --git a/scripts/gcc-plugins/randomize_layout_plugin.c b/scripts/gcc-plugins/randomize_layout_plugin.c
index c4a345c..d941389 100644
--- a/scripts/gcc-plugins/randomize_layout_plugin.c
+++ b/scripts/gcc-plugins/randomize_layout_plugin.c
@@ -52,8 +52,6 @@ struct whitelist_entry {
 	{ "net/unix/af_unix.c", "unix_skb_parms", "char" },
 	/* big_key payload.data struct splashing */
 	{ "security/keys/big_key.c", "path", "void *" },
-	/* walk struct security_hook_heads as an array of struct list_head */
-	{ "security/security.c", "list_head", "security_hook_heads" },
 	{ }
 };
 
diff --git a/security/security.c b/security/security.c
index 3cafff6..90d53c5 100644
--- a/security/security.c
+++ b/security/security.c
@@ -60,12 +60,6 @@ static void __init do_security_initcalls(void)
  */
 int __init security_init(void)
 {
-	int i;
-	struct hlist_head *list = (struct hlist_head *) &security_hook_heads;
-
-	for (i = 0; i < sizeof(security_hook_heads) / sizeof(struct hlist_head);
-	     i++)
-		INIT_HLIST_HEAD(&list[i]);
 	pr_info("Security Framework initialized\n");
 
 	/*
-- 
1.8.3.1

> >
> > Signed-off-by: Sargun Dhillon <sargun@sargun.me>
> > ---
> >  include/linux/lsm_hooks.h | 428 +++++++++++++++++++++++-----------------------
> >  security/security.c       |  22 +--
> >  2 files changed, 225 insertions(+), 225 deletions(-)
> 
> 
> 
--
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

  parent reply	other threads:[~2018-03-26 11:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-25 10:08 [PATCH] security: convert security hooks to use hlist Sargun Dhillon
2018-03-25 17:12 ` Casey Schaufler
     [not found]   ` <CAMp4zn8vB8zzh9cc7h2-=t6OyCzOfgGOrQz4y+FuC0Mmnp7ksw@mail.gmail.com>
2018-03-26  9:18     ` Igor Stoppa
2018-03-26 11:07   ` Tetsuo Handa [this message]
2018-03-26 19:33     ` Sargun Dhillon
2018-03-25 21:25 ` James Morris
2018-03-26 19:31   ` Sargun Dhillon

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=201803262007.BDF21886.OJOFLVMHFQSFOt@I-love.SAKURA.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --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.