From: Mimi Zohar <zohar@linux.vnet.ibm.com>
To: Dmitry Kasatkin <d.kasatkin@samsung.com>
Cc: linux-ima-devel@lists.sourceforge.net,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk,
linux-fsdevel@vger.kernel.org, dmitry.kasatkin@gmail.com
Subject: Re: [PATCH v1 1/3] ima: provide flag to identify new empty files
Date: Tue, 15 Jul 2014 10:00:27 -0400 [thread overview]
Message-ID: <1405432827.21720.20.camel@dhcp-9-2-203-236.watson.ibm.com> (raw)
In-Reply-To: <ac60392e0118902ce9b308fdae09d633da1682af.1405078844.git.d.kasatkin@samsung.com>
On Fri, 2014-07-11 at 14:46 +0300, Dmitry Kasatkin wrote:
> Newly created empty files do not get initial security.ima
> value because iversion does not change. It can be checked from
> the shell as:
>
> $ (exec >foo)
> $ getfattr -h -e hex -d -m security foo
>
> This patch defines IMA_NEW_FILE flag which is set when IMA detects that new
> file is created. It is checked upon ima_file_free hook to set initial
> security.ima value.
Other than rebasing on top of #next, this patch set looks good.
thanks,
Mimi
> Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
> ---
> security/integrity/ima/ima_appraise.c | 7 +++++--
> security/integrity/ima/ima_main.c | 12 +++++++-----
> security/integrity/integrity.h | 1 +
> 3 files changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
> index 9dd18b5..3a4beb3 100644
> --- a/security/integrity/ima/ima_appraise.c
> +++ b/security/integrity/ima/ima_appraise.c
> @@ -194,8 +194,11 @@ int ima_appraise_measurement(int func, struct integrity_iint_cache *iint,
> goto out;
>
> cause = "missing-hash";
> - status =
> - (inode->i_size == 0) ? INTEGRITY_PASS : INTEGRITY_NOLABEL;
> + status = INTEGRITY_NOLABEL;
> + if (inode->i_size == 0) {
> + iint->flags |= IMA_NEW_FILE;
> + status = INTEGRITY_PASS;
> + }
> goto out;
> }
>
> diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
> index e51e0d5..5a870e7 100644
> --- a/security/integrity/ima/ima_main.c
> +++ b/security/integrity/ima/ima_main.c
> @@ -124,11 +124,13 @@ static void ima_check_last_writer(struct integrity_iint_cache *iint,
> return;
>
> mutex_lock(&iint->mutex);
> - if (atomic_read(&inode->i_writecount) == 1 &&
> - iint->version != inode->i_version) {
> - iint->flags &= ~IMA_DONE_MASK;
> - if (iint->flags & IMA_APPRAISE)
> - ima_update_xattr(iint, file);
> + if (atomic_read(&inode->i_writecount) == 1) {
> + if ((iint->version != inode->i_version) ||
> + (iint->flags & IMA_NEW_FILE)) {
> + iint->flags &= ~(IMA_DONE_MASK | IMA_NEW_FILE);
> + if (iint->flags & IMA_APPRAISE)
> + ima_update_xattr(iint, file);
> + }
> }
> mutex_unlock(&iint->mutex);
> }
> diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h
> index 92c1083..7656d47 100644
> --- a/security/integrity/integrity.h
> +++ b/security/integrity/integrity.h
> @@ -30,6 +30,7 @@
> #define IMA_ACTION_FLAGS 0xff000000
> #define IMA_DIGSIG_REQUIRED 0x01000000
> #define IMA_PERMIT_DIRECTIO 0x02000000
> +#define IMA_NEW_FILE 0x04000000
>
> #define IMA_DO_MASK (IMA_MEASURE | IMA_APPRAISE | IMA_AUDIT | \
> IMA_APPRAISE_SUBMASK)
next prev parent reply other threads:[~2014-07-15 14:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-11 11:46 [PATCH v1 0/3] fixes for missing security.ima on new empty files Dmitry Kasatkin
2014-07-11 11:46 ` [PATCH v1 1/3] ima: provide flag to identify " Dmitry Kasatkin
2014-07-15 14:00 ` Mimi Zohar [this message]
2014-07-15 22:12 ` [Linux-ima-devel] " Mimi Zohar
2014-07-16 7:56 ` Dmitry Kasatkin
2014-07-11 11:47 ` [PATCH v1 2/3] evm: skip integrity verification for newly created files Dmitry Kasatkin
2014-07-15 14:01 ` Mimi Zohar
2014-07-11 11:47 ` [PATCH v1 3/3] ima: pass 'opened' flag to identify " Dmitry Kasatkin
2014-07-15 22:12 ` Mimi Zohar
2014-07-16 8:25 ` Dmitry Kasatkin
2014-07-16 11:37 ` 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=1405432827.21720.20.camel@dhcp-9-2-203-236.watson.ibm.com \
--to=zohar@linux.vnet.ibm.com \
--cc=d.kasatkin@samsung.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-ima-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).