LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: zohar@linux.vnet.ibm.com (Mimi Zohar)
Cc: linux-kernel@vger.kernel.org, safford@watson.ibm.com,
serue@linux.vnet.ibm.com, kjhall@linux.vnet.ibm.com,
zohar@us.ibm.com
Subject: Re: [RFC][Patch 3/6] integrity: EVM as an integrity service provider
Date: Mon, 26 Mar 2007 13:40:18 +1000 [thread overview]
Message-ID: <E1HVg4A-0002vq-00@gondolin.me.apana.org.au> (raw)
In-Reply-To: <1173369828.5981.3.camel@localhost.localdomain>
Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:
>
> +int update_file_hash(struct dentry *dentry, struct file *f,
> + struct hash_desc *desc)
> +{
...
> + while (offset < i_size) {
> + rbuf_len = kernel_read(file, offset, rbuf, PAGE_SIZE);
> + if (rbuf_len <= 0)
> + break;
> + offset += rbuf_len;
> + sg[0].page = virt_to_page(rbuf);
> + sg[0].offset = ((long)rbuf & ~PAGE_MASK);
> + sg[0].length = rbuf_len;
> +
> + crypto_hash_update(desc, sg, rbuf_len);
You should check for errors here and on all calls to crypto_hash_*
that return errors.
> +int evm_calc_hash(struct dentry *dentry, struct file *file, char *digest,
> + int xattr_type)
> +{
> + struct crypto_hash *tfm;
> + struct hash_desc desc;
> + int error = 0;
> +
> + if (!dentry && !file)
> + return -ENOENT;
> +
> + tfm = crypto_alloc_hash(evm_hash, 0, CRYPTO_ALG_ASYNC);
> + if (!tfm) {
That should be !IS_ERR(tfm).
> +static int __init init_evm(void)
> +{
> + int error;
> +
> + if (strncmp(evm_hash, "sha1", 4) == 0) {
> + evm_hash_type = EVM_TYPE_SHA1;
> + hash_digest_size = SHA1_DIGEST_SIZE;
> + hash_str_size = SHA1_STR_SIZE;
This looks suspect. Can you guarantee that only md5/sha1 are used?
If not you should be getting these from the tfm. If yes then you
shouldn't allow arbitrary strings to be used.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
prev parent reply other threads:[~2007-03-26 3:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-08 16:03 Mimi Zohar
2007-03-26 3:40 ` Herbert Xu [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=E1HVg4A-0002vq-00@gondolin.me.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=kjhall@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=safford@watson.ibm.com \
--cc=serue@linux.vnet.ibm.com \
--cc=zohar@linux.vnet.ibm.com \
--cc=zohar@us.ibm.com \
--subject='Re: [RFC][Patch 3/6] integrity: EVM as an integrity service provider' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).