svn commit: r362098 - stable/12/sys/fs/ext2fs
Author: fsu Date: Fri Jun 12 13:54:41 2020 New Revision: 362098 URL: https://svnweb.freebsd.org/changeset/base/362098 Log: MFC r361135: Restrict the max runp and runb return values in case of extents mapping. This restriction already present in case of indirect mapping, do the same in case of extents. PR: 246182 Reported by: Teran McKinney Modified: stable/12/sys/fs/ext2fs/ext2_bmap.c Modified: stable/12/sys/fs/ext2fs/ext2_bmap.c == --- stable/12/sys/fs/ext2fs/ext2_bmap.c Fri Jun 12 13:53:50 2020 (r362097) +++ stable/12/sys/fs/ext2fs/ext2_bmap.c Fri Jun 12 13:54:41 2020 (r362098) @@ -94,21 +94,28 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bn { struct inode *ip; struct m_ext2fs *fs; + struct mount *mp; + struct ext2mount *ump; struct ext4_extent_header *ehp; struct ext4_extent *ep; struct ext4_extent_path *path = NULL; daddr_t lbn; - int error, depth; + int error, depth, maxrun = 0, bsize; ip = VTOI(vp); fs = ip->i_e2fs; + mp = vp->v_mount; + ump = VFSTOEXT2(mp); lbn = bn; ehp = (struct ext4_extent_header *)ip->i_data; depth = ehp->eh_depth; + bsize = EXT2_BLOCK_SIZE(ump->um_e2fs); *bnp = -1; - if (runp != NULL) + if (runp != NULL) { + maxrun = mp->mnt_iosize_max / bsize - 1; *runp = 0; + } if (runb != NULL) *runb = 0; @@ -119,18 +126,21 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bn ep = path[depth].ep_ext; if(ep) { if (lbn < ep->e_blk) { - if (runp != NULL) - *runp = ep->e_blk - lbn - 1; + if (runp != NULL) { + *runp = min(maxrun, ep->e_blk - lbn - 1); + } } else if (ep->e_blk <= lbn && lbn < ep->e_blk + ep->e_len) { *bnp = fsbtodb(fs, lbn - ep->e_blk + (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32)); - if (runp != NULL) - *runp = ep->e_len - (lbn - ep->e_blk) - 1; + if (runp != NULL) { + *runp = min(maxrun, + ep->e_len - (lbn - ep->e_blk) - 1); + } if (runb != NULL) - *runb = lbn - ep->e_blk; + *runb = min(maxrun, lbn - ep->e_blk); } else { if (runb != NULL) - *runb = ep->e_blk + lbn - ep->e_len; + *runb = min(maxrun, ep->e_blk + lbn - ep->e_len); } } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r362097 - stable/12/sys/fs/ext2fs
Author: fsu Date: Fri Jun 12 13:53:50 2020 New Revision: 362097 URL: https://svnweb.freebsd.org/changeset/base/362097 Log: MFC r361134: Fix incorrect inode link count check in case of rename. The check was incorrect because the directory inode link count have min value 2 after dir_nlink extfs feature introduction. Modified: stable/12/sys/fs/ext2fs/ext2_vnops.c Modified: stable/12/sys/fs/ext2fs/ext2_vnops.c == --- stable/12/sys/fs/ext2fs/ext2_vnops.cFri Jun 12 13:52:11 2020 (r362096) +++ stable/12/sys/fs/ext2fs/ext2_vnops.cFri Jun 12 13:53:50 2020 (r362097) @@ -1016,10 +1016,11 @@ abortit: */ ext2_dec_nlink(xp); if (doingdirectory) { - if (--xp->i_nlink != 0) + if (xp->i_nlink > 2) panic("ext2_rename: linked directory"); error = ext2_truncate(tvp, (off_t)0, IO_SYNC, tcnp->cn_cred, tcnp->cn_thread); + xp->i_nlink = 0; } xp->i_flag |= IN_CHANGE; vput(tvp); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r362096 - stable/12/sys/fs/ext2fs
Author: fsu Date: Fri Jun 12 13:52:11 2020 New Revision: 362096 URL: https://svnweb.freebsd.org/changeset/base/362096 Log: MFC r361133: Add inode bitmap tail initialization. Make ext2fs compatible with changes introduced in e2fsprogs v1.45.2. Now the tail of inode bitmap is filled with 0xff pattern explicitly during bitmap initialization phase to avoid e2fsck error like: "Padding at end of inode bitmap is not set." Modified: stable/12/sys/fs/ext2fs/ext2_alloc.c Modified: stable/12/sys/fs/ext2fs/ext2_alloc.c == --- stable/12/sys/fs/ext2fs/ext2_alloc.cFri Jun 12 13:02:44 2020 (r362095) +++ stable/12/sys/fs/ext2fs/ext2_alloc.cFri Jun 12 13:52:11 2020 (r362096) @@ -1286,6 +1286,16 @@ ext2_zero_inode_table(struct inode *ip, int cg) return (0); } +static void +ext2_fix_bitmap_tail(unsigned char *bitmap, int first, int last) +{ + int i; + + for (i = first; i <= last; i++) + bitmap[i] = 0xff; +} + + /* * Determine whether an inode can be allocated. * @@ -1298,7 +1308,7 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipr struct m_ext2fs *fs; struct buf *bp; struct ext2mount *ump; - int error, start, len, ifree; + int error, start, len, ifree, ibytes; char *ibp, *loc; ipref--;/* to avoid a lot of (ipref -1) */ @@ -1320,7 +1330,10 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipr if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) { if (fs->e2fs_gd[cg].ext4bgd_flags & EXT2_BG_INODE_UNINIT) { - memset(bp->b_data, 0, fs->e2fs_bsize); + ibytes = fs->e2fs_ipg / 8; + memset(bp->b_data, 0, ibytes - 1); + ext2_fix_bitmap_tail(bp->b_data, ibytes, + fs->e2fs_bsize - 1); fs->e2fs_gd[cg].ext4bgd_flags &= ~EXT2_BG_INODE_UNINIT; } ext2_gd_i_bitmap_csum_set(fs, cg, bp); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361136 - head/sys/fs/ext2fs
Author: fsu Date: Sun May 17 14:52:54 2020 New Revision: 361136 URL: https://svnweb.freebsd.org/changeset/base/361136 Log: Add BE architectures support. Author of most initial version: pfg (https://reviews.freebsd.org/D23259) Reviewed by:pfg MFC after: 3 months Differential Revision:https://reviews.freebsd.org/D24685 Modified: head/sys/fs/ext2fs/ext2_alloc.c head/sys/fs/ext2fs/ext2_balloc.c head/sys/fs/ext2fs/ext2_bmap.c head/sys/fs/ext2fs/ext2_csum.c head/sys/fs/ext2fs/ext2_extattr.c head/sys/fs/ext2fs/ext2_extents.c head/sys/fs/ext2fs/ext2_extents.h head/sys/fs/ext2fs/ext2_htree.c head/sys/fs/ext2fs/ext2_inode.c head/sys/fs/ext2fs/ext2_inode_cnv.c head/sys/fs/ext2fs/ext2_lookup.c head/sys/fs/ext2fs/ext2_subr.c head/sys/fs/ext2fs/ext2_vfsops.c head/sys/fs/ext2fs/ext2_vnops.c head/sys/fs/ext2fs/ext2fs.h head/sys/fs/ext2fs/fs.h Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Sun May 17 14:10:46 2020 (r361135) +++ head/sys/fs/ext2fs/ext2_alloc.c Sun May 17 14:52:54 2020 (r361136) @@ -397,7 +397,7 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred ump = pip->i_ump; EXT2_LOCK(ump); - if (fs->e2fs->e2fs_ficount == 0) + if (fs->e2fs_ficount == 0) goto noinodes; /* * If it is a directory then obtain a cylinder group based on @@ -413,7 +413,7 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred if (fs->e2fs_contigdirs[cg] > 0) fs->e2fs_contigdirs[cg]--; } - ipref = cg * fs->e2fs->e2fs_ipg + 1; + ipref = cg * fs->e2fs_ipg + 1; ino = (ino_t)ext2_hashalloc(pip, cg, (long)ipref, mode, ext2_nodealloccg); if (ino == 0) goto noinodes; @@ -501,87 +501,87 @@ uint64_t e2fs_gd_get_b_bitmap(struct ext2_gd *gd) { - return (((uint64_t)(gd->ext4bgd_b_bitmap_hi) << 32) | - gd->ext2bgd_b_bitmap); + return (((uint64_t)(le32toh(gd->ext4bgd_b_bitmap_hi)) << 32) | + le32toh(gd->ext2bgd_b_bitmap)); } uint64_t e2fs_gd_get_i_bitmap(struct ext2_gd *gd) { - return (((uint64_t)(gd->ext4bgd_i_bitmap_hi) << 32) | - gd->ext2bgd_i_bitmap); + return (((uint64_t)(le32toh(gd->ext4bgd_i_bitmap_hi)) << 32) | + le32toh(gd->ext2bgd_i_bitmap)); } uint64_t e2fs_gd_get_i_tables(struct ext2_gd *gd) { - return (((uint64_t)(gd->ext4bgd_i_tables_hi) << 32) | - gd->ext2bgd_i_tables); + return (((uint64_t)(le32toh(gd->ext4bgd_i_tables_hi)) << 32) | + le32toh(gd->ext2bgd_i_tables)); } static uint32_t e2fs_gd_get_nbfree(struct ext2_gd *gd) { - return (((uint32_t)(gd->ext4bgd_nbfree_hi) << 16) | - gd->ext2bgd_nbfree); + return (((uint32_t)(le16toh(gd->ext4bgd_nbfree_hi)) << 16) | + le16toh(gd->ext2bgd_nbfree)); } static void e2fs_gd_set_nbfree(struct ext2_gd *gd, uint32_t val) { - gd->ext2bgd_nbfree = val & 0x; - gd->ext4bgd_nbfree_hi = val >> 16; + gd->ext2bgd_nbfree = htole16(val & 0x); + gd->ext4bgd_nbfree_hi = htole16(val >> 16); } static uint32_t e2fs_gd_get_nifree(struct ext2_gd *gd) { - return (((uint32_t)(gd->ext4bgd_nifree_hi) << 16) | - gd->ext2bgd_nifree); + return (((uint32_t)(le16toh(gd->ext4bgd_nifree_hi)) << 16) | + le16toh(gd->ext2bgd_nifree)); } static void e2fs_gd_set_nifree(struct ext2_gd *gd, uint32_t val) { - gd->ext2bgd_nifree = val & 0x; - gd->ext4bgd_nifree_hi = val >> 16; + gd->ext2bgd_nifree = htole16(val & 0x); + gd->ext4bgd_nifree_hi = htole16(val >> 16); } uint32_t e2fs_gd_get_ndirs(struct ext2_gd *gd) { - return (((uint32_t)(gd->ext4bgd_ndirs_hi) << 16) | - gd->ext2bgd_ndirs); + return (((uint32_t)(le16toh(gd->ext4bgd_ndirs_hi)) << 16) | + le16toh(gd->ext2bgd_ndirs)); } static void e2fs_gd_set_ndirs(struct ext2_gd *gd, uint32_t val) { - gd->ext2bgd_ndirs = val & 0x; - gd->ext4bgd_ndirs_hi = val >> 16; + gd->ext2bgd_ndirs = htole16(val & 0x); + gd->ext4bgd_ndirs_hi = htole16(val >> 16); } static uint32_t e2fs_gd_get_i_unused(struct ext2_gd *gd) { - return (((uint32_t)(gd->ext4bgd_i_unused_hi) << 16) | - gd->ext4bgd_i_unused); + return ((uint32_t)(le16toh(gd->ext4bgd_i_unused_hi) << 16) | + le16toh(gd->ext4bgd_i_unused)); } static void e2fs_gd_set_i_unused(struct ext2_gd *gd, uint32_t val) { - gd->ext4bgd_i_unused = val & 0x; - gd->ext4bgd_i_unused_hi = val >> 16; + gd->ext4bgd_i_unused = htole16(val & 0x); + gd->ext4bgd_i_unused_hi = htole16(val >> 16); } /* @@ -612,7 +612,7 @@ ext2_dirpref(struct inode *pip)
svn commit: r361135 - head/sys/fs/ext2fs
Author: fsu Date: Sun May 17 14:10:46 2020 New Revision: 361135 URL: https://svnweb.freebsd.org/changeset/base/361135 Log: Restrict the max runp and runb return values in case of extents mapping. This restriction already present in case of indirect mapping, do the same in case of extents. PR: 246182 Reported by: Teran McKinney MFC after:2 weeks Modified: head/sys/fs/ext2fs/ext2_bmap.c Modified: head/sys/fs/ext2fs/ext2_bmap.c == --- head/sys/fs/ext2fs/ext2_bmap.c Sun May 17 14:03:13 2020 (r361134) +++ head/sys/fs/ext2fs/ext2_bmap.c Sun May 17 14:10:46 2020 (r361135) @@ -94,21 +94,28 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bn { struct inode *ip; struct m_ext2fs *fs; + struct mount *mp; + struct ext2mount *ump; struct ext4_extent_header *ehp; struct ext4_extent *ep; struct ext4_extent_path *path = NULL; daddr_t lbn; - int error, depth; + int error, depth, maxrun = 0, bsize; ip = VTOI(vp); fs = ip->i_e2fs; + mp = vp->v_mount; + ump = VFSTOEXT2(mp); lbn = bn; ehp = (struct ext4_extent_header *)ip->i_data; depth = ehp->eh_depth; + bsize = EXT2_BLOCK_SIZE(ump->um_e2fs); *bnp = -1; - if (runp != NULL) + if (runp != NULL) { + maxrun = mp->mnt_iosize_max / bsize - 1; *runp = 0; + } if (runb != NULL) *runb = 0; @@ -119,18 +126,21 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bn ep = path[depth].ep_ext; if(ep) { if (lbn < ep->e_blk) { - if (runp != NULL) - *runp = ep->e_blk - lbn - 1; + if (runp != NULL) { + *runp = min(maxrun, ep->e_blk - lbn - 1); + } } else if (ep->e_blk <= lbn && lbn < ep->e_blk + ep->e_len) { *bnp = fsbtodb(fs, lbn - ep->e_blk + (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32)); - if (runp != NULL) - *runp = ep->e_len - (lbn - ep->e_blk) - 1; + if (runp != NULL) { + *runp = min(maxrun, + ep->e_len - (lbn - ep->e_blk) - 1); + } if (runb != NULL) - *runb = lbn - ep->e_blk; + *runb = min(maxrun, lbn - ep->e_blk); } else { if (runb != NULL) - *runb = ep->e_blk + lbn - ep->e_len; + *runb = min(maxrun, ep->e_blk + lbn - ep->e_len); } } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361134 - head/sys/fs/ext2fs
Author: fsu Date: Sun May 17 14:03:13 2020 New Revision: 361134 URL: https://svnweb.freebsd.org/changeset/base/361134 Log: Fix incorrect inode link count check in case of rename. The check was incorrect because the directory inode link count have min value 2 after dir_nlink extfs feature introduction. Modified: head/sys/fs/ext2fs/ext2_vnops.c Modified: head/sys/fs/ext2fs/ext2_vnops.c == --- head/sys/fs/ext2fs/ext2_vnops.c Sun May 17 14:00:54 2020 (r361133) +++ head/sys/fs/ext2fs/ext2_vnops.c Sun May 17 14:03:13 2020 (r361134) @@ -1018,10 +1018,11 @@ abortit: */ ext2_dec_nlink(xp); if (doingdirectory) { - if (--xp->i_nlink != 0) + if (xp->i_nlink > 2) panic("ext2_rename: linked directory"); error = ext2_truncate(tvp, (off_t)0, IO_SYNC, tcnp->cn_cred, tcnp->cn_thread); + xp->i_nlink = 0; } xp->i_flag |= IN_CHANGE; vput(tvp); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361133 - head/sys/fs/ext2fs
Author: fsu Date: Sun May 17 14:00:54 2020 New Revision: 361133 URL: https://svnweb.freebsd.org/changeset/base/361133 Log: Add inode bitmap tail initialization. Make ext2fs compatible with changes introduced in e2fsprogs v1.45.2. Now the tail of inode bitmap is filled with 0xff pattern explicitly during bitmap initialization phase to avoid e2fsck error like: "Padding at end of inode bitmap is not set." Modified: head/sys/fs/ext2fs/ext2_alloc.c Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Sun May 17 11:13:12 2020 (r361132) +++ head/sys/fs/ext2fs/ext2_alloc.c Sun May 17 14:00:54 2020 (r361133) @@ -1287,6 +1287,16 @@ ext2_zero_inode_table(struct inode *ip, int cg) return (0); } +static void +ext2_fix_bitmap_tail(unsigned char *bitmap, int first, int last) +{ + int i; + + for (i = first; i <= last; i++) + bitmap[i] = 0xff; +} + + /* * Determine whether an inode can be allocated. * @@ -1299,7 +1309,7 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipr struct m_ext2fs *fs; struct buf *bp; struct ext2mount *ump; - int error, start, len, ifree; + int error, start, len, ifree, ibytes; char *ibp, *loc; ipref--;/* to avoid a lot of (ipref -1) */ @@ -1320,7 +1330,10 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipr if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) { if (fs->e2fs_gd[cg].ext4bgd_flags & EXT2_BG_INODE_UNINIT) { - memset(bp->b_data, 0, fs->e2fs_bsize); + ibytes = fs->e2fs_ipg / 8; + memset(bp->b_data, 0, ibytes - 1); + ext2_fix_bitmap_tail(bp->b_data, ibytes, + fs->e2fs_bsize - 1); fs->e2fs_gd[cg].ext4bgd_flags &= ~EXT2_BG_INODE_UNINIT; } ext2_gd_i_bitmap_csum_set(fs, cg, bp); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r358578 - stable/12/sys/fs/ext2fs
Author: fsu Date: Tue Mar 3 14:58:53 2020 New Revision: 358578 URL: https://svnweb.freebsd.org/changeset/base/358578 Log: MFC r358073: Add a EXT2FS-specific implementation for lseek(SEEK_DATA). Reviewed by:pfg MFC after: 1 week Differential Revision:https://reviews.freebsd.org/D23605 Modified: stable/12/sys/fs/ext2fs/ext2_bmap.c stable/12/sys/fs/ext2fs/ext2_extern.h stable/12/sys/fs/ext2fs/ext2_vnops.c Modified: stable/12/sys/fs/ext2fs/ext2_bmap.c == --- stable/12/sys/fs/ext2fs/ext2_bmap.c Tue Mar 3 14:15:30 2020 (r358577) +++ stable/12/sys/fs/ext2fs/ext2_bmap.c Tue Mar 3 14:58:53 2020 (r358578) @@ -139,6 +139,47 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bn return (error); } +static int +readindir(struct vnode *vp, e2fs_lbn_t lbn, e2fs_daddr_t daddr, struct buf **bpp) +{ + struct buf *bp; + struct mount *mp; + struct ext2mount *ump; + int error; + + mp = vp->v_mount; + ump = VFSTOEXT2(mp); + + bp = getblk(vp, lbn, mp->mnt_stat.f_iosize, 0, 0, 0); + if ((bp->b_flags & B_CACHE) == 0) { + KASSERT(daddr != 0, + ("readindir: indirect block not in cache")); + + bp->b_blkno = blkptrtodb(ump, daddr); + bp->b_iocmd = BIO_READ; + bp->b_flags &= ~B_INVAL; + bp->b_ioflags &= ~BIO_ERROR; + vfs_busy_pages(bp, 0); + bp->b_iooffset = dbtob(bp->b_blkno); + bstrategy(bp); +#ifdef RACCT + if (racct_enable) { + PROC_LOCK(curproc); + racct_add_buf(curproc, bp, 0); + PROC_UNLOCK(curproc); + } +#endif + curthread->td_ru.ru_inblock++; + error = bufwait(bp); + if (error != 0) { + brelse(bp); + return (error); + } + } + *bpp = bp; + return (0); +} + /* * Indirect blocks are now on the vnode for the file. They are given negative * logical block numbers. Indirect blocks are addressed by the negative @@ -228,35 +269,10 @@ ext2_bmaparray(struct vnode *vp, daddr_t bn, daddr_t * */ if (bp) bqrelse(bp); + error = readindir(vp, metalbn, daddr, ); + if (error != 0) + return (error); - bp = getblk(vp, metalbn, bsize, 0, 0, 0); - if ((bp->b_flags & B_CACHE) == 0) { -#ifdef INVARIANTS - if (!daddr) - panic("ext2_bmaparray: indirect block not in cache"); -#endif - bp->b_blkno = blkptrtodb(ump, daddr); - bp->b_iocmd = BIO_READ; - bp->b_flags &= ~B_INVAL; - bp->b_ioflags &= ~BIO_ERROR; - vfs_busy_pages(bp, 0); - bp->b_iooffset = dbtob(bp->b_blkno); - bstrategy(bp); -#ifdef RACCT - if (racct_enable) { - PROC_LOCK(curproc); - racct_add_buf(curproc, bp, 0); - PROC_UNLOCK(curproc); - } -#endif - curthread->td_ru.ru_inblock++; - error = bufwait(bp); - if (error) { - brelse(bp); - return (error); - } - } - daddr = ((e2fs_daddr_t *)bp->b_data)[ap->in_off]; if (num == 1 && daddr && runp) { for (bn = ap->in_off + 1; @@ -294,6 +310,107 @@ ext2_bmaparray(struct vnode *vp, daddr_t bn, daddr_t * *bnp = -1; } return (0); +} + +static e2fs_lbn_t +lbn_count(struct ext2mount *ump, int level) + +{ + e2fs_lbn_t blockcnt; + + for (blockcnt = 1; level > 0; level--) + blockcnt *= MNINDIR(ump); + return (blockcnt); +} + +int +ext2_bmap_seekdata(struct vnode *vp, off_t *offp) +{ + struct buf *bp; + struct indir a[EXT2_NIADDR + 1], *ap; + struct inode *ip; + struct mount *mp; + struct ext2mount *ump; + e2fs_daddr_t bn, daddr, nextbn; + uint64_t bsize; + off_t numblks; + int error, num, num1, off; + + bp = NULL; + error = 0; + ip = VTOI(vp); + mp = vp->v_mount; + ump = VFSTOEXT2(mp); + + if (vp->v_type != VREG || (ip->i_flags & SF_SNAPSHOT) != 0) + return (EINVAL); + if (*offp < 0 || *offp >= ip->i_size) + return (ENXIO); + + bsize = mp->mnt_stat.f_iosize; + for (bn = *offp / bsize, numblks = howmany(ip->i_size, bsize); + bn < numblks;
svn commit: r358073 - head/sys/fs/ext2fs
Author: fsu Date: Tue Feb 18 16:39:57 2020 New Revision: 358073 URL: https://svnweb.freebsd.org/changeset/base/358073 Log: Add a EXT2FS-specific implementation for lseek(SEEK_DATA). The lseek(SEEK_DATA) optimization logic could be simply borrowed from ufs side. See, https://reviews.freebsd.org/D19599. Reviewed by:pfg MFC after: 1 week Differential Revision:https://reviews.freebsd.org/D23605 Modified: head/sys/fs/ext2fs/ext2_bmap.c head/sys/fs/ext2fs/ext2_extern.h head/sys/fs/ext2fs/ext2_vnops.c Modified: head/sys/fs/ext2fs/ext2_bmap.c == --- head/sys/fs/ext2fs/ext2_bmap.c Tue Feb 18 16:37:48 2020 (r358072) +++ head/sys/fs/ext2fs/ext2_bmap.c Tue Feb 18 16:39:57 2020 (r358073) @@ -139,6 +139,47 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bn return (error); } +static int +readindir(struct vnode *vp, e2fs_lbn_t lbn, e2fs_daddr_t daddr, struct buf **bpp) +{ + struct buf *bp; + struct mount *mp; + struct ext2mount *ump; + int error; + + mp = vp->v_mount; + ump = VFSTOEXT2(mp); + + bp = getblk(vp, lbn, mp->mnt_stat.f_iosize, 0, 0, 0); + if ((bp->b_flags & B_CACHE) == 0) { + KASSERT(daddr != 0, + ("readindir: indirect block not in cache")); + + bp->b_blkno = blkptrtodb(ump, daddr); + bp->b_iocmd = BIO_READ; + bp->b_flags &= ~B_INVAL; + bp->b_ioflags &= ~BIO_ERROR; + vfs_busy_pages(bp, 0); + bp->b_iooffset = dbtob(bp->b_blkno); + bstrategy(bp); +#ifdef RACCT + if (racct_enable) { + PROC_LOCK(curproc); + racct_add_buf(curproc, bp, 0); + PROC_UNLOCK(curproc); + } +#endif + curthread->td_ru.ru_inblock++; + error = bufwait(bp); + if (error != 0) { + brelse(bp); + return (error); + } + } + *bpp = bp; + return (0); +} + /* * Indirect blocks are now on the vnode for the file. They are given negative * logical block numbers. Indirect blocks are addressed by the negative @@ -228,35 +269,10 @@ ext2_bmaparray(struct vnode *vp, daddr_t bn, daddr_t * */ if (bp) bqrelse(bp); + error = readindir(vp, metalbn, daddr, ); + if (error != 0) + return (error); - bp = getblk(vp, metalbn, bsize, 0, 0, 0); - if ((bp->b_flags & B_CACHE) == 0) { -#ifdef INVARIANTS - if (!daddr) - panic("ext2_bmaparray: indirect block not in cache"); -#endif - bp->b_blkno = blkptrtodb(ump, daddr); - bp->b_iocmd = BIO_READ; - bp->b_flags &= ~B_INVAL; - bp->b_ioflags &= ~BIO_ERROR; - vfs_busy_pages(bp, 0); - bp->b_iooffset = dbtob(bp->b_blkno); - bstrategy(bp); -#ifdef RACCT - if (racct_enable) { - PROC_LOCK(curproc); - racct_add_buf(curproc, bp, 0); - PROC_UNLOCK(curproc); - } -#endif - curthread->td_ru.ru_inblock++; - error = bufwait(bp); - if (error) { - brelse(bp); - return (error); - } - } - daddr = ((e2fs_daddr_t *)bp->b_data)[ap->in_off]; if (num == 1 && daddr && runp) { for (bn = ap->in_off + 1; @@ -294,6 +310,107 @@ ext2_bmaparray(struct vnode *vp, daddr_t bn, daddr_t * *bnp = -1; } return (0); +} + +static e2fs_lbn_t +lbn_count(struct ext2mount *ump, int level) + +{ + e2fs_lbn_t blockcnt; + + for (blockcnt = 1; level > 0; level--) + blockcnt *= MNINDIR(ump); + return (blockcnt); +} + +int +ext2_bmap_seekdata(struct vnode *vp, off_t *offp) +{ + struct buf *bp; + struct indir a[EXT2_NIADDR + 1], *ap; + struct inode *ip; + struct mount *mp; + struct ext2mount *ump; + e2fs_daddr_t bn, daddr, nextbn; + uint64_t bsize; + off_t numblks; + int error, num, num1, off; + + bp = NULL; + error = 0; + ip = VTOI(vp); + mp = vp->v_mount; + ump = VFSTOEXT2(mp); + + if (vp->v_type != VREG || (ip->i_flags & SF_SNAPSHOT) != 0) + return (EINVAL); + if (*offp < 0 || *offp >= ip->i_size) + return (ENXIO); + + bsize = mp->mnt_stat.f_iosize; +
svn commit: r346269 - head/sys/fs/ext2fs
Author: fsu Date: Tue Apr 16 11:37:15 2019 New Revision: 346269 URL: https://svnweb.freebsd.org/changeset/base/346269 Log: ext2fs: Initial version of DTrace support. Commit forgotten file. Reviewed by:pfg, gnn MFC after: 1 week Differential Revision:https://reviews.freebsd.org/D19848 Modified: head/sys/fs/ext2fs/ext2_extents.c Modified: head/sys/fs/ext2fs/ext2_extents.c == --- head/sys/fs/ext2fs/ext2_extents.c Tue Apr 16 11:30:41 2019 (r346268) +++ head/sys/fs/ext2fs/ext2_extents.c Tue Apr 16 11:37:15 2019 (r346269) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -46,9 +47,17 @@ #include #include +SDT_PROVIDER_DECLARE(ext2fs); +/* + * ext2fs trace probe: + * arg0: verbosity. Higher numbers give more verbose messages + * arg1: Textual message + */ +SDT_PROBE_DEFINE2(ext2fs, , trace, extents, "int", "char*"); + static MALLOC_DEFINE(M_EXT2EXTENTS, "ext2_extents", "EXT2 extents"); -#ifdef EXT2FS_DEBUG +#ifdef EXT2FS_PRINT_EXTENTS static void ext4_ext_print_extent(struct ext4_extent *ep) { @@ -230,22 +239,22 @@ ext4_ext_check_header(struct inode *ip, struct ext4_ex fs = ip->i_e2fs; if (eh->eh_magic != EXT4_EXT_MAGIC) { - error_msg = "invalid magic"; + error_msg = "header: invalid magic"; goto corrupted; } if (eh->eh_max == 0) { - error_msg = "invalid eh_max"; + error_msg = "header: invalid eh_max"; goto corrupted; } if (eh->eh_ecount > eh->eh_max) { - error_msg = "invalid eh_entries"; + error_msg = "header: invalid eh_entries"; goto corrupted; } return (0); corrupted: - ext2_fserr(fs, ip->i_uid, error_msg); + SDT_PROBE2(ext2fs, , trace, extents, 1, error_msg); return (EIO); } @@ -412,7 +421,7 @@ ext4_ext_find_extent(struct inode *ip, daddr_t block, ppos++; if (ppos > depth) { - ext2_fserr(fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "ppos > depth => extent corrupted"); error = EIO; brelse(bp); @@ -643,13 +652,13 @@ ext4_ext_insert_index(struct inode *ip, struct ext4_ex fs = ip->i_e2fs; if (lblk == path->ep_index->ei_blk) { - ext2_fserr(fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "lblk == index blk => extent corrupted"); return (EIO); } if (path->ep_header->eh_ecount >= path->ep_header->eh_max) { - ext2_fserr(fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "ecout > maxcount => extent corrupted"); return (EIO); } @@ -667,7 +676,7 @@ ext4_ext_insert_index(struct inode *ip, struct ext4_ex memmove(idx + 1, idx, len * sizeof(struct ext4_extent_index)); if (idx > EXT_MAX_INDEX(path->ep_header)) { - ext2_fserr(fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "index is out of range => extent corrupted"); return (EIO); } @@ -736,7 +745,7 @@ ext4_ext_split(struct inode *ip, struct ext4_extent_pa * We will split at current extent for now. */ if (path[depth].ep_ext > EXT_MAX_EXTENT(path[depth].ep_header)) { - ext2_fserr(fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "extent is out of range => extent corrupted"); return (EIO); } @@ -773,7 +782,7 @@ ext4_ext_split(struct inode *ip, struct ext4_extent_pa ex = EXT_FIRST_EXTENT(neh); if (path[depth].ep_header->eh_ecount != path[depth].ep_header->eh_max) { - ext2_fserr(fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "extents count out of range => extent corrupted"); error = EIO; goto cleanup; @@ -1362,7 +1371,7 @@ ext4_ext_rm_leaf(struct inode *ip, struct ext4_extent_ eh = path[depth].ep_header; if (!eh) { - ext2_fserr(ip->i_e2fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "bad header => extent corrupted"); return (EIO); } @@ -1449,7 +1458,8 @@ ext4_read_extent_tree_block(struct inode *ip, e4fs_dad eh = ext4_ext_block_header(bp->b_data); if (eh->eh_depth != depth) { - ext2_fserr(fs, ip->i_uid, "unexpected eh_depth"); + SDT_PROBE2(ext2fs, , trace, extents, 1, + "unexpected eh_depth"); goto err; }
svn commit: r346267 - head/sys/fs/ext2fs
Author: fsu Date: Tue Apr 16 11:20:10 2019 New Revision: 346267 URL: https://svnweb.freebsd.org/changeset/base/346267 Log: ext2fs: Initial version of DTrace support. Reviewed by:pfg, gnn MFC after: 1 week Differential Revision:https://reviews.freebsd.org/D19848 Modified: head/sys/fs/ext2fs/ext2_alloc.c head/sys/fs/ext2fs/ext2_csum.c head/sys/fs/ext2fs/ext2_extattr.c head/sys/fs/ext2fs/ext2_extents.h head/sys/fs/ext2fs/ext2_extern.h head/sys/fs/ext2fs/ext2_hash.c head/sys/fs/ext2fs/ext2_htree.c head/sys/fs/ext2fs/ext2_inode.c head/sys/fs/ext2fs/ext2_inode_cnv.c head/sys/fs/ext2fs/ext2_lookup.c head/sys/fs/ext2fs/ext2_subr.c head/sys/fs/ext2fs/ext2_vfsops.c head/sys/fs/ext2fs/ext2_vnops.c head/sys/fs/ext2fs/fs.h Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Tue Apr 16 09:44:46 2019 (r346266) +++ head/sys/fs/ext2fs/ext2_alloc.c Tue Apr 16 11:20:10 2019 (r346267) @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +56,23 @@ #include #include +SDT_PROVIDER_DEFINE(ext2fs); +/* + * ext2fs trace probe: + * arg0: verbosity. Higher numbers give more verbose messages + * arg1: Textual message + */ +SDT_PROBE_DEFINE2(ext2fs, , alloc, trace, "int", "char*"); +SDT_PROBE_DEFINE3(ext2fs, , alloc, ext2_reallocblks_realloc, +"ino_t", "e2fs_lbn_t", "e2fs_lbn_t"); +SDT_PROBE_DEFINE1(ext2fs, , alloc, ext2_reallocblks_bap, "uint32_t"); +SDT_PROBE_DEFINE1(ext2fs, , alloc, ext2_reallocblks_blkno, "e2fs_daddr_t"); +SDT_PROBE_DEFINE2(ext2fs, , alloc, ext2_b_bitmap_validate_error, "char*", "int"); +SDT_PROBE_DEFINE3(ext2fs, , alloc, ext2_nodealloccg_bmap_corrupted, +"int", "daddr_t", "char*"); +SDT_PROBE_DEFINE2(ext2fs, , alloc, ext2_blkfree_bad_block, "ino_t", "e4fs_daddr_t"); +SDT_PROBE_DEFINE2(ext2fs, , alloc, ext2_vfree_doublefree, "char*", "ino_t"); + 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 *); @@ -128,8 +146,7 @@ ext2_alloc(struct inode *ip, daddr_t lbn, e4fs_daddr_t } nospace: EXT2_UNLOCK(ump); - ext2_fserr(fs, cred->cr_uid, "filesystem full"); - uprintf("\n%s: write failed, filesystem is full\n", fs->e2fs_fsmnt); + SDT_PROBE2(ext2fs, , alloc, trace, 1, "cannot allocate data block"); return (ENOSPC); } @@ -147,8 +164,10 @@ ext2_alloc_meta(struct inode *ip) EXT2_LOCK(ip->i_ump); blk = ext2_hashalloc(ip, ino_to_cg(fs, ip->i_number), 0, fs->e2fs_bsize, ext2_alloccg); - if (0 == blk) + if (0 == blk) { EXT2_UNLOCK(ip->i_ump); + SDT_PROBE2(ext2fs, , alloc, trace, 1, "cannot allocate meta block"); + } return (blk); } @@ -289,10 +308,8 @@ ext2_reallocblks(struct vop_reallocblks_args *ap) * block pointers in the inode and indirect blocks associated * with the file. */ -#ifdef DEBUG - printf("realloc: ino %ju, lbns %jd-%jd\n\told:", - (uintmax_t)ip->i_number, (intmax_t)start_lbn, (intmax_t)end_lbn); -#endif /* DEBUG */ + SDT_PROBE3(ext2fs, , alloc, ext2_reallocblks_realloc, + ip->i_number, start_lbn, end_lbn); blkno = newblk; for (bap = [soff], i = 0; i < len; i++, blkno += fs->e2fs_fpb) { if (i == ssize) { @@ -303,9 +320,7 @@ ext2_reallocblks(struct vop_reallocblks_args *ap) if (buflist->bs_children[i]->b_blkno != fsbtodb(fs, *bap)) panic("ext2_reallocblks: alloc mismatch"); #endif -#ifdef DEBUG - printf(" %d,", *bap); -#endif /* DEBUG */ + SDT_PROBE1(ext2fs, , alloc, ext2_reallocblks_bap, *bap); *bap++ = blkno; } /* @@ -341,20 +356,13 @@ ext2_reallocblks(struct vop_reallocblks_args *ap) /* * Last, free the old blocks and assign the new blocks to the buffers. */ -#ifdef DEBUG - printf("\n\tnew:"); -#endif /* DEBUG */ for (blkno = newblk, i = 0; i < len; i++, blkno += fs->e2fs_fpb) { ext2_blkfree(ip, dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->e2fs_bsize); buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno); -#ifdef DEBUG - printf(" %d,", blkno); -#endif /* DEBUG */ + SDT_PROBE1(ext2fs, , alloc, ext2_reallocblks_blkno, blkno); } -#ifdef DEBUG - printf("\n"); -#endif /* DEBUG */ + return (0); fail: @@ -481,8 +489,7 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred noinodes: EXT2_UNLOCK(ump); - ext2_fserr(fs, cred->cr_uid, "out of inodes"); - uprintf("\n%s: create/symlink failed, no inodes free\n", fs->e2fs_fsmnt); + SDT_PROBE2(ext2fs, ,
svn commit: r350385 - stable/11/sys/fs/ext2fs
Author: fsu Date: Sat Jul 27 19:29:28 2019 New Revision: 350385 URL: https://svnweb.freebsd.org/changeset/base/350385 Log: MFC r349800,r349801,r349802: Fix misc fs fuzzing issues. Reported by:Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE Reported as:FS-27-EXT2-12: Denial of Service in openat-0 (vm_fault_hold/ext2_clusteracct) FS-22-EXT2-9: Denial of service in ftruncate-0 (ext2_balloc) FS-11-EXT2-6: Denial Of Service in write-1 (ext2_balloc) Modified: stable/11/sys/fs/ext2fs/ext2_balloc.c stable/11/sys/fs/ext2fs/ext2_vfsops.c Modified: stable/11/sys/fs/ext2fs/ext2_balloc.c == --- stable/11/sys/fs/ext2fs/ext2_balloc.c Sat Jul 27 19:29:23 2019 (r350384) +++ stable/11/sys/fs/ext2fs/ext2_balloc.c Sat Jul 27 19:29:28 2019 (r350385) @@ -67,7 +67,7 @@ ext2_balloc(struct inode *ip, e2fs_lbn_t lbn, int size struct indir indirs[NIADDR + 2]; e4fs_daddr_t nb, newb; e2fs_daddr_t *bap, pref; - int osize, nsize, num, i, error; + int num, i, error; *bpp = NULL; if (lbn < 0) @@ -93,56 +93,25 @@ ext2_balloc(struct inode *ip, e2fs_lbn_t lbn, int size * no new block is to be allocated, and no need to expand * the file */ - if (nb != 0 && ip->i_size >= (lbn + 1) * fs->e2fs_bsize) { + if (nb != 0) { error = bread(vp, lbn, fs->e2fs_bsize, NOCRED, ); if (error) { brelse(bp); return (error); } bp->b_blkno = fsbtodb(fs, nb); - *bpp = bp; - return (0); - } - if (nb != 0) { - /* -* Consider need to reallocate a fragment. -*/ - osize = fragroundup(fs, blkoff(fs, ip->i_size)); - nsize = fragroundup(fs, size); - if (nsize <= osize) { - error = bread(vp, lbn, osize, NOCRED, ); - if (error) { - brelse(bp); - return (error); - } - bp->b_blkno = fsbtodb(fs, nb); - } else { - /* -* Godmar thinks: this shouldn't happen w/o -* fragments -*/ - printf("nsize %d(%d) > osize %d(%d) nb %d\n", - (int)nsize, (int)size, (int)osize, - (int)ip->i_size, (int)nb); - panic( - "ext2_balloc: Something is terribly wrong"); -/* - * please note there haven't been any changes from here on - - * FFS seems to work. - */ + if (ip->i_size >= (lbn + 1) * fs->e2fs_bsize) { + *bpp = bp; + return (0); } } else { - if (ip->i_size < (lbn + 1) * fs->e2fs_bsize) - nsize = fragroundup(fs, size); - else - nsize = fs->e2fs_bsize; EXT2_LOCK(ump); error = ext2_alloc(ip, lbn, ext2_blkpref(ip, lbn, (int)lbn, >i_db[0], 0), - nsize, cred, ); + fs->e2fs_bsize, cred, ); if (error) return (error); - bp = getblk(vp, lbn, nsize, 0, 0, 0); + bp = getblk(vp, lbn, fs->e2fs_bsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, newb); if (flags & BA_CLRBUF) vfs_bio_clrbuf(bp); @@ -227,7 +196,6 @@ ext2_balloc(struct inode *ip, e2fs_lbn_t lbn, int size */ if ((error = bwrite(nbp)) != 0) { ext2_blkfree(ip, nb, fs->e2fs_bsize); - EXT2_UNLOCK(ump); brelse(bp); return (error); } Modified: stable/11/sys/fs/ext2fs/ext2_vfsops.c == --- stable/11/sys/fs/ext2fs/ext2_vfsops.c Sat Jul 27 19:29:23 2019 (r350384) +++ stable/11/sys/fs/ext2fs/ext2_vfsops.c Sat Jul 27 19:29:28 2019 (r350385) @@ -375,8 +375,11 @@ compute_sb_data(struct vnode *devvp, struct ext2fs *es
svn commit: r350384 - stable/12/sys/fs/ext2fs
Author: fsu Date: Sat Jul 27 19:29:23 2019 New Revision: 350384 URL: https://svnweb.freebsd.org/changeset/base/350384 Log: MFC r349800,r349801: Fix misc fs fuzzing issues. Reported by:Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE Reported as:FS-22-EXT2-9: Denial of service in ftruncate-0 (ext2_balloc) FS-11-EXT2-6: Denial Of Service in write-1 (ext2_balloc) Modified: stable/12/sys/fs/ext2fs/ext2_balloc.c Modified: stable/12/sys/fs/ext2fs/ext2_balloc.c == --- stable/12/sys/fs/ext2fs/ext2_balloc.c Sat Jul 27 18:07:46 2019 (r350383) +++ stable/12/sys/fs/ext2fs/ext2_balloc.c Sat Jul 27 19:29:23 2019 (r350384) @@ -62,7 +62,7 @@ ext2_ext_balloc(struct inode *ip, uint32_t lbn, int si struct buf *bp = NULL; struct vnode *vp = ITOV(ip); daddr_t newblk; - int osize, nsize, blks, error, allocated; + int blks, error, allocated; fs = ip->i_e2fs; blks = howmany(size, fs->e2fs_bsize); @@ -72,47 +72,22 @@ ext2_ext_balloc(struct inode *ip, uint32_t lbn, int si return (error); if (allocated) { - if (ip->i_size < (lbn + 1) * fs->e2fs_bsize) - nsize = fragroundup(fs, size); - else - nsize = fs->e2fs_bsize; - - bp = getblk(vp, lbn, nsize, 0, 0, 0); + bp = getblk(vp, lbn, fs->e2fs_bsize, 0, 0, 0); if(!bp) return (EIO); - - bp->b_blkno = fsbtodb(fs, newblk); - if (flags & BA_CLRBUF) - vfs_bio_clrbuf(bp); } else { - if (ip->i_size >= (lbn + 1) * fs->e2fs_bsize) { - - error = bread(vp, lbn, fs->e2fs_bsize, NOCRED, ); - if (error) { - brelse(bp); - return (error); - } - bp->b_blkno = fsbtodb(fs, newblk); - *bpp = bp; - return (0); - } - - /* -* Consider need to reallocate a fragment. -*/ - osize = fragroundup(fs, blkoff(fs, ip->i_size)); - nsize = fragroundup(fs, size); - if (nsize <= osize) - error = bread(vp, lbn, osize, NOCRED, ); - else - error = bread(vp, lbn, fs->e2fs_bsize, NOCRED, ); + error = bread(vp, lbn, fs->e2fs_bsize, NOCRED, ); if (error) { brelse(bp); return (error); } - bp->b_blkno = fsbtodb(fs, newblk); } + + bp->b_blkno = fsbtodb(fs, newblk); + if (flags & BA_CLRBUF) + vfs_bio_clrbuf(bp); + *bpp = bp; return (error); @@ -134,7 +109,7 @@ ext2_balloc(struct inode *ip, e2fs_lbn_t lbn, int size struct indir indirs[EXT2_NIADDR + 2]; e4fs_daddr_t nb, newb; e2fs_daddr_t *bap, pref; - int osize, nsize, num, i, error; + int num, i, error; *bpp = NULL; if (lbn < 0) @@ -164,53 +139,22 @@ ext2_balloc(struct inode *ip, e2fs_lbn_t lbn, int size * no new block is to be allocated, and no need to expand * the file */ - if (nb != 0 && ip->i_size >= (lbn + 1) * fs->e2fs_bsize) { + if (nb != 0) { error = bread(vp, lbn, fs->e2fs_bsize, NOCRED, ); if (error) { brelse(bp); return (error); } bp->b_blkno = fsbtodb(fs, nb); - *bpp = bp; - return (0); - } - if (nb != 0) { - /* -* Consider need to reallocate a fragment. -*/ - osize = fragroundup(fs, blkoff(fs, ip->i_size)); - nsize = fragroundup(fs, size); - if (nsize <= osize) { - error = bread(vp, lbn, osize, NOCRED, ); - if (error) { - brelse(bp); - return (error); - } - bp->b_blkno = fsbtodb(fs, nb); - } else { - /* -* Godmar thinks: this shouldn't happen w/o -* fragments -*/ - printf("nsize %d(%d) > osize %d(%d) nb %d\n", -
svn commit: r349802 - head/sys/fs/ext2fs
Author: fsu Date: Sun Jul 7 08:58:02 2019 New Revision: 349802 URL: https://svnweb.freebsd.org/changeset/base/349802 Log: Add additional check for 'blocks per group' and 'fragments per group' superblock fields. These fields will not be equal only in case if bigalloc filesystem feature is turned on. This feature is not supported for now. Reported by:Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE Reported as:FS-27-EXT2-12: Denial of Service in openat-0 (vm_fault_hold/ext2_clusteracct) MFC after:2 weeks Modified: head/sys/fs/ext2fs/ext2_vfsops.c Modified: head/sys/fs/ext2fs/ext2_vfsops.c == --- head/sys/fs/ext2fs/ext2_vfsops.cSun Jul 7 08:56:13 2019 (r349801) +++ head/sys/fs/ext2fs/ext2_vfsops.cSun Jul 7 08:58:02 2019 (r349802) @@ -559,7 +559,12 @@ ext2_compute_sb_data(struct vnode *devvp, struct ext2f SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error, "zero blocks/fragments per group"); return (EINVAL); + } else if (fs->e2fs_bpg != fs->e2fs_fpg) { + SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error, + "blocks per group not equal fragments per group"); + return (EINVAL); } + if (fs->e2fs_bpg != fs->e2fs_bsize * 8) { SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error, "non-standard group size unsupported"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r349801 - head/sys/fs/ext2fs
Author: fsu Date: Sun Jul 7 08:56:13 2019 New Revision: 349801 URL: https://svnweb.freebsd.org/changeset/base/349801 Log: Remove ufs fragments logic. The ext2fs fragments are different from ufs fragments. In case of ext2fs the fragment should be equal or more then block size. The values more than block size are used only in case of bigalloc feature, which is does not supported for now. Reported by:Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE Reported as:FS-22-EXT2-9: Denial of service in ftruncate-0 (ext2_balloc) MFC after:2 weeks Modified: head/sys/fs/ext2fs/ext2_balloc.c Modified: head/sys/fs/ext2fs/ext2_balloc.c == --- head/sys/fs/ext2fs/ext2_balloc.cSun Jul 7 08:53:52 2019 (r349800) +++ head/sys/fs/ext2fs/ext2_balloc.cSun Jul 7 08:56:13 2019 (r349801) @@ -62,7 +62,7 @@ ext2_ext_balloc(struct inode *ip, uint32_t lbn, int si struct buf *bp = NULL; struct vnode *vp = ITOV(ip); daddr_t newblk; - int osize, nsize, blks, error, allocated; + int blks, error, allocated; fs = ip->i_e2fs; blks = howmany(size, fs->e2fs_bsize); @@ -72,47 +72,22 @@ ext2_ext_balloc(struct inode *ip, uint32_t lbn, int si return (error); if (allocated) { - if (ip->i_size < (lbn + 1) * fs->e2fs_bsize) - nsize = fragroundup(fs, size); - else - nsize = fs->e2fs_bsize; - - bp = getblk(vp, lbn, nsize, 0, 0, 0); + bp = getblk(vp, lbn, fs->e2fs_bsize, 0, 0, 0); if(!bp) return (EIO); - - bp->b_blkno = fsbtodb(fs, newblk); - if (flags & BA_CLRBUF) - vfs_bio_clrbuf(bp); } else { - if (ip->i_size >= (lbn + 1) * fs->e2fs_bsize) { - - error = bread(vp, lbn, fs->e2fs_bsize, NOCRED, ); - if (error) { - brelse(bp); - return (error); - } - bp->b_blkno = fsbtodb(fs, newblk); - *bpp = bp; - return (0); - } - - /* -* Consider need to reallocate a fragment. -*/ - osize = fragroundup(fs, blkoff(fs, ip->i_size)); - nsize = fragroundup(fs, size); - if (nsize <= osize) - error = bread(vp, lbn, osize, NOCRED, ); - else - error = bread(vp, lbn, fs->e2fs_bsize, NOCRED, ); + error = bread(vp, lbn, fs->e2fs_bsize, NOCRED, ); if (error) { brelse(bp); return (error); } - bp->b_blkno = fsbtodb(fs, newblk); } + + bp->b_blkno = fsbtodb(fs, newblk); + if (flags & BA_CLRBUF) + vfs_bio_clrbuf(bp); + *bpp = bp; return (error); @@ -134,7 +109,7 @@ ext2_balloc(struct inode *ip, e2fs_lbn_t lbn, int size struct indir indirs[EXT2_NIADDR + 2]; e4fs_daddr_t nb, newb; e2fs_daddr_t *bap, pref; - int osize, nsize, num, i, error; + int num, i, error; *bpp = NULL; if (lbn < 0) @@ -164,53 +139,22 @@ ext2_balloc(struct inode *ip, e2fs_lbn_t lbn, int size * no new block is to be allocated, and no need to expand * the file */ - if (nb != 0 && ip->i_size >= (lbn + 1) * fs->e2fs_bsize) { + if (nb != 0) { error = bread(vp, lbn, fs->e2fs_bsize, NOCRED, ); if (error) { brelse(bp); return (error); } bp->b_blkno = fsbtodb(fs, nb); - *bpp = bp; - return (0); - } - if (nb != 0) { - /* -* Consider need to reallocate a fragment. -*/ - osize = fragroundup(fs, blkoff(fs, ip->i_size)); - nsize = fragroundup(fs, size); - if (nsize <= osize) { - error = bread(vp, lbn, osize, NOCRED, ); - if (error) { - brelse(bp); - return (error); - } - bp->b_blkno = fsbtodb(fs, nb); - } else { - /* -* Godmar thinks: this shouldn't happen w/o -* fragments -
svn commit: r349800 - head/sys/fs/ext2fs
Author: fsu Date: Sun Jul 7 08:53:52 2019 New Revision: 349800 URL: https://svnweb.freebsd.org/changeset/base/349800 Log: Remove unneeded mount point unlock call. Reported by:Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE Reported as:FS-11-EXT2-6: Denial Of Service in write-1 (ext2_balloc) MFC after:2 weeks Modified: head/sys/fs/ext2fs/ext2_balloc.c Modified: head/sys/fs/ext2fs/ext2_balloc.c == --- head/sys/fs/ext2fs/ext2_balloc.cSun Jul 7 06:57:04 2019 (r349799) +++ head/sys/fs/ext2fs/ext2_balloc.cSun Jul 7 08:53:52 2019 (r349800) @@ -308,7 +308,6 @@ ext2_balloc(struct inode *ip, e2fs_lbn_t lbn, int size */ if ((error = bwrite(nbp)) != 0) { ext2_blkfree(ip, nb, fs->e2fs_bsize); - EXT2_UNLOCK(ump); brelse(bp); return (error); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r346955 - stable/12/sys/fs/ext2fs
Author: fsu Date: Tue Apr 30 09:10:45 2019 New Revision: 346955 URL: https://svnweb.freebsd.org/changeset/base/346955 Log: MFC r346267, 346269: ext2fs: Initial version of DTrace support. Reviewed by:pfg, gnn Differential Revision:https://reviews.freebsd.org/D19848 Modified: stable/12/sys/fs/ext2fs/ext2_alloc.c stable/12/sys/fs/ext2fs/ext2_csum.c stable/12/sys/fs/ext2fs/ext2_extattr.c stable/12/sys/fs/ext2fs/ext2_extents.c stable/12/sys/fs/ext2fs/ext2_extents.h stable/12/sys/fs/ext2fs/ext2_extern.h stable/12/sys/fs/ext2fs/ext2_hash.c stable/12/sys/fs/ext2fs/ext2_htree.c stable/12/sys/fs/ext2fs/ext2_inode.c stable/12/sys/fs/ext2fs/ext2_inode_cnv.c stable/12/sys/fs/ext2fs/ext2_lookup.c stable/12/sys/fs/ext2fs/ext2_subr.c stable/12/sys/fs/ext2fs/ext2_vfsops.c stable/12/sys/fs/ext2fs/ext2_vnops.c stable/12/sys/fs/ext2fs/fs.h Modified: stable/12/sys/fs/ext2fs/ext2_alloc.c == --- stable/12/sys/fs/ext2fs/ext2_alloc.cTue Apr 30 08:17:11 2019 (r346954) +++ stable/12/sys/fs/ext2fs/ext2_alloc.cTue Apr 30 09:10:45 2019 (r346955) @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +56,23 @@ #include #include +SDT_PROVIDER_DEFINE(ext2fs); +/* + * ext2fs trace probe: + * arg0: verbosity. Higher numbers give more verbose messages + * arg1: Textual message + */ +SDT_PROBE_DEFINE2(ext2fs, , alloc, trace, "int", "char*"); +SDT_PROBE_DEFINE3(ext2fs, , alloc, ext2_reallocblks_realloc, +"ino_t", "e2fs_lbn_t", "e2fs_lbn_t"); +SDT_PROBE_DEFINE1(ext2fs, , alloc, ext2_reallocblks_bap, "uint32_t"); +SDT_PROBE_DEFINE1(ext2fs, , alloc, ext2_reallocblks_blkno, "e2fs_daddr_t"); +SDT_PROBE_DEFINE2(ext2fs, , alloc, ext2_b_bitmap_validate_error, "char*", "int"); +SDT_PROBE_DEFINE3(ext2fs, , alloc, ext2_nodealloccg_bmap_corrupted, +"int", "daddr_t", "char*"); +SDT_PROBE_DEFINE2(ext2fs, , alloc, ext2_blkfree_bad_block, "ino_t", "e4fs_daddr_t"); +SDT_PROBE_DEFINE2(ext2fs, , alloc, ext2_vfree_doublefree, "char*", "ino_t"); + 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 *); @@ -128,8 +146,7 @@ ext2_alloc(struct inode *ip, daddr_t lbn, e4fs_daddr_t } nospace: EXT2_UNLOCK(ump); - ext2_fserr(fs, cred->cr_uid, "filesystem full"); - uprintf("\n%s: write failed, filesystem is full\n", fs->e2fs_fsmnt); + SDT_PROBE2(ext2fs, , alloc, trace, 1, "cannot allocate data block"); return (ENOSPC); } @@ -147,8 +164,10 @@ ext2_alloc_meta(struct inode *ip) EXT2_LOCK(ip->i_ump); blk = ext2_hashalloc(ip, ino_to_cg(fs, ip->i_number), 0, fs->e2fs_bsize, ext2_alloccg); - if (0 == blk) + if (0 == blk) { EXT2_UNLOCK(ip->i_ump); + SDT_PROBE2(ext2fs, , alloc, trace, 1, "cannot allocate meta block"); + } return (blk); } @@ -289,10 +308,8 @@ ext2_reallocblks(struct vop_reallocblks_args *ap) * block pointers in the inode and indirect blocks associated * with the file. */ -#ifdef DEBUG - printf("realloc: ino %ju, lbns %jd-%jd\n\told:", - (uintmax_t)ip->i_number, (intmax_t)start_lbn, (intmax_t)end_lbn); -#endif /* DEBUG */ + SDT_PROBE3(ext2fs, , alloc, ext2_reallocblks_realloc, + ip->i_number, start_lbn, end_lbn); blkno = newblk; for (bap = [soff], i = 0; i < len; i++, blkno += fs->e2fs_fpb) { if (i == ssize) { @@ -303,9 +320,7 @@ ext2_reallocblks(struct vop_reallocblks_args *ap) if (buflist->bs_children[i]->b_blkno != fsbtodb(fs, *bap)) panic("ext2_reallocblks: alloc mismatch"); #endif -#ifdef DEBUG - printf(" %d,", *bap); -#endif /* DEBUG */ + SDT_PROBE1(ext2fs, , alloc, ext2_reallocblks_bap, *bap); *bap++ = blkno; } /* @@ -341,20 +356,13 @@ ext2_reallocblks(struct vop_reallocblks_args *ap) /* * Last, free the old blocks and assign the new blocks to the buffers. */ -#ifdef DEBUG - printf("\n\tnew:"); -#endif /* DEBUG */ for (blkno = newblk, i = 0; i < len; i++, blkno += fs->e2fs_fpb) { ext2_blkfree(ip, dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->e2fs_bsize); buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno); -#ifdef DEBUG - printf(" %d,", blkno); -#endif /* DEBUG */ + SDT_PROBE1(ext2fs, , alloc, ext2_reallocblks_blkno, blkno); } -#ifdef DEBUG - printf("\n"); -#endif /* DEBUG */ + return (0); fail: @@ -481,8 +489,7 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred noinodes: EXT2_UNLOCK(ump); - ext2_fserr(fs, cred->cr_uid,
svn commit: r346269 - head/sys/fs/ext2fs
Author: fsu Date: Tue Apr 16 11:37:15 2019 New Revision: 346269 URL: https://svnweb.freebsd.org/changeset/base/346269 Log: ext2fs: Initial version of DTrace support. Commit forgotten file. Reviewed by:pfg, gnn MFC after: 1 week Differential Revision:https://reviews.freebsd.org/D19848 Modified: head/sys/fs/ext2fs/ext2_extents.c Modified: head/sys/fs/ext2fs/ext2_extents.c == --- head/sys/fs/ext2fs/ext2_extents.c Tue Apr 16 11:30:41 2019 (r346268) +++ head/sys/fs/ext2fs/ext2_extents.c Tue Apr 16 11:37:15 2019 (r346269) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -46,9 +47,17 @@ #include #include +SDT_PROVIDER_DECLARE(ext2fs); +/* + * ext2fs trace probe: + * arg0: verbosity. Higher numbers give more verbose messages + * arg1: Textual message + */ +SDT_PROBE_DEFINE2(ext2fs, , trace, extents, "int", "char*"); + static MALLOC_DEFINE(M_EXT2EXTENTS, "ext2_extents", "EXT2 extents"); -#ifdef EXT2FS_DEBUG +#ifdef EXT2FS_PRINT_EXTENTS static void ext4_ext_print_extent(struct ext4_extent *ep) { @@ -230,22 +239,22 @@ ext4_ext_check_header(struct inode *ip, struct ext4_ex fs = ip->i_e2fs; if (eh->eh_magic != EXT4_EXT_MAGIC) { - error_msg = "invalid magic"; + error_msg = "header: invalid magic"; goto corrupted; } if (eh->eh_max == 0) { - error_msg = "invalid eh_max"; + error_msg = "header: invalid eh_max"; goto corrupted; } if (eh->eh_ecount > eh->eh_max) { - error_msg = "invalid eh_entries"; + error_msg = "header: invalid eh_entries"; goto corrupted; } return (0); corrupted: - ext2_fserr(fs, ip->i_uid, error_msg); + SDT_PROBE2(ext2fs, , trace, extents, 1, error_msg); return (EIO); } @@ -412,7 +421,7 @@ ext4_ext_find_extent(struct inode *ip, daddr_t block, ppos++; if (ppos > depth) { - ext2_fserr(fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "ppos > depth => extent corrupted"); error = EIO; brelse(bp); @@ -643,13 +652,13 @@ ext4_ext_insert_index(struct inode *ip, struct ext4_ex fs = ip->i_e2fs; if (lblk == path->ep_index->ei_blk) { - ext2_fserr(fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "lblk == index blk => extent corrupted"); return (EIO); } if (path->ep_header->eh_ecount >= path->ep_header->eh_max) { - ext2_fserr(fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "ecout > maxcount => extent corrupted"); return (EIO); } @@ -667,7 +676,7 @@ ext4_ext_insert_index(struct inode *ip, struct ext4_ex memmove(idx + 1, idx, len * sizeof(struct ext4_extent_index)); if (idx > EXT_MAX_INDEX(path->ep_header)) { - ext2_fserr(fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "index is out of range => extent corrupted"); return (EIO); } @@ -736,7 +745,7 @@ ext4_ext_split(struct inode *ip, struct ext4_extent_pa * We will split at current extent for now. */ if (path[depth].ep_ext > EXT_MAX_EXTENT(path[depth].ep_header)) { - ext2_fserr(fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "extent is out of range => extent corrupted"); return (EIO); } @@ -773,7 +782,7 @@ ext4_ext_split(struct inode *ip, struct ext4_extent_pa ex = EXT_FIRST_EXTENT(neh); if (path[depth].ep_header->eh_ecount != path[depth].ep_header->eh_max) { - ext2_fserr(fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "extents count out of range => extent corrupted"); error = EIO; goto cleanup; @@ -1362,7 +1371,7 @@ ext4_ext_rm_leaf(struct inode *ip, struct ext4_extent_ eh = path[depth].ep_header; if (!eh) { - ext2_fserr(ip->i_e2fs, ip->i_uid, + SDT_PROBE2(ext2fs, , trace, extents, 1, "bad header => extent corrupted"); return (EIO); } @@ -1449,7 +1458,8 @@ ext4_read_extent_tree_block(struct inode *ip, e4fs_dad eh = ext4_ext_block_header(bp->b_data); if (eh->eh_depth != depth) { - ext2_fserr(fs, ip->i_uid, "unexpected eh_depth"); + SDT_PROBE2(ext2fs, , trace, extents, 1, + "unexpected eh_depth"); goto err; }
svn commit: r346267 - head/sys/fs/ext2fs
Author: fsu Date: Tue Apr 16 11:20:10 2019 New Revision: 346267 URL: https://svnweb.freebsd.org/changeset/base/346267 Log: ext2fs: Initial version of DTrace support. Reviewed by:pfg, gnn MFC after: 1 week Differential Revision:https://reviews.freebsd.org/D19848 Modified: head/sys/fs/ext2fs/ext2_alloc.c head/sys/fs/ext2fs/ext2_csum.c head/sys/fs/ext2fs/ext2_extattr.c head/sys/fs/ext2fs/ext2_extents.h head/sys/fs/ext2fs/ext2_extern.h head/sys/fs/ext2fs/ext2_hash.c head/sys/fs/ext2fs/ext2_htree.c head/sys/fs/ext2fs/ext2_inode.c head/sys/fs/ext2fs/ext2_inode_cnv.c head/sys/fs/ext2fs/ext2_lookup.c head/sys/fs/ext2fs/ext2_subr.c head/sys/fs/ext2fs/ext2_vfsops.c head/sys/fs/ext2fs/ext2_vnops.c head/sys/fs/ext2fs/fs.h Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Tue Apr 16 09:44:46 2019 (r346266) +++ head/sys/fs/ext2fs/ext2_alloc.c Tue Apr 16 11:20:10 2019 (r346267) @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +56,23 @@ #include #include +SDT_PROVIDER_DEFINE(ext2fs); +/* + * ext2fs trace probe: + * arg0: verbosity. Higher numbers give more verbose messages + * arg1: Textual message + */ +SDT_PROBE_DEFINE2(ext2fs, , alloc, trace, "int", "char*"); +SDT_PROBE_DEFINE3(ext2fs, , alloc, ext2_reallocblks_realloc, +"ino_t", "e2fs_lbn_t", "e2fs_lbn_t"); +SDT_PROBE_DEFINE1(ext2fs, , alloc, ext2_reallocblks_bap, "uint32_t"); +SDT_PROBE_DEFINE1(ext2fs, , alloc, ext2_reallocblks_blkno, "e2fs_daddr_t"); +SDT_PROBE_DEFINE2(ext2fs, , alloc, ext2_b_bitmap_validate_error, "char*", "int"); +SDT_PROBE_DEFINE3(ext2fs, , alloc, ext2_nodealloccg_bmap_corrupted, +"int", "daddr_t", "char*"); +SDT_PROBE_DEFINE2(ext2fs, , alloc, ext2_blkfree_bad_block, "ino_t", "e4fs_daddr_t"); +SDT_PROBE_DEFINE2(ext2fs, , alloc, ext2_vfree_doublefree, "char*", "ino_t"); + 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 *); @@ -128,8 +146,7 @@ ext2_alloc(struct inode *ip, daddr_t lbn, e4fs_daddr_t } nospace: EXT2_UNLOCK(ump); - ext2_fserr(fs, cred->cr_uid, "filesystem full"); - uprintf("\n%s: write failed, filesystem is full\n", fs->e2fs_fsmnt); + SDT_PROBE2(ext2fs, , alloc, trace, 1, "cannot allocate data block"); return (ENOSPC); } @@ -147,8 +164,10 @@ ext2_alloc_meta(struct inode *ip) EXT2_LOCK(ip->i_ump); blk = ext2_hashalloc(ip, ino_to_cg(fs, ip->i_number), 0, fs->e2fs_bsize, ext2_alloccg); - if (0 == blk) + if (0 == blk) { EXT2_UNLOCK(ip->i_ump); + SDT_PROBE2(ext2fs, , alloc, trace, 1, "cannot allocate meta block"); + } return (blk); } @@ -289,10 +308,8 @@ ext2_reallocblks(struct vop_reallocblks_args *ap) * block pointers in the inode and indirect blocks associated * with the file. */ -#ifdef DEBUG - printf("realloc: ino %ju, lbns %jd-%jd\n\told:", - (uintmax_t)ip->i_number, (intmax_t)start_lbn, (intmax_t)end_lbn); -#endif /* DEBUG */ + SDT_PROBE3(ext2fs, , alloc, ext2_reallocblks_realloc, + ip->i_number, start_lbn, end_lbn); blkno = newblk; for (bap = [soff], i = 0; i < len; i++, blkno += fs->e2fs_fpb) { if (i == ssize) { @@ -303,9 +320,7 @@ ext2_reallocblks(struct vop_reallocblks_args *ap) if (buflist->bs_children[i]->b_blkno != fsbtodb(fs, *bap)) panic("ext2_reallocblks: alloc mismatch"); #endif -#ifdef DEBUG - printf(" %d,", *bap); -#endif /* DEBUG */ + SDT_PROBE1(ext2fs, , alloc, ext2_reallocblks_bap, *bap); *bap++ = blkno; } /* @@ -341,20 +356,13 @@ ext2_reallocblks(struct vop_reallocblks_args *ap) /* * Last, free the old blocks and assign the new blocks to the buffers. */ -#ifdef DEBUG - printf("\n\tnew:"); -#endif /* DEBUG */ for (blkno = newblk, i = 0; i < len; i++, blkno += fs->e2fs_fpb) { ext2_blkfree(ip, dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->e2fs_bsize); buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno); -#ifdef DEBUG - printf(" %d,", blkno); -#endif /* DEBUG */ + SDT_PROBE1(ext2fs, , alloc, ext2_reallocblks_blkno, blkno); } -#ifdef DEBUG - printf("\n"); -#endif /* DEBUG */ + return (0); fail: @@ -481,8 +489,7 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred noinodes: EXT2_UNLOCK(ump); - ext2_fserr(fs, cred->cr_uid, "out of inodes"); - uprintf("\n%s: create/symlink failed, no inodes free\n", fs->e2fs_fsmnt); + SDT_PROBE2(ext2fs, ,
svn commit: r345272 - stable/12/sys/fs/ext2fs
Author: fsu Date: Mon Mar 18 12:34:13 2019 New Revision: 345272 URL: https://svnweb.freebsd.org/changeset/base/345272 Log: MFC: r344757: Fix double free in case of mount error. Reported by:Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE Reported as:FS-9-EXT3-2: Denial Of Service in nmount-5 (vm_fault_hold) Reviewed by:pfg Differential Revision:https://reviews.freebsd.org/D19385 Modified: stable/12/sys/fs/ext2fs/ext2_vfsops.c Modified: stable/12/sys/fs/ext2fs/ext2_vfsops.c == --- stable/12/sys/fs/ext2fs/ext2_vfsops.c Mon Mar 18 12:31:07 2019 (r345271) +++ stable/12/sys/fs/ext2fs/ext2_vfsops.c Mon Mar 18 12:34:13 2019 (r345272) @@ -614,8 +614,12 @@ ext2_compute_sb_data(struct vnode *devvp, struct ext2f fsbtodb(fs, ext2_cg_location(fs, i)), fs->e2fs_bsize, NOCRED, ); if (error) { - free(fs->e2fs_contigdirs, M_EXT2MNT); - free(fs->e2fs_gd, M_EXT2MNT); + /* +* fs->e2fs_gd and fs->e2fs_contigdirs +* will be freed later by the caller, +* because this function could be called from +* MNT_UPDATE path. +*/ brelse(bp); return (error); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r345271 - stable/12/sys/fs/ext2fs
Author: fsu Date: Mon Mar 18 12:31:07 2019 New Revision: 345271 URL: https://svnweb.freebsd.org/changeset/base/345271 Log: MFC: r344752: Add additional on-disk inode checks. Reviewed by:pfg Differential Revision:https://reviews.freebsd.org/D19323 Modified: stable/12/sys/fs/ext2fs/ext2_csum.c stable/12/sys/fs/ext2fs/ext2_inode_cnv.c stable/12/sys/fs/ext2fs/ext2_vfsops.c stable/12/sys/fs/ext2fs/ext2fs.h Modified: stable/12/sys/fs/ext2fs/ext2_csum.c == --- stable/12/sys/fs/ext2fs/ext2_csum.c Mon Mar 18 12:26:25 2019 (r345270) +++ stable/12/sys/fs/ext2fs/ext2_csum.c Mon Mar 18 12:31:07 2019 (r345271) @@ -629,6 +629,8 @@ ext2_ei_csum_verify(struct inode *ip, struct ext2fs_di if (!memcmp(ei, _zero, sizeof(struct ext2fs_dinode))) return (0); + printf("WARNING: Bad inode %ju csum - run fsck\n", ip->i_number); + return (EIO); } Modified: stable/12/sys/fs/ext2fs/ext2_inode_cnv.c == --- stable/12/sys/fs/ext2fs/ext2_inode_cnv.cMon Mar 18 12:26:25 2019 (r345270) +++ stable/12/sys/fs/ext2fs/ext2_inode_cnv.cMon Mar 18 12:31:07 2019 (r345271) @@ -34,7 +34,6 @@ #include #include -#include #include #include #include @@ -92,8 +91,31 @@ ext2_print_inode(struct inode *in) int ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) { + struct m_ext2fs *fs = ip->i_e2fs; + if ((ip->i_number < EXT2_FIRST_INO(fs) && ip->i_number != EXT2_ROOTINO) || + (ip->i_number < EXT2_ROOTINO) || + (ip->i_number > fs->e2fs->e2fs_icount)) { + printf("ext2fs: bad inode number %ju\n", ip->i_number); + return (EINVAL); + } + + if (ip->i_number == EXT2_ROOTINO && ei->e2di_nlink == 0) { + printf("ext2fs: root inode unallocated\n"); + return (EINVAL); + } ip->i_nlink = ei->e2di_nlink; + + /* Check extra inode size */ + if (EXT2_INODE_SIZE(fs) > E2FS_REV0_INODE_SIZE) { + if (E2FS_REV0_INODE_SIZE + ei->e2di_extra_isize > + EXT2_INODE_SIZE(fs) || (ei->e2di_extra_isize & 3)) { + printf("ext2fs: bad extra inode size %u, inode size=%u\n", + ei->e2di_extra_isize, EXT2_INODE_SIZE(fs)); + return (EINVAL); + } + } + /* * Godmar thinks - if the link count is zero, then the inode is * unused - according to ext2 standards. Ufs marks this fact by Modified: stable/12/sys/fs/ext2fs/ext2_vfsops.c == --- stable/12/sys/fs/ext2fs/ext2_vfsops.c Mon Mar 18 12:26:25 2019 (r345270) +++ stable/12/sys/fs/ext2fs/ext2_vfsops.c Mon Mar 18 12:31:07 2019 (r345271) @@ -773,11 +773,18 @@ loop: MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp); return (error); } - ext2_ei2i((struct ext2fs_dinode *)((char *)bp->b_data + + + error = ext2_ei2i((struct ext2fs_dinode *)((char *)bp->b_data + EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number)), ip); + brelse(bp); VOP_UNLOCK(vp, 0); vrele(vp); + + if (error) { + MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp); + return (error); + } } return (0); } @@ -1208,8 +1215,6 @@ ext2_vget(struct mount *mp, ino_t ino, int flags, stru error = ext2_ei2i((struct ext2fs_dinode *)((char *)bp->b_data + EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ino)), ip); if (error) { - printf("ext2fs: Bad inode %lu csum - run fsck\n", - (unsigned long)ino); brelse(bp); vput(vp); *vpp = NULL; Modified: stable/12/sys/fs/ext2fs/ext2fs.h == --- stable/12/sys/fs/ext2fs/ext2fs.hMon Mar 18 12:26:25 2019 (r345270) +++ stable/12/sys/fs/ext2fs/ext2fs.hMon Mar 18 12:31:07 2019 (r345271) @@ -422,4 +422,11 @@ struct ext2_gd { EXT2F_INCOMPAT_64BIT) ? ((s)->e2fs_bsize / sizeof(struct ext2_gd)) : \ ((s)->e2fs_bsize / E2FS_REV0_GD_SIZE)) +/* + * Macro-instructions used to manage inodes + */ +#defineEXT2_FIRST_INO(s) ((EXT2_SB(s)->e2fs->e2fs_rev == E2FS_REV0) ? \ +EXT2_FIRSTINO : \ +EXT2_SB(s)->e2fs->e2fs_first_ino) + #endif /* !_FS_EXT2FS_EXT2FS_H_ */ ___ svn-src-all@freebsd.org mailing list
svn commit: r345270 - stable/12/sys/fs/ext2fs
Author: fsu Date: Mon Mar 18 12:26:25 2019 New Revision: 345270 URL: https://svnweb.freebsd.org/changeset/base/345270 Log: MFC: r344754: Do not panic if inode bitmap is corrupted. admbug: 804 Reported by:Ilja Van Sprundel Reviewed by:pfg Differential Revision:https://reviews.freebsd.org/D19325 Modified: stable/12/sys/fs/ext2fs/ext2_alloc.c Modified: stable/12/sys/fs/ext2fs/ext2_alloc.c == --- stable/12/sys/fs/ext2fs/ext2_alloc.cMon Mar 18 12:22:23 2019 (r345269) +++ stable/12/sys/fs/ext2fs/ext2_alloc.cMon Mar 18 12:26:25 2019 (r345270) @@ -1350,10 +1350,12 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipr start = 0; loc = memcchr([start], 0xff, len); if (loc == NULL) { - printf("cg = %d, ipref = %lld, fs = %s\n", + printf("ext2fs: inode bitmap corrupted: " + "cg = %d, ipref = %lld, fs = %s - run fsck\n", cg, (long long)ipref, fs->e2fs_fsmnt); - panic("ext2fs_nodealloccg: map corrupted"); - /* NOTREACHED */ + brelse(bp); + EXT2_LOCK(ump); + return (0); } } ipref = (loc - ibp) * NBBY + ffs(~*loc) - 1; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r345268 - stable/12/sys/fs/ext2fs
Author: fsu Date: Mon Mar 18 12:22:04 2019 New Revision: 345268 URL: https://svnweb.freebsd.org/changeset/base/345268 Log: MFC: r344756, r345179: Do not read the on-disk inode in case of vnode allocation. Reported by:Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE Reported as:FS-6-EXT2-4: Denial Of Service in mkdir-0 (ext2_mkdir/vn_rdwr) Reviewed by:pfg Differential Revision:https://reviews.freebsd.org/D19327 Modified: stable/12/sys/fs/ext2fs/ext2_alloc.c Modified: stable/12/sys/fs/ext2fs/ext2_alloc.c == --- stable/12/sys/fs/ext2fs/ext2_alloc.cMon Mar 18 12:15:58 2019 (r345267) +++ stable/12/sys/fs/ext2fs/ext2_alloc.cMon Mar 18 12:22:04 2019 (r345268) @@ -373,10 +373,12 @@ int ext2_valloc(struct vnode *pvp, int mode, struct ucred *cred, struct vnode **vpp) { struct timespec ts; - struct inode *pip; struct m_ext2fs *fs; - struct inode *ip; struct ext2mount *ump; + struct inode *pip; + struct inode *ip; + struct vnode *vp; + struct thread *td; ino_t ino, ipref; int error, cg; @@ -404,33 +406,63 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred } ipref = cg * fs->e2fs->e2fs_ipg + 1; ino = (ino_t)ext2_hashalloc(pip, cg, (long)ipref, mode, ext2_nodealloccg); - if (ino == 0) goto noinodes; - error = VFS_VGET(pvp->v_mount, ino, LK_EXCLUSIVE, vpp); + + td = curthread; + error = vfs_hash_get(ump->um_mountp, ino, LK_EXCLUSIVE, td, vpp, NULL, NULL); + if (error || *vpp != NULL) { + return (error); + } + + ip = malloc(sizeof(struct inode), M_EXT2NODE, M_WAITOK | M_ZERO); + if (ip == NULL) { + return (ENOMEM); + } + + /* Allocate a new vnode/inode. */ + if ((error = getnewvnode("ext2fs", ump->um_mountp, _vnodeops, )) != 0) { + free(ip, M_EXT2NODE); + return (error); + } + + lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); + vp->v_data = ip; + ip->i_vnode = vp; + ip->i_e2fs = fs = ump->um_e2fs; + ip->i_ump = ump; + ip->i_number = ino; + ip->i_block_group = ino_to_cg(fs, ino); + ip->i_next_alloc_block = 0; + ip->i_next_alloc_goal = 0; + + error = insmntque(vp, ump->um_mountp); if (error) { - ext2_vfree(pvp, ino, mode); + free(ip, M_EXT2NODE); return (error); } - ip = VTOI(*vpp); - /* -* The question is whether using VGET was such good idea at all: -* Linux doesn't read the old inode in when it is allocating a -* new one. I will set at least i_size and i_blocks to zero. -*/ - ip->i_flag = 0; - ip->i_size = 0; - ip->i_blocks = 0; - ip->i_mode = 0; - ip->i_flags = 0; + error = vfs_hash_insert(vp, ino, LK_EXCLUSIVE, td, vpp, NULL, NULL); + if (error || *vpp != NULL) { + *vpp = NULL; + free(ip, M_EXT2NODE); + return (error); + } + + if ((error = ext2_vinit(ump->um_mountp, _fifoops, )) != 0) { + vput(vp); + *vpp = NULL; + free(ip, M_EXT2NODE); + return (error); + } + if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_EXTENTS) && (S_ISREG(mode) || S_ISDIR(mode))) ext4_ext_tree_init(ip); else memset(ip->i_data, 0, sizeof(ip->i_data)); - + /* * Set up a new generation number for this inode. * Avoid zero values. @@ -443,10 +475,10 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred ip->i_birthtime = ts.tv_sec; ip->i_birthnsec = ts.tv_nsec; -/* -printf("ext2_valloc: allocated inode %d\n", ino); -*/ + *vpp = vp; + return (0); + noinodes: EXT2_UNLOCK(ump); ext2_fserr(fs, cred->cr_uid, "out of inodes"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r345267 - stable/12/sys/fs/ext2fs
Author: fsu Date: Mon Mar 18 12:15:58 2019 New Revision: 345267 URL: https://svnweb.freebsd.org/changeset/base/345267 Log: MFC: r344755: Fix integer overflow possibility. Reported by:Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE Reported as:FS-2-EXT2-1: Out-of-Bounds Write in nmount (ext2_vget) Reviewed by:pfg Differential Revision:https://reviews.freebsd.org/D19326 Modified: stable/12/sys/fs/ext2fs/ext2_vfsops.c Modified: stable/12/sys/fs/ext2fs/ext2_vfsops.c == --- stable/12/sys/fs/ext2fs/ext2_vfsops.c Mon Mar 18 12:09:10 2019 (r345266) +++ stable/12/sys/fs/ext2fs/ext2_vfsops.c Mon Mar 18 12:15:58 2019 (r345267) @@ -1156,8 +1156,8 @@ ext2_vget(struct mount *mp, ino_t ino, int flags, stru struct buf *bp; struct vnode *vp; struct thread *td; - int i, error; - int used_blocks; + unsigned int i, used_blocks; + int error; td = curthread; error = vfs_hash_get(mp, ino, flags, td, vpp, NULL, NULL); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r345266 - stable/12/sys/fs/ext2fs
Author: fsu Date: Mon Mar 18 12:09:10 2019 New Revision: 345266 URL: https://svnweb.freebsd.org/changeset/base/345266 Log: MFC: r344753: Validate block bitmaps. Reviewed by:pfg Differential Revision:https://reviews.freebsd.org/D19324 Modified: stable/12/sys/fs/ext2fs/ext2_alloc.c Modified: stable/12/sys/fs/ext2fs/ext2_alloc.c == --- stable/12/sys/fs/ext2fs/ext2_alloc.cMon Mar 18 12:04:43 2019 (r345265) +++ stable/12/sys/fs/ext2fs/ext2_alloc.cMon Mar 18 12:09:10 2019 (r345266) @@ -902,6 +902,52 @@ ext2_cg_block_bitmap_init(struct m_ext2fs *fs, int cg, return (0); } +static int +ext2_b_bitmap_validate(struct m_ext2fs *fs, struct buf *bp, int cg) +{ + struct ext2_gd *gd; + uint64_t group_first_block; + unsigned int offset, max_bit; + + if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG)) { + /* +* It is not possible to check block bitmap in case of this feature, +* because the inode and block bitmaps and inode table +* blocks may not be in the group at all. +* So, skip check in this case. +*/ + return (0); + } + + gd = >e2fs_gd[cg]; + max_bit = fs->e2fs_fpg; + group_first_block = ((uint64_t)cg) * fs->e2fs->e2fs_fpg + + fs->e2fs->e2fs_first_dblock; + + /* Check block bitmap block number */ + offset = e2fs_gd_get_b_bitmap(gd) - group_first_block; + if (offset >= max_bit || !isset(bp->b_data, offset)) { + printf("ext2fs: bad block bitmap, group %d\n", cg); + return (EINVAL); + } + + /* Check inode bitmap block number */ + offset = e2fs_gd_get_i_bitmap(gd) - group_first_block; + if (offset >= max_bit || !isset(bp->b_data, offset)) { + printf("ext2fs: bad inode bitmap, group %d\n", cg); + return (EINVAL); + } + + /* Check inode table */ + offset = e2fs_gd_get_i_tables(gd) - group_first_block; + if (offset >= max_bit || offset + fs->e2fs_itpg >= max_bit) { + printf("ext2fs: bad inode table, group %d\n", cg); + return (EINVAL); + } + + return (0); +} + /* * Determine whether a block can be allocated. * @@ -922,40 +968,37 @@ ext2_alloccg(struct inode *ip, int cg, daddr_t bpref, ump = ip->i_ump; if (e2fs_gd_get_nbfree(>e2fs_gd[cg]) == 0) return (0); + EXT2_UNLOCK(ump); error = bread(ip->i_devvp, fsbtodb(fs, e2fs_gd_get_b_bitmap(>e2fs_gd[cg])), (int)fs->e2fs_bsize, NOCRED, ); - if (error) { - brelse(bp); - EXT2_LOCK(ump); - return (0); - } + if (error) + goto fail; + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) { error = ext2_cg_block_bitmap_init(fs, cg, bp); - if (error) { - brelse(bp); - EXT2_LOCK(ump); - return (0); - } + if (error) + goto fail; + ext2_gd_b_bitmap_csum_set(fs, cg, bp); } error = ext2_gd_b_bitmap_csum_verify(fs, cg, bp); - if (error) { - brelse(bp); - EXT2_LOCK(ump); - return (0); - } - if (e2fs_gd_get_nbfree(>e2fs_gd[cg]) == 0) { - /* -* Another thread allocated the last block in this -* group while we were waiting for the buffer. -*/ - brelse(bp); - EXT2_LOCK(ump); - return (0); - } + if (error) + goto fail; + + error = ext2_b_bitmap_validate(fs,bp, cg); + if (error) + goto fail; + + /* +* Check, that another thread did not not allocate the last block in this +* group while we were waiting for the buffer. +*/ + if (e2fs_gd_get_nbfree(>e2fs_gd[cg]) == 0) + goto fail; + bbp = (char *)bp->b_data; if (dtog(fs, bpref) != cg) @@ -1028,11 +1071,9 @@ retry: goto retry; } bno = ext2_mapsearch(fs, bbp, bpref); - if (bno < 0) { - brelse(bp); - EXT2_LOCK(ump); - return (0); - } + if (bno < 0) + goto fail; + gotit: #ifdef INVARIANTS if (isset(bbp, bno)) { @@ -1052,6 +1093,11 @@ gotit: ext2_gd_b_bitmap_csum_set(fs, cg, bp); bdwrite(bp); return (((uint64_t)cg) * fs->e2fs->e2fs_fpg + fs->e2fs->e2fs_first_dblock + bno); + +fail: + brelse(bp); + EXT2_LOCK(ump); + return (0); } /*
svn commit: r345265 - stable/12/sys/fs/ext2fs
Author: fsu Date: Mon Mar 18 12:04:43 2019 New Revision: 345265 URL: https://svnweb.freebsd.org/changeset/base/345265 Log: MFC r344751: Make superblock reading logic more strict. Add more on-disk superblock consistency checks to ext2_compute_sb_data() function. It should decrease the probability of mounting filesystems with corrupted superblock data. Reviewed by:pfg Differential Revision:https://reviews.freebsd.org/D19322 Modified: stable/12/sys/fs/ext2fs/ext2_alloc.c stable/12/sys/fs/ext2fs/ext2_extern.h stable/12/sys/fs/ext2fs/ext2_vfsops.c stable/12/sys/fs/ext2fs/ext2fs.h Modified: stable/12/sys/fs/ext2fs/ext2_alloc.c == --- stable/12/sys/fs/ext2fs/ext2_alloc.cMon Mar 18 11:44:53 2019 (r345264) +++ stable/12/sys/fs/ext2fs/ext2_alloc.cMon Mar 18 12:04:43 2019 (r345265) @@ -457,7 +457,7 @@ noinodes: /* * 64-bit compatible getters and setters for struct ext2_gd from ext2fs.h */ -static uint64_t +uint64_t e2fs_gd_get_b_bitmap(struct ext2_gd *gd) { @@ -465,7 +465,7 @@ e2fs_gd_get_b_bitmap(struct ext2_gd *gd) gd->ext2bgd_b_bitmap); } -static uint64_t +uint64_t e2fs_gd_get_i_bitmap(struct ext2_gd *gd) { @@ -754,7 +754,7 @@ ext2_hashalloc(struct inode *ip, int cg, long pref, in return (0); } -static unsigned long +static uint64_t ext2_cg_number_gdb_nometa(struct m_ext2fs *fs, int cg) { @@ -768,7 +768,7 @@ ext2_cg_number_gdb_nometa(struct m_ext2fs *fs, int cg) EXT2_DESCS_PER_BLOCK(fs)); } -static unsigned long +static uint64_t ext2_cg_number_gdb_meta(struct m_ext2fs *fs, int cg) { unsigned long metagroup; @@ -784,7 +784,7 @@ ext2_cg_number_gdb_meta(struct m_ext2fs *fs, int cg) return (0); } -static unsigned long +uint64_t ext2_cg_number_gdb(struct m_ext2fs *fs, int cg) { unsigned long first_meta_bg, metagroup; Modified: stable/12/sys/fs/ext2fs/ext2_extern.h == --- stable/12/sys/fs/ext2fs/ext2_extern.h Mon Mar 18 11:44:53 2019 (r345264) +++ stable/12/sys/fs/ext2fs/ext2_extern.h Mon Mar 18 12:04:43 2019 (r345265) @@ -91,6 +91,7 @@ int ext2_dirrewrite(struct inode *, intext2_dirempty(struct inode *, ino_t, struct ucred *); intext2_checkpath(struct inode *, struct inode *, struct ucred *); intext2_cg_has_sb(struct m_ext2fs *fs, int cg); +uint64_t ext2_cg_number_gdb(struct m_ext2fs *fs, int cg); intext2_inactive(struct vop_inactive_args *); intext2_htree_add_entry(struct vnode *, struct ext2fs_direct_2 *, struct componentname *); @@ -104,6 +105,8 @@ int ext2_htree_lookup(struct inode *, const char *, in intext2_search_dirblock(struct inode *, void *, int *, const char *, int, int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *); uint32_t e2fs_gd_get_ndirs(struct ext2_gd *gd); +uint64_t e2fs_gd_get_b_bitmap(struct ext2_gd *); +uint64_t e2fs_gd_get_i_bitmap(struct ext2_gd *); uint64_t e2fs_gd_get_i_tables(struct ext2_gd *); void ext2_sb_csum_set_seed(struct m_ext2fs *); intext2_sb_csum_verify(struct m_ext2fs *); Modified: stable/12/sys/fs/ext2fs/ext2_vfsops.c == --- stable/12/sys/fs/ext2fs/ext2_vfsops.c Mon Mar 18 11:44:53 2019 (r345264) +++ stable/12/sys/fs/ext2fs/ext2_vfsops.c Mon Mar 18 12:04:43 2019 (r345265) @@ -98,7 +98,7 @@ VFS_SET(ext2fs_vfsops, ext2fs, 0); static int ext2_check_sb_compat(struct ext2fs *es, struct cdev *dev, int ronly); -static int compute_sb_data(struct vnode * devvp, +static int ext2_compute_sb_data(struct vnode * devvp, struct ext2fs * es, struct m_ext2fs * fs); static const char *ext2_opts[] = { "acls", "async", "noatime", "noclusterr", @@ -321,7 +321,7 @@ ext2_check_sb_compat(struct ext2fs *es, struct cdev *d } static e4fs_daddr_t -cg_location(struct m_ext2fs *fs, int number) +ext2_cg_location(struct m_ext2fs *fs, int number) { int cg, descpb, logical_sb, has_super = 0; @@ -350,82 +350,196 @@ cg_location(struct m_ext2fs *fs, int number) fs->e2fs->e2fs_first_dblock); } +static int +ext2_cg_validate(struct m_ext2fs *fs) +{ + uint64_t b_bitmap; + uint64_t i_bitmap; + uint64_t i_tables; + uint64_t first_block, last_block, last_cg_block; + struct ext2_gd *gd; + unsigned int i, cg_count; + + first_block = fs->e2fs->e2fs_first_dblock; + last_cg_block = ext2_cg_number_gdb(fs, 0); + cg_count = fs->e2fs_gcount; + + for (i = 0; i < fs->e2fs_gcount; i++) { + gd = >e2fs_gd[i]; + + if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG) || + i == fs->e2fs_gcount
svn commit: r345179 - head/sys/fs/ext2fs
Author: fsu Date: Fri Mar 15 11:49:46 2019 New Revision: 345179 URL: https://svnweb.freebsd.org/changeset/base/345179 Log: Remove unneeded mount point unlock function calls. The ext2_nodealloccg() function unlocks the mount point in case of successful node allocation. The additional unlocks are not required and should be removed. PR: 236452 Reported by: pho MFC after:3 days Modified: head/sys/fs/ext2fs/ext2_alloc.c Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Fri Mar 15 11:21:20 2019 (r345178) +++ head/sys/fs/ext2fs/ext2_alloc.c Fri Mar 15 11:49:46 2019 (r345179) @@ -412,23 +412,21 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred td = curthread; error = vfs_hash_get(ump->um_mountp, ino, LK_EXCLUSIVE, td, vpp, NULL, NULL); if (error || *vpp != NULL) { - EXT2_UNLOCK(ump); return (error); } ip = malloc(sizeof(struct inode), M_EXT2NODE, M_WAITOK | M_ZERO); if (ip == NULL) { - EXT2_UNLOCK(ump); return (ENOMEM); } /* Allocate a new vnode/inode. */ if ((error = getnewvnode("ext2fs", ump->um_mountp, _vnodeops, )) != 0) { free(ip, M_EXT2NODE); - EXT2_UNLOCK(ump); return (error); } + lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); vp->v_data = ip; ip->i_vnode = vp; ip->i_e2fs = fs = ump->um_e2fs; @@ -438,11 +436,9 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred ip->i_next_alloc_block = 0; ip->i_next_alloc_goal = 0; - lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); error = insmntque(vp, ump->um_mountp); if (error) { free(ip, M_EXT2NODE); - EXT2_UNLOCK(ump); return (error); } @@ -450,7 +446,6 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred if (error || *vpp != NULL) { *vpp = NULL; free(ip, M_EXT2NODE); - EXT2_UNLOCK(ump); return (error); } @@ -458,7 +453,6 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred vput(vp); *vpp = NULL; free(ip, M_EXT2NODE); - EXT2_UNLOCK(ump); return (error); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r344757 - head/sys/fs/ext2fs
Author: fsu Date: Mon Mar 4 11:33:49 2019 New Revision: 344757 URL: https://svnweb.freebsd.org/changeset/base/344757 Log: Fix double free in case of mount error. Reported by:Christopher Krah Reported as:FS-9-EXT3-2: Denial Of Service in nmount-5 (vm_fault_hold) Reviewed by:pfg MFC after: 1 week Differential Revision:https://reviews.freebsd.org/D19385 Modified: head/sys/fs/ext2fs/ext2_vfsops.c Modified: head/sys/fs/ext2fs/ext2_vfsops.c == --- head/sys/fs/ext2fs/ext2_vfsops.cMon Mar 4 11:27:47 2019 (r344756) +++ head/sys/fs/ext2fs/ext2_vfsops.cMon Mar 4 11:33:49 2019 (r344757) @@ -614,8 +614,12 @@ ext2_compute_sb_data(struct vnode *devvp, struct ext2f fsbtodb(fs, ext2_cg_location(fs, i)), fs->e2fs_bsize, NOCRED, ); if (error) { - free(fs->e2fs_contigdirs, M_EXT2MNT); - free(fs->e2fs_gd, M_EXT2MNT); + /* +* fs->e2fs_gd and fs->e2fs_contigdirs +* will be freed later by the caller, +* because this function could be called from +* MNT_UPDATE path. +*/ brelse(bp); return (error); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r344756 - head/sys/fs/ext2fs
Author: fsu Date: Mon Mar 4 11:27:47 2019 New Revision: 344756 URL: https://svnweb.freebsd.org/changeset/base/344756 Log: Do not read the on-disk inode in case of vnode allocation. Reported by:Christopher Krah Reported as:FS-6-EXT2-4: Denial Of Service in mkdir-0 (ext2_mkdir/vn_rdwr) Reviewed by:pfg MFC after: 1 week Differential Revision:https://reviews.freebsd.org/D19327 Modified: head/sys/fs/ext2fs/ext2_alloc.c Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Mon Mar 4 11:19:21 2019 (r344755) +++ head/sys/fs/ext2fs/ext2_alloc.c Mon Mar 4 11:27:47 2019 (r344756) @@ -373,10 +373,12 @@ int ext2_valloc(struct vnode *pvp, int mode, struct ucred *cred, struct vnode **vpp) { struct timespec ts; - struct inode *pip; struct m_ext2fs *fs; - struct inode *ip; struct ext2mount *ump; + struct inode *pip; + struct inode *ip; + struct vnode *vp; + struct thread *td; ino_t ino, ipref; int error, cg; @@ -404,33 +406,69 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred } ipref = cg * fs->e2fs->e2fs_ipg + 1; ino = (ino_t)ext2_hashalloc(pip, cg, (long)ipref, mode, ext2_nodealloccg); - if (ino == 0) goto noinodes; - error = VFS_VGET(pvp->v_mount, ino, LK_EXCLUSIVE, vpp); + + td = curthread; + error = vfs_hash_get(ump->um_mountp, ino, LK_EXCLUSIVE, td, vpp, NULL, NULL); + if (error || *vpp != NULL) { + EXT2_UNLOCK(ump); + return (error); + } + + ip = malloc(sizeof(struct inode), M_EXT2NODE, M_WAITOK | M_ZERO); + if (ip == NULL) { + EXT2_UNLOCK(ump); + return (ENOMEM); + } + + /* Allocate a new vnode/inode. */ + if ((error = getnewvnode("ext2fs", ump->um_mountp, _vnodeops, )) != 0) { + free(ip, M_EXT2NODE); + EXT2_UNLOCK(ump); + return (error); + } + + vp->v_data = ip; + ip->i_vnode = vp; + ip->i_e2fs = fs = ump->um_e2fs; + ip->i_ump = ump; + ip->i_number = ino; + ip->i_block_group = ino_to_cg(fs, ino); + ip->i_next_alloc_block = 0; + ip->i_next_alloc_goal = 0; + + lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); + error = insmntque(vp, ump->um_mountp); if (error) { - ext2_vfree(pvp, ino, mode); + free(ip, M_EXT2NODE); + EXT2_UNLOCK(ump); return (error); } - ip = VTOI(*vpp); - /* -* The question is whether using VGET was such good idea at all: -* Linux doesn't read the old inode in when it is allocating a -* new one. I will set at least i_size and i_blocks to zero. -*/ - ip->i_flag = 0; - ip->i_size = 0; - ip->i_blocks = 0; - ip->i_mode = 0; - ip->i_flags = 0; + error = vfs_hash_insert(vp, ino, LK_EXCLUSIVE, td, vpp, NULL, NULL); + if (error || *vpp != NULL) { + *vpp = NULL; + free(ip, M_EXT2NODE); + EXT2_UNLOCK(ump); + return (error); + } + + if ((error = ext2_vinit(ump->um_mountp, _fifoops, )) != 0) { + vput(vp); + *vpp = NULL; + free(ip, M_EXT2NODE); + EXT2_UNLOCK(ump); + return (error); + } + if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_EXTENTS) && (S_ISREG(mode) || S_ISDIR(mode))) ext4_ext_tree_init(ip); else memset(ip->i_data, 0, sizeof(ip->i_data)); - + /* * Set up a new generation number for this inode. * Avoid zero values. @@ -443,10 +481,10 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred ip->i_birthtime = ts.tv_sec; ip->i_birthnsec = ts.tv_nsec; -/* -printf("ext2_valloc: allocated inode %d\n", ino); -*/ + *vpp = vp; + return (0); + noinodes: EXT2_UNLOCK(ump); ext2_fserr(fs, cred->cr_uid, "out of inodes"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r344755 - head/sys/fs/ext2fs
Author: fsu Date: Mon Mar 4 11:19:21 2019 New Revision: 344755 URL: https://svnweb.freebsd.org/changeset/base/344755 Log: Fix integer overflow possibility. Reported by:Christopher Krah Reported as:FS-2-EXT2-1: Out-of-Bounds Write in nmount (ext2_vget) Reviewed by:pfg MFC after: 1 week Differential Revision:https://reviews.freebsd.org/D19326 Modified: head/sys/fs/ext2fs/ext2_vfsops.c Modified: head/sys/fs/ext2fs/ext2_vfsops.c == --- head/sys/fs/ext2fs/ext2_vfsops.cMon Mar 4 11:12:19 2019 (r344754) +++ head/sys/fs/ext2fs/ext2_vfsops.cMon Mar 4 11:19:21 2019 (r344755) @@ -1163,8 +1163,8 @@ ext2_vget(struct mount *mp, ino_t ino, int flags, stru struct buf *bp; struct vnode *vp; struct thread *td; - int i, error; - int used_blocks; + unsigned int i, used_blocks; + int error; td = curthread; error = vfs_hash_get(mp, ino, flags, td, vpp, NULL, NULL); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r344754 - head/sys/fs/ext2fs
Author: fsu Date: Mon Mar 4 11:12:19 2019 New Revision: 344754 URL: https://svnweb.freebsd.org/changeset/base/344754 Log: Do not panic if inode bitmap is corrupted. admbug: 804 Reported by:Ilja Van Sprundel Reviewed by:pfg MFC after: 1 week Differential Revision:https://reviews.freebsd.org/D19325 Modified: head/sys/fs/ext2fs/ext2_alloc.c Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Mon Mar 4 11:01:23 2019 (r344753) +++ head/sys/fs/ext2fs/ext2_alloc.c Mon Mar 4 11:12:19 2019 (r344754) @@ -1318,10 +1318,12 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipr start = 0; loc = memcchr([start], 0xff, len); if (loc == NULL) { - printf("cg = %d, ipref = %lld, fs = %s\n", + printf("ext2fs: inode bitmap corrupted: " + "cg = %d, ipref = %lld, fs = %s - run fsck\n", cg, (long long)ipref, fs->e2fs_fsmnt); - panic("ext2fs_nodealloccg: map corrupted"); - /* NOTREACHED */ + brelse(bp); + EXT2_LOCK(ump); + return (0); } } ipref = (loc - ibp) * NBBY + ffs(~*loc) - 1; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r344753 - head/sys/fs/ext2fs
Author: fsu Date: Mon Mar 4 11:01:23 2019 New Revision: 344753 URL: https://svnweb.freebsd.org/changeset/base/344753 Log: Validate block bitmaps. Reviewed by:pfg MFC after: 1 week Differential Revision:https://reviews.freebsd.org/D19324 Modified: head/sys/fs/ext2fs/ext2_alloc.c Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Mon Mar 4 10:55:01 2019 (r344752) +++ head/sys/fs/ext2fs/ext2_alloc.c Mon Mar 4 11:01:23 2019 (r344753) @@ -902,6 +902,52 @@ ext2_cg_block_bitmap_init(struct m_ext2fs *fs, int cg, return (0); } +static int +ext2_b_bitmap_validate(struct m_ext2fs *fs, struct buf *bp, int cg) +{ + struct ext2_gd *gd; + uint64_t group_first_block; + unsigned int offset, max_bit; + + if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG)) { + /* +* It is not possible to check block bitmap in case of this feature, +* because the inode and block bitmaps and inode table +* blocks may not be in the group at all. +* So, skip check in this case. +*/ + return (0); + } + + gd = >e2fs_gd[cg]; + max_bit = fs->e2fs_fpg; + group_first_block = ((uint64_t)cg) * fs->e2fs->e2fs_fpg + + fs->e2fs->e2fs_first_dblock; + + /* Check block bitmap block number */ + offset = e2fs_gd_get_b_bitmap(gd) - group_first_block; + if (offset >= max_bit || !isset(bp->b_data, offset)) { + printf("ext2fs: bad block bitmap, group %d\n", cg); + return (EINVAL); + } + + /* Check inode bitmap block number */ + offset = e2fs_gd_get_i_bitmap(gd) - group_first_block; + if (offset >= max_bit || !isset(bp->b_data, offset)) { + printf("ext2fs: bad inode bitmap, group %d\n", cg); + return (EINVAL); + } + + /* Check inode table */ + offset = e2fs_gd_get_i_tables(gd) - group_first_block; + if (offset >= max_bit || offset + fs->e2fs_itpg >= max_bit) { + printf("ext2fs: bad inode table, group %d\n", cg); + return (EINVAL); + } + + return (0); +} + /* * Determine whether a block can be allocated. * @@ -922,40 +968,37 @@ ext2_alloccg(struct inode *ip, int cg, daddr_t bpref, ump = ip->i_ump; if (e2fs_gd_get_nbfree(>e2fs_gd[cg]) == 0) return (0); + EXT2_UNLOCK(ump); error = bread(ip->i_devvp, fsbtodb(fs, e2fs_gd_get_b_bitmap(>e2fs_gd[cg])), (int)fs->e2fs_bsize, NOCRED, ); - if (error) { - brelse(bp); - EXT2_LOCK(ump); - return (0); - } + if (error) + goto fail; + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) { error = ext2_cg_block_bitmap_init(fs, cg, bp); - if (error) { - brelse(bp); - EXT2_LOCK(ump); - return (0); - } + if (error) + goto fail; + ext2_gd_b_bitmap_csum_set(fs, cg, bp); } error = ext2_gd_b_bitmap_csum_verify(fs, cg, bp); - if (error) { - brelse(bp); - EXT2_LOCK(ump); - return (0); - } - if (e2fs_gd_get_nbfree(>e2fs_gd[cg]) == 0) { - /* -* Another thread allocated the last block in this -* group while we were waiting for the buffer. -*/ - brelse(bp); - EXT2_LOCK(ump); - return (0); - } + if (error) + goto fail; + + error = ext2_b_bitmap_validate(fs,bp, cg); + if (error) + goto fail; + + /* +* Check, that another thread did not not allocate the last block in this +* group while we were waiting for the buffer. +*/ + if (e2fs_gd_get_nbfree(>e2fs_gd[cg]) == 0) + goto fail; + bbp = (char *)bp->b_data; if (dtog(fs, bpref) != cg) @@ -1028,11 +1071,9 @@ retry: goto retry; } bno = ext2_mapsearch(fs, bbp, bpref); - if (bno < 0) { - brelse(bp); - EXT2_LOCK(ump); - return (0); - } + if (bno < 0) + goto fail; + gotit: #ifdef INVARIANTS if (isset(bbp, bno)) { @@ -1052,6 +1093,11 @@ gotit: ext2_gd_b_bitmap_csum_set(fs, cg, bp); bdwrite(bp); return (((uint64_t)cg) * fs->e2fs->e2fs_fpg + fs->e2fs->e2fs_first_dblock + bno); + +fail: + brelse(bp); + EXT2_LOCK(ump); + return (0); } /*
svn commit: r344752 - head/sys/fs/ext2fs
Author: fsu Date: Mon Mar 4 10:55:01 2019 New Revision: 344752 URL: https://svnweb.freebsd.org/changeset/base/344752 Log: Add additional on-disk inode checks. Reviewed by:pfg MFC after: 1 week Differential Revision:https://reviews.freebsd.org/D19323 Modified: head/sys/fs/ext2fs/ext2_csum.c head/sys/fs/ext2fs/ext2_inode_cnv.c head/sys/fs/ext2fs/ext2_vfsops.c head/sys/fs/ext2fs/ext2fs.h Modified: head/sys/fs/ext2fs/ext2_csum.c == --- head/sys/fs/ext2fs/ext2_csum.c Mon Mar 4 10:42:25 2019 (r344751) +++ head/sys/fs/ext2fs/ext2_csum.c Mon Mar 4 10:55:01 2019 (r344752) @@ -629,6 +629,8 @@ ext2_ei_csum_verify(struct inode *ip, struct ext2fs_di if (!memcmp(ei, _zero, sizeof(struct ext2fs_dinode))) return (0); + printf("WARNING: Bad inode %ju csum - run fsck\n", ip->i_number); + return (EIO); } Modified: head/sys/fs/ext2fs/ext2_inode_cnv.c == --- head/sys/fs/ext2fs/ext2_inode_cnv.c Mon Mar 4 10:42:25 2019 (r344751) +++ head/sys/fs/ext2fs/ext2_inode_cnv.c Mon Mar 4 10:55:01 2019 (r344752) @@ -34,7 +34,6 @@ #include #include -#include #include #include #include @@ -92,8 +91,31 @@ ext2_print_inode(struct inode *in) int ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) { + struct m_ext2fs *fs = ip->i_e2fs; + if ((ip->i_number < EXT2_FIRST_INO(fs) && ip->i_number != EXT2_ROOTINO) || + (ip->i_number < EXT2_ROOTINO) || + (ip->i_number > fs->e2fs->e2fs_icount)) { + printf("ext2fs: bad inode number %ju\n", ip->i_number); + return (EINVAL); + } + + if (ip->i_number == EXT2_ROOTINO && ei->e2di_nlink == 0) { + printf("ext2fs: root inode unallocated\n"); + return (EINVAL); + } ip->i_nlink = ei->e2di_nlink; + + /* Check extra inode size */ + if (EXT2_INODE_SIZE(fs) > E2FS_REV0_INODE_SIZE) { + if (E2FS_REV0_INODE_SIZE + ei->e2di_extra_isize > + EXT2_INODE_SIZE(fs) || (ei->e2di_extra_isize & 3)) { + printf("ext2fs: bad extra inode size %u, inode size=%u\n", + ei->e2di_extra_isize, EXT2_INODE_SIZE(fs)); + return (EINVAL); + } + } + /* * Godmar thinks - if the link count is zero, then the inode is * unused - according to ext2 standards. Ufs marks this fact by Modified: head/sys/fs/ext2fs/ext2_vfsops.c == --- head/sys/fs/ext2fs/ext2_vfsops.cMon Mar 4 10:42:25 2019 (r344751) +++ head/sys/fs/ext2fs/ext2_vfsops.cMon Mar 4 10:55:01 2019 (r344752) @@ -773,11 +773,18 @@ loop: MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp); return (error); } - ext2_ei2i((struct ext2fs_dinode *)((char *)bp->b_data + + + error = ext2_ei2i((struct ext2fs_dinode *)((char *)bp->b_data + EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number)), ip); + brelse(bp); VOP_UNLOCK(vp, 0); vrele(vp); + + if (error) { + MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp); + return (error); + } } return (0); } @@ -1208,8 +1215,6 @@ ext2_vget(struct mount *mp, ino_t ino, int flags, stru error = ext2_ei2i((struct ext2fs_dinode *)((char *)bp->b_data + EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ino)), ip); if (error) { - printf("ext2fs: Bad inode %lu csum - run fsck\n", - (unsigned long)ino); brelse(bp); vput(vp); *vpp = NULL; Modified: head/sys/fs/ext2fs/ext2fs.h == --- head/sys/fs/ext2fs/ext2fs.h Mon Mar 4 10:42:25 2019(r344751) +++ head/sys/fs/ext2fs/ext2fs.h Mon Mar 4 10:55:01 2019(r344752) @@ -422,4 +422,11 @@ struct ext2_gd { EXT2F_INCOMPAT_64BIT) ? ((s)->e2fs_bsize / sizeof(struct ext2_gd)) : \ ((s)->e2fs_bsize / E2FS_REV0_GD_SIZE)) +/* + * Macro-instructions used to manage inodes + */ +#defineEXT2_FIRST_INO(s) ((EXT2_SB(s)->e2fs->e2fs_rev == E2FS_REV0) ? \ +EXT2_FIRSTINO : \ +EXT2_SB(s)->e2fs->e2fs_first_ino) + #endif /* !_FS_EXT2FS_EXT2FS_H_ */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r344751 - head/sys/fs/ext2fs
Author: fsu Date: Mon Mar 4 10:42:25 2019 New Revision: 344751 URL: https://svnweb.freebsd.org/changeset/base/344751 Log: Make superblock reading logic more strict. Add more on-disk superblock consistency checks to ext2_compute_sb_data() function. It should decrease the probability of mounting filesystems with corrupted superblock data. Reviewed by:pfg MFC after: 1 week Differential Revision:https://reviews.freebsd.org/D19322 Modified: head/sys/fs/ext2fs/ext2_alloc.c head/sys/fs/ext2fs/ext2_extern.h head/sys/fs/ext2fs/ext2_vfsops.c head/sys/fs/ext2fs/ext2fs.h Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Mon Mar 4 06:43:00 2019 (r344750) +++ head/sys/fs/ext2fs/ext2_alloc.c Mon Mar 4 10:42:25 2019 (r344751) @@ -457,7 +457,7 @@ noinodes: /* * 64-bit compatible getters and setters for struct ext2_gd from ext2fs.h */ -static uint64_t +uint64_t e2fs_gd_get_b_bitmap(struct ext2_gd *gd) { @@ -465,7 +465,7 @@ e2fs_gd_get_b_bitmap(struct ext2_gd *gd) gd->ext2bgd_b_bitmap); } -static uint64_t +uint64_t e2fs_gd_get_i_bitmap(struct ext2_gd *gd) { @@ -754,7 +754,7 @@ ext2_hashalloc(struct inode *ip, int cg, long pref, in return (0); } -static unsigned long +static uint64_t ext2_cg_number_gdb_nometa(struct m_ext2fs *fs, int cg) { @@ -768,7 +768,7 @@ ext2_cg_number_gdb_nometa(struct m_ext2fs *fs, int cg) EXT2_DESCS_PER_BLOCK(fs)); } -static unsigned long +static uint64_t ext2_cg_number_gdb_meta(struct m_ext2fs *fs, int cg) { unsigned long metagroup; @@ -784,7 +784,7 @@ ext2_cg_number_gdb_meta(struct m_ext2fs *fs, int cg) return (0); } -static unsigned long +uint64_t ext2_cg_number_gdb(struct m_ext2fs *fs, int cg) { unsigned long first_meta_bg, metagroup; Modified: head/sys/fs/ext2fs/ext2_extern.h == --- head/sys/fs/ext2fs/ext2_extern.hMon Mar 4 06:43:00 2019 (r344750) +++ head/sys/fs/ext2fs/ext2_extern.hMon Mar 4 10:42:25 2019 (r344751) @@ -91,6 +91,7 @@ int ext2_dirrewrite(struct inode *, intext2_dirempty(struct inode *, ino_t, struct ucred *); intext2_checkpath(struct inode *, struct inode *, struct ucred *); intext2_cg_has_sb(struct m_ext2fs *fs, int cg); +uint64_t ext2_cg_number_gdb(struct m_ext2fs *fs, int cg); intext2_inactive(struct vop_inactive_args *); intext2_htree_add_entry(struct vnode *, struct ext2fs_direct_2 *, struct componentname *); @@ -104,6 +105,8 @@ int ext2_htree_lookup(struct inode *, const char *, in intext2_search_dirblock(struct inode *, void *, int *, const char *, int, int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *); uint32_t e2fs_gd_get_ndirs(struct ext2_gd *gd); +uint64_t e2fs_gd_get_b_bitmap(struct ext2_gd *); +uint64_t e2fs_gd_get_i_bitmap(struct ext2_gd *); uint64_t e2fs_gd_get_i_tables(struct ext2_gd *); void ext2_sb_csum_set_seed(struct m_ext2fs *); intext2_sb_csum_verify(struct m_ext2fs *); Modified: head/sys/fs/ext2fs/ext2_vfsops.c == --- head/sys/fs/ext2fs/ext2_vfsops.cMon Mar 4 06:43:00 2019 (r344750) +++ head/sys/fs/ext2fs/ext2_vfsops.cMon Mar 4 10:42:25 2019 (r344751) @@ -98,7 +98,7 @@ VFS_SET(ext2fs_vfsops, ext2fs, 0); static int ext2_check_sb_compat(struct ext2fs *es, struct cdev *dev, int ronly); -static int compute_sb_data(struct vnode * devvp, +static int ext2_compute_sb_data(struct vnode * devvp, struct ext2fs * es, struct m_ext2fs * fs); static const char *ext2_opts[] = { "acls", "async", "noatime", "noclusterr", @@ -321,7 +321,7 @@ ext2_check_sb_compat(struct ext2fs *es, struct cdev *d } static e4fs_daddr_t -cg_location(struct m_ext2fs *fs, int number) +ext2_cg_location(struct m_ext2fs *fs, int number) { int cg, descpb, logical_sb, has_super = 0; @@ -350,82 +350,196 @@ cg_location(struct m_ext2fs *fs, int number) fs->e2fs->e2fs_first_dblock); } +static int +ext2_cg_validate(struct m_ext2fs *fs) +{ + uint64_t b_bitmap; + uint64_t i_bitmap; + uint64_t i_tables; + uint64_t first_block, last_block, last_cg_block; + struct ext2_gd *gd; + unsigned int i, cg_count; + + first_block = fs->e2fs->e2fs_first_dblock; + last_cg_block = ext2_cg_number_gdb(fs, 0); + cg_count = fs->e2fs_gcount; + + for (i = 0; i < fs->e2fs_gcount; i++) { + gd = >e2fs_gd[i]; + + if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG) || + i == fs->e2fs_gcount - 1) { + last_block = fs->e2fs_bcount - 1; +
svn commit: r342998 - in stable/12/sys: amd64/linux amd64/linux32 arm64/linux i386/linux
Author: fsu Date: Sun Jan 13 12:12:50 2019 New Revision: 342998 URL: https://svnweb.freebsd.org/changeset/base/342998 Log: MFC r342933: Fix errno values returned from DUMMY_XATTR linuxulator calls Reported by: we...@uni-mainz.de Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D18812 Modified: stable/12/sys/amd64/linux/linux_dummy.c stable/12/sys/amd64/linux32/linux32_dummy.c stable/12/sys/arm64/linux/linux_dummy.c stable/12/sys/i386/linux/linux_dummy.c Modified: stable/12/sys/amd64/linux/linux_dummy.c == --- stable/12/sys/amd64/linux/linux_dummy.c Sun Jan 13 08:49:55 2019 (r342997) +++ stable/12/sys/amd64/linux/linux_dummy.c Sun Jan 13 12:12:50 2019 (r342998) @@ -162,7 +162,7 @@ linux_ ## s ## xattr( \ struct thread *td, struct linux_ ## s ## xattr_args *arg) \ { \ \ - return (ENOATTR); \ + return (EOPNOTSUPP);\ } DUMMY_XATTR(set); DUMMY_XATTR(lset); Modified: stable/12/sys/amd64/linux32/linux32_dummy.c == --- stable/12/sys/amd64/linux32/linux32_dummy.c Sun Jan 13 08:49:55 2019 (r342997) +++ stable/12/sys/amd64/linux32/linux32_dummy.c Sun Jan 13 12:12:50 2019 (r342998) @@ -168,7 +168,7 @@ linux_ ## s ## xattr( \ struct thread *td, struct linux_ ## s ## xattr_args *arg) \ { \ \ - return (ENOATTR); \ + return (EOPNOTSUPP);\ } DUMMY_XATTR(set); DUMMY_XATTR(lset); Modified: stable/12/sys/arm64/linux/linux_dummy.c == --- stable/12/sys/arm64/linux/linux_dummy.c Sun Jan 13 08:49:55 2019 (r342997) +++ stable/12/sys/arm64/linux/linux_dummy.c Sun Jan 13 12:12:50 2019 (r342998) @@ -161,7 +161,7 @@ linux_ ## s ## xattr( \ struct thread *td, struct linux_ ## s ## xattr_args *arg) \ { \ \ - return (ENOATTR); \ + return (EOPNOTSUPP);\ } DUMMY_XATTR(set); DUMMY_XATTR(lset); Modified: stable/12/sys/i386/linux/linux_dummy.c == --- stable/12/sys/i386/linux/linux_dummy.c Sun Jan 13 08:49:55 2019 (r342997) +++ stable/12/sys/i386/linux/linux_dummy.c Sun Jan 13 12:12:50 2019 (r342998) @@ -164,7 +164,7 @@ linux_ ## s ## xattr( \ struct thread *td, struct linux_ ## s ## xattr_args *arg) \ { \ \ - return (ENOATTR); \ + return (EOPNOTSUPP);\ } DUMMY_XATTR(set); DUMMY_XATTR(lset); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r342999 - in stable/11/sys: amd64/linux amd64/linux32 i386/linux
Author: fsu Date: Sun Jan 13 12:13:08 2019 New Revision: 342999 URL: https://svnweb.freebsd.org/changeset/base/342999 Log: MFC r342933: Fix errno values returned from DUMMY_XATTR linuxulator calls Reported by: we...@uni-mainz.de Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D18812 Modified: stable/11/sys/amd64/linux/linux_dummy.c stable/11/sys/amd64/linux32/linux32_dummy.c stable/11/sys/i386/linux/linux_dummy.c Modified: stable/11/sys/amd64/linux/linux_dummy.c == --- stable/11/sys/amd64/linux/linux_dummy.c Sun Jan 13 12:12:50 2019 (r342998) +++ stable/11/sys/amd64/linux/linux_dummy.c Sun Jan 13 12:13:08 2019 (r342999) @@ -164,7 +164,7 @@ linux_ ## s ## xattr( \ struct thread *td, struct linux_ ## s ## xattr_args *arg) \ { \ \ - return (ENOATTR); \ + return (EOPNOTSUPP);\ } DUMMY_XATTR(set); DUMMY_XATTR(lset); Modified: stable/11/sys/amd64/linux32/linux32_dummy.c == --- stable/11/sys/amd64/linux32/linux32_dummy.c Sun Jan 13 12:12:50 2019 (r342998) +++ stable/11/sys/amd64/linux32/linux32_dummy.c Sun Jan 13 12:13:08 2019 (r342999) @@ -170,7 +170,7 @@ linux_ ## s ## xattr( \ struct thread *td, struct linux_ ## s ## xattr_args *arg) \ { \ \ - return (ENOATTR); \ + return (EOPNOTSUPP);\ } DUMMY_XATTR(set); DUMMY_XATTR(lset); Modified: stable/11/sys/i386/linux/linux_dummy.c == --- stable/11/sys/i386/linux/linux_dummy.c Sun Jan 13 12:12:50 2019 (r342998) +++ stable/11/sys/i386/linux/linux_dummy.c Sun Jan 13 12:13:08 2019 (r342999) @@ -166,7 +166,7 @@ linux_ ## s ## xattr( \ struct thread *td, struct linux_ ## s ## xattr_args *arg) \ { \ \ - return (ENOATTR); \ + return (EOPNOTSUPP);\ } DUMMY_XATTR(set); DUMMY_XATTR(lset); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r342933 - in head/sys: amd64/linux amd64/linux32 arm64/linux i386/linux
Author: fsu Date: Fri Jan 11 07:58:25 2019 New Revision: 342933 URL: https://svnweb.freebsd.org/changeset/base/342933 Log: Fix errno values returned from DUMMY_XATTR linuxulator calls Reported by: we...@uni-mainz.de Reviewed by: markj MFC after: 1 day Differential Revision: https://reviews.freebsd.org/D18812 Modified: head/sys/amd64/linux/linux_dummy.c head/sys/amd64/linux32/linux32_dummy.c head/sys/arm64/linux/linux_dummy.c head/sys/i386/linux/linux_dummy.c Modified: head/sys/amd64/linux/linux_dummy.c == --- head/sys/amd64/linux/linux_dummy.c Fri Jan 11 05:41:46 2019 (r342932) +++ head/sys/amd64/linux/linux_dummy.c Fri Jan 11 07:58:25 2019 (r342933) @@ -162,7 +162,7 @@ linux_ ## s ## xattr( \ struct thread *td, struct linux_ ## s ## xattr_args *arg) \ { \ \ - return (ENOATTR); \ + return (EOPNOTSUPP);\ } DUMMY_XATTR(set); DUMMY_XATTR(lset); Modified: head/sys/amd64/linux32/linux32_dummy.c == --- head/sys/amd64/linux32/linux32_dummy.c Fri Jan 11 05:41:46 2019 (r342932) +++ head/sys/amd64/linux32/linux32_dummy.c Fri Jan 11 07:58:25 2019 (r342933) @@ -168,7 +168,7 @@ linux_ ## s ## xattr( \ struct thread *td, struct linux_ ## s ## xattr_args *arg) \ { \ \ - return (ENOATTR); \ + return (EOPNOTSUPP);\ } DUMMY_XATTR(set); DUMMY_XATTR(lset); Modified: head/sys/arm64/linux/linux_dummy.c == --- head/sys/arm64/linux/linux_dummy.c Fri Jan 11 05:41:46 2019 (r342932) +++ head/sys/arm64/linux/linux_dummy.c Fri Jan 11 07:58:25 2019 (r342933) @@ -161,7 +161,7 @@ linux_ ## s ## xattr( \ struct thread *td, struct linux_ ## s ## xattr_args *arg) \ { \ \ - return (ENOATTR); \ + return (EOPNOTSUPP);\ } DUMMY_XATTR(set); DUMMY_XATTR(lset); Modified: head/sys/i386/linux/linux_dummy.c == --- head/sys/i386/linux/linux_dummy.c Fri Jan 11 05:41:46 2019 (r342932) +++ head/sys/i386/linux/linux_dummy.c Fri Jan 11 07:58:25 2019 (r342933) @@ -164,7 +164,7 @@ linux_ ## s ## xattr( \ struct thread *td, struct linux_ ## s ## xattr_args *arg) \ { \ \ - return (ENOATTR); \ + return (EOPNOTSUPP);\ } DUMMY_XATTR(set); DUMMY_XATTR(lset); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r338153 - head/sys/fs/fuse
Author: fsu Date: Tue Aug 21 18:50:29 2018 New Revision: 338153 URL: https://svnweb.freebsd.org/changeset/base/338153 Log: FUSE extattrs: fix issue when neither uio nor size were not passed to VOP_* (cosmetic only). Reviewed by:cem, pfg MFC after: 2 weeks Differential Revision:https://reviews.freebsd.org/D13737 Modified: head/sys/fs/fuse/fuse_vnops.c Modified: head/sys/fs/fuse/fuse_vnops.c == --- head/sys/fs/fuse/fuse_vnops.c Tue Aug 21 18:39:47 2018 (r338152) +++ head/sys/fs/fuse/fuse_vnops.c Tue Aug 21 18:50:29 2018 (r338153) @@ -2012,21 +2012,21 @@ fuse_vnop_getextattr(struct vop_getextattr_args *ap) { struct vnode *vp = ap->a_vp; struct uio *uio = ap->a_uio; - struct fuse_dispatcher fdi = {0}; + struct fuse_dispatcher fdi; struct fuse_getxattr_in *get_xattr_in; struct fuse_getxattr_out *get_xattr_out; struct mount *mp = vnode_mount(vp); - char *prefix; - size_t len; - char *attr_str; struct thread *td = ap->a_td; struct ucred *cred = ap->a_cred; - int err = 0; + char *prefix; + char *attr_str; + size_t len; + int err; fuse_trace_printf_vnop(); if (fuse_isdeadfs(vp)) - return ENXIO; + return (ENXIO); /* Default to looking for user attributes. */ if (ap->a_attrnamespace == EXTATTR_NAMESPACE_SYSTEM) @@ -2057,7 +2057,6 @@ fuse_vnop_getextattr(struct vop_getextattr_args *ap) ap->a_name); err = fdisp_wait_answ(); - if (err != 0) { if (err == ENOSYS) fsess_set_notimpl(mp, FUSE_GETXATTR); @@ -2094,20 +2093,20 @@ fuse_vnop_setextattr(struct vop_setextattr_args *ap) { struct vnode *vp = ap->a_vp; struct uio *uio = ap->a_uio; - struct fuse_dispatcher fdi = {0}; + struct fuse_dispatcher fdi; struct fuse_setxattr_in *set_xattr_in; struct mount *mp = vnode_mount(vp); + struct thread *td = ap->a_td; + struct ucred *cred = ap->a_cred; char *prefix; size_t len; char *attr_str; - struct thread *td = ap->a_td; - struct ucred *cred = ap->a_cred; - int err = 0; - + int err; + fuse_trace_printf_vnop(); if (fuse_isdeadfs(vp)) - return ENXIO; + return (ENXIO); /* Default to looking for user attributes. */ if (ap->a_attrnamespace == EXTATTR_NAMESPACE_SYSTEM) @@ -2220,10 +2219,12 @@ fuse_vnop_listextattr(struct vop_listextattr_args *ap) { struct vnode *vp = ap->a_vp; struct uio *uio = ap->a_uio; - struct fuse_dispatcher fdi = {0}; + struct fuse_dispatcher fdi; struct fuse_listxattr_in *list_xattr_in; struct fuse_listxattr_out *list_xattr_out; struct mount *mp = vnode_mount(vp); + struct thread *td = ap->a_td; + struct ucred *cred = ap->a_cred; size_t len; char *prefix; char *attr_str; @@ -2231,14 +2232,12 @@ fuse_vnop_listextattr(struct vop_listextattr_args *ap) char *linux_list; int bsd_list_len; int linux_list_len; - struct thread *td = ap->a_td; - struct ucred *cred = ap->a_cred; - int err = 0; + int err; fuse_trace_printf_vnop(); if (fuse_isdeadfs(vp)) - return ENXIO; + return (ENXIO); /* * Add space for a NUL and the period separator if enabled. @@ -2332,19 +2331,19 @@ static int fuse_vnop_deleteextattr(struct vop_deleteextattr_args *ap) { struct vnode *vp = ap->a_vp; - struct fuse_dispatcher fdi = {0}; + struct fuse_dispatcher fdi; struct mount *mp = vnode_mount(vp); + struct thread *td = ap->a_td; + struct ucred *cred = ap->a_cred; char *prefix; size_t len; char *attr_str; - struct thread *td = ap->a_td; - struct ucred *cred = ap->a_cred; int err; fuse_trace_printf_vnop(); if (fuse_isdeadfs(vp)) - return ENXIO; + return (ENXIO); /* Default to looking for user attributes. */ if (ap->a_attrnamespace == EXTATTR_NAMESPACE_SYSTEM) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r338151 - head/sys/fs/ext2fs
Author: fsu Date: Tue Aug 21 18:39:29 2018 New Revision: 338151 URL: https://svnweb.freebsd.org/changeset/base/338151 Log: Change unused inodes counters behavior in the cylinder groups. Make it more close to native ext4 implementation to avoid fsck errors. Modified: head/sys/fs/ext2fs/ext2_alloc.c Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Tue Aug 21 18:39:02 2018 (r338150) +++ head/sys/fs/ext2fs/ext2_alloc.c Tue Aug 21 18:39:29 2018 (r338151) @@ -1210,7 +1210,7 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipr struct m_ext2fs *fs; struct buf *bp; struct ext2mount *ump; - int error, start, len; + int error, start, len, ifree; char *ibp, *loc; ipref--;/* to avoid a lot of (ipref -1) */ @@ -1285,9 +1285,12 @@ gotit: e2fs_gd_set_nifree(>e2fs_gd[cg], e2fs_gd_get_nifree(>e2fs_gd[cg]) - 1); if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || - EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) - e2fs_gd_set_i_unused(>e2fs_gd[cg], - e2fs_gd_get_i_unused(>e2fs_gd[cg]) - 1); + EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) { + ifree = fs->e2fs->e2fs_ipg - e2fs_gd_get_i_unused(>e2fs_gd[cg]); + if (ipref + 1 > ifree) + e2fs_gd_set_i_unused(>e2fs_gd[cg], + fs->e2fs->e2fs_ipg - (ipref + 1)); + } fs->e2fs->e2fs_ficount--; fs->e2fs_fmod = 1; if ((mode & IFMT) == IFDIR) { @@ -1391,10 +1394,6 @@ ext2_vfree(struct vnode *pvp, ino_t ino, int mode) fs->e2fs->e2fs_ficount++; e2fs_gd_set_nifree(>e2fs_gd[cg], e2fs_gd_get_nifree(>e2fs_gd[cg]) + 1); - if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || - EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) - e2fs_gd_set_i_unused(>e2fs_gd[cg], - e2fs_gd_get_i_unused(>e2fs_gd[cg]) + 1); if ((mode & IFMT) == IFDIR) { e2fs_gd_set_ndirs(>e2fs_gd[cg], e2fs_gd_get_ndirs(>e2fs_gd[cg]) - 1); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r338152 - head/sys/fs/fuse
Author: fsu Date: Tue Aug 21 18:39:47 2018 New Revision: 338152 URL: https://svnweb.freebsd.org/changeset/base/338152 Log: FUSE extattrs: fix issue when neither uio nor size were not passed to VOP_*. The requested size was returned incorrectly in case uio == NULL from listextattr because the nameprefix/name conversion was not applied. Also, make a_size/uio returning logic more unified with other filesystems. Reviewed by:cem, pfg MFC after: 2 weeks Differential Revision:https://reviews.freebsd.org/D13528 Modified: head/sys/fs/fuse/fuse_kernel.h head/sys/fs/fuse/fuse_vnops.c Modified: head/sys/fs/fuse/fuse_kernel.h == --- head/sys/fs/fuse/fuse_kernel.h Tue Aug 21 18:39:29 2018 (r338151) +++ head/sys/fs/fuse/fuse_kernel.h Tue Aug 21 18:39:47 2018 (r338152) @@ -282,11 +282,16 @@ struct fuse_fsync_in { __u32 padding; }; -struct fuse_setxattr_in { +struct fuse_listxattr_in { __u32 size; __u32 flags; }; +struct fuse_listxattr_out { + __u32 size; + __u32 flags; +}; + struct fuse_getxattr_in { __u32 size; __u32 padding; @@ -295,6 +300,11 @@ struct fuse_getxattr_in { struct fuse_getxattr_out { __u32 size; __u32 padding; +}; + +struct fuse_setxattr_in { + __u32 size; + __u32 flags; }; struct fuse_lk_in { Modified: head/sys/fs/fuse/fuse_vnops.c == --- head/sys/fs/fuse/fuse_vnops.c Tue Aug 21 18:39:29 2018 (r338151) +++ head/sys/fs/fuse/fuse_vnops.c Tue Aug 21 18:39:47 2018 (r338152) @@ -2047,7 +2047,7 @@ fuse_vnop_getextattr(struct vop_getextattr_args *ap) * fuse_getxattr_out. If we pass in a non-zero size, we get back * that much data, without the struct fuse_getxattr_out header. */ - if (ap->a_size != NULL) + if (uio == NULL) get_xattr_in->size = 0; else get_xattr_in->size = uio->uio_resid; @@ -2065,25 +2065,13 @@ fuse_vnop_getextattr(struct vop_getextattr_args *ap) goto out; } - /* -* If we get to this point (i.e. no error), we should have a valid -* answer of some sort. i.e. non-zero iosize and a valid pointer. -*/ - if ((fdi.answ == NULL) || (fdi.iosize == 0)) { - debug_printf("getxattr: err = 0, but answ = %p, iosize = %zu\n", - fdi.answ, fdi.iosize); - err = EINVAL; - goto out; - } get_xattr_out = fdi.answ; - if (ap->a_size != NULL) { + if (ap->a_size != NULL) *ap->a_size = get_xattr_out->size; - } else if (fdi.iosize > 0) { + + if (uio != NULL) err = uiomove(fdi.answ, fdi.iosize, uio); - } else { - err = EINVAL; - } out: fdisp_destroy(); @@ -2233,14 +2221,16 @@ fuse_vnop_listextattr(struct vop_listextattr_args *ap) struct vnode *vp = ap->a_vp; struct uio *uio = ap->a_uio; struct fuse_dispatcher fdi = {0}; - struct fuse_getxattr_in *get_xattr_in; - struct fuse_getxattr_out *get_xattr_out; + struct fuse_listxattr_in *list_xattr_in; + struct fuse_listxattr_out *list_xattr_out; struct mount *mp = vnode_mount(vp); size_t len; char *prefix; char *attr_str; char *bsd_list = NULL; + char *linux_list; int bsd_list_len; + int linux_list_len; struct thread *td = ap->a_td; struct ucred *cred = ap->a_cred; int err = 0; @@ -2261,17 +2251,15 @@ fuse_vnop_listextattr(struct vop_listextattr_args *ap) len = strlen(prefix) + sizeof(extattr_namespace_separator) + 1; - fdisp_init(, sizeof(*get_xattr_in) + len); + fdisp_init(, sizeof(*list_xattr_in) + len); fdisp_make_vp(, FUSE_LISTXATTR, vp, td, cred); - get_xattr_in = fdi.indata; - if (ap->a_size != NULL) - get_xattr_in->size = 0; - else - get_xattr_in->size = uio->uio_resid + sizeof(*get_xattr_out); - - - attr_str = (char *)fdi.indata + sizeof(*get_xattr_in); + /* +* Retrieve Linux / FUSE compatible list size. +*/ + list_xattr_in = fdi.indata; + list_xattr_in->size = 0; + attr_str = (char *)fdi.indata + sizeof(*list_xattr_in); snprintf(attr_str, len, "%s%c", prefix, extattr_namespace_separator); err = fdisp_wait_answ(); @@ -2282,32 +2270,47 @@ fuse_vnop_listextattr(struct vop_listextattr_args *ap) goto out; } - if ((fdi.answ == NULL) || (fdi.iosize == 0)) { - err = EINVAL; + list_xattr_out = fdi.answ; + linux_list_len = list_xattr_out->size; + if (linux_list_len == 0) { +
svn commit: r338150 - head/sys/fs/ext2fs
Author: fsu Date: Tue Aug 21 18:39:02 2018 New Revision: 338150 URL: https://svnweb.freebsd.org/changeset/base/338150 Log: Fix directory blocks checksum updating logic. Count dirent tail in the searchslot logic in case of directory block search. Add htree root csum update function call in case of rename. Modified: head/sys/fs/ext2fs/ext2_csum.c head/sys/fs/ext2fs/ext2_extern.h head/sys/fs/ext2fs/ext2_lookup.c head/sys/fs/ext2fs/ext2_vnops.c Modified: head/sys/fs/ext2fs/ext2_csum.c == --- head/sys/fs/ext2fs/ext2_csum.c Tue Aug 21 18:22:12 2018 (r338149) +++ head/sys/fs/ext2fs/ext2_csum.c Tue Aug 21 18:39:02 2018 (r338150) @@ -162,12 +162,32 @@ ext2_init_dirent_tail(struct ext2fs_direct_tail *tp) tp->e2dt_reserved_ft = EXT2_FT_DIR_CSUM; } +int +ext2_is_dirent_tail(struct inode *ip, struct ext2fs_direct_2 *ep) +{ + struct m_ext2fs *fs; + struct ext2fs_direct_tail *tp; + + fs = ip->i_e2fs; + + if (!EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) + return (0); + + tp = (struct ext2fs_direct_tail *)ep; + if (tp->e2dt_reserved_zero1 == 0 && + tp->e2dt_rec_len == sizeof(struct ext2fs_direct_tail) && + tp->e2dt_reserved_zero2 == 0 && + tp->e2dt_reserved_ft == EXT2_FT_DIR_CSUM) + return (1); + + return (0); +} + struct ext2fs_direct_tail * ext2_dirent_get_tail(struct inode *ip, struct ext2fs_direct_2 *ep) { struct ext2fs_direct_2 *dep; void *top; - struct ext2fs_direct_tail *tp; unsigned int rec_len; dep = ep; @@ -184,14 +204,10 @@ ext2_dirent_get_tail(struct inode *ip, struct ext2fs_d if (dep != top) return (NULL); - tp = (struct ext2fs_direct_tail *)dep; - if (tp->e2dt_reserved_zero1 || - tp->e2dt_rec_len != sizeof(struct ext2fs_direct_tail) || - tp->e2dt_reserved_zero2 || - tp->e2dt_reserved_ft != EXT2_FT_DIR_CSUM) - return (NULL); + if (ext2_is_dirent_tail(ip, dep)) + return ((struct ext2fs_direct_tail *)dep); - return (tp); + return (NULL); } static uint32_t Modified: head/sys/fs/ext2fs/ext2_extern.h == --- head/sys/fs/ext2fs/ext2_extern.hTue Aug 21 18:22:12 2018 (r338149) +++ head/sys/fs/ext2fs/ext2_extern.hTue Aug 21 18:39:02 2018 (r338150) @@ -120,6 +120,7 @@ int ext2_dx_csum_verify(struct inode *ip, struct ext2f intext2_extent_blk_csum_verify(struct inode *, void *); void ext2_extent_blk_csum_set(struct inode *, void *); void ext2_init_dirent_tail(struct ext2fs_direct_tail *); +intext2_is_dirent_tail(struct inode *, struct ext2fs_direct_2 *); intext2_gd_i_bitmap_csum_verify(struct m_ext2fs *, int, struct buf *); void ext2_gd_i_bitmap_csum_set(struct m_ext2fs *, int, struct buf *); intext2_gd_b_bitmap_csum_verify(struct m_ext2fs *, int, struct buf *); Modified: head/sys/fs/ext2fs/ext2_lookup.c == --- head/sys/fs/ext2fs/ext2_lookup.cTue Aug 21 18:22:12 2018 (r338149) +++ head/sys/fs/ext2fs/ext2_lookup.cTue Aug 21 18:39:02 2018 (r338150) @@ -429,16 +429,13 @@ searchloop: error = ext2_blkatoff(vdp, (off_t)i_offset, NULL, ); if (error != 0) return (error); + entryoffsetinblock = 0; - /* -* If still looking for a slot, and at a DIRBLKSIZE -* boundary, have to start looking for free space again. -*/ - if (ss.slotstatus == NONE && - (entryoffsetinblock & (DIRBLKSIZ - 1)) == 0) { + if (ss.slotstatus == NONE) { ss.slotoffset = -1; ss.slotfreespace = 0; } + error = ext2_search_dirblock(dp, bp->b_data, _found, cnp->cn_nameptr, cnp->cn_namelen, , _offset, , @@ -719,9 +716,7 @@ ext2_search_dirblock(struct inode *ip, void *data, int vdp = ITOV(ip); ep = (struct ext2fs_direct_2 *)((char *)data + offset); - top = (struct ext2fs_direct_2 *)((char *)data + - bsize - EXT2_DIR_REC_LEN(0)); - + top = (struct ext2fs_direct_2 *)((char *)data + bsize); while (ep < top) { /* * Full validation checks are slow, so we only check @@ -751,6 +746,8 @@ ext2_search_dirblock(struct inode *ip, void *data, int if (ep->e2d_ino != 0) size -= EXT2_DIR_REC_LEN(ep->e2d_namlen); + else if (ext2_is_dirent_tail(ip, ep)) + size -=
svn commit: r337454 - head/sys/fs/ext2fs
Author: fsu Date: Wed Aug 8 12:08:46 2018 New Revision: 337454 URL: https://svnweb.freebsd.org/changeset/base/337454 Log: Split the dir_index and dir_nlink features. Do not allow to create more that EXT4_LINK_MAX links to directory in case if the dir_nlink is not set, like it is done in the fresh e2fsprogs updates. MFC after: 3 months Modified: head/sys/fs/ext2fs/ext2_dir.h head/sys/fs/ext2fs/ext2_vnops.c Modified: head/sys/fs/ext2fs/ext2_dir.h == --- head/sys/fs/ext2fs/ext2_dir.h Wed Aug 8 12:07:45 2018 (r337453) +++ head/sys/fs/ext2fs/ext2_dir.h Wed Aug 8 12:08:46 2018 (r337454) @@ -89,7 +89,6 @@ struct ext2fs_direct_tail { /* * Maximal count of links to a file */ -#defineEXT2_LINK_MAX 32000 #defineEXT4_LINK_MAX 65000 /* Modified: head/sys/fs/ext2fs/ext2_vnops.c == --- head/sys/fs/ext2fs/ext2_vnops.c Wed Aug 8 12:07:45 2018 (r337453) +++ head/sys/fs/ext2fs/ext2_vnops.c Wed Aug 8 12:08:46 2018 (r337454) @@ -675,19 +675,6 @@ out: return (error); } -static unsigned short -ext2_max_nlink(struct inode *ip) -{ - struct m_ext2fs *fs; - - fs = ip->i_e2fs; - - if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_DIR_NLINK)) - return (EXT4_LINK_MAX); - else - return (EXT2_LINK_MAX); -} - /* * link vnode call */ @@ -705,7 +692,7 @@ ext2_link(struct vop_link_args *ap) panic("ext2_link: no name"); #endif ip = VTOI(vp); - if ((nlink_t)ip->i_nlink >= ext2_max_nlink(ip)) { + if ((nlink_t)ip->i_nlink >= EXT4_LINK_MAX) { error = EMLINK; goto out; } @@ -732,10 +719,12 @@ ext2_inc_nlink(struct inode *ip) ip->i_nlink++; - if (ext2_htree_has_idx(ip) && ip->i_nlink > 1) { - if (ip->i_nlink >= ext2_max_nlink(ip) || ip->i_nlink == 2) + if (S_ISDIR(ip->i_mode) && + EXT2_HAS_RO_COMPAT_FEATURE(ip->i_e2fs, EXT2F_ROCOMPAT_DIR_NLINK) && + ip->i_nlink > 1) { + if (ip->i_nlink >= EXT4_LINK_MAX || ip->i_nlink == 2) ip->i_nlink = 1; - } else if (ip->i_nlink > ext2_max_nlink(ip)) { + } else if (ip->i_nlink > EXT4_LINK_MAX) { ip->i_nlink--; return (EMLINK); } @@ -833,7 +822,8 @@ abortit: goto abortit; dp = VTOI(fdvp); ip = VTOI(fvp); - if (ip->i_nlink >= ext2_max_nlink(ip) && !ext2_htree_has_idx(ip)) { + if (ip->i_nlink >= EXT4_LINK_MAX && + !EXT2_HAS_RO_COMPAT_FEATURE(ip->i_e2fs, EXT2F_ROCOMPAT_DIR_NLINK)) { VOP_UNLOCK(fvp, 0); error = EMLINK; goto abortit; @@ -1304,8 +1294,8 @@ ext2_mkdir(struct vop_mkdir_args *ap) panic("ext2_mkdir: no name"); #endif dp = VTOI(dvp); - if ((nlink_t)dp->i_nlink >= ext2_max_nlink(dp) && - !ext2_htree_has_idx(dp)) { + if ((nlink_t)dp->i_nlink >= EXT4_LINK_MAX && + !EXT2_HAS_RO_COMPAT_FEATURE(dp->i_e2fs, EXT2F_ROCOMPAT_DIR_NLINK)) { error = EMLINK; goto out; } @@ -1655,10 +1645,11 @@ ext2_pathconf(struct vop_pathconf_args *ap) switch (ap->a_name) { case _PC_LINK_MAX: - if (ext2_htree_has_idx(VTOI(ap->a_vp))) + if (EXT2_HAS_RO_COMPAT_FEATURE(VTOI(ap->a_vp)->i_e2fs, + EXT2F_ROCOMPAT_DIR_NLINK)) *ap->a_retval = INT_MAX; else - *ap->a_retval = ext2_max_nlink(VTOI(ap->a_vp)); + *ap->a_retval = EXT4_LINK_MAX; break; case _PC_NAME_MAX: *ap->a_retval = NAME_MAX; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r337453 - head/sys/fs/ext2fs
Author: fsu Date: Wed Aug 8 12:07:45 2018 New Revision: 337453 URL: https://svnweb.freebsd.org/changeset/base/337453 Log: Fix directory blocks checksum updating logic. The checksum updating functions were not called in case of dir index inode splitting and in case of dir entry removing, when the entry was first in the block. Fix and move the dir entry adding logic when i_count == 0 to new function. MFC after: 3 months Modified: head/sys/fs/ext2fs/ext2_htree.c head/sys/fs/ext2fs/ext2_lookup.c Modified: head/sys/fs/ext2fs/ext2_htree.c == --- head/sys/fs/ext2fs/ext2_htree.c Wed Aug 8 07:58:29 2018 (r337452) +++ head/sys/fs/ext2fs/ext2_htree.c Wed Aug 8 12:07:45 2018 (r337453) @@ -800,7 +800,7 @@ ext2_htree_add_entry(struct vnode *dvp, struct ext2fs_ cursize = roundup(ip->i_size, blksize); dirsize = cursize + blksize; blknum = dirsize / blksize - 1; - + ext2_dx_csum_set(ip, (struct ext2fs_direct_2 *)newidxblock); error = ext2_htree_append_block(dvp, newidxblock, cnp, blksize); if (error) Modified: head/sys/fs/ext2fs/ext2_lookup.c == --- head/sys/fs/ext2fs/ext2_lookup.cWed Aug 8 07:58:29 2018 (r337452) +++ head/sys/fs/ext2fs/ext2_lookup.cWed Aug 8 12:07:45 2018 (r337453) @@ -859,6 +859,68 @@ ext2_dirbadentry(struct vnode *dp, struct ext2fs_direc } /* + * Insert an entry into the fresh directory block. + * Initialize entry tail if the metadata_csum feature is turned on. + */ +static int +ext2_add_first_entry(struct vnode *dvp, struct ext2fs_direct_2 *entry, +struct componentname *cnp) +{ + struct inode *dp; + struct iovec aiov; + struct uio auio; + char* buf = NULL; + int dirblksize, error; + + dp = VTOI(dvp); + dirblksize = dp->i_e2fs->e2fs_bsize; + + if (dp->i_offset & (dirblksize - 1)) + panic("ext2_add_first_entry: bad directory offset"); + + if (EXT2_HAS_RO_COMPAT_FEATURE(dp->i_e2fs, + EXT2F_ROCOMPAT_METADATA_CKSUM)) { + entry->e2d_reclen = dirblksize - sizeof(struct ext2fs_direct_tail); + buf = malloc(dirblksize, M_TEMP, M_WAITOK); + if (!buf) { + error = ENOMEM; + goto out; + } + memcpy(buf, entry, EXT2_DIR_REC_LEN(entry->e2d_namlen)); + ext2_init_dirent_tail(EXT2_DIRENT_TAIL(buf, dirblksize)); + ext2_dirent_csum_set(dp, (struct ext2fs_direct_2 *)buf); + + auio.uio_offset = dp->i_offset; + auio.uio_resid = dirblksize; + aiov.iov_len = auio.uio_resid; + aiov.iov_base = (caddr_t)buf; + } else { + entry->e2d_reclen = dirblksize; + auio.uio_offset = dp->i_offset; + auio.uio_resid = EXT2_DIR_REC_LEN(entry->e2d_namlen); + aiov.iov_len = auio.uio_resid; + aiov.iov_base = (caddr_t)entry; + } + + auio.uio_iov = + auio.uio_iovcnt = 1; + auio.uio_rw = UIO_WRITE; + auio.uio_segflg = UIO_SYSSPACE; + auio.uio_td = (struct thread *)0; + error = VOP_WRITE(dvp, , IO_SYNC, cnp->cn_cred); + if (error) + goto out; + + dp->i_size = roundup2(dp->i_size, dirblksize); + dp->i_flag |= IN_CHANGE; + +out: + free(buf, M_TEMP); + return (error); + +} + +/* * Write a directory entry after a call to namei, using the parameters * that it left in nameidata. The argument ip is the inode which the new * directory entry will refer to. Dvp is a pointer to the directory to @@ -871,7 +933,6 @@ ext2_direnter(struct inode *ip, struct vnode *dvp, str { struct inode *dp; struct ext2fs_direct_2 newdir; - struct buf *bp; int DIRBLKSIZ = ip->i_e2fs->e2fs_bsize; int error; @@ -911,36 +972,15 @@ ext2_direnter(struct inode *ip, struct vnode *dvp, str } } - if (dp->i_count == 0) { - /* -* If dp->i_count is 0, then namei could find no -* space in the directory. Here, dp->i_offset will -* be on a directory block boundary and we will write the -* new entry into a fresh block. -*/ - if (dp->i_offset & (DIRBLKSIZ - 1)) - panic("ext2_direnter: newblk"); + /* +* If dp->i_count is 0, then namei could find no +* space in the directory. Here, dp->i_offset will +* be on a directory block boundary and we will write the +* new entry into a fresh block. +*/ + if (dp->i_count == 0) + return
svn commit: r333586 - head/sys/fs/ext2fs
Author: fsu Date: Sun May 13 19:48:30 2018 New Revision: 333586 URL: https://svnweb.freebsd.org/changeset/base/333586 Log: Fix directory blocks checksumming. Reviewed by:pfg MFC after: 3 months Differential Revision:https://reviews.freebsd.org/D15396 Modified: head/sys/fs/ext2fs/ext2_csum.c head/sys/fs/ext2fs/ext2_extern.h head/sys/fs/ext2fs/ext2_htree.c head/sys/fs/ext2fs/ext2_inode_cnv.c head/sys/fs/ext2fs/ext2_lookup.c head/sys/fs/ext2fs/ext2_vnops.c Modified: head/sys/fs/ext2fs/ext2_csum.c == --- head/sys/fs/ext2fs/ext2_csum.c Sun May 13 19:29:35 2018 (r333585) +++ head/sys/fs/ext2fs/ext2_csum.c Sun May 13 19:48:30 2018 (r333586) @@ -154,12 +154,37 @@ ext2_extattr_blk_csum_set(struct inode *ip, struct buf header->h_checksum = ext2_extattr_blk_csum(ip, ip->i_facl, header); } -static struct ext2fs_direct_tail * -ext2_get_dirent_tail(struct inode *ip, struct ext2fs_direct_2 *ep) +void +ext2_init_dirent_tail(struct ext2fs_direct_tail *tp) { + memset(tp, 0, sizeof(struct ext2fs_direct_tail)); + tp->e2dt_rec_len = sizeof(struct ext2fs_direct_tail); + tp->e2dt_reserved_ft = EXT2_FT_DIR_CSUM; +} + +struct ext2fs_direct_tail * +ext2_dirent_get_tail(struct inode *ip, struct ext2fs_direct_2 *ep) +{ + struct ext2fs_direct_2 *dep; + void *top; struct ext2fs_direct_tail *tp; + unsigned int rec_len; - tp = EXT2_DIRENT_TAIL(ep, ip->i_e2fs->e2fs_bsize); + dep = ep; + top = EXT2_DIRENT_TAIL(ep, ip->i_e2fs->e2fs_bsize); + rec_len = dep->e2d_reclen; + + while (rec_len && !(rec_len & 0x3)) { + dep = (struct ext2fs_direct_2 *)(((char *)dep) + rec_len); + if ((void *)dep >= top) + break; + rec_len = dep->e2d_reclen; + } + + if (dep != top) + return (NULL); + + tp = (struct ext2fs_direct_tail *)dep; if (tp->e2dt_reserved_zero1 || tp->e2dt_rec_len != sizeof(struct ext2fs_direct_tail) || tp->e2dt_reserved_zero2 || @@ -189,13 +214,13 @@ ext2_dirent_csum(struct inode *ip, struct ext2fs_direc return (crc); } -static int +int ext2_dirent_csum_verify(struct inode *ip, struct ext2fs_direct_2 *ep) { uint32_t calculated; struct ext2fs_direct_tail *tp; - tp = ext2_get_dirent_tail(ip, ep); + tp = ext2_dirent_get_tail(ip, ep); if (tp == NULL) return (0); @@ -263,7 +288,7 @@ ext2_dx_csum(struct inode *ip, struct ext2fs_direct_2 return (crc); } -static int +int ext2_dx_csum_verify(struct inode *ip, struct ext2fs_direct_2 *ep) { uint32_t calculated; @@ -304,7 +329,7 @@ ext2_dir_blk_csum_verify(struct inode *ip, struct buf ep = (struct ext2fs_direct_2 *)bp->b_data; - if (ext2_get_dirent_tail(ip, ep) != NULL) + if (ext2_dirent_get_tail(ip, ep) != NULL) error = ext2_dirent_csum_verify(ip, ep); else if (ext2_get_dx_count(ip, ep, NULL) != NULL) error = ext2_dx_csum_verify(ip, ep); @@ -316,12 +341,18 @@ ext2_dir_blk_csum_verify(struct inode *ip, struct buf return (error); } -static void +void ext2_dirent_csum_set(struct inode *ip, struct ext2fs_direct_2 *ep) { + struct m_ext2fs *fs; struct ext2fs_direct_tail *tp; - tp = ext2_get_dirent_tail(ip, ep); + fs = ip->i_e2fs; + + if (!EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) + return; + + tp = ext2_dirent_get_tail(ip, ep); if (tp == NULL) return; @@ -329,13 +360,19 @@ ext2_dirent_csum_set(struct inode *ip, struct ext2fs_d ext2_dirent_csum(ip, ep, (char *)tp - (char *)ep); } -static void +void ext2_dx_csum_set(struct inode *ip, struct ext2fs_direct_2 *ep) { + struct m_ext2fs *fs; struct ext2fs_htree_count *cp; struct ext2fs_htree_tail *tp; int count_offset, limit, count; + fs = ip->i_e2fs; + + if (!EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) + return; + cp = ext2_get_dx_count(ip, ep, _offset); if (cp == NULL) return; @@ -350,35 +387,6 @@ ext2_dx_csum_set(struct inode *ip, struct ext2fs_direc tp->ht_checksum = ext2_dx_csum(ip, ep, count_offset, count, tp); } -void -ext2_dir_blk_csum_set_mem(struct inode *ip, char *buf, int size) -{ - struct m_ext2fs *fs; - struct ext2fs_direct_2 *ep; - - fs = ip->i_e2fs; - - if (!EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) - return; - - ep = (struct ext2fs_direct_2 *)buf; - - if (ext2_htree_has_idx(ip)) { - if (ext2_get_dx_count(ip, ep, NULL) != NULL) - ext2_dx_csum_set(ip, ep); - } else { - if
svn commit: r333585 - head/sys/fs/ext2fs
Author: fsu Date: Sun May 13 19:29:35 2018 New Revision: 333585 URL: https://svnweb.freebsd.org/changeset/base/333585 Log: Fix on-disk inode checksum calculation logic. Reviewed by:pfg MFC after: 3 months Differential Revision:https://reviews.freebsd.org/D15395 Modified: head/sys/fs/ext2fs/ext2_csum.c head/sys/fs/ext2fs/ext2_inode_cnv.c Modified: head/sys/fs/ext2fs/ext2_csum.c == --- head/sys/fs/ext2fs/ext2_csum.c Sun May 13 19:19:10 2018 (r333584) +++ head/sys/fs/ext2fs/ext2_csum.c Sun May 13 19:29:35 2018 (r333585) @@ -535,29 +535,42 @@ static uint32_t ext2_ei_csum(struct inode *ip, struct ext2fs_dinode *ei) { struct m_ext2fs *fs; - uint16_t old_hi; - uint32_t inum, gen, crc; + uint32_t inode_csum_seed, inum, gen, crc; + uint16_t dummy_csum = 0; + unsigned int offset, csum_size; fs = ip->i_e2fs; - - ei->e2di_chksum_lo = 0; - if ((EXT2_INODE_SIZE(ip->i_e2fs) > E2FS_REV0_INODE_SIZE && - ei->e2di_extra_isize >= EXT2_INODE_CSUM_HI_EXTRA_END)) { - old_hi = ei->e2di_chksum_hi; - ei->e2di_chksum_hi = 0; - } - + offset = offsetof(struct ext2fs_dinode, e2di_chksum_lo); + csum_size = sizeof(dummy_csum); inum = ip->i_number; gen = ip->i_gen; + crc = calculate_crc32c(fs->e2fs_csum_seed, + (uint8_t *), sizeof(inum)); + inode_csum_seed = calculate_crc32c(crc, + (uint8_t *), sizeof(gen)); - crc = calculate_crc32c(fs->e2fs_csum_seed, (uint8_t *), sizeof(inum)); - crc = calculate_crc32c(crc, (uint8_t *), sizeof(gen)); - crc = calculate_crc32c(crc, (uint8_t *)ei, fs->e2fs->e2fs_inode_size); + crc = calculate_crc32c(inode_csum_seed, (uint8_t *)ei, offset); + crc = calculate_crc32c(crc, (uint8_t *)_csum, csum_size); + offset += csum_size; + crc = calculate_crc32c(crc, (uint8_t *)ei + offset, + E2FS_REV0_INODE_SIZE - offset); - if ((EXT2_INODE_SIZE(fs) > E2FS_REV0_INODE_SIZE && - ei->e2di_extra_isize >= EXT2_INODE_CSUM_HI_EXTRA_END)) - ei->e2di_chksum_hi = old_hi; + if (EXT2_INODE_SIZE(fs) > E2FS_REV0_INODE_SIZE) { + offset = offsetof(struct ext2fs_dinode, e2di_chksum_hi); + crc = calculate_crc32c(crc, (uint8_t *)ei + + E2FS_REV0_INODE_SIZE, offset - E2FS_REV0_INODE_SIZE); + if ((EXT2_INODE_SIZE(ip->i_e2fs) > E2FS_REV0_INODE_SIZE && + ei->e2di_extra_isize >= EXT2_INODE_CSUM_HI_EXTRA_END)) { + crc = calculate_crc32c(crc, (uint8_t *)_csum, + csum_size); + offset += csum_size; + } + + crc = calculate_crc32c(crc, (uint8_t *)ei + offset, + EXT2_INODE_SIZE(fs) - offset); + } + return (crc); } @@ -573,10 +586,6 @@ ext2_ei_csum_verify(struct inode *ip, struct ext2fs_di if (!EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) return (0); - /* Check case, when dinode was not initialized */ - if (!memcmp(ei, _zero, sizeof(struct ext2fs_dinode))) - return (0); - provided = ei->e2di_chksum_lo; calculated = ext2_ei_csum(ip, ei); @@ -587,8 +596,17 @@ ext2_ei_csum_verify(struct inode *ip, struct ext2fs_di } else calculated &= 0x; - if (provided != calculated) + if (provided != calculated) { + /* +* If it is first time used dinode, +* it is expected that it will be zeroed +* and we will not return checksum error in this case. +*/ + if (!memcmp(ei, _zero, sizeof(struct ext2fs_dinode))) + return (0); + return (EIO); + } return (0); } Modified: head/sys/fs/ext2fs/ext2_inode_cnv.c == --- head/sys/fs/ext2fs/ext2_inode_cnv.c Sun May 13 19:19:10 2018 (r333584) +++ head/sys/fs/ext2fs/ext2_inode_cnv.c Sun May 13 19:29:35 2018 (r333585) @@ -92,10 +92,7 @@ ext2_print_inode(struct inode *in) int ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) { - struct m_ext2fs *fs; - const static struct ext2fs_dinode ei_zero; - fs = ip->i_e2fs; ip->i_nlink = ei->e2di_nlink; /* * Godmar thinks - if the link count is zero, then the inode is @@ -139,11 +136,7 @@ ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) memcpy(ip->i_data, ei->e2di_blocks, sizeof(ei->e2di_blocks)); - if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM) && - memcmp(ei, _zero, EXT2_INODE_SIZE(fs))) - return (ext2_ei_csum_verify(ip,
svn commit: r333584 - head/sys/fs/ext2fs
Author: fsu Date: Sun May 13 19:19:10 2018 New Revision: 333584 URL: https://svnweb.freebsd.org/changeset/base/333584 Log: Fix EXT2FS_DEBUG definition usage. Reviewed by:pfg MFC after: 3 months Differential Revision:https://reviews.freebsd.org/D15394 Modified: head/sys/fs/ext2fs/ext2_alloc.c head/sys/fs/ext2fs/ext2_bmap.c head/sys/fs/ext2fs/ext2_extents.c head/sys/fs/ext2fs/ext2_extents.h head/sys/fs/ext2fs/ext2_hash.c head/sys/fs/ext2fs/ext2_htree.c head/sys/fs/ext2fs/ext2_inode.c head/sys/fs/ext2fs/ext2_inode_cnv.c head/sys/fs/ext2fs/ext2_lookup.c head/sys/fs/ext2fs/ext2_subr.c head/sys/fs/ext2fs/ext2_vfsops.c head/sys/fs/ext2fs/ext2_vnops.c head/sys/fs/ext2fs/fs.h Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Sun May 13 17:44:26 2018 (r333583) +++ head/sys/fs/ext2fs/ext2_alloc.c Sun May 13 19:19:10 2018 (r333584) @@ -1381,8 +1381,8 @@ ext2_vfree(struct vnode *pvp, ino_t ino, int mode) ibp = (char *)bp->b_data; ino = (ino - 1) % fs->e2fs->e2fs_ipg; if (isclr(ibp, ino)) { - printf("ino = %llu, fs = %s\n", - (unsigned long long)ino, fs->e2fs_fsmnt); + printf("ino = %ju, fs = %s\n", + ino, fs->e2fs_fsmnt); if (fs->e2fs_ronly == 0) panic("ext2_vfree: freeing free inode"); } Modified: head/sys/fs/ext2fs/ext2_bmap.c == --- head/sys/fs/ext2fs/ext2_bmap.c Sun May 13 17:44:26 2018 (r333583) +++ head/sys/fs/ext2fs/ext2_bmap.c Sun May 13 19:19:10 2018 (r333584) @@ -48,8 +48,8 @@ #include #include -#include #include +#include #include #include #include Modified: head/sys/fs/ext2fs/ext2_extents.c == --- head/sys/fs/ext2fs/ext2_extents.c Sun May 13 17:44:26 2018 (r333583) +++ head/sys/fs/ext2fs/ext2_extents.c Sun May 13 19:19:10 2018 (r333584) @@ -53,7 +53,7 @@ static void ext4_ext_print_extent(struct ext4_extent *ep) { - printf("ext %p => (blk %u len %u start %lu)\n", + printf("ext %p => (blk %u len %u start %ju)\n", ep, ep->e_blk, ep->e_len, (uint64_t)ep->e_start_hi << 32 | ep->e_start_lo); } @@ -69,7 +69,7 @@ ext4_ext_print_index(struct inode *ip, struct ext4_ext fs = ip->i_e2fs; - printf("index %p => (blk %u pblk %lu)\n", + printf("index %p => (blk %u pblk %ju)\n", ex, ex->ei_blk, (uint64_t)ex->ei_leaf_hi << 32 | ex->ei_leaf_lo); if(!do_walk) @@ -110,9 +110,9 @@ ext4_ext_print_path(struct inode *ip, struct ext4_exte { int k, l; - l = path->ep_depth + l = path->ep_depth; - printf("ip=%d, Path:\n", ip->i_number); + printf("ip=%ju, Path:\n", ip->i_number); for (k = 0; k <= l; k++, path++) { if (path->ep_index) { ext4_ext_print_index(ip, path->ep_index, 0); @@ -123,13 +123,13 @@ ext4_ext_print_path(struct inode *ip, struct ext4_exte } void -ext4_ext_print_extent_tree_status(struct inode * ip) +ext4_ext_print_extent_tree_status(struct inode *ip) { struct ext4_extent_header *ehp; ehp = (struct ext4_extent_header *)(char *)ip->i_db; - printf("Extent status:ip=%d\n", ip->i_number); + printf("Extent status:ip=%ju\n", ip->i_number); if (!(ip->i_flag & IN_E4EXTENTS)) return; Modified: head/sys/fs/ext2fs/ext2_extents.h == --- head/sys/fs/ext2fs/ext2_extents.h Sun May 13 17:44:26 2018 (r333583) +++ head/sys/fs/ext2fs/ext2_extents.h Sun May 13 19:19:10 2018 (r333584) @@ -130,7 +130,7 @@ int ext4_ext_get_blocks(struct inode *ip, int64_t iblo unsigned long max_blocks, struct ucred *cred, struct buf **bpp, int *allocate, daddr_t *); #ifdef EXT2FS_DEBUG -void ext4_ext_print_extent_tree_status(struct inode * ip); +void ext4_ext_print_extent_tree_status(struct inode *ip); #endif #endif /* !_FS_EXT2FS_EXT2_EXTENTS_H_ */ Modified: head/sys/fs/ext2fs/ext2_hash.c == --- head/sys/fs/ext2fs/ext2_hash.c Sun May 13 17:44:26 2018 (r333583) +++ head/sys/fs/ext2fs/ext2_hash.c Sun May 13 19:19:10 2018 (r333584) @@ -61,6 +61,7 @@ #include #include +#include #include #include #include Modified: head/sys/fs/ext2fs/ext2_htree.c == --- head/sys/fs/ext2fs/ext2_htree.c Sun May 13 17:44:26 2018 (r333583) +++ head/sys/fs/ext2fs/ext2_htree.c Sun May 13 19:19:10
svn commit: r328566 - head/sys/fs/ext2fs
Author: fsu Date: Mon Jan 29 22:15:46 2018 New Revision: 328566 URL: https://svnweb.freebsd.org/changeset/base/328566 Log: Fix mistake in case of zeroed inode check. Reported by: pho MFC after:6 months Modified: head/sys/fs/ext2fs/ext2_inode_cnv.c Modified: head/sys/fs/ext2fs/ext2_inode_cnv.c == --- head/sys/fs/ext2fs/ext2_inode_cnv.c Mon Jan 29 22:03:01 2018 (r328565) +++ head/sys/fs/ext2fs/ext2_inode_cnv.c Mon Jan 29 22:15:46 2018 (r328566) @@ -90,8 +90,10 @@ ext2_print_inode(struct inode *in) int ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) { + struct m_ext2fs *fs; const static struct ext2fs_dinode ei_zero; + fs = ip->i_e2fs; ip->i_nlink = ei->e2di_nlink; /* * Godmar thinks - if the link count is zero, then the inode is @@ -135,7 +137,8 @@ ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) memcpy(ip->i_data, ei->e2di_blocks, sizeof(ei->e2di_blocks)); - if (memcmp(ei, _zero, sizeof(struct ext2fs_dinode))) + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM) && + memcmp(ei, _zero, EXT2_INODE_SIZE(fs))) return (ext2_ei_csum_verify(ip, ei)); return (0); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r328564 - head/sys/fs/ext2fs
Author: fsu Date: Mon Jan 29 21:54:13 2018 New Revision: 328564 URL: https://svnweb.freebsd.org/changeset/base/328564 Log: Add flex_bg/meta_bg features RW support. Reviewed by:pfg MFC after: 6 months Differential Revision:https://reviews.freebsd.org/D13964 Modified: head/sys/fs/ext2fs/ext2_alloc.c head/sys/fs/ext2fs/ext2_vfsops.c head/sys/fs/ext2fs/ext2fs.h Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Mon Jan 29 21:16:56 2018 (r328563) +++ head/sys/fs/ext2fs/ext2_alloc.c Mon Jan 29 21:54:13 2018 (r328564) @@ -755,49 +755,68 @@ ext2_hashalloc(struct inode *ip, int cg, long pref, in } static unsigned long -ext2_cg_num_gdb(struct m_ext2fs *fs, int cg) +ext2_cg_number_gdb_nometa(struct m_ext2fs *fs, int cg) { - int gd_per_block, metagroup, first, last; - gd_per_block = fs->e2fs_bsize / sizeof(struct ext2_gd); - metagroup = cg / gd_per_block; - first = metagroup * gd_per_block; - last = first + gd_per_block - 1; + if (!ext2_cg_has_sb(fs, cg)) + return (0); - if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_META_BG) || - metagroup < fs->e2fs->e3fs_first_meta_bg) { - if (!ext2_cg_has_sb(fs, cg)) - return (0); - if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_META_BG)) - return (fs->e2fs->e3fs_first_meta_bg); - return (fs->e2fs_gdbcount); - } + if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_META_BG)) + return (fs->e2fs->e3fs_first_meta_bg); + return ((fs->e2fs_gcount + EXT2_DESCS_PER_BLOCK(fs) - 1) / + EXT2_DESCS_PER_BLOCK(fs)); +} + +static unsigned long +ext2_cg_number_gdb_meta(struct m_ext2fs *fs, int cg) +{ + unsigned long metagroup; + int first, last; + + metagroup = cg / EXT2_DESCS_PER_BLOCK(fs); + first = metagroup * EXT2_DESCS_PER_BLOCK(fs); + last = first + EXT2_DESCS_PER_BLOCK(fs) - 1; + if (cg == first || cg == first + 1 || cg == last) return (1); + return (0); +} +static unsigned long +ext2_cg_number_gdb(struct m_ext2fs *fs, int cg) +{ + unsigned long first_meta_bg, metagroup; + + first_meta_bg = fs->e2fs->e3fs_first_meta_bg; + metagroup = cg / EXT2_DESCS_PER_BLOCK(fs); + + if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_META_BG) || + metagroup < first_meta_bg) + return (ext2_cg_number_gdb_nometa(fs, cg)); + + return ext2_cg_number_gdb_meta(fs, cg); } static int -ext2_num_base_meta_blocks(struct m_ext2fs *fs, int cg) +ext2_number_base_meta_blocks(struct m_ext2fs *fs, int cg) { - int num, gd_per_block; + int number; - gd_per_block = fs->e2fs_bsize / sizeof(struct ext2_gd); - num = ext2_cg_has_sb(fs, cg); + number = ext2_cg_has_sb(fs, cg); if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_META_BG) || - cg < fs->e2fs->e3fs_first_meta_bg * gd_per_block) { - if (num) { - num += ext2_cg_num_gdb(fs, cg); - num += fs->e2fs->e2fs_reserved_ngdb; + cg < fs->e2fs->e3fs_first_meta_bg * EXT2_DESCS_PER_BLOCK(fs)) { + if (number) { + number += ext2_cg_number_gdb(fs, cg); + number += fs->e2fs->e2fs_reserved_ngdb; } } else { - num += ext2_cg_num_gdb(fs, cg); + number += ext2_cg_number_gdb(fs, cg); } - - return (num); + + return (number); } static void @@ -815,6 +834,20 @@ ext2_mark_bitmap_end(int start_bit, int end_bit, char } static int +ext2_get_group_number(struct m_ext2fs *fs, e4fs_daddr_t block) +{ + + return ((block - fs->e2fs->e2fs_first_dblock) / fs->e2fs_bsize); +} + +static int +ext2_block_in_group(struct m_ext2fs *fs, e4fs_daddr_t block, int cg) +{ + + return ((ext2_get_group_number(fs, block) == cg) ? 1 : 0); +} + +static int ext2_cg_block_bitmap_init(struct m_ext2fs *fs, int cg, struct buf *bp) { int bit, bit_max, inodes_per_block; @@ -825,7 +858,7 @@ ext2_cg_block_bitmap_init(struct m_ext2fs *fs, int cg, memset(bp->b_data, 0, fs->e2fs_bsize); - bit_max = ext2_num_base_meta_blocks(fs, cg); + bit_max = ext2_number_base_meta_blocks(fs, cg); if ((bit_max >> 3) >= fs->e2fs_bsize) return (EINVAL); @@ -837,12 +870,12 @@ ext2_cg_block_bitmap_init(struct m_ext2fs *fs, int cg, /* Set bits for block and inode bitmaps, and inode table. */ tmp = e2fs_gd_get_b_bitmap(>e2fs_gd[cg]); if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG) || - cg == dtogd(fs, tmp)) + ext2_block_in_group(fs, tmp, cg)) setbit(bp->b_data, tmp -
svn commit: r327977 - head/sys/fs/ext2fs
Author: fsu Date: Sun Jan 14 20:46:39 2018 New Revision: 327977 URL: https://svnweb.freebsd.org/changeset/base/327977 Log: Add metadata_csum feature support. Reviewed by: pfg (mentor) Approved by: pfg (mentor) MFC after: 6 months Differential Revision:https://reviews.freebsd.org/D13810 Modified: head/sys/fs/ext2fs/ext2_alloc.c head/sys/fs/ext2fs/ext2_csum.c head/sys/fs/ext2fs/ext2_dir.h head/sys/fs/ext2fs/ext2_extattr.c head/sys/fs/ext2fs/ext2_extattr.h head/sys/fs/ext2fs/ext2_extents.c head/sys/fs/ext2fs/ext2_extents.h head/sys/fs/ext2fs/ext2_extern.h head/sys/fs/ext2fs/ext2_inode_cnv.c head/sys/fs/ext2fs/ext2_lookup.c head/sys/fs/ext2fs/ext2_subr.c head/sys/fs/ext2fs/ext2_vfsops.c head/sys/fs/ext2fs/ext2_vnops.c head/sys/fs/ext2fs/ext2fs.h head/sys/fs/ext2fs/htree.h Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Sun Jan 14 20:36:21 2018 (r327976) +++ head/sys/fs/ext2fs/ext2_alloc.c Sun Jan 14 20:46:39 2018 (r327977) @@ -898,14 +898,22 @@ ext2_alloccg(struct inode *ip, int cg, daddr_t bpref, EXT2_LOCK(ump); return (0); } - if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM)) { + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || + EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) { error = ext2_cg_block_bitmap_init(fs, cg, bp); if (error) { brelse(bp); EXT2_LOCK(ump); return (0); } + ext2_gd_b_bitmap_csum_set(fs, cg, bp); } + error = ext2_gd_b_bitmap_csum_verify(fs, cg, bp); + if (error) { + brelse(bp); + EXT2_LOCK(ump); + return (0); + } if (e2fs_gd_get_nbfree(>e2fs_gd[cg]) == 0) { /* * Another thread allocated the last block in this @@ -1008,6 +1016,7 @@ gotit: e2fs_gd_get_nbfree(>e2fs_gd[cg]) - 1); fs->e2fs_fmod = 1; EXT2_UNLOCK(ump); + ext2_gd_b_bitmap_csum_set(fs, cg, bp); bdwrite(bp); return (((uint64_t)cg) * fs->e2fs->e2fs_fpg + fs->e2fs->e2fs_first_dblock + bno); } @@ -1187,11 +1196,13 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipr EXT2_LOCK(ump); return (0); } - if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM)) { + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || + EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) { if (fs->e2fs_gd[cg].ext4bgd_flags & EXT2_BG_INODE_UNINIT) { memset(bp->b_data, 0, fs->e2fs_bsize); fs->e2fs_gd[cg].ext4bgd_flags &= ~EXT2_BG_INODE_UNINIT; } + ext2_gd_i_bitmap_csum_set(fs, cg, bp); error = ext2_zero_inode_table(ip, cg); if (error) { brelse(bp); @@ -1199,6 +1210,12 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipr return (0); } } + error = ext2_gd_i_bitmap_csum_verify(fs, cg, bp); + if (error) { + brelse(bp); + EXT2_LOCK(ump); + return (0); + } if (e2fs_gd_get_nifree(>e2fs_gd[cg]) == 0) { /* * Another thread allocated the last i-node in this @@ -1234,7 +1251,8 @@ gotit: EXT2_LOCK(ump); e2fs_gd_set_nifree(>e2fs_gd[cg], e2fs_gd_get_nifree(>e2fs_gd[cg]) - 1); - if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM)) + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || + EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) e2fs_gd_set_i_unused(>e2fs_gd[cg], e2fs_gd_get_i_unused(>e2fs_gd[cg]) - 1); fs->e2fs->e2fs_ficount--; @@ -1245,6 +1263,7 @@ gotit: fs->e2fs_total_dir++; } EXT2_UNLOCK(ump); + ext2_gd_i_bitmap_csum_set(fs, cg, bp); bdwrite(bp); return ((uint64_t)cg * fs->e2fs_ipg + ipref + 1); } @@ -1293,6 +1312,7 @@ ext2_blkfree(struct inode *ip, e4fs_daddr_t bno, long e2fs_gd_get_nbfree(>e2fs_gd[cg]) + 1); fs->e2fs_fmod = 1; EXT2_UNLOCK(ump); + ext2_gd_b_bitmap_csum_set(fs, cg, bp); bdwrite(bp); } @@ -1338,7 +1358,8 @@ ext2_vfree(struct vnode *pvp, ino_t ino, int mode) fs->e2fs->e2fs_ficount++; e2fs_gd_set_nifree(>e2fs_gd[cg], e2fs_gd_get_nifree(>e2fs_gd[cg]) + 1); - if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM)) + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || +
svn commit: r327585 - stable/11/sys/fs/ext2fs
Author: fsu Date: Fri Jan 5 10:04:13 2018 New Revision: 327585 URL: https://svnweb.freebsd.org/changeset/base/327585 Log: MFC r326807: Fix extattr getters in case of neither uio nor buffer was not passed to VOP_*. Approved by:pfg (mentor) Differential Revision:https://reviews.freebsd.org/D13359 Modified: stable/11/sys/fs/ext2fs/ext2_extattr.c Modified: stable/11/sys/fs/ext2fs/ext2_extattr.c == --- stable/11/sys/fs/ext2fs/ext2_extattr.c Fri Jan 5 10:04:01 2018 (r327584) +++ stable/11/sys/fs/ext2fs/ext2_extattr.c Fri Jan 5 10:04:13 2018 (r327585) @@ -218,9 +218,10 @@ ext2_extattr_inode_list(struct inode *ip, int attrname return (ENOTSUP); } - if (uio == NULL) + if (size != NULL) *size += name_len + 1; - else { + + if (uio != NULL) { char *name = malloc(name_len + 1, M_TEMP, M_WAITOK); name[0] = name_len; memcpy([1], attr_name, name_len); @@ -284,9 +285,10 @@ ext2_extattr_block_list(struct inode *ip, int attrname return (ENOTSUP); } - if (uio == NULL) + if (size != NULL) *size += name_len + 1; - else { + + if (uio != NULL) { char *name = malloc(name_len + 1, M_TEMP, M_WAITOK); name[0] = name_len; memcpy([1], attr_name, name_len); @@ -359,12 +361,12 @@ ext2_extattr_inode_get(struct inode *ip, int attrnames if (strlen(name) == name_len && 0 == strncmp(attr_name, name, name_len)) { - if (uio == NULL) + if (size != NULL) *size += entry->e_value_size; - else { + + if (uio != NULL) error = uiomove(((char *)EXT2_IFIRST(header)) + entry->e_value_offs, entry->e_value_size, uio); - } brelse(bp); return (error); @@ -426,12 +428,12 @@ ext2_extattr_block_get(struct inode *ip, int attrnames if (strlen(name) == name_len && 0 == strncmp(attr_name, name, name_len)) { - if (uio == NULL) + if (size != NULL) *size += entry->e_value_size; - else { + + if (uio != NULL) error = uiomove(bp->b_data + entry->e_value_offs, entry->e_value_size, uio); - } brelse(bp); return (error); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r327584 - head/sys/fs/ext2fs
Author: fsu Date: Fri Jan 5 10:04:01 2018 New Revision: 327584 URL: https://svnweb.freebsd.org/changeset/base/327584 Log: Add 64bit feature support. Reviewed by:kevlo, pfg (mentor) Approved by:pfg (mentor) MFC after: 6 months Differential Revision:https://reviews.freebsd.org/D11530 Modified: head/sys/fs/ext2fs/ext2_alloc.c head/sys/fs/ext2fs/ext2_balloc.c head/sys/fs/ext2fs/ext2_csum.c head/sys/fs/ext2fs/ext2_extents.c head/sys/fs/ext2fs/ext2_extents.h head/sys/fs/ext2fs/ext2_extern.h head/sys/fs/ext2fs/ext2_hash.c head/sys/fs/ext2fs/ext2_subr.c head/sys/fs/ext2fs/ext2_vfsops.c head/sys/fs/ext2fs/ext2_vnops.c head/sys/fs/ext2fs/ext2fs.h head/sys/fs/ext2fs/fs.h Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Fri Jan 5 09:31:41 2018 (r327583) +++ head/sys/fs/ext2fs/ext2_alloc.c Fri Jan 5 10:04:01 2018 (r327584) @@ -103,12 +103,12 @@ ext2_alloc(struct inode *ip, daddr_t lbn, e4fs_daddr_t if (cred == NOCRED) panic("ext2_alloc: missing credential"); #endif /* INVARIANTS */ - if (size == fs->e2fs_bsize && fs->e2fs->e2fs_fbcount == 0) + if (size == fs->e2fs_bsize && fs->e2fs_fbcount == 0) goto nospace; if (cred->cr_uid != 0 && - fs->e2fs->e2fs_fbcount < fs->e2fs->e2fs_rbcount) + fs->e2fs_fbcount < fs->e2fs_rbcount) goto nospace; - if (bpref >= fs->e2fs->e2fs_bcount) + if (bpref >= fs->e2fs_bcount) bpref = 0; if (bpref == 0) cg = ino_to_cg(fs, ip->i_number); @@ -455,6 +455,96 @@ noinodes: } /* + * 64-bit compatible getters and setters for struct ext2_gd from ext2fs.h + */ +static uint64_t +e2fs_gd_get_b_bitmap(struct ext2_gd *gd) +{ + + return (((uint64_t)(gd->ext4bgd_b_bitmap_hi) << 32) | + gd->ext2bgd_b_bitmap); +} + +static uint64_t +e2fs_gd_get_i_bitmap(struct ext2_gd *gd) +{ + + return (((uint64_t)(gd->ext4bgd_i_bitmap_hi) << 32) | + gd->ext2bgd_i_bitmap); +} + +uint64_t +e2fs_gd_get_i_tables(struct ext2_gd *gd) +{ + + return (((uint64_t)(gd->ext4bgd_i_tables_hi) << 32) | + gd->ext2bgd_i_tables); +} + +static uint32_t +e2fs_gd_get_nbfree(struct ext2_gd *gd) +{ + + return (((uint32_t)(gd->ext4bgd_nbfree_hi) << 16) | + gd->ext2bgd_nbfree); +} + +static void +e2fs_gd_set_nbfree(struct ext2_gd *gd, uint32_t val) +{ + + gd->ext2bgd_nbfree = val & 0x; + gd->ext4bgd_nbfree_hi = val >> 16; +} + +static uint32_t +e2fs_gd_get_nifree(struct ext2_gd *gd) +{ + + return (((uint32_t)(gd->ext4bgd_nifree_hi) << 16) | + gd->ext2bgd_nifree); +} + +static void +e2fs_gd_set_nifree(struct ext2_gd *gd, uint32_t val) +{ + + gd->ext2bgd_nifree = val & 0x; + gd->ext4bgd_nifree_hi = val >> 16; +} + +uint32_t +e2fs_gd_get_ndirs(struct ext2_gd *gd) +{ + + return (((uint32_t)(gd->ext4bgd_ndirs_hi) << 16) | + gd->ext2bgd_ndirs); +} + +static void +e2fs_gd_set_ndirs(struct ext2_gd *gd, uint32_t val) +{ + + gd->ext2bgd_ndirs = val & 0x; + gd->ext4bgd_ndirs_hi = val >> 16; +} + +static uint32_t +e2fs_gd_get_i_unused(struct ext2_gd *gd) +{ + return (((uint32_t)(gd->ext4bgd_i_unused_hi) << 16) | + gd->ext4bgd_i_unused); +} + +static void +e2fs_gd_set_i_unused(struct ext2_gd *gd, uint32_t val) +{ + + gd->ext4bgd_i_unused = val & 0x; + gd->ext4bgd_i_unused_hi = val >> 16; +} + +/* * Find a cylinder to place a directory. * * The policy implemented by this algorithm is to allocate a @@ -473,8 +563,9 @@ ext2_dirpref(struct inode *pip) { struct m_ext2fs *fs; int cg, prefcg, cgsize; - u_int avgifree, avgbfree, avgndir, curdirsize; - u_int minifree, minbfree, maxndir; + uint64_t avgbfree, minbfree; + u_int avgifree, avgndir, curdirsize; + u_int minifree, maxndir; u_int mincg, minndir; u_int dirsize, maxcontigdirs; @@ -482,7 +573,7 @@ ext2_dirpref(struct inode *pip) fs = pip->i_e2fs; avgifree = fs->e2fs->e2fs_ficount / fs->e2fs_gcount; - avgbfree = fs->e2fs->e2fs_fbcount / fs->e2fs_gcount; + avgbfree = fs->e2fs_fbcount / fs->e2fs_gcount; avgndir = fs->e2fs_total_dir / fs->e2fs_gcount; /* @@ -494,18 +585,18 @@ ext2_dirpref(struct inode *pip) mincg = prefcg; minndir = fs->e2fs_ipg; for (cg = prefcg; cg < fs->e2fs_gcount; cg++) - if (fs->e2fs_gd[cg].ext2bgd_ndirs < minndir && - fs->e2fs_gd[cg].ext2bgd_nifree >= avgifree && - fs->e2fs_gd[cg].ext2bgd_nbfree >= avgbfree) { + if (e2fs_gd_get_ndirs(>e2fs_gd[cg]) < minndir && +
svn commit: r327087 - stable/11/sys/kern
Author: fsu Date: Fri Dec 22 17:19:08 2017 New Revision: 327087 URL: https://svnweb.freebsd.org/changeset/base/327087 Log: MFC r326808, r326824: Move buffer size checks outside of the vnode locks. Reviewed by:kib, cem, pfg (mentor) Approved by:pfg (mentor) Differential Revision:https://reviews.freebsd.org/D13405 Modified: stable/11/sys/kern/vfs_extattr.c Modified: stable/11/sys/kern/vfs_extattr.c == --- stable/11/sys/kern/vfs_extattr.cFri Dec 22 17:15:02 2017 (r327086) +++ stable/11/sys/kern/vfs_extattr.cFri Dec 22 17:19:08 2017 (r327087) @@ -165,6 +165,9 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, co ssize_t cnt; int error; + if (nbytes > IOSIZE_MAX) + return (EINVAL); + error = vn_start_write(vp, , V_WAIT | PCATCH); if (error) return (error); @@ -175,10 +178,6 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, co auio.uio_iov = auio.uio_iovcnt = 1; auio.uio_offset = 0; - if (nbytes > IOSIZE_MAX) { - error = EINVAL; - goto done; - } auio.uio_resid = nbytes; auio.uio_rw = UIO_WRITE; auio.uio_segflg = UIO_USERSPACE; @@ -197,7 +196,9 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, co cnt -= auio.uio_resid; td->td_retval[0] = cnt; +#ifdef MAC done: +#endif VOP_UNLOCK(vp, 0); vn_finished_write(mp); return (error); @@ -328,6 +329,9 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, co size_t size, *sizep; int error; + if (nbytes > IOSIZE_MAX) + return (EINVAL); + vn_lock(vp, LK_SHARED | LK_RETRY); /* @@ -344,10 +348,6 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, co auio.uio_iov = auio.uio_iovcnt = 1; auio.uio_offset = 0; - if (nbytes > IOSIZE_MAX) { - error = EINVAL; - goto done; - } auio.uio_resid = nbytes; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; @@ -372,8 +372,9 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, co td->td_retval[0] = cnt; } else td->td_retval[0] = size; - +#ifdef MAC done: +#endif VOP_UNLOCK(vp, 0); return (error); } @@ -636,6 +637,9 @@ extattr_list_vp(struct vnode *vp, int attrnamespace, v ssize_t cnt; int error; + if (nbytes > IOSIZE_MAX) + return (EINVAL); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); auiop = NULL; @@ -647,10 +651,6 @@ extattr_list_vp(struct vnode *vp, int attrnamespace, v auio.uio_iov = auio.uio_iovcnt = 1; auio.uio_offset = 0; - if (nbytes > IOSIZE_MAX) { - error = EINVAL; - goto done; - } auio.uio_resid = nbytes; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; @@ -674,8 +674,9 @@ extattr_list_vp(struct vnode *vp, int attrnamespace, v td->td_retval[0] = cnt; } else td->td_retval[0] = size; - +#ifdef MAC done: +#endif VOP_UNLOCK(vp, 0); return (error); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r326808 - head/sys/kern
Should be fixed in r326824. On Wed, Dec 13, 2017 at 1:58 PM, Fedor Uporov <f...@freebsd.org> wrote: > Hi, Andrew. > > Thanks for report, I know about the issue. > Just, need to get back home to my laptop to fix it. > Need 2-4 hours. > > On Wed, Dec 13, 2017 at 1:46 PM, Andrew Turner <and...@fubar.geek.nz> > wrote: > >> >> > On 12 Dec 2017, at 20:15, Fedor Uporov <f...@freebsd.org> wrote: >> > >> > Author: fsu >> > Date: Tue Dec 12 20:15:57 2017 >> > New Revision: 326808 >> > URL: https://svnweb.freebsd.org/changeset/base/326808 >> > >> > Log: >> > Move buffer size checks outside of the vnode locks. >> > >> > Reviewed by:kib, cem, pfg (mentor) >> > Approved by:pfg (mentor) >> > MFC after: 1 weeks >> > >> > Differential Revision:https://reviews.freebsd.org/D13405 >> >> This breaks the build when MAC is undefined, e.g. the armv7 GENERIC >> kernel. >> >> /usr/home/andrew/freebsd/repo/head-svn/sys/kern/vfs_extattr.c:201:1: >> error: unused label 'done' [-Werror,-Wunused-label] >> done: >> ^ >> /usr/home/andrew/freebsd/repo/head-svn/sys/kern/vfs_extattr.c:376:1: >> error: unused label 'done' [-Werror,-Wunused-label] >> done: >> ^ >> /usr/home/andrew/freebsd/repo/head-svn/sys/kern/vfs_extattr.c:677:1: >> error: unused label 'done' [-Werror,-Wunused-label] >> done: >> ^ >> 3 errors generated. >> >> Andrew >> >> > ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326824 - head/sys/kern
Author: fsu Date: Wed Dec 13 16:14:38 2017 New Revision: 326824 URL: https://svnweb.freebsd.org/changeset/base/326824 Log: Fix kernel build if MAC is not defined. Reported by:Ravi Pokala, Andrew Turner Approved by:pfg (mentor) MFC after: 1 week Modified: head/sys/kern/vfs_extattr.c Modified: head/sys/kern/vfs_extattr.c == --- head/sys/kern/vfs_extattr.c Wed Dec 13 16:13:17 2017(r326823) +++ head/sys/kern/vfs_extattr.c Wed Dec 13 16:14:38 2017(r326824) @@ -198,7 +198,9 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, co cnt -= auio.uio_resid; td->td_retval[0] = cnt; +#ifdef MAC done: +#endif VOP_UNLOCK(vp, 0); vn_finished_write(mp); return (error); @@ -372,8 +374,9 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, co td->td_retval[0] = cnt; } else td->td_retval[0] = size; - +#ifdef MAC done: +#endif VOP_UNLOCK(vp, 0); return (error); } @@ -673,8 +676,9 @@ extattr_list_vp(struct vnode *vp, int attrnamespace, v td->td_retval[0] = cnt; } else td->td_retval[0] = size; - +#ifdef MAC done: +#endif VOP_UNLOCK(vp, 0); return (error); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r326808 - head/sys/kern
Hi, Andrew. Thanks for report, I know about the issue. Just, need to get back home to my laptop to fix it. Need 2-4 hours. On Wed, Dec 13, 2017 at 1:46 PM, Andrew Turner <and...@fubar.geek.nz> wrote: > > > On 12 Dec 2017, at 20:15, Fedor Uporov <f...@freebsd.org> wrote: > > > > Author: fsu > > Date: Tue Dec 12 20:15:57 2017 > > New Revision: 326808 > > URL: https://svnweb.freebsd.org/changeset/base/326808 > > > > Log: > > Move buffer size checks outside of the vnode locks. > > > > Reviewed by:kib, cem, pfg (mentor) > > Approved by:pfg (mentor) > > MFC after: 1 weeks > > > > Differential Revision:https://reviews.freebsd.org/D13405 > > This breaks the build when MAC is undefined, e.g. the armv7 GENERIC kernel. > > /usr/home/andrew/freebsd/repo/head-svn/sys/kern/vfs_extattr.c:201:1: > error: unused label 'done' [-Werror,-Wunused-label] > done: > ^ > /usr/home/andrew/freebsd/repo/head-svn/sys/kern/vfs_extattr.c:376:1: > error: unused label 'done' [-Werror,-Wunused-label] > done: > ^ > /usr/home/andrew/freebsd/repo/head-svn/sys/kern/vfs_extattr.c:677:1: > error: unused label 'done' [-Werror,-Wunused-label] > done: > ^ > 3 errors generated. > > Andrew > > ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326810 - in stable/11: lib/libsysdecode sys/amd64/linux sys/amd64/linux32 sys/i386/linux
Author: fsu Date: Tue Dec 12 20:28:54 2017 New Revision: 326810 URL: https://svnweb.freebsd.org/changeset/base/326810 Log: MFC r326282, r326317: Remap ENOATTR to ENODATA in the linuxulator. In the linux ENOADATA is frequently #defined as ENOATTR. The change is required for an xattrs support implementation. Sync bsd_to_linux_errno[] table with i386 and amd64 tables in the sys directory. Discussed with: netchild Requested by: jhb Approved by: pfg (mentor) Modified: stable/11/lib/libsysdecode/errno.c stable/11/sys/amd64/linux/linux_sysvec.c stable/11/sys/amd64/linux32/linux32_sysvec.c stable/11/sys/i386/linux/linux_sysvec.c Modified: stable/11/lib/libsysdecode/errno.c == --- stable/11/lib/libsysdecode/errno.c Tue Dec 12 20:22:09 2017 (r326809) +++ stable/11/lib/libsysdecode/errno.c Tue Dec 12 20:28:54 2017 (r326810) @@ -53,7 +53,7 @@ static int bsd_to_linux_errno[ELAST + 1] = { -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, + -6, -6, -43, -42, -75,-125, -84, -61, -16, -74, -72, -67, -71 }; #endif Modified: stable/11/sys/amd64/linux/linux_sysvec.c == --- stable/11/sys/amd64/linux/linux_sysvec.cTue Dec 12 20:22:09 2017 (r326809) +++ stable/11/sys/amd64/linux/linux_sysvec.cTue Dec 12 20:28:54 2017 (r326810) @@ -147,7 +147,7 @@ static int bsd_to_linux_errno[ELAST + 1] = { -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, + -6, -6, -43, -42, -75,-125, -84, -61, -16, -74, -72, -67, -71 }; Modified: stable/11/sys/amd64/linux32/linux32_sysvec.c == --- stable/11/sys/amd64/linux32/linux32_sysvec.cTue Dec 12 20:22:09 2017(r326809) +++ stable/11/sys/amd64/linux32/linux32_sysvec.cTue Dec 12 20:28:54 2017(r326810) @@ -146,7 +146,7 @@ static int bsd_to_linux_errno[ELAST + 1] = { -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, + -6, -6, -43, -42, -75,-125, -84, -61, -16, -74, -72, -67, -71 }; Modified: stable/11/sys/i386/linux/linux_sysvec.c == --- stable/11/sys/i386/linux/linux_sysvec.c Tue Dec 12 20:22:09 2017 (r326809) +++ stable/11/sys/i386/linux/linux_sysvec.c Tue Dec 12 20:28:54 2017 (r326810) @@ -145,7 +145,7 @@ static int bsd_to_linux_errno[ELAST + 1] = { -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, + -6, -6, -43, -42, -75,-125, -84, -61, -16, -74, -72, -67, -71 }; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326808 - head/sys/kern
Author: fsu Date: Tue Dec 12 20:15:57 2017 New Revision: 326808 URL: https://svnweb.freebsd.org/changeset/base/326808 Log: Move buffer size checks outside of the vnode locks. Reviewed by:kib, cem, pfg (mentor) Approved by:pfg (mentor) MFC after: 1 weeks Differential Revision:https://reviews.freebsd.org/D13405 Modified: head/sys/kern/vfs_extattr.c Modified: head/sys/kern/vfs_extattr.c == --- head/sys/kern/vfs_extattr.c Tue Dec 12 20:02:48 2017(r326807) +++ head/sys/kern/vfs_extattr.c Tue Dec 12 20:15:57 2017(r326808) @@ -167,6 +167,9 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, co ssize_t cnt; int error; + if (nbytes > IOSIZE_MAX) + return (EINVAL); + error = vn_start_write(vp, , V_WAIT | PCATCH); if (error) return (error); @@ -177,10 +180,6 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, co auio.uio_iov = auio.uio_iovcnt = 1; auio.uio_offset = 0; - if (nbytes > IOSIZE_MAX) { - error = EINVAL; - goto done; - } auio.uio_resid = nbytes; auio.uio_rw = UIO_WRITE; auio.uio_segflg = UIO_USERSPACE; @@ -330,6 +329,9 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, co size_t size, *sizep; int error; + if (nbytes > IOSIZE_MAX) + return (EINVAL); + vn_lock(vp, LK_SHARED | LK_RETRY); /* @@ -346,10 +348,6 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, co auio.uio_iov = auio.uio_iovcnt = 1; auio.uio_offset = 0; - if (nbytes > IOSIZE_MAX) { - error = EINVAL; - goto done; - } auio.uio_resid = nbytes; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; @@ -638,6 +636,9 @@ extattr_list_vp(struct vnode *vp, int attrnamespace, v ssize_t cnt; int error; + if (nbytes > IOSIZE_MAX) + return (EINVAL); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); auiop = NULL; @@ -649,10 +650,6 @@ extattr_list_vp(struct vnode *vp, int attrnamespace, v auio.uio_iov = auio.uio_iovcnt = 1; auio.uio_offset = 0; - if (nbytes > IOSIZE_MAX) { - error = EINVAL; - goto done; - } auio.uio_resid = nbytes; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326807 - head/sys/fs/ext2fs
Author: fsu Date: Tue Dec 12 20:02:48 2017 New Revision: 326807 URL: https://svnweb.freebsd.org/changeset/base/326807 Log: Fix extattr getters in case of neither uio nor buffer was not passed to VOP_*. Approved by:pfg (mentor) MFC after: 2 weeks Differential Revision:https://reviews.freebsd.org/D13359 Modified: head/sys/fs/ext2fs/ext2_extattr.c Modified: head/sys/fs/ext2fs/ext2_extattr.c == --- head/sys/fs/ext2fs/ext2_extattr.c Tue Dec 12 19:45:24 2017 (r326806) +++ head/sys/fs/ext2fs/ext2_extattr.c Tue Dec 12 20:02:48 2017 (r326807) @@ -220,9 +220,10 @@ ext2_extattr_inode_list(struct inode *ip, int attrname return (ENOTSUP); } - if (uio == NULL) + if (size != NULL) *size += name_len + 1; - else { + + if (uio != NULL) { char *name = malloc(name_len + 1, M_TEMP, M_WAITOK); name[0] = name_len; memcpy([1], attr_name, name_len); @@ -286,9 +287,10 @@ ext2_extattr_block_list(struct inode *ip, int attrname return (ENOTSUP); } - if (uio == NULL) + if (size != NULL) *size += name_len + 1; - else { + + if (uio != NULL) { char *name = malloc(name_len + 1, M_TEMP, M_WAITOK); name[0] = name_len; memcpy([1], attr_name, name_len); @@ -361,12 +363,12 @@ ext2_extattr_inode_get(struct inode *ip, int attrnames if (strlen(name) == name_len && 0 == strncmp(attr_name, name, name_len)) { - if (uio == NULL) + if (size != NULL) *size += entry->e_value_size; - else { + + if (uio != NULL) error = uiomove(((char *)EXT2_IFIRST(header)) + entry->e_value_offs, entry->e_value_size, uio); - } brelse(bp); return (error); @@ -428,12 +430,12 @@ ext2_extattr_block_get(struct inode *ip, int attrnames if (strlen(name) == name_len && 0 == strncmp(attr_name, name, name_len)) { - if (uio == NULL) + if (size != NULL) *size += entry->e_value_size; - else { + + if (uio != NULL) error = uiomove(bp->b_data + entry->e_value_offs, entry->e_value_size, uio); - } brelse(bp); return (error); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326317 - head/lib/libsysdecode
Author: fsu Date: Tue Nov 28 16:25:46 2017 New Revision: 326317 URL: https://svnweb.freebsd.org/changeset/base/326317 Log: Sync bsd_to_linux_errno[] table with i386 and amd64 tables in the sys directory. Additional fix for r326282. MFC after: 1 week Approved by: pfg Modified: head/lib/libsysdecode/errno.c Modified: head/lib/libsysdecode/errno.c == --- head/lib/libsysdecode/errno.c Tue Nov 28 16:09:02 2017 (r326316) +++ head/lib/libsysdecode/errno.c Tue Nov 28 16:25:46 2017 (r326317) @@ -53,7 +53,7 @@ static int bsd_to_linux_errno[ELAST + 1] = { -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, + -6, -6, -43, -42, -75,-125, -84, -61, -16, -74, -72, -67, -71 }; #endif ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326282 - in head/sys: amd64/linux amd64/linux32 i386/linux
Author: fsu Date: Mon Nov 27 17:03:11 2017 New Revision: 326282 URL: https://svnweb.freebsd.org/changeset/base/326282 Log: Remap ENOATTR to ENODATA in the linuxulator. In the linux ENOADATA is frequently #defined as ENOATTR. The change is required for an xattrs support implementation. MFC after: 1 week Discussed with: netchild Approved by: pfg Differential Revision: https://reviews.freebsd.org/D13221 Modified: head/sys/amd64/linux/linux_sysvec.c head/sys/amd64/linux32/linux32_sysvec.c head/sys/i386/linux/linux_sysvec.c Modified: head/sys/amd64/linux/linux_sysvec.c == --- head/sys/amd64/linux/linux_sysvec.c Mon Nov 27 16:28:28 2017 (r326281) +++ head/sys/amd64/linux/linux_sysvec.c Mon Nov 27 17:03:11 2017 (r326282) @@ -147,7 +147,7 @@ static int bsd_to_linux_errno[ELAST + 1] = { -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, + -6, -6, -43, -42, -75,-125, -84, -61, -16, -74, -72, -67, -71 }; Modified: head/sys/amd64/linux32/linux32_sysvec.c == --- head/sys/amd64/linux32/linux32_sysvec.c Mon Nov 27 16:28:28 2017 (r326281) +++ head/sys/amd64/linux32/linux32_sysvec.c Mon Nov 27 17:03:11 2017 (r326282) @@ -148,7 +148,7 @@ static int bsd_to_linux_errno[ELAST + 1] = { -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, + -6, -6, -43, -42, -75,-125, -84, -61, -16, -74, -72, -67, -71 }; Modified: head/sys/i386/linux/linux_sysvec.c == --- head/sys/i386/linux/linux_sysvec.c Mon Nov 27 16:28:28 2017 (r326281) +++ head/sys/i386/linux/linux_sysvec.c Mon Nov 27 17:03:11 2017 (r326282) @@ -147,7 +147,7 @@ static int bsd_to_linux_errno[ELAST + 1] = { -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, + -6, -6, -43, -42, -75,-125, -84, -61, -16, -74, -72, -67, -71 }; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r325745 - stable/11/sys/fs/ext2fs
Author: fsu Date: Sun Nov 12 18:06:43 2017 New Revision: 325745 URL: https://svnweb.freebsd.org/changeset/base/325745 Log: MFC r324962: Set doreallocblks sysctl value to zero by default because of possibility of filesystem corruption. Approved by:pfg (mentor) Modified: stable/11/sys/fs/ext2fs/ext2_alloc.c Modified: stable/11/sys/fs/ext2fs/ext2_alloc.c == --- stable/11/sys/fs/ext2fs/ext2_alloc.cSun Nov 12 17:15:54 2017 (r325744) +++ stable/11/sys/fs/ext2fs/ext2_alloc.cSun Nov 12 18:06:43 2017 (r325745) @@ -172,7 +172,7 @@ static int doasyncfree = 1; SYSCTL_INT(_vfs_ext2fs, OID_AUTO, doasyncfree, CTLFLAG_RW, , 0, "Use asychronous writes to update block pointers when freeing blocks"); -static int doreallocblks = 1; +static int doreallocblks = 0; SYSCTL_INT(_vfs_ext2fs, OID_AUTO, doreallocblks, CTLFLAG_RW, , 0, ""); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r325161 - stable/11/sys/fs/fuse
Author: fsu Date: Mon Oct 30 18:03:33 2017 New Revision: 325161 URL: https://svnweb.freebsd.org/changeset/base/325161 Log: MFC r324620: Add extended attributes support to fuse kernel module. Author: ken Reviewed by:cem, pfg (mentor) Approved by:pfg (mentor) Differential Revision: https://reviews.freebsd.org/D12485 Modified: stable/11/sys/fs/fuse/fuse_ipc.c stable/11/sys/fs/fuse/fuse_vnops.c Modified: stable/11/sys/fs/fuse/fuse_ipc.c == --- stable/11/sys/fs/fuse/fuse_ipc.cMon Oct 30 15:57:48 2017 (r325160) +++ stable/11/sys/fs/fuse/fuse_ipc.cMon Oct 30 18:03:33 2017 (r325161) @@ -636,23 +636,20 @@ fuse_body_audit(struct fuse_ticket *ftick, size_t blen break; case FUSE_SETXATTR: - panic("FUSE_SETXATTR implementor has forgotten to define a" - " response body format check"); + err = (blen == 0) ? 0 : EINVAL; break; case FUSE_GETXATTR: - panic("FUSE_GETXATTR implementor has forgotten to define a" - " response body format check"); - break; - case FUSE_LISTXATTR: - panic("FUSE_LISTXATTR implementor has forgotten to define a" - " response body format check"); + /* +* These can have varying response lengths, and 0 length +* isn't necessarily invalid. +*/ + err = 0; break; case FUSE_REMOVEXATTR: - panic("FUSE_REMOVEXATTR implementor has forgotten to define a" - " response body format check"); + err = (blen == 0) ? 0 : EINVAL; break; case FUSE_FLUSH: Modified: stable/11/sys/fs/fuse/fuse_vnops.c == --- stable/11/sys/fs/fuse/fuse_vnops.c Mon Oct 30 15:57:48 2017 (r325160) +++ stable/11/sys/fs/fuse/fuse_vnops.c Mon Oct 30 18:03:33 2017 (r325161) @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -111,10 +112,13 @@ __FBSDID("$FreeBSD$"); static vop_access_t fuse_vnop_access; static vop_close_t fuse_vnop_close; static vop_create_t fuse_vnop_create; +static vop_deleteextattr_t fuse_vnop_deleteextattr; static vop_fsync_t fuse_vnop_fsync; static vop_getattr_t fuse_vnop_getattr; +static vop_getextattr_t fuse_vnop_getextattr; static vop_inactive_t fuse_vnop_inactive; static vop_link_t fuse_vnop_link; +static vop_listextattr_t fuse_vnop_listextattr; static vop_lookup_t fuse_vnop_lookup; static vop_mkdir_t fuse_vnop_mkdir; static vop_mknod_t fuse_vnop_mknod; @@ -127,6 +131,7 @@ static vop_remove_t fuse_vnop_remove; static vop_rename_t fuse_vnop_rename; static vop_rmdir_t fuse_vnop_rmdir; static vop_setattr_t fuse_vnop_setattr; +static vop_setextattr_t fuse_vnop_setextattr; static vop_strategy_t fuse_vnop_strategy; static vop_symlink_t fuse_vnop_symlink; static vop_write_t fuse_vnop_write; @@ -139,10 +144,13 @@ struct vop_vector fuse_vnops = { .vop_access = fuse_vnop_access, .vop_close = fuse_vnop_close, .vop_create = fuse_vnop_create, + .vop_deleteextattr = fuse_vnop_deleteextattr, .vop_fsync = fuse_vnop_fsync, .vop_getattr = fuse_vnop_getattr, + .vop_getextattr = fuse_vnop_getextattr, .vop_inactive = fuse_vnop_inactive, .vop_link = fuse_vnop_link, + .vop_listextattr = fuse_vnop_listextattr, .vop_lookup = fuse_vnop_lookup, .vop_mkdir = fuse_vnop_mkdir, .vop_mknod = fuse_vnop_mknod, @@ -156,6 +164,7 @@ struct vop_vector fuse_vnops = { .vop_rename = fuse_vnop_rename, .vop_rmdir = fuse_vnop_rmdir, .vop_setattr = fuse_vnop_setattr, + .vop_setextattr = fuse_vnop_setextattr, .vop_strategy = fuse_vnop_strategy, .vop_symlink = fuse_vnop_symlink, .vop_write = fuse_vnop_write, @@ -1955,6 +1964,383 @@ fuse_vnop_putpages(struct vop_putpages_args *ap) } } return rtvals[0]; +} + +static const char extattr_namespace_separator = '.'; + +/* +struct vop_getextattr_args { +struct vop_generic_args a_gen; +struct vnode *a_vp; +int a_attrnamespace; +const char *a_name; +struct uio *a_uio; +size_t *a_size; +struct ucred *a_cred; +struct thread *a_td; +}; +*/ +static int +fuse_vnop_getextattr(struct vop_getextattr_args *ap) +{ + struct vnode *vp = ap->a_vp; + struct uio *uio = ap->a_uio; + struct fuse_dispatcher fdi = {0}; + struct fuse_getxattr_in *get_xattr_in; + struct fuse_getxattr_out *get_xattr_out; + struct mount *mp = vnode_mount(vp); + char *prefix; + size_t len; +
svn commit: r324963 - head/sys/fs/ext2fs
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.hTue Oct 24 19:16:25 2017 (r324962) +++ head/sys/fs/ext2fs/ext2_extern.hTue Oct 24 20:10:08 2017 (r324963) @@ -51,7 +51,7 @@ struct vnode; intext2_add_entry(struct vnode *, struct ext2fs_direct_2 *); intext2_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); intext2_balloc(struct inode *, e2fs_lbn_t, int, struct ucred *, struct buf **, int); intext2_blkatoff(struct vnode *, off_t, char **, struct buf **); @@ -61,7 +61,7 @@ e4fs_daddr_t ext2_blkpref(struct inode *, e2fs_lbn_t, intext2_bmap(struct vop_bmap_args *); intext2_bmaparray(struct vnode *, daddr_t, daddr_t *, int *, int *); intext4_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) +++
svn commit: r324962 - head/sys/fs/ext2fs
Author: fsu Date: Tue Oct 24 19:16:25 2017 New Revision: 324962 URL: https://svnweb.freebsd.org/changeset/base/324962 Log: Set doreallocblks sysctl value to zero by default because of possibility of filesystem corruption. Approved by:pfg (mentor) MFC after: 2 weeks Modified: head/sys/fs/ext2fs/ext2_alloc.c Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Tue Oct 24 19:14:33 2017 (r324961) +++ head/sys/fs/ext2fs/ext2_alloc.c Tue Oct 24 19:16:25 2017 (r324962) @@ -173,7 +173,7 @@ static int doasyncfree = 1; SYSCTL_INT(_vfs_ext2fs, OID_AUTO, doasyncfree, CTLFLAG_RW, , 0, "Use asychronous writes to update block pointers when freeing blocks"); -static int doreallocblks = 1; +static int doreallocblks = 0; SYSCTL_INT(_vfs_ext2fs, OID_AUTO, doreallocblks, CTLFLAG_RW, , 0, ""); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r324961 - head/sys/fs/ext2fs
Author: fsu Date: Tue Oct 24 19:14:33 2017 New Revision: 324961 URL: https://svnweb.freebsd.org/changeset/base/324961 Log: Do not free bufs in case of extents metadata blocks + remove unneeded asserts. Approved by:pfg (mentor) MFC after: 6 months Modified: head/sys/fs/ext2fs/ext2_extents.c Modified: head/sys/fs/ext2fs/ext2_extents.c == --- head/sys/fs/ext2fs/ext2_extents.c Tue Oct 24 17:14:53 2017 (r324960) +++ head/sys/fs/ext2fs/ext2_extents.c Tue Oct 24 19:14:33 2017 (r324961) @@ -420,7 +420,7 @@ ext4_ext_find_extent(struct inode *ip, daddr_t block, } ext4_ext_fill_path_bdata([ppos], bp, blk); - brelse(bp); + bqrelse(bp); eh = ext4_ext_block_header(path[ppos].ep_data); error = ext4_ext_check_header(ip, eh); @@ -1228,7 +1228,7 @@ ext4_ext_get_blocks(struct inode *ip, e4fs_daddr_t ibl } if ((ex = path[depth].ep_ext)) { - uint64_t lblk = ex->e_blk; + uint64_t lblk = ex->e_blk; uint16_t e_len = ex->e_len; e4fs_daddr_t e_start = ext4_ext_extent_pblock(ex); @@ -1397,9 +1397,6 @@ ext4_ext_rm_leaf(struct inode *ip, struct ext4_extent_ /* Remove whole extent. */ block = ex_blk; num = 0; - KASSERT(a == ex_blk, ("ext4_ext_rm_leaf: bad a")); - KASSERT(b != ex_blk + ex_len - 1, - ("ext4_ext_rm_leaf: bad b")); } if (ex == EXT_FIRST_EXTENT(eh)) @@ -1508,7 +1505,7 @@ ext4_ext_remove_space(struct inode *ip, off_t length, return (error); path = malloc(sizeof(struct ext4_extent_path) * (depth + 1), - M_EXT2EXTENTS, M_WAITOK | M_ZERO); + M_EXT2EXTENTS, M_WAITOK | M_ZERO); if (!path) return (ENOMEM); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r324759 - head/sys/fs/ext2fs
Author: fsu Date: Thu Oct 19 16:42:03 2017 New Revision: 324759 URL: https://svnweb.freebsd.org/changeset/base/324759 Log: Fix unused variable + style(9) fixes inside the ext4_ext_find_extent() Approved by:pfg (mentor) Reported by:Coverity CID:1381754 MFC after: 6 months Modified: head/sys/fs/ext2fs/ext2_extents.c Modified: head/sys/fs/ext2fs/ext2_extents.c == --- head/sys/fs/ext2fs/ext2_extents.c Thu Oct 19 16:40:17 2017 (r324758) +++ head/sys/fs/ext2fs/ext2_extents.c Thu Oct 19 16:42:03 2017 (r324759) @@ -377,11 +377,11 @@ ext4_ext_find_extent(struct inode *ip, daddr_t block, if (error) return (error); - if (!ppath) + if (ppath == NULL) return (EINVAL); path = *ppath; - if (!path) { + if (path == NULL) { path = malloc(EXT4_EXT_DEPTH_MAX * sizeof(struct ext4_extent_path), M_EXT2EXTENTS, M_WAITOK | M_ZERO); @@ -1349,7 +1349,7 @@ ext4_ext_rm_leaf(struct inode *ip, struct ext4_extent_ uint64_t start) { struct m_ext2fs *fs; - int depth, credits; + int depth; struct ext4_extent_header *eh; unsigned int a, b, block, num; unsigned long ex_blk; @@ -1402,11 +1402,8 @@ ext4_ext_rm_leaf(struct inode *ip, struct ext4_extent_ ("ext4_ext_rm_leaf: bad b")); } - credits = EXT4_EXT_DEPTH_MAX; - if (ex == EXT_FIRST_EXTENT(eh)) { + if (ex == EXT_FIRST_EXTENT(eh)) correct_index = 1; - credits += (ext4_ext_inode_depth(ip)) + 1; - } error = ext4_remove_blocks(ip, ex, a, b); if (error) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r324713 - head/sys/fs/ext2fs
Ryan, Seems like, I lost the dual declaration when made the merging and then did not check the gcc build. Thanks for fix. On Wed, Oct 18, 2017 at 12:41 AM, Ryan Libbywrote: > Author: rlibby > Date: Wed Oct 18 00:41:23 2017 > New Revision: 324713 > URL: https://svnweb.freebsd.org/changeset/base/324713 > > Log: > ext2: delete redundant decl of ext2_fserr > > Fix gcc build after r324706. > > Reviewed by: pfg > Differential Revision:https://reviews.freebsd.org/D12709 > > Modified: > head/sys/fs/ext2fs/ext2_extern.h > > Modified: head/sys/fs/ext2fs/ext2_extern.h > > == > --- head/sys/fs/ext2fs/ext2_extern.hWed Oct 18 00:33:20 2017 > (r324712) > +++ head/sys/fs/ext2fs/ext2_extern.hWed Oct 18 00:41:23 2017 > (r324713) > @@ -102,7 +102,6 @@ int ext2_search_dirblock(struct inode *, void *, int * > int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot > *); > intext2_gd_csum_verify(struct m_ext2fs *fs, struct cdev *dev); > void ext2_gd_csum_set(struct m_ext2fs *fs); > -void ext2_fserr(struct m_ext2fs *, uid_t, char *); > > > /* Flags to low-level allocation routines. > > ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r324706 - head/sys/fs/ext2fs
Author: fsu Date: Tue Oct 17 20:45:44 2017 New Revision: 324706 URL: https://svnweb.freebsd.org/changeset/base/324706 Log: Add inital extents read-write support. Approved by:pfg (mentor) MFC after: 6 months RelNotes: Yes Differential Revision:https://reviews.freebsd.org/D12087 Modified: head/sys/fs/ext2fs/ext2_alloc.c head/sys/fs/ext2fs/ext2_balloc.c head/sys/fs/ext2fs/ext2_bmap.c head/sys/fs/ext2fs/ext2_extattr.c head/sys/fs/ext2fs/ext2_extents.c head/sys/fs/ext2fs/ext2_extents.h head/sys/fs/ext2fs/ext2_extern.h head/sys/fs/ext2fs/ext2_inode.c head/sys/fs/ext2fs/ext2_inode_cnv.c head/sys/fs/ext2fs/ext2_subr.c head/sys/fs/ext2fs/ext2_vfsops.c head/sys/fs/ext2fs/ext2_vnops.c head/sys/fs/ext2fs/ext2fs.h head/sys/fs/ext2fs/inode.h Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Tue Oct 17 20:37:31 2017 (r324705) +++ head/sys/fs/ext2fs/ext2_alloc.c Tue Oct 17 20:45:44 2017 (r324706) @@ -135,19 +135,20 @@ nospace: * Allocate EA's block for inode. */ daddr_t -ext2_allocfacl(struct inode *ip) +ext2_alloc_meta(struct inode *ip) { struct m_ext2fs *fs; - daddr_t facl; + daddr_t blk; fs = ip->i_e2fs; EXT2_LOCK(ip->i_ump); - facl = ext2_alloccg(ip, ino_to_cg(fs, ip->i_number), 0, fs->e2fs_bsize); - if (0 == facl) + blk = ext2_hashalloc(ip, ino_to_cg(fs, ip->i_number), 0, fs->e2fs_bsize, + ext2_alloccg); + if (0 == blk) EXT2_UNLOCK(ip->i_ump); - return (facl); + return (blk); } /* @@ -200,7 +201,7 @@ ext2_reallocblks(struct vop_reallocblks_args *ap) fs = ip->i_e2fs; ump = ip->i_ump; - if (fs->e2fs_contigsumsize <= 0) + if (fs->e2fs_contigsumsize <= 0 || ip->i_flag & IN_E4EXTENTS) return (ENOSPC); buflist = ap->a_buflist; @@ -375,7 +376,7 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred struct inode *ip; struct ext2mount *ump; ino_t ino, ipref; - int i, error, cg; + int error, cg; *vpp = NULL; pip = VTOI(pvp); @@ -421,11 +422,12 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred ip->i_blocks = 0; ip->i_mode = 0; ip->i_flags = 0; - /* now we want to make sure that the block pointers are zeroed out */ - for (i = 0; i < EXT2_NDADDR; i++) - ip->i_db[i] = 0; - for (i = 0; i < EXT2_NIADDR; i++) - ip->i_ib[i] = 0; + if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_EXTENTS) + && (S_ISREG(mode) || S_ISDIR(mode))) + ext4_ext_tree_init(ip); + else + memset(ip->i_data, 0, sizeof(ip->i_data)); + /* * Set up a new generation number for this inode. @@ -575,8 +577,11 @@ e4fs_daddr_t ext2_blkpref(struct inode *ip, e2fs_lbn_t lbn, int indx, e2fs_daddr_t *bap, e2fs_daddr_t blocknr) { + struct m_ext2fs *fs; int tmp; + fs = ip->i_e2fs; + mtx_assert(EXT2_MTX(ip->i_ump), MA_OWNED); /* @@ -599,10 +604,9 @@ ext2_blkpref(struct inode *ip, e2fs_lbn_t lbn, int ind * Else lets fall back to the blocknr or, if there is none, follow * the rule that a block should be allocated near its inode. */ - return blocknr ? blocknr : + return (blocknr ? blocknr : (e2fs_daddr_t)(ip->i_block_group * - EXT2_BLOCKS_PER_GROUP(ip->i_e2fs)) + - ip->i_e2fs->e2fs->e2fs_first_dblock; + EXT2_BLOCKS_PER_GROUP(fs)) + fs->e2fs->e2fs_first_dblock); } /* Modified: head/sys/fs/ext2fs/ext2_balloc.c == --- head/sys/fs/ext2fs/ext2_balloc.cTue Oct 17 20:37:31 2017 (r324705) +++ head/sys/fs/ext2fs/ext2_balloc.cTue Oct 17 20:45:44 2017 (r324706) @@ -51,6 +51,76 @@ #include #include +static int +ext2_ext_balloc(struct inode *ip, uint32_t lbn, int size, +struct ucred *cred, struct buf **bpp, int flags) +{ + struct m_ext2fs *fs; + struct buf *bp = NULL; + struct vnode *vp = ITOV(ip); + uint32_t nb; + int osize, nsize, blks, error, allocated; + + fs = ip->i_e2fs; + blks = howmany(size, fs->e2fs_bsize); + + error = ext4_ext_get_blocks(ip, lbn, blks, cred, NULL, , ); + if (error) + return (error); + + if (allocated) { + if (ip->i_size < (lbn + 1) * fs->e2fs_bsize) + nsize = fragroundup(fs, size); + else + nsize = fs->e2fs_bsize; + + bp = getblk(vp, lbn, nsize, 0, 0, 0); + if(!bp) + return (EIO); + + bp->b_blkno = fsbtodb(fs, nb); + if (flags & BA_CLRBUF) +
svn commit: r324627 - stable/11/sys/fs/ext2fs
Author: fsu Date: Sun Oct 15 14:03:53 2017 New Revision: 324627 URL: https://svnweb.freebsd.org/changeset/base/324627 Log: MFC r324064: Add check to avoid raw inode iblocks fields overflow in case of huge_file feature. Use the Linux logic for now. Approved by:pfg (mentor) Differential Revision: https://reviews.freebsd.org/D12131 Modified: stable/11/sys/fs/ext2fs/ext2_alloc.c stable/11/sys/fs/ext2fs/ext2_extern.h stable/11/sys/fs/ext2fs/ext2_inode.c stable/11/sys/fs/ext2fs/ext2_inode_cnv.c Modified: stable/11/sys/fs/ext2fs/ext2_alloc.c == --- stable/11/sys/fs/ext2fs/ext2_alloc.cSun Oct 15 11:46:11 2017 (r324626) +++ stable/11/sys/fs/ext2fs/ext2_alloc.cSun Oct 15 14:03:53 2017 (r324627) @@ -56,7 +56,6 @@ 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 voidext2_fserr(struct m_ext2fs *, uid_t, char *); static u_long ext2_hashalloc(struct inode *, int, long, int, daddr_t (*)(struct inode *, int, daddr_t, int)); @@ -1303,7 +1302,7 @@ ext2_mapsearch(struct m_ext2fs *fs, char *bbp, daddr_t * The form of the error message is: * fs: error message */ -static void +void ext2_fserr(struct m_ext2fs *fs, uid_t uid, char *cp) { Modified: stable/11/sys/fs/ext2fs/ext2_extern.h == --- stable/11/sys/fs/ext2fs/ext2_extern.h Sun Oct 15 11:46:11 2017 (r324626) +++ stable/11/sys/fs/ext2fs/ext2_extern.h Sun Oct 15 14:03:53 2017 (r324627) @@ -62,9 +62,10 @@ int ext2_bmap(struct vop_bmap_args *); intext2_bmaparray(struct vnode *, daddr_t, daddr_t *, int *, int *); void ext2_clusteracct(struct m_ext2fs *, char *, int, 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 *); intext2_getlbns(struct vnode *, daddr_t, struct indir *, int *); -void ext2_i2ei(struct inode *, struct ext2fs_dinode *); +intext2_i2ei(struct inode *, struct ext2fs_dinode *); void ext2_itimes(struct vnode *vp); intext2_reallocblks(struct vop_reallocblks_args *); intext2_reclaim(struct vop_reclaim_args *); Modified: stable/11/sys/fs/ext2fs/ext2_inode.c == --- stable/11/sys/fs/ext2fs/ext2_inode.cSun Oct 15 11:46:11 2017 (r324626) +++ stable/11/sys/fs/ext2fs/ext2_inode.cSun Oct 15 14:03:53 2017 (r324627) @@ -90,8 +90,12 @@ ext2_update(struct vnode *vp, int waitfor) brelse(bp); return (error); } - ext2_i2ei(ip, (struct ext2fs_dinode *)((char *)bp->b_data + + error = ext2_i2ei(ip, (struct ext2fs_dinode *)((char *)bp->b_data + EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number))); + if (error) { + brelse(bp); + return (error); + } if (waitfor && !DOINGASYNC(vp)) return (bwrite(bp)); else { Modified: stable/11/sys/fs/ext2fs/ext2_inode_cnv.c == --- stable/11/sys/fs/ext2fs/ext2_inode_cnv.cSun Oct 15 11:46:11 2017 (r324626) +++ stable/11/sys/fs/ext2fs/ext2_inode_cnv.cSun Oct 15 14:03:53 2017 (r324627) @@ -136,11 +136,13 @@ ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) /* * inode to raw ext2 inode */ -void +int ext2_i2ei(struct inode *ip, struct ext2fs_dinode *ei) { + struct m_ext2fs *fs; int i; + fs = ip->i_e2fs; ei->e2di_mode = ip->i_mode; ei->e2di_nlink = ip->i_nlink; /* @@ -167,8 +169,19 @@ ext2_i2ei(struct inode *ip, struct ext2fs_dinode *ei) ei->e2di_flags |= (ip->i_flags & UF_NODUMP) ? EXT2_NODUMP : 0; ei->e2di_flags |= (ip->i_flag & IN_E3INDEX) ? EXT3_INDEX : 0; ei->e2di_flags |= (ip->i_flag & IN_E4EXTENTS) ? EXT4_EXTENTS : 0; - ei->e2di_nblock = ip->i_blocks & 0x; - ei->e2di_nblock_high = ip->i_blocks >> 32 & 0x; + if (ip->i_blocks > ~0U && + !EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_HUGE_FILE)) { + ext2_fserr(fs, ip->i_uid, "i_blocks value is out of range"); + return (EIO); + } + if (ip->i_blocks <= 0xULL) { + ei->e2di_nblock = ip->i_blocks & 0x; + ei->e2di_nblock_high = ip->i_blocks >> 32 & 0x; + } else { + ei->e2di_flags |= EXT4_HUGE_FILE; + ei->e2di_nblock = dbtofsb(fs, ip->i_blocks); + ei->e2di_nblock_high =
Re: svn commit: r324620 - head/sys/fs/fuse
Stefan, Can not answer your question because I just integrated the @ken's patch. Thanks. On Sun, Oct 15, 2017 at 6:55 AM, Stefan Esser <s...@freebsd.org> wrote: > Am 14.10.17 um 21:02 schrieb Fedor Uporov: > > Author: fsu > > Date: Sat Oct 14 19:02:52 2017 > > New Revision: 324620 > > URL: https://svnweb.freebsd.org/changeset/base/324620 > > > > Log: > > Add extended attributes support to fuse kernel module. > > > > Author: kem > > Reviewed by:cem, pfg (mentor) > > Approved by:pfg (mentor) > > MFC after: 2 weeks > > > > Differential Revision: https://reviews.freebsd.org/D12485 > > Should any of these defines have been updated? > > /sys/fuse/fs/fuse.h: > #define FUSE_FREEBSD_VERSION"0.4.4" > > /sys/fuse/fs/fuse_kernel.h: > #define FUSE_KERNEL_VERSION 7 > #define FUSE_KERNEL_MINOR_VERSION 8 > > Regards, STefan > ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r324620 - head/sys/fs/fuse
Author: fsu Date: Sat Oct 14 19:02:52 2017 New Revision: 324620 URL: https://svnweb.freebsd.org/changeset/base/324620 Log: Add extended attributes support to fuse kernel module. Author: kem Reviewed by:cem, pfg (mentor) Approved by:pfg (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D12485 Modified: head/sys/fs/fuse/fuse_ipc.c head/sys/fs/fuse/fuse_vnops.c Modified: head/sys/fs/fuse/fuse_ipc.c == --- head/sys/fs/fuse/fuse_ipc.c Sat Oct 14 18:38:36 2017(r324619) +++ head/sys/fs/fuse/fuse_ipc.c Sat Oct 14 19:02:52 2017(r324620) @@ -636,23 +636,20 @@ fuse_body_audit(struct fuse_ticket *ftick, size_t blen break; case FUSE_SETXATTR: - panic("FUSE_SETXATTR implementor has forgotten to define a" - " response body format check"); + err = (blen == 0) ? 0 : EINVAL; break; case FUSE_GETXATTR: - panic("FUSE_GETXATTR implementor has forgotten to define a" - " response body format check"); - break; - case FUSE_LISTXATTR: - panic("FUSE_LISTXATTR implementor has forgotten to define a" - " response body format check"); + /* +* These can have varying response lengths, and 0 length +* isn't necessarily invalid. +*/ + err = 0; break; case FUSE_REMOVEXATTR: - panic("FUSE_REMOVEXATTR implementor has forgotten to define a" - " response body format check"); + err = (blen == 0) ? 0 : EINVAL; break; case FUSE_FLUSH: Modified: head/sys/fs/fuse/fuse_vnops.c == --- head/sys/fs/fuse/fuse_vnops.c Sat Oct 14 18:38:36 2017 (r324619) +++ head/sys/fs/fuse/fuse_vnops.c Sat Oct 14 19:02:52 2017 (r324620) @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -112,10 +113,13 @@ __FBSDID("$FreeBSD$"); static vop_access_t fuse_vnop_access; static vop_close_t fuse_vnop_close; static vop_create_t fuse_vnop_create; +static vop_deleteextattr_t fuse_vnop_deleteextattr; static vop_fsync_t fuse_vnop_fsync; static vop_getattr_t fuse_vnop_getattr; +static vop_getextattr_t fuse_vnop_getextattr; static vop_inactive_t fuse_vnop_inactive; static vop_link_t fuse_vnop_link; +static vop_listextattr_t fuse_vnop_listextattr; static vop_lookup_t fuse_vnop_lookup; static vop_mkdir_t fuse_vnop_mkdir; static vop_mknod_t fuse_vnop_mknod; @@ -128,6 +132,7 @@ static vop_remove_t fuse_vnop_remove; static vop_rename_t fuse_vnop_rename; static vop_rmdir_t fuse_vnop_rmdir; static vop_setattr_t fuse_vnop_setattr; +static vop_setextattr_t fuse_vnop_setextattr; static vop_strategy_t fuse_vnop_strategy; static vop_symlink_t fuse_vnop_symlink; static vop_write_t fuse_vnop_write; @@ -140,10 +145,13 @@ struct vop_vector fuse_vnops = { .vop_access = fuse_vnop_access, .vop_close = fuse_vnop_close, .vop_create = fuse_vnop_create, + .vop_deleteextattr = fuse_vnop_deleteextattr, .vop_fsync = fuse_vnop_fsync, .vop_getattr = fuse_vnop_getattr, + .vop_getextattr = fuse_vnop_getextattr, .vop_inactive = fuse_vnop_inactive, .vop_link = fuse_vnop_link, + .vop_listextattr = fuse_vnop_listextattr, .vop_lookup = fuse_vnop_lookup, .vop_mkdir = fuse_vnop_mkdir, .vop_mknod = fuse_vnop_mknod, @@ -157,6 +165,7 @@ struct vop_vector fuse_vnops = { .vop_rename = fuse_vnop_rename, .vop_rmdir = fuse_vnop_rmdir, .vop_setattr = fuse_vnop_setattr, + .vop_setextattr = fuse_vnop_setextattr, .vop_strategy = fuse_vnop_strategy, .vop_symlink = fuse_vnop_symlink, .vop_write = fuse_vnop_write, @@ -1956,6 +1965,383 @@ fuse_vnop_putpages(struct vop_putpages_args *ap) } } return rtvals[0]; +} + +static const char extattr_namespace_separator = '.'; + +/* +struct vop_getextattr_args { +struct vop_generic_args a_gen; +struct vnode *a_vp; +int a_attrnamespace; +const char *a_name; +struct uio *a_uio; +size_t *a_size; +struct ucred *a_cred; +struct thread *a_td; +}; +*/ +static int +fuse_vnop_getextattr(struct vop_getextattr_args *ap) +{ + struct vnode *vp = ap->a_vp; + struct uio *uio = ap->a_uio; + struct fuse_dispatcher fdi = {0}; + struct fuse_getxattr_in *get_xattr_in; + struct fuse_getxattr_out *get_xattr_out; + struct mount *mp = vnode_mount(vp); + char *prefix; + size_t len; + char *attr_str; +
svn commit: r324064 - head/sys/fs/ext2fs
Author: fsu Date: Wed Sep 27 16:12:13 2017 New Revision: 324064 URL: https://svnweb.freebsd.org/changeset/base/324064 Log: Add check to avoid raw inode iblocks fields overflow in case of huge_file feature. Use the Linux logic for now. Reviewed by:pfg (mentor) Approved by:pfg (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D12131 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_inode_cnv.c Modified: head/sys/fs/ext2fs/ext2_alloc.c == --- head/sys/fs/ext2fs/ext2_alloc.c Wed Sep 27 15:29:17 2017 (r324063) +++ head/sys/fs/ext2fs/ext2_alloc.c Wed Sep 27 16:12:13 2017 (r324064) @@ -56,7 +56,6 @@ 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 voidext2_fserr(struct m_ext2fs *, uid_t, char *); static u_long ext2_hashalloc(struct inode *, int, long, int, daddr_t (*)(struct inode *, int, daddr_t, int)); @@ -1303,7 +1302,7 @@ ext2_mapsearch(struct m_ext2fs *fs, char *bbp, daddr_t * The form of the error message is: * fs: error message */ -static void +void ext2_fserr(struct m_ext2fs *fs, uid_t uid, char *cp) { Modified: head/sys/fs/ext2fs/ext2_extern.h == --- head/sys/fs/ext2fs/ext2_extern.hWed Sep 27 15:29:17 2017 (r324063) +++ head/sys/fs/ext2fs/ext2_extern.hWed Sep 27 16:12:13 2017 (r324064) @@ -62,9 +62,10 @@ int ext2_bmap(struct vop_bmap_args *); intext2_bmaparray(struct vnode *, daddr_t, daddr_t *, int *, int *); void ext2_clusteracct(struct m_ext2fs *, char *, int, 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 *); intext2_getlbns(struct vnode *, daddr_t, struct indir *, int *); -void ext2_i2ei(struct inode *, struct ext2fs_dinode *); +intext2_i2ei(struct inode *, struct ext2fs_dinode *); void ext2_itimes(struct vnode *vp); intext2_reallocblks(struct vop_reallocblks_args *); intext2_reclaim(struct vop_reclaim_args *); Modified: head/sys/fs/ext2fs/ext2_inode.c == --- head/sys/fs/ext2fs/ext2_inode.c Wed Sep 27 15:29:17 2017 (r324063) +++ head/sys/fs/ext2fs/ext2_inode.c Wed Sep 27 16:12:13 2017 (r324064) @@ -90,8 +90,12 @@ ext2_update(struct vnode *vp, int waitfor) brelse(bp); return (error); } - ext2_i2ei(ip, (struct ext2fs_dinode *)((char *)bp->b_data + + error = ext2_i2ei(ip, (struct ext2fs_dinode *)((char *)bp->b_data + EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number))); + if (error) { + brelse(bp); + return (error); + } if (waitfor && !DOINGASYNC(vp)) return (bwrite(bp)); else { Modified: head/sys/fs/ext2fs/ext2_inode_cnv.c == --- head/sys/fs/ext2fs/ext2_inode_cnv.c Wed Sep 27 15:29:17 2017 (r324063) +++ head/sys/fs/ext2fs/ext2_inode_cnv.c Wed Sep 27 16:12:13 2017 (r324064) @@ -136,11 +136,13 @@ ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) /* * inode to raw ext2 inode */ -void +int ext2_i2ei(struct inode *ip, struct ext2fs_dinode *ei) { + struct m_ext2fs *fs; int i; + fs = ip->i_e2fs; ei->e2di_mode = ip->i_mode; ei->e2di_nlink = ip->i_nlink; /* @@ -167,8 +169,19 @@ ext2_i2ei(struct inode *ip, struct ext2fs_dinode *ei) ei->e2di_flags |= (ip->i_flags & UF_NODUMP) ? EXT2_NODUMP : 0; ei->e2di_flags |= (ip->i_flag & IN_E3INDEX) ? EXT3_INDEX : 0; ei->e2di_flags |= (ip->i_flag & IN_E4EXTENTS) ? EXT4_EXTENTS : 0; - ei->e2di_nblock = ip->i_blocks & 0x; - ei->e2di_nblock_high = ip->i_blocks >> 32 & 0x; + if (ip->i_blocks > ~0U && + !EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_HUGE_FILE)) { + ext2_fserr(fs, ip->i_uid, "i_blocks value is out of range"); + return (EIO); + } + if (ip->i_blocks <= 0xULL) { + ei->e2di_nblock = ip->i_blocks & 0x; + ei->e2di_nblock_high = ip->i_blocks >> 32 & 0x; + } else { + ei->e2di_flags |= EXT4_HUGE_FILE; + ei->e2di_nblock = dbtofsb(fs, ip->i_blocks); + ei->e2di_nblock_high = dbtofsb(fs, ip->i_blocks) >> 32 & 0x; + }
svn commit: r323972 - head/usr.bin/calendar/calendars
Author: fsu Date: Sun Sep 24 14:36:01 2017 New Revision: 323972 URL: https://svnweb.freebsd.org/changeset/base/323972 Log: Add myself to the calendar.freebsd Reviewed by:pfg (mentor) Approved by:pfg (mentor) Modified: head/usr.bin/calendar/calendars/calendar.freebsd Modified: head/usr.bin/calendar/calendars/calendar.freebsd == --- head/usr.bin/calendar/calendars/calendar.freebsdSun Sep 24 14:22:36 2017(r323971) +++ head/usr.bin/calendar/calendars/calendar.freebsdSun Sep 24 14:36:01 2017(r323972) @@ -419,6 +419,7 @@ 11/23 Luca Pizzamiglio <pizza...@freebsd.org> born in Casalpusterlengo, Italy, 1978 11/24 Andrey Zakhvatov <a...@freebsd.org> born in Chelyabinsk, Russian Federation, 1974 11/24 Daniel Gerzo <dan...@freebsd.org> born in Bratislava, Slovakia, 1986 +11/25 Fedor Uporov <f...@freebsd.org> born in Yalta, Crimea, USSR, 1988 11/28 Nik Clayton <n...@freebsd.org> born in Peterborough, United Kingdom, 1973 11/28 Stanislav Sedov <s...@freebsd.org> born in Chelyabinsk, USSR, 1985 12/01 Hajimu Umemoto <u...@freebsd.org> born in Nara, Japan, 1961 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r323958 - head/share/misc
Author: fsu Date: Sat Sep 23 19:49:12 2017 New Revision: 323958 URL: https://svnweb.freebsd.org/changeset/base/323958 Log: Add myself as src committer. Approved by:pfg (mentor) Modified: head/share/misc/committers-src.dot Modified: head/share/misc/committers-src.dot == --- head/share/misc/committers-src.dot Sat Sep 23 18:37:37 2017 (r323957) +++ head/share/misc/committers-src.dot Sat Sep 23 19:49:12 2017 (r323958) @@ -167,6 +167,7 @@ fabient [label="Fabien Thomas\nfabi...@freebsd.org\n20 fanf [label="Tony Finch\nf...@freebsd.org\n2002/05/05"] fjoe [label="Max Khon\nf...@freebsd.org\n2001/08/06"] flz [label="Florent Thoumie\n...@freebsd.org\n2006/03/30"] +fsu [label="Fedor Uporov\n...@freebsd.org\n2017/08/28"] gabor [label="Gabor Kovesdan\nga...@freebsd.org\n2010/02/02"] gad [label="Garance A. Drosehn\n...@freebsd.org\n2000/10/27"] gallatin [label="Andrew Gallatin\ngalla...@freebsd.org\n1999/01/15"] @@ -689,6 +690,8 @@ obrien -> groudier obrien -> gshapiro obrien -> kan obrien -> sam + +pfg -> fsu peter -> asmodai peter -> jayanth ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"