From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH v2 2/3] vfs: truncate check IS_APPEND() on real inode
Date: Fri, 7 Apr 2017 12:01:40 +0300 [thread overview]
Message-ID: <1491555701-16608-3-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1491555701-16608-1-git-send-email-amir73il@gmail.com>
truncate an overlayfs inode was checking IS_APPEND() on
overlay inode, but overlay inode does not have the S_APPEND flag.
Move the IS_APPEND() check to after we have the upperdentry
and pass it the real upper inode.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/open.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/open.c b/fs/open.c
index b7d5ab1..425db52 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -87,10 +87,6 @@ long vfs_truncate(const struct path *path, loff_t length)
if (error)
goto mnt_drop_write_and_out;
- error = -EPERM;
- if (IS_APPEND(inode))
- goto mnt_drop_write_and_out;
-
/*
* If this is an overlayfs then do as if opening the file so we get
* write access on the upper inode, not on the overlay inode. For
@@ -101,7 +97,11 @@ long vfs_truncate(const struct path *path, loff_t length)
if (IS_ERR(upperdentry))
goto mnt_drop_write_and_out;
- error = get_write_access(upperdentry->d_inode);
+ error = -EPERM;
+ if (IS_APPEND(d_inode(upperdentry)))
+ goto mnt_drop_write_and_out;
+
+ error = get_write_access(d_inode(upperdentry));
if (error)
goto mnt_drop_write_and_out;
@@ -120,7 +120,7 @@ long vfs_truncate(const struct path *path, loff_t length)
error = do_truncate(path->dentry, length, 0, NULL);
put_write_and_out:
- put_write_access(upperdentry->d_inode);
+ put_write_access(d_inode(upperdentry));
mnt_drop_write_and_out:
mnt_drop_write(path->mnt);
out:
--
2.7.4
next prev parent reply other threads:[~2017-04-07 9:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-07 9:01 [PATCH v2 0/3] ovl: fix IS_APPEND() checks Amir Goldstein
2017-04-07 9:01 ` [PATCH v2 1/3] vfs: ftruncate check IS_APPEND() on real inode Amir Goldstein
2017-04-07 13:10 ` Miklos Szeredi
2017-04-07 16:03 ` Amir Goldstein
2017-04-07 9:01 ` Amir Goldstein [this message]
2017-04-07 13:21 ` [PATCH v2 2/3] vfs: truncate " Miklos Szeredi
2017-04-07 16:16 ` Amir Goldstein
2017-04-08 11:50 ` Amir Goldstein
2017-04-07 9:01 ` [PATCH v2 3/3] ovl: check IS_APPEND() on real upper inode Amir Goldstein
2017-04-07 13:33 ` Miklos Szeredi
2017-04-07 16:19 ` Amir Goldstein
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=1491555701-16608-3-git-send-email-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--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).