[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <3a31f5a68221d29c818d6edb7d5134b2dbd5051c.1324543719.git.dmitry.kasatkin@intel.com>
Date: Thu, 22 Dec 2011 10:55:25 +0200
From: Dmitry Kasatkin <dmitry.kasatkin@...el.com>
To: linux-fsdevel@...r.kernel.org,
linux-security-module@...r.kernel.org
Cc: akpm@...ux-foundation.org, viro@...iv.linux.org.uk,
linux-kernel@...r.kernel.org, zohar@...ux.vnet.ibm.com
Subject: [PATCH v2 1/2] vfs: iversion truncate bug fix
When a file is opened with O_TRUNC or truncated with truncate()/ftruncate(),
and then closed, iversion is not updated. This patch uses ATTR_OPEN flag,
which is currently used to identify files opened with O_TRUNC,
as an indication to increment iversion.
Also it adds passing of this flag from do_sys_truncate and do_sys_ftruncate.
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@...el.com>
---
fs/attr.c | 3 +++
fs/open.c | 5 +++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/attr.c b/fs/attr.c
index 7ee7ba4..e02370d 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -176,6 +176,9 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
return -EPERM;
}
+ if ((ia_valid & ATTR_OPEN) && IS_I_VERSION(inode))
+ inode_inc_iversion(inode);
+
if ((ia_valid & ATTR_MODE)) {
mode_t amode = attr->ia_mode;
/* Flag setting protected by i_mutex */
diff --git a/fs/open.c b/fs/open.c
index 22c41b5..4ee6847 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -113,7 +113,7 @@ static long do_sys_truncate(const char __user *pathname, loff_t length)
if (!error)
error = security_path_truncate(&path);
if (!error)
- error = do_truncate(path.dentry, length, 0, NULL);
+ error = do_truncate(path.dentry, length, ATTR_OPEN, NULL);
put_write_and_out:
put_write_access(inode);
@@ -168,7 +168,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
if (!error)
error = security_path_truncate(&file->f_path);
if (!error)
- error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
+ error = do_truncate(dentry, length,
+ ATTR_MTIME|ATTR_CTIME|ATTR_OPEN, file);
out_putf:
fput(file);
out:
--
1.7.4.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists