LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v3 0/4] IMA: work on audit records produced by IMA
@ 2018-06-04 20:54 Stefan Berger
  2018-06-04 20:54 ` [PATCH v3 1/4] ima: Call audit_log_string() rather than logging it untrusted Stefan Berger
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Stefan Berger @ 2018-06-04 20:54 UTC (permalink / raw)
  To: zohar, paul, linux-integrity, linux-audit
  Cc: sgrubb, linux-kernel, Stefan Berger

This series of patches cleans up some usages of the audit
subsystem's API by IMA. We also introduce a new record type
that IMA creates while parsing policy rules.

   Stefan

v2->v3:
 - reworked patch 4; pass current->audit_context rather than NULL

v1->v2:
 - dropped several patches that extended existing messages with missing
   fields
 - Using audit_log_task_info() for new record type in last patch
 - rebased on security-next; new message type is now 1807

Stefan Berger (4):
  ima: Call audit_log_string() rather than logging it untrusted
  ima: Use audit_log_format() rather than audit_log_string()
  ima: Do not audit if CONFIG_INTEGRITY_AUDIT is not set
  ima: Differentiate auditing policy rules from "audit" actions

 include/uapi/linux/audit.h           |  1 +
 security/integrity/ima/Kconfig       |  1 +
 security/integrity/ima/ima_policy.c  |  9 ++++++---
 security/integrity/integrity.h       | 15 +++++++++++++++
 security/integrity/integrity_audit.c |  6 +-----
 5 files changed, 24 insertions(+), 8 deletions(-)

-- 
2.13.6

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 1/4] ima: Call audit_log_string() rather than logging it untrusted
  2018-06-04 20:54 [PATCH v3 0/4] IMA: work on audit records produced by IMA Stefan Berger
@ 2018-06-04 20:54 ` Stefan Berger
  2018-06-04 20:54 ` [PATCH v3 2/4] ima: Use audit_log_format() rather than audit_log_string() Stefan Berger
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Stefan Berger @ 2018-06-04 20:54 UTC (permalink / raw)
  To: zohar, paul, linux-integrity, linux-audit
  Cc: sgrubb, linux-kernel, Stefan Berger

The parameters passed to this logging function are all provided by
a privileged user and therefore we can call audit_log_string()
rather than audit_log_untrustedstring().

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Suggested-by: Steve Grubb <sgrubb@redhat.com>
Acked-by: Paul Moore <paul@paul-moore.com>
---
 security/integrity/ima/ima_policy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index 8bbc18eb07eb..1d00db19d167 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -634,7 +634,7 @@ static void ima_log_string_op(struct audit_buffer *ab, char *key, char *value,
 		audit_log_format(ab, "%s<", key);
 	else
 		audit_log_format(ab, "%s=", key);
-	audit_log_untrustedstring(ab, value);
+	audit_log_string(ab, value);
 	audit_log_format(ab, " ");
 }
 static void ima_log_string(struct audit_buffer *ab, char *key, char *value)
-- 
2.13.6

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 2/4] ima: Use audit_log_format() rather than audit_log_string()
  2018-06-04 20:54 [PATCH v3 0/4] IMA: work on audit records produced by IMA Stefan Berger
  2018-06-04 20:54 ` [PATCH v3 1/4] ima: Call audit_log_string() rather than logging it untrusted Stefan Berger
@ 2018-06-04 20:54 ` Stefan Berger
  2018-06-04 20:54 ` [PATCH v3 3/4] ima: Do not audit if CONFIG_INTEGRITY_AUDIT is not set Stefan Berger
  2018-06-04 20:54 ` [PATCH v3 4/4] ima: Differentiate auditing policy rules from "audit" actions Stefan Berger
  3 siblings, 0 replies; 10+ messages in thread
From: Stefan Berger @ 2018-06-04 20:54 UTC (permalink / raw)
  To: zohar, paul, linux-integrity, linux-audit
  Cc: sgrubb, linux-kernel, Stefan Berger

Remove the usage of audit_log_string() and replace it with
audit_log_format().

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Suggested-by: Steve Grubb <sgrubb@redhat.com>
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Acked-by: Paul Moore <paul@paul-moore.com>
---
 security/integrity/ima/ima_policy.c  | 3 +--
 security/integrity/integrity_audit.c | 6 +-----
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index 1d00db19d167..3fcf0935468c 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -634,8 +634,7 @@ static void ima_log_string_op(struct audit_buffer *ab, char *key, char *value,
 		audit_log_format(ab, "%s<", key);
 	else
 		audit_log_format(ab, "%s=", key);
-	audit_log_string(ab, value);
-	audit_log_format(ab, " ");
+	audit_log_format(ab, "%s ", value);
 }
 static void ima_log_string(struct audit_buffer *ab, char *key, char *value)
 {
diff --git a/security/integrity/integrity_audit.c b/security/integrity/integrity_audit.c
index 90987d15b6fe..db30763d5525 100644
--- a/security/integrity/integrity_audit.c
+++ b/security/integrity/integrity_audit.c
@@ -45,11 +45,7 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode,
 			 from_kuid(&init_user_ns, audit_get_loginuid(current)),
 			 audit_get_sessionid(current));
 	audit_log_task_context(ab);
-	audit_log_format(ab, " op=");
-	audit_log_string(ab, op);
-	audit_log_format(ab, " cause=");
-	audit_log_string(ab, cause);
-	audit_log_format(ab, " comm=");
+	audit_log_format(ab, " op=%s cause=%s comm=", op, cause);
 	audit_log_untrustedstring(ab, get_task_comm(name, current));
 	if (fname) {
 		audit_log_format(ab, " name=");
-- 
2.13.6

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 3/4] ima: Do not audit if CONFIG_INTEGRITY_AUDIT is not set
  2018-06-04 20:54 [PATCH v3 0/4] IMA: work on audit records produced by IMA Stefan Berger
  2018-06-04 20:54 ` [PATCH v3 1/4] ima: Call audit_log_string() rather than logging it untrusted Stefan Berger
  2018-06-04 20:54 ` [PATCH v3 2/4] ima: Use audit_log_format() rather than audit_log_string() Stefan Berger
@ 2018-06-04 20:54 ` Stefan Berger
  2018-06-05  0:16   ` Paul Moore
  2018-06-04 20:54 ` [PATCH v3 4/4] ima: Differentiate auditing policy rules from "audit" actions Stefan Berger
  3 siblings, 1 reply; 10+ messages in thread
From: Stefan Berger @ 2018-06-04 20:54 UTC (permalink / raw)
  To: zohar, paul, linux-integrity, linux-audit
  Cc: sgrubb, linux-kernel, Stefan Berger

If Integrity is not auditing, IMA shouldn't audit, either.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
 security/integrity/ima/Kconfig      |  1 +
 security/integrity/ima/ima_policy.c |  6 +++++-
 security/integrity/integrity.h      | 15 +++++++++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/security/integrity/ima/Kconfig b/security/integrity/ima/Kconfig
index 6a8f67714c83..94c2151331aa 100644
--- a/security/integrity/ima/Kconfig
+++ b/security/integrity/ima/Kconfig
@@ -12,6 +12,7 @@ config IMA
 	select TCG_TIS if TCG_TPM && X86
 	select TCG_CRB if TCG_TPM && ACPI
 	select TCG_IBMVTPM if TCG_TPM && PPC_PSERIES
+	select INTEGRITY_AUDIT if AUDIT
 	help
 	  The Trusted Computing Group(TCG) runtime Integrity
 	  Measurement Architecture(IMA) maintains a list of hash
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index 3fcf0935468c..bc99713dfe57 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -628,6 +628,9 @@ static int ima_lsm_rule_init(struct ima_rule_entry *entry,
 static void ima_log_string_op(struct audit_buffer *ab, char *key, char *value,
 			      bool (*rule_operator)(kuid_t, kuid_t))
 {
+	if (!ab)
+		return;
+
 	if (rule_operator == &uid_gt)
 		audit_log_format(ab, "%s>", key);
 	else if (rule_operator == &uid_lt)
@@ -649,7 +652,8 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
 	bool uid_token;
 	int result = 0;
 
-	ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_INTEGRITY_RULE);
+	ab = integrity_audit_log_start(NULL, GFP_KERNEL,
+				       AUDIT_INTEGRITY_RULE);
 
 	entry->uid = INVALID_UID;
 	entry->fowner = INVALID_UID;
diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h
index 0bb372eed62a..e60473b13a8d 100644
--- a/security/integrity/integrity.h
+++ b/security/integrity/integrity.h
@@ -15,6 +15,7 @@
 #include <linux/integrity.h>
 #include <crypto/sha.h>
 #include <linux/key.h>
+#include <linux/audit.h>
 
 /* iint action cache flags */
 #define IMA_MEASURE		0x00000001
@@ -199,6 +200,13 @@ static inline void evm_load_x509(void)
 void integrity_audit_msg(int audit_msgno, struct inode *inode,
 			 const unsigned char *fname, const char *op,
 			 const char *cause, int result, int info);
+
+static inline struct audit_buffer *
+integrity_audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type)
+{
+	return audit_log_start(ctx, gfp_mask, type);
+}
+
 #else
 static inline void integrity_audit_msg(int audit_msgno, struct inode *inode,
 				       const unsigned char *fname,
@@ -206,4 +214,11 @@ static inline void integrity_audit_msg(int audit_msgno, struct inode *inode,
 				       int result, int info)
 {
 }
+
+static inline struct audit_buffer *
+integrity_audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type)
+{
+	return NULL;
+}
+
 #endif
-- 
2.13.6

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 4/4] ima: Differentiate auditing policy rules from "audit" actions
  2018-06-04 20:54 [PATCH v3 0/4] IMA: work on audit records produced by IMA Stefan Berger
                   ` (2 preceding siblings ...)
  2018-06-04 20:54 ` [PATCH v3 3/4] ima: Do not audit if CONFIG_INTEGRITY_AUDIT is not set Stefan Berger
@ 2018-06-04 20:54 ` Stefan Berger
  2018-06-05  0:21   ` Paul Moore
  3 siblings, 1 reply; 10+ messages in thread
From: Stefan Berger @ 2018-06-04 20:54 UTC (permalink / raw)
  To: zohar, paul, linux-integrity, linux-audit
  Cc: sgrubb, linux-kernel, Stefan Berger

The AUDIT_INTEGRITY_RULE is used for auditing IMA policy rules and
the IMA "audit" policy action.  This patch defines
AUDIT_INTEGRITY_POLICY_RULE to reflect the IMA policy rules.

Since we defined a new message type we can now also pass the
audit_context and get an associated SYSCALL record. This now produces
the following records when parsing IMA policy's rules:

type=UNKNOWN[1807] msg=audit(1527888965.738:320): action=audit \
  func=MMAP_CHECK mask=MAY_EXEC res=1
type=UNKNOWN[1807] msg=audit(1527888965.738:320): action=audit \
  func=FILE_CHECK mask=MAY_READ res=1
type=SYSCALL msg=audit(1527888965.738:320): arch=c000003e syscall=1 \
  success=yes exit=17 a0=1 a1=55bcfcca9030 a2=11 a3=7fcc1b55fb38 \
  items=0 ppid=1567 pid=1601 auid=0 uid=0 gid=0 euid=0 suid=0 \
  fsuid=0 egid=0 sgid=0 fsgid=0 tty=tty2 ses=2 comm="echo" \
  exe="/usr/bin/echo" \
  subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
 include/uapi/linux/audit.h          | 1 +
 security/integrity/ima/ima_policy.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 65d9293f1fb8..cb358551376b 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -148,6 +148,7 @@
 #define AUDIT_INTEGRITY_PCR	    1804 /* PCR invalidation msgs */
 #define AUDIT_INTEGRITY_RULE	    1805 /* policy rule */
 #define AUDIT_INTEGRITY_EVM_XATTR   1806 /* New EVM-covered xattr */
