lkml.org 
[lkml]   [2011]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] do_truncate needs to increment iversion
On Wed, 14 Dec 2011 18:44:57 +0200
Dmitry Kasatkin <dmitry.kasatkin@intel.com> wrote:

> IMA/EVM uses iversion to identify if file content has been changed.
> It has been found that when file is opened, truncated with ftruncate()
> and then closed, iversion is not updated.
>
> This patch adds iversion incrementation to do_truncate().

I confess that I've never really fully understood what i_version is
supposed to do, so I'm not in any position to comment on where, when
and why the thing should be updated.

At present it gets updated in file_update_time() so I suppose that
we're not calling file_update_time() in the ftruncate case, which
sounds wrong?

It's notable that file_update_time() will not update i_version if the
inode has NOCMTIME. This might be wrong, but one would need to know
the intent of i_version to be able to say. Do your files have
S_NOCMTIME set?

> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -56,6 +56,8 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
> newattrs.ia_valid |= ret | ATTR_FORCE;
>
> mutex_lock(&dentry->d_inode->i_mutex);
> + if (IS_I_VERSION(dentry->d_inode))
> + inode_inc_iversion(dentry->d_inode);
> ret = notify_change(dentry, &newattrs);
> mutex_unlock(&dentry->d_inode->i_mutex);
> return ret;

With four evaluations, it is time to cache dentry->d_inode in a local.


\
 
 \ /
  Last update: 2011-12-15 22:59    [W:1.261 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site