linux-integrity.vger.kernel.org archive mirror
 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>
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 08:43:32 -0400	[thread overview]
Message-ID: <3a576c8f562201f441a72bb7232c4bb0faa36318.camel@linux.ibm.com> (raw)
In-Reply-To: <529bc35e-642f-9f50-f3a7-0d3c07890afe@viveris.fr>

Hi Simon,

On Wed, 2021-07-28 at 07:00 +0000, THOBY Simon wrote: 
> >> +
> >> +	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 ?

Memory pressure isn't the reason for preventing the xattr write.  It's
the reason for not being able to audit the setxattr failure.

thanks,

Mimi


  reply	other threads:[~2021-07-28 12:43 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
2021-07-28 12:43       ` Mimi Zohar [this message]
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=3a576c8f562201f441a72bb7232c4bb0faa36318.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 \
    --cc=paul@paul-moore.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;
as well as URLs for NNTP newsgroup(s).