From: Casey Schaufler <casey@schaufler-ca.com>
To: Djalal Harouni <tixxdz@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andy Lutomirski <luto@kernel.org>,
Kees Cook <keescook@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
kernel-hardening@lists.openwall.com,
LSM List <linux-security-module@vger.kernel.org>,
Linux API <linux-api@vger.kernel.org>,
Dongsu Park <dpark@posteo.net>,
James Morris <james.l.morris@oracle.com>,
"Serge E. Hallyn" <serge@hallyn.com>,
Paul Moore <paul@paul-moore.com>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH RFC v2 2/3] security: add the ModAutoRestrict Linux Security Module
Date: Mon, 10 Apr 2017 12:04:25 -0700 [thread overview]
Message-ID: <36b005c9-e550-2ee8-61b2-136628f1a05f@schaufler-ca.com> (raw)
In-Reply-To: <CAEiveUeYB8jQoP9R9xSj+5dxc3cfCg46Z=C5TkfkYibDWrEbPQ@mail.gmail.com>
On 4/10/2017 11:27 AM, Djalal Harouni wrote:
> On Mon, Apr 10, 2017 at 5:42 PM, Casey Schaufler <casey@schaufler-ca.com> wrote:
>> On 4/9/2017 3:42 AM, Djalal Harouni wrote:
> [...]
>>> +
>>> +static inline struct modautoload_task *init_modautoload_task(struct task_struct *tsk,
>>> + unsigned long flags)
>>> +{
>>> + struct modautoload_task *modtask;
>>> +
>>> + modtask = task_security(tsk, modautorestrict_task_security_index);
>>> +
>>> + modtask->flags = (u8)flags;
>> I don't think you want to do this cast.
> Will fix it. Thanks!
>
>
> [...]
>>> +
>>> +#ifdef CONFIG_SYSCTL
>>> +static int modautoload_dointvec_minmax(struct ctl_table *table, int write,
>>> + void __user *buffer, size_t *lenp,
>>> + loff_t *ppos)
>>> +{
>>> + struct ctl_table table_copy;
>>> +
>>> + if (write && !capable(CAP_SYS_MODULE))
>>> + return -EPERM;
>>> +
>>> + table_copy = *table;
>>> + if (*(int *)table_copy.data == *(int *)table_copy.extra2)
>> While it's probably doing what you want, I find this
>> sort of casting disturbing.
> Ok will try to improve it.
>
>
>>> + table_copy.extra1 = table_copy.extra2;
>>> +
>>> + return proc_dointvec_minmax(&table_copy, write, buffer, lenp, ppos);
>>> +}
>>> +
>>> +struct ctl_path modautoload_sysctl_path[] = {
>>> + { .procname = "kernel", },
>>> + { .procname = "modautorestrict", },
>>> + { }
>>> +};
>>> +
>>> +static struct ctl_table modautoload_sysctl_table[] = {
>>> + {
>>> + .procname = "autoload",
>>> + .data = &autoload_restrict,
>>> + .maxlen = sizeof(int),
>>> + .mode = 0644,
>>> + .proc_handler = modautoload_dointvec_minmax,
>>> + .extra1 = &zero,
>>> + .extra2 = &max_autoload_restrict,
>>> + },
>>> + { }
>>> +};
>>> +
>>> +static void __init modautoload_init_sysctl(void)
>>> +{
>>> + if (!register_sysctl_paths(modautoload_sysctl_path, modautoload_sysctl_table))
>>> + panic("modautorestrict: sysctl registration failed.\n");
>>> +}
>>> +#else
>>> +static inline void modautoload_init_sysctl(void) { }
>>> +#endif /* CONFIG_SYSCTL */
>>> +
>>> +void __init modautorestrict_init(void)
>>> +{
>>> + modautorestrict_task_security_index =
>>> + security_reserve_task_blob_index(sizeof(struct modautoload_task));
>>> + security_add_hooks(modautoload_hooks,
>>> + ARRAY_SIZE(modautoload_hooks), "modautorestrict");
>>> +
>>> + modautoload_init_sysctl();
>>> + pr_info("ModAutoRestrict LSM: Initialized\n");
>>> +}
>>> diff --git a/security/security.c b/security/security.c
>>> index 4dc6bca..d8852fe 100644
>>> --- a/security/security.c
>>> +++ b/security/security.c
>>> @@ -70,6 +70,7 @@ int __init security_init(void)
>>> capability_add_hooks();
>>> yama_add_hooks();
>>> loadpin_add_hooks();
>>> + modautorestrict_init();
>> This should be modautorestrict_add_hooks() if this were
>> a "minor" module, but as it's using a blob it is a "major"
>> module. Either way, this is not right.
> Do you mean that if I'm using a blob, it should go with the rest LSMs
> in do_security_initcalls() ?
Right. Today you have coincidental non-interference because
no one else is using the task blob. As you're aware, TOMOYO
is going to start using it, and I believe the AppArmor has
plans for it as well. There are parts of the Smack cred blob
that should probably go in the task blob as they aren't used
in access decisions. I haven't looked closely enough, but that's
possible for SELinux, too. So even though it's a new blob, the
major/minor rules apply.
>
>>> /*
>>> * Load all the remaining security modules.
> Thanks for the comments!
>
>
next prev parent reply other threads:[~2017-04-10 19:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-09 10:42 [PATCH RFC v2 0/3] security: Add ModAutoRestrict LSM Djalal Harouni
2017-04-09 10:42 ` [PATCH RFC v2 1/3] LSM: Allow per LSM module per "struct task_struct" blob Djalal Harouni
2017-04-10 15:50 ` Casey Schaufler
2017-04-10 18:30 ` Djalal Harouni
2017-04-10 19:26 ` Casey Schaufler
2017-04-10 20:00 ` Djalal Harouni
2017-04-11 4:43 ` [kernel-hardening] " Kees Cook
2017-04-11 19:54 ` Casey Schaufler
2017-04-11 19:57 ` Kees Cook
2017-04-12 16:08 ` Djalal Harouni
2017-04-12 16:22 ` Djalal Harouni
2017-04-12 20:41 ` Casey Schaufler
2017-04-09 10:42 ` [PATCH RFC v2 2/3] security: add the ModAutoRestrict Linux Security Module Djalal Harouni
2017-04-10 15:42 ` Casey Schaufler
2017-04-10 18:27 ` Djalal Harouni
2017-04-10 19:04 ` Casey Schaufler [this message]
2017-04-10 19:55 ` Djalal Harouni
2017-04-09 10:42 ` [PATCH RFC v2 3/3] Documentation: add ModAutoRestrict LSM documentation Djalal Harouni
2017-04-11 4:23 ` [PATCH RFC v2 0/3] security: Add ModAutoRestrict LSM Kees Cook
2017-04-12 15:26 ` Djalal Harouni
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=36b005c9-e550-2ee8-61b2-136628f1a05f@schaufler-ca.com \
--to=casey@schaufler-ca.com \
--cc=akpm@linux-foundation.org \
--cc=dpark@posteo.net \
--cc=gregkh@linuxfoundation.org \
--cc=james.l.morris@oracle.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=luto@kernel.org \
--cc=paul@paul-moore.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=serge@hallyn.com \
--cc=tixxdz@gmail.com \
/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
all inboxes | Powered by JetHome®