Skip to contentSkip to conversation

SGI-PV: Read buffer overflow

PATCH In review Roel Kluin 2 participants 2 messages Aug 2, 2009 – Aug 3, 2009 XFS filesystem

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 SGI-PV: Read buffer overflow

Check whether index is within bounds before grabbing the element.

---

fs/xfs/xfs_da_btree.c +3 -2
index 9ff6e57..ef1d275 100644
@@ -1414,8 +1414,9 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
 	ASSERT(args != NULL);
 	ASSERT(path != NULL);
 	ASSERT((path->active > 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
-	level = (path->active-1) - 1;	/* skip bottom layer in path */
-	for (blk = &path->blk[level]; level >= 0; blk--, level--) {
+	/* skip bottom layer in path */
+	for (level = (path->active-1) - 1; level >= 0; blk--, level--) {
+		blk = &path->blk[level];
 		ASSERT(blk->bp != NULL);
 		node = blk->bp->data;
 		ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw
Quoted 9 lines

Check whether index is within bounds before grabbing the element.

---

fs/xfs/xfs_da_btree.c +0 -0
index 9ff6e57..ef1d275 100644

fs/xfs/xfs_da_btree.c xfs_da_path_shift(xfs_da_state_t · line 1419

Quoted 8 lines
fs/xfs/xfs_da_btree.c +2 -2
@@ -1414,8 +1414,9 @@ xfs_da_path_shift(xfs_da_state_t 
 *state, xfs_da_state_path_t *path,
 	ASSERT(args != NULL);
 	ASSERT(path != NULL);
 	ASSERT((path->active > 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
-	level = (path->active-1) - 1;	/* skip bottom layer in path */
-	for (blk = &path->blk[level]; level >= 0; blk--, level--) {
+	/* skip bottom layer in path */
+	for (level = (path->active-1) - 1; level >= 0; blk--, level--) {

No need to decrement "blk" above. You are reassigning it anyway in the next statement.

Quoted 4 lines
fs/xfs/xfs_da_btree.c +1 -0
+		blk = &path->blk[level];
 		ASSERT(blk->bp != NULL);
 		node = blk->bp->data;

ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);

Note that if level were < 0 upon entry to the loop in its previous form, then the computed value of blk would never have been used.

-Alex

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs