public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] SGI-PV: Read buffer overflow
@ 2009-08-02 11:18 Roel Kluin
  2009-08-03 19:11 ` Alex Elder
  0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-08-02 11:18 UTC (permalink / raw)
  To: felixb, xfs, Andrew Morton

Check whether index is within bounds before grabbing the element.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 9ff6e57..ef1d275 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -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
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] SGI-PV: Read buffer overflow
  2009-08-02 11:18 [PATCH] SGI-PV: Read buffer overflow Roel Kluin
@ 2009-08-03 19:11 ` Alex Elder
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Elder @ 2009-08-03 19:11 UTC (permalink / raw)
  To: Roel Kluin; +Cc: Andrew Morton, xfs

> Check whether index is within bounds before grabbing the element.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
> index 9ff6e57..ef1d275 100644
> --- a/fs/xfs/xfs_da_btree.c
> +++ b/fs/xfs/xfs_da_btree.c
> @@ -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.

> +		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
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-03 19:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-02 11:18 [PATCH] SGI-PV: Read buffer overflow Roel Kluin
2009-08-03 19:11 ` Alex Elder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox