* [PATCH v3 1/5] vfs: deny fallocate() on directory [not found] <1485851699-25313-1-git-send-email-amir73il@gmail.com> @ 2017-01-31 8:34 ` Amir Goldstein 2017-01-31 10:56 ` Christoph Hellwig [not found] ` <1485851699-25313-1-git-send-email-amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 1 sibling, 1 reply; 4+ messages in thread From: Amir Goldstein @ 2017-01-31 8:34 UTC (permalink / raw) To: Miklos Szeredi Cc: Jan Kara, Christoph Hellwig, Al Viro, linux-unionfs, linux-fsdevel, linux-api There was an obscure use case of fallocate of directory inode in the vfs helper with the comment: "Let individual file system decide if it supports preallocation for directories or not." But there is no in-tree file system that implements fallocate for directory operations. Deny an attempt to fallocate a directory with EISDIR error. This change is needed prior to converting sb_start_write() to file_start_write(), so freeze protection is correctly handled for cases of fallocate file and blockdev. Cc: linux-api@vger.kernel.org Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Amir Goldstein <amir73il@gmail.com> --- fs/open.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/open.c b/fs/open.c index 9921f70..f9118f4 100644 --- a/fs/open.c +++ b/fs/open.c @@ -301,12 +301,10 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len) if (S_ISFIFO(inode->i_mode)) return -ESPIPE; - /* - * Let individual file system decide if it supports preallocation - * for directories or not. - */ - if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode) && - !S_ISBLK(inode->i_mode)) + if (S_ISDIR(inode->i_mode)) + return -EISDIR; + + if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode)) return -ENODEV; /* Check for wrap through zero too */ -- 2.7.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 1/5] vfs: deny fallocate() on directory 2017-01-31 8:34 ` [PATCH v3 1/5] vfs: deny fallocate() on directory Amir Goldstein @ 2017-01-31 10:56 ` Christoph Hellwig 0 siblings, 0 replies; 4+ messages in thread From: Christoph Hellwig @ 2017-01-31 10:56 UTC (permalink / raw) To: Amir Goldstein Cc: Miklos Szeredi, Jan Kara, Christoph Hellwig, Al Viro, linux-unionfs, linux-fsdevel, linux-api Looks fine, Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <1485851699-25313-1-git-send-email-amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* [PATCH v3 2/5] vfs: deny copy_file_range() for non regular files [not found] ` <1485851699-25313-1-git-send-email-amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2017-01-31 8:34 ` Amir Goldstein [not found] ` <1485851699-25313-3-git-send-email-amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Amir Goldstein @ 2017-01-31 8:34 UTC (permalink / raw) To: Miklos Szeredi Cc: Jan Kara, Christoph Hellwig, Al Viro, linux-unionfs-u79uwXL29TY76Z2rM5mHXA, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, linux-api-u79uwXL29TY76Z2rM5mHXA There is no in-tree file system that implements copy_file_range() for non regular files. Deny an attempt to copy_file_range() a directory with EISDIR and any other non regualr file with EINVAL to conform with behavior of vfs_{clone,dedup}_file_range(). This change is needed prior to converting sb_start_write() to file_start_write() in the vfs helper. Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org> Cc: Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org> Signed-off-by: Amir Goldstein <amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- fs/read_write.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index 5816d4c..511178d 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1518,6 +1518,11 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, if (flags != 0) return -EINVAL; + if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) + return -EISDIR; + if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) + return -EINVAL; + ret = rw_verify_area(READ, file_in, &pos_in, len); if (unlikely(ret)) return ret; -- 2.7.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
[parent not found: <1485851699-25313-3-git-send-email-amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v3 2/5] vfs: deny copy_file_range() for non regular files [not found] ` <1485851699-25313-3-git-send-email-amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2017-01-31 10:56 ` Christoph Hellwig 0 siblings, 0 replies; 4+ messages in thread From: Christoph Hellwig @ 2017-01-31 10:56 UTC (permalink / raw) To: Amir Goldstein Cc: Miklos Szeredi, Jan Kara, Christoph Hellwig, Al Viro, linux-unionfs-u79uwXL29TY76Z2rM5mHXA, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, linux-api-u79uwXL29TY76Z2rM5mHXA Looks fine, Reviewed-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org> ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-31 10:56 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <1485851699-25313-1-git-send-email-amir73il@gmail.com> 2017-01-31 8:34 ` [PATCH v3 1/5] vfs: deny fallocate() on directory Amir Goldstein 2017-01-31 10:56 ` Christoph Hellwig [not found] ` <1485851699-25313-1-git-send-email-amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2017-01-31 8:34 ` [PATCH v3 2/5] vfs: deny copy_file_range() for non regular files Amir Goldstein [not found] ` <1485851699-25313-3-git-send-email-amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2017-01-31 10:56 ` Christoph Hellwig
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).