diff mbox

ceph: add O_LARGEFILE flag check in ceph_open()

Message ID 20180720013515.16422-1-cgxu519@gmx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chengguang Xu July 20, 2018, 1:35 a.m. UTC
Add a check to disallow opening large files on 32bit
systems if the caller didn't specify O_LARGEFILE.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 fs/ceph/file.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Christoph Hellwig July 20, 2018, 3:16 p.m. UTC | #1
On Fri, Jul 20, 2018 at 09:35:15AM +0800, Chengguang Xu wrote:
> Add a check to disallow opening large files on 32bit
> systems if the caller didn't specify O_LARGEFILE.
> 
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>

Please call generic_file_open for this instead of open coding it.
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index ad0bed99b1d5..0dada8d60731 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -349,6 +349,10 @@  int ceph_open(struct inode *inode, struct file *file)
 		return 0;
 	}
 
+	if (!(file->f_flags & O_LARGEFILE) &&
+			i_size_read(inode) > MAX_NON_LFS)
+		return -EFBIG;
+
 	/* filter out O_CREAT|O_EXCL; vfs did that already.  yuck. */
 	flags = file->f_flags & ~(O_CREAT|O_EXCL);
 	if (S_ISDIR(inode->i_mode))