All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Garrett <mjg59@google.com>
To: linux-integrity@vger.kernel.org
Cc: zohar@linux.vnet.ibm.com, Matthew Garrett <mjg59@google.com>
Subject: [PATCH 6/6] EVM: Add a new digital signature format
Date: Wed, 27 Sep 2017 15:16:53 -0700	[thread overview]
Message-ID: <20170927221653.11219-7-mjg59@google.com> (raw)
In-Reply-To: <20170927221653.11219-1-mjg59@google.com>

As a companion to

EVM: Add an hmac_ng xattr format

add an equivalent format for digital signatures, identical to the
previous format but with an additional 64 bits of information about
which metadata was used to generate the signature. This allows for
distributing digital signatures that protect the metadata without having
to include the inode number (something that's not known in advance)

Signed-off-by: Matthew Garrett <mjg59@google.com>
---
 security/integrity/evm/evm_main.c | 26 ++++++++++++++++++++++++++
 security/integrity/integrity.h    |  6 ++++++
 2 files changed, 32 insertions(+)

diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index 77eda423824d..a58ff5d8caf6 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -128,9 +128,11 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
 {
 	struct evm_ima_xattr_data *xattr_data = NULL;
 	struct evm_hmac_ng_data *hmac_ng_data;
+	struct evm_ima_xattr_ng_data *digsig_ng_data;
 	struct evm_ima_xattr_data calc;
 	enum integrity_status evm_status = INTEGRITY_PASS;
 	int rc, xattr_len;
+	u64 flags;
 
 	if (iint && iint->evm_status == INTEGRITY_PASS)
 		return iint->evm_status;
@@ -209,6 +211,30 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
 		if (rc)
 			rc = -EINVAL;
 		break;
+	case EVM_IMA_XATTR_DIGSIG_NG:
+		digsig_ng_data = (struct evm_ima_xattr_ng_data *)xattr_data;
+		flags = be64_to_cpu(digsig_ng_data->hdr.flags);
+
+		rc = evm_calc_hash(dentry, xattr_name, xattr_value,
+				   xattr_value_len, flags, calc.digest);
+		if (rc)
+			break;
+		rc = integrity_digsig_verify(INTEGRITY_KEYRING_EVM,
+				 (const char *)&digsig_ng_data->sig,
+				 xattr_len-sizeof(struct evm_ima_xattr_ng_hdr),
+				 calc.digest, sizeof(calc.digest));
+		if (!rc) {
+			/* Replace RSA with HMAC if not mounted readonly and
+			 * not immutable
+			 */
+			if (!IS_RDONLY(d_backing_inode(dentry)) &&
+			    !IS_IMMUTABLE(d_backing_inode(dentry)))
+				evm_update_evmxattr(dentry, xattr_name,
+						    xattr_value,
+						    xattr_value_len,
+						    evm_default_flags);
+		}
+		break;
 	default:
 		rc = -EINVAL;
 		break;
diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h
index 9abd99224916..f41ccf42df65 100644
--- a/security/integrity/integrity.h
+++ b/security/integrity/integrity.h
@@ -64,6 +64,7 @@ enum evm_ima_xattr_type {
 	EVM_IMA_XATTR_DIGSIG,
 	IMA_XATTR_DIGEST_NG,
 	EVM_XATTR_HMAC_NG,
+	EVM_IMA_XATTR_DIGSIG_NG,
 	IMA_XATTR_LAST
 };
 
@@ -113,6 +114,11 @@ struct evm_hmac_ng_data {
 	u8 digest[SHA1_DIGEST_SIZE];
 } __packed;
 
+struct evm_ima_xattr_ng_data {
+	struct evm_ima_xattr_ng_hdr hdr;
+	struct signature_v2_hdr sig;
+} __packed;
+
 /* integrity data associated with an inode */
 struct integrity_iint_cache {
 	struct rb_node rb_node;	/* rooted in integrity_iint_tree */
-- 
2.14.2.822.g60be5d43e6-goog

  parent reply	other threads:[~2017-09-27 22:17 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-27 22:16 RFC: Make it practical to ship EVM signatures Matthew Garrett
2017-09-27 22:16 ` [PATCH 1/6] IMA: Allow EVM validation on appraisal even without a symmetric key Matthew Garrett
2017-10-01  2:08   ` Mimi Zohar
2017-10-02 17:02     ` Matthew Garrett
2017-10-02 19:41       ` Mimi Zohar
2017-09-27 22:16 ` [PATCH 2/6] EVM: Add infrastructure for making EVM fields optional Matthew Garrett
2017-09-27 22:16 ` [PATCH 3/6] EVM: Allow userland to override the default EVM attributes Matthew Garrett
2017-09-27 22:16 ` [PATCH 4/6] EVM: Add an hmac_ng xattr format Matthew Garrett
2017-09-27 22:16 ` [PATCH 5/6] EVM: Write out HMAC xattrs in the new format Matthew Garrett
2017-09-27 22:16 ` Matthew Garrett [this message]
2017-09-28 20:12 ` RFC: Make it practical to ship EVM signatures Mimi Zohar
2017-09-28 21:13   ` Matthew Garrett
2017-09-29  0:53     ` Mimi Zohar
2017-09-29 18:09       ` Matthew Garrett
2017-09-29 19:02         ` Mimi Zohar
2017-09-29 19:17           ` Matthew Garrett
2017-09-29 20:01             ` Mimi Zohar
2017-09-29 20:09               ` Matthew Garrett
2017-10-01  2:36                 ` Mimi Zohar
2017-10-02 17:09                   ` Matthew Garrett
2017-10-02 19:54                     ` Mimi Zohar
     [not found]                       ` <CACdnJutYw7Pgh-EwWuwp9Wz+5KzoreZVr+c6UV30zC__8FZSVA@mail.gmail.com>
     [not found]                         ` <1506974574.5691.304.camel@linux.vnet.ibm.com>
2017-10-02 20:07                           ` Matthew Garrett
2017-10-09 17:51                 ` Mimi Zohar
2017-10-09 17:59                   ` Matthew Garrett
2017-10-09 18:15                     ` Mimi Zohar
2017-10-09 18:18                       ` Matthew Garrett
2017-10-09 18:40                         ` Mimi Zohar
     [not found]                           ` <20171009232314.545de76a@totoro>
     [not found]                             ` <1507583449.3748.46.camel@linux.vnet.ibm.com>
     [not found]                               ` <20171010003326.6409ae23@totoro>
2017-10-09 21:40                                 ` Mimi Zohar
2017-10-09 23:10                                   ` Mikhail Kurinnoi
2017-10-10 19:07                                     ` Mimi Zohar
2017-10-12 23:09                                       ` Dmitry Kasatkin
2017-10-18 19:48                                         ` Dmitry Kasatkin
2017-10-18 20:30                                           ` Mimi Zohar
2017-10-18 20:37                                             ` Dmitry Kasatkin
2017-10-18 21:02                                               ` Mikhail Kurinnoi
2017-10-18 21:07                                               ` Mimi Zohar
2017-10-19 10:14                                                 ` Dmitry Kasatkin
2017-10-19 11:43                                                   ` Mimi Zohar
2017-10-19 17:08                                                   ` Matthew Garrett
2017-10-19 18:38                                                     ` Dmitry Kasatkin
2017-10-19 10:36                                                 ` Dmitry Kasatkin
2017-10-19 11:45                                                   ` Mimi Zohar
2017-10-02 14:53           ` Roberto Sassu
2017-10-02  8:55       ` Roberto Sassu

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=20170927221653.11219-7-mjg59@google.com \
    --to=mjg59@google.com \
    --cc=linux-integrity@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.