linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: ebiggers3@gmail.com (Eric Biggers)
To: linux-security-module@vger.kernel.org
Subject: [PATCH 4/7] fscrypt: fix dereference of NULL user_key_payload
Date: Thu, 28 Sep 2017 14:25:59 -0700	[thread overview]
Message-ID: <20170928212602.41744-5-ebiggers3@gmail.com> (raw)
In-Reply-To: <20170928212602.41744-1-ebiggers3@gmail.com>

From: Eric Biggers <ebiggers@google.com>

When an fscrypt-encrypted file is opened, we request the file's master
key from the keyrings service as a logon key, then access 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: 88bd6ccdcdd6 ("ext4 crypto: add encryption key management facilities")
Cc: <stable@vger.kernel.org>    [v4.1+]
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/crypto/keyinfo.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index 018c588c7ac3..8e704d12a1cf 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -109,6 +109,11 @@ static int validate_user_key(struct fscrypt_info *crypt_info,
 		goto out;
 	}
 	ukp = user_key_payload_locked(keyring_key);
+	if (!ukp) {
+		/* key was revoked before we acquired its semaphore */
+		res = -EKEYREVOKED;
+		goto out;
+	}
 	if (ukp->datalen != sizeof(struct fscrypt_key)) {
 		res = -EINVAL;
 		goto out;
-- 
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 at  http://vger.kernel.org/majordomo-info.html

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

Thread overview: 15+ 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 ` [PATCH 1/7] KEYS: encrypted: fix dereference of NULL user_key_payload Eric Biggers
2017-10-03 10:51   ` James Morris
2017-09-28 21:25 ` [PATCH 2/7] FS-Cache: " Eric Biggers
2017-10-03 10:51   ` James Morris
2017-09-28 21:25 ` [PATCH 3/7] lib/digsig: " Eric Biggers
2017-10-03 10:52   ` James Morris
2017-09-28 21:25 ` Eric Biggers [this message]
2017-10-03 10:56   ` [PATCH 4/7] fscrypt: " James Morris
2017-09-28 21:26 ` [PATCH 5/7] ecryptfs: " Eric Biggers
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-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-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-5-ebiggers3@gmail.com \
    --to=ebiggers3@gmail.com \
    --cc=linux-security-module@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 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).