linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
To: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: Dmitry Kasatkin <d.kasatkin@samsung.com>,
	David Howells <dhowells@redhat.com>,
	James Morris <jmorris@namei.org>,
	Roberto Sassu <roberto.sassu@polito.it>,
	linux-security-module <linux-security-module@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 17/20] ima: make IMA policy replaceable at runtime
Date: Thu, 15 May 2014 09:08:47 +0300	[thread overview]
Message-ID: <CACE9dm8-VB5PHYY0rm9fQkefxZE2Vs5VdavdR5bF5oCHMtnTYA@mail.gmail.com> (raw)
In-Reply-To: <1400111124.6068.85.camel@dhcp-9-2-203-236.watson.ibm.com>

On 15 May 2014 02:45, Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:
> On Wed, 2014-04-23 at 16:30 +0300, Dmitry Kasatkin wrote:
>> This patch provides functionality to replace the IMA policy at runtime.
>>
>> By default, the IMA policy can be successfully updated only once,
>> but with this patch when the kernel configuration option
>> CONFIG_IMA_POLICY_REPLACEABLE is enabled, the IMA policy can be replaced
>> multiple times at runtime.
>>
>> Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
>
> I have a couple of concerns with replacing the IMA policy.
>
> - Currently opened files might now be in policy, that previously
> weren't.  Do these files need to be measured, appraised, or audited?
> These files could have been modified, but the 'security.ima' xattr
> hasn't been updated yet. In such cases, appraisal would fail.
>

Hi,

Yep. It is a "bit" larger problem.
But it will fail as well when using "chown" to change uid from user to
root, for example.

> - At minimum, after replacing the policy, the iint cache entry flags
> need to be reset.
>
> Please provide the motivation for such a use case scenario.
>
> Mimi
>

As I think I once mentioned, this patch should not be sent in that patchset.
We have some experimental stuff for controlling IMA at runtime.
That is not completed. There is no reason to discuss here a lot.


- Dmitry


>> ---
>>  security/integrity/ima/Kconfig      |  8 ++++++++
>>  security/integrity/ima/ima_fs.c     |  2 ++
>>  security/integrity/ima/ima_policy.c | 23 +++++++++++++++++++----
>>  3 files changed, 29 insertions(+), 4 deletions(-)
>>
>> diff --git a/security/integrity/ima/Kconfig b/security/integrity/ima/Kconfig
>> index b00044f..b60a315 100644
>> --- a/security/integrity/ima/Kconfig
>> +++ b/security/integrity/ima/Kconfig
>> @@ -160,3 +160,11 @@ config IMA_KERNEL_POLICY
>>       default n
>>       help
>>         This option enables IMA policy loading from the kernel.
>> +
>> +config IMA_POLICY_REPLACEABLE
>> +     bool "Allows to replace policy at runtime"
>> +     depends on IMA_POLICY_LOADER
>> +     default n
>> +     help
>> +       Enabling this option allows to replace policy at runtime.
>> +       Only signed policy is allowed.
>> diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
>> index d050a5c..b4144b4 100644
>> --- a/security/integrity/ima/ima_fs.c
>> +++ b/security/integrity/ima/ima_fs.c
>> @@ -304,11 +304,13 @@ static int ima_open_policy(struct inode *inode, struct file *filp)
>>               return -EACCES;
>>       if (test_and_set_bit(IMA_FS_BUSY, &ima_fs_flags))
>>               return -EBUSY;
>> +#ifndef CONFIG_IMA_POLICY_REPLACEABLE
>>       if (!ima_default_policy()) {
>>               /* policy was already set*/
>>               clear_bit(IMA_FS_BUSY, &ima_fs_flags);
>>               return -EACCES;
>>       }
>> +#endif
>>       return 0;
>>  }
>>
>> diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
>> index c6da801..981e953 100644
>> --- a/security/integrity/ima/ima_policy.c
>> +++ b/security/integrity/ima/ima_policy.c
>> @@ -108,11 +108,14 @@ static struct ima_rule_entry default_appraise_rules[] = {
>>
>>  static LIST_HEAD(ima_default_rules);
>>  static LIST_HEAD(ima_policy_rules);
>> +static LIST_HEAD(ima_active_rules);
>>  static struct list_head *ima_rules;
>>  static bool path_rules;
>>
>>  static DEFINE_MUTEX(ima_rules_mutex);
>>
>> +static void ima_do_delete_rules(struct list_head *rules);
>> +
>>  static bool ima_use_tcb __initdata;
>>  static int __init default_measure_policy_setup(char *str)
>>  {
>> @@ -367,7 +370,14 @@ void ima_update_policy(void)
>>       int result = 0;
>>       int audit_info = 0;
>>
>> -     ima_rules = &ima_policy_rules;
>> +     if (ima_default_policy()) {
>> +             /* set new policy head */
>> +             ima_rules = &ima_active_rules;
>> +     } else {
>> +             /* FIXME: must be protected by lock */
>> +             ima_do_delete_rules(ima_rules);
>> +     }
>> +     list_replace_init(&ima_policy_rules, ima_rules);
>>
>>       integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
>>                           NULL, op, cause, result, audit_info);
>> @@ -734,14 +744,14 @@ ssize_t ima_parse_add_rule(char *rule)
>>       return len;
>>  }
>>
>> -/* ima_delete_rules called to cleanup invalid policy */
>> -void ima_delete_rules(void)
>> +/* ima_delete_rules called to cleanup invalid or old policy */
>> +static void ima_do_delete_rules(struct list_head *rules)
>>  {
>>       struct ima_rule_entry *entry, *tmp;
>>       int i;
>>
>>       mutex_lock(&ima_rules_mutex);
>> -     list_for_each_entry_safe(entry, tmp, &ima_policy_rules, list) {
>> +     list_for_each_entry_safe(entry, tmp, rules, list) {
>>               for (i = 0; i < MAX_LSM_RULES; i++)
>>                       kfree(entry->lsm[i].args_p);
>>
>> @@ -751,6 +761,11 @@ void ima_delete_rules(void)
>>       mutex_unlock(&ima_rules_mutex);
>>  }
>>
>> +void ima_delete_rules(void)
>> +{
>> +     ima_do_delete_rules(&ima_policy_rules);
>> +}
>> +
>>  #ifdef CONFIG_IMA_POLICY_LOADER
>>
>>  ssize_t ima_read_policy(char *path)
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Thanks,
Dmitry

  reply	other threads:[~2014-05-15  6:08 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-23 13:30 [PATCH 00/20] in-kernel IMA/EVM initialization Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 01/20] KEYS: verify a certificate is signed by a 'trusted' key Dmitry Kasatkin
2014-04-24 16:53   ` Mimi Zohar
2014-04-24 20:07     ` Dmitry Kasatkin
2014-04-24 21:03       ` Mimi Zohar
2014-04-23 13:30 ` [PATCH 02/20] integrity: initialize EVM before IMA Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 03/20] ima: move asymmetric keys config option Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 04/20] integrity: move integrity subsystem options to a separate menu Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 05/20] integrity: provide builtin 'trusted' keyrings Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 06/20] ima: create '_ima' as a builtin 'trusted' keyring Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 07/20] integrity: provide x509 certificate loading from the kernel Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 08/20] ima: load x509 certificate " Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 09/20] evm: create '_evm' as a builtin 'trusted' keyring Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 10/20] evm: load x509 certificate from the kernel Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 11/20] ima: added kernel parameter for disabling IMA Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 12/20] ima: provide buffer hash calculation function Dmitry Kasatkin
2014-04-24 21:04   ` Mimi Zohar
2014-04-25 14:52     ` Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 13/20] ima: replace opencount with bitop Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 14/20] ima: check if policy was set at open Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 15/20] ima: path based policy loading interface Dmitry Kasatkin
2014-04-24 21:03   ` Mimi Zohar
2014-04-25 15:18     ` Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 16/20] ima: load policy from the kernel Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 17/20] ima: make IMA policy replaceable at runtime Dmitry Kasatkin
2014-05-14 23:45   ` Mimi Zohar
2014-05-15  6:08     ` Dmitry Kasatkin [this message]
2014-04-23 13:30 ` [PATCH 18/20] evm: added kernel parameter for disabling EVM Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 19/20] evm: try enable EVM from the kernel Dmitry Kasatkin
2014-04-23 13:30 ` [PATCH 20/20] evm: read EVM key " Dmitry Kasatkin
2014-04-24 18:44 ` [PATCH 00/20] in-kernel IMA/EVM initialization Mimi Zohar

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=CACE9dm8-VB5PHYY0rm9fQkefxZE2Vs5VdavdR5bF5oCHMtnTYA@mail.gmail.com \
    --to=dmitry.kasatkin@gmail.com \
    --cc=d.kasatkin@samsung.com \
    --cc=dhowells@redhat.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=roberto.sassu@polito.it \
    --cc=zohar@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).