diff options
Diffstat (limited to 'fs/xfs/xfs_ialloc.c')
| -rw-r--r-- | fs/xfs/xfs_ialloc.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index c7142a064c48..0626a32c3447 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
| @@ -24,14 +24,10 @@ | |||
| 24 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
| 25 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
| 26 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
| 27 | #include "xfs_dir2.h" | ||
| 28 | #include "xfs_dmapi.h" | ||
| 29 | #include "xfs_mount.h" | 27 | #include "xfs_mount.h" |
| 30 | #include "xfs_bmap_btree.h" | 28 | #include "xfs_bmap_btree.h" |
| 31 | #include "xfs_alloc_btree.h" | 29 | #include "xfs_alloc_btree.h" |
| 32 | #include "xfs_ialloc_btree.h" | 30 | #include "xfs_ialloc_btree.h" |
| 33 | #include "xfs_dir2_sf.h" | ||
| 34 | #include "xfs_attr_sf.h" | ||
| 35 | #include "xfs_dinode.h" | 31 | #include "xfs_dinode.h" |
| 36 | #include "xfs_inode.h" | 32 | #include "xfs_inode.h" |
| 37 | #include "xfs_btree.h" | 33 | #include "xfs_btree.h" |
| @@ -216,7 +212,7 @@ xfs_ialloc_inode_init( | |||
| 216 | * to log a whole cluster of inodes instead of all the | 212 | * to log a whole cluster of inodes instead of all the |
| 217 | * individual transactions causing a lot of log traffic. | 213 | * individual transactions causing a lot of log traffic. |
| 218 | */ | 214 | */ |
| 219 | xfs_biozero(fbuf, 0, ninodes << mp->m_sb.sb_inodelog); | 215 | xfs_buf_zero(fbuf, 0, ninodes << mp->m_sb.sb_inodelog); |
| 220 | for (i = 0; i < ninodes; i++) { | 216 | for (i = 0; i < ninodes; i++) { |
| 221 | int ioffset = i << mp->m_sb.sb_inodelog; | 217 | int ioffset = i << mp->m_sb.sb_inodelog; |
| 222 | uint isize = sizeof(struct xfs_dinode); | 218 | uint isize = sizeof(struct xfs_dinode); |
| @@ -1217,7 +1213,6 @@ xfs_imap_lookup( | |||
| 1217 | struct xfs_inobt_rec_incore rec; | 1213 | struct xfs_inobt_rec_incore rec; |
| 1218 | struct xfs_btree_cur *cur; | 1214 | struct xfs_btree_cur *cur; |
| 1219 | struct xfs_buf *agbp; | 1215 | struct xfs_buf *agbp; |
| 1220 | xfs_agino_t startino; | ||
| 1221 | int error; | 1216 | int error; |
| 1222 | int i; | 1217 | int i; |
| 1223 | 1218 | ||
| @@ -1231,13 +1226,13 @@ xfs_imap_lookup( | |||
| 1231 | } | 1226 | } |
| 1232 | 1227 | ||
| 1233 | /* | 1228 | /* |
| 1234 | * derive and lookup the exact inode record for the given agino. If the | 1229 | * Lookup the inode record for the given agino. If the record cannot be |
| 1235 | * record cannot be found, then it's an invalid inode number and we | 1230 | * found, then it's an invalid inode number and we should abort. Once |
| 1236 | * should abort. | 1231 | * we have a record, we need to ensure it contains the inode number |
| 1232 | * we are looking up. | ||
| 1237 | */ | 1233 | */ |
| 1238 | cur = xfs_inobt_init_cursor(mp, tp, agbp, agno); | 1234 | cur = xfs_inobt_init_cursor(mp, tp, agbp, agno); |
| 1239 | startino = agino & ~(XFS_IALLOC_INODES(mp) - 1); | 1235 | error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, &i); |
| 1240 | error = xfs_inobt_lookup(cur, startino, XFS_LOOKUP_EQ, &i); | ||
| 1241 | if (!error) { | 1236 | if (!error) { |
| 1242 | if (i) | 1237 | if (i) |
| 1243 | error = xfs_inobt_get_rec(cur, &rec, &i); | 1238 | error = xfs_inobt_get_rec(cur, &rec, &i); |
| @@ -1250,6 +1245,11 @@ xfs_imap_lookup( | |||
| 1250 | if (error) | 1245 | if (error) |
| 1251 | return error; | 1246 | return error; |
| 1252 | 1247 | ||
| 1248 | /* check that the returned record contains the required inode */ | ||
| 1249 | if (rec.ir_startino > agino || | ||
| 1250 | rec.ir_startino + XFS_IALLOC_INODES(mp) <= agino) | ||
| 1251 | return EINVAL; | ||
| 1252 | |||
| 1253 | /* for untrusted inodes check it is allocated first */ | 1253 | /* for untrusted inodes check it is allocated first */ |
| 1254 | if ((flags & XFS_IGET_UNTRUSTED) && | 1254 | if ((flags & XFS_IGET_UNTRUSTED) && |
| 1255 | (rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino))) | 1255 | (rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino))) |
