Author: fsu
Date: Tue Oct 24 20:10:08 2017
New Revision: 324963
URL: https://svnweb.freebsd.org/changeset/base/324963

Log:
  Fix physical block number overflow in different places.
  
  Approved by:    pfg (mentor)
  MFC after:      6 months

Modified:
  head/sys/fs/ext2fs/ext2_alloc.c
  head/sys/fs/ext2fs/ext2_extern.h
  head/sys/fs/ext2fs/ext2_inode.c
  head/sys/fs/ext2fs/ext2_subr.c

Modified: head/sys/fs/ext2fs/ext2_alloc.c
==============================================================================
--- head/sys/fs/ext2fs/ext2_alloc.c     Tue Oct 24 19:16:25 2017        
(r324962)
+++ head/sys/fs/ext2fs/ext2_alloc.c     Tue Oct 24 20:10:08 2017        
(r324963)
@@ -56,8 +56,8 @@
 static daddr_t ext2_alloccg(struct inode *, int, daddr_t, int);
 static daddr_t ext2_clusteralloc(struct inode *, int, daddr_t, int);
 static u_long  ext2_dirpref(struct inode *);
-static u_long  ext2_hashalloc(struct inode *, int, long, int,
-                               daddr_t (*)(struct inode *, int, daddr_t, 
+static e4fs_daddr_t ext2_hashalloc(struct inode *, int, long, int,
+    daddr_t (*)(struct inode *, int, daddr_t, 
                                                int));
 static daddr_t ext2_nodealloccg(struct inode *, int, daddr_t, int);
 static daddr_t  ext2_mapsearch(struct m_ext2fs *, char *, daddr_t);
@@ -85,7 +85,7 @@ ext2_alloc(struct inode *ip, daddr_t lbn, e4fs_daddr_t
 {
        struct m_ext2fs *fs;
        struct ext2mount *ump;
-       int32_t bno;
+       e4fs_daddr_t bno;
        int cg;
 
        *bnp = 0;
@@ -134,7 +134,7 @@ nospace:
 /*
  * Allocate EA's block for inode.
  */
-daddr_t
+e4fs_daddr_t
 ext2_alloc_meta(struct inode *ip)
 {
        struct m_ext2fs *fs;
@@ -617,12 +617,12 @@ ext2_blkpref(struct inode *ip, e2fs_lbn_t lbn, int ind
  *   2) quadradically rehash on the cylinder group number.
  *   3) brute force search for a free block.
  */
-static u_long
+static e4fs_daddr_t
 ext2_hashalloc(struct inode *ip, int cg, long pref, int size,
     daddr_t (*allocator) (struct inode *, int, daddr_t, int))
 {
        struct m_ext2fs *fs;
-       ino_t result;
+       e4fs_daddr_t result;
        int i, icg = cg;
 
        mtx_assert(EXT2_MTX(ip->i_ump), MA_OWNED);
@@ -1181,7 +1181,7 @@ ext2_blkfree(struct inode *ip, e4fs_daddr_t bno, long 
        fs = ip->i_e2fs;
        ump = ip->i_ump;
        cg = dtog(fs, bno);
-       if ((u_int)bno >= fs->e2fs->e2fs_bcount) {
+       if (bno >= fs->e2fs->e2fs_bcount) {
                printf("bad block %lld, ino %ju\n", (long long)bno,
                    (uintmax_t)ip->i_number);
                ext2_fserr(fs, ip->i_uid, "bad block");

Modified: head/sys/fs/ext2fs/ext2_extern.h
==============================================================================
--- head/sys/fs/ext2fs/ext2_extern.h    Tue Oct 24 19:16:25 2017        
(r324962)
+++ head/sys/fs/ext2fs/ext2_extern.h    Tue Oct 24 20:10:08 2017        
(r324963)
@@ -51,7 +51,7 @@ struct vnode;
 int    ext2_add_entry(struct vnode *, struct ext2fs_direct_2 *);
 int    ext2_alloc(struct inode *, daddr_t, e4fs_daddr_t, int,
            struct ucred *, e4fs_daddr_t *);
-daddr_t ext2_alloc_meta(struct inode *ip);
+e4fs_daddr_t ext2_alloc_meta(struct inode *ip);
 int    ext2_balloc(struct inode *,
            e2fs_lbn_t, int, struct ucred *, struct buf **, int);
 int    ext2_blkatoff(struct vnode *, off_t, char **, struct buf **);
@@ -61,7 +61,7 @@ e4fs_daddr_t  ext2_blkpref(struct inode *, e2fs_lbn_t, 
 int    ext2_bmap(struct vop_bmap_args *);
 int    ext2_bmaparray(struct vnode *, daddr_t, daddr_t *, int *, int *);
 int    ext4_bmapext(struct vnode *, int32_t, int64_t *, int *, int *);
-void   ext2_clusteracct(struct m_ext2fs *, char *, int, daddr_t, int);
+void   ext2_clusteracct(struct m_ext2fs *, char *, int, e4fs_daddr_t, int);
 void   ext2_dirbad(struct inode *ip, doff_t offset, char *how);
 void   ext2_fserr(struct m_ext2fs *, uid_t, char *);
 void   ext2_ei2i(struct ext2fs_dinode *, struct inode *);

Modified: head/sys/fs/ext2fs/ext2_inode.c
==============================================================================
--- head/sys/fs/ext2fs/ext2_inode.c     Tue Oct 24 19:16:25 2017        
(r324962)
+++ head/sys/fs/ext2fs/ext2_inode.c     Tue Oct 24 20:10:08 2017        
(r324963)
@@ -224,9 +224,9 @@ ext2_ind_truncate(struct vnode *vp, off_t length, int 
     struct thread *td)
 {
        struct vnode *ovp = vp;
-       int32_t lastblock;
+       e4fs_daddr_t lastblock;
        struct inode *oip;
-       int32_t bn, lbn, lastiblock[EXT2_NIADDR], indir_lbn[EXT2_NIADDR];
+       e4fs_daddr_t bn, lbn, lastiblock[EXT2_NIADDR], indir_lbn[EXT2_NIADDR];
        uint32_t oldblks[EXT2_NDADDR + EXT2_NIADDR];
        uint32_t newblks[EXT2_NDADDR + EXT2_NIADDR];
        struct m_ext2fs *fs;

Modified: head/sys/fs/ext2fs/ext2_subr.c
==============================================================================
--- head/sys/fs/ext2fs/ext2_subr.c      Tue Oct 24 19:16:25 2017        
(r324962)
+++ head/sys/fs/ext2fs/ext2_subr.c      Tue Oct 24 20:10:08 2017        
(r324963)
@@ -91,11 +91,12 @@ ext2_blkatoff(struct vnode *vp, off_t offset, char **r
  * Cnt == 1 means free; cnt == -1 means allocating.
  */
 void
-ext2_clusteracct(struct m_ext2fs *fs, char *bbp, int cg, daddr_t bno, int cnt)
+ext2_clusteracct(struct m_ext2fs *fs, char *bbp, int cg, e4fs_daddr_t bno, int 
cnt)
 {
        int32_t *sump = fs->e2fs_clustersum[cg].cs_sum;
        int32_t *lp;
-       int back, bit, end, forw, i, loc, start;
+       e4fs_daddr_t start, end, loc, forw, back;
+       int bit, i;
 
        /* Initialize the cluster summary array. */
        if (fs->e2fs_clustersum[cg].cs_init == 0) {
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to