+#define AUDIT_INTEGRITY_POLICY_RULE 1807 /* IMA policy rules */
 
 #define AUDIT_KERNEL		2000	/* Asynchronous audit record. NOT A REQUEST. */
 
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index bc99713dfe57..f7230db217a7 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -652,8 +652,8 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
 	bool uid_token;
 	int result = 0;
 
-	ab = integrity_audit_log_start(NULL, GFP_KERNEL,
-				       AUDIT_INTEGRITY_RULE);
+	ab = integrity_audit_log_start(current->audit_context, GFP_KERNEL,
+				       AUDIT_INTEGRITY_POLICY_RULE);
 
 	entry->uid = INVALID_UID;
 	entry->fowner = INVALID_UID;
-- 
2.13.6

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 3/4] ima: Do not audit if CONFIG_INTEGRITY_AUDIT is not set
  2018-06-04 20:54 ` [PATCH v3 3/4] ima: Do not audit if CONFIG_INTEGRITY_AUDIT is not set Stefan Berger
@ 2018-06-05  0:16   ` Paul Moore
  0 siblings, 0 replies; 10+ messages in thread
From: Paul Moore @ 2018-06-05  0:16 UTC (permalink / raw)
  To: Stefan Berger; +Cc: zohar, linux-integrity, linux-audit, sgrubb, linux-kernel

On Mon, Jun 4, 2018 at 4:54 PM, Stefan Berger
<stefanb@linux.vnet.ibm.com> wrote:
> If Integrity is not auditing, IMA shouldn't audit, either.
>
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> ---
>  security/integrity/ima/Kconfig      |  1 +
>  security/integrity/ima/ima_policy.c |  6 +++++-
>  security/integrity/integrity.h      | 15 +++++++++++++++
>  3 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/security/integrity/ima/Kconfig b/security/integrity/ima/Kconfig
> index 6a8f67714c83..94c2151331aa 100644
> --- a/security/integrity/ima/Kconfig
> +++ b/security/integrity/ima/Kconfig
> @@ -12,6 +12,7 @@ config IMA
>         select TCG_TIS if TCG_TPM && X86
>         select TCG_CRB if TCG_TPM && ACPI
>         select TCG_IBMVTPM if TCG_TPM && PPC_PSERIES
> +       select INTEGRITY_AUDIT if AUDIT
>         help
>           The Trusted Computing Group(TCG) runtime Integrity
>           Measurement Architecture(IMA) maintains a list of hash
> diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
> index 3fcf0935468c..bc99713dfe57 100644
> --- a/security/integrity/ima/ima_policy.c
> +++ b/security/integrity/ima/ima_policy.c
> @@ -628,6 +628,9 @@ static int ima_lsm_rule_init(struct ima_rule_entry *entry,
>  static void ima_log_string_op(struct audit_buffer *ab, char *key, char *value,
>                               bool (*rule_operator)(kuid_t, kuid_t))
>  {
> +       if (!ab)
> +               return;
> +
>         if (rule_operator == &uid_gt)
>                 audit_log_format(ab, "%s>", key);
>         else if (rule_operator == &uid_lt)
> @@ -649,7 +652,8 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
>         bool uid_token;
>         int result = 0;
>
> -       ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_INTEGRITY_RULE);
> +       ab = integrity_audit_log_start(NULL, GFP_KERNEL,
> +                                      AUDIT_INTEGRITY_RULE);

There was a lot of confusion here, so this is understandable, but you
should pass "audit_context()"[1] as the first parameter instead of
NULL.  Other than that this patch looks fine.

[1] In Linus' tree at the moment you would need to use
current->audit_context, but the audit PR heading to Linus during this
merge window will introduce the "audit_context()" function which is
preferable as we may need to change things around a bit in the near
future.

>         entry->uid = INVALID_UID;
>         entry->fowner = INVALID_UID;
> diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h
> index 0bb372eed62a..e60473b13a8d 100644
> --- a/security/integrity/integrity.h
> +++ b/security/integrity/integrity.h
> @@ -15,6 +15,7 @@
>  #include <linux/integrity.h>
>  #include <crypto/sha.h>
>  #include <linux/key.h>
> +#include <linux/audit.h>
>
>  /* iint action cache flags */
>  #define IMA_MEASURE            0x00000001
> @@ -199,6 +200,13 @@ static inline void evm_load_x509(void)
>  void integrity_audit_msg(int audit_msgno, struct inode *inode,
>                          const unsigned char *fname, const char *op,
>                          const char *cause, int result, int info);
> +
> +static inline struct audit_buffer *
> +integrity_audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type)
> +{
> +       return audit_log_start(ctx, gfp_mask, type);
> +}
> +
>  #else
>  static inline void integrity_audit_msg(int audit_msgno, struct inode *inode,
>                                        const unsigned char *fname,
> @@ -206,4 +214,11 @@ static inline void integrity_audit_msg(int audit_msgno, struct inode *inode,
>                                        int result, int info)
>  {
>  }
> +
> +static inline struct audit_buffer *
> +integrity_audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type)
> +{
> +       return NULL;
> +}
> +
>  #endif
> --
> 2.13.6

-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 4/4] ima: Differentiate auditing policy rules from "audit" actions
  2018-06-04 20:54 ` [PATCH v3 4/4] ima: Differentiate auditing policy rules from "audit" actions Stefan Berger
@ 2018-06-05  0:21   ` Paul Moore
  2018-06-05 14:15     ` Mimi Zohar
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Moore @ 2018-06-05  0:21 UTC (permalink / raw)
  To: Stefan Berger; +Cc: zohar, linux-integrity, linux-audit, sgrubb, linux-kernel

On Mon, Jun 4, 2018 at 4:54 PM, Stefan Berger
<stefanb@linux.vnet.ibm.com> wrote:
> The AUDIT_INTEGRITY_RULE is used for auditing IMA policy rules and
> the IMA "audit" policy action.  This patch defines
> AUDIT_INTEGRITY_POLICY_RULE to reflect the IMA policy rules.
>
> Since we defined a new message type we can now also pass the
> audit_context and get an associated SYSCALL record. This now produces
> the following records when parsing IMA policy's rules:

Aaand now I see you included the current->audit_context pointer I
mentioned in my comments for 3/4 ;)

So basically this should be fine, although I should point out that you
do not need to define a new message type to associate records
together.  The fact that we don't associate all connected records is
basically a bug.

Anyway, patches 3/4 and 4/4 look good to me.  Considering this is
likely going in during the *next* merge window, I would ask that you
convert from "current->audit_context" to "audit_context()" as soon as
this merge window closes.

Thanks!

> type=UNKNOWN[1807] msg=audit(1527888965.738:320): action=audit \
>   func=MMAP_CHECK mask=MAY_EXEC res=1
> type=UNKNOWN[1807] msg=audit(1527888965.738:320): action=audit \
>   func=FILE_CHECK mask=MAY_READ res=1
> type=SYSCALL msg=audit(1527888965.738:320): arch=c000003e syscall=1 \
>   success=yes exit=17 a0=1 a1=55bcfcca9030 a2=11 a3=7fcc1b55fb38 \
>   items=0 ppid=1567 pid=1601 auid=0 uid=0 gid=0 euid=0 suid=0 \
>   fsuid=0 egid=0 sgid=0 fsgid=0 tty=tty2 ses=2 comm="echo" \
>   exe="/usr/bin/echo" \
>   subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)
>
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> ---
>  include/uapi/linux/audit.h          | 1 +
>  security/integrity/ima/ima_policy.c | 4 ++--
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> index 65d9293f1fb8..cb358551376b 100644
> --- a/include/uapi/linux/audit.h
> +++ b/include/uapi/linux/audit.h
> @@ -148,6 +148,7 @@
>  #define AUDIT_INTEGRITY_PCR        1804 /* PCR invalidation msgs */
>  #define AUDIT_INTEGRITY_RULE       1805 /* policy rule */
>  #define AUDIT_INTEGRITY_EVM_XATTR   1806 /* New EVM-covered xattr */
> +#define AUDIT_INTEGRITY_POLICY_RULE 1807 /* IMA policy rules */
>
>  #define AUDIT_KERNEL           2000    /* Asynchronous audit record. NOT A REQUEST. */
>
> diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
> index bc99713dfe57..f7230db217a7 100644
> --- a/security/integrity/ima/ima_policy.c
> +++ b/security/integrity/ima/ima_policy.c
> @@ -652,8 +652,8 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
>         bool uid_token;
>         int result = 0;
>
> -       ab = integrity_audit_log_start(NULL, GFP_KERNEL,
> -                                      AUDIT_INTEGRITY_RULE);
> +       ab = integrity_audit_log_start(current->audit_context, GFP_KERNEL,
> +                                      AUDIT_INTEGRITY_POLICY_RULE);
>
>         entry->uid = INVALID_UID;
>         entry->fowner = INVALID_UID;
> --
> 2.13.6
>

-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 4/4] ima: Differentiate auditing policy rules from "audit" actions
  2018-06-05  0:21   ` Paul Moore
