From patchwork Thu May 10 15:45:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 10392015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 721AF60353 for ; Thu, 10 May 2018 15:53:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6284428C1A for ; Thu, 10 May 2018 15:53:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5714928B8A; Thu, 10 May 2018 15:53:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52FEE28CE3 for ; Thu, 10 May 2018 15:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965537AbeEJPxP (ORCPT ); Thu, 10 May 2018 11:53:15 -0400 Received: from smtprelay0137.hostedemail.com ([216.40.44.137]:57978 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965033AbeEJPxO (ORCPT ); Thu, 10 May 2018 11:53:14 -0400 X-Greylist: delayed 431 seconds by postgrey-1.27 at vger.kernel.org; Thu, 10 May 2018 11:53:13 EDT Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by smtpgrave03.hostedemail.com (Postfix) with ESMTP id 4D50718030440; Thu, 10 May 2018 15:46:46 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay05.hostedemail.com (Postfix) with ESMTP id 2A22F1804D7A9; Thu, 10 May 2018 15:46:43 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: mask55_1cf91d2a5a145 X-Filterd-Recvd-Size: 8795 Received: from joe-laptop.perches.com (unknown [47.151.150.235]) (Authenticated sender: joe@perches.com) by omf04.hostedemail.com (Postfix) with ESMTPA; Thu, 10 May 2018 15:46:38 +0000 (UTC) From: Joe Perches To: Mimi Zohar Cc: David Howells , James Morris , "Serge E. Hallyn" , linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/18] security: encrypted-keys: Remove pr_fmt duplicate logging prefixes Date: Thu, 10 May 2018 08:45:43 -0700 Message-Id: X-Mailer: git-send-email 2.15.0 In-Reply-To: References: Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Converting pr_fmt from a simple define to use KBUILD_MODNAME added some duplicate logging prefixes to existing uses. Remove them. Signed-off-by: Joe Perches Reviewed-by: James Morris --- security/keys/encrypted-keys/encrypted.c | 63 ++++++++++++++------------------ 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c index d92cbf9687c3..40a14d5c6ae5 100644 --- a/security/keys/encrypted-keys/encrypted.c +++ b/security/keys/encrypted-keys/encrypted.c @@ -84,8 +84,7 @@ static int aes_get_sizes(void) tfm = crypto_alloc_skcipher(blkcipher_alg, 0, CRYPTO_ALG_ASYNC); if (IS_ERR(tfm)) { - pr_err("encrypted_key: failed to alloc_cipher (%ld)\n", - PTR_ERR(tfm)); + pr_err("failed to alloc_cipher (%ld)\n", PTR_ERR(tfm)); return PTR_ERR(tfm); } ivsize = crypto_skcipher_ivsize(tfm); @@ -106,15 +105,14 @@ static int valid_ecryptfs_desc(const char *ecryptfs_desc) int i; if (strlen(ecryptfs_desc) != KEY_ECRYPTFS_DESC_LEN) { - pr_err("encrypted_key: key description must be %d hexadecimal " - "characters long\n", KEY_ECRYPTFS_DESC_LEN); + pr_err("key description must be %d hexadecimal characters long\n", + KEY_ECRYPTFS_DESC_LEN); return -EINVAL; } for (i = 0; i < KEY_ECRYPTFS_DESC_LEN; i++) { if (!isxdigit(ecryptfs_desc[i])) { - pr_err("encrypted_key: key description must contain " - "only hexadecimal characters\n"); + pr_err("key description must contain only hexadecimal characters\n"); return -EINVAL; } } @@ -180,7 +178,7 @@ static int datablob_parse(char *datablob, const char **format, keyword = strsep(&datablob, " \t"); if (!keyword) { - pr_info("encrypted_key: insufficient parameters specified\n"); + pr_info("insufficient parameters specified\n"); return ret; } key_cmd = match_token(keyword, key_tokens, args); @@ -188,7 +186,7 @@ static int datablob_parse(char *datablob, const char **format, /* Get optional format: default | ecryptfs */ p = strsep(&datablob, " \t"); if (!p) { - pr_err("encrypted_key: insufficient parameters specified\n"); + pr_err("insufficient parameters specified\n"); return ret; } @@ -205,20 +203,20 @@ static int datablob_parse(char *datablob, const char **format, } if (!*master_desc) { - pr_info("encrypted_key: master key parameter is missing\n"); + pr_info("master key parameter is missing\n"); goto out; } if (valid_master_desc(*master_desc, NULL) < 0) { - pr_info("encrypted_key: master key parameter \'%s\' " - "is invalid\n", *master_desc); + pr_info("master key parameter \'%s\' is invalid\n", + *master_desc); goto out; } if (decrypted_datalen) { *decrypted_datalen = strsep(&datablob, " \t"); if (!*decrypted_datalen) { - pr_info("encrypted_key: keylen parameter is missing\n"); + pr_info("keylen parameter is missing\n"); goto out; } } @@ -226,37 +224,35 @@ static int datablob_parse(char *datablob, const char **format, switch (key_cmd) { case Opt_new: if (!decrypted_datalen) { - pr_info("encrypted_key: keyword \'%s\' not allowed " - "when called from .update method\n", keyword); + pr_info("keyword \'%s\' not allowed when called from .update method\n", + keyword); break; } ret = 0; break; case Opt_load: if (!decrypted_datalen) { - pr_info("encrypted_key: keyword \'%s\' not allowed " - "when called from .update method\n", keyword); + pr_info("keyword \'%s\' not allowed when called from .update method\n", + keyword); break; } *hex_encoded_iv = strsep(&datablob, " \t"); if (!*hex_encoded_iv) { - pr_info("encrypted_key: hex blob is missing\n"); + pr_info("hex blob is missing\n"); break; } ret = 0; break; case Opt_update: if (decrypted_datalen) { - pr_info("encrypted_key: keyword \'%s\' not allowed " - "when called from .instantiate method\n", + pr_info("keyword \'%s\' not allowed when called from .instantiate method\n", keyword); break; } ret = 0; break; case Opt_err: - pr_info("encrypted_key: keyword \'%s\' not recognized\n", - keyword); + pr_info("keyword \'%s\' not recognized\n", keyword); break; } out: @@ -344,7 +340,7 @@ static int calc_hmac(u8 *digest, const u8 *key, unsigned int keylen, tfm = crypto_alloc_shash(hmac_alg, 0, CRYPTO_ALG_ASYNC); if (IS_ERR(tfm)) { - pr_err("encrypted_key: can't alloc %s transform: %ld\n", + pr_err("can't alloc %s transform: %ld\n", hmac_alg, PTR_ERR(tfm)); return PTR_ERR(tfm); } @@ -395,22 +391,21 @@ static struct skcipher_request *init_skcipher_req(const u8 *key, tfm = crypto_alloc_skcipher(blkcipher_alg, 0, CRYPTO_ALG_ASYNC); if (IS_ERR(tfm)) { - pr_err("encrypted_key: failed to load %s transform (%ld)\n", + pr_err("failed to load %s transform (%ld)\n", blkcipher_alg, PTR_ERR(tfm)); return ERR_CAST(tfm); } ret = crypto_skcipher_setkey(tfm, key, key_len); if (ret < 0) { - pr_err("encrypted_key: failed to setkey (%d)\n", ret); + pr_err("failed to setkey (%d)\n", ret); crypto_free_skcipher(tfm); return ERR_PTR(ret); } req = skcipher_request_alloc(tfm, GFP_KERNEL); if (!req) { - pr_err("encrypted_key: failed to allocate request for %s\n", - blkcipher_alg); + pr_err("failed to allocate request for %s\n", blkcipher_alg); crypto_free_skcipher(tfm); return ERR_PTR(-ENOMEM); } @@ -441,11 +436,10 @@ static struct key *request_master_key(struct encrypted_key_payload *epayload, int ret = PTR_ERR(mkey); if (ret == -ENOTSUPP) - pr_info("encrypted_key: key %s not supported", + pr_info("key %s not supported\n", epayload->master_desc); else - pr_info("encrypted_key: key %s not found", - epayload->master_desc); + pr_info("key %s not found\n", epayload->master_desc); goto out; } @@ -490,7 +484,7 @@ static int derived_key_encrypt(struct encrypted_key_payload *epayload, skcipher_request_free(req); crypto_free_skcipher(tfm); if (ret < 0) - pr_err("encrypted_key: failed to encrypt (%d)\n", ret); + pr_err("failed to encrypt (%d)\n", ret); else dump_encrypted_data(epayload, encrypted_datalen); out: @@ -627,8 +621,7 @@ static struct encrypted_key_payload *encrypted_key_alloc(struct key *key, payload_datalen = decrypted_datalen; if (format && !strcmp(format, key_format_ecryptfs)) { if (dlen != ECRYPTFS_MAX_KEY_BYTES) { - pr_err("encrypted_key: keylen for the ecryptfs format " - "must be equal to %d bytes\n", + pr_err("keylen for the ecryptfs format must be equal to %d bytes\n", ECRYPTFS_MAX_KEY_BYTES); return ERR_PTR(-EINVAL); } @@ -696,7 +689,7 @@ static int encrypted_key_decrypt(struct encrypted_key_payload *epayload, ret = datablob_hmac_verify(epayload, format, master_key, master_keylen); if (ret < 0) { - pr_err("encrypted_key: bad hmac (%d)\n", ret); + pr_err("bad hmac (%d)\n", ret); goto out; } @@ -706,7 +699,7 @@ static int encrypted_key_decrypt(struct encrypted_key_payload *epayload, ret = derived_key_decrypt(epayload, derived_key, sizeof derived_key); if (ret < 0) - pr_err("encrypted_key: failed to decrypt key (%d)\n", ret); + pr_err("failed to decrypt key (%d)\n", ret); out: up_read(&mkey->sem); key_put(mkey); @@ -986,7 +979,7 @@ static int __init init_encrypted(void) hash_tfm = crypto_alloc_shash(hash_alg, 0, CRYPTO_ALG_ASYNC); if (IS_ERR(hash_tfm)) { - pr_err("encrypted_key: can't allocate %s transform: %ld\n", + pr_err("can't allocate %s transform: %ld\n", hash_alg, PTR_ERR(hash_tfm)); return PTR_ERR(hash_tfm); }