2009-02-04 22:06:58 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2005,2006,2007,2008 IBM Corporation
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Reiner Sailer <sailer@watson.ibm.com>
|
|
|
|
* Mimi Zohar <zohar@us.ibm.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation, version 2 of the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* File: ima.h
|
|
|
|
* internal Integrity Measurement Architecture (IMA) definitions
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LINUX_IMA_H
|
|
|
|
#define __LINUX_IMA_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/crypto.h>
|
2016-01-15 06:57:47 +08:00
|
|
|
#include <linux/fs.h>
|
2009-02-04 22:06:58 +08:00
|
|
|
#include <linux/security.h>
|
|
|
|
#include <linux/hash.h>
|
|
|
|
#include <linux/tpm.h>
|
|
|
|
#include <linux/audit.h>
|
2014-10-30 18:39:39 +08:00
|
|
|
#include <crypto/hash_info.h>
|
2009-02-04 22:06:58 +08:00
|
|
|
|
2011-03-10 03:13:22 +08:00
|
|
|
#include "../integrity.h"
|
|
|
|
|
2013-11-09 02:21:40 +08:00
|
|
|
enum ima_show_type { IMA_SHOW_BINARY, IMA_SHOW_BINARY_NO_FIELD_LEN,
|
2014-02-03 20:56:04 +08:00
|
|
|
IMA_SHOW_BINARY_OLD_STRING_FMT, IMA_SHOW_ASCII };
|
2009-02-04 22:06:58 +08:00
|
|
|
enum tpm_pcrs { TPM_PCR0 = 0, TPM_PCR8 = 8 };
|
|
|
|
|
|
|
|
/* digest size for IMA, fits SHA1 or MD5 */
|
2011-03-10 03:13:22 +08:00
|
|
|
#define IMA_DIGEST_SIZE SHA1_DIGEST_SIZE
|
2009-02-04 22:06:58 +08:00
|
|
|
#define IMA_EVENT_NAME_LEN_MAX 255
|
|
|
|
|
|
|
|
#define IMA_HASH_BITS 9
|
|
|
|
#define IMA_MEASURE_HTABLE_SIZE (1 << IMA_HASH_BITS)
|
|
|
|
|
ima: new templates management mechanism
The original 'ima' template is fixed length, containing the filedata hash
and pathname. The filedata hash is limited to 20 bytes (md5/sha1). The
pathname is a null terminated string, limited to 255 characters. To
overcome these limitations and to add additional file metadata, it is
necessary to extend the current version of IMA by defining additional
templates.
The main reason to introduce this feature is that, each time a new
template is defined, the functions that generate and display the
measurement list would include the code for handling a new format and,
thus, would significantly grow over time.
This patch set solves this problem by separating the template management
from the remaining IMA code. The core of this solution is the definition
of two new data structures: a template descriptor, to determine which
information should be included in the measurement list, and a template
field, to generate and display data of a given type.
To define a new template field, developers define the field identifier
and implement two functions, init() and show(), respectively to generate
and display measurement entries. Initially, this patch set defines the
following template fields (support for additional data types will be
added later):
- 'd': the digest of the event (i.e. the digest of a measured file),
calculated with the SHA1 or MD5 hash algorithm;
- 'n': the name of the event (i.e. the file name), with size up to
255 bytes;
- 'd-ng': the digest of the event, calculated with an arbitrary hash
algorithm (field format: [<hash algo>:]digest, where the digest
prefix is shown only if the hash algorithm is not SHA1 or MD5);
- 'n-ng': the name of the event, without size limitations.
Defining a new template descriptor requires specifying the template format,
a string of field identifiers separated by the '|' character. This patch
set defines the following template descriptors:
- "ima": its format is 'd|n';
- "ima-ng" (default): its format is 'd-ng|n-ng'
Further details about the new template architecture can be found in
Documentation/security/IMA-templates.txt.
Changelog:
- don't defer calling ima_init_template() - Mimi
- don't define ima_lookup_template_desc() until used - Mimi
- squashed with documentation patch - Mimi
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
2013-06-07 18:16:29 +08:00
|
|
|
#define IMA_TEMPLATE_FIELD_ID_MAX_LEN 16
|
|
|
|
#define IMA_TEMPLATE_NUM_FIELDS_MAX 15
|
|
|
|
|
2013-06-07 18:16:30 +08:00
|
|
|
#define IMA_TEMPLATE_IMA_NAME "ima"
|
|
|
|
#define IMA_TEMPLATE_IMA_FMT "d|n"
|
|
|
|
|
2014-09-13 01:35:54 +08:00
|
|
|
/* current content of the policy */
|
|
|
|
extern int ima_policy_flag;
|
|
|
|
|
2009-02-04 22:06:58 +08:00
|
|
|
/* set during initialization */
|
|
|
|
extern int ima_initialized;
|
|
|
|
extern int ima_used_chip;
|
2013-04-25 15:43:56 +08:00
|
|
|
extern int ima_hash_algo;
|
ima: integrity appraisal extension
IMA currently maintains an integrity measurement list used to assert the
integrity of the running system to a third party. The IMA-appraisal
extension adds local integrity validation and enforcement of the
measurement against a "good" value stored as an extended attribute
'security.ima'. The initial methods for validating 'security.ima' are
hashed based, which provides file data integrity, and digital signature
based, which in addition to providing file data integrity, provides
authenticity.
This patch creates and maintains the 'security.ima' xattr, containing
the file data hash measurement. Protection of the xattr is provided by
EVM, if enabled and configured.
Based on policy, IMA calls evm_verifyxattr() to verify a file's metadata
integrity and, assuming success, compares the file's current hash value
with the one stored as an extended attribute in 'security.ima'.
Changelov v4:
- changed iint cache flags to hex values
Changelog v3:
- change appraisal default for filesystems without xattr support to fail
Changelog v2:
- fix audit msg 'res' value
- removed unused 'ima_appraise=' values
Changelog v1:
- removed unused iint mutex (Dmitry Kasatkin)
- setattr hook must not reset appraised (Dmitry Kasatkin)
- evm_verifyxattr() now differentiates between no 'security.evm' xattr
(INTEGRITY_NOLABEL) and no EVM 'protected' xattrs included in the
'security.evm' (INTEGRITY_NOXATTRS).
- replace hash_status with ima_status (Dmitry Kasatkin)
- re-initialize slab element ima_status on free (Dmitry Kasatkin)
- include 'security.ima' in EVM if CONFIG_IMA_APPRAISE, not CONFIG_IMA
- merged half "ima: ima_must_appraise_or_measure API change" (Dmitry Kasatkin)
- removed unnecessary error variable in process_measurement() (Dmitry Kasatkin)
- use ima_inode_post_setattr() stub function, if IMA_APPRAISE not configured
(moved ima_inode_post_setattr() to ima_appraise.c)
- make sure ima_collect_measurement() can read file
Changelog:
- add 'iint' to evm_verifyxattr() call (Dimitry Kasatkin)
- fix the race condition between chmod, which takes the i_mutex and then
iint->mutex, and ima_file_free() and process_measurement(), which take
the locks in the reverse order, by eliminating iint->mutex. (Dmitry Kasatkin)
- cleanup of ima_appraise_measurement() (Dmitry Kasatkin)
- changes as a result of the iint not allocated for all regular files, but
only for those measured/appraised.
- don't try to appraise new/empty files
- expanded ima_appraisal description in ima/Kconfig
- IMA appraise definitions required even if IMA_APPRAISE not enabled
- add return value to ima_must_appraise() stub
- unconditionally set status = INTEGRITY_PASS *after* testing status,
not before. (Found by Joe Perches)
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
2012-02-13 23:15:05 +08:00
|
|
|
extern int ima_appraise;
|
2009-02-04 22:06:58 +08:00
|
|
|
|
2015-04-11 23:09:50 +08:00
|
|
|
/* IMA event related data */
|
|
|
|
struct ima_event_data {
|
|
|
|
struct integrity_iint_cache *iint;
|
|
|
|
struct file *file;
|
|
|
|
const unsigned char *filename;
|
|
|
|
struct evm_ima_xattr_data *xattr_value;
|
|
|
|
int xattr_len;
|
2015-04-11 23:12:39 +08:00
|
|
|
const char *violation;
|
2015-04-11 23:09:50 +08:00
|
|
|
};
|
|
|
|
|
ima: new templates management mechanism
The original 'ima' template is fixed length, containing the filedata hash
and pathname. The filedata hash is limited to 20 bytes (md5/sha1). The
pathname is a null terminated string, limited to 255 characters. To
overcome these limitations and to add additional file metadata, it is
necessary to extend the current version of IMA by defining additional
templates.
The main reason to introduce this feature is that, each time a new
template is defined, the functions that generate and display the
measurement list would include the code for handling a new format and,
thus, would significantly grow over time.
This patch set solves this problem by separating the template management
from the remaining IMA code. The core of this solution is the definition
of two new data structures: a template descriptor, to determine which
information should be included in the measurement list, and a template
field, to generate and display data of a given type.
To define a new template field, developers define the field identifier
and implement two functions, init() and show(), respectively to generate
and display measurement entries. Initially, this patch set defines the
following template fields (support for additional data types will be
added later):
- 'd': the digest of the event (i.e. the digest of a measured file),
calculated with the SHA1 or MD5 hash algorithm;
- 'n': the name of the event (i.e. the file name), with size up to
255 bytes;
- 'd-ng': the digest of the event, calculated with an arbitrary hash
algorithm (field format: [<hash algo>:]digest, where the digest
prefix is shown only if the hash algorithm is not SHA1 or MD5);
- 'n-ng': the name of the event, without size limitations.
Defining a new template descriptor requires specifying the template format,
a string of field identifiers separated by the '|' character. This patch
set defines the following template descriptors:
- "ima": its format is 'd|n';
- "ima-ng" (default): its format is 'd-ng|n-ng'
Further details about the new template architecture can be found in
Documentation/security/IMA-templates.txt.
Changelog:
- don't defer calling ima_init_template() - Mimi
- don't define ima_lookup_template_desc() until used - Mimi
- squashed with documentation patch - Mimi
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
2013-06-07 18:16:29 +08:00
|
|
|
/* IMA template field data definition */
|
|
|
|
struct ima_field_data {
|
|
|
|
u8 *data;
|
|
|
|
u32 len;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* IMA template field definition */
|
|
|
|
struct ima_template_field {
|
|
|
|
const char field_id[IMA_TEMPLATE_FIELD_ID_MAX_LEN];
|
2015-04-11 23:09:50 +08:00
|
|
|
int (*field_init)(struct ima_event_data *event_data,
|
|
|
|
struct ima_field_data *field_data);
|
|
|
|
void (*field_show)(struct seq_file *m, enum ima_show_type show,
|
|
|
|
struct ima_field_data *field_data);
|
ima: new templates management mechanism
The original 'ima' template is fixed length, containing the filedata hash
and pathname. The filedata hash is limited to 20 bytes (md5/sha1). The
pathname is a null terminated string, limited to 255 characters. To
overcome these limitations and to add additional file metadata, it is
necessary to extend the current version of IMA by defining additional
templates.
The main reason to introduce this feature is that, each time a new
template is defined, the functions that generate and display the
measurement list would include the code for handling a new format and,
thus, would significantly grow over time.
This patch set solves this problem by separating the template management
from the remaining IMA code. The core of this solution is the definition
of two new data structures: a template descriptor, to determine which
information should be included in the measurement list, and a template
field, to generate and display data of a given type.
To define a new template field, developers define the field identifier
and implement two functions, init() and show(), respectively to generate
and display measurement entries. Initially, this patch set defines the
following template fields (support for additional data types will be
added later):
- 'd': the digest of the event (i.e. the digest of a measured file),
calculated with the SHA1 or MD5 hash algorithm;
- 'n': the name of the event (i.e. the file name), with size up to
255 bytes;
- 'd-ng': the digest of the event, calculated with an arbitrary hash
algorithm (field format: [<hash algo>:]digest, where the digest
prefix is shown only if the hash algorithm is not SHA1 or MD5);
- 'n-ng': the name of the event, without size limitations.
Defining a new template descriptor requires specifying the template format,
a string of field identifiers separated by the '|' character. This patch
set defines the following template descriptors:
- "ima": its format is 'd|n';
- "ima-ng" (default): its format is 'd-ng|n-ng'
Further details about the new template architecture can be found in
Documentation/security/IMA-templates.txt.
Changelog:
- don't defer calling ima_init_template() - Mimi
- don't define ima_lookup_template_desc() until used - Mimi
- squashed with documentation patch - Mimi
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
2013-06-07 18:16:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* IMA template descriptor definition */
|
|
|
|
struct ima_template_desc {
|
|
|
|
char *name;
|
|
|
|
char *fmt;
|
|
|
|
int num_fields;
|
|
|
|
struct ima_template_field **fields;
|
|
|
|
};
|
|
|
|
|
2009-02-04 22:06:58 +08:00
|
|
|
struct ima_template_entry {
|
2013-03-12 08:29:47 +08:00
|
|
|
u8 digest[TPM_DIGEST_SIZE]; /* sha1 or md5 measurement hash */
|
2013-06-07 18:16:33 +08:00
|
|
|
struct ima_template_desc *template_desc; /* template descriptor */
|
|
|
|
u32 template_data_len;
|
|
|
|
struct ima_field_data template_data[0]; /* template related data */
|
2009-02-04 22:06:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ima_queue_entry {
|
|
|
|
struct hlist_node hnext; /* place in hash collision list */
|
|
|
|
struct list_head later; /* place in ima_measurements list */
|
|
|
|
struct ima_template_entry *entry;
|
|
|
|
};
|
|
|
|
extern struct list_head ima_measurements; /* list of all measurements */
|
|
|
|
|
|
|
|
/* Internal IMA function definitions */
|
|
|
|
int ima_init(void);
|
2009-02-04 22:06:59 +08:00
|
|
|
int ima_fs_init(void);
|
2009-02-04 22:06:58 +08:00
|
|
|
int ima_add_template_entry(struct ima_template_entry *entry, int violation,
|
2013-06-07 18:16:27 +08:00
|
|
|
const char *op, struct inode *inode,
|
|
|
|
const unsigned char *filename);
|
2013-04-25 15:43:56 +08:00
|
|
|
int ima_calc_file_hash(struct file *file, struct ima_digest_data *hash);
|
2014-04-17 17:01:40 +08:00
|
|
|
int ima_calc_buffer_hash(const void *buf, loff_t len,
|
|
|
|
struct ima_digest_data *hash);
|
2013-11-09 02:21:39 +08:00
|
|
|
int ima_calc_field_array_hash(struct ima_field_data *field_data,
|
|
|
|
struct ima_template_desc *desc, int num_fields,
|
2013-06-07 18:16:33 +08:00
|
|
|
struct ima_digest_data *hash);
|
2013-06-07 18:16:25 +08:00
|
|
|
int __init ima_calc_boot_aggregate(struct ima_digest_data *hash);
|
2013-06-07 18:16:26 +08:00
|
|
|
void ima_add_violation(struct file *file, const unsigned char *filename,
|
2015-04-11 23:12:39 +08:00
|
|
|
struct integrity_iint_cache *iint,
|
2009-02-04 22:06:58 +08:00
|
|
|
const char *op, const char *cause);
|
2012-06-08 15:42:30 +08:00
|
|
|
int ima_init_crypto(void);
|
2013-06-07 18:16:30 +08:00
|
|
|
void ima_putc(struct seq_file *m, void *data, int datalen);
|
2015-06-11 23:54:42 +08:00
|
|
|
void ima_print_digest(struct seq_file *m, u8 *digest, u32 size);
|
2013-06-07 18:16:33 +08:00
|
|
|
struct ima_template_desc *ima_template_desc_current(void);
|
|
|
|
int ima_init_template(void);
|
2009-02-04 22:06:58 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* used to protect h_table and sha_table
|
|
|
|
*/
|
|
|
|
extern spinlock_t ima_queue_lock;
|
|
|
|
|
|
|
|
struct ima_h_table {
|
|
|
|
atomic_long_t len; /* number of stored measurements in the list */
|
|
|
|
atomic_long_t violations;
|
|
|
|
struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
|
|
|
|
};
|
|
|
|
extern struct ima_h_table ima_htable;
|
|
|
|
|
|
|
|
static inline unsigned long ima_hash_key(u8 *digest)
|
|
|
|
{
|
|
|
|
return hash_long(*digest, IMA_HASH_BITS);
|
|
|
|
}
|
|
|
|
|
2016-01-15 09:59:14 +08:00
|
|
|
enum ima_hooks {
|
|
|
|
FILE_CHECK = 1,
|
|
|
|
MMAP_CHECK,
|
|
|
|
BPRM_CHECK,
|
|
|
|
MODULE_CHECK,
|
|
|
|
FIRMWARE_CHECK,
|
|
|
|
POST_SETATTR
|
|
|
|
};
|
|
|
|
|
2009-02-04 22:06:58 +08:00
|
|
|
/* LIM API function definitions */
|
2016-01-15 09:59:14 +08:00
|
|
|
int ima_get_action(struct inode *inode, int mask, enum ima_hooks func);
|
|
|
|
int ima_must_measure(struct inode *inode, int mask, enum ima_hooks func);
|
2011-03-10 03:13:22 +08:00
|
|
|
int ima_collect_measurement(struct integrity_iint_cache *iint,
|
2016-01-15 06:57:47 +08:00
|
|
|
struct file *file, void *buf, loff_t size,
|
|
|
|
enum hash_algo algo);
|
2011-03-10 03:13:22 +08:00
|
|
|
void ima_store_measurement(struct integrity_iint_cache *iint, struct file *file,
|
2013-07-23 23:15:00 +08:00
|
|
|
const unsigned char *filename,
|
|
|
|
struct evm_ima_xattr_data *xattr_value,
|
|
|
|
int xattr_len);
|
2012-06-15 01:04:36 +08:00
|
|
|
void ima_audit_measurement(struct integrity_iint_cache *iint,
|
|
|
|
const unsigned char *filename);
|
2015-04-11 23:09:50 +08:00
|
|
|
int ima_alloc_init_template(struct ima_event_data *event_data,
|
|
|
|
struct ima_template_entry **entry);
|
2009-02-04 22:06:58 +08:00
|
|
|
int ima_store_template(struct ima_template_entry *entry, int violation,
|
2013-06-07 18:16:27 +08:00
|
|
|
struct inode *inode, const unsigned char *filename);
|
2013-12-03 02:40:34 +08:00
|
|
|
void ima_free_template_entry(struct ima_template_entry *entry);
|
2012-09-04 05:40:17 +08:00
|
|
|
const char *ima_d_path(struct path *path, char **pathbuf);
|
2009-02-04 22:06:58 +08:00
|
|
|
|
|
|
|
/* IMA policy related functions */
|
ima: integrity appraisal extension
IMA currently maintains an integrity measurement list used to assert the
integrity of the running system to a third party. The IMA-appraisal
extension adds local integrity validation and enforcement of the
measurement against a "good" value stored as an extended attribute
'security.ima'. The initial methods for validating 'security.ima' are
hashed based, which provides file data integrity, and digital signature
based, which in addition to providing file data integrity, provides
authenticity.
This patch creates and maintains the 'security.ima' xattr, containing
the file data hash measurement. Protection of the xattr is provided by
EVM, if enabled and configured.
Based on policy, IMA calls evm_verifyxattr() to verify a file's metadata
integrity and, assuming success, compares the file's current hash value
with the one stored as an extended attribute in 'security.ima'.
Changelov v4:
- changed iint cache flags to hex values
Changelog v3:
- change appraisal default for filesystems without xattr support to fail
Changelog v2:
- fix audit msg 'res' value
- removed unused 'ima_appraise=' values
Changelog v1:
- removed unused iint mutex (Dmitry Kasatkin)
- setattr hook must not reset appraised (Dmitry Kasatkin)
- evm_verifyxattr() now differentiates between no 'security.evm' xattr
(INTEGRITY_NOLABEL) and no EVM 'protected' xattrs included in the
'security.evm' (INTEGRITY_NOXATTRS).
- replace hash_status with ima_status (Dmitry Kasatkin)
- re-initialize slab element ima_status on free (Dmitry Kasatkin)
- include 'security.ima' in EVM if CONFIG_IMA_APPRAISE, not CONFIG_IMA
- merged half "ima: ima_must_appraise_or_measure API change" (Dmitry Kasatkin)
- removed unnecessary error variable in process_measurement() (Dmitry Kasatkin)
- use ima_inode_post_setattr() stub function, if IMA_APPRAISE not configured
(moved ima_inode_post_setattr() to ima_appraise.c)
- make sure ima_collect_measurement() can read file
Changelog:
- add 'iint' to evm_verifyxattr() call (Dimitry Kasatkin)
- fix the race condition between chmod, which takes the i_mutex and then
iint->mutex, and ima_file_free() and process_measurement(), which take
the locks in the reverse order, by eliminating iint->mutex. (Dmitry Kasatkin)
- cleanup of ima_appraise_measurement() (Dmitry Kasatkin)
- changes as a result of the iint not allocated for all regular files, but
only for those measured/appraised.
- don't try to appraise new/empty files
- expanded ima_appraisal description in ima/Kconfig
- IMA appraise definitions required even if IMA_APPRAISE not enabled
- add return value to ima_must_appraise() stub
- unconditionally set status = INTEGRITY_PASS *after* testing status,
not before. (Found by Joe Perches)
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
2012-02-13 23:15:05 +08:00
|
|
|
int ima_match_policy(struct inode *inode, enum ima_hooks func, int mask,
|
|
|
|
int flags);
|
2009-02-04 22:06:58 +08:00
|
|
|
void ima_init_policy(void);
|
|
|
|
void ima_update_policy(void);
|
2014-09-13 01:35:54 +08:00
|
|
|
void ima_update_policy_flag(void);
|
2010-04-20 22:20:54 +08:00
|
|
|
ssize_t ima_parse_add_rule(char *);
|
2009-02-04 22:07:00 +08:00
|
|
|
void ima_delete_rules(void);
|
2015-12-22 21:51:23 +08:00
|
|
|
int ima_check_policy(void);
|
2015-12-02 23:47:56 +08:00
|
|
|
void *ima_policy_start(struct seq_file *m, loff_t *pos);
|
|
|
|
void *ima_policy_next(struct seq_file *m, void *v, loff_t *pos);
|
|
|
|
void ima_policy_stop(struct seq_file *m, void *v);
|
|
|
|
int ima_policy_show(struct seq_file *m, void *v);
|
2009-02-04 22:07:00 +08:00
|
|
|
|
ima: integrity appraisal extension
IMA currently maintains an integrity measurement list used to assert the
integrity of the running system to a third party. The IMA-appraisal
extension adds local integrity validation and enforcement of the
measurement against a "good" value stored as an extended attribute
'security.ima'. The initial methods for validating 'security.ima' are
hashed based, which provides file data integrity, and digital signature
based, which in addition to providing file data integrity, provides
authenticity.
This patch creates and maintains the 'security.ima' xattr, containing
the file data hash measurement. Protection of the xattr is provided by
EVM, if enabled and configured.
Based on policy, IMA calls evm_verifyxattr() to verify a file's metadata
integrity and, assuming success, compares the file's current hash value
with the one stored as an extended attribute in 'security.ima'.
Changelov v4:
- changed iint cache flags to hex values
Changelog v3:
- change appraisal default for filesystems without xattr support to fail
Changelog v2:
- fix audit msg 'res' value
- removed unused 'ima_appraise=' values
Changelog v1:
- removed unused iint mutex (Dmitry Kasatkin)
- setattr hook must not reset appraised (Dmitry Kasatkin)
- evm_verifyxattr() now differentiates between no 'security.evm' xattr
(INTEGRITY_NOLABEL) and no EVM 'protected' xattrs included in the
'security.evm' (INTEGRITY_NOXATTRS).
- replace hash_status with ima_status (Dmitry Kasatkin)
- re-initialize slab element ima_status on free (Dmitry Kasatkin)
- include 'security.ima' in EVM if CONFIG_IMA_APPRAISE, not CONFIG_IMA
- merged half "ima: ima_must_appraise_or_measure API change" (Dmitry Kasatkin)
- removed unnecessary error variable in process_measurement() (Dmitry Kasatkin)
- use ima_inode_post_setattr() stub function, if IMA_APPRAISE not configured
(moved ima_inode_post_setattr() to ima_appraise.c)
- make sure ima_collect_measurement() can read file
Changelog:
- add 'iint' to evm_verifyxattr() call (Dimitry Kasatkin)
- fix the race condition between chmod, which takes the i_mutex and then
iint->mutex, and ima_file_free() and process_measurement(), which take
the locks in the reverse order, by eliminating iint->mutex. (Dmitry Kasatkin)
- cleanup of ima_appraise_measurement() (Dmitry Kasatkin)
- changes as a result of the iint not allocated for all regular files, but
only for those measured/appraised.
- don't try to appraise new/empty files
- expanded ima_appraisal description in ima/Kconfig
- IMA appraise definitions required even if IMA_APPRAISE not enabled
- add return value to ima_must_appraise() stub
- unconditionally set status = INTEGRITY_PASS *after* testing status,
not before. (Found by Joe Perches)
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
2012-02-13 23:15:05 +08:00
|
|
|
/* Appraise integrity measurements */
|
|
|
|
#define IMA_APPRAISE_ENFORCE 0x01
|
|
|
|
#define IMA_APPRAISE_FIX 0x02
|
2014-05-08 18:11:29 +08:00
|
|
|
#define IMA_APPRAISE_LOG 0x04
|
|
|
|
#define IMA_APPRAISE_MODULES 0x08
|
|
|
|
#define IMA_APPRAISE_FIRMWARE 0x10
|
ima: integrity appraisal extension
IMA currently maintains an integrity measurement list used to assert the
integrity of the running system to a third party. The IMA-appraisal
extension adds local integrity validation and enforcement of the
measurement against a "good" value stored as an extended attribute
'security.ima'. The initial methods for validating 'security.ima' are
hashed based, which provides file data integrity, and digital signature
based, which in addition to providing file data integrity, provides
authenticity.
This patch creates and maintains the 'security.ima' xattr, containing
the file data hash measurement. Protection of the xattr is provided by
EVM, if enabled and configured.
Based on policy, IMA calls evm_verifyxattr() to verify a file's metadata
integrity and, assuming success, compares the file's current hash value
with the one stored as an extended attribute in 'security.ima'.
Changelov v4:
- changed iint cache flags to hex values
Changelog v3:
- change appraisal default for filesystems without xattr support to fail
Changelog v2:
- fix audit msg 'res' value
- removed unused 'ima_appraise=' values
Changelog v1:
- removed unused iint mutex (Dmitry Kasatkin)
- setattr hook must not reset appraised (Dmitry Kasatkin)
- evm_verifyxattr() now differentiates between no 'security.evm' xattr
(INTEGRITY_NOLABEL) and no EVM 'protected' xattrs included in the
'security.evm' (INTEGRITY_NOXATTRS).
- replace hash_status with ima_status (Dmitry Kasatkin)
- re-initialize slab element ima_status on free (Dmitry Kasatkin)
- include 'security.ima' in EVM if CONFIG_IMA_APPRAISE, not CONFIG_IMA
- merged half "ima: ima_must_appraise_or_measure API change" (Dmitry Kasatkin)
- removed unnecessary error variable in process_measurement() (Dmitry Kasatkin)
- use ima_inode_post_setattr() stub function, if IMA_APPRAISE not configured
(moved ima_inode_post_setattr() to ima_appraise.c)
- make sure ima_collect_measurement() can read file
Changelog:
- add 'iint' to evm_verifyxattr() call (Dimitry Kasatkin)
- fix the race condition between chmod, which takes the i_mutex and then
iint->mutex, and ima_file_free() and process_measurement(), which take
the locks in the reverse order, by eliminating iint->mutex. (Dmitry Kasatkin)
- cleanup of ima_appraise_measurement() (Dmitry Kasatkin)
- changes as a result of the iint not allocated for all regular files, but
only for those measured/appraised.
- don't try to appraise new/empty files
- expanded ima_appraisal description in ima/Kconfig
- IMA appraise definitions required even if IMA_APPRAISE not enabled
- add return value to ima_must_appraise() stub
- unconditionally set status = INTEGRITY_PASS *after* testing status,
not before. (Found by Joe Perches)
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
2012-02-13 23:15:05 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_IMA_APPRAISE
|
2016-01-15 09:59:14 +08:00
|
|
|
int ima_appraise_measurement(enum ima_hooks func,
|
|
|
|
struct integrity_iint_cache *iint,
|
2013-04-25 15:44:04 +08:00
|
|
|
struct file *file, const unsigned char *filename,
|
|
|
|
struct evm_ima_xattr_data *xattr_value,
|
2014-06-27 23:15:44 +08:00
|
|
|
int xattr_len, int opened);
|
2012-09-27 23:26:53 +08:00
|
|
|
int ima_must_appraise(struct inode *inode, int mask, enum ima_hooks func);
|
ima: integrity appraisal extension
IMA currently maintains an integrity measurement list used to assert the
integrity of the running system to a third party. The IMA-appraisal
extension adds local integrity validation and enforcement of the
measurement against a "good" value stored as an extended attribute
'security.ima'. The initial methods for validating 'security.ima' are
hashed based, which provides file data integrity, and digital signature
based, which in addition to providing file data integrity, provides
authenticity.
This patch creates and maintains the 'security.ima' xattr, containing
the file data hash measurement. Protection of the xattr is provided by
EVM, if enabled and configured.
Based on policy, IMA calls evm_verifyxattr() to verify a file's metadata
integrity and, assuming success, compares the file's current hash value
with the one stored as an extended attribute in 'security.ima'.
Changelov v4:
- changed iint cache flags to hex values
Changelog v3:
- change appraisal default for filesystems without xattr support to fail
Changelog v2:
- fix audit msg 'res' value
- removed unused 'ima_appraise=' values
Changelog v1:
- removed unused iint mutex (Dmitry Kasatkin)
- setattr hook must not reset appraised (Dmitry Kasatkin)
- evm_verifyxattr() now differentiates between no 'security.evm' xattr
(INTEGRITY_NOLABEL) and no EVM 'protected' xattrs included in the
'security.evm' (INTEGRITY_NOXATTRS).
- replace hash_status with ima_status (Dmitry Kasatkin)
- re-initialize slab element ima_status on free (Dmitry Kasatkin)
- include 'security.ima' in EVM if CONFIG_IMA_APPRAISE, not CONFIG_IMA
- merged half "ima: ima_must_appraise_or_measure API change" (Dmitry Kasatkin)
- removed unnecessary error variable in process_measurement() (Dmitry Kasatkin)
- use ima_inode_post_setattr() stub function, if IMA_APPRAISE not configured
(moved ima_inode_post_setattr() to ima_appraise.c)
- make sure ima_collect_measurement() can read file
Changelog:
- add 'iint' to evm_verifyxattr() call (Dimitry Kasatkin)
- fix the race condition between chmod, which takes the i_mutex and then
iint->mutex, and ima_file_free() and process_measurement(), which take
the locks in the reverse order, by eliminating iint->mutex. (Dmitry Kasatkin)
- cleanup of ima_appraise_measurement() (Dmitry Kasatkin)
- changes as a result of the iint not allocated for all regular files, but
only for those measured/appraised.
- don't try to appraise new/empty files
- expanded ima_appraisal description in ima/Kconfig
- IMA appraise definitions required even if IMA_APPRAISE not enabled
- add return value to ima_must_appraise() stub
- unconditionally set status = INTEGRITY_PASS *after* testing status,
not before. (Found by Joe Perches)
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
2012-02-13 23:15:05 +08:00
|
|
|
void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file);
|
2012-12-04 06:08:11 +08:00
|
|
|
enum integrity_status ima_get_cache_status(struct integrity_iint_cache *iint,
|
2016-01-15 09:59:14 +08:00
|
|
|
enum ima_hooks func);
|
2014-10-30 18:39:39 +08:00
|
|
|
enum hash_algo ima_get_hash_algo(struct evm_ima_xattr_data *xattr_value,
|
|
|
|
int xattr_len);
|
2013-04-25 15:44:04 +08:00
|
|
|
int ima_read_xattr(struct dentry *dentry,
|
|
|
|
struct evm_ima_xattr_data **xattr_value);
|
ima: integrity appraisal extension
IMA currently maintains an integrity measurement list used to assert the
integrity of the running system to a third party. The IMA-appraisal
extension adds local integrity validation and enforcement of the
measurement against a "good" value stored as an extended attribute
'security.ima'. The initial methods for validating 'security.ima' are
hashed based, which provides file data integrity, and digital signature
based, which in addition to providing file data integrity, provides
authenticity.
This patch creates and maintains the 'security.ima' xattr, containing
the file data hash measurement. Protection of the xattr is provided by
EVM, if enabled and configured.
Based on policy, IMA calls evm_verifyxattr() to verify a file's metadata
integrity and, assuming success, compares the file's current hash value
with the one stored as an extended attribute in 'security.ima'.
Changelov v4:
- changed iint cache flags to hex values
Changelog v3:
- change appraisal default for filesystems without xattr support to fail
Changelog v2:
- fix audit msg 'res' value
- removed unused 'ima_appraise=' values
Changelog v1:
- removed unused iint mutex (Dmitry Kasatkin)
- setattr hook must not reset appraised (Dmitry Kasatkin)
- evm_verifyxattr() now differentiates between no 'security.evm' xattr
(INTEGRITY_NOLABEL) and no EVM 'protected' xattrs included in the
'security.evm' (INTEGRITY_NOXATTRS).
- replace hash_status with ima_status (Dmitry Kasatkin)
- re-initialize slab element ima_status on free (Dmitry Kasatkin)
- include 'security.ima' in EVM if CONFIG_IMA_APPRAISE, not CONFIG_IMA
- merged half "ima: ima_must_appraise_or_measure API change" (Dmitry Kasatkin)
- removed unnecessary error variable in process_measurement() (Dmitry Kasatkin)
- use ima_inode_post_setattr() stub function, if IMA_APPRAISE not configured
(moved ima_inode_post_setattr() to ima_appraise.c)
- make sure ima_collect_measurement() can read file
Changelog:
- add 'iint' to evm_verifyxattr() call (Dimitry Kasatkin)
- fix the race condition between chmod, which takes the i_mutex and then
iint->mutex, and ima_file_free() and process_measurement(), which take
the locks in the reverse order, by eliminating iint->mutex. (Dmitry Kasatkin)
- cleanup of ima_appraise_measurement() (Dmitry Kasatkin)
- changes as a result of the iint not allocated for all regular files, but
only for those measured/appraised.
- don't try to appraise new/empty files
- expanded ima_appraisal description in ima/Kconfig
- IMA appraise definitions required even if IMA_APPRAISE not enabled
- add return value to ima_must_appraise() stub
- unconditionally set status = INTEGRITY_PASS *after* testing status,
not before. (Found by Joe Perches)
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
2012-02-13 23:15:05 +08:00
|
|
|
|
|
|
|
#else
|
2016-01-15 09:59:14 +08:00
|
|
|
static inline int ima_appraise_measurement(enum ima_hooks func,
|
2012-12-04 06:08:11 +08:00
|
|
|
struct integrity_iint_cache *iint,
|
ima: integrity appraisal extension
IMA currently maintains an integrity measurement list used to assert the
integrity of the running system to a third party. The IMA-appraisal
extension adds local integrity validation and enforcement of the
measurement against a "good" value stored as an extended attribute
'security.ima'. The initial methods for validating 'security.ima' are
hashed based, which provides file data integrity, and digital signature
based, which in addition to providing file data integrity, provides
authenticity.
This patch creates and maintains the 'security.ima' xattr, containing
the file data hash measurement. Protection of the xattr is provided by
EVM, if enabled and configured.
Based on policy, IMA calls evm_verifyxattr() to verify a file's metadata
integrity and, assuming success, compares the file's current hash value
with the one stored as an extended attribute in 'security.ima'.
Changelov v4:
- changed iint cache flags to hex values
Changelog v3:
- change appraisal default for filesystems without xattr support to fail
Changelog v2:
- fix audit msg 'res' value
- removed unused 'ima_appraise=' values
Changelog v1:
- removed unused iint mutex (Dmitry Kasatkin)
- setattr hook must not reset appraised (Dmitry Kasatkin)
- evm_verifyxattr() now differentiates between no 'security.evm' xattr
(INTEGRITY_NOLABEL) and no EVM 'protected' xattrs included in the
'security.evm' (INTEGRITY_NOXATTRS).
- replace hash_status with ima_status (Dmitry Kasatkin)
- re-initialize slab element ima_status on free (Dmitry Kasatkin)
- include 'security.ima' in EVM if CONFIG_IMA_APPRAISE, not CONFIG_IMA
- merged half "ima: ima_must_appraise_or_measure API change" (Dmitry Kasatkin)
- removed unnecessary error variable in process_measurement() (Dmitry Kasatkin)
- use ima_inode_post_setattr() stub function, if IMA_APPRAISE not configured
(moved ima_inode_post_setattr() to ima_appraise.c)
- make sure ima_collect_measurement() can read file
Changelog:
- add 'iint' to evm_verifyxattr() call (Dimitry Kasatkin)
- fix the race condition between chmod, which takes the i_mutex and then
iint->mutex, and ima_file_free() and process_measurement(), which take
the locks in the reverse order, by eliminating iint->mutex. (Dmitry Kasatkin)
- cleanup of ima_appraise_measurement() (Dmitry Kasatkin)
- changes as a result of the iint not allocated for all regular files, but
only for those measured/appraised.
- don't try to appraise new/empty files
- expanded ima_appraisal description in ima/Kconfig
- IMA appraise definitions required even if IMA_APPRAISE not enabled
- add return value to ima_must_appraise() stub
- unconditionally set status = INTEGRITY_PASS *after* testing status,
not before. (Found by Joe Perches)
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
2012-02-13 23:15:05 +08:00
|
|
|
struct file *file,
|
2013-04-25 15:44:04 +08:00
|
|
|
const unsigned char *filename,
|
|
|
|
struct evm_ima_xattr_data *xattr_value,
|
2014-06-27 23:15:44 +08:00
|
|
|
int xattr_len, int opened)
|
ima: integrity appraisal extension
IMA currently maintains an integrity measurement list used to assert the
integrity of the running system to a third party. The IMA-appraisal
extension adds local integrity validation and enforcement of the
measurement against a "good" value stored as an extended attribute
'security.ima'. The initial methods for validating 'security.ima' are
hashed based, which provides file data integrity, and digital signature
based, which in addition to providing file data integrity, provides
authenticity.
This patch creates and maintains the 'security.ima' xattr, containing
the file data hash measurement. Protection of the xattr is provided by
EVM, if enabled and configured.
Based on policy, IMA calls evm_verifyxattr() to verify a file's metadata
integrity and, assuming success, compares the file's current hash value
with the one stored as an extended attribute in 'security.ima'.
Changelov v4:
- changed iint cache flags to hex values
Changelog v3:
- change appraisal default for filesystems without xattr support to fail
Changelog v2:
- fix audit msg 'res' value
- removed unused 'ima_appraise=' values
Changelog v1:
- removed unused iint mutex (Dmitry Kasatkin)
- setattr hook must not reset appraised (Dmitry Kasatkin)
- evm_verifyxattr() now differentiates between no 'security.evm' xattr
(INTEGRITY_NOLABEL) and no EVM 'protected' xattrs included in the
'security.evm' (INTEGRITY_NOXATTRS).
- replace hash_status with ima_status (Dmitry Kasatkin)
- re-initialize slab element ima_status on free (Dmitry Kasatkin)
- include 'security.ima' in EVM if CONFIG_IMA_APPRAISE, not CONFIG_IMA
- merged half "ima: ima_must_appraise_or_measure API change" (Dmitry Kasatkin)
- removed unnecessary error variable in process_measurement() (Dmitry Kasatkin)
- use ima_inode_post_setattr() stub function, if IMA_APPRAISE not configured
(moved ima_inode_post_setattr() to ima_appraise.c)
- make sure ima_collect_measurement() can read file
Changelog:
- add 'iint' to evm_verifyxattr() call (Dimitry Kasatkin)
- fix the race condition between chmod, which takes the i_mutex and then
iint->mutex, and ima_file_free() and process_measurement(), which take
the locks in the reverse order, by eliminating iint->mutex. (Dmitry Kasatkin)
- cleanup of ima_appraise_measurement() (Dmitry Kasatkin)
- changes as a result of the iint not allocated for all regular files, but
only for those measured/appraised.
- don't try to appraise new/empty files
- expanded ima_appraisal description in ima/Kconfig
- IMA appraise definitions required even if IMA_APPRAISE not enabled
- add return value to ima_must_appraise() stub
- unconditionally set status = INTEGRITY_PASS *after* testing status,
not before. (Found by Joe Perches)
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
2012-02-13 23:15:05 +08:00
|
|
|
{
|
|
|
|
return INTEGRITY_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2012-09-27 23:26:53 +08:00
|
|
|
static inline int ima_must_appraise(struct inode *inode, int mask,
|
|
|
|
enum ima_hooks func)
|
ima: integrity appraisal extension
IMA currently maintains an integrity measurement list used to assert the
integrity of the running system to a third party. The IMA-appraisal
extension adds local integrity validation and enforcement of the
measurement against a "good" value stored as an extended attribute
'security.ima'. The initial methods for validating 'security.ima' are
hashed based, which provides file data integrity, and digital signature
based, which in addition to providing file data integrity, provides
authenticity.
This patch creates and maintains the 'security.ima' xattr, containing
the file data hash measurement. Protection of the xattr is provided by
EVM, if enabled and configured.
Based on policy, IMA calls evm_verifyxattr() to verify a file's metadata
integrity and, assuming success, compares the file's current hash value
with the one stored as an extended attribute in 'security.ima'.
Changelov v4:
- changed iint cache flags to hex values
Changelog v3:
- change appraisal default for filesystems without xattr support to fail
Changelog v2:
- fix audit msg 'res' value
- removed unused 'ima_appraise=' values
Changelog v1:
- removed unused iint mutex (Dmitry Kasatkin)
- setattr hook must not reset appraised (Dmitry Kasatkin)
- evm_verifyxattr() now differentiates between no 'security.evm' xattr
(INTEGRITY_NOLABEL) and no EVM 'protected' xattrs included in the
'security.evm' (INTEGRITY_NOXATTRS).
- replace hash_status with ima_status (Dmitry Kasatkin)
- re-initialize slab element ima_status on free (Dmitry Kasatkin)
- include 'security.ima' in EVM if CONFIG_IMA_APPRAISE, not CONFIG_IMA
- merged half "ima: ima_must_appraise_or_measure API change" (Dmitry Kasatkin)
- removed unnecessary error variable in process_measurement() (Dmitry Kasatkin)
- use ima_inode_post_setattr() stub function, if IMA_APPRAISE not configured
(moved ima_inode_post_setattr() to ima_appraise.c)
- make sure ima_collect_measurement() can read file
Changelog:
- add 'iint' to evm_verifyxattr() call (Dimitry Kasatkin)
- fix the race condition between chmod, which takes the i_mutex and then
iint->mutex, and ima_file_free() and process_measurement(), which take
the locks in the reverse order, by eliminating iint->mutex. (Dmitry Kasatkin)
- cleanup of ima_appraise_measurement() (Dmitry Kasatkin)
- changes as a result of the iint not allocated for all regular files, but
only for those measured/appraised.
- don't try to appraise new/empty files
- expanded ima_appraisal description in ima/Kconfig
- IMA appraise definitions required even if IMA_APPRAISE not enabled
- add return value to ima_must_appraise() stub
- unconditionally set status = INTEGRITY_PASS *after* testing status,
not before. (Found by Joe Perches)
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
2012-02-13 23:15:05 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ima_update_xattr(struct integrity_iint_cache *iint,
|
|
|
|
struct file *file)
|
|
|
|
{
|
|
|
|
}
|
2012-12-04 06:08:11 +08:00
|
|
|
|
|
|
|
static inline enum integrity_status ima_get_cache_status(struct integrity_iint_cache
|
2016-01-15 09:59:14 +08:00
|
|
|
*iint,
|
|
|
|
enum ima_hooks func)
|
2012-12-04 06:08:11 +08:00
|
|
|
{
|
|
|
|
return INTEGRITY_UNKNOWN;
|
|
|
|
}
|
2013-04-25 15:44:04 +08:00
|
|
|
|
2014-10-30 18:39:39 +08:00
|
|
|
static inline enum hash_algo
|
|
|
|
ima_get_hash_algo(struct evm_ima_xattr_data *xattr_value, int xattr_len)
|
2013-04-25 15:44:04 +08:00
|
|
|
{
|
2014-10-30 18:39:39 +08:00
|
|
|
return ima_hash_algo;
|
2013-04-25 15:44:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ima_read_xattr(struct dentry *dentry,
|
|
|
|
struct evm_ima_xattr_data **xattr_value)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
ima: integrity appraisal extension
IMA currently maintains an integrity measurement list used to assert the
integrity of the running system to a third party. The IMA-appraisal
extension adds local integrity validation and enforcement of the
measurement against a "good" value stored as an extended attribute
'security.ima'. The initial methods for validating 'security.ima' are
hashed based, which provides file data integrity, and digital signature
based, which in addition to providing file data integrity, provides
authenticity.
This patch creates and maintains the 'security.ima' xattr, containing
the file data hash measurement. Protection of the xattr is provided by
EVM, if enabled and configured.
Based on policy, IMA calls evm_verifyxattr() to verify a file's metadata
integrity and, assuming success, compares the file's current hash value
with the one stored as an extended attribute in 'security.ima'.
Changelov v4:
- changed iint cache flags to hex values
Changelog v3:
- change appraisal default for filesystems without xattr support to fail
Changelog v2:
- fix audit msg 'res' value
- removed unused 'ima_appraise=' values
Changelog v1:
- removed unused iint mutex (Dmitry Kasatkin)
- setattr hook must not reset appraised (Dmitry Kasatkin)
- evm_verifyxattr() now differentiates between no 'security.evm' xattr
(INTEGRITY_NOLABEL) and no EVM 'protected' xattrs included in the
'security.evm' (INTEGRITY_NOXATTRS).
- replace hash_status with ima_status (Dmitry Kasatkin)
- re-initialize slab element ima_status on free (Dmitry Kasatkin)
- include 'security.ima' in EVM if CONFIG_IMA_APPRAISE, not CONFIG_IMA
- merged half "ima: ima_must_appraise_or_measure API change" (Dmitry Kasatkin)
- removed unnecessary error variable in process_measurement() (Dmitry Kasatkin)
- use ima_inode_post_setattr() stub function, if IMA_APPRAISE not configured
(moved ima_inode_post_setattr() to ima_appraise.c)
- make sure ima_collect_measurement() can read file
Changelog:
- add 'iint' to evm_verifyxattr() call (Dimitry Kasatkin)
- fix the race condition between chmod, which takes the i_mutex and then
iint->mutex, and ima_file_free() and process_measurement(), which take
the locks in the reverse order, by eliminating iint->mutex. (Dmitry Kasatkin)
- cleanup of ima_appraise_measurement() (Dmitry Kasatkin)
- changes as a result of the iint not allocated for all regular files, but
only for those measured/appraised.
- don't try to appraise new/empty files
- expanded ima_appraisal description in ima/Kconfig
- IMA appraise definitions required even if IMA_APPRAISE not enabled
- add return value to ima_must_appraise() stub
- unconditionally set status = INTEGRITY_PASS *after* testing status,
not before. (Found by Joe Perches)
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
2012-02-13 23:15:05 +08:00
|
|
|
#endif
|
|
|
|
|
2009-02-04 22:07:00 +08:00
|
|
|
/* LSM based policy rules require audit */
|
|
|
|
#ifdef CONFIG_IMA_LSM_RULES
|
|
|
|
|
|
|
|
#define security_filter_rule_init security_audit_rule_init
|
|
|
|
#define security_filter_rule_match security_audit_rule_match
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static inline int security_filter_rule_init(u32 field, u32 op, char *rulestr,
|
|
|
|
void **lsmrule)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int security_filter_rule_match(u32 secid, u32 field, u32 op,
|
|
|
|
void *lsmrule,
|
|
|
|
struct audit_context *actx)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2015-12-02 23:47:56 +08:00
|
|
|
#endif /* CONFIG_IMA_TRUSTED_KEYRING */
|
|
|
|
|
|
|
|
#ifdef CONFIG_IMA_READ_POLICY
|
|
|
|
#define POLICY_FILE_FLAGS (S_IWUSR | S_IRUSR)
|
|
|
|
#else
|
|
|
|
#define POLICY_FILE_FLAGS S_IWUSR
|
|
|
|
#endif /* CONFIG_IMA_WRITE_POLICY */
|
|
|
|
|
|
|
|
#endif /* __LINUX_IMA_H */
|