added ima hook for buffer, being enabled as a policy
Subsystems (5)
RFC PATCH v2 1/5 added ima hook for buffer, being enabled as a policy
From: Prakhar Srivastava <[email protected]>
---
Currently for soft reboot(kexec_file_load) the kernel file and signature is measured by IMA. The cmdline args used to load the kernel is not measured.
The boot aggregate that gets calculated will have no change since the EFI loader has not been triggered.
Adding the kexec cmdline args measure and kernel version will add some attestable criteria.
This adds a new ima hook ima_buffer_check and a policy entry BUFFER_CHECK. This enables buffer has measurements into ima log
Documentation/ABI/testing/ima_policy | 1 + include/linux/ima.h | 13 +++- security/integrity/ima/ima.h | 1 + security/integrity/ima/ima_main.c | 95 ++++++++++++++++++++++++++++ security/integrity/ima/ima_policy.c | 14 +++- 5 files changed, 122 insertions(+), 2 deletions(-)
Documentation/ABI/testing/ima_policy +1 -0
@@ -28,6 +28,7 @@ Description: base: func:= [BPRM_CHECK][MMAP_CHECK][FILE_CHECK][MODULE_CHECK] [FIRMWARE_CHECK] [KEXEC_KERNEL_CHECK] [KEXEC_INITRAMFS_CHECK] + [BUFFER_CHECK] mask:= [[^]MAY_READ] [[^]MAY_WRITE] [[^]MAY_APPEND] [[^]MAY_EXEC] fsmagic:= hex value
include/linux/ima.h +12 -1
@@ -14,6 +14,12 @@#include <linux/kexec.h> struct linux_binprm ; +enum __buffer_id { +KERNEL_VERSION , +KEXEC_CMDLINE , +MAX_BUFFER_ID =KEXEC_CMDLINE +} buffer_id; +#ifdef CONFIG_IMA extern int ima_bprm_check (struct linux_binprm *bprm);extern int ima_file_check (struct file *file,int mask,int opened);
@@ -23,7 +29,7 @@ extern int ima_read_file(struct file *file, enum kernel_read_file_id id);extern int ima_post_read_file (struct file *file,void *buf,loff_t size,enum kernel_read_file_id id);extern void ima_post_path_mknod (struct dentry *dentry); - +extern void ima_buffer_check (const void *buff,int size,enum buffer_id id);#ifdef CONFIG_IMA_KEXEC extern void ima_add_kexec_buffer (struct kimage *image);#endif
@@ -65,6 +71,11 @@ static inline void ima_post_path_mknod(struct dentry *dentry) return; } +static inline void ima_buffer_check (const void *buff,int size, +enum buffer_id id) +{ +return ; +}#endif /* CONFIG_IMA */ #ifndef CONFIG_IMA_KEXEC
security/integrity/ima/ima.h +1 -0
@@ -181,6 +181,7 @@ enum ima_hooks {FIRMWARE_CHECK ,KEXEC_KERNEL_CHECK ,KEXEC_INITRAMFS_CHECK , +BUFFER_CHECK ,POLICY_CHECK , MAX_CHECK };
security/integrity/ima/ima_main.c +95 -0
107 lines not on this page · raw message
security/integrity/ima/ima_policy.c +13 -1
@@ -231,6 +231,12 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode,const struct cred *cred =current_cred ();int i; +// Incase of BUFFER_CHECK, Inode is NULL +if (!inode) { +if ((rule->flags &IMA_FUNC ) && (rule->func == func)) +return true; +return false; + }if ((rule->flags &IMA_FUNC ) && (rule->func != func && func !=POST_SETATTR ))return false;
@@ -665,6 +671,8 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)else if (strcmp (args[0 ].from,"KEXEC_INITRAMFS_CHECK" ) ==0 ) entry->func =KEXEC_INITRAMFS_CHECK ; +else if (strcmp (args[0 ].from,"BUFFER_CHECK" ) ==0 ) + entry->func =BUFFER_CHECK ;else if (strcmp (args[0 ].from,"POLICY_CHECK" ) ==0 ) entry->func =POLICY_CHECK ;else
@@ -944,7 +952,7 @@ enum { func_file =0 , func_mmap, func_bprm, func_module, func_firmware, func_post, func_kexec_kernel, func_kexec_initramfs, - func_policy + func_buffer, func_policy }; static char *func_tokens[] = {
@@ -956,6 +964,7 @@ static char *func_tokens[] = {"POST_SETATTR" ,"KEXEC_KERNEL_CHECK" ,"KEXEC_INITRAMFS_CHECK" , +"BUFFER_CHECK" , "POLICY_CHECK" };
@@ -1027,6 +1036,9 @@ static void policy_func_show(struct seq_file *m, enum ima_hooks func)case KEXEC_INITRAMFS_CHECK :seq_printf (m,pt (Opt_func),ft (func_kexec_initramfs));break ; +case BUFFER_CHECK : +seq_printf (m,pt (Opt_func),ft (func_buffer)); +break ;case POLICY_CHECK :seq_printf (m,pt (Opt_func),ft (func_policy));break ;
Signature · 1 line
2.17.1
RFC PATCH v2 2/5 use event name instead of enum to make the call generic
From: Prakhar Srivastava <[email protected]>
---
Currently for soft reboot(kexec_file_load) the kernel file and signature is measured by IMA. The cmdline args used to load the kernel is not measured.
The boot aggregate that gets calculated will have no change since the EFI loader has not been triggered.
Adding the kexec cmdline args measure and kernel version will add some attestable criteria.
remove enums to control type of buffers entries, instead pass the event name to be used.
include/linux/ima.h | 10 ++-------- kernel/kexec_file.c | 3 +++ security/integrity/ima/ima.h | 2 +- security/integrity/ima/ima_main.c | 30 ++++++++++-------------------- 4 files changed, 16 insertions(+), 29 deletions(-)
include/linux/ima.h +2 -8
@@ -14,12 +14,6 @@#include <linux/kexec.h> struct linux_binprm ; -enum __buffer_id { -KERNEL_VERSION , -KEXEC_CMDLINE , -MAX_BUFFER_ID =KEXEC_CMDLINE -} buffer_id; -#ifdef CONFIG_IMA extern int ima_bprm_check (struct linux_binprm *bprm);extern int ima_file_check (struct file *file,int mask,int opened);
@@ -29,7 +23,7 @@ extern int ima_read_file(struct file *file, enum kernel_read_file_id id);extern int ima_post_read_file (struct file *file,void *buf,loff_t size,enum kernel_read_file_id id);extern void ima_post_path_mknod (struct dentry *dentry); -extern void ima_buffer_check (const void *buff,int size,enum buffer_id id); +extern void ima_buffer_check (const void *buff,int size,char *eventname);#ifdef CONFIG_IMA_KEXEC extern void ima_add_kexec_buffer (struct kimage *image);#endif
@@ -72,7 +66,7 @@ static inline void ima_post_path_mknod(struct dentry *dentry) }static inline void ima_buffer_check (const void *buff,int size, -enum buffer_id id) +char *eventname) {return ; }
kernel/kexec_file.c +3 -0
@@ -182,6 +182,9 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd, ret = -EINVAL ; goto out; } + +ima_buffer_check (image->cmdline_buf, cmdline_len -1 , +"kexec_cmdline" ); }/* Call arch image load handlers */
security/integrity/ima/ima.h +1 -1
@@ -181,8 +181,8 @@ enum ima_hooks {FIRMWARE_CHECK ,KEXEC_KERNEL_CHECK ,KEXEC_INITRAMFS_CHECK , -BUFFER_CHECK ,POLICY_CHECK , +BUFFER_CHECK , MAX_CHECK };
security/integrity/ima/ima_main.c +10 -20
@@ -160,8 +160,7 @@ void ima_file_free(struct file *file)* (Instead of using the file hash the buffer hash is used). * @buff - The buffer that needs to be added to the log * @size - size of buffer(in bytes) -* @id - buffer id, this is differentiator for the various buffers -* that can be measured. +* @id - eventname, event name to be used for buffer measurement. * * The buffer passed is added to the ima logs. * If the sig template is used, then the sig field contains the buffer.
@@ -170,7 +169,7 @@ void ima_file_free(struct file *file)* On error cases surface errors from ima calls. */ static int process_buffer_measurement (const void *buff,int size, -enum buffer_id id) +char *eventname) {int ret = -EINVAL ;struct ima_template_entry *entry =NULL ;
@@ -185,23 +184,13 @@ static int process_buffer_measurement(const void *buff, int size,int violation =0 ;int pcr =CONFIG_IMA_MEASURE_PCR_IDX ; -if (!buff || size ==0 ) +if (!buff || size ==0 || !eventname) goto err_out;if (ima_get_action (NULL ,0 ,BUFFER_CHECK , &pcr) !=IMA_MEASURE ) goto err_out; -switch (buffer_id) { -case KERNEL_VERSION : - name ="Kernel-version" ; -break ; -case KEXEC_CMDLINE : - name ="Kexec-cmdline" ; -break ; -default : - goto err_out; - } - + name = eventname;memset (iint,0 ,sizeof (*iint));memset (&hash,0 ,sizeof (hash));
@@ -452,15 +441,16 @@ int ima_read_file(struct file *file, enum kernel_read_file_id read_id)* ima_buffer_check - based on policy, collect & store buffer measurement * @buf: pointer to buffer * @size: size of buffer -* @buffer_id: caller identifier +* @eventname: caller identifier * * Buffers can only be measured, not appraised. The buffer identifier -* is used as the measurement list entry name (eg. boot_cmdline). +* is used as the measurement list entry name (eg. boot_cmdline, +* kernel_version). */ -void ima_buffer_check (const void *buf,int size,enum buffer_id id) +void ima_buffer_check (const void *buf,int size,char *eventname) { -if (buf && size !=0 ) -process_buffer_measurement (buf, size, id); +if (buf && size !=0 && eventname) +process_buffer_measurement (buf, size, eventname);return ; }
Signature · 1 line
2.17.1
Re: [PATCH v2 2/5 RFC] use event name instead of enum to make the call generic
Quoted 5 lines · Prakhar Srivastava
From: Prakhar Srivastava <[email protected]>
Signed-off-by Prakhar Srivastava <[email protected]>---
Quoted 8 lines
Currently for soft
reboot(kexec_file_load)the kernel file and signature is measured by IMA. The cmdline args used to load the kernel is not measured.
The boot aggregate that gets calculated will have no change since the EFI loader has not been triggered.
Adding the kexec cmdline args measure and kernel version will add some attestable criteria.
Any reason for including the whole commit message after "---"
Anything after "---" is not included in the patch description when patch is applied.
This comment applies to all the patches in this patchset.
Quoted 1 line
remove enums to control type of buffers entries, instead pass the event name to be used.
Is the last statement meant to be a Changelog from v1-> v2 ? Only the changelog has to be after "---"
Also, If posting more than one patch, it is preferrable to add a cover-letter.
Quoted 11 lines
include/linux/ima.h | 10 ++-------- kernel/kexec_file.c | 3 +++ security/integrity/ima/ima.h | 2 +- security/integrity/ima/ima_main.c | 30 ++++++++++-------------------- 4 files changed, 16 insertions(+), 29 deletions(-)include/linux/ima.h +0
-0
include/linux/ima.h line 22
Quoted 9 lines
include/linux/ima.h +0
-6@@ -14,12 +14,6 @@#include <linux/kexec.h> struct linux_binprm ; -enum __buffer_id { -KERNEL_VERSION , -KEXEC_CMDLINE , -MAX_BUFFER_ID =KEXEC_CMDLINE -} buffer_id; -
Is the v2 version created on top of the v1 version that was posted ?
The v2 version has to be on top of the HEAD of the repository itself, and not on the v1 version. Only the final reviewed and tested version makes to the upstream.
Btw, which repository and its branch are you using ?
Thanks & Regards,
- Nayna
Quoted 120 lines
include/linux/ima.h +2
-2#ifdef CONFIG_IMA extern int ima_bprm_check (struct linux_binprm *bprm);extern int ima_file_check (struct file *file,int mask,int opened);@@ -29,7 +23,7 @@ extern int ima_read_file(struct file *file, enum kernel_read_file_id id);extern int ima_post_read_file (struct file *file,void *buf,loff_t size,enum kernel_read_file_id id);extern void ima_post_path_mknod (struct dentry *dentry); -extern void ima_buffer_check (const void *buff,int size,enum buffer_id id); +extern void ima_buffer_check (const void *buff,int size,char *eventname);#ifdef CONFIG_IMA_KEXEC extern void ima_add_kexec_buffer (struct kimage *image);#endif @@ -72,7 +66,7 @@ static inline void ima_post_path_mknod(struct dentry *dentry) }static inline void ima_buffer_check (const void *buff,int size, -enum buffer_id id) +char *eventname) {return ; }kernel/kexec_file.c +3
-0@@ -182,6 +182,9 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd, ret = -EINVAL ; goto out; } + +ima_buffer_check (image->cmdline_buf, cmdline_len -1 , +"kexec_cmdline" ); }/* Call arch image load handlers */ security/integrity/ima/ima.h +1
-1@@ -181,8 +181,8 @@ enum ima_hooks {FIRMWARE_CHECK ,KEXEC_KERNEL_CHECK ,KEXEC_INITRAMFS_CHECK , -BUFFER_CHECK ,POLICY_CHECK , +BUFFER_CHECK , MAX_CHECK };security/integrity/ima/ima_main.c +10
-20@@ -160,8 +160,7 @@ void ima_file_free(struct file *file)* (Instead of using the file hash the buffer hash is used). * @buff - The buffer that needs to be added to the log * @size - size of buffer(in bytes) -* @id - buffer id, this is differentiator for the various buffers -* that can be measured. +* @id - eventname, event name to be used for buffer measurement. * * The buffer passed is added to the ima logs. * If the sig template is used, then the sig field contains the buffer. @@ -170,7 +169,7 @@ void ima_file_free(struct file *file)* On error cases surface errors from ima calls. */ static int process_buffer_measurement (const void *buff,int size, -enum buffer_id id) +char *eventname) {int ret = -EINVAL ;struct ima_template_entry *entry =NULL ;@@ -185,23 +184,13 @@ static int process_buffer_measurement(const void *buff, int size,int violation =0 ;int pcr =CONFIG_IMA_MEASURE_PCR_IDX ; -if (!buff || size ==0 ) +if (!buff || size ==0 || !eventname) goto err_out;if (ima_get_action (NULL ,0 ,BUFFER_CHECK , &pcr) !=IMA_MEASURE ) goto err_out; -switch (buffer_id) { -case KERNEL_VERSION : - name ="Kernel-version" ; -break ; -case KEXEC_CMDLINE : - name ="Kexec-cmdline" ; -break ; -default : - goto err_out; - } - + name = eventname;memset (iint,0 ,sizeof (*iint));memset (&hash,0 ,sizeof (hash));@@ -452,15 +441,16 @@ int ima_read_file(struct file *file, enum kernel_read_file_id read_id)* ima_buffer_check - based on policy, collect & store buffer measurement * @buf: pointer to buffer * @size: size of buffer -* @buffer_id: caller identifier +* @eventname: caller identifier * * Buffers can only be measured, not appraised. The buffer identifier -* is used as the measurement list entry name (eg. boot_cmdline). +* is used as the measurement list entry name (eg. boot_cmdline, +* kernel_version). */ -void ima_buffer_check (const void *buf,int size,enum buffer_id id) +void ima_buffer_check (const void *buf,int size,char *eventname) { -if (buf && size !=0 ) -process_buffer_measurement (buf, size, id); +if (buf && size !=0 && eventname) +process_buffer_measurement (buf, size, eventname);return ; }
Re: [PATCH v2 2/5 RFC] use event name instead of enum to make the call generic
Quoted 17 lines · Nayna
Quoted 5 lines · Prakhar Srivastava
From: Prakhar Srivastava <[email protected]>
Signed-off-by Prakhar Srivastava <[email protected]>---
Quoted 8 lines
Currently for soft
reboot(kexec_file_load)the kernel file and signature is measured by IMA. The cmdline args used to load the kernel is not measured.
The boot aggregate that gets calculated will have no change since the EFI loader has not been triggered.
Adding the kexec cmdline args measure and kernel version will add some attestable criteria.
Quoted 5 lines
Any reason for including the whole commit message after "---"
Anything after "---" is not included in the patch description when patch is applied.
This comment applies to all the patches in this patchset.
I will fix the comments and send out the patchset with a cover letter. Thankyou for pointing this out.
Quoted 6 lines
Quoted 2 lines
remove enums to control type of buffers entries, instead pass the event name to be used.
Is the last statement meant to be a Changelog from v1-> v2 ? Only the changelog has to be after "---"
Also, If posting more than one patch, it is preferrable to add a cover-letter.
I will add a cover letter alongside fixing the comments. Thankyou!
Quoted 16 lines
Quoted 16 lines
include/linux/ima.h | 10 ++-------- kernel/kexec_file.c | 3 +++ security/integrity/ima/ima.h | 2 +-
security/integrity/ima/ima_main.c| 30 ++++++++++--------------------4 files changed, 16 insertions(+), 29 deletions(-)include/linux/ima.h +0
-0@@ -14,12 +14,6 @@ #include <linux/kexec.h> struct linux_binprm;
Quoted 9 lines
include/linux/ima.h line 22
Quoted 6 lines
include/linux/ima.h +0
-6-enum __buffer_id { - KERNEL_VERSION, - KEXEC_CMDLINE, - MAX_BUFFER_ID = KEXEC_CMDLINE -} buffer_id; -Is the v2 version created on top of the v1 version that was posted ?
v2 is based off the HEAD of the repo.
Quoted 4 lines
The v2 version has to be on top of the HEAD of the repository itself, and not on the v1 version. Only the final reviewed and tested version makes to the upstream.
Btw, which repository and its branch are you using ?
I am basing my changes off IMA branch:git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git
Quoted 133 lines
Thanks & Regards,
- NaynaQuoted 127 lines
include/linux/ima.h +1
-1#ifdef CONFIG_IMA extern int ima_bprm_check(struct linux_binprm *bprm); extern int ima_file_check(struct file *file, int mask, int opened);@@ -29,7 +23,7 @@ extern int ima_read_file(struct file *file, enum kernel_read_file_id id); extern int ima_post_read_file(struct file *file, void *buf, loff_t size, enum kernel_read_file_id id); extern void ima_post_path_mknod(struct dentry *dentry); -extern void ima_buffer_check (const void *buff,int size,enum buffer_id id); +extern void ima_buffer_check (const void *buff,int size,char *eventname);#ifdef
CONFIG_IMA_KEXEC
extern voidima_add_kexec_buffer(struct kimage *image); #endifinclude/linux/ima.h +1
-1@@ -72,7 +66,7 @@ static inline void ima_post_path_mknod(struct dentry *dentry) } static inline void ima_buffer_check(const void *buff, int size, - enum buffer_id id) + char *eventname) { return;}
kernel/kexec_file.c +3
-0@@ -182,6 +182,9 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd, ret = -EINVAL; goto out; } + + ima_buffer_check(image->cmdline_buf, cmdline_len - 1, + "kexec_cmdline"); }/* Call arch image load handlers */
security/integrity/ima/ima.h +1
-1@@ -181,8 +181,8 @@ enum ima_hooks { FIRMWARE_CHECK, KEXEC_KERNEL_CHECK, KEXEC_INITRAMFS_CHECK, - BUFFER_CHECK, POLICY_CHECK, + BUFFER_CHECK,
MAX_CHECK
};security/integrity/ima/ima_main.c +10
-20@@ -160,8 +160,7 @@ void ima_file_free(struct file *file) * (Instead of using the file hash the buffer hash is used). * @buff - The buffer that needs to be added to the log * @size - size of buffer(in bytes) - * @id - buffer id, this is differentiator for the various buffers - * that can be measured. + * @id - eventname, event name to be used for buffer measurement. * * The buffer passed is added to the ima logs. * If the sig template is used, then the sig field contains the buffer.@@ -170,7 +169,7 @@ void ima_file_free(struct file *file)* On error cases surface errors from ima calls. */ static int process_buffer_measurement(const void *buff, int size, - enum buffer_id id) + char *eventname) { int ret = -EINVAL; struct ima_template_entry *entry = NULL;@@ -185,23 +184,13 @@ static int process_buffer_measurement(const void *buff, int size, int violation = 0; int pcr = CONFIG_IMA_MEASURE_PCR_IDX; - if (!buff || size == 0) + if (!buff || size == 0 || !eventname) goto err_out; if (ima_get_action(NULL, 0, BUFFER_CHECK, &pcr) != IMA_MEASURE) goto err_out; - switch (buffer_id) { - case KERNEL_VERSION: - name = "Kernel-version"; - break; - case KEXEC_CMDLINE: - name = "Kexec-cmdline"; - break; - default: - goto err_out; - } - + name = eventname; memset(iint, 0, sizeof(*iint)); memset(&hash, 0, sizeof(hash));@@ -452,15 +441,16 @@ int ima_read_file(struct file *file, enumkernel_read_file_id read_id) * ima_buffer_check - based on policy, collect & store buffer measurement * @buf: pointer to buffer * @size: size of buffer -* @buffer_id: caller identifier +* @eventname: caller identifier * * Buffers can only be measured, not appraised. The buffer identifier -* is used as the measurement list entry name (eg. boot_cmdline). +* is used as the measurement list entry name (eg. boot_cmdline, +* kernel_version). */ -void ima_buffer_check (const void *buf,int size,enum buffer_id id) +void ima_buffer_check (const void *buf,int size,char *eventname) { - if (buf && size != 0) - process_buffer_measurement(buf, size, id); + if (buf && size != 0 && eventname) + process_buffer_measurement(buf, size, eventname); return;}
Re: [PATCH v2 2/5 RFC] use event name instead of enum to make the call generic
Quoted 3 lines · prsriva
I will fix the comments and send out the patchset with a cover letter. Thankyou for pointing this out.
Please trim the emails you reply to rather than quoting everything.
But the real reason I'm reacting to this email is because it was marked as spam, because your SMTP setup is incorrect, and you don't go through the proper MS SMTP server. As a result, you don't get the proper DKIM signature for verification of the microsoft.com email address, and sane email clients will mark your emails as spam.
Please fix.
Linus
James Morris
maintainerRe: [PATCH v2 2/5 RFC] use event name instead of enum to make the call generic
Quoted 7 lines · Linus Torvalds
Quoted 3 lines · prsriva
I will fix the comments and send out the patchset with a cover letter. Thankyou for pointing this out.
Please trim the emails you reply to rather than quoting everything.
Quoted 7 lines
But the real reason I'm reacting to this email is because it was marked as spam, because your SMTP setup is incorrect, and you don't go through the proper MS SMTP server. As a result, you don't get the proper DKIM signature for verification of the microsoft.com email address, and sane email clients will mark your emails as spam.
Please fix.
It's the correct SMTP server for linux.microsoft.com.
linux.microsoft.com. 3600 IN TXT "v=spf1 ip4:13.77.154.182 -all"
linux.microsoft.com. 3600 IN TXT "v=DMARC1;p=none;pct=100;rua=mailto:[email protected]"
We don't have DKIM set up yet.
Signature · 2 lines
James Morris <[email protected]>
James Bottomley
maintainerRe: [PATCH v2 2/5 RFC] use event name instead of enum to make the call generic
Quoted 17 lines · James Morris
Quoted 15 lines · Linus Torvalds
Quoted 3 lines · prsriva
I will fix the comments and send out the patchset with a cover letter. Thankyou for pointing this out.
Please trim the emails you reply to rather than quoting everything.
But the real reason I'm reacting to this email is because it was marked as spam, because your SMTP setup is incorrect, and you don't go through the proper MS SMTP server. As a result, you don't get the proper DKIM signature for verification of the microsoft.com email address, and sane email clients will mark your emails as spam.
Quoted 8 lines
Quoted 1 line
Please fix.
It's the correct SMTP server for linux.microsoft.com.
linux.microsoft.com. 3600 IN TXT "v=spf1
ip4:13.77.154.182 -all"
linux.microsoft.com. 3600 IN TXT "v=DMARC
1;p=none;pct=100;rua=mailto:[email protected]"
That's not the correct location: DMARC records should be at the _dmarc. subdomain. without this you'll inherit the dmarc policy of _dmarc.microsoft.com
Quoted 1 line
We don't have DKIM set up yet.
If you advertise DMARC, you're expected to have DKIM working for spam purposes. On the other hand, if you don't advertise DMARC, google will probably still bin all your email as spam.
James
James Morris
maintainerRe: [PATCH v2 2/5 RFC] use event name instead of enum to make the call generic
Quoted 4 lines · James Bottomley
That's not the correct location: DMARC records should be at the
_dmarc. subdomain. without this you'll inherit the dmarc policy of _dmarc.microsoft.com
Thanks.
Quoted 5 lines
Quoted 1 line
We don't have DKIM set up yet.
If you advertise DMARC, you're expected to have DKIM working for spam purposes. On the other hand, if you don't advertise DMARC, google will probably still bin all your email as spam.
Working on it.
Signature · 2 lines
James Morris <[email protected]>
Re: [PATCH v2 2/5 RFC] use event name instead of enum to make the call generic
In reply to James MorrisQuoted 4 lines · James Morris
Quoted 2 lines
Please fix.
It's the correct SMTP server for linux.microsoft.com.
In that case, it seems that your SMTP server is misconfigured, and shouldn't be used.
Quoted 4 lines
linux.microsoft.com. 3600 IN TXT "v=spf1 ip4:13.77.154.182 -all" linux.microsoft.com. 3600 IN TXT "v=DMARC1;p=none;pct=100;rua=mailto:[email protected]"We don't have DKIM set up yet.
I get
dmarc=fail (p=REJECT sp=REJECT dis=QUARANTINE) header.from=microsoft.com
because the microsoft.com DMARC rules will be triggered before the "linux.microsoft.com" rules are.
Linus
Re: [PATCH v2 2/5 RFC] use event name instead of enum to make the call generic
In reply to prsrivaQuoted 9 lines · prsriva
Quoted 8 lines · Nayna
Quoted 5 lines · Prakhar Srivastava
From: Prakhar Srivastava <[email protected]>
Signed-off-by Prakhar Srivastava <[email protected]>---
Quoted 6 lines
Quoted 4 lines
The v2 version has to be on top of the HEAD of the repository itself, and not on the v1 version. Only the final reviewed and tested version makes to the upstream.
Btw, which repository and its branch are you using ?
I am basing my changes off IMA branch:
git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git
Ok. Please use either next-integrity branch or James Morris next-general or next-testing.
Thanks & Regards,
- Nayna
RFC PATCH v2 3/5 since cmdline args can be same for multiple kexec, log entry hash will collide. Prepend the kernel file name to the cmdline args to distinguish between cmdline args passed to subsequent kexec calls
In reply to Prakhar SrivastavaFrom: Prakhar Srivastava <[email protected]>
---
Currently for soft reboot(kexec_file_load) the kernel file and signature is measured by IMA. The cmdline args used to load the kernel is not measured.
The boot aggregate that gets calculated will have no change since the EFI loader has not been triggered.
Adding the kexec cmdline args measure and kernel version will add some attestable criteria.
Cmdline args can be same for multiple kexec, log entry
hash will collide. Prepend the kernel file name to the cmdline args to distinguish between cmdline args passed to subsequent kexec calls
kernel/kexec_core.c | 57 +++++++++++++++++++++++++++++++++++++++++ kernel/kexec_file.c | 14 ++++++++-- kernel/kexec_internal.h | 3 +++ 3 files changed, 72 insertions(+), 2 deletions(-)
kernel/kexec_core.c +57 -0
@@ -1151,3 +1151,60 @@ void __weak arch_kexec_protect_crashkres(void)void __weak arch_kexec_unprotect_crashkres (void ) {} + +/** +* kexec_cmdline_prepend_img_name - prepare the buffer with cmdline +* that needs to be measured +* @outbuf - out buffer that contains the formated string +* @kernel_fd - the file identifier for the kerenel image +* @cmdline_ptr - ptr to the cmdline buffer +* @cmdline_len - len of the buffer. +* +* This generates a buffer in the format Kerenelfilename::cmdline +* +* On success return 0. +* On failure return -EINVAL. +*/ +int kexec_cmdline_prepend_img_name (char **outbuf,int kernel_fd, +const char *cmdline_ptr, +unsigned long cmdline_len) +{ +int ret = -EINVAL ; +struct fd f = {}; +int size =0 ; +char *buf =NULL ; +char delimiter[] ="::" ; + +if (!outbuf || !cmdline_ptr) + goto out; + + f =fdget (kernel_fd); +if (!f.file) + goto out; + + size = (f.file->f_path.dentry->d_name.len + cmdline_len -1 + +ARRAY_SIZE (delimiter)) -1 ; + + buf =kzalloc (size,GFP_KERNEL ); +if (!buf) + goto out; + +memcpy (buf, f.file->f_path.dentry->d_name.name, + f.file->f_path.dentry->d_name.len); +memcpy (buf + f.file->f_path.dentry->d_name.len, + delimiter,ARRAY_SIZE (delimiter) -1 ); +memcpy (buf + f.file->f_path.dentry->d_name.len + +ARRAY_SIZE (delimiter) -1 , + cmdline_ptr, cmdline_len -1 ); + + *outbuf = buf; + ret = size; + +pr_debug ("kexec cmdline buff: %s\n" , buf); + +out: +if (f.file) +fdput (f); + +return ret; +}
kernel/kexec_file.c +12 -2
@@ -126,6 +126,8 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd,int ret =0 ;void *ldata;loff_t size; +char *buff_to_measure =NULL ; +int buff_to_measure_size =0 ; ret =kernel_read_file_from_fd (kernel_fd, &image->kernel_buf, &size,INT_MAX ,READING_KEXEC_IMAGE );
@@ -183,8 +185,13 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd, goto out; } -ima_buffer_check (image->cmdline_buf, cmdline_len -1 , -"kexec_cmdline" ); +/* IMA measures the cmdline args passed to the next kernel*/ + buff_to_measure_size =kexec_cmdline_prepend_img_name (&buff_to_measure, + kernel_fd, image->cmdline_buf, image->cmdline_buf_len); + +ima_buffer_check (buff_to_measure, buff_to_measure_size, +"kexec_cmdline" ); + }/* Call arch image load handlers */
@@ -200,6 +207,9 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd,/* In case of error, free up all allocated memory in this function */ if (ret)kimage_file_post_load_cleanup (image); + +kfree (buff_to_measure); +return ret; }
kernel/kexec_internal.h +3 -0
@@ -11,6 +11,9 @@ int kimage_load_segment(struct kimage *image, struct kexec_segment *segment);void kimage_terminate (struct kimage *image);int kimage_is_destination_range (struct kimage *image,unsigned long start,unsigned long end); +int kexec_cmdline_prepend_img_name (char **outbuf,int kernel_fd, +const char *cmdline_ptr, +unsigned long cmdline_len);extern struct mutex kexec_mutex;
Signature · 1 line
2.17.1
RFC PATCH v2 4/5 added a buffer_check LSM hook
In reply to Prakhar SrivastavaFrom: Prakhar Srivastava <[email protected]>
---
Currently for soft reboot(kexec_file_load) the kernel file and signature is measured by IMA. The cmdline args used to load the kernel is not measured.
The boot aggregate that gets calculated will have no change since the EFI loader has not been triggered.
Adding the kexec cmdline args measure and kernel version will add some attestable criteria.
This patch adds a LSM hook for buffer_check
Suggested by Mimi Zohar
include/linux/lsm_hooks.h | 3 +++ include/linux/security.h | 5 +++++ security/security.c | 7 +++++++ 3 files changed, 15 insertions(+)
include/linux/lsm_hooks.h +3 -0
@@ -1568,6 +1568,8 @@ union security_list_options {int (*inode_setsecctx)(struct dentry *dentry,void *ctx,u32 ctxlen);int (*inode_getsecctx)(struct inode *inode,void **ctx,u32 *ctxlen); +int (*buffer_check)(const void *buff,int size,const char *eventname); +#ifdef CONFIG_SECURITY_NETWORK int (*unix_stream_connect)(struct sock *sock,struct sock *other,struct sock *newsk);
@@ -1813,6 +1815,7 @@ struct security_hook_heads {struct list_head inode_notifysecctx;struct list_head inode_setsecctx;struct list_head inode_getsecctx; +struct list_head buffer_check;#ifdef CONFIG_SECURITY_NETWORK struct list_head unix_stream_connect;struct list_head unix_may_send;
include/linux/security.h +5 -0
@@ -377,6 +377,8 @@ void security_inode_invalidate_secctx(struct inode *inode);int security_inode_notifysecctx (struct inode *inode,void *ctx,u32 ctxlen);int security_inode_setsecctx (struct dentry *dentry,void *ctx,u32 ctxlen);int security_inode_getsecctx (struct inode *inode,void **ctx,u32 *ctxlen); + +void security_buffer_measure (const void *buff,int size,char *eventname);#else /* CONFIG_SECURITY */ struct security_mnt_opts { };
@@ -776,6 +778,9 @@ static inline void security_inode_getsecid(struct inode *inode, u32 *secid) *secid =0 ; } +static inline void security_buffer_measure (const void *buff,int size,char *eventname) +{ } +static inline int security_inode_copy_up (struct dentry *src,struct cred **new) {return 0 ;
security/security.c +7 -0
@@ -320,6 +320,13 @@ int security_bprm_check(struct linux_binprm *bprm)return ima_bprm_check (bprm); } +void security_buffer_measure (const void *buff,int size,char *eventname) +{ +call_void_hook (buffer_check, buff, size, eventname); +return ima_buffer_check (buff, size, eventname); +} + +void security_bprm_committing_creds (struct linux_binprm *bprm) {call_void_hook (bprm_committing_creds, bprm);
Signature · 1 line
2.17.1
RFC PATCH v2 5/5 add the buffer to the event data in ima free entry data if store_template failed added check in templates for buffer
In reply to Prakhar SrivastavaFrom: Prakhar Srivastava <[email protected]>
---
Currently for soft reboot(kexec_file_load) the kernel file and signature is measured by IMA. The cmdline args used to load the kernel is not measured.
The boot aggregate that gets calculated will have no change since the EFI loader has not been triggered.
Adding the kexec cmdline args measure and kernel version will add some attestable criteria.
This patch adds the buffer to be measured as the event data. this also contains changes necessary for template
security/integrity/ima/ima_main.c | 36 +++++++++++++++++++++-- security/integrity/ima/ima_template_lib.c | 3 +- security/integrity/integrity.h | 1 + 3 files changed, 36 insertions(+), 4 deletions(-)
security/integrity/ima/ima_main.c +33 -3
@@ -14,7 +14,7 @@* * File: ima_main.c * implements the IMA hooks: ima_bprm_check, ima_file_mmap, -* and ima_file_check. +* ima_file_check and ima_buffer_check. */ #include <linux/module.h> #include <linux/file.h>
@@ -180,16 +180,37 @@ static int process_buffer_measurement(const void *buff, int size,struct ima_digest_data hdr;char digest[IMA_MAX_DIGEST_SIZE ]; } hash; +struct buffer_xattr { +enum evm_ima_xattr_type type; +u16 buff_length; +unsigned char buff[0 ]; + };char *name =NULL ;int violation =0 ;int pcr =CONFIG_IMA_MEASURE_PCR_IDX ; +struct buffer_xattr *buffer_event_data =NULL ; +int alloc_length =0 ; +int action =0 ;if (!buff || size ==0 || !eventname) goto err_out; -if (ima_get_action (NULL ,0 ,BUFFER_CHECK , &pcr) !=IMA_MEASURE ) + action =ima_get_action (NULL ,0 ,BUFFER_CHECK , &pcr); +if (!(action &IMA_AUDIT ) && !(action &IMA_MEASURE )) goto err_out; + alloc_length =sizeof (struct buffer_xattr ) + size; + buffer_event_data =kzalloc (alloc_length,GFP_KERNEL ); +if (!buffer_event_data) + goto err_out; + + buffer_event_data->type =IMA_BUFFER_CHECK ; + buffer_event_data->buff_length = size; +memcpy (buffer_event_data->buff, buff, size); + + event_data.xattr_value = (struct evm_ima_xattr_data *)buffer_event_data; + event_data.xattr_len = alloc_length; + name = eventname;memset (iint,0 ,sizeof (*iint));memset (&hash,0 ,sizeof (hash));
@@ -208,16 +229,25 @@ static int process_buffer_measurement(const void *buff, int size,if (ret <0 ) goto err_out; - ret =ima_store_template (entry, violation,NULL , +if (action &IMA_MEASURE ) + ret =ima_store_template (entry, violation,NULL , buff, pcr); +if (ret <0 ) {ima_free_template_entry (entry); goto err_out; } +if (action &IMA_AUDIT ) +ima_audit_measurement (iint, event_data.filename); + +kfree (buffer_event_data);return 0 ; err_out: + +kfree (buffer_event_data); +pr_err ("Error in adding buffer measure: %d\n" , ret);return ret; }
security/integrity/ima/ima_template_lib.c +2 -1
@@ -322,7 +322,8 @@ int ima_eventsig_init(struct ima_event_data *event_data,int xattr_len = event_data->xattr_len;int rc =0 ; -if ((!xattr_value) || (xattr_value->type !=EVM_IMA_XATTR_DIGSIG )) +if ((!xattr_value) || !((xattr_value->type ==EVM_IMA_XATTR_DIGSIG ) || + (xattr_value->type ==IMA_BUFFER_CHECK ))) goto out; rc = ima_write_template_field_data(xattr_value, xattr_len, fmt,
security/integrity/integrity.h +1 -0
@@ -58,6 +58,7 @@ enum evm_ima_xattr_type {EVM_XATTR_HMAC ,EVM_IMA_XATTR_DIGSIG ,IMA_XATTR_DIGEST_NG , +IMA_BUFFER_CHECK , IMA_XATTR_LAST };
Signature · 1 line
2.17.1