public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] ima: audit log files opened with O_DIRECT flag
@ 2014-05-12 20:24 Mimi Zohar
  2014-05-12 23:27 ` Mimi Zohar
  0 siblings, 1 reply; 6+ messages in thread
From: Mimi Zohar @ 2014-05-12 20:24 UTC (permalink / raw)
  To: linux-security-module
  Cc: J. R. Okajima, Dmitry Kasatkin, Al Viro, linux-kernel

As a temporary fix, do not measure, appraise, or audit files
opened with the O_DIRECT flag set.  Just audit log it.

Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
---
security/integrity/ima/ima_api.c  | 10 +++++++++-
security/integrity/ima/ima_main.c |  5 ++++-
2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/security/integrity/ima/ima_api.c
b/security/integrity/ima/ima_api.c
index ba9e4d7..d719978 100644
--- a/security/integrity/ima/ima_api.c
+++ b/security/integrity/ima/ima_api.c
@@ -199,6 +199,7 @@ int ima_collect_measurement(struct
integrity_iint_cache *iint,
    struct evm_ima_xattr_data **xattr_value,
    int *xattr_len)
{
+ const char *audit_cause = "failed";
struct inode *inode = file_inode(file);
const char *filename = file->f_dentry->d_name.name;
int result = 0;
@@ -213,6 +214,12 @@ int ima_collect_measurement(struct
integrity_iint_cache *iint,
if (!(iint->flags & IMA_COLLECTED)) {
u64 i_version = file_inode(file)->i_version;

+ if (file->f_flags & O_DIRECT) {
+ audit_cause = "failed(directio)";
+ result = -EACCES;
+ goto out;
+ }
+ 
/* use default hash algorithm */
hash.hdr.algo = ima_hash_algo;

@@ -233,9 +240,10 @@ int ima_collect_measurement(struct
integrity_iint_cache *iint,
result = -ENOMEM;
}
}
+out:
if (result)
integrity_audit_msg(AUDIT_INTEGRITY_DATA, inode,
-     filename, "collect_data", "failed",
+     filename, "collect_data", audit_cause,
    result, 0);
return result;
}
diff --git a/security/integrity/ima/ima_main.c
b/security/integrity/ima/ima_main.c
index 654111f..3e5b732 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -214,8 +214,11 @@ static int process_measurement(struct file *file,
const char *filename,
xattr_ptr = &xattr_value;

rc = ima_collect_measurement(iint, file, xattr_ptr, &xattr_len);
- if (rc != 0)
+ if (rc != 0) { 
+ if (file->f_flags & O_DIRECT)
+ rc = 0;
goto out_digsig;
+ }

pathname = filename ?: ima_d_path(&file->f_path, &pathbuf);

-- 
1.8.1.4




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

end of thread, other threads:[~2014-05-21  9:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-12 20:24 [RFC PATCH] ima: audit log files opened with O_DIRECT flag Mimi Zohar
2014-05-12 23:27 ` Mimi Zohar
2014-05-13  7:19   ` J. R. Okajima
2014-05-13 11:10     ` Mimi Zohar
2014-05-19 21:06     ` [PATCH v1] " Mimi Zohar
2014-05-21  9:38       ` Dmitry Kasatkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox