From: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
To: linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org
Cc: akpm@linux-foundation.org, viro@zeniv.linux.org.uk,
linux-kernel@vger.kernel.org, zohar@linux.vnet.ibm.com
Subject: [PATCH v2 1/2] vfs: iversion truncate bug fix
Date: Thu, 22 Dec 2011 10:55:25 +0200 [thread overview]
Message-ID: <3a31f5a68221d29c818d6edb7d5134b2dbd5051c.1324543719.git.dmitry.kasatkin@intel.com> (raw)
In-Reply-To: <cover.1324543719.git.dmitry.kasatkin@intel.com>
In-Reply-To: <cover.1324543719.git.dmitry.kasatkin@intel.com>
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@intel.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
next prev parent reply other threads:[~2011-12-22 8:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-22 8:55 [PATCH v2 0/2] vfs: truncate bug fixes Dmitry Kasatkin
2011-12-22 8:55 ` Dmitry Kasatkin [this message]
2011-12-22 8:55 ` [PATCH v2 2/2] vfs: ATTR_OPEN rename Dmitry Kasatkin
2011-12-22 9:10 ` [PATCH v2 0/2] vfs: truncate bug fixes Al Viro
2011-12-22 10:29 ` Kasatkin, Dmitry
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=3a31f5a68221d29c818d6edb7d5134b2dbd5051c.1324543719.git.dmitry.kasatkin@intel.com \
--to=dmitry.kasatkin@intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=zohar@linux.vnet.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®