All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH 2/2] Ocfs2/move_extents: Validate moving goal after the adjustment.
  2011-06-11 19:57 [Ocfs2-devel] [PATCH 2/2] Ocfs2/move_extents: Validate moving goal after the adjustment Mariusz Kozlowski
@ 2011-04-27 22:06 ` Tristan Ye
  0 siblings, 0 replies; 3+ messages in thread
From: Tristan Ye @ 2011-04-27 22:06 UTC (permalink / raw)
  To: ocfs2-devel

On 06/12/2011 03:57 AM, Mariusz Kozlowski wrote:
> Hi,
> 
>   I think this one (ea5e1675 upstream) is wrong. Validation was moved
> before 'bg' was assinged any sane value. Also 'bg' is defined with NULL
> now so it hides real problem that 'bg' is used uninitialized. So currently
> as 'bg' is NULL from the begining it will blow up with null pointer
> dereference somewhere around test in line 489:


You're definitely correct, I'm blaming myself for not making things in
order after moving the validation logic backwards a bit, thanks so much
for pointing this out.

Tristan.

> 
> 489:        if (range->me_goal == le64_to_cpu(bg->bg_blkno))
> 490:	                range->me_goal += c_to_b;
> 
> Sorry for reply with no context but I'm not subscribed to ocfs2-devel.

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

* [Ocfs2-devel] [PATCH 2/2] Ocfs2/move_extents: Validate moving goal after the adjustment.
  2011-05-27  6:32 [Ocfs2-devel] [PATCH 1/2] Ocfs2/move_extents: Avoid doing division in extent moving Tristan Ye
@ 2011-05-27  6:32 ` Tristan Ye
  0 siblings, 0 replies; 3+ messages in thread
From: Tristan Ye @ 2011-05-27  6:32 UTC (permalink / raw)
  To: ocfs2-devel

though the goal_to_be_moved will be validated again in following moving, it's
still a good idea to validate it after adjustment at the very beginning, instead
of validating it before adjustment.

Signed-off-by: Tristan Ye <tristan.ye@oracle.com>
---
 fs/ocfs2/move_extents.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
index d184e0b..cd94270 100644
--- a/fs/ocfs2/move_extents.c
+++ b/fs/ocfs2/move_extents.c
@@ -472,12 +472,24 @@ static int ocfs2_validate_and_adjust_move_goal(struct inode *inode,
 	int ret, goal_bit = 0;
 
 	struct buffer_head *gd_bh = NULL;
-	struct ocfs2_group_desc *bg;
+	struct ocfs2_group_desc *bg = NULL;
 	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
 	int c_to_b = 1 << (osb->s_clustersize_bits -
 					inode->i_sb->s_blocksize_bits);
 
 	/*
+	 * make goal become cluster aligned.
+	 */
+	range->me_goal = ocfs2_block_to_cluster_start(inode->i_sb,
+						      range->me_goal);
+	/*
+	 * moving goal is not allowd to start with a group desc blok(#0 blk)
+	 * let's compromise to the latter cluster.
+	 */
+	if (range->me_goal == le64_to_cpu(bg->bg_blkno))
+		range->me_goal += c_to_b;
+
+	/*
 	 * validate goal sits within global_bitmap, and return the victim
 	 * group desc
 	 */
@@ -491,18 +503,6 @@ static int ocfs2_validate_and_adjust_move_goal(struct inode *inode,
 	bg = (struct ocfs2_group_desc *)gd_bh->b_data;
 
 	/*
-	 * make goal become cluster aligned.
-	 */
-	range->me_goal = ocfs2_block_to_cluster_start(inode->i_sb,
-						      range->me_goal);
-	/*
-	 * moving goal is not allowd to start with a group desc blok(#0 blk)
-	 * let's compromise to the latter cluster.
-	 */
-	if (range->me_goal == le64_to_cpu(bg->bg_blkno))
-		range->me_goal += c_to_b;
-
-	/*
 	 * movement is not gonna cross two groups.
 	 */
 	if ((le16_to_cpu(bg->bg_bits) - goal_bit) * osb->s_clustersize <
-- 
1.5.5

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

* [Ocfs2-devel] [PATCH 2/2] Ocfs2/move_extents: Validate moving goal after the adjustment.
@ 2011-06-11 19:57 Mariusz Kozlowski
  2011-04-27 22:06 ` Tristan Ye
  0 siblings, 1 reply; 3+ messages in thread
From: Mariusz Kozlowski @ 2011-06-11 19:57 UTC (permalink / raw)
  To: ocfs2-devel

Hi,

  I think this one (ea5e1675 upstream) is wrong. Validation was moved
before 'bg' was assinged any sane value. Also 'bg' is defined with NULL
now so it hides real problem that 'bg' is used uninitialized. So currently
as 'bg' is NULL from the begining it will blow up with null pointer
dereference somewhere around test in line 489:

489:        if (range->me_goal == le64_to_cpu(bg->bg_blkno))
490:	                range->me_goal += c_to_b;

Sorry for reply with no context but I'm not subscribed to ocfs2-devel.
-- 
Mariusz Kozlowski

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

end of thread, other threads:[~2011-06-11 19:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-11 19:57 [Ocfs2-devel] [PATCH 2/2] Ocfs2/move_extents: Validate moving goal after the adjustment Mariusz Kozlowski
2011-04-27 22:06 ` Tristan Ye
  -- strict thread matches above, loose matches on Subject: below --
2011-05-27  6:32 [Ocfs2-devel] [PATCH 1/2] Ocfs2/move_extents: Avoid doing division in extent moving Tristan Ye
2011-05-27  6:32 ` [Ocfs2-devel] [PATCH 2/2] Ocfs2/move_extents: Validate moving goal after the adjustment Tristan Ye

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.