All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers3@gmail.com>
To: keyrings@vger.kernel.org
Cc: David Howells <dhowells@redhat.com>,
	Michael Halcrow <mhalcrow@google.com>,
	linux-cachefs@redhat.com, ecryptfs@vger.kernel.org,
	linux-fscrypt@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	Eric Biggers <ebiggers@google.com>,
	stable@vger.kernel.org
Subject: [PATCH 3/7] lib/digsig: fix dereference of NULL user_key_payload
Date: Thu, 28 Sep 2017 14:25:58 -0700	[thread overview]
Message-ID: <20170928212602.41744-4-ebiggers3@gmail.com> (raw)
In-Reply-To: <20170928212602.41744-1-ebiggers3@gmail.com>

From: Eric Biggers <ebiggers@google.com>

digsig_verify() requests a user key, then accesses its payload.
However, a revoked key has a NULL payload, and we failed to check for
this.  request_key() *does* skip revoked keys, but there is still a
window where the key can be revoked before we acquire its semaphore.

Fix it by checking for a NULL payload, treating it like a key which was
already revoked at the time it was requested.

Fixes: 051dbb918c7f ("crypto: digital signature verification support")
Cc: <stable@vger.kernel.org>    [v3.3+]
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 lib/digsig.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/digsig.c b/lib/digsig.c
index 03d7c63837ae..6ba6fcd92dd1 100644
--- a/lib/digsig.c
+++ b/lib/digsig.c
@@ -87,6 +87,12 @@ static int digsig_verify_rsa(struct key *key,
 	down_read(&key->sem);
 	ukp = user_key_payload_locked(key);
 
+	if (!ukp) {
+		/* key was revoked before we acquired its semaphore */
+		err = -EKEYREVOKED;
+		goto err1;
+	}
+
 	if (ukp->datalen < sizeof(*pkh))
 		goto err1;
 
-- 
2.14.2.822.g60be5d43e6-goog

WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers3@gmail.com>
To: keyrings@vger.kernel.org
Cc: David Howells <dhowells@redhat.com>,
	Michael Halcrow <mhalcrow@google.com>,
	linux-cachefs@redhat.com, ecryptfs@vger.kernel.org,
	linux-fscrypt@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	Eric Biggers <ebiggers@google.com>,
	stable@vger.kernel.org
Subject: [PATCH 3/7] lib/digsig: fix dereference of NULL user_key_payload
Date: Thu, 28 Sep 2017 21:25:58 +0000	[thread overview]
Message-ID: <20170928212602.41744-4-ebiggers3@gmail.com> (raw)
In-Reply-To: <20170928212602.41744-1-ebiggers3@gmail.com>

From: Eric Biggers <ebiggers@google.com>

digsig_verify() requests a user key, then accesses its payload.
However, a revoked key has a NULL payload, and we failed to check for
this.  request_key() *does* skip revoked keys, but there is still a
window where the key can be revoked before we acquire its semaphore.

Fix it by checking for a NULL payload, treating it like a key which was
already revoked at the time it was requested.

Fixes: 051dbb918c7f ("crypto: digital signature verification support")
Cc: <stable@vger.kernel.org>    [v3.3+]
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 lib/digsig.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/digsig.c b/lib/digsig.c
index 03d7c63837ae..6ba6fcd92dd1 100644
--- a/lib/digsig.c
+++ b/lib/digsig.c
@@ -87,6 +87,12 @@ static int digsig_verify_rsa(struct key *key,
 	down_read(&key->sem);
 	ukp = user_key_payload_locked(key);
 
+	if (!ukp) {
+		/* key was revoked before we acquired its semaphore */
+		err = -EKEYREVOKED;
+		goto err1;
+	}
+
 	if (ukp->datalen < sizeof(*pkh))
 		goto err1;
 
-- 
2.14.2.822.g60be5d43e6-goog


WARNING: multiple messages have this Message-ID (diff)
From: ebiggers3@gmail.com (Eric Biggers)
To: linux-security-module@vger.kernel.org
Subject: [PATCH 3/7] lib/digsig: fix dereference of NULL user_key_payload
Date: Thu, 28 Sep 2017 14:25:58 -0700	[thread overview]
Message-ID: <20170928212602.41744-4-ebiggers3@gmail.com> (raw)
In-Reply-To: <20170928212602.41744-1-ebiggers3@gmail.com>

From: Eric Biggers <ebiggers@google.com>

digsig_verify() requests a user key, then accesses its payload.
However, a revoked key has a NULL payload, and we failed to check for
this.  request_key() *does* skip revoked keys, but there is still a
window where the key can be revoked before we acquire its semaphore.

Fix it by checking for a NULL payload, treating it like a key which was
already revoked at the time it was requested.

Fixes: 051dbb918c7f ("crypto: digital signature verification support")
Cc: <stable@vger.kernel.org>    [v3.3+]
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 lib/digsig.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/digsig.c b/lib/digsig.c
index 03d7c63837ae..6ba6fcd92dd1 100644
--- a/lib/digsig.c
+++ b/lib/digsig.c
@@ -87,6 +87,12 @@ static int digsig_verify_rsa(struct key *key,
 	down_read(&key->sem);
 	ukp = user_key_payload_locked(key);
 
+	if (!ukp) {
+		/* key was revoked before we acquired its semaphore */
+		err = -EKEYREVOKED;
+		goto err1;
+	}
+
 	if (ukp->datalen < sizeof(*pkh))
 		goto err1;
 
-- 
2.14.2.822.g60be5d43e6-goog

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info@ http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-09-28 21:25 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28 21:25 [PATCH 0/7] Fix dereferencing payload of revoked keys Eric Biggers
2017-09-28 21:25 ` Eric Biggers
2017-09-28 21:25 ` Eric Biggers
2017-09-28 21:25 ` [PATCH 1/7] KEYS: encrypted: fix dereference of NULL user_key_payload Eric Biggers
2017-09-28 21:25   ` Eric Biggers
2017-09-28 21:25   ` Eric Biggers
2017-10-03 10:51   ` James Morris
2017-10-03 10:51     ` James Morris
2017-10-03 10:51     ` James Morris
2017-09-28 21:25 ` [PATCH 2/7] FS-Cache: " Eric Biggers
2017-09-28 21:25   ` Eric Biggers
2017-09-28 21:25   ` Eric Biggers
2017-10-03 10:51   ` James Morris
2017-10-03 10:51     ` James Morris
2017-10-03 10:51     ` James Morris
2017-09-28 21:25 ` Eric Biggers [this message]
2017-09-28 21:25   ` [PATCH 3/7] lib/digsig: " Eric Biggers
2017-09-28 21:25   ` Eric Biggers
2017-10-03 10:52   ` James Morris
2017-10-03 10:52     ` James Morris
2017-10-03 10:52     ` James Morris
2017-09-28 21:25 ` [PATCH 4/7] fscrypt: " Eric Biggers
2017-09-28 21:25   ` Eric Biggers
2017-09-28 21:25   ` Eric Biggers
2017-10-03 10:56   ` James Morris
2017-10-03 10:56     ` James Morris
2017-10-03 10:56     ` James Morris
2017-09-28 21:26 ` [PATCH 5/7] ecryptfs: " Eric Biggers
2017-09-28 21:26   ` Eric Biggers
2017-09-28 21:26   ` Eric Biggers
2017-10-03 11:01   ` James Morris
2017-10-03 11:01     ` James Morris
2017-10-03 11:01     ` James Morris
2017-09-28 21:26 ` [PATCH 6/7] ecryptfs: fix out-of-bounds read of key payload Eric Biggers
2017-09-28 21:26   ` Eric Biggers
2017-09-28 21:26   ` Eric Biggers
2017-10-03 11:03   ` James Morris
2017-10-03 11:03     ` James Morris
2017-10-03 11:03     ` James Morris
2017-09-28 21:26 ` [PATCH 7/7] ecryptfs: move key payload accessor functions into keystore.c Eric Biggers
2017-09-28 21:26   ` Eric Biggers
2017-09-28 21:26   ` Eric Biggers
2017-10-03 11:05   ` James Morris
2017-10-03 11:05     ` James Morris
2017-10-03 11:05     ` James Morris

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=20170928212602.41744-4-ebiggers3@gmail.com \
    --to=ebiggers3@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=ebiggers@google.com \
    --cc=ecryptfs@vger.kernel.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-cachefs@redhat.com \
    --cc=linux-fscrypt@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mhalcrow@google.com \
    --cc=stable@vger.kernel.org \
    /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.