All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roberto Sassu <roberto.sassu@polito.it>
To: linux-security-module@vger.kernel.org
Cc: keyrings@linux-nfs.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, dhowells@redhat.com,
	jmorris@namei.org, zohar@linux.vnet.ibm.com,
	safford@watson.ibm.com, ramunno@polito.it,
	tyhicks@linux.vnet.ibm.com, kirkland@canonical.com,
	Roberto Sassu <roberto.sassu@polito.it>
Subject: [RFC][PATCH v3 2/6] encrypted-keys: added additional debug messages
Date: Mon, 24 Jan 2011 17:44:50 +0100	[thread overview]
Message-ID: <1295887497-20198-3-git-send-email-roberto.sassu@polito.it> (raw)
In-Reply-To: <1295887497-20198-1-git-send-email-roberto.sassu@polito.it>

[-- Attachment #1: Type: text/plain, Size: 2644 bytes --]

Some debug messages have been added in the function datablob_parse() in
order to better identify errors returned when dealing with 'encrypted'
keys.

Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Acked-by: Gianluca Ramunno <ramunno@polito.it>
Acked-by: Mimi Zohar <zohar@us.ibm.com>
---
 security/keys/encrypted.c |   44 +++++++++++++++++++++++++++++++++-----------
 1 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/security/keys/encrypted.c b/security/keys/encrypted.c
index 6135836..322e979 100644
--- a/security/keys/encrypted.c
+++ b/security/keys/encrypted.c
@@ -133,46 +133,68 @@ static int datablob_parse(char *datablob, char **master_desc,
 	substring_t args[MAX_OPT_ARGS];
 	int ret = -EINVAL;
 	int key_cmd;
-	char *p;
+	char *keyword;
 
-	p = strsep(&datablob, " \t");
-	if (!p)
+	keyword = strsep(&datablob, " \t");
+	if (!keyword) {
+		pr_err("encrypted_key: insufficient parameters specified\n");
 		return ret;
-	key_cmd = match_token(p, key_tokens, args);
+	}
+	key_cmd = match_token(keyword, key_tokens, args);
 
 	*master_desc = strsep(&datablob, " \t");
-	if (!*master_desc)
+	if (!*master_desc) {
+		pr_err("encrypted_key: master key parameter is missing\n");
 		goto out;
+	}
 
-	if (valid_master_desc(*master_desc, NULL) < 0)
+	if (valid_master_desc(*master_desc, NULL) < 0) {
+		pr_err("encrypted_key: master key parameter \'%s\' "
+		       "is invalid\n", *master_desc);
 		goto out;
+	}
 
 	if (decrypted_datalen) {
 		*decrypted_datalen = strsep(&datablob, " \t");
-		if (!*decrypted_datalen)
+		if (!*decrypted_datalen) {
+			pr_err("encrypted_key: keylen parameter is missing\n");
 			goto out;
+		}
 	}
 
 	switch (key_cmd) {
 	case Opt_new:
-		if (!decrypted_datalen)
+		if (!decrypted_datalen) {
+			pr_err("encrypted_key: keyword \'%s\' not allowed when "
+			       "updating an existent key\n", keyword);
 			break;
+		}
 		ret = 0;
 		break;
 	case Opt_load:
-		if (!decrypted_datalen)
+		if (!decrypted_datalen) {
+			pr_err("encrypted_key: keyword \'%s\' not allowed when "
+			       "updating an existent key\n", keyword);
 			break;
+		}
 		*hex_encoded_iv = strsep(&datablob, " \t");
-		if (!*hex_encoded_iv)
+		if (!*hex_encoded_iv) {
+			pr_err("encrypted_key: hex blob is missing\n");
 			break;
+		}
 		ret = 0;
 		break;
 	case Opt_update:
-		if (decrypted_datalen)
+		if (decrypted_datalen) {
+			pr_err("encrypted_key: keyword \'%s\' not allowed when "
+			       "instantiating a new key\n", keyword);
 			break;
+		}
 		ret = 0;
 		break;
 	case Opt_err:
+		pr_err("encrypted_key: keyword \'%s\' not recognized\n",
+		       keyword);
 		break;
 	}
 out:
-- 
1.7.3.4


[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 2061 bytes --]

  parent reply	other threads:[~2011-01-24 16:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-24 16:44 [RFC][PATCH v3 0/6] eCryptfs: added support for the encrypted key type Roberto Sassu
2011-01-24 16:44 ` [RFC][PATCH v3 1/6] encrypted-keys: fixed valid_master_desc() function description Roberto Sassu
2011-01-24 16:44 ` Roberto Sassu [this message]
2011-01-24 16:44 ` [RFC][PATCH v3 3/6] encrypted-keys: add key format support Roberto Sassu
2011-01-24 16:44 ` [RFC][PATCH v3 4/6] eCryptfs: export global eCryptfs definitions to include/linux/ecryptfs.h Roberto Sassu
2011-01-24 16:44 ` [RFC][PATCH v3 5/6] encrypted-keys: add ecryptfs format support Roberto Sassu
2011-01-25 22:57   ` Tyler Hicks
2011-01-24 16:44 ` [RFC][PATCH v3 6/6] eCryptfs: added support for the encrypted key type Roberto Sassu
2011-01-25 22:41   ` Tyler Hicks
2011-01-26 10:49 ` [RFC][PATCH v3 2/6] encrypted-keys: added additional debug messages David Howells
2011-01-26 11:03 ` [RFC][PATCH v3 3/6] encrypted-keys: add key format support David Howells
2011-01-26 11:52   ` Mimi Zohar
2011-01-26 13:01   ` David Howells
2011-01-26 11:05 ` [RFC][PATCH v3 4/6] eCryptfs: export global eCryptfs definitions to include/linux/ecryptfs.h David Howells
2011-01-26 11:05 ` [RFC][PATCH v3 1/6] encrypted-keys: fixed valid_master_desc() function description David Howells
2011-01-26 11:18 ` [RFC][PATCH v3 5/6] encrypted-keys: add ecryptfs format support David Howells
2011-01-26 12:57   ` Mimi Zohar
2011-01-26 11:28 ` [RFC][PATCH v3 6/6] eCryptfs: added support for the encrypted key type David Howells
2011-01-27 18:59   ` 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=1295887497-20198-3-git-send-email-roberto.sassu@polito.it \
    --to=roberto.sassu@polito.it \
    --cc=dhowells@redhat.com \
    --cc=jmorris@namei.org \
    --cc=keyrings@linux-nfs.org \
    --cc=kirkland@canonical.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=ramunno@polito.it \
    --cc=safford@watson.ibm.com \
    --cc=tyhicks@linux.vnet.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 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.