From: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
To: Matthew Garrett <mjg59@google.com>
Cc: linux-integrity@vger.kernel.org, zohar@linux.vnet.ibm.com
Subject: Re: [PATCH] evm: Allow non-SHA1 digital signatures
Date: Thu, 10 May 2018 13:28:16 -0300 [thread overview]
Message-ID: <878t8r1nmn.fsf@morokweng.localdomain> (raw)
In-Reply-To: <20180420203408.50769-1-mjg59@google.com>
Hello Matthew,
I have just a few minor nits. Feel free to ignore if you don't think
it's worth addressing them.
Matthew Garrett <mjg59@google.com> writes:
> @@ -203,10 +205,24 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
> if (!(inode->i_opflags & IOP_XATTR))
> return -EOPNOTSUPP;
>
> - desc = init_desc(type);
> + desc = init_desc(type, hash_algo);
> if (IS_ERR(desc))
> return PTR_ERR(desc);
>
> + /*
> + * HMACs are always SHA1, but signatures may be of varying sizes, so
> + * allocate a buffer for the non-HMAC case and return the size to
> + * the caller
> + */
> + if (type != EVM_XATTR_HMAC) {
> + *digestlen = crypto_shash_digestsize(desc->tfm);
> + *digest = kmalloc(*digestlen, GFP_KERNEL);
> + if (!*digest) {
> + error = -ENOMEM;
> + goto out;
> + }
> + }
> +
> error = -ENODATA;
> for (xattrname = evm_config_xattrnames; *xattrname != NULL; xattrname++) {
> bool is_ima = false;
I think it's worth mentioning either here or in the comment at the
beginning of this function that when type == EVM_XATTR_HMAC *digest is
expected to point to an existing buffer.
> @@ -251,18 +267,18 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
>
> int evm_calc_hmac(struct dentry *dentry, const char *req_xattr_name,
> const char *req_xattr_value, size_t req_xattr_value_len,
> - char *digest)
> + char **digest)
IMHO it's a slightly better interface if evm_calc_hmac() keeps taking a
char *, since it won't need to change where its argument points to.
> {
> return evm_calc_hmac_or_hash(dentry, req_xattr_name, req_xattr_value,
> - req_xattr_value_len, EVM_XATTR_HMAC, digest);
> + req_xattr_value_len, EVM_XATTR_HMAC, 0x02, digest, NULL);
It's clearer to use HASH_ALGO_SHA1 instead of 0x02 here.
> }
> @@ -333,7 +349,7 @@ int evm_init_hmac(struct inode *inode, const struct xattr *lsm_xattr,
> {
> struct shash_desc *desc;
>
> - desc = init_desc(EVM_XATTR_HMAC);
> + desc = init_desc(EVM_XATTR_HMAC, 0x02);
Same here.
> if (IS_ERR(desc)) {
> pr_info("init_desc failed\n");
> return PTR_ERR(desc);
> diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
> index 9ea9c19a545c..3d952e69852f 100644
> --- a/security/integrity/evm/evm_main.c
> +++ b/security/integrity/evm/evm_main.c
> @@ -28,6 +28,8 @@
> #include <crypto/algapi.h>
> #include "evm.h"
>
> +#define HMAC_LEN 20
It's clearer to use SHA1_DIGEST_SIZE instead of 20 here.
> +
> int evm_initialized;
>
> static const char * const integrity_status_msg[] = {
--
Thiago Jung Bauermann
IBM Linux Technology Center
prev parent reply other threads:[~2018-05-10 16:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-20 20:34 [PATCH] evm: Allow non-SHA1 digital signatures Matthew Garrett
2018-05-09 22:06 ` Matthew Garrett
2018-05-10 1:26 ` Mimi Zohar
2018-05-10 16:10 ` Thiago Jung Bauermann
2018-05-10 16:28 ` Thiago Jung Bauermann [this message]
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=878t8r1nmn.fsf@morokweng.localdomain \
--to=bauerman@linux.vnet.ibm.com \
--cc=linux-integrity@vger.kernel.org \
--cc=mjg59@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox