From: Eric Biggers <ebiggers3@gmail.com>
To: ecryptfs@vger.kernel.org, Tyler Hicks <tyhicks@canonical.com>
Cc: keyrings@vger.kernel.org, linux-security-module@vger.kernel.org,
Eric Biggers <ebiggers@google.com>,
stable@vger.kernel.org, Michael Halcrow <mhalcrow@google.com>
Subject: [PATCH v2 2/3] ecryptfs: fix out-of-bounds read of key payload
Date: Mon, 9 Oct 2017 12:51:28 -0700 [thread overview]
Message-ID: <20171009195129.68610-2-ebiggers3@gmail.com> (raw)
In-Reply-To: <20171009195129.68610-1-ebiggers3@gmail.com>
From: Eric Biggers <ebiggers@google.com>
eCryptfs blindly casts the user-supplied key payload to a
'struct ecryptfs_auth_tok' without validating that the payload does, in
fact, have the size of a 'struct ecryptfs_auth_tok'. Fix it.
Fixes: 237fead61998 ("[PATCH] ecryptfs: fs/Makefile and fs/Kconfig")
Reviewed-by: James Morris <james.l.morris@oracle.com>
Cc: <stable@vger.kernel.org> [v2.6.19+]
Cc: Michael Halcrow <mhalcrow@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
Changed since v1: added Reviewed-by and resent in series with just the
ecryptfs patches. Can this please be taken through the ecryptfs tree?
fs/ecryptfs/ecryptfs_kernel.h | 6 ++++++
fs/ecryptfs/keystore.c | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index 3fbc0ff79699..945844d5f0ef 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -93,6 +93,9 @@ ecryptfs_get_encrypted_key_payload_data(struct key *key)
if (!payload)
return ERR_PTR(-EKEYREVOKED);
+ if (payload->payload_datalen != sizeof(struct ecryptfs_auth_tok))
+ return ERR_PTR(-EINVAL);
+
return (struct ecryptfs_auth_tok *)payload->payload_data;
}
@@ -129,6 +132,9 @@ ecryptfs_get_key_payload_data(struct key *key)
if (!ukp)
return ERR_PTR(-EKEYREVOKED);
+ if (ukp->datalen != sizeof(struct ecryptfs_auth_tok))
+ return ERR_PTR(-EINVAL);
+
return (struct ecryptfs_auth_tok *)ukp->data;
}
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index fa218cd64f74..95e20ab67df3 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -471,6 +471,10 @@ ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key,
(*auth_tok) = ecryptfs_get_key_payload_data(auth_tok_key);
if (IS_ERR(*auth_tok)) {
rc = PTR_ERR(*auth_tok);
+ if (rc == -EINVAL) {
+ ecryptfs_printk(KERN_ERR,
+ "Authentication token payload has wrong length\n");
+ }
*auth_tok = NULL;
goto out;
}
--
2.14.2.920.gcf0c67979c-goog
WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers3@gmail.com>
To: linux-security-module@vger.kernel.org
Subject: [PATCH v2 2/3] ecryptfs: fix out-of-bounds read of key payload
Date: Mon, 09 Oct 2017 19:51:28 +0000 [thread overview]
Message-ID: <20171009195129.68610-2-ebiggers3@gmail.com> (raw)
In-Reply-To: <20171009195129.68610-1-ebiggers3@gmail.com>
From: Eric Biggers <ebiggers@google.com>
eCryptfs blindly casts the user-supplied key payload to a
'struct ecryptfs_auth_tok' without validating that the payload does, in
fact, have the size of a 'struct ecryptfs_auth_tok'. Fix it.
Fixes: 237fead61998 ("[PATCH] ecryptfs: fs/Makefile and fs/Kconfig")
Reviewed-by: James Morris <james.l.morris@oracle.com>
Cc: <stable@vger.kernel.org> [v2.6.19+]
Cc: Michael Halcrow <mhalcrow@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
Changed since v1: added Reviewed-by and resent in series with just the
ecryptfs patches. Can this please be taken through the ecryptfs tree?
fs/ecryptfs/ecryptfs_kernel.h | 6 ++++++
fs/ecryptfs/keystore.c | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index 3fbc0ff79699..945844d5f0ef 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -93,6 +93,9 @@ ecryptfs_get_encrypted_key_payload_data(struct key *key)
if (!payload)
return ERR_PTR(-EKEYREVOKED);
+ if (payload->payload_datalen != sizeof(struct ecryptfs_auth_tok))
+ return ERR_PTR(-EINVAL);
+
return (struct ecryptfs_auth_tok *)payload->payload_data;
}
@@ -129,6 +132,9 @@ ecryptfs_get_key_payload_data(struct key *key)
if (!ukp)
return ERR_PTR(-EKEYREVOKED);
+ if (ukp->datalen != sizeof(struct ecryptfs_auth_tok))
+ return ERR_PTR(-EINVAL);
+
return (struct ecryptfs_auth_tok *)ukp->data;
}
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index fa218cd64f74..95e20ab67df3 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -471,6 +471,10 @@ ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key,
(*auth_tok) = ecryptfs_get_key_payload_data(auth_tok_key);
if (IS_ERR(*auth_tok)) {
rc = PTR_ERR(*auth_tok);
+ if (rc = -EINVAL) {
+ ecryptfs_printk(KERN_ERR,
+ "Authentication token payload has wrong length\n");
+ }
*auth_tok = NULL;
goto out;
}
--
2.14.2.920.gcf0c67979c-goog
WARNING: multiple messages have this Message-ID (diff)
From: ebiggers3@gmail.com (Eric Biggers)
To: linux-security-module@vger.kernel.org
Subject: [PATCH v2 2/3] ecryptfs: fix out-of-bounds read of key payload
Date: Mon, 9 Oct 2017 12:51:28 -0700 [thread overview]
Message-ID: <20171009195129.68610-2-ebiggers3@gmail.com> (raw)
In-Reply-To: <20171009195129.68610-1-ebiggers3@gmail.com>
From: Eric Biggers <ebiggers@google.com>
eCryptfs blindly casts the user-supplied key payload to a
'struct ecryptfs_auth_tok' without validating that the payload does, in
fact, have the size of a 'struct ecryptfs_auth_tok'. Fix it.
Fixes: 237fead61998 ("[PATCH] ecryptfs: fs/Makefile and fs/Kconfig")
Reviewed-by: James Morris <james.l.morris@oracle.com>
Cc: <stable@vger.kernel.org> [v2.6.19+]
Cc: Michael Halcrow <mhalcrow@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
Changed since v1: added Reviewed-by and resent in series with just the
ecryptfs patches. Can this please be taken through the ecryptfs tree?
fs/ecryptfs/ecryptfs_kernel.h | 6 ++++++
fs/ecryptfs/keystore.c | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index 3fbc0ff79699..945844d5f0ef 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -93,6 +93,9 @@ ecryptfs_get_encrypted_key_payload_data(struct key *key)
if (!payload)
return ERR_PTR(-EKEYREVOKED);
+ if (payload->payload_datalen != sizeof(struct ecryptfs_auth_tok))
+ return ERR_PTR(-EINVAL);
+
return (struct ecryptfs_auth_tok *)payload->payload_data;
}
@@ -129,6 +132,9 @@ ecryptfs_get_key_payload_data(struct key *key)
if (!ukp)
return ERR_PTR(-EKEYREVOKED);
+ if (ukp->datalen != sizeof(struct ecryptfs_auth_tok))
+ return ERR_PTR(-EINVAL);
+
return (struct ecryptfs_auth_tok *)ukp->data;
}
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index fa218cd64f74..95e20ab67df3 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -471,6 +471,10 @@ ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key,
(*auth_tok) = ecryptfs_get_key_payload_data(auth_tok_key);
if (IS_ERR(*auth_tok)) {
rc = PTR_ERR(*auth_tok);
+ if (rc == -EINVAL) {
+ ecryptfs_printk(KERN_ERR,
+ "Authentication token payload has wrong length\n");
+ }
*auth_tok = NULL;
goto out;
}
--
2.14.2.920.gcf0c67979c-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
next prev parent reply other threads:[~2017-10-09 19:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-09 19:51 [PATCH v2 1/3] ecryptfs: fix dereference of NULL user_key_payload Eric Biggers
2017-10-09 19:51 ` Eric Biggers
2017-10-09 19:51 ` Eric Biggers
2017-10-09 19:51 ` Eric Biggers [this message]
2017-10-09 19:51 ` [PATCH v2 2/3] ecryptfs: fix out-of-bounds read of key payload Eric Biggers
2017-10-09 19:51 ` Eric Biggers
2017-10-09 19:51 ` [PATCH v2 3/3] ecryptfs: move key payload accessor functions into keystore.c Eric Biggers
2017-10-09 19:51 ` Eric Biggers
2017-10-09 19:51 ` Eric Biggers
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=20171009195129.68610-2-ebiggers3@gmail.com \
--to=ebiggers3@gmail.com \
--cc=ebiggers@google.com \
--cc=ecryptfs@vger.kernel.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mhalcrow@google.com \
--cc=stable@vger.kernel.org \
--cc=tyhicks@canonical.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.