Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753567Ab0LWRei (ORCPT ); Thu, 23 Dec 2010 12:34:38 -0500 Received: from out3.smtp.messagingengine.com ([66.111.4.27]:44014 "EHLO out3.smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753518Ab0LWReg (ORCPT ); Thu, 23 Dec 2010 12:34:36 -0500 X-Sasl-enc: gA6fQlUdDQM6xwxrMOh78G7A9G81GmKhiXojV+jL82cB 1293125675 To: linux-security-module@vger.kernel.org Subject: [RFC][PATCH 2/6] encrypted-keys: added additional debug messages From: Roberto Sassu Date: Thu, 23 Dec 2010 18:34:30 +0100 Cc: keyrings@linux-nfs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Mimi Zohar , David Howells , James Morris , David Safford , Gianluca Ramunno , Tyler Hicks , kirkland@canonical.com MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3326347.OXiLX5CQZO"; protocol="application/pkcs7-signature"; micalg=sha1 Content-Transfer-Encoding: 7bit Message-Id: <201012231834.30497.roberto.sassu@polito.it> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9183 Lines: 195 --nextPart3326347.OXiLX5CQZO Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 =2D-- security/keys/encrypted_defined.c | 44 +++++++++++++++++++++++++++------= =2D-- 1 files changed, 33 insertions(+), 11 deletions(-) diff --git a/security/keys/encrypted_defined.c b/security/keys/encrypted_de= fined.c index c1c5e27..2bb2c47 100644 =2D-- a/security/keys/encrypted_defined.c +++ b/security/keys/encrypted_defined.c @@ -133,46 +133,68 @@ static int datablob_parse(char *datablob, char **mast= er_desc, substring_t args[MAX_OPT_ARGS]; int ret =3D -EINVAL; int key_cmd; =2D char *p; + char *p, *keyword; =20 =2D p =3D strsep(&datablob, " \t"); =2D if (!p) + keyword =3D strsep(&datablob, " \t"); + if (!keyword) { + pr_err("encrypted_key: insufficient parameters specified\n"); return ret; =2D key_cmd =3D match_token(p, key_tokens, args); + } + key_cmd =3D match_token(keyword, key_tokens, args); =20 *master_desc =3D strsep(&datablob, " \t"); =2D if (!*master_desc) + if (!*master_desc) { + pr_err("encrypted_key: master key parameter is missing\n"); goto out; + } =20 =2D 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; + } =20 if (decrypted_datalen) { *decrypted_datalen =3D strsep(&datablob, " \t"); =2D if (!*decrypted_datalen) + if (!*decrypted_datalen) { + pr_err("encrypted_key: keylen parameter is missing\n"); goto out; + } } =20 switch (key_cmd) { case Opt_new: =2D if (!decrypted_datalen) + if (!decrypted_datalen) { + pr_err("encrypted_key: keyword \'%s\' not allowed when " + "updating an existent key\n", keyword); break; + } ret =3D 0; break; case Opt_load: =2D 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 =3D strsep(&datablob, " \t"); =2D if (!*hex_encoded_iv) + if (!*hex_encoded_iv) { + pr_err("encrypted_key: hex blob is missing\n"); break; + } ret =3D 0; break; case Opt_update: =2D if (decrypted_datalen) + if (decrypted_datalen) { + pr_err("encrypted_key: keyword \'%s\' not allowed when " + "instantiating a new key\n", keyword); break; + } ret =3D 0; break; case Opt_err: + pr_err("encrypted_key: keyword \'%s\' not recognized\n", + keyword); break; } out: =2D-=20 1.7.2.3 --nextPart3326347.OXiLX5CQZO Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIO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CSqG SIb3DQEJBDEWBBRR7JQ1jUHcMMPPWnMxlaYvOT3ZMzAoBgkqhkiG9w0BCQ8xGzAZMAsGCWCGSAFl AwQBAjAKBggqhkiG9w0DBzANBgkqhkiG9w0BAQEFAASCAQAENZ6YW+IWVE7qj00Fq6ycxunSGbEE IjOjmVDN1x7YQGf+rrwoObyjTHM29lRr9kLndyE5oqWk+/yAV8+jCmMwfCgbBU/0BvOEMDZSOIsv I6TNCCAE2yYu3DG4AtFNPzzKgeKc5ztK1/fgqG1Gd6AvmglL1K554QyfpLU67t/dfhnTI3mCi4TC eLWEF1XdmZVX4ZXngwxrv2AcznV+/DHy5Jph5z+agF7ysxHFgS/T2QYDdrbIjX29rpO2+cb2MI1a 5e0xnpTVaREQEzXmPi3fmS/e/jmQwpYxrg5WrlT6c0Ob0PVv7hb2YSEIJm7HHxoZ8ze7Ih+X+bgk UTGgVLvZAAAAAAAA --nextPart3326347.OXiLX5CQZO-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/