linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux-next: manual merge of the integrity tree with the pidfd tree
@ 2021-01-27  3:58 Stephen Rothwell
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Rothwell @ 2021-01-27  3:58 UTC (permalink / raw)
  To: Mimi Zohar, Dmitry Kasatkin, Christian Brauner
  Cc: Linux Kernel Mailing List, Linux Next Mailing List, Mimi Zohar,
	Tushar Sugandhi

[-- Attachment #1: Type: text/plain, Size: 2668 bytes --]

Hi all,

Today's linux-next merge of the integrity tree got a conflict in:

  security/integrity/ima/ima_policy.c

between commit:

  a2d2329e30e2 ("ima: handle idmapped mounts")

from the pidfd tree and commit:

  2b4a2474a202 ("IMA: generalize keyring specific measurement constructs")

from the integrity tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc security/integrity/ima/ima_policy.c
index e14426c24a19,9b45d064a87d..000000000000
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@@ -498,11 -522,10 +523,11 @@@ static bool ima_match_rule_data(struct 
   *
   * Returns true on rule match, false on failure.
   */
 -static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode,
 -			    const struct cred *cred, u32 secid,
 -			    enum ima_hooks func, int mask,
 +static bool ima_match_rules(struct ima_rule_entry *rule,
 +			    struct user_namespace *mnt_userns,
 +			    struct inode *inode, const struct cred *cred,
 +			    u32 secid, enum ima_hooks func, int mask,
- 			    const char *keyring)
+ 			    const char *func_data)
  {
  	int i;
  
@@@ -623,11 -650,10 +653,11 @@@ static int get_subaction(struct ima_rul
   * list when walking it.  Reads are many orders of magnitude more numerous
   * than writes so ima_match_policy() is classical RCU candidate.
   */
 -int ima_match_policy(struct inode *inode, const struct cred *cred, u32 secid,
 -		     enum ima_hooks func, int mask, int flags, int *pcr,
 +int ima_match_policy(struct user_namespace *mnt_userns, struct inode *inode,
 +		     const struct cred *cred, u32 secid, enum ima_hooks func,
 +		     int mask, int flags, int *pcr,
  		     struct ima_template_desc **template_desc,
- 		     const char *keyring)
+ 		     const char *func_data)
  {
  	struct ima_rule_entry *entry;
  	int action = 0, actmask = flags | (flags << 1);
@@@ -641,8 -667,8 +671,8 @@@
  		if (!(entry->action & actmask))
  			continue;
  
 -		if (!ima_match_rules(entry, inode, cred, secid, func, mask,
 -				     func_data))
 +		if (!ima_match_rules(entry, mnt_userns, inode, cred, secid,
- 				     func, mask, keyring))
++				     func, mask, func_data))
  			continue;
  
  		action |= entry->flags & IMA_ACTION_FLAGS;

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* linux-next: manual merge of the integrity tree with the pidfd tree
@ 2021-01-27  4:19 Stephen Rothwell
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Rothwell @ 2021-01-27  4:19 UTC (permalink / raw)
  To: Mimi Zohar, Dmitry Kasatkin, Christian Brauner
  Cc: Linux Kernel Mailing List, Linux Next Mailing List, Mimi Zohar,
	Tushar Sugandhi

[-- Attachment #1: Type: text/plain, Size: 4725 bytes --]

Hi all,

FIXME: Add owner of second tree to To:
       Add author(s)/SOB of conflicting commits.

Today's linux-next merge of the integrity tree got a conflict in:

  security/integrity/ima/ima_main.c

between commit:

  a2d2329e30e2 ("ima: handle idmapped mounts")

from the pidfd tree and commits:

  2b4a2474a202 ("IMA: generalize keyring specific measurement constructs")
  291af651b350 ("IMA: add support to measure buffer data hash")
  d6e645012d97 ("IMA: define a hook to measure kernel integrity critical data")

from the integrity tree.

In ima_measure_critical_data(), process_buffer_measurement() is called
with a NULL inode and func set to CRITCTAL_DATA.  In this case, the
mnt_userns parameter is not used (I followed the call chain down) and
so I just passed a NULL for it.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc security/integrity/ima/ima_main.c
index cb1c56eccd6d,6a429846f90a..000000000000
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@@ -816,22 -809,22 +816,24 @@@ int ima_post_load_data(char *buf, loff_
  }
  
  /*
-  * process_buffer_measurement - Measure the buffer to ima log.
+  * process_buffer_measurement - Measure the buffer or the buffer data hash
 + * @mnt_userns:	user namespace of the mount the inode was found from
   * @inode: inode associated with the object being measured (NULL for KEY_CHECK)
   * @buf: pointer to the buffer that needs to be added to the log.
   * @size: size of buffer(in bytes).
   * @eventname: event name to be used for the buffer entry.
   * @func: IMA hook
   * @pcr: pcr to extend the measurement
-  * @keyring: keyring name to determine the action to be performed
+  * @func_data: func specific data, may be NULL
+  * @buf_hash: measure buffer data hash
   *
-  * Based on policy, the buffer is measured into the ima log.
+  * Based on policy, either the buffer data or buffer data hash is measured
   */
 -void process_buffer_measurement(struct inode *inode, const void *buf, int size,
 +void process_buffer_measurement(struct user_namespace *mnt_userns,
 +				struct inode *inode, const void *buf, int size,
  				const char *eventname, enum ima_hooks func,
- 				int pcr, const char *keyring)
+ 				int pcr, const char *func_data,
+ 				bool buf_hash)
  {
  	int ret = 0;
  	const char *audit_cause = "ENOMEM";
@@@ -869,9 -864,8 +873,9 @@@
  	 */
  	if (func) {
  		security_task_getsecid(current, &secid);
 -		action = ima_get_action(inode, current_cred(), secid, 0, func,
 -					&pcr, &template, func_data);
 +		action = ima_get_action(mnt_userns, inode, current_cred(),
 +					secid, 0, func, &pcr, &template,
- 					keyring);
++					func_data);
  		if (!(action & IMA_MEASURE))
  			return;
  	}
@@@ -929,12 -937,38 +947,38 @@@ void ima_kexec_cmdline(int kernel_fd, c
  	if (!f.file)
  		return;
  
 -	process_buffer_measurement(file_inode(f.file), buf, size,
 -				   "kexec-cmdline", KEXEC_CMDLINE, 0, NULL,
 -				   false);
 +	process_buffer_measurement(file_mnt_user_ns(f.file), file_inode(f.file),
 +				   buf, size, "kexec-cmdline", KEXEC_CMDLINE, 0,
- 				   NULL);
++				   NULL, false);
  	fdput(f);
  }
  
+ /**
+  * ima_measure_critical_data - measure kernel integrity critical data
+  * @event_label: unique event label for grouping and limiting critical data
+  * @event_name: event name for the record in the IMA measurement list
+  * @buf: pointer to buffer data
+  * @buf_len: length of buffer data (in bytes)
+  * @hash: measure buffer data hash
+  *
+  * Measure data critical to the integrity of the kernel into the IMA log
+  * and extend the pcr.  Examples of critical data could be various data
+  * structures, policies, and states stored in kernel memory that can
+  * impact the integrity of the system.
+  */
+ void ima_measure_critical_data(const char *event_label,
+ 			       const char *event_name,
+ 			       const void *buf, size_t buf_len,
+ 			       bool hash)
+ {
+ 	if (!event_name || !event_label || !buf || !buf_len)
+ 		return;
+ 
 -	process_buffer_measurement(NULL, buf, buf_len, event_name,
++	process_buffer_measurement(NULL, NULL, buf, buf_len, event_name,
+ 				   CRITICAL_DATA, 0, event_label,
+ 				   hash);
+ }
+ 
  static int __init init_ima(void)
  {
  	int error;

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2021-01-27  5:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-27  3:58 linux-next: manual merge of the integrity tree with the pidfd tree Stephen Rothwell
2021-01-27  4:19 Stephen Rothwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).