All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.ibm.com>
To: THOBY Simon <Simon.THOBY@viveris.fr>,
	"dmitry.kasatkin@gmail.com" <dmitry.kasatkin@gmail.com>,
	"linux-integrity@vger.kernel.org"
	<linux-integrity@vger.kernel.org>,
	BARVAUX Didier <Didier.BARVAUX@viveris.fr>
Subject: Re: [PATCH v6 2/5] IMA: block writes of the security.ima xattr with unsupported algorithms
Date: Mon, 09 Aug 2021 19:34:17 -0400	[thread overview]
Message-ID: <1381b22a98d7b43b7cba9f79fc0b739ed2816a5f.camel@linux.ibm.com> (raw)
In-Reply-To: <20210804092010.350372-3-simon.thoby@viveris.fr>

On Wed, 2021-08-04 at 09:20 +0000, THOBY Simon wrote:
> +static int validate_hash_algo(struct dentry *dentry,
> +                                  const struct evm_ima_xattr_data *xattr_value,
> +                                  size_t xattr_value_len)
> +{
> +       int result = 0;
> +       char *path = NULL, *pathbuf = NULL;
> +       enum hash_algo xattr_hash_algo;
> +
> +       xattr_hash_algo = ima_get_hash_algo(xattr_value, xattr_value_len);
> +
> +       if (likely(xattr_hash_algo == ima_hash_algo ||
> +                  crypto_has_alg(hash_algo_name[xattr_hash_algo], 0, 0)))
> +               return result;
> +
> +       result = -EACCES;
> +
> +       pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
> +       if (!pathbuf)
> +               return result;
> +
> +       path = dentry_path(dentry, pathbuf, PATH_MAX);
> +
> +       integrity_audit_msg(AUDIT_INTEGRITY_DATA, d_inode(dentry), path,
> +                           "collect_data", "unavailable-hash-algorithm",
> +                           result, 0);

"collect_data" refers to calculating the file hash,
ima_collect_measurement(), which may be stored in the measurement list,
used for verifying the signature and/or included in the audit record.

validate_hash_algo() verifies the hash algorithm before allowing the
file hash or signature to be written as security.ima.  Instead of
"collect_data" it should be "set_data" or something similar.

thanks,

Mimi

> +
> +       kfree(pathbuf);
> +
> +       return result;



  parent reply	other threads:[~2021-08-09 23:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04  9:20 [PATCH v6 0/5] IMA: restrict the accepted digest algorithms for the security.ima xattr THOBY Simon
2021-08-04  9:20 ` [PATCH v6 1/5] IMA: remove the dependency on CRYPTO_MD5 THOBY Simon
2021-08-04 17:41   ` Lakshmi Ramasubramanian
2021-08-09 20:59   ` Mimi Zohar
2021-08-04  9:20 ` [PATCH v6 2/5] IMA: block writes of the security.ima xattr with unsupported algorithms THOBY Simon
2021-08-04 17:40   ` Lakshmi Ramasubramanian
2021-08-09 13:32   ` Mimi Zohar
2021-08-09 23:34   ` Mimi Zohar [this message]
2021-08-10  6:44     ` THOBY Simon
2021-08-04  9:20 ` [PATCH v6 3/5] IMA: add support to restrict the hash algorithms used for file appraisal THOBY Simon
2021-08-04 17:44   ` Lakshmi Ramasubramanian
2021-08-09 17:43   ` Mimi Zohar
2021-08-10  6:45     ` THOBY Simon
2021-08-04  9:20 ` [PATCH v6 4/5] IMA: add a policy option to restrict xattr hash algorithms on appraisal THOBY Simon
2021-08-04 20:53   ` Lakshmi Ramasubramanian
2021-08-05  7:42     ` THOBY Simon
2021-08-09 18:05   ` Mimi Zohar
2021-08-04  9:20 ` [PATCH v6 5/5] IMA: introduce a new policy option func=SETXATTR_CHECK THOBY Simon
2021-08-04 18:49   ` Lakshmi Ramasubramanian
2021-08-09 18:12     ` Mimi Zohar

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=1381b22a98d7b43b7cba9f79fc0b739ed2816a5f.camel@linux.ibm.com \
    --to=zohar@linux.ibm.com \
    --cc=Didier.BARVAUX@viveris.fr \
    --cc=Simon.THOBY@viveris.fr \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=linux-integrity@vger.kernel.org \
    /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.