summaryrefslogtreecommitdiffstats
path: root/sys/gnu
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2004-02-19 09:06:06 +0000
committertjr <tjr@FreeBSD.org>2004-02-19 09:06:06 +0000
commitd2df6bc6f718fb3b4771f1057489a9370b4155cb (patch)
treeaac5f0575afb893455deb9cc3f4f5c2879b19a06 /sys/gnu
parent4583be830a6ae7272e015769b97449f07c914bac (diff)
downloadFreeBSD-src-d2df6bc6f718fb3b4771f1057489a9370b4155cb.zip
FreeBSD-src-d2df6bc6f718fb3b4771f1057489a9370b4155cb.tar.gz
Enforce the file size limit in VOP_WRITE() as well as VOP_TRUNCATE();
pointed out by bde.
Diffstat (limited to 'sys/gnu')
-rw-r--r--sys/gnu/ext2fs/ext2_fs_sb.h4
-rw-r--r--sys/gnu/ext2fs/ext2_inode.c10
-rw-r--r--sys/gnu/ext2fs/ext2_readwrite.c8
-rw-r--r--sys/gnu/ext2fs/ext2_vfsops.c5
-rw-r--r--sys/gnu/fs/ext2fs/ext2_fs_sb.h4
-rw-r--r--sys/gnu/fs/ext2fs/ext2_inode.c10
-rw-r--r--sys/gnu/fs/ext2fs/ext2_readwrite.c8
-rw-r--r--sys/gnu/fs/ext2fs/ext2_vfsops.c5
8 files changed, 22 insertions, 32 deletions
diff --git a/sys/gnu/ext2fs/ext2_fs_sb.h b/sys/gnu/ext2fs/ext2_fs_sb.h
index 85f71bf..811f589 100644
--- a/sys/gnu/ext2fs/ext2_fs_sb.h
+++ b/sys/gnu/ext2fs/ext2_fs_sb.h
@@ -3,6 +3,8 @@
*
* Aug 1995, Godmar Back (gback@cs.utah.edu)
* University of Utah, Department of Computer Science
+ *
+ * $FreeBSD$
*/
/*
* linux/include/linux/ext2_fs_sb.h
@@ -74,7 +76,7 @@ struct ext2_sb_info {
char s_rd_only; /* read-only */
char s_dirt; /* fs modified flag */
char s_wasvalid; /* valid at mount time */
-
+ off_t fs_maxfilesize;
char fs_fsmnt[MAXMNTLEN]; /* name mounted on */
};
diff --git a/sys/gnu/ext2fs/ext2_inode.c b/sys/gnu/ext2fs/ext2_inode.c
index d940a5c..5b5eb83 100644
--- a/sys/gnu/ext2fs/ext2_inode.c
+++ b/sys/gnu/ext2fs/ext2_inode.c
@@ -164,15 +164,7 @@ printf("ext2_truncate called %d to %d\n", VTOI(ovp)->i_number, length);
* value of oszie is 0, length will be at least 1.
*/
if (osize < length) {
- /*
- * XXX Refuse to extend files past 2GB on old format
- * filesystems or ones that don't already have the
- * large file flag set in the superblock.
- */
- if (osize < 0x8000000 && length >= 0x80000000 &&
- (oip->i_e2fs->s_es->s_rev_level == EXT2_GOOD_OLD_REV ||
- (oip->i_e2fs->s_es->s_feature_ro_compat &
- EXT2_FEATURE_RO_COMPAT_LARGE_FILE) == 0))
+ if (length > oip->i_e2fs->fs_maxfilesize)
return (EFBIG);
offset = blkoff(fs, length - 1);
lbn = lblkno(fs, length - 1);
diff --git a/sys/gnu/ext2fs/ext2_readwrite.c b/sys/gnu/ext2fs/ext2_readwrite.c
index c40ae98..10cffcd 100644
--- a/sys/gnu/ext2fs/ext2_readwrite.c
+++ b/sys/gnu/ext2fs/ext2_readwrite.c
@@ -89,10 +89,8 @@ READ(ap)
panic("%s: type %d", READ_S, vp->v_type);
#endif
fs = ip->I_FS;
-#if 0
- if ((u_quad_t)uio->uio_offset > fs->fs_maxfilesize)
+ if ((uoff_t)uio->uio_offset > fs->fs_maxfilesize)
return (EFBIG);
-#endif
orig_resid = uio->uio_resid;
for (error = 0, bp = NULL; uio->uio_resid > 0; bp = NULL) {
@@ -207,11 +205,9 @@ WRITE(ap)
}
fs = ip->I_FS;
-#if 0
if (uio->uio_offset < 0 ||
- (u_quad_t)uio->uio_offset + uio->uio_resid > fs->fs_maxfilesize)
+ (uoff_t)uio->uio_offset + uio->uio_resid > fs->fs_maxfilesize)
return (EFBIG);
-#endif
/*
* Maybe this should be above the vnode op call, but so long as
* file servers have no limits, I don't think it matters.
diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c
index 664a5ff..13e9cbd 100644
--- a/sys/gnu/ext2fs/ext2_vfsops.c
+++ b/sys/gnu/ext2fs/ext2_vfsops.c
@@ -506,6 +506,11 @@ static int compute_sb_data(devvp, es, fs)
}
fs->s_loaded_inode_bitmaps = 0;
fs->s_loaded_block_bitmaps = 0;
+ if (es->s_rev_level == EXT2_GOOD_OLD_REV || (es->s_feature_ro_compat &
+ EXT2_FEATURE_RO_COMPAT_LARGE_FILE) == 0)
+ fs->fs_maxfilesize = 0x7fffffff;
+ else
+ fs->fs_maxfilesize = 0x7fffffffffffffff;
return 0;
}
diff --git a/sys/gnu/fs/ext2fs/ext2_fs_sb.h b/sys/gnu/fs/ext2fs/ext2_fs_sb.h
index 85f71bf..811f589 100644
--- a/sys/gnu/fs/ext2fs/ext2_fs_sb.h
+++ b/sys/gnu/fs/ext2fs/ext2_fs_sb.h
@@ -3,6 +3,8 @@
*
* Aug 1995, Godmar Back (gback@cs.utah.edu)
* University of Utah, Department of Computer Science
+ *
+ * $FreeBSD$
*/
/*
* linux/include/linux/ext2_fs_sb.h
@@ -74,7 +76,7 @@ struct ext2_sb_info {
char s_rd_only; /* read-only */
char s_dirt; /* fs modified flag */
char s_wasvalid; /* valid at mount time */
-
+ off_t fs_maxfilesize;
char fs_fsmnt[MAXMNTLEN]; /* name mounted on */
};
diff --git a/sys/gnu/fs/ext2fs/ext2_inode.c b/sys/gnu/fs/ext2fs/ext2_inode.c
index d940a5c..5b5eb83 100644
--- a/sys/gnu/fs/ext2fs/ext2_inode.c
+++ b/sys/gnu/fs/ext2fs/ext2_inode.c
@@ -164,15 +164,7 @@ printf("ext2_truncate called %d to %d\n", VTOI(ovp)->i_number, length);
* value of oszie is 0, length will be at least 1.
*/
if (osize < length) {
- /*
- * XXX Refuse to extend files past 2GB on old format
- * filesystems or ones that don't already have the
- * large file flag set in the superblock.
- */
- if (osize < 0x8000000 && length >= 0x80000000 &&
- (oip->i_e2fs->s_es->s_rev_level == EXT2_GOOD_OLD_REV ||
- (oip->i_e2fs->s_es->s_feature_ro_compat &
- EXT2_FEATURE_RO_COMPAT_LARGE_FILE) == 0))
+ if (length > oip->i_e2fs->fs_maxfilesize)
return (EFBIG);
offset = blkoff(fs, length - 1);
lbn = lblkno(fs, length - 1);
diff --git a/sys/gnu/fs/ext2fs/ext2_readwrite.c b/sys/gnu/fs/ext2fs/ext2_readwrite.c
index c40ae98..10cffcd 100644
--- a/sys/gnu/fs/ext2fs/ext2_readwrite.c
+++ b/sys/gnu/fs/ext2fs/ext2_readwrite.c
@@ -89,10 +89,8 @@ READ(ap)
panic("%s: type %d", READ_S, vp->v_type);
#endif
fs = ip->I_FS;
-#if 0
- if ((u_quad_t)uio->uio_offset > fs->fs_maxfilesize)
+ if ((uoff_t)uio->uio_offset > fs->fs_maxfilesize)
return (EFBIG);
-#endif
orig_resid = uio->uio_resid;
for (error = 0, bp = NULL; uio->uio_resid > 0; bp = NULL) {
@@ -207,11 +205,9 @@ WRITE(ap)
}
fs = ip->I_FS;
-#if 0
if (uio->uio_offset < 0 ||
- (u_quad_t)uio->uio_offset + uio->uio_resid > fs->fs_maxfilesize)
+ (uoff_t)uio->uio_offset + uio->uio_resid > fs->fs_maxfilesize)
return (EFBIG);
-#endif
/*
* Maybe this should be above the vnode op call, but so long as
* file servers have no limits, I don't think it matters.
diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c
index 664a5ff..13e9cbd 100644
--- a/sys/gnu/fs/ext2fs/ext2_vfsops.c
+++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c
@@ -506,6 +506,11 @@ static int compute_sb_data(devvp, es, fs)
}
fs->s_loaded_inode_bitmaps = 0;
fs->s_loaded_block_bitmaps = 0;
+ if (es->s_rev_level == EXT2_GOOD_OLD_REV || (es->s_feature_ro_compat &
+ EXT2_FEATURE_RO_COMPAT_LARGE_FILE) == 0)
+ fs->fs_maxfilesize = 0x7fffffff;
+ else
+ fs->fs_maxfilesize = 0x7fffffffffffffff;
return 0;
}
OpenPOWER on IntegriCloud