All of lore.kernel.org
 help / color / mirror / Atom feed
From: THOBY Simon <Simon.THOBY@viveris.fr>
To: Mimi Zohar <zohar@linux.ibm.com>,
	"dmitry.kasatkin@gmail.com" <dmitry.kasatkin@gmail.com>,
	"linux-integrity@vger.kernel.org"
	<linux-integrity@vger.kernel.org>,
	BARVAUX Didier <Didier.BARVAUX@viveris.fr>
Cc: Paul Moore <paul@paul-moore.com>
Subject: Re: [PATCH v4 2/5] IMA: block writes of the security.ima xattr with unsupported algorithms
Date: Wed, 28 Jul 2021 07:00:18 +0000	[thread overview]
Message-ID: <529bc35e-642f-9f50-f3a7-0d3c07890afe@viveris.fr> (raw)
In-Reply-To: <5a3a35b5f20fb17f7430046b0378e05f1dffa098.camel@linux.ibm.com>

Hi Mimi,

On 7/27/21 10:32 PM, Mimi Zohar wrote:
> [Cc'ing Paul Moore]
> 
> Hi Simon,
> 

[snip]

> 
>> +
>> +	if (likely(dentry_hash == ima_hash_algo
>> +	    || crypto_has_alg(hash_algo_name[dentry_hash], 0, 0)))
>> +		return 0;
>> +
>> +	pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
>> +	/* no memory available ? no file path for you */
> 
> The comment here is unnecessary.  Avoid or limit comments inside a
> function.  Refer to the section "8) Commenting" in
> Documentation/process/coding-style.rst
> 
>> +	if (pathbuf)
>> +		path = dentry_path(dentry, pathbuf, PATH_MAX);
>> +
>> +	/* disallow xattr writes with algorithms not built in the kernel */
>> +	integrity_audit_msg(AUDIT_INTEGRITY_DATA, d_inode(dentry),
>> +		path, "collect_data", "unavailable-hash-algorithm", res, 0);
> 
> This will emit an audit message without the filename when !path.  Is
> this what you intended?
> 

This is what I was clumsily trying to explain in the previous comment: if we cannot
allocate memory for a file path, I thought it best to log the audit message without
the path than fail with a -ENOMEM (auditing will also try to allocate a memory buffer
too, but a bit smaller, and memory could have been reclaimed between the two calls,
so the auditing operation may succeed).

Of course I could also return -ENOMEM, and it would happily propagate back to the user.

What do you think ?

Thanks,
Simon

  reply	other threads:[~2021-07-28  7:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-27 16:33 [PATCH v4 0/5] IMA: restrict the accepted digest algorithms for THOBY Simon
2021-07-27 16:33 ` [PATCH v4 1/5] IMA: remove the dependency on CRYPTO_MD5 THOBY Simon
2021-07-27 17:57   ` Mimi Zohar
2021-07-27 16:33 ` [PATCH v4 2/5] IMA: block writes of the security.ima xattr with unsupported algorithms THOBY Simon
2021-07-27 20:32   ` Mimi Zohar
2021-07-28  7:00     ` THOBY Simon [this message]
2021-07-28 12:43       ` Mimi Zohar
2021-07-28 12:53         ` THOBY Simon
2021-07-28 13:09           ` Mimi Zohar
2021-07-27 16:33 ` [PATCH v4 3/5] IMA: add support to restrict the hash algorithms used for file appraisal THOBY Simon
2021-07-27 20:38   ` Mimi Zohar
2021-07-27 16:33 ` [PATCH v4 4/5] IMA: add a policy option to restrict xattr hash algorithms on appraisal THOBY Simon
2021-07-27 21:07   ` Mimi Zohar
2021-07-27 16:33 ` [PATCH v4 5/5] IMA: introduce a new policy option func=SETXATTR_CHECK THOBY Simon
2021-07-27 17:25   ` Mimi Zohar
2021-07-27 17:58     ` THOBY Simon
2021-07-27 17:47 ` [PATCH v4 0/5] IMA: restrict the accepted digest algorithms for 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=529bc35e-642f-9f50-f3a7-0d3c07890afe@viveris.fr \
    --to=simon.thoby@viveris.fr \
    --cc=Didier.BARVAUX@viveris.fr \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=zohar@linux.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 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.