@ 2018-06-05 14:15     ` Mimi Zohar
  2018-06-05 22:18       ` Paul Moore
  0 siblings, 1 reply; 10+ messages in thread
From: Mimi Zohar @ 2018-06-05 14:15 UTC (permalink / raw)
  To: Paul Moore, Stefan Berger
  Cc: linux-integrity, linux-audit, sgrubb, linux-kernel

Hi Paul,

On Mon, 2018-06-04 at 20:21 -0400, Paul Moore wrote:
> On Mon, Jun 4, 2018 at 4:54 PM, Stefan Berger
> <stefanb@linux.vnet.ibm.com> wrote:
> > The AUDIT_INTEGRITY_RULE is used for auditing IMA policy rules and
> > the IMA "audit" policy action.  This patch defines
> > AUDIT_INTEGRITY_POLICY_RULE to reflect the IMA policy rules.
> >
> > Since we defined a new message type we can now also pass the
> > audit_context and get an associated SYSCALL record. This now produces
> > the following records when parsing IMA policy's rules:
> 
> Aaand now I see you included the current->audit_context pointer I
> mentioned in my comments for 3/4 ;)
> 
> So basically this should be fine, although I should point out that you
> do not need to define a new message type to associate records
> together.  The fact that we don't associate all connected records is
> basically a bug.
> 
> Anyway, patches 3/4 and 4/4 look good to me.  Considering this is
> likely going in during the *next* merge window, I would ask that you
> convert from "current->audit_context" to "audit_context()" as soon as
> this merge window closes.
> 
> Thanks!

Thanks, Paul.  I'd like to start queueing patches for the next open
window now, instead of scrambling later.  Can I add your Ack now, and
remember to make this change when rebasing?

Mimi

> 
> > type=UNKNOWN[1807] msg=audit(1527888965.738:320): action=audit \
> >   func=MMAP_CHECK mask=MAY_EXEC res=1
> > type=UNKNOWN[1807] msg=audit(1527888965.738:320): action=audit \
> >   func=FILE_CHECK mask=MAY_READ res=1
> > type=SYSCALL msg=audit(1527888965.738:320): arch=c000003e syscall=1 \
> >   success=yes exit=17 a0=1 a1=55bcfcca9030 a2=11 a3=7fcc1b55fb38 \
> >   items=0 ppid=1567 pid=1601 auid=0 uid=0 gid=0 euid=0 suid=0 \
> >   fsuid=0 egid=0 sgid=0 fsgid=0 tty=tty2 ses=2 comm="echo" \
> >   exe="/usr/bin/echo" \
> >   subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)
> >
> > Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> > ---
> >  include/uapi/linux/audit.h          | 1 +
> >  security/integrity/ima/ima_policy.c | 4 ++--
> >  2 files changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> > index 65d9293f1fb8..cb358551376b 100644
> > --- a/include/uapi/linux/audit.h
> > +++ b/include/uapi/linux/audit.h
> > @@ -148,6 +148,7 @@
> >  #define AUDIT_INTEGRITY_PCR        1804 /* PCR invalidation msgs */
> >  #define AUDIT_INTEGRITY_RULE       1805 /* policy rule */
> >  #define AUDIT_INTEGRITY_EVM_XATTR   1806 /* New EVM-covered xattr */
> > +#define AUDIT_INTEGRITY_POLICY_RULE 1807 /* IMA policy rules */
> >
> >  #define AUDIT_KERNEL           2000    /* Asynchronous audit record. NOT A REQUEST. */
> >
> > diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
> > index bc99713dfe57..f7230db217a7 100644
> > --- a/security/integrity/ima/ima_policy.c
> > +++ b/security/integrity/ima/ima_policy.c
> > @@ -652,8 +652,8 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
> >         bool uid_token;
> >         int result = 0;
> >
> > -       ab = integrity_audit_log_start(NULL, GFP_KERNEL,
> > -                                      AUDIT_INTEGRITY_RULE);
> > +       ab = integrity_audit_log_start(current->audit_context, GFP_KERNEL,
> > +                                      AUDIT_INTEGRITY_POLICY_RULE);
> >
> >         entry->uid = INVALID_UID;
> >         entry->fowner = INVALID_UID;
> > --
> > 2.13.6
> >
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 4/4] ima: Differentiate auditing policy rules from "audit" actions
  2018-06-05 14:15     ` Mimi Zohar
@ 2018-06-05 22:18       ` Paul Moore
  2018-06-06 14:52         ` Mimi Zohar
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Moore @ 2018-06-05 22:18 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: Stefan Berger, linux-integrity, linux-audit, sgrubb, linux-kernel

On Tue, Jun 5, 2018 at 10:15 AM, Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:
> Hi Paul,
>
> On Mon, 2018-06-04 at 20:21 -0400, Paul Moore wrote:
>> On Mon, Jun 4, 2018 at 4:54 PM, Stefan Berger
>> <stefanb@linux.vnet.ibm.com> wrote:
>> > The AUDIT_INTEGRITY_RULE is used for auditing IMA policy rules and
>> > the IMA "audit" policy action.  This patch defines
>> > AUDIT_INTEGRITY_POLICY_RULE to reflect the IMA policy rules.
>> >
>> > Since we defined a new message type we can now also pass the
>> > audit_context and get an associated SYSCALL record. This now produces
>> > the following records when parsing IMA policy's rules:
>>
>> Aaand now I see you included the current->audit_context pointer I
>> mentioned in my comments for 3/4 ;)
>>
>> So basically this should be fine, although I should point out that you
>> do not need to define a new message type to associate records
>> together.  The fact that we don't associate all connected records is
>> basically a bug.
>>
>> Anyway, patches 3/4 and 4/4 look good to me.  Considering this is
>> likely going in during the *next* merge window, I would ask that you
>> convert from "current->audit_context" to "audit_context()" as soon as
>> this merge window closes.
>>
>> Thanks!
>
> Thanks, Paul.  I'd like to start queueing patches for the next open
> window now, instead of scrambling later.  Can I add your Ack now, and
> remember to make this change when rebasing?

Sure, go ahead and add my ACK to both 3/4 and 4/4 as long as you
double pinky swear you'll do the audit_context() fix-up during the
merge :)

Acked-by: Paul Moore <paul@paul-moore.com>

-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 4/4] ima: Differentiate auditing policy rules from "audit" actions
  2018-06-05 22:18       ` Paul Moore
@ 2018-06-06 14:52         ` Mimi Zohar
  0 siblings, 0 replies; 10+ messages in thread
From: Mimi Zohar @ 2018-06-06 14:52 UTC (permalink / raw)
  To: Paul Moore
  Cc: Stefan Berger, linux-integrity, linux-audit, sgrubb, linux-kernel

On Tue, 2018-06-05 at 18:18 -0400, Paul Moore wrote:
> On Tue, Jun 5, 2018 at 10:15 AM, Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:
> > Hi Paul,
> >
> > On Mon, 2018-06-04 at 20:21 -0400, Paul Moore wrote:
> >> On Mon, Jun 4, 2018 at 4:54 PM, Stefan Berger
> >> <stefanb@linux.vnet.ibm.com> wrote:
> >> > The AUDIT_INTEGRITY_RULE is used for auditing IMA policy rules and
> >> > the IMA "audit" policy action.  This patch defines
> >> > AUDIT_INTEGRITY_POLICY_RULE to reflect the IMA policy rules.
> >> >
> >> > Since we defined a new message type we can now also pass the
> >> > audit_context and get an associated SYSCALL record. This now produces
> >> > the following records when parsing IMA policy's rules:
> >>
> >> Aaand now I see you included the current->audit_context pointer I
> >> mentioned in my comments for 3/4 ;)
> >>
> >> So basically this should be fine, although I should point out that you
> >> do not need to define a new message type to associate records
> >> together.  The fact that we don't associate all connected records is
> >> basically a bug.
> >>
> >> Anyway, patches 3/4 and 4/4 look good to me.  Considering this is
> >> likely going in during the *next* merge window, I would ask that you
> >> convert from "current->audit_context" to "audit_context()" as soon as
> >> this merge window closes.
> >>
> >> Thanks!
> >
> > Thanks, Paul.  I'd like to start queueing patches for the next open
> > window now, instead of scrambling later.  Can I add your Ack now, and
> > remember to make this change when rebasing?
> 
> Sure, go ahead and add my ACK to both 3/4 and 4/4 as long as you
> double pinky swear you'll do the audit_context() fix-up during the
> merge :)
> 
> Acked-by: Paul Moore <paul@paul-moore.com>

Sure, it will be really hard to miss.  The next-integrity-queued
branch has:

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

*** Remember replace current->audit_context with call to audit_context() ***
Acked-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-06-06 14:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-04 20:54 [PATCH v3 0/4] IMA: work on audit records produced by IMA Stefan Berger
2018-06-04 20:54 ` [PATCH v3 1/4] ima: Call audit_log_string() rather than logging it untrusted Stefan Berger
2018-06-04 20:54 ` [PATCH v3 2/4] ima: Use audit_log_format() rather than audit_log_string() Stefan Berger
2018-06-04 20:54 ` [PATCH v3 3/4] ima: Do not audit if CONFIG_INTEGRITY_AUDIT is not set Stefan Berger
2018-06-05  0:16   ` Paul Moore
2018-06-04 20:54 ` [PATCH v3 4/4] ima: Differentiate auditing policy rules from "audit" actions Stefan Berger
2018-06-05  0:21   ` Paul Moore
2018-06-05 14:15     ` Mimi Zohar
2018-06-05 22:18       ` Paul Moore
2018-06-06 14:52         ` Mimi Zohar

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).