Patch "ima: extend "mask" policy matching support" has been added to the 4.1-stable tree
Subsystems (4)
This is a note to let you know that I've just added the patch titled
ima: extend "mask" policy matching support
to the 4.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
ima-extend-mask-policy-matching-support.patch
and it can be found in the queue-4.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
4351c294b8c1028077280f761e158d167b592974Mon Sep 17 00:00:00 2001
From: Mimi Zohar <[email protected]>
Date: Wed, 5 Nov 2014 07:53:55 -0500
Subject: ima: extend "mask" policy matching support
From: Mimi Zohar <[email protected]>
commit 4351c294b8c1028077280f761e158d167b592974 upstream.
The current "mask" policy option matches files opened as MAY_READ, MAY_WRITE, MAY_APPEND or MAY_EXEC. This patch extends the "mask" option to match files opened containing one of these modes. For example, "mask=^MAY_READ" would match files opened read-write.
--- Documentation/ABI/testing/ima_policy | 3 ++- security/integrity/ima/ima_policy.c | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-)
Documentation/ABI/testing/ima_policy +2 -1
@@ -27,7 +27,8 @@ Description: base: func:= [BPRM_CHECK][MMAP_CHECK][FILE_CHECK][MODULE_CHECK] [FIRMWARE_CHECK] - mask:= [MAY_READ] [MAY_WRITE] [MAY_APPEND] [MAY_EXEC] + mask:= [[^]MAY_READ] [[^]MAY_WRITE] [[^]MAY_APPEND] + [[^]MAY_EXEC] fsmagic:= hex value fsuuid:= file system UUID (e.g 8bcbe394-4f13-4144-be8e-5aa9ea2ce2f6) uid:= decimal value
security/integrity/ima/ima_policy.c +15 -5
@@ -27,6 +27,7 @@#define IMA_UID 0x0008#define IMA_FOWNER 0x0010#define IMA_FSUUID 0x0020 +#define IMA_INMASK 0x0040#define IMA_EUID 0x0080#define UNKNOWN 0
@@ -187,6 +188,9 @@ static bool ima_match_rules(struct ima_rif ((rule->flags &IMA_MASK ) && (rule->mask != mask && func !=POST_SETATTR ))return false; +if ((rule->flags &IMA_INMASK ) && + (!(rule->mask & mask) && func !=POST_SETATTR )) +return false;if ((rule->flags &IMA_FSMAGIC ) && rule->fsmagic != inode->i_sb->s_magic)return false;
@@ -448,6 +452,7 @@ static void ima_log_string(struct audit_static int ima_parse_rule (char *rule,struct ima_rule_entry *entry) {struct audit_buffer *ab; +char *from;char *p;int result =0 ;
@@ -538,18 +543,23 @@ static int ima_parse_rule(char *rule, stif (entry->mask) result = -EINVAL ; -if ((strcmp (args[0 ].from,"MAY_EXEC" )) ==0 ) + from = args[0 ].from; +if (*from =='^' ) + from++; + +if ((strcmp (from,"MAY_EXEC" )) ==0 ) entry->mask =MAY_EXEC ; -else if (strcmp (args[0 ].from,"MAY_WRITE" ) ==0 ) +else if (strcmp (from,"MAY_WRITE" ) ==0 ) entry->mask =MAY_WRITE ; -else if (strcmp (args[0 ].from,"MAY_READ" ) ==0 ) +else if (strcmp (from,"MAY_READ" ) ==0 ) entry->mask =MAY_READ ; -else if (strcmp (args[0 ].from,"MAY_APPEND" ) ==0 ) +else if (strcmp (from,"MAY_APPEND" ) ==0 ) entry->mask =MAY_APPEND ;else result = -EINVAL ;if (!result) - entry->flags |=IMA_MASK ; + entry->flags |= (*args[0 ].from =='^' ) + ?IMA_INMASK :IMA_MASK ;break ;case Opt_fsmagic:ima_log_string (ab,"fsmagic" , args[0 ].from);
Patches currently in stable-queue which might be from [email protected] are
queue-4.1/keys-fix-ca_keys-partial-key-matching.patch queue-4.1/ima-update-builtin-policies.patch queue-4.1/ima-extend-mask-policy-matching-support.patch queue-4.1/ima-cleanup-ima_init_policy-a-little.patch queue-4.1/evm-labeling-pseudo-filesystems-exception.patch queue-4.1/ima-fix-ima_show_template_data_ascii.patch queue-4.1/ima-add-support-for-new-euid-policy-condition.patch queue-4.1/ima-do-not-measure-or-appraise-the-nsfs-filesystem.patch queue-4.1/ima-skip-measurement-of-cgroupfs-files-and-update-documentation.patch