mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
	Christian Brauner <christian.brauner@ubuntu.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	Mimi Zohar <zohar@linux.ibm.com>,
	Tushar Sugandhi <tusharsu@linux.microsoft.com>
Subject: linux-next: manual merge of the integrity tree with the pidfd tree
Date: Wed, 27 Jan 2021 15:19:31 +1100	[thread overview]
Message-ID: <20210127151931.530d7aa9@canb.auug.org.au> (raw)

[-- 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 --]

             reply	other threads:[~2021-01-27  5:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27  4:19 Stephen Rothwell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-01-27  3:58 Stephen Rothwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210127151931.530d7aa9@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=christian.brauner@ubuntu.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=tusharsu@linux.microsoft.com \
    --cc=zohar@linux.ibm.com \
    --cc=zohar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®