aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2011-05-11 11:04:06 -0400
committerAlex Elder <aelder@sgi.com>2011-05-25 11:48:37 -0400
commit2f2b3220b0566692da14e06ea5fc0d697a78dc7c (patch)
tree714a8ac9b2bf41f4253eb340b550023f47d5d593 /fs/xfs
parentec90c5563413ba6d29607397c54958d49c3461a3 (diff)
xfs: do not use unchecked extent indices in xfs_bmap_add_extent_*
Make sure to only call xfs_iext_get_ext after we've validate the extent index in the various xfs_bmap_add_extent_* helpers. Based on an earlier patch from Lachlan McIlroy. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Lachlan McIlroy <lmcilroy@redhat.com> Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_bmap.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 8f586df8ff8d..130ec4fa5eaf 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -1629,7 +1629,6 @@ xfs_bmap_add_extent_hole_delay(
1629 xfs_bmbt_irec_t *new, /* new data to add to file extents */ 1629 xfs_bmbt_irec_t *new, /* new data to add to file extents */
1630 int *logflagsp) /* inode logging flags */ 1630 int *logflagsp) /* inode logging flags */
1631{ 1631{
1632 xfs_bmbt_rec_host_t *ep; /* extent record for idx */
1633 xfs_ifork_t *ifp; /* inode fork pointer */ 1632 xfs_ifork_t *ifp; /* inode fork pointer */
1634 xfs_bmbt_irec_t left; /* left neighbor extent entry */ 1633 xfs_bmbt_irec_t left; /* left neighbor extent entry */
1635 xfs_filblks_t newlen=0; /* new indirect size */ 1634 xfs_filblks_t newlen=0; /* new indirect size */
@@ -1639,7 +1638,6 @@ xfs_bmap_add_extent_hole_delay(
1639 xfs_filblks_t temp=0; /* temp for indirect calculations */ 1638 xfs_filblks_t temp=0; /* temp for indirect calculations */
1640 1639
1641 ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); 1640 ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
1642 ep = xfs_iext_get_ext(ifp, *idx);
1643 state = 0; 1641 state = 0;
1644 ASSERT(isnullstartblock(new->br_startblock)); 1642 ASSERT(isnullstartblock(new->br_startblock));
1645 1643
@@ -1660,7 +1658,7 @@ xfs_bmap_add_extent_hole_delay(
1660 */ 1658 */
1661 if (*idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) { 1659 if (*idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) {
1662 state |= BMAP_RIGHT_VALID; 1660 state |= BMAP_RIGHT_VALID;
1663 xfs_bmbt_get_all(ep, &right); 1661 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *idx), &right);
1664 1662
1665 if (isnullstartblock(right.br_startblock)) 1663 if (isnullstartblock(right.br_startblock))
1666 state |= BMAP_RIGHT_DELAY; 1664 state |= BMAP_RIGHT_DELAY;
@@ -1740,7 +1738,8 @@ xfs_bmap_add_extent_hole_delay(
1740 oldlen = startblockval(new->br_startblock) + 1738 oldlen = startblockval(new->br_startblock) +
1741 startblockval(right.br_startblock); 1739 startblockval(right.br_startblock);
1742 newlen = xfs_bmap_worst_indlen(ip, temp); 1740 newlen = xfs_bmap_worst_indlen(ip, temp);
1743 xfs_bmbt_set_allf(ep, new->br_startoff, 1741 xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, *idx),
1742 new->br_startoff,
1744 nullstartblock((int)newlen), temp, right.br_state); 1743 nullstartblock((int)newlen), temp, right.br_state);
1745 trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_); 1744 trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_);
1746 break; 1745 break;
@@ -1780,7 +1779,6 @@ xfs_bmap_add_extent_hole_real(
1780 int *logflagsp, /* inode logging flags */ 1779 int *logflagsp, /* inode logging flags */
1781 int whichfork) /* data or attr fork */ 1780 int whichfork) /* data or attr fork */
1782{ 1781{
1783 xfs_bmbt_rec_host_t *ep; /* pointer to extent entry ins. point */
1784 int error; /* error return value */ 1782 int error; /* error return value */
1785 int i; /* temp state */ 1783 int i; /* temp state */
1786 xfs_ifork_t *ifp; /* inode fork pointer */ 1784 xfs_ifork_t *ifp; /* inode fork pointer */
@@ -1791,7 +1789,6 @@ xfs_bmap_add_extent_hole_real(
1791 1789
1792 ifp = XFS_IFORK_PTR(ip, whichfork); 1790 ifp = XFS_IFORK_PTR(ip, whichfork);
1793 ASSERT(*idx <= ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)); 1791 ASSERT(*idx <= ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t));
1794 ep = xfs_iext_get_ext(ifp, *idx);
1795 state = 0; 1792 state = 0;
1796 1793
1797 if (whichfork == XFS_ATTR_FORK) 1794 if (whichfork == XFS_ATTR_FORK)
@@ -1813,7 +1810,7 @@ xfs_bmap_add_extent_hole_real(
1813 */ 1810 */
1814 if (*idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) { 1811 if (*idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) {
1815 state |= BMAP_RIGHT_VALID; 1812 state |= BMAP_RIGHT_VALID;
1816 xfs_bmbt_get_all(ep, &right); 1813 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *idx), &right);
1817 if (isnullstartblock(right.br_startblock)) 1814 if (isnullstartblock(right.br_startblock))
1818 state |= BMAP_RIGHT_DELAY; 1815 state |= BMAP_RIGHT_DELAY;
1819 } 1816 }
@@ -1925,7 +1922,8 @@ xfs_bmap_add_extent_hole_real(
1925 * Merge the new allocation with the right neighbor. 1922 * Merge the new allocation with the right neighbor.
1926 */ 1923 */
1927 trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_); 1924 trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_);
1928 xfs_bmbt_set_allf(ep, new->br_startoff, new->br_startblock, 1925 xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, *idx),
1926 new->br_startoff, new->br_startblock,
1929 new->br_blockcount + right.br_blockcount, 1927 new->br_blockcount + right.br_blockcount,
1930 right.br_state); 1928 right.br_state);
1931 trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_); 1929 trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_);