[PATCH v4 01/19] firmware: simplify dev_*() print messages for generic helpers

2016-02-12 Thread Mimi Zohar
From: "Luis R. Rodriguez" Simplify a few of the *generic* shared dev_warn() and dev_dbg() print messages for three reasons: 0) Historically firmware_class code was added to help get device driver firmware binaries but these days request_firmware*() helpers are being repurposed for gener

[PATCH v4 10/19] firmware: replace call to fw_read_file_contents() with kernel version

2016-02-12 Thread Mimi Zohar
Replace the fw_read_file_contents with kernel_file_read_from_path(). Although none of the upstreamed LSMs define a kernel_fw_from_file hook, IMA is called by the security function to prevent unsigned firmware from being loaded and to measure/appraise signed firmware, based on policy. Instead of r

[PATCH v4 18/19] ima: measure and appraise the IMA policy itself

2016-02-12 Thread Mimi Zohar
Add support for measuring and appraising the IMA policy itself. Changelog v4: - use braces on both if/else branches, even if single line on one of the branches - Dmitry - Use the id mapping - Dmitry Signed-off-by: Mimi Zohar Acked-by: Petko Manolov Acked-by: Dmitry Kasatkin --- security/integ

[PATCH v4 03/19] firmware: clean up filesystem load exit path

2016-02-12 Thread Mimi Zohar
From: Kees Cook This makes the error and success paths more readable while trying to load firmware from the filesystem. Signed-off-by: Kees Cook Cc: Josh Boyer Cc: David Howells Acked-by: Luis R. Rodriguez Signed-off-by: Mimi Zohar --- drivers/base/firmware_class.c | 12 +--- 1 fil

[PATCH v4 02/19] firmware: move completing fw into a helper

2016-02-12 Thread Mimi Zohar
From: "Luis R. Rodriguez" This will be re-used later through a new extensible interface. Reviewed-by: Josh Boyer Signed-off-by: Luis R. Rodriguez Signed-off-by: Mimi Zohar Acked-by: Kees Cook --- drivers/base/firmware_class.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletion

[PATCH v4 19/19] ima: require signed IMA policy

2016-02-12 Thread Mimi Zohar
Require the IMA policy to be signed when additional rules can be added. v1: - initialize the policy flag - include IMA_APPRAISE_POLICY in the policy flag Signed-off-by: Mimi Zohar Acked-by: Petko Manolov Acked-by: Dmitry Kasatkin --- security/integrity/ima/ima_policy.c | 7 +++ 1 file cha

[PATCH v4 15/19] kexec: replace call to copy_file_from_fd() with kernel version

2016-02-12 Thread Mimi Zohar
Replace copy_file_from_fd() with kernel_read_file_from_fd(). Two new identifiers named READING_KEXEC_IMAGE and READING_KEXEC_INITRAMFS are defined for measuring, appraising or auditing the kexec image and initramfs. Changelog v3: - return -EBADF, not -ENOEXEC - identifier change - split patch, mo

[PATCH v4 13/19] module: replace copy_module_from_fd with kernel version

2016-02-12 Thread Mimi Zohar
Replace copy_module_from_fd() with kernel_read_file_from_fd(). Although none of the upstreamed LSMs define a kernel_module_from_file hook, IMA is called, based on policy, to prevent unsigned kernel modules from being loaded by the original kernel module syscall and to measure/appraise signed kerne

[PATCH v4 12/19] vfs: define kernel_copy_file_from_fd()

2016-02-12 Thread Mimi Zohar
This patch defines kernel_read_file_from_fd(), a wrapper for the VFS common kernel_read_file(). Changelog: - Separated from the kernel modules patch Acked-by: Kees Cook Acked-by: Luis R. Rodriguez Cc: Al Viro Signed-off-by: Mimi Zohar --- fs/exec.c | 16 include/lin

[PATCH v4 16/19] ima: support for kexec image and initramfs

2016-02-12 Thread Mimi Zohar
Add IMA policy support for measuring/appraising the kexec image and initramfs. Two new IMA policy identifiers KEXEC_KERNEL_CHECK and KEXEC_INITRAMFS_CHECK are defined. Example policy rules: measure func=KEXEC_KERNEL_CHECK appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig measure func=KEXEC_INI

[PATCH v4 09/19] vfs: define kernel_read_file_from_path

2016-02-12 Thread Mimi Zohar
This patch defines kernel_read_file_from_path(), a wrapper for the VFS common kernel_read_file(). Changelog: - Separated from the IMA patch Signed-off-by: Mimi Zohar Acked-by: Kees Cook Acked-by: Luis R. Rodriguez Cc: Al Viro --- fs/exec.c | 22 ++ include/linux/

[PATCH v4 14/19] ima: remove firmware and module specific cached status info

2016-02-12 Thread Mimi Zohar
Each time a file is read by the kernel, the file should be re-measured and the file signature re-appraised, based on policy. As there is no need to preserve the status information, this patch replaces the firmware and module specific cache status with a generic one named read_file. This change si

[PATCH v4 17/19] ima: load policy using path

2016-02-12 Thread Mimi Zohar
From: Dmitry Kasatkin We currently cannot do appraisal or signature vetting of IMA policies since we currently can only load IMA policies by writing the contents of the policy directly in, as follows: cat policy-file > /ima/policy If we provide the kernel the path to the IMA policy so it can lo

[PATCH v4 11/19] security: define kernel_read_file hook

2016-02-12 Thread Mimi Zohar
The kernel_read_file security hook is called prior to reading the file into memory. Signed-off-by: Mimi Zohar Acked-by: Kees Cook Acked-by: Luis R. Rodriguez Acked-by: Casey Schaufler --- fs/exec.c | 4 include/linux/ima.h | 6 ++ include/linux

[PATCH v4 04/19] vfs: define a generic function to read a file from the kernel

2016-02-12 Thread Mimi Zohar
For a while it was looked down upon to directly read files from Linux. These days there exists a few mechanisms in the kernel that do just this though to load a file into a local buffer. There are minor but important checks differences on each. This patch set is the first attempt at resolving som

[PATCH v4 08/19] ima: define a new hook to measure and appraise a file already in memory

2016-02-12 Thread Mimi Zohar
This patch defines a new IMA hook ima_post_read_file() for measuring and appraising files read by the kernel. The caller loads the file into memory before calling this function, which calculates the hash followed by the normal IMA policy based processing. Changelog v3: - rename ima_hash_and_proces

[PATCH v4 00/19] vfs: support for a common kernel file loader

2016-02-12 Thread Mimi Zohar
For a while it was looked down upon to directly read files from Linux. These days there exists a few mechanisms in the kernel that do just this though to load a file into a local buffer. There are minor but important checks differences on each, we should take all the best practices from each of the

[PATCH v4 05/19] vfs: define kernel_read_file_id enumeration

2016-02-12 Thread Mimi Zohar
To differentiate between the kernel_read_file() callers, this patch defines a new enumeration named kernel_read_file_id and includes the caller identifier as an argument. Subsequent patches define READING_KEXEC_IMAGE, READING_KEXEC_INITRAMFS, READING_FIRMWARE, READING_MODULE, and READING_POLICY.

[PATCH v4 06/19] ima: provide buffer hash calculation function

2016-02-12 Thread Mimi Zohar
From: Dmitry Kasatkin This patch provides convenient buffer hash calculation function. Changelog v3: - fix while hash calculation - Dmitry v1: - rewrite to support loff_t sized buffers - Mimi (based on Fenguang Wu's testing) Signed-off-by: Dmitry Kasatkin Signed-off-by: Mimi Zohar --- secu

[PATCH v4 07/19] ima: calculate the hash of a buffer using aynchronous hash(ahash)

2016-02-12 Thread Mimi Zohar
Setting up ahash has some overhead. Only use ahash to calculate the hash of a buffer, if the buffer is larger than ima_ahash_minsize. Signed-off-by: Mimi Zohar Acked-by: Dmitry Kasatkin --- security/integrity/ima/ima_crypto.c | 75 - 1 file changed, 73 inser

Re: [PATCH v3 19/22] ima: support for kexec image and initramfs

2016-02-12 Thread Mimi Zohar
On Fri, 2016-02-12 at 20:53 +0800, Dave Young wrote: > Hi, Mimi > > > diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h > > index a5d2592..832e62a 100644 > > --- a/security/integrity/ima/ima.h > > +++ b/security/integrity/ima/ima.h > > @@ -147,6 +147,8 @@ enum ima_hooks { >

Re: [PATCH v3 19/22] ima: support for kexec image and initramfs

2016-02-12 Thread Dave Young
Hi, Mimi > diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h > index a5d2592..832e62a 100644 > --- a/security/integrity/ima/ima.h > +++ b/security/integrity/ima/ima.h > @@ -147,6 +147,8 @@ enum ima_hooks { > POST_SETATTR, > MODULE_CHECK, > FIRMWARE_CHECK, >

Re: [PATCH v3 18/22] kexec: replace call to copy_file_from_fd() with kernel version

2016-02-12 Thread Dave Young
On 02/03/16 at 02:06pm, Mimi Zohar wrote: > Replace copy_file_from_fd() with kernel_read_file_from_fd(). > > Two new identifiers named READING_KEXEC_IMAGE and READING_KEXEC_INITRAMFS > are defined for measuring, appraising or auditing the kexec image and > initramfs. > > Changelog v3: > - return

Re: [PATCH] x86/efi: skip bgrt init for kexec reboot

2016-02-12 Thread Dave Young
On 02/11/16 at 04:09pm, Matt Fleming wrote: > On Fri, 05 Feb, at 08:41:15AM, Dave Young wrote: > > On 02/04/16 at 11:56am, Matt Fleming wrote: > > > On Thu, 04 Feb, at 07:09:03PM, Dave Young wrote: > > > > > > > > Consider the original code path, maybe change it to efi_kexec_setup will > > > > be