Enforce the file size limit in VOP_WRITE() as well as VOP_TRUNCATE();
pointed out by bde.
This commit is contained in:
parent
4583be830a
commit
d2df6bc6f7
@ -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 */
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user