integrity: TPM internel kernel interface
Subsystems (12)
PATCH 1/4 integrity: TPM internel kernel interface
In reply to a message not in the archive Resubmitting integrity-tpm-internal-kernel-interface.patch, which was previously Signed-off-by Kylene Hall.
Updated per feedback.
Adds the following support:
- make internal kernel interface to transmit TPM commands global
- adds reading a pcr value
- adds extending a pcr value
- adds lookup the tpm_chip for given chip number and type
drivers/char/tpm/tpm.c +110 -3
@@ -1,11 +1,12 @@/* -* Copyright (C) 2004 IBM Corporation +* Copyright (C) 2004,2007,2008 IBM Corporation * * Authors: * Leendert van Doorn <[email protected]> * Dave Safford <[email protected]> * Reiner Sailer <[email protected]> * Kylene Hall <[email protected]> +* Debora Velarde <[email protected]> * * Maintained by: <[email protected]> *
@@ -28,6 +29,13 @@#include <linux/spinlock.h> #include <linux/smp_lock.h> +#include <linux/mm.h> +#include <linux/slab.h> +#include <linux/string.h> +#include <linux/crypto.h> +#include <linux/fs.h> +#include <linux/scatterlist.h> +#include <asm/unaligned.h> #include "tpm.h" enum tpm_const {
@@ -50,6 +58,8 @@ enum tpm_duration {static LIST_HEAD (tpm_chip_list);static DEFINE_SPINLOCK (driver_lock); static DECLARE_BITMAP(dev_mask, TPM_NUM_DEVICES); +#define TPM_CHIP_NUM_MASK 0x0000ffff +#define TPM_CHIP_TYPE_SHIFT 16/* * Array with one entry per ordinal defining the maximum amount
@@ -366,8 +376,7 @@ EXPORT_SYMBOL_GPL(tpm_calc_ordinal_durat/* * Internal kernel interface to transmit TPM commands */ -static ssize_t tpm_transmit (struct tpm_chip *chip,const char *buf, -size_t bufsiz) +ssize_t tpm_transmit (struct tpm_chip *chip,char *buf,size_t bufsiz) {ssize_t rc;u32 count, ordinal;
@@ -425,6 +434,7 @@ out:mutex_unlock (&chip->tpm_mutex);return rc; } +EXPORT_SYMBOL_GPL (tpm_transmit);#define TPM_DIGEST_SIZE 20#define TPM_ERROR_SIZE 10
@@ -710,6 +720,7 @@ ssize_t tpm_show_temp_deactivated(struct }EXPORT_SYMBOL_GPL (tpm_show_temp_deactivated); +#define READ_PCR_RESULT_SIZE 30static const u8 pcrread[] = {0 ,193 ,/* TPM_TAG_RQU_COMMAND */ 0 ,0 ,0 ,14 ,/* length */
@@ -765,6 +776,102 @@ out: }EXPORT_SYMBOL_GPL (tpm_show_pcrs); +/* +* tpm_chip_lookup - return tpm_chip for given chip number and type +*/ +static struct tpm_chip *tpm_chip_lookup (int chip_num,int chip_typ) +{ +struct tpm_chip *pos; + +spin_lock (&driver_lock); +list_for_each_entry (pos, &tpm_chip_list, list) { +if ((chip_num ==TPM_ANY_NUM || pos->dev_num == chip_num) + && (chip_typ ==TPM_ANY_TYPE )) { +spin_unlock (&driver_lock); +return pos; + } + } + +spin_unlock (&driver_lock); +return NULL ; +} + +/** +* tpm_pcr_read - read a pcr value +* @chip_id: tpm chip identifier +* Upper 2 bytes: ANY, HW_ONLY or SW_ONLY +* Lower 2 bytes: tpm idx # or AN& +* @pcr_idx: pcr idx to retrieve +* @res_buf: TPM_PCR value +* size of res_buf is 20 bytes (or NULL if you don't care) +*/ +int tpm_pcr_read (u32 chip_id,int pcr_idx,u8 *res_buf) +{ +u8 data[READ_PCR_RESULT_SIZE ]; +int rc; +__be32 index; +int chip_num = chip_id &TPM_CHIP_NUM_MASK ; +struct tpm_chip *chip; + + chip =tpm_chip_lookup (chip_num, chip_id >>TPM_CHIP_TYPE_SHIFT ); +if (chip ==NULL ) +return -ENODEV ; +BUILD_BUG_ON (sizeof (pcrread) >READ_PCR_RESULT_SIZE ); +memcpy (data, pcrread,sizeof (pcrread)); + index =cpu_to_be32 (pcr_idx); +memcpy (data +10 , &index,4 ); + rc =tpm_transmit (chip, data,sizeof (data)); +if (rc >0 ) + rc =get_unaligned_be32 ((__be32 *) (data +6 )); + +if (rc ==0 && res_buf) +memcpy (res_buf, data +10 ,TPM_DIGEST_SIZE ); + +return rc; + +} +EXPORT_SYMBOL_GPL (tpm_pcr_read); + +#define EXTEND_PCR_SIZE 34 +static const u8 pcrextend[] = { +0 ,193 ,/* TPM_TAG_RQU_COMMAND */ +0 ,0 ,0 ,34 ,/* length */ +0 ,0 ,0 ,20 ,/* TPM_ORD_Extend */ +0 ,0 ,0 ,0 /* PCR index */ +}; + +/** +* tpm_pcr_extend - extend pcr value with hash +* @chip_id: tpm chip identifier +* Upper 2 bytes: ANY, HW_ONLY or SW_ONLY +* Lower 2 bytes: tpm idx # or AN& +* @pcr_idx: pcr idx to extend +* @hash: hash value used to extend pcr value +*/ +int tpm_pcr_extend (u32 chip_id,int pcr_idx,const u8 *hash) +{ +u8 data[EXTEND_PCR_SIZE ]; +int rc; +__be32 index; +int chip_num = chip_id &TPM_CHIP_NUM_MASK ; +struct tpm_chip *chip; + + chip =tpm_chip_lookup (chip_num, chip_id >>TPM_CHIP_TYPE_SHIFT ); +if (chip ==NULL ) +return -ENODEV ; + +BUILD_BUG_ON (sizeof (pcrextend) >EXTEND_PCR_SIZE ); +memcpy (data, pcrextend,sizeof (pcrextend)); + index =cpu_to_be32 (pcr_idx); +memcpy (data +10 , &index,4 ); +memcpy (data +14 , hash,TPM_DIGEST_SIZE ); + rc =tpm_transmit (chip, data,sizeof (data)); +if (rc >0 ) + rc =get_unaligned_be32 ((__be32 *) (data +6 )); +return rc; +} +EXPORT_SYMBOL_GPL (tpm_pcr_extend); +#define READ_PUBEK_RESULT_SIZE 314static const u8 readpubek[] = {0 ,193 ,/* TPM_TAG_RQU_COMMAND */
drivers/char/tpm/tpm.h +3 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2004 IBM Corporation +* Copyright (C) 2004, 2007 IBM Corporation * * Authors: * Leendert van Doorn <[email protected]>
@@ -26,6 +26,7 @@#include <linux/miscdevice.h> #include <linux/platform_device.h> #include <linux/io.h> +#include <linux/tpm.h> enum tpm_timeout {TPM_TIMEOUT =5 ,/* msecs */
@@ -128,6 +129,7 @@ extern void tpm_get_timeouts(struct tpm_extern void tpm_gen_interrupt (struct tpm_chip *);extern void tpm_continue_selftest (struct tpm_chip *);extern unsigned long tpm_calc_ordinal_duration (struct tpm_chip *,u32 ); +ssize_t tpm_transmit (struct tpm_chip *chip,char *buf,size_t bufsiz);extern struct tpm_chip *tpm_register_hardware (struct device *,const struct tpm_vendor_specific *);extern int tpm_open (struct inode *,struct file *);
include/linux/tpm.h new file +49 -0
49 lines not on this page · raw message
PATCH 2/4 integrity: special fs magic
In reply to a message not in the archive - Move special fs magic number definitions to magic.h
- Add magic.h include
fs/debugfs/inode.c +1 -2
@@ -26,8 +26,7 @@#include <linux/debugfs.h> #include <linux/fsnotify.h> #include <linux/string.h> - -#define DEBUGFS_MAGIC 0x64626720 +#include <linux/magic.h> static struct vfsmount *debugfs_mount;static int debugfs_mount_count;
include/linux/magic.h +4 -0
@@ -6,6 +6,10 @@#define AFS_SUPER_MAGIC 0x5346414F#define AUTOFS_SUPER_MAGIC 0x0187#define CODA_SUPER_MAGIC 0x73757245 +#define DEBUGFS_MAGIC 0x64626720 +#define SYSFS_MAGIC 0x62656572 +#define SECURITYFS_MAGIC 0x73636673 +#define TMPFS_MAGIC 0x01021994#define EFS_SUPER_MAGIC 0x414A53#define EXT2_SUPER_MAGIC 0xEF53#define EXT3_SUPER_MAGIC 0xEF53
mm/shmem.c +1 -3
@@ -50,14 +50,12 @@#include <linux/migrate.h> #include <linux/highmem.h> #include <linux/seq_file.h> +#include <linux/magic.h> #include <asm/uaccess.h> #include <asm/div64.h> #include <asm/pgtable.h> -/* This magic number is used in glibc for posix shared memory */ -#define TMPFS_MAGIC 0x01021994 -#define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))#define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)#define BLOCKS_PER_PAGE (PAGE_CACHE_SIZE/512)
security/inode.c +1 -2
@@ -20,8 +20,7 @@#include <linux/init.h> #include <linux/namei.h> #include <linux/security.h> - -#define SECURITYFS_MAGIC 0x73636673 +#include <linux/magic.h> static struct vfsmount *mount;static int mount_count;
PATCH 3/4 integrity: Linux Integrity Module(LIM)
In reply to a message not in the archive This version resolves the merge issues resulting from the removal of the nameidata parameter to inode_permission().
- Moved the integrity_inode_permission() call from inode_permission() to vfs_inode_permission() and file_inode_permission().
- Replaced the inode and nameidata parameters with file and path parameters to integrity_inode_permission().
This patch is a redesign of the integrity framework, which address a number of issues, including
- generalizing the measurement API beyond just inode measurements.
- separation of the measurement into distinct collection, appraisal, and commitment phases, for greater flexibility.
Extended Verification Module(EVM) and the Integrity Measurement Architecture(IMA) were originally implemented as an LSM module. Based on discussions on the LSM mailing list, a decision was made that the LSM hooks should only be used to enforce mandatory access control decisions and a new set of hooks should be defined specifically for integrity.
EVM/IMA was limited to verifying and measuring a file's (i.e. an inode) integrity and the metadata associated with it. Current research is looking into other types of integrity measurements. (i.e. "Linux kernel integrity measurement using contextual inspection", by Peter A. Loscocco, Perry W. Wilson, J. Aaron Pendergrass, C. Durward McDonell,
http://doi.acm.org/10.1145/1314354.1314362). As a result, a requirement of the new integrity framework is support for different types of integrity measurements.
This patch provides an integrity framework(api and hooks) and placement of the integrity hooks in the appropriate places in the fs directory. Collecting, appraising, and storing of file and other types of integrity data is supported. Multiple integrity templates, which implement the integrity API, may register themselves. For now, only a single integrity provider can register itself for the integrity hooks. (Support for multiple providers registering themselves for the integrity hooks would require some form of stacking.)
The six integrity hooks are:
inode_permission, inode_alloc_integrity, inode_free_integrity, bprm_check_integrity, file_free_integrity, file_mmap
The five integrity API calls provided are:
integrity_must_measure, integrity_collect_measurement, integrity_appraise_measurement, integrity_store_measurement, and integrity_display_template.
The type of integrity data being collected, appraised, stored, or displayed is template dependent.
(Details on the calls and their exact arguments are in linux/integrity.h, included in the patch.)
Documentation/kernel-parameters.txt +6 -0
@@ -44,6 +44,7 @@ parameter is applicable: FB The frame buffer device is enabled. HW Appropriate hardware is enabled. IA-64 IA-64 architecture is enabled. + INTEGRITY Integrity support is enabled. IOSCHED More than one I/O scheduler is enabled. IP_PNP IP DHCP, BOOTP, or RARP is enabled. ISAPNP ISA PnP code is enabled.
@@ -878,6 +879,11 @@ and is between 256 and 4096 characters. inport.irq= [HW] Inport (ATI XL and Microsoft) busmouse driver Format: <irq> + integrity_audit= [INTEGRITY] + Format: { "0" | "1" } + 0 -- disable integrity auditing messages. + 1 -- enable integrity auditing messages. (Default) + inttest= [IA64] iommu= [x86]
fs/exec.c +4 -0
@@ -45,6 +45,7 @@#include <linux/proc_fs.h> #include <linux/mount.h> #include <linux/security.h> +#include <linux/integrity.h> #include <linux/syscalls.h> #include <linux/tsacct_kern.h> #include <linux/cn_proc.h>
@@ -1204,6 +1205,9 @@ int search_binary_handler(struct linux_b retval =security_bprm_check (bprm);if (retval)return retval; + retval =integrity_bprm_check (bprm); +if (retval) +return retval;/* kernel module loader fixup */ /* so we don't try to load run modprobe in kernel space. */
fs/file_table.c +3 -0
@@ -13,6 +13,7 @@#include <linux/module.h> #include <linux/fs.h> #include <linux/security.h> +#include <linux/integrity.h> #include <linux/eventpoll.h> #include <linux/rcupdate.h> #include <linux/mount.h>
@@ -272,6 +273,7 @@ void __fput(struct file *file)if (file->f_op && file->f_op->release) file->f_op->release (inode, file);security_file_free (file); +integrity_file_free (file);if (unlikely (S_ISCHR (inode->i_mode) && inode->i_cdev !=NULL ))cdev_put (inode->i_cdev);fops_put (file->f_op);
@@ -343,6 +345,7 @@ void put_filp(struct file *file) {if (atomic_long_dec_and_test (&file->f_count)) {security_file_free (file); +integrity_file_free (file);file_kill (file);file_free (file); }
fs/inode.c +11 -0
@@ -17,6 +17,7 @@#include <linux/hash.h> #include <linux/swap.h> #include <linux/security.h> +#include <linux/integrity.h> #include <linux/pagemap.h> #include <linux/cdev.h> #include <linux/bootmem.h>
@@ -151,6 +152,15 @@ static struct inode *alloc_inode(structreturn NULL ; } +/* allocate, attach and initialize an i_integrity */ +if (integrity_inode_alloc (inode)) { +if (inode->i_sb->s_op->destroy_inode) + inode->i_sb->s_op->destroy_inode (inode); +else +kmem_cache_free (inode_cachep, (inode)); +return NULL ; + } +spin_lock_init (&inode->i_lock);lockdep_set_class (&inode->i_lock, &sb->s_type->i_lock_key);
@@ -190,6 +200,7 @@ void destroy_inode(struct inode *inode) {BUG_ON (inode_has_buffers (inode));security_inode_free (inode); +integrity_inode_free (inode);if (inode->i_sb->s_op->destroy_inode) inode->i_sb->s_op->destroy_inode (inode);else
fs/namei.c +17 -2
@@ -24,6 +24,7 @@#include <linux/fsnotify.h> #include <linux/personality.h> #include <linux/security.h> +#include <linux/integrity.h> #include <linux/syscalls.h> #include <linux/mount.h> #include <linux/audit.h>
@@ -289,7 +290,14 @@ int inode_permission(struct inode *inode*/ int vfs_permission (struct nameidata *nd,int mask) { -return inode_permission (nd->path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (nd->path.dentry->d_inode, mask); +if (retval) +return retval; +return integrity_inode_permission (NULL , &nd->path, + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC )); }/**
@@ -306,7 +314,14 @@ int vfs_permission(struct nameidata *nd,*/ int file_permission (struct file *file,int mask) { -return inode_permission (file->f_path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (file->f_path.dentry->d_inode, mask); +if (retval) +return retval; +return integrity_inode_permission (file,NULL , + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC )); }/*
include/linux/audit.h +8 -0
@@ -123,6 +123,11 @@#define AUDIT_LAST_KERN_ANOM_MSG 1799#define AUDIT_ANOM_PROMISCUOUS 1700/* Device changed promiscuous mode */ #define AUDIT_ANOM_ABEND 1701/* Process ended abnormally */ +#define AUDIT_INTEGRITY_DATA 1800/* Data integrity verification */ +#define AUDIT_INTEGRITY_METADATA 1801/* Metadata integrity verification */ +#define AUDIT_INTEGRITY_STATUS 1802/* Integrity enable status */ +#define AUDIT_INTEGRITY_HASH 1803/* Integrity HASH type */ +#define AUDIT_INTEGRITY_PCR 1804/* PCR invalidation msgs */ #define AUDIT_KERNEL 2000/* Asynchronous audit record. NOT A REQUEST. */
@@ -440,6 +445,8 @@ extern int audit_set_loginuid(struct ta#define audit_get_loginuid (t) ((t)->loginuid)#define audit_get_sessionid (t) ((t)->sessionid)extern void audit_log_task_context (struct audit_buffer *ab); +extern void audit_log_inode_context (struct audit_buffer *ab, +struct inode *inode);extern int __audit_ipc_obj (struct kern_ipc_perm *ipcp);extern int __audit_ipc_set_perm (unsigned long qbytes,uid_t uid,gid_t gid,mode_t mode);extern int audit_bprm (struct linux_binprm *bprm);
@@ -520,6 +527,7 @@ extern int audit_signals;#define audit_get_loginuid (t) (-1)#define audit_get_sessionid (t) (-1)#define audit_log_task_context (b) do { ; } while (0) +#define audit_log_inode_context (b, a) do { } while (0)#define audit_ipc_obj (i) ({ 0; })#define audit_ipc_set_perm (q,u,g,m) ({ 0; })#define audit_bprm (p) ({ 0; })
include/linux/fs.h +3 -0
@@ -680,6 +680,9 @@ struct inode {#ifdef CONFIG_SECURITY void *i_security;#endif +#ifdef CONFIG_INTEGRITY +void *i_integrity; +#endif void *i_private;/* fs or device private pointer */ };
include/linux/integrity.h new file +184 -0
184 lines not on this page · raw message
mm/mmap.c +4 -0
@@ -20,6 +20,7 @@#include <linux/fs.h> #include <linux/personality.h> #include <linux/security.h> +#include <linux/integrity.h> #include <linux/hugetlb.h> #include <linux/profile.h> #include <linux/module.h>
@@ -1046,6 +1047,9 @@ unsigned long do_mmap_pgoff(struct file error =security_file_mmap (file, reqprot, prot, flags, addr,0 );if (error)return error; + error =integrity_file_mmap (file, prot); +if (error) +return error;return mmap_region (file, addr, len, flags, vm_flags, pgoff, accountable);
security/Kconfig +2 -0
@@ -4,6 +4,8 @@ menu "Security options" +source security/integrity/Kconfig + config KEYS bool "Enable access key retention support" help
security/Makefile +4 -0
@@ -16,3 +16,7 @@ obj-$(CONFIG_SECURITY_SELINUX) += selin obj-$(CONFIG_SECURITY_SMACK) += smack/built-in.o obj-$(CONFIG_SECURITY_ROOTPLUG) += root_plug.o obj-$(CONFIG_CGROUP_DEVICE) += device_cgroup.o + +# Object integrity file lists +subdir-$(CONFIG_INTEGRITY) += integrity +obj-$(CONFIG_INTEGRITY) += integrity/built-in.o
security/integrity/Kconfig new file +24 -0
@@ -0,0 +1,24 @@ +# +# Integrity configuration +# + +menu "Integrity options" + +config INTEGRITY + bool "Enable different integrity models" + help + This allows you to choose different integrity modules to be + configured into your kernel. + + If you are unsure how to answer this question, answer N. + +config INTEGRITY_AUDIT + bool "Integrity audit boot parameter" + depends on INTEGRITY + default y + help + This option adds a kernel parameter 'integrity_audit', which + allows integrity auditing to be disabled at boot. If this + option is selected, integrity auditing can be disabled with + 'integrity_audit=0' on the kernel command line. +endmenu
security/integrity/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# +# Makefile for the kernel integrity code +# + +# Object file lists +obj-$(CONFIG_INTEGRITY) += integrity.o integrity_audit.o
security/integrity/integrity.c new file +306 -0
306 lines not on this page · raw message
security/integrity/integrity_audit.c new file +79 -0
79 lines not on this page · raw message
PATCH 4/4 integrity: IMA as an integrity service provider
In reply to a message not in the archiveThis is a re-release of Integrity Measurement Architecture(IMA) as an independent Linunx Integrity Module(LIM) service provider.
This version addresses the merge issues resulting from the removal of the nameidata parameter to inode_permission().
- The parameter changes to integrity_inode_permission() are reflected here in this patch.
and extends the measurement policy definition language, based on comments at OLS.
- Added policy support for LSM subj_role, subj_type, and obj_role.
- Added policy support for uid.
- Constrained the default INODE_PERMISSION measurement to only measure files opened for read by root, using uid.
and addresses linux-next testing issues: (updated)
- Updated security/integrity/ima/Kconfig for LSM measurement policy
- Added dummy security_filter_rule_init/match routines for when no LSM is configured.
This version addresses a number of issues discussed on LKML, including:
- Corrects the atomic_long_t variable usage, to use the appropriate atomic_long calls.
- Added Documentation/ABI/testing/ima_policy which describes loading the IMA measurement policy.
- Added policy support for magic numbers and removed them from skip_measurement().
- Added policy support for LSM obj_type.
- Replaced using .i_mtime to detect when a file has been modified with .i_version. This requires the filesystem to be mounted with iversion. (Requires iversion mount support.)
- Added const for integrity_template_operations.
- Removed integrity_fixup_ops(), to make integrity_operations const too.
- Removed ima_fixup_inodes() by registering the integrity_ops early in security_initcall(), but waiting to start IMA in late_initcall(), until after the TPM is available.
- Removed CONFIG_IMA_BOOTPARAM and CONFIG_IMA_BOOTPARAM_VALUE.
- Replaced,as appropriate, all GFP_ATOMICs with GFP_KERNEL.
As a LIM integrity provider, IMA implements the new LIM must_measure(), collect_measurement(), store_measurement(), and display_template() API calls. The store_measurement() call supports two types of data, IMA (i.e. file data) and generic template data.
IMA provides hardware (TPM) based measurement and attestation for both files and other types of template measurements. As the Trusted Computing (TPM) model requires, IMA measures all files before they are accessed in any way (on the bprm_check_integrity, file_mmap and inode_permission hooks), and commits the measurements to the TPM. In addition, IMA maintains a list of these hash values, which can be used to validate the aggregate PCR value. The TPM can sign these measurements, and thus the system can prove to itself and to a third party these measurements in a way that cannot be circumvented by malicious or compromised software.
When store_measurement() is called for the IMA type of data, the file measurement and the file name hint are used to form an IMA template. IMA then calculates the IMA template measurement(hash) and submits it to the TPM chip for inclusion in one of the chip's Platform Configuration Registers (PCR).
When store_measurement() is called for generic template data, IMA calculates the measurement(hash) of the template data, and submits the template measurement to the TPM chip for inclusion in one of the chip's Platform Configuration Registers(PCR).
In order to view the contents of template data through securityfs, the template_display() function must be defined in the registered template_operations. In the case of the IMA template, the list of file names and files hashes submitted can be viewed through securityfs.
As mentioned above, IMA maintains a list of hash values of executables and other sensitive system files loaded into the run-time of the system. Our work has shown that requests for integrity appraisal and measurement need to be based on knowledge of the filesystem, requiring the system to either be labeled with integrity data or depend on the existent LSM security labels. The previous set of integrity patches modified the LSM modules to be integrity context aware, meaning that the LSM modules made integrity data/metadata appraisal and measurement API calls based on an understanding of the LSM security labels. Both of the LSM maintainers felt that the changes were too intrusive and that integrity enforcement should be made by the integrity provider, not the LSM module.
To address these concerns, Stephen Smalley suggested using the security_audit_rule_match(), renamed to security_filter_rule_match(), to define LSM specific integrity measurement policy rules, in lieu of modifying the LSM modules. In the current set of patches, the integrity API calls can be made either by IMA, based on an LSM specific integrity policy, or by an integrity context aware LSM.
Documentation/ABI/testing/ima_policy new file +60 -0
@@ -0,0 +1,60 @@ +What: security/ima/policy +Date: May 2008 +Contact: Mimi Zohar <[email protected]> +Description: + The Trusted Computing Group(TCG) runtime Integrity + Measurement Architecture(IMA) maintains a list of hash + values of executables and other sensitive system files + loaded into the run-time of this system. At runtime, + the policy can be constrained based on LSM specific data. + Policies are loaded into security/ima/policy by opening + the file, writing the rules one at a time and then + closing the file. The new policy takes effect after + the security/ima/policy is closed. + + rule format: action [condition ...] + + action: measure | dont_measure + condition:= base | lsm + base: [[func=] [mask=] [fsmagic=] [uid=]] + lsm: [[subj_user=] [subj_role=] [subj_type=] + [obj_user=] [obj_role=] [obj_type=]] + + base: func:= [BPRM_CHECK][FILE_MMAP][INODE_PERMISSION] + mask:= [MAY_READ] [MAY_WRITE] [MAY_APPEND] [MAY_EXEC] + fsmagic:= hex value + uid:= decimal value + lsm: are LSM specific + + default policy: + # PROC_SUPER_MAGIC + dont_measure fsmagic=0x9fa0 + # SYSFS_MAGIC + dont_measure fsmagic=0x62656572 + # DEBUGFS_MAGIC + dont_measure fsmagic=0x64626720 + # TMPFS_MAGIC + dont_measure fsmagic=0x01021994 + # SECURITYFS_MAGIC + dont_measure fsmagic=0x73636673 + # SELINUX_MAGIC + dont_measure fsmagic=0xF97CFF8C + + measure func=BPRM_CHECK + measure func=FILE_MMAP mask=MAY_EXEC + measure func=INODE_PERM mask=MAY_READ uid=0 + + The default policy measures all executables in bprm_check, + all files mmapped executable in file_mmap, and all files + open for read by root in inode_permission. + + Examples of LSM specific definitions: + + SELinux: + dont_measure obj_type=var_log_t + dont_measure obj_type=auditd_log_t + measure subj_user=system_u func=INODE_PERM mask=MAY_READ + measure subj_role=system_r func=INODE_PERM mask=MAY_READ + + Smack: + measure subj_user=_ func=INODE_PERM mask=MAY_READ
Documentation/kernel-parameters.txt +5 -0
@@ -44,6 +44,7 @@ parameter is applicable: FB The frame buffer device is enabled. HW Appropriate hardware is enabled. IA-64 IA-64 architecture is enabled. + IMA Integrity measurement architecture is enabled. INTEGRITY Integrity support is enabled. IOSCHED More than one I/O scheduler is enabled. IP_PNP IP DHCP, BOOTP, or RARP is enabled.
@@ -862,6 +863,10 @@ and is between 256 and 4096 characters. ihash_entries= [KNL] Set number of hash buckets for inode cache. + ima_hash= [IMA] runtime ability to define hash crypto alg. + Format: { "MD5" | "SHA1" } + Default is "SHA1". + in2000= [HW,SCSI] See header of drivers/scsi/in2000.c.
include/linux/ima.h new file +46 -0
46 lines not on this page · raw message
security/integrity/Kconfig +2 -3
@@ -2,8 +2,6 @@ # Integrity configuration # -menu "Integrity options" - config INTEGRITY bool "Enable different integrity models" help
@@ -21,4 +19,5 @@ config INTEGRITY_AUDIT allows integrity auditing to be disabled at boot. If this option is selected, integrity auditing can be disabled with 'integrity_audit=0' on the kernel command line. -endmenu + +source security/integrity/ima/Kconfig
security/integrity/Makefile +2 -0
@@ -4,3 +4,5 @@ # Object file lists obj-$(CONFIG_INTEGRITY) += integrity.o integrity_audit.o + +obj-$(CONFIG_IMA) += ima/
security/integrity/ima/Kconfig new file +48 -0
48 lines not on this page · raw message
security/integrity/ima/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# +# Makefile for building Trusted Computing Group's(TCG) runtime Integrity +# Measurement Architecture(IMA). +# + +obj-$(CONFIG_IMA) += ima.o + +ima-y := ima_fs.o ima_queue.o ima_init.o ima_main.o ima_crypto.o ima_api.o \ + ima_policy.o
security/integrity/ima/ima.h new file +170 -0
170 lines not on this page · raw message
security/integrity/ima/ima_api.c new file +348 -0
348 lines not on this page · raw message
security/integrity/ima/ima_crypto.c new file +153 -0
153 lines not on this page · raw message
security/integrity/ima/ima_fs.c new file +471 -0
471 lines not on this page · raw message
security/integrity/ima/ima_init.c new file +105 -0
105 lines not on this page · raw message
security/integrity/ima/ima_main.c new file +354 -0
354 lines not on this page · raw message
security/integrity/ima/ima_policy.c new file +330 -0
330 lines not on this page · raw message
security/integrity/ima/ima_queue.c new file +124 -0
124 lines not on this page · raw message
Re: [PATCH 2/4] integrity: special fs magic
In reply to Mimi ZoharQuoted 4 lines · Mimi Zohar
- Move special fs magic number definitions to
magic.h
- Addmagic.hincludeSigned-off-by Mimi Zohar <[email protected]>
Why? What is this patch for? Are you going to do something with these magic values later?
thanks,
greg k-h
Re: [PATCH 2/4] integrity: special fs magic
Quoted 8 lines · Greg KH
Quoted 4 lines · Mimi Zohar
- Move special fs magic number definitions to
magic.h
- Addmagic.hincludeSigned-off-by Mimi Zohar <[email protected]>Why? What is this patch for? Are you going to do something with these magic values later?
Ok, I now see the follow-up patch that does something with them.
You should say so in this patch.
And is it really ok to be doing things from userspace based on a filesystem "magic" key? Those are numbers we have never exported to userspace before, what happens if they are changed?
thanks,
greg k-h
Re: [PATCH 2/4] integrity: special fs magic
In reply to Greg KH[email protected] wrote on 08/08/2008 03:04:48 PM:
Quoted 6 lines
Re: [PATCH 2/4] integrity: special fs magic
Quoted 3 lines · Mimi Zohar
- Move special fs magic number definitions to
magic.h
- Addmagic.hinclude
Quoted 7 lines
Quoted 1 line
Signed-off-by Mimi Zohar <[email protected]>Why? What is this patch for? Are you going to do something with these magic values later?
thanks,
yes, [PATCH 4/4] integrity: IMA as an integrity service provider, uses these definition in defining the default IMA measurement policy. The default policy can be replaced with an LSM specific one. More details on the IMA measurement policy are available in Documentation/ABI/testing/ima_policy.
Mimi
Re: [PATCH 2/4] integrity: special fs magic
In reply to Greg KHGreg KH <[email protected]> wrote on 08/08/2008 03:15:19 PM:
Quoted 8 lines · Greg KH
Quoted 7 lines · Mimi Zohar
Quoted 4 lines
- Move special fs magic number definitions to
magic.h
- Addmagic.hincludeSigned-off-by Mimi Zohar <[email protected]>Why? What is this patch for? Are you going to do something with
these
Quoted 6 lines
Quoted 1 line
magic values later?
Ok, I now see the follow-up patch that does something with them.
You should say so in this patch.
Quoted 7 lines
And is it really ok to be doing things from userspace based on a filesystem "magic" key? Those are numbers we have never exported to userspace before, what happens if they are changed?
thanks,
greg k-h
Userspace only loads the measurement policy (via securityfs), and if a magic number changes, and the policy is not updated to match, then we would end up measuring some filesystems we didn't need to. Before the magic numbers were hard coded in IMA, now at least, it's extensible.
Mimi
Re: [PATCH 4/4] integrity: IMA as an integrity service provider
In reply to Mimi ZoharQuoted 13 lines · On Fri, 08 Aug 2008 14:56:36 -0400 Mimi Zohar wrote:
Index:
security-testing-2.6/Documentation/kernel-parameters.txt
===================================================================Documentation/kernel-parameters.txt +1
-0@@ -44,6 +44,7 @@ parameter is applicable: FB The frame buffer device is enabled. HW Appropriate hardware is enabled. IA-64 IA-64 architecture is enabled. + IMA Integrity measurement architecture is enabled. INTEGRITY Integrity support is enabled. IOSCHED More than one I/O scheduler is enabled. IP_PNP IP DHCP, BOOTP, or RARP is enabled.
Documentation/kernel-parameters.txt and is between 256 and 4096 characters. · line 866
Quoted 4 lines
Documentation/kernel-parameters.txt +1
-0@@ -862,6 +863,10 @@ and is between 256 and 4096 characters. ihash_entries= [KNL] Set number of hash buckets for inode cache. + ima_hash= [IMA] runtime ability to define hash crypto alg.
Please spell out algorithm.
Quoted 28 lines
Documentation/kernel-parameters.txt +3
-0+ Format: { "MD5" | "SHA1" } + Default is "SHA1". + in2000= [HW,SCSI] See header of drivers/scsi/in2000.c.Index: security-testing-2.6/security/integrity/ima/Kconfig
===================================================================security/integrity/ima/Kconfig new file +17
-0@@ -0,0 +1,48 @@ +# +# IBM Integrity Measurement Architecture +# + +config IMA + bool "Integrity Measurement Architecture(IMA)" + depends on INTEGRITY + depends on ACPI + select CRYPTO + select CRYPTO_HMAC + select CRYPTO_MD5 + select CRYPTO_SHA1 + select TCG_TPM + select TCG_TIS + help + The Trusted Computing Group(TCG) runtime Integrity + Measurement Architecture(IMA) maintains a list of hash
security/integrity/ima/Kconfig line 27
Quoted 10 lines
security/integrity/ima/Kconfig new file +10
-0+ values of executables and other sensitive system files + loaded into the run-time of this system. If your system + has a TPM chip, then IMA also maintains an aggregate + integrity value over this list inside the TPM hardware. + These measurements and the aggregate (signed inside the + TPM) can be retrieved and presented to remote parties to + establish system properties. If unsure, say N. + +config IMA_MEASURE_PCR_IDX + int "PCR for Aggregate (8<= Index <= 14)"
Use consistent spacing (8 <= Index <= 14).
Quoted 11 lines
security/integrity/ima/Kconfig new file +11
-0+ depends on IMA + range 8 14 + default 10 + help + IMA_MEASURE_PCR_IDX determines the TPM PCR register index + that IMA uses to maintain the integrity aggregate of the + measurement list. If unsure, use the default 10. + +config IMA_BASE_HOOKS + bool "IMA base hooks" + depends on IMA
security/integrity/ima/Kconfig line 48
Quoted 10 lines
security/integrity/ima/Kconfig new file +10
-0+ default n + help + Enable this option to allow the LSM module to enforce integrity. + +config IMA_LSM_RULES + bool "Enable LSM measurement policy rules" + depends on IMA && (SELINUX || SMACK) + default y + help + Disabling this option will not enforce LSM based policy rules.
---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/
Re: [PATCH 2/4] integrity: special fs magic
In reply to Mimi ZoharQuoted 21 lines · Mimi Zohar
Greg KH <[email protected]> wrote on 08/08/2008 03:15:19 PM:
Quoted 8 lines · Greg KH
Quoted 7 lines · Mimi Zohar
Quoted 4 lines
- Move special fs magic number definitions to
magic.h
- Addmagic.hincludeSigned-off-by Mimi Zohar <[email protected]>Why? What is this patch for? Are you going to do something with
these
Quoted 10 lines
Quoted 1 line
magic values later?
Ok, I now see the follow-up patch that does something with them.
You should say so in this patch.
And is it really ok to be doing things from userspace based on a filesystem "magic" key? Those are numbers we have never exported to userspace before, what happens if they are changed?
Quoted 8 lines
Quoted 3 lines
thanks,
greg k-h
Userspace only loads the measurement policy (via securityfs), and if a magic number changes, and the policy is not updated to match, then we would end up measuring some filesystems we didn't need to. Before the magic numbers were hard coded in IMA, now at least, it's extensible.
Why not just use a name then instead? That way if the number changes within the kernel, then it will always be right.
thanks,
greg k-h
Re: [PATCH 2/4] integrity: special fs magic
In reply to Mimi ZoharQuoted 2 lines · Mimi Zohar
- Move special fs magic number definitions to
magic.h
- Addmagic.hinclude
Moving them is fine, using them for anything however is not.
drivers/char/tpm/tpm.c out: · line 795
Quoted 13 lines
drivers/char/tpm/tpm.c +13
-0+{ +struct tpm_chip *pos; + +spin_lock (&driver_lock); +list_for_each_entry (pos, &tpm_chip_list, list) { +if ((chip_num ==TPM_ANY_NUM || pos->dev_num == chip_num) + && (chip_typ ==TPM_ANY_TYPE )) { +spin_unlock (&driver_lock); +return pos; + } + } + +spin_unlock (&driver_lock);
besides the usual coding style issues, what protects the chip from going away afer you dropped the lock?
Re: [PATCH 2/4] integrity: special fs magic
In reply to Greg KHQuoted 10 lines · Greg KH
Quoted 8 lines · Greg KH
Quoted 4 lines · Mimi Zohar
- Move special fs magic number definitions to
magic.h
- Addmagic.hincludeSigned-off-by Mimi Zohar <[email protected]>Why? What is this patch for? Are you going to do something with these magic values later?
Quoted 7 lines
Ok, I now see the follow-up patch that does something with them.
You should say so in this patch.
And is it really ok to be doing things from userspace based on a filesystem "magic" key? Those are numbers we have never exported to userspace before, what happens if they are changed?
These constants re exported to userspace in struct statfs .type and better don't change. Providing the symbolic names for them sounds like a good idea to me. What userspace does with that or not is their business, and if it's utterly stupid it'll be their fault if it doesn't work as expected..
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
In reply to Mimi Zoharfs/inode.c static struct inode *alloc_inode(struct · line 163
Quoted 8 lines
fs/inode.c +8
-0+if (integrity_inode_alloc (inode)) { +if (inode->i_sb->s_op->destroy_inode) + inode->i_sb->s_op->destroy_inode (inode); +else +kmem_cache_free (inode_cachep, (inode)); +return NULL ; + } +
Please factor this and the lsm failure case out into a single out_free_inode goto label.
Quoted 17 lines
int
vfs_permission(struct nameidata *nd, int mask){fs/namei.c +8
-1-return inode_permission (nd->path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (nd->path.dentry->d_inode, mask); +if (retval) +return retval; +return integrity_inode_permission (NULL , &nd->path, + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC )); }/** @@ -306,7 +314,14 @@ int vfs_permission(struct nameidata *nd,*/ int file_permission (struct file *file,int mask)
fs/namei.c int vfs_permission(struct nameidata *nd, · line 324
Quoted 10 lines
fs/namei.c +8
-1{ -return inode_permission (file->f_path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (file->f_path.dentry->d_inode, mask); +if (retval) +return retval; +return integrity_inode_permission (file,NULL , + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC ));
Please put your hook into inode_permission. Note that in inode permission and lots of callers there is no path available so don't pass it. Please pass the full MAY_FOO mask for new interfaces and do filtering that won't break if new ones are introduced.
include/linux/fs.h struct inode { · line 685
Quoted 3 lines
include/linux/fs.h +3
-0+#ifdef CONFIG_INTEGRITY +void *i_integrity; +#endif
Sorry, but I don't think we can bloat the inode even further for this.
Quoted 2 lines
+/*
+ *integrity.h
don't bother to mention the filename in the top of file comment.
Re: [PATCH 2/4] integrity: special fs magic
In reply to Christoph HellwigChristoph Hellwig <[email protected]> wrote on 08/09/2008 02:47:59 PM:
Quoted 9 lines · Greg KH
Quoted 8 lines · Greg KH
Quoted 7 lines · Mimi Zohar
Quoted 4 lines
- Move special fs magic number definitions to
magic.h
- Addmagic.hincludeSigned-off-by Mimi Zohar <[email protected]>Why? What is this patch for? Are you going to do something with
these
Quoted 10 lines
Quoted 9 lines
Quoted 1 line
magic values later?
Ok, I now see the follow-up patch that does something with them.
You should say so in this patch.
And is it really ok to be doing things from userspace based on a filesystem "magic" key? Those are numbers we have never exported to userspace before, what happens if they are changed?
Quoted 5 lines
These constants re exported to userspace in struct statfs .type and better don't change. Providing the symbolic names for them sounds like a good idea to me. What userspace does with that or not is their business, and if it's utterly stupid it'll be their fault if it doesn't work as expected..
ok.
Mimi
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
In reply to Christoph HellwigChristoph Hellwig <[email protected]> wrote on 08/09/2008 02:53:40 PM:
Quoted 11 lines
fs/inode.c static struct inode *alloc_inode(struct · line 163
Quoted 8 lines
fs/inode.c +8
-0+if (integrity_inode_alloc (inode)) { +if (inode->i_sb->s_op->destroy_inode) + inode->i_sb->s_op->destroy_inode (inode); +else +kmem_cache_free (inode_cachep, (inode)); +return NULL ; + } +Please factor this and the lsm failure case out into a single
out_free_inodegoto label.
ok
Quoted 24 lines
Quoted 24 lines
int
vfs_permission(struct nameidata *nd, int mask){fs/namei.c +13
-2-return inode_permission (nd->path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (nd->path.dentry->d_inode, mask); +if (retval) +return retval; +return integrity_inode_permission (NULL , &nd->path, + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC )); }/** @@ -306,7 +314,14 @@ int vfs_permission(struct nameidata *nd,*/ int file_permission (struct file *file,int mask) { -return inode_permission (file->f_path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (file->f_path.dentry->d_inode, mask); +if (retval) +return retval;
Quoted 8 lines
fs/namei.c int vfs_permission(struct nameidata *nd, · line 324
Quoted 3 lines
fs/namei.c +3
-0+return integrity_inode_permission (file,NULL , + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC ));Please put your hook into
inode_permission. Note that in inode permission and lots of callers there is no path available so don't pass it. Please pass the fullMAY_FOOmask for new interfaces and do filtering that won't break if new ones are introduced.
We started out with the integrity_inode_permission() hook call in inode_permission(), but because of the removal of the nameidata parameter in the last merge, based on discussions
http://marc.info/?l=linux-security-module&m=121797845308246&w=2,
the call to integrity_inode_permission() was moved up to the caller, where either a file or path are available. Any suggestions?
Quoted 5 lines
include/linux/fs.h struct inode { · line 685
Quoted 3 lines
include/linux/fs.h +3
-0+#ifdef CONFIG_INTEGRITY +void *i_integrity; +#endif Sorry, but I don't think we can bloat the inode even further for this.
The original version of IMA was LSM based, using i_security. Based on discussions on the LSM mailing list, it was decided that the LSM hooks were meant only for access control. During the same time frame, there was a lot of work done in stacking LSM modules and i_security, but that approach was dropped. It was suggested that we define a separate set of hooks for integrity, which this patch set provides. Caching integrity results is an important aspect. Any suggestions in lieu of defining i_integrity?
Quoted 4 lines
Quoted 2 lines
+/*
+ *integrity.hdon't bother to mention the filename in the top of file comment.
ok
Mimi
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
Quoted 49 lines · Mimi Zohar
Christoph Hellwig <[email protected]> wrote on 08/09/2008 02:53:40 PM:
Quoted 11 lines
fs/inode.c static struct inode *alloc_inode(struct · line 163
Quoted 8 lines
fs/inode.c +8
-0+if (integrity_inode_alloc (inode)) { +if (inode->i_sb->s_op->destroy_inode) + inode->i_sb->s_op->destroy_inode (inode); +else +kmem_cache_free (inode_cachep, (inode)); +return NULL ; + } +Please factor this and the lsm failure case out into a single
out_free_inodegoto label.ok
Quoted 24 lines
Quoted 24 lines
int
vfs_permission(struct nameidata *nd, int mask){fs/namei.c +13
-2-return inode_permission (nd->path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (nd->path.dentry->d_inode, mask); +if (retval) +return retval; +return integrity_inode_permission (NULL , &nd->path, + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC )); }/** @@ -306,7 +314,14 @@ int vfs_permission(struct nameidata *nd,*/ int file_permission (struct file *file,int mask) { -return inode_permission (file->f_path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (file->f_path.dentry->d_inode, mask); +if (retval) +return retval;Quoted 8 lines
fs/namei.c int vfs_permission(struct nameidata *nd, · line 324
Quoted 3 lines
fs/namei.c +3
-0+return integrity_inode_permission (file,NULL , + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC ));Please put your hook into
inode_permission. Note that in inode permission and lots of callers there is no path available so don't pass it. Please pass the fullMAY_FOOmask for new interfaces and do filtering that won't break if new ones are introduced.
Quoted 6 lines
We started out with the
integrity_inode_permission()hook call ininode_permission(), but because of the removal of the nameidata parameter in the last merge, based on discussions
http://marc.info/?l=linux-security-module&m=121797845308246&w=2,
the call tointegrity_inode_permission()was moved up to the caller, where either a file or path are available. Any suggestions?
Mimi, can you explain exactly (and concisely) what you are doing with the pathname?
Quoted 6 lines
Quoted 5 lines
include/linux/fs.h struct inode { · line 685
Quoted 3 lines
include/linux/fs.h +3
-0+#ifdef CONFIG_INTEGRITY +void *i_integrity; +#endif Sorry, but I don't think we can bloat the inode even further for this.
Quoted 8 lines
The original version of IMA was LSM based, using
i_security. Based on discussions on the LSM mailing list, it was decided that the LSM hooks were meant only for access control. During the same time frame, there was a lot of work done in stacking LSM modules andi_security, but that approach was dropped. It was suggested that we define a separate set of hooks for integrity, which this patch set provides. Caching integrity results is an important aspect. Any suggestions in lieu of definingi_integrity?
The i_integrity is only bloating the inode if LIM is enabled. Surely that beats having LIM define its own hash table and locking to track integrity labels on inodes? Do you have another suggestion?
Or is the concern about having more #ifdefs in the struct inode definition?
-serge
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
[email protected] wrote on 08/11/2008 01:02:55 PM:
Quoted 24 lines · Mimi Zohar
Quoted 23 lines
Christoph Hellwig <[email protected]> wrote on 08/09/2008 02:53:40 PM:
Quoted 22 lines
Quoted 22 lines
int
vfs_permission(struct nameidata *nd, int mask){fs/namei.c +11
-2-return inode_permission (nd->path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (nd->path.dentry->d_inode, mask); +if (retval) +return retval; +return integrity_inode_permission (NULL , &nd->path, + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC )); }/** @@ -306,7 +314,14 @@ int vfs_permission(struct nameidata *nd,*/ int file_permission (struct file *file,int mask) { -return inode_permission (file->f_path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (file->f_path.dentry->d_inode, mask);
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
fs/namei.c int vfs_permission(struct nameidata *nd, · line 324
Quoted 5 lines
fs/namei.c +5
-0+if (retval) +return retval; +return integrity_inode_permission (file,NULL , + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC ));Please put your hook into
inode_permission. Note that in inode permission and lots of callers there is no path available so don't
pass
Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
it. Please pass the full
MAY_FOOmask for new interfaces and do filtering that won't break if new ones are introduced.We started out with the
integrity_inode_permission()hook call ininode_permission(), but because of the removal of the nameidata parameter in the last merge, based on discussions
http://marc.info/?l=linux-security-module&m=121797845308246&w=2,
the call tointegrity_inode_permission()was moved up to the caller, where either a file or path are available. Any suggestions?
Quoted 2 lines
Mimi, can you explain exactly (and concisely) what you are doing with the pathname?
IMA maintains a list of hash values of system sensitive files loaded into the run-time of the system and extends a PCR with the hash value. In order to calculate this hash value, IMA requires access to either the file or the path, which currently is not accessible in inode_permission().
Mimi
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
Quoted 45 lines · Mimi Zohar
[email protected] wrote on 08/11/2008 01:02:55 PM:
Quoted 24 lines · Mimi Zohar
Quoted 23 lines
Christoph Hellwig <[email protected]> wrote on 08/09/2008 02:53:40 PM:
Quoted 22 lines
Quoted 22 lines
int
vfs_permission(struct nameidata *nd, int mask){fs/namei.c +11
-2-return inode_permission (nd->path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (nd->path.dentry->d_inode, mask); +if (retval) +return retval; +return integrity_inode_permission (NULL , &nd->path, + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC )); }/** @@ -306,7 +314,14 @@ int vfs_permission(struct nameidata *nd,*/ int file_permission (struct file *file,int mask) { -return inode_permission (file->f_path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (file->f_path.dentry->d_inode, mask);Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
fs/namei.c int vfs_permission(struct nameidata *nd, · line 324
Quoted 5 lines
fs/namei.c +5
-0+if (retval) +return retval; +return integrity_inode_permission (file,NULL , + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC ));Please put your hook into
inode_permission. Note that in inode permission and lots of callers there is no path available so don'tpass
Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
it. Please pass the full
MAY_FOOmask for new interfaces and do filtering that won't break if new ones are introduced.We started out with the
integrity_inode_permission()hook call ininode_permission(), but because of the removal of the nameidata parameter in the last merge, based on discussions
http://marc.info/?l=linux-security-module&m=121797845308246&w=2,
the call tointegrity_inode_permission()was moved up to the caller, where either a file or path are available. Any suggestions?
Quoted 8 lines
Quoted 2 lines
Mimi, can you explain exactly (and concisely) what you are doing with the pathname?
IMA maintains a list of hash values of system sensitive files loaded into the run-time of the system and extends a PCR with the hash value. In order to calculate this hash value, IMA requires access to either the file or the path, which currently is not accessible in
inode_permission().
So the usual question is, if I've done
ln -s /etc/shadow /tmp/shadow
will IMA do the right thing if I'm opening /tmp/shadow? Or will it only catch any writes I've done the next time someone (i.e. passwd) opens /etc/shadow?
thanks,
-serge
Christoph Hellwig <[email protected]> wrote on 08/09/2008 02:46:22 PM:
Quoted 8 lines
Quoted 8 lines
drivers/char/tpm/tpm.c +8
-0+{ +struct tpm_chip *pos; + +spin_lock (&driver_lock); +list_for_each_entry (pos, &tpm_chip_list, list) { +if ((chip_num ==TPM_ANY_NUM || pos->dev_num == chip_num) + && (chip_typ ==TPM_ANY_TYPE )) { +spin_unlock (&driver_lock);
Quoted 9 lines
drivers/char/tpm/tpm.c out: · line 795
Quoted 5 lines
drivers/char/tpm/tpm.c +5
-0+return pos; + } + } + +spin_unlock (&driver_lock);besides the usual coding style issues, what protects the chip from going away afer you dropped the lock?
I assume the concern here is that between looking up the chip and actually
using the chip, the TPM chip is disabled/deactivated. Based on discussions
with Kenneth Goldman, the TCG main specification part2: structures, require
that even if the TPM is disabled/deactivated, the command to extend the PCR
will succeed, but the command to read the PCR will fail with an appropriate
error code.
Mimi
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
In reply to Serge E. HallynQuoted 55 lines · Serge E. Hallyn
Quoted 45 lines · Mimi Zohar
[email protected] wrote on 08/11/2008 01:02:55 PM:
Quoted 24 lines · Mimi Zohar
Quoted 23 lines
Christoph Hellwig <[email protected]> wrote on 08/09/2008 02:53:40 PM:
Quoted 22 lines
Quoted 22 lines
int
vfs_permission(struct nameidata *nd, int mask){fs/namei.c +11
-2-return inode_permission (nd->path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (nd->path.dentry->d_inode, mask); +if (retval) +return retval; +return integrity_inode_permission (NULL , &nd->path, + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC )); }/** @@ -306,7 +314,14 @@ int vfs_permission(struct nameidata *nd,*/ int file_permission (struct file *file,int mask) { -return inode_permission (file->f_path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (file->f_path.dentry->d_inode, mask);Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
fs/namei.c int vfs_permission(struct nameidata *nd, · line 324
Quoted 5 lines
fs/namei.c +5
-0+if (retval) +return retval; +return integrity_inode_permission (file,NULL , + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC ));Please put your hook into
inode_permission. Note that in inode permission and lots of callers there is no path available so don'tpass
Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
it. Please pass the full
MAY_FOOmask for new interfaces and do filtering that won't break if new ones are introduced.We started out with the
integrity_inode_permission()hook call ininode_permission(), but because of the removal of the nameidata parameter in the last merge, based on discussions
http://marc.info/?l=linux-security-module&m=121797845308246&w=2,
the call tointegrity_inode_permission()was moved up to the caller, where either a file or path are available. Any suggestions?Quoted 8 lines
Quoted 2 lines
Mimi, can you explain exactly (and concisely) what you are doing with the pathname?
IMA maintains a list of hash values of system sensitive files loaded into the run-time of the system and extends a PCR with the hash value. In order to calculate this hash value, IMA requires access to either the file or the path, which currently is not accessible in
inode_permission().
Quoted 8 lines
So the usual question is, if I've done
ln -s/etc/shadow/tmp/shadow
will IMA do the right thing if I'm opening/tmp/shadow? Or will it only catch any writes I've done the next time someone (i.e. passwd) opens/etc/shadow?thanks,
-serge
We really do need to get credentials patch in to common store all this permission/secuirty data.. With a section for integrity related entries.
Anti-Virus Passes and fails, signed running programs support and so on.
Lot of different things need ways of recording integrity status's. Users also need to know if a application does not work is it TPM is it Anti-virus is it lack of signature.
A common way of extracting what the blockage has to be the way forward. Since then this can be integrated into file managers and the like. Running like 12 different tools to find what blocked a program is kinda wasteful.
Sorting out this storage is kinda critical. People could be running
a few different integrity systems side by side.
Peter Dolding
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
In reply to Mimi ZoharQuoted 6 lines · Mimi Zohar
We started out with the
integrity_inode_permission()hook call ininode_permission(), but because of the removal of the nameidata parameter in the last merge, based on discussions
http://marc.info/?l=linux-security-module&m=121797845308246&w=2,
the call tointegrity_inode_permission()was moved up to the caller, where either a file or path are available. Any suggestions?
vfs_permission and file_permission are just small wrappers around inode_permission. In hindsight they actualyl were a wrong idea and will probably go away in the not so distant future. Note that there are various callers of inode_permission that don't have a vfsmount anywhere near.
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
In reply to Serge E. HallynQuoted 11 lines · Serge E. Hallyn
Quoted 10 lines
Quoted 1 line
Sorry, but I don't think we can bloat the inode even further for this.
The original version of IMA was LSM based, using
i_security. Based on discussions on the LSM mailing list, it was decided that the LSM hooks were meant only for access control. During the same time frame, there was a lot of work done in stacking LSM modules andi_security, but that approach was dropped. It was suggested that we define a separate set of hooks for integrity, which this patch set provides. Caching integrity results is an important aspect. Any suggestions in lieu of definingi_integrity?
Quoted 6 lines
The
i_integrityis only bloating the inode if LIM is enabled. Surely that beats having LIM define its own hash table and locking to track integrity labels on inodes? Do you have another suggestion?Or is the concern about having more #ifdefs in the struct inode definition?
No, the concern is over bloating the inode for a rather academic fringe feature. As this comes from IBM I'm pretty sure someone will pressure the big distro to turn it on. And inode growth is a concern for fileserving or other inode heavy workload. Mimi mentioned this is just a cache of information, so consider using something like XFS's mru cache which is used for something similar where the xfs_inode was kept small despite a very niche feature needing a cache attached to the inode:
fs/xfs/xfs_mru_cache.c
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
In reply to Peter DoldingQuoted 9 lines · Peter Dolding
We really do need to get credentials patch in to common store all this permission/secuirty data.. With a section for integrity related entries.
Anti-Virus Passes and fails, signed running programs support and so on.
Lot of different things need ways of recording integrity status's. Users also need to know if a application does not work is it TPM is it Anti-virus is it lack of signature.
Peter, please read up what the credentials patches do, or how struct cred/ucred is used in SVR4 and BSD for the last 20 years. It is useful, but it's not going to help with any of the strange thigns the AV or Integrity people are doing.
Quoted 12 lines · Mimi Zohar
I assume the concern here is that between looking up the chip and actually
using the chip, the TPM chip is disabled/deactivated. Based on discussions
with Kenneth Goldman, the TCG main specification part2: structures, require
that even if the TPM is disabled/deactivated, the command to extend the PCR
will succeed, but the command to read the PCR will fail with an appropriate
error code.
And what happens when the chip simply goes away due to a hotplug action? Or not even the actual chip goes away but just the chip driver and you now dereference freed memory?
Christoph Hellwig <[email protected]> wrote on 08/12/2008 03:30:31 PM:
Quoted 3 lines · Mimi Zohar
Quoted 2 lines
I assume the concern here is that between looking up the chip and
actually
Quoted 7 lines
Quoted 6 lines
using the chip, the TPM chip is disabled/deactivated. Based on discussions
with Kenneth Goldman, the TCG main specification part2: structures, require
that even if the TPM is disabled/deactivated, the command to extend the
Quoted 8 lines
Quoted 4 lines
PCR
will succeed, but the command to read the PCR will fail with an appropriate
error code.And what happens when the chip simply goes away due to a hotplug action? Or not even the actual chip goes away but just the chip driver and you now dereference freed memory?
Being a TCG/TPM person, I can only address the first question. The intent is that the TPM is soldered to the planar/motherboard (the TCG uses the phrase "bound to the platform"). I can't imagine any manufacturer designing a pluggable TPM. It would subvert PCR measurements and thus attestation, data sealing, etc.
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
In reply to Christoph HellwigQuoted 16 lines · Christoph Hellwig
Quoted 15 lines · Serge E. Hallyn
Quoted 10 lines
Quoted 1 line
Sorry, but I don't think we can bloat the inode even further for this.
The original version of IMA was LSM based, using
i_security. Based on discussions on the LSM mailing list, it was decided that the LSM hooks were meant only for access control. During the same time frame, there was a lot of work done in stacking LSM modules andi_security, but that approach was dropped. It was suggested that we define a separate set of hooks for integrity, which this patch set provides. Caching integrity results is an important aspect. Any suggestions in lieu of definingi_integrity?The
i_integrityis only bloating the inode if LIM is enabled. Surely that beats having LIM define its own hash table and locking to track integrity labels on inodes? Do you have another suggestion?
Quoted 6 lines
Quoted 2 lines
Or is the concern about having more #ifdefs in the struct inode definition?
No, the concern is over bloating the inode for a rather academic fringe feature. As this comes from IBM I'm pretty sure someone will pressure the big distro to turn it on.
By default?? I should hope not...
Note that these are all not loadable modules. So presumably either it's in the kernel and enforcing, or it's not there.
Quoted 7 lines
And inode growth is a concern for
fileserving or other inode heavy workload. Mimi mentioned this is just a cache of information, so consider using something like XFS's mru cache which is used for something similar where thexfs_inodewas kept small despite a very niche feature needing a cache attached to the inode:
fs/xfs/xfs_mru_cache.c
ok, so basically as I said above
Quoted 2 lines
Quoted 2 lines
... having LIM define its own hash table and locking to track integrity labels on inodes?
:)
But then that is in fact the better way to go if there can be a lot of inodes with i_integrity=NULL. It looks like IMA always allocates something, but if I understand the idea behind templates correctly, that isn't necessarily always the case.
thanks,
-serge
Quoted 5 lines
Being a TCG/TPM person, I can only address the first question. The intent is that the TPM is soldered to the planar/motherboard (the TCG uses the phrase "bound to the platform"). I can't imagine any manufacturer designing a pluggable TPM. It would subvert PCR measurements and thus attestation, data sealing, etc.
So the security limit of your TPM is a soldering iron .. whoo. I'm not sure this is actually the case however as the secret of interest is in the TPM so even if I replaced the TPM the goodies already set up are in the TPM I just unsoldered surely ?
Alan
Quoted 22 lines · Kenneth Goldman
Christoph Hellwig <[email protected]> wrote on 08/12/2008 03:30:31 PM:
Quoted 3 lines · Mimi Zohar
Quoted 2 lines
I assume the concern here is that between looking up the chip and
actually
Quoted 7 lines
Quoted 6 lines
using the chip, the TPM chip is disabled/deactivated. Based on discussions
with Kenneth Goldman, the TCG main specification part2: structures, require
that even if the TPM is disabled/deactivated, the command to extend theQuoted 8 lines
Quoted 4 lines
PCR
will succeed, but the command to read the PCR will fail with an appropriate
error code.And what happens when the chip simply goes away due to a hotplug action? Or not even the actual chip goes away but just the chip driver and you now dereference freed memory?
Quoted 5 lines
Being a TCG/TPM person, I can only address the first question. The intent is that the TPM is soldered to the planar/motherboard (the TCG uses the phrase "bound to the platform"). I can't imagine any manufacturer designing a pluggable TPM. It would subvert PCR measurements and thus attestation, data sealing, etc.
Load up the fake-php hotplug pci driver and "soft" disconnect it from the system :)
That was easy...
Note, just because you think your device is always going to be soldered to the motherboard, doesn't mean it can't be disconnected at any point in time with the kernel running.
Or the module could just be unloaded, that's also a very common thing to have happen, right?
thanks,
greg k-h
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
In reply to Christoph HellwigQuoted 7 lines · Christoph Hellwig
Quoted 6 lines · Peter Dolding
We really do need to get credentials patch in to common store all this permission/secuirty data.. With a section for integrity related entries.
Anti-Virus Passes and fails, signed running programs support and so on.
Quoted 9 lines
Quoted 3 lines
Lot of different things need ways of recording integrity status's. Users also need to know if a application does not work is it TPM is it Anti-virus is it lack of signature.
Peter, please read up what the credentials patches do, or how struct cred/ucred is used in SVR4 and BSD for the last 20 years. It is useful, but it's not going to help with any of the strange thigns the AV or Integrity people are doing.
The Issue I have. By your answer you have not. Credentials patch
for Linux allows more than the BSD one does. Linux one is a complete permission storage replacement.
http://linux.derkeiler.com/Mailing-Lists/Kernel/2008-08/msg02682.html
Note the file credentials one. That is reused by FS Cache and it creates fake inodes. So worst case event LIM blocks a valid file because its coming from cache.
"vfs_permission and file_permission are just small wrappers around inode_permission." No longer both go to inote_permission after the
credentials patch is in. file_permission instead goes to credentials
struct connected to the inode. Most calls to inode_permission end up wrapped to the credentials struct.
Basically by the way Linux Credentials patch is being done.inode_permission could completely cease to exist. Completely
replaced by the credentials structure.
Each filesystem having its own cache is one reason why Linux
Credentials Patch is being brought into live. So a single cache can
store all the need information of the OS and for the file system. Even better operate on filesystems lacking all the need permission structs using a userspace program to fill in some of the blanks.
LSM's in Credentials can there own protected data sets since all alterations to Credentials by the user space deamon have to go past LSM for approval or rejection. Linux Credentials only need a extra protected zone added to cover you LIM needs and AV needs to store data.
In simple terms permissions stored in inodes is basically deprecated by Linux's Credentials patch.
Sorting out the Credentials patch is kinda key. Nothing you AV or
Integrity people is strange to the Linux Credentials patch. Without
embracing requires more processing when pulling data from a common cache that has already been AV or Integrity scanned and maintained in that state. Now its really designing the struct that should exist in Credentials.
Peter Dolding
Alan Cox <[email protected]> wrote on 08/12/2008 05:36:36 PM:
Quoted 10 lines
Quoted 5 lines
Being a TCG/TPM person, I can only address the first question. The intent is that the TPM is soldered to the planar/motherboard (the TCG uses the phrase "bound to the platform"). I can't imagine any manufacturer designing a pluggable TPM. It would subvert PCR measurements and thus attestation, data sealing, etc.
So the security limit of your TPM is a soldering iron .. whoo. I'm not sure this is actually the case however as the secret of interest is in the TPM so even if I replaced the TPM the goodies already set up are in the TPM I just unsoldered surely ?
I suppose it depends on the precise interpretation of your technical term "goodies". :-)
One of the two primary uses of the TCG technology is protection against an attack on the software. The TCG uses the terms attestation, integrity, platform measurements, etc. For this class of> "goodies", the TCG technology does not protect against hardware attacks such as replacing the TPM with a bogus device, replacing the CRTM hardware, flashing the CRTM using a JTAG cable, lifting a TPM pin> and asserting reset, using a JTAG cable to set breakpoints and alter memory, etc.
For this use case, the attack model is a remote, software attack. The> user is not considered the attacker.
(In the other primary use case, the user is the attacker, but it's an entirely different discussion.)
(It's also important to note that the TPM itself does not completely secure the platform. There's an entire system design around it, which> it why I try to say "TCG technology" rather than TPM.)
Greg KH <[email protected]> wrote on 08/12/2008 07:16:02 PM:
Quoted 4 lines · Kenneth Goldman
Quoted 3 lines
Christoph Hellwig <[email protected]> wrote on 08/12/2008 03:30:31 PM:
Quoted 1 line
And what happens when the chip simply goes away due to a hotplug
action?
Quoted 1 line
Quoted 1 line
Quoted 1 line
Or not even the actual chip goes away but just the chip driver and
you
Quoted 11 lines
Quoted 7 lines
Quoted 1 line
now dereference freed memory?
Being a TCG/TPM person, I can only address the first question. The intent is that the TPM is soldered to the planar/motherboard (the TCG uses the phrase "bound to the platform"). I can't imagine any manufacturer designing a pluggable TPM. It would subvert PCR measurements and thus attestation, data sealing, etc.
Load up the fake-php hotplug pci driver and "soft" disconnect it from the system :)
Quoted 8 lines
That was easy...
Note, just because you think your device is always going to be soldered to the motherboard, doesn't mean it can't be disconnected at any point in time with the kernel running.
Or the module could just be unloaded, that's also a very common thing to have happen, right?
As I said, I'm a TCG/TPM person, so I can't address "the module could just be unloaded" or "hotplug pci driver". I'll leave that issue to the Linux driver experts.
I was using the common meaning of hotplug, removing and replacing a hardware component while power is on. By that common definition, the TPM would not be a hotpluggable component.
(As an aside, the TPM is commonly connected to the LPC bus on the planar, not the PCI bus.)
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
In reply to Peter DoldingQuoted 2 lines · Peter Dolding
Credentials patch for Linux allows more than the BSD one does. Linux one is a complete permission storage replacement.
No, it isn't. It replaces the permission storage facility of a process but does not change the way in which an inode caches its credentials in RAM.
Quoted 3 lines
http://linux.derkeiler.com/Mailing-Lists/Kernel/2008-08/msg02682.html
Note the file credentials one.
I said "Open file credentials". I was referring to struct file which designates an open file handle, not the file/inode itself. What this means is that the open file handle takes a reference to the subjective security context of the process that opened it, at the time it opened it, so that accesses to that file are (with exceptions) done with those credentials, no matter who is actually using the handle.
For disk filesystems, for the most part, this makes no difference: an open file is usable by anyone who has the handle. However, for network filesystems, where each request is marked with the details of who the request should be accounted to and the server decides, it does matter.
Quoted 1 line
That is reused by FS Cache and it creates fake inodes.
FS-Cache+CacheFiles doesn't create fake inodes at all. It creates real inodes on disk in the cache. The reason for these patches is that CacheFiles needs to use its own subjective security context when creating or accessing these inodes, rather than the subjective context of whoever invoked AFS or NFS, and thus caused CacheFiles to touch the cache.
Quoted 5 lines
"
vfs_permissionandfile_permissionare just small wrappers aroundinode_permission." No longer both go toinote_permissionafter the
credentials patch is in.file_permissioninstead goes to credentials
struct connected to the inode. Most calls toinode_permissionend up wrapped to the credentials struct.
I don't understand what you're talking about. Looking in fs/namei.c, I see:
int vfs_permission(struct nameidata *nd, int mask)
{
return inode_permission(nd->path.dentry->d_inode, mask);
}And:
int file_permission(struct file *file, int mask)
{
return inode_permission(file->f_path.dentry->d_inode, mask);
}That looks like they still both go to inode_permission().
Quoted 3 lines
Basically by the way Linux Credentials patch is being done.
inode_permissioncould completely cease to exist. Completely
replaced by the credentials structure.
Erm... Why? inode_permission() is a function, the creds struct is a data type.
Quoted 2 lines
Each filesystem having its own cache is one reason why Linux Credentials Patch is being brought into live.
Not as far as I know. The credentials belonging to the filesystem and the inodes in the filesystem belong to the filesystem and are not held in cred structs. Using cred structs for inodes would waste memory as a task's credentials have a lot of bits an inode's don't.
Quoted 9 lines
So a single cache can store all the need information of the OS and for the file system. Even better operate on filesystems lacking all the need permission structs using a userspace program to fill in some of the blanks.
LSM's in Credentials can there own protected data sets since all alterations to Credentials by the user space deamon have to go past LSM for approval or rejection. Linux Credentials only need a extra protected zone added to cover you LIM needs and AV needs to store data.
Are you suggesting the offloading of security data caching to userspace?
Quoted 2 lines
In simple terms permissions stored in inodes is basically deprecated by Linux's Credentials patch.
In simple terms, no they aren't.
Quoted 8 lines
Sorting out the Credentials patch is kinda key. Nothing you AV or
Integrity people is strange to the Linux Credentials patch. Without
embracing requires more processing when pulling data from a common cache that has already been AV or Integrity scanned and maintained in that state. Now its really designing the struct that should exist in Credentials.From my quick glance over the integrity patches, I'd say that the cred struct
is entirely the wrong place to store this data. It's nothing to do with a task's subjective state, except, perhaps, in setting it up. It appears to be per-inode state.
David
Quoted 8 lines
"goodies", the TCG technology does not protect against hardware attacks such as replacing the TPM with a bogus device, replacing the CRTM hardware, flashing the CRTM using a JTAG cable, lifting a TPM pin> and asserting reset, using a JTAG cable to set breakpoints and alter memory, etc.
For this use case, the attack model is a remote, software attack. The> user is not considered the attacker.
Surely if I can replace your TPM with alternative hardware then I can also replace it with virtualised software traps.
[If there is a good document on this btw please just point me there instead and I'll go read further]
Quoted 11 lines · Alan Cox
Quoted 8 lines
"goodies", the TCG technology does not protect against hardware attacks such as replacing the TPM with a bogus device, replacing the CRTM hardware, flashing the CRTM using a JTAG cable, lifting a TPM pin> and asserting reset, using a JTAG cable to set breakpoints and alter memory, etc.
For this use case, the attack model is a remote, software attack. The> user is not considered the attacker.
Surely if I can replace your TPM with alternative hardware then I can also replace it with virtualised software traps.
Yes, which in fact is what most people working on TPM support use because the real hardware is just too slow :)
Quoted 2 lines
[If there is a good document on this btw please just point me there instead and I'll go read further]
I recommend this one:
http://www.few.vu.nl/~srijith/publications/confs/sws07-final.pdf :)
Alan Cox <[email protected]> wrote on 08/13/2008 09:40:40 AM:
Quoted 11 lines
Quoted 8 lines
"goodies", the TCG technology does not protect against hardware attacks such as replacing the TPM with a bogus device, replacing the CRTM hardware, flashing the CRTM using a JTAG cable, lifting a TPM pin> and asserting reset, using a JTAG cable to set breakpoints and alter memory, etc.
For this use case, the attack model is a remote, software attack. The> user is not considered the attacker.
Surely if I can replace your TPM with alternative hardware then I can also replace it with virtualised software traps.
Replacing with alternative hardware is outside the attack model. For this use case, the TCG assumes the user will not be attacking himself.
Replacing with software is a valid remote attack. It will be detected through the TCG platform measurement process. The local defense is "sealing" data to trusted measurements. The remote defense is "attestation" or "quote", getting signed measurements and deciding whether to trust them.
Quoted 2 lines
[If there is a good document on this btw please just point me there instead and I'll go read further]
The TPM main specification (design principles) discusses measurements,> reporting, attestation, and so on.
The "TCG PC Client Specific Implementation Specification For Conventional BIOS" is specific to the PC platform (there are specifications for mobile devices, printers, storage, etc.) but section 1.2 has a good discussion of the concepts.
https://www.trustedcomputinggroup.org/home
(Feel free to email me privately if this is becoming off topic for the mailing list.)
[email protected] wrote on 08/12/2008 07:16:02 PM:
Quoted 11 lines · Kenneth Goldman
Quoted 10 lines
Christoph Hellwig <[email protected]> wrote on 08/12/2008 03:30:31 PM:
Quoted 3 lines · Mimi Zohar
Quoted 2 lines
I assume the concern here is that between looking up the chip and
actually
Quoted 4 lines
Quoted 4 lines
using the chip, the TPM chip is disabled/deactivated. Based on discussions
with Kenneth Goldman, the TCG main specification part2:
structures,
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
require
that even if the TPM is disabled/deactivated, the command to
extend the
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
PCR
will succeed, but the command to read the PCR will fail with an appropriate
error code.And what happens when the chip simply goes away due to a hotplug
action?
Quoted 1 line
Quoted 1 line
Quoted 1 line
Or not even the actual chip goes away but just the chip driver and
you
Quoted 11 lines
Quoted 7 lines
Quoted 1 line
now dereference freed memory?
Being a TCG/TPM person, I can only address the first question. The intent is that the TPM is soldered to the planar/motherboard (the TCG uses the phrase "bound to the platform"). I can't imagine any manufacturer designing a pluggable TPM. It would subvert PCR measurements and thus attestation, data sealing, etc.
Load up the fake-php hotplug pci driver and "soft" disconnect it from the system :)
Quoted 8 lines
That was easy...
Note, just because you think your device is always going to be soldered to the motherboard, doesn't mean it can't be disconnected at any point in time with the kernel running.
Or the module could just be unloaded, that's also a very common thing to have happen, right?
This problem only affects the TPM internal kernel interface, if the TPM driver is not built-in. For IMA, this is not an issue as the TPM driver must be built-in in order to start collecting measurements as soon as possible, which is at late_initcall(). I will resolve this problem for the general internal kernel interface usage case.
Thanks!
Mimi
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
In reply to Serge E. HallynQuoted 44 lines · Serge E. Hallyn
Quoted 16 lines · Christoph Hellwig
Quoted 15 lines · Serge E. Hallyn
Quoted 10 lines
Quoted 1 line
Sorry, but I don't think we can bloat the inode even further for this.
The original version of IMA was LSM based, using
i_security. Based on discussions on the LSM mailing list, it was decided that the LSM hooks were meant only for access control. During the same time frame, there was a lot of work done in stacking LSM modules andi_security, but that approach was dropped. It was suggested that we define a separate set of hooks for integrity, which this patch set provides. Caching integrity results is an important aspect. Any suggestions in lieu of definingi_integrity?The
i_integrityis only bloating the inode if LIM is enabled. Surely that beats having LIM define its own hash table and locking to track integrity labels on inodes? Do you have another suggestion?Quoted 6 lines
Quoted 2 lines
Or is the concern about having more #ifdefs in the struct inode definition?
No, the concern is over bloating the inode for a rather academic fringe feature. As this comes from IBM I'm pretty sure someone will pressure the big distro to turn it on.
By default?? I should hope not...
Note that these are all not loadable modules. So presumably either it's in the kernel and enforcing, or it's not there.
Quoted 7 lines
And inode growth is a concern for
fileserving or other inode heavy workload. Mimi mentioned this is just a cache of information, so consider using something like XFS's mru cache which is used for something similar where thexfs_inodewas kept small despite a very niche feature needing a cache attached to the inode:
fs/xfs/xfs_mru_cache.cok, so basically as I said above
Quoted 2 lines
Quoted 2 lines
... having LIM define its own hash table and locking to track integrity labels on inodes?
:)
Quoted 7 lines
But then that is in fact the better way to go if there can be a lot of inodes with i_integrity=NULL. It looks like IMA always allocates something, but if I understand the idea behind templates correctly, that isn't necessarily always the case.
thanks,
-serge
IMA has a two stage initialization, one at security_initcall() and another at late_initcall(), when the tpm is available, to make sure that all inode's i_integrity are allocated.
Multiple templates can register themselves with LIM, but only one integrity provider, such as IMA, can register itself at a time. So hypothetically, other integrity providers could be implemented without a need for i_integrity.
Mimi
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
In reply to Serge E. HallynQuoted 55 lines · Serge E. Hallyn
Quoted 45 lines · Mimi Zohar
[email protected] wrote on 08/11/2008 01:02:55 PM:
Quoted 24 lines · Mimi Zohar
Quoted 23 lines
Christoph Hellwig <[email protected]> wrote on 08/09/2008 02:53:40 PM:
Quoted 22 lines
Quoted 22 lines
int
vfs_permission(struct nameidata *nd, int mask){fs/namei.c +11
-2-return inode_permission (nd->path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (nd->path.dentry->d_inode, mask); +if (retval) +return retval; +return integrity_inode_permission (NULL , &nd->path, + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC )); }/** @@ -306,7 +314,14 @@ int vfs_permission(struct nameidata *nd,*/ int file_permission (struct file *file,int mask) { -return inode_permission (file->f_path.dentry->d_inode, mask); +int retval; + + retval =inode_permission (file->f_path.dentry->d_inode, mask);Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
fs/namei.c int vfs_permission(struct nameidata *nd, · line 324
Quoted 5 lines
fs/namei.c +5
-0+if (retval) +return retval; +return integrity_inode_permission (file,NULL , + mask & (MAY_READ |MAY_WRITE | +MAY_EXEC ));Please put your hook into
inode_permission. Note that in inode permission and lots of callers there is no path available so don'tpass
Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
it. Please pass the full
MAY_FOOmask for new interfaces and do filtering that won't break if new ones are introduced.We started out with the
integrity_inode_permission()hook call ininode_permission(), but because of the removal of the nameidata parameter in the last merge, based on discussions
http://marc.info/?l=linux-security-module&m=121797845308246&w=2,
the call tointegrity_inode_permission()was moved up to the caller, where either a file or path are available. Any suggestions?Quoted 8 lines
Quoted 2 lines
Mimi, can you explain exactly (and concisely) what you are doing with the pathname?
IMA maintains a list of hash values of system sensitive files loaded into the run-time of the system and extends a PCR with the hash value. In order to calculate this hash value, IMA requires access to either the file or the path, which currently is not accessible in
inode_permission().
Quoted 5 lines
So the usual question is, if I've done
ln -s/etc/shadow/tmp/shadow
will IMA do the right thing if I'm opening/tmp/shadow? Or will it only catch any writes I've done the next time someone (i.e. passwd) opens/etc/shadow?
It will measure the right thing, as the measurement is based on the dentry contained within the file/path structures, not names. File names in IMA are only used as a hint in the measurement hash list.
Mimi
Re: [PATCH 3/4] integrity: Linux Integrity Module(LIM)
In reply to David HowellsQuoted 24 lines · David Howells
Quoted 2 lines · Peter Dolding
Credentials patch for Linux allows more than the BSD one does. Linux one is a complete permission storage replacement.
No, it isn't. It replaces the permission storage facility of a process but does not change the way in which an inode caches its credentials in RAM.
Quoted 3 lines
http://linux.derkeiler.com/Mailing-Lists/Kernel/2008-08/msg02682.html
Note the file credentials one.
I said "Open file credentials". I was referring to struct file which designates an open file handle, not the file/inode itself. What this means is that the open file handle takes a reference to the subjective security context of the process that opened it, at the time it opened it, so that accesses to that file are (with exceptions) done with those credentials, no matter who is actually using the handle.
For disk filesystems, for the most part, this makes no difference: an open file is usable by anyone who has the handle. However, for network filesystems, where each request is marked with the details of who the request should be accounted to and the server decides, it does matter.
Quoted 8 lines
Quoted 1 line
That is reused by FS Cache and it creates fake inodes.
FS-Cache+CacheFiles doesn't create fake inodes at all. It creates real inodes on disk in the cache. The reason for these patches is that CacheFiles needs to use its own subjective security context when creating or accessing these inodes, rather than the subjective context of whoever invoked AFS or NFS, and thus caused CacheFiles to touch the cache.
Source of Inodes is different. Old style attack aganst AV's has been
to get them to approve something then swap the contents while its
still approved. Simplest is cache attacking. We need to single up
the cache with secuirty around it.
Other cache that has been targeted is the swapfile. Since its another
cache. Building solid intergeity its key to get control of the
caches.
Quoted 13 lines
Quoted 5 lines
"
vfs_permissionandfile_permissionare just small wrappers aroundinode_permission." No longer both go toinote_permissionafter the
credentials patch is in.file_permissioninstead goes to credentials
struct connected to the inode. Most calls toinode_permissionend up wrapped to the credentials struct.I don't understand what you're talking about. Looking in
fs/namei.c, I see:int vfs_permission(struct nameidata *nd, int mask) { return inode_permission(nd->path.dentry->d_inode, mask); }
Quoted 8 lines
And:
int file_permission(struct file *file, int mask) { return inode_permission(file->f_path.dentry->d_inode, mask); }That looks like they still both go to
inode_permission().
Hmm I had redirect file_permission in my own working tree. Experiment in reduced storage in the inode and credentionals systems.
If you look at inode in operation you might as well call the file permissions on a per file base. All found so far are the pointer to the same struct if its exactly the same file.
Its a point of duplication of storage. Credentials and inode storing it.
Ie file permissions only stored once.
Quoted 19 lines
Quoted 3 lines
Basically by the way Linux Credentials patch is being done.
inode_permissioncould completely cease to exist. Completely
replaced by the credentials structure.Erm... Why?
inode_permission()is a function, the creds struct is a data type.Quoted 2 lines
Each filesystem having its own cache is one reason why Linux Credentials Patch is being brought into live.
Not as far as I know. The credentials belonging to the filesystem and the inodes in the filesystem belong to the filesystem and are not held in cred structs. Using cred structs for inodes would waste memory as a task's credentials have a lot of bits an inode's don't.
Quoted 4 lines
So a single cache can store all the need information of the OS and for the file system. Even better operate on filesystems lacking all the need permission structs using a userspace program to fill in some of the blanks.
Quoted 7 lines
Quoted 5 lines
LSM's in Credentials can there own protected data sets since all alterations to Credentials by the user space deamon have to go past LSM for approval or rejection. Linux Credentials only need a extra protected zone added to cover you LIM needs and AV needs to store data.
Are you suggesting the offloading of security data caching to userspace?
Not for caching mainly. For some operations intergretiy might be
chosen to be done in user space like if file is signed or not. Like
checking just using userspace drivers. Remember you can already
insert userspace drivers in theory for testing of a TPM setup running from userspace in a small section of the OS could be useful to make sure everything is right before making active.
Strict interface allowing sections of the security system to operate in user space and kernel space. For allowing existence of a combined defence.
AV program may be approved to set X integrity data in credentials.
Signature checking program might set a flag to say that a application should never run as root or that its a particular class of
application. Triggering the LSM to auto reduce applications that
programs system access to match its settings. For this to be
possible we need secuirty that only the Signature checking program can set the signature flags. Then the LSM can trust and repond to them.
This is bring ipset's style for firewalls http://ipset.netfilter.org/
to the main secuirty system.
Having both kernel and usermode existing in secuirty has the same advantage as allowing user mode drivers. The userspace to be changeable with threats and independent to kernel.
Most creative expands I am looking into.
Giving Linux equal to layor 7 file wall filtering on the filesystem level. file id magics run on file when before the file is opened by
the application that information stored in credentials. If a program
is no meant to open that file type it can be gets blocked. When running anti-virus and many filemangers side by side they don't need to run magics repetitively.
Final one is a new form of file interlink. Bit like streams in NTFS. So thumbnails and the like of images used by filemanagers are
connected to there related file. So when deleting the file a thumb
nail was created from the thumbnail gets removed. Hopefully allowing
applications to save on down scaling as well.
Yes I am really messing around in the current internal structs. To hopefully provide a framework to archive the max secuirty creatable. As well as reducing duplication. So price of doing MAX should be quite min.
Quoted 7 lines
Quoted 3 lines
In simple terms permissions stored in inodes is basically deprecated by Linux's Credentials patch.
In simple terms, no they aren't.
From the way I am doing it. Storing shared permissions between files
it is deprecated for the inodes stuct. Since I altered the code to
move that into credentials alone. I was thinking too much in my
working tree.
Quoted 8 lines
Quoted 7 lines
Sorting out the Credentials patch is kinda key. Nothing you AV or
Integrity people is strange to the Linux Credentials patch. Without
embracing requires more processing when pulling data from a common cache that has already been AV or Integrity scanned and maintained in that state. Now its really designing the struct that should exist in Credentials.
Quoted 5 lines
From my quick glance over the integrity patches, I'd say that the cred struct is entirely the wrong place to store this data. It's nothing to do with a task's subjective state, except, perhaps, in setting it up. It appears to be per-inode state.
Its the in operation of the LIM. Same as AV. Complete files will
be scanned. Passed or failed or marked unknown. Currently we have
nice duplication of lots of things. Its been the alteration in my working tree that has given me major different look at how to do
this. I am trying to get to a location where there is no
duplication of permission storage or caching. Simpler to audit
system access 1 struct know operational and real storage state.
Peter Dolding
Hi!
Quoted 8 lines
Quoted 3 lines
And what happens when the chip simply goes away due to a hotplug action? Or not even the actual chip goes away but just the chip driver and you now dereference freed memory?
Being a TCG/TPM person, I can only address the first question. The intent is that the TPM is soldered to the planar/motherboard (the TCG uses the phrase "bound to the platform"). I can't imagine any manufacturer designing a pluggable TPM. It would subvert PCR
Only 2 TPMs I've seen were on pluggable modules... which was fortunate because they slowed down boot by 5+ minutes, and broke it completely in other cases. Nickname 'kurvitko' (aka useless trash that breaks stuff). They are currently lying under my table, disconnected.
(OTOH they were not on PCI, but on some low-count pin header).
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 11 lines · Pavel Machek
Hi!
Quoted 8 lines
Quoted 3 lines
And what happens when the chip simply goes away due to a hotplug action? Or not even the actual chip goes away but just the chip driver and you now dereference freed memory?
Being a TCG/TPM person, I can only address the first question. The intent is that the TPM is soldered to the planar/motherboard (the TCG uses the phrase "bound to the platform"). I can't imagine any manufacturer designing a pluggable TPM. It would subvert PCR
Quoted 7 lines
Only 2 TPMs I've seen were on pluggable modules... which was fortunate because they slowed down boot by 5+ minutes, and broke it completely in other cases. Nickname 'kurvitko' (aka useless trash that breaks stuff). They are currently lying under my table, disconnected.
(OTOH they were not on PCI, but on some low-count pin header).
Pavel
Remember even soldered on stuff can fail. How linux handles the
death of the TPM module needs to be covered.
Peter Dolding
"Peter Dolding" <[email protected]> wrote on 08/15/2008 06:37:27 AM:
Quoted 2 lines
Remember even soldered on stuff can fail. How linux handles the
death of the TPM module needs to be covered.
Is fault tolerance a requirement just for the TPM, or is it a general> Linux requirement? Has it always been there, or is it new?
For example, does kernel software have to gracefully handle failures in the disk controller, processor, memory controller, BIOS flash memory, etc?
I'd think it would be quite hard to code around motherboard failures in a commodity platform not designed for fault tolerance.
Quoted 11 lines · Kenneth Goldman
"Peter Dolding" <[email protected]> wrote on 08/15/2008 06:37:27 AM:
Quoted 2 lines
Remember even soldered on stuff can fail. How linux handles the
death of the TPM module needs to be covered.Is fault tolerance a requirement just for the TPM, or is it a general> Linux requirement? Has it always been there, or is it new?
For example, does kernel software have to gracefully handle failures in the disk controller, processor, memory controller, BIOS flash memory, etc?
Well, on a dual/quad core/socket/whatever system, a failing processor can be downed and the system keep going. On a NUMA box, you can yank a node with a bad memory controller after you take it down. Similarly for a disk controller if you have more than one, and the failed one isn't critical for system operation.
And the TPM chip is more like a USB controller, in that there's a *high* degree of probability that the system will still be able to run even if it fails or goes insane (consider that on my laptop, the TPM driver was broken for a while, and I was still ableto work). So you need to write code to do things like detect TPM downage or insanity, decide what to do on the kernel level, what to reflect up to any security modules running in userspace, etc....
Quoted 7 lines · On Fri, 15 Aug 2008 14:50:01 -0400 Kenneth Goldman <[email protected]> wrote:
"Peter Dolding" <[email protected]> wrote on 08/15/2008 06:37:27 AM:
Quoted 2 lines
Remember even soldered on stuff can fail. How linux handles the
death of the TPM module needs to be covered.Is fault tolerance a requirement just for the TPM, or is it a general> Linux requirement? Has it always been there, or is it new?
We try very very hard to not crash on failure.
Quoted 3 lines
For example, does kernel software have to gracefully handle failures in the disk controller, processor, memory controller, BIOS flash memory, etc?
Our disk layer will retry, reset, change cable speeds and if that fails and you are running raid with multipaths or sufficient mirrors continue. We capture processor exceptions and when possible log and continue although most CPU failures report with the context corrupt. We log and the EDAC layer handles as much as it possible can for memory errors (actually we could be a bit more selective here and there are proposals to go further)
Quoted 2 lines
I'd think it would be quite hard to code around motherboard failures in a commodity platform not designed for fault tolerance.
The Linux userbase ranges from fault tolerant systems like Stratus to dodgy cheapo boards from iffy cheap and cheerful computer merchants so it makes sense to try and be robust.
In your TPM case being robust against the TPM ceasing to respond certainly is worthwhile so that at least you return an error on failure rather than the box dying. You may well not be able to get the chip back in order without a hardware change/reboot.
Alan
Pavel Machek <[email protected]> wrote on 08/14/2008 07:12:10 AM:
Quoted 6 lines
Only 2 TPMs I've seen were on pluggable modules... which was fortunate because they slowed down boot by 5+ minutes, and broke it completely in other cases. Nickname 'kurvitko' (aka useless trash that breaks stuff). They are currently lying under my table, disconnected.
(OTOH they were not on PCI, but on some low-count pin header).
1 - The pluggable modules use a standard LPC bus header. In my> experience, all the TPM vendors supply them in low quantities for evaluation and test, but no one expects them to be used in production because of the security issues.
2 - I'd be interested to know whether the slowdown was in the BIOS, in the OS boot, or on bringup of an application? Was this Linux or some other OS?
Both the TCG and the platform vendors are very sensitive to the BIOS part of the boot time. For example, the TPM self test is broken into a fast part for features that are required before boot and a slower part that can be done later. There are recommendations to break up hashing to remove the TPM from the critical path.
Even then, the slowest TPM operation is keypair creation, on the order of 1-5 seconds, which should not be required during boot. I wonder if the problem was actually a code bug or unsupported operation causing timeouts?
It would be great if you could debug a bit and report your findings to us.