Skip to contentSkip to conversation

ocfs2: two bug fixes about xattr and inline-data

PATCH New Tiger Yang 5 participants 24 messages Mar 4, 2009 – Mar 9, 2009 OCFS2

lore
Share & tools
lore

Tiger Yang

author
#0 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Mark and Joel,

I found two serious bugs about xattr and inline-data.

the first bug:
in ocfs2_mknod(), we check and found the ACL or security xattr entry could be set into inode in ocfs2_calc_xattr_init(), then don't reserve block for them. But in ocfs2_mknod_locked(), if we found ocfs2 support inline-data, then set id_count with the max_inline_data. After that, we set acl/security xattr entry in ocfs2_init_acl() or ocfs2_init_security_set(), but in there we found inode is full, then panic at ocfs2_claim_metadata in ocfs2_xattr_block_set.

the second bug:
we don't check inline xattr in ocfs2_try_to_write_inline_data(), so the inline data may overwrite the xattr entries which have already in inode.

thanks,
tiger

author
#1 lore raw

PATCH 1/2 ocfs2: reserve xattr block for directory inode in mknod

As we set directory inode starting with inline data, there is no place in inode for ACLs or security extended attributes entries. In this case, we have to reserve xattr block at the begining of mknod.

---
 fs/ocfs2/xattr.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
fs/ocfs2/xattr.c +1 -0
index 4ddd788..053ae3d 100644
@@ -549,6 +549,7 @@ int ocfs2_calc_xattr_init(struct inode *dir,
 	 * for them is ok.
 	 */
 	if (dir->i_sb->s_blocksize == OCFS2_MIN_BLOCKSIZE ||
+	    (S_ISDIR(mode) && ocfs2_supports_inline_data(osb)) ||
 	    (s_size + a_size) > OCFS2_XATTR_FREE_IN_IBODY) {
 		ret = ocfs2_reserve_new_metadata_blocks(osb, 1, xattr_ac);
 		if (ret) {
Signature · 1 line
1.5.4.1
#2 lore raw

PATCH 1/2 ocfs2: reserve xattr block for directory inode in mknod

Quoted 6 lines · Tiger Yang

As we set directory inode starting with inline data, there is no place in inode for ACLs or security extended attributes entries. In this case, we have to reserve xattr block at the begining of mknod.

This is fine, but can you update the comment above? Something
like "If this is a new directory with inline data, we choose to reserve the entire inline area for directory contents and force an external xattr block."

Joel

Signature · 7 lines
"War doesn't determine who's right; war determines who's left."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
author
#3 lore raw

PATCH 2/2 ocfs2: fix check condition of max inline data

In reply to Tiger Yang

We should consider the inline xattr when
we try to write inline data.

---
 fs/ocfs2/aops.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
fs/ocfs2/aops.c +4 -1
index a067a6c..dc6d734 100644
@@ -1555,6 +1555,7 @@ static int ocfs2_try_to_write_inline_data(struct address_space *mapping,
 	int ret, written = 0;
 	loff_t end = pos + len;
 	struct ocfs2_inode_info *oi = OCFS2_I(inode);
+	struct ocfs2_dinode *di = NULL;
 
 	mlog(0, "Inode %llu, write of %u bytes at off %llu. features: 0x%x\n",
 	     (unsigned long long)oi->ip_blkno, len, (unsigned long long)pos,
@@ -1587,7 +1588,9 @@ static int ocfs2_try_to_write_inline_data(struct address_space *mapping,
 	/*
 	 * Check whether the write can fit.
 	 */
-	if (mmap_page || end > ocfs2_max_inline_data(inode->i_sb))
+	di = (struct ocfs2_dinode *)wc->w_di_bh->b_data;
+	if (mmap_page ||
+	    end > ocfs2_max_inline_data_with_xattr(inode->i_sb, di))
 		return 0;
 
 do_inline_write:
Signature · 1 line
1.5.4.1
#4 lore raw

PATCH 2/2 ocfs2: fix check condition of max inline data

Hi tiger,
I just searched the code in ocfs2. There are other cases(in
ocfs2_read_inline_data) which may have the problem also.

So I just think that since you have already added inlin-data-xattr support in ocfs2, why not remove the function ocfs2_max_inline_data and use ocfs2_max_inline_data_with_xattr instead in all the cases? Make it more intelligent?

I am just worried that this function may be used wrongly afterwards and cause future bugs like this.

Regards,
Tao

Quoted 31 lines · Tiger Yang

We should consider the inline xattr when
we try to write inline data.

---
 fs/ocfs2/aops.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
fs/ocfs2/aops.c +4 -1
index a067a6c..dc6d734 100644
@@ -1555,6 +1555,7 @@ static int ocfs2_try_to_write_inline_data(struct address_space *mapping,
 	int ret, written = 0;
 	loff_t end = pos + len;
 	struct ocfs2_inode_info *oi = OCFS2_I(inode);
+	struct ocfs2_dinode *di = NULL;
 
 	mlog(0, "Inode %llu, write of %u bytes at off %llu. features: 0x%x\n",
 	     (unsigned long long)oi->ip_blkno, len, (unsigned long long)pos,
@@ -1587,7 +1588,9 @@ static int ocfs2_try_to_write_inline_data(struct address_space *mapping,
 	/*
 	 * Check whether the write can fit.
 	 */
-	if (mmap_page || end > ocfs2_max_inline_data(inode->i_sb))
+	di = (struct ocfs2_dinode *)wc->w_di_bh->b_data;
+	if (mmap_page ||
+	    end > ocfs2_max_inline_data_with_xattr(inode->i_sb, di))
 		return 0;
 
 do_inline_write:
author
#5 lore raw

PATCH 2/2 ocfs2: fix check condition of max inline data

Hi, Tao,

yes. ocfs2_max_inline_data_with_xattr() in read_inline_data() is more critical, I think ocfs2_max_inline_data() is also safe before.

I deliberately left ocfs2_max_inline_data() because in some case, like in mknod, di->i_dyn_features have not been set with OCFS2_INLINE_XATTR_FL or we couldn't get correct di in somewhere.

thanks,
tiger

Quoted 50 lines · Tao Ma

Hi tiger,
I just searched the code in ocfs2. There are other cases(in
ocfs2_read_inline_data) which may have the problem also.

So I just think that since you have already added inlin-data-xattr support in ocfs2, why not remove the function ocfs2_max_inline_data and use ocfs2_max_inline_data_with_xattr instead in all the cases? Make it more intelligent?

I am just worried that this function may be used wrongly afterwards and cause future bugs like this.

Regards,
Tao

Quoted 34 lines · Tiger Yang

We should consider the inline xattr when
we try to write inline data.

---
 fs/ocfs2/aops.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
fs/ocfs2/aops.c +1 -0
index a067a6c..dc6d734 100644
@@ -1555,6 +1555,7 @@ static int ocfs2_try_to_write_inline_data(struct 
 address_space *mapping,
     int ret, written = 0;
     loff_t end = pos + len;
     struct ocfs2_inode_info *oi = OCFS2_I(inode);
+    struct ocfs2_dinode *di = NULL;
 
     mlog(0, "Inode %llu, write of %u bytes at off %llu. features: 

0x%x\n",

          (unsigned long long)oi->ip_blkno, len, (unsigned long long)pos,
fs/ocfs2/aops.c +3 -1
@@ -1587,7 +1588,9 @@ static int ocfs2_try_to_write_inline_data(struct 
 address_space *mapping,
     /*
      * Check whether the write can fit.
      */
-    if (mmap_page || end > ocfs2_max_inline_data(inode->i_sb))
+    di = (struct ocfs2_dinode *)wc->w_di_bh->b_data;
+    if (mmap_page ||
+        end > ocfs2_max_inline_data_with_xattr(inode->i_sb, di))
         return 0;
 

do_inline_write:

#6 lore raw

PATCH 2/2 ocfs2: fix check condition of max inline data

Quoted 8 lines · Tiger Yang

Hi, Tao,

yes. ocfs2_max_inline_data_with_xattr() in read_inline_data() is more critical, I think ocfs2_max_inline_data() is also safe before.

I deliberately left ocfs2_max_inline_data() because in some case, like in mknod, di->i_dyn_features have not been set with OCFS2_INLINE_XATTR_FL or we couldn't get correct di in somewhere.

yes, I already noticed it. But as I have said in the previous mail, could you please make it more intelligent? in mknod, we know all the cases so we can do it.

Regards,
Tao

Quoted 56 lines

thanks,
tiger

Quoted 51 lines · Tao Ma

Hi tiger,
I just searched the code in ocfs2. There are other cases(in
ocfs2_read_inline_data) which may have the problem also.

So I just think that since you have already added inlin-data-xattr support in ocfs2, why not remove the function ocfs2_max_inline_data and use ocfs2_max_inline_data_with_xattr instead in all the cases? Make it more intelligent?

I am just worried that this function may be used wrongly afterwards and cause future bugs like this.

Regards,
Tao

Quoted 35 lines · Tiger Yang

We should consider the inline xattr when
we try to write inline data.

---
 fs/ocfs2/aops.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
fs/ocfs2/aops.c +1 -0
index a067a6c..dc6d734 100644
@@ -1555,6 +1555,7 @@ static int 
 ocfs2_try_to_write_inline_data(struct address_space *mapping,
     int ret, written = 0;
     loff_t end = pos + len;
     struct ocfs2_inode_info *oi = OCFS2_I(inode);
+    struct ocfs2_dinode *di = NULL;
 
     mlog(0, "Inode %llu, write of %u bytes at off %llu. features: 

0x%x\n",

          (unsigned long long)oi->ip_blkno, len, (unsigned long 

long)pos,

fs/ocfs2/aops.c +3 -1
@@ -1587,7 +1588,9 @@ static int 
 ocfs2_try_to_write_inline_data(struct address_space *mapping,
     /*
      * Check whether the write can fit.
      */
-    if (mmap_page || end > ocfs2_max_inline_data(inode->i_sb))
+    di = (struct ocfs2_dinode *)wc->w_di_bh->b_data;
+    if (mmap_page ||
+        end > ocfs2_max_inline_data_with_xattr(inode->i_sb, di))
         return 0;
 

do_inline_write:

#7 lore raw

PATCH 2/2 ocfs2: fix check condition of max inline data

Quoted 6 lines · Tao Ma
Quoted 5 lines · Tiger Yang

Hi, Tao,

yes. ocfs2_max_inline_data_with_xattr() in read_inline_data() is more critical, I think ocfs2_max_inline_data() is also safe before.

Quoted 6 lines
Quoted 3 lines

I deliberately left ocfs2_max_inline_data() because in some case, like in mknod, di->i_dyn_features have not been set with OCFS2_INLINE_XATTR_FL or we couldn't get correct di in somewhere.

yes, I already noticed it. But as I have said in the previous mail, could you please make it more intelligent? in mknod, we know all the cases so we can do it.

I just looked, and they all have the di (well, it's called fe in
mknod_locked, but it is still there. the aops.c functions have it on the write_ctxt). I agree with Tao, max_inline_data_with_xattr() is always the correct function.
Btw, in mknod, it's safe to call. The INLINE_XATTR_FL will
*not* be set, which is correct with regards to your previous patch (that makes sure a block is reserved for the xattrs on an inline directory).
Good catch!

Joel

Signature · 8 lines
"Win95 file and print sharing are for relatively friendly nets."
	- Paul Leach, Microsoft

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
#8 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

In reply to Tiger Yang
Quoted 1 line · Tiger Yang

I found two serious bugs about xattr and inline-data.

Tristan,
Can you add tests for this in the xattr suite? Thanks!

Joel

Quoted 17 lines

the first bug:
in ocfs2_mknod(), we check and found the ACL or security xattr entry could be set into inode in ocfs2_calc_xattr_init(), then don't reserve block for them. But in ocfs2_mknod_locked(), if we found ocfs2 support inline-data, then set id_count with the max_inline_data. After that, we set acl/security xattr entry in ocfs2_init_acl() or ocfs2_init_security_set(), but in there we found inode is full, then panic at ocfs2_claim_metadata in ocfs2_xattr_block_set.

the second bug:
we don't check inline xattr in ocfs2_try_to_write_inline_data(), so the inline data may overwrite the xattr entries which have already in inode.

thanks,
tiger

Signature · 9 lines
"Here's something to think about:  How come you never see a headline
 like ``Psychic Wins Lottery''?"
	- Jay Leno

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
#9 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Quoted 5 lines · Joel Becker
Quoted 1 line · Tiger Yang

I found two serious bugs about xattr and inline-data.

Tristan,
Can you add tests for this in the xattr suite? Thanks!

Of course, I'll be looking back to my testcases, and add these if missed.

Actually, I've already had inline-data&inline-xattr combination tests in xattr testing suite, how can I misse such boundary cases?

Tiger,

Thanks for posting the cases:)

Regards,
Tristan

Quoted 21 lines

Joel

Quoted 17 lines

the first bug:
in ocfs2_mknod(), we check and found the ACL or security xattr entry could be set into inode in ocfs2_calc_xattr_init(), then don't reserve block for them. But in ocfs2_mknod_locked(), if we found ocfs2 support inline-data, then set id_count with the max_inline_data. After that, we set acl/security xattr entry in ocfs2_init_acl() or ocfs2_init_security_set(), but in there we found inode is full, then panic at ocfs2_claim_metadata in ocfs2_xattr_block_set.

the second bug:
we don't check inline xattr in ocfs2_try_to_write_inline_data(), so the inline data may overwrite the xattr entries which have already in inode.

thanks,
tiger

#10 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Hi tristan,
the first bug should happen when you create a directory with acl. So do
you have the test case for that?
The second one should happen when you try to try to the inline file and
then you will lose the xattr entry you set.

Regards,
Tao

Quoted 45 lines · tristan.ye
Quoted 4 lines · Joel Becker
Quoted 1 line · Tiger Yang

I found two serious bugs about xattr and inline-data.

Tristan,
Can you add tests for this in the xattr suite? Thanks!

Of course, I'll be looking back to my testcases, and add these if missed.

Actually, I've already had inline-data&inline-xattr combination tests in xattr testing suite, how can I misse such boundary cases?

Tiger,

Thanks for posting the cases:)

Regards,
Tristan

Quoted 18 lines

Joel

Quoted 16 lines

the first bug:
in ocfs2_mknod(), we check and found the ACL or security xattr entry could be set into inode in ocfs2_calc_xattr_init(), then don't reserve block for them. But in ocfs2_mknod_locked(), if we found ocfs2 support inline-data, then set id_count with the max_inline_data. After that, we set acl/security xattr entry in ocfs2_init_acl() or ocfs2_init_security_set(), but in there we found inode is full, then panic at ocfs2_claim_metadata in ocfs2_xattr_block_set.

the second bug:
we don't check inline xattr in ocfs2_try_to_write_inline_data(), so the inline data may overwrite the xattr entries which have already in inode.

thanks,
tiger

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel

#11 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Quoted 3 lines · Tao Ma

Hi tristan,
the first bug should happen when you create a directory with acl. So do
you have the test case for that?

Yes, I can add this.

Quoted 2 lines

The second one should happen when you try to try to the inline file and
then you will lose the xattr entry you set.

Actually, I've had similar testcase, and it never failed to me, that means a previously set xattr entry which has reserved 256 bytes in inode never be affected or overwriten by the following inline-data writing attempt when i_size > MAX_INLINE_SIZE - 256.

Regards,
Tristan

Quoted 50 lines

Regards,
Tao

Quoted 45 lines · tristan.ye
Quoted 4 lines · Joel Becker
Quoted 1 line · Tiger Yang

I found two serious bugs about xattr and inline-data.

Tristan,
Can you add tests for this in the xattr suite? Thanks!

Of course, I'll be looking back to my testcases, and add these if missed.

Actually, I've already had inline-data&inline-xattr combination tests in xattr testing suite, how can I misse such boundary cases?

Tiger,

Thanks for posting the cases:)

Regards,
Tristan

Quoted 18 lines

Joel

Quoted 16 lines

the first bug:
in ocfs2_mknod(), we check and found the ACL or security xattr entry could be set into inode in ocfs2_calc_xattr_init(), then don't reserve block for them. But in ocfs2_mknod_locked(), if we found ocfs2 support inline-data, then set id_count with the max_inline_data. After that, we set acl/security xattr entry in ocfs2_init_acl() or ocfs2_init_security_set(), but in there we found inode is full, then panic at ocfs2_claim_metadata in ocfs2_xattr_block_set.

the second bug:
we don't check inline xattr in ocfs2_try_to_write_inline_data(), so the inline data may overwrite the xattr entries which have already in inode.

thanks,
tiger

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel

#12 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Quoted 5 lines · tristan.ye
Quoted 3 lines · Tao Ma

Hi tristan,
the first bug should happen when you create a directory with acl. So do
you have the test case for that?

Quoted 8 lines

Yes, I can add this.

Quoted 2 lines

The second one should happen when you try to try to the inline file and
then you will lose the xattr entry you set.

Actually, I've had similar testcase, and it never failed to me, that means a previously set xattr entry which has reserved 256 bytes in inode never be affected or overwriten by the following inline-data writing attempt when i_size > MAX_INLINE_SIZE - 256.

Just go through the code and guess ;) the process should be:
1. fill in some inline data.
2. set entry
3. write i_size > MAX_INLINE_SIZE - 256.

I guess your case miss step 1.

Tiger,
Can bug 2 reproduced by my guess steps?

Regards,
Tao

Quoted 56 lines

Regards,
Tristan

Quoted 47 lines

Regards,
Tao

Quoted 43 lines · tristan.ye
Quoted 4 lines · Joel Becker
Quoted 1 line · Tiger Yang

I found two serious bugs about xattr and inline-data.

Tristan,
Can you add tests for this in the xattr suite? Thanks!

Of course, I'll be looking back to my testcases, and add these if missed.

Actually, I've already had inline-data&inline-xattr combination tests in xattr testing suite, how can I misse such boundary cases?

Tiger,

Thanks for posting the cases:)

Regards,
Tristan

Quoted 18 lines

Joel

Quoted 16 lines

the first bug:
in ocfs2_mknod(), we check and found the ACL or security xattr entry could be set into inode in ocfs2_calc_xattr_init(), then don't reserve block for them. But in ocfs2_mknod_locked(), if we found ocfs2 support inline-data, then set id_count with the max_inline_data. After that, we set acl/security xattr entry in ocfs2_init_acl() or ocfs2_init_security_set(), but in there we found inode is full, then panic at ocfs2_claim_metadata in ocfs2_xattr_block_set.

the second bug:
we don't check inline xattr in ocfs2_try_to_write_inline_data(), so the inline data may overwrite the xattr entries which have already in inode.

thanks,
tiger

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel

#13 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Quoted 11 lines · Tao Ma
Quoted 9 lines · tristan.ye
Quoted 3 lines · Tao Ma

Hi tristan,
the first bug should happen when you create a directory with acl. So do
you have the test case for that?

Yes, I can add this.

Quoted 2 lines

The second one should happen when you try to try to the inline file and
then you will lose the xattr entry you set.

Quoted 8 lines
Quoted 4 lines

Actually, I've had similar testcase, and it never failed to me, that means a previously set xattr entry which has reserved 256 bytes in inode never be affected or overwriten by the following inline-data writing attempt when i_size > MAX_INLINE_SIZE - 256.

Just go through the code and guess ;) the process should be:
1. fill in some inline data.
2. set entry
3. write i_size > MAX_INLINE_SIZE - 256.

I still can not reproduce this bug with your testing step on joel's cacheme branch, maybe it is a regression bug on mainline kernel, tiger, how did you think about it?

Quoted 64 lines

I guess your case miss step 1.

Tiger,
Can bug 2 reproduced by my guess steps?

Regards,
Tao

Quoted 56 lines

Regards,
Tristan

Quoted 47 lines

Regards,
Tao

Quoted 43 lines · tristan.ye
Quoted 4 lines · Joel Becker
Quoted 1 line · Tiger Yang

I found two serious bugs about xattr and inline-data.

Tristan,
Can you add tests for this in the xattr suite? Thanks!

Of course, I'll be looking back to my testcases, and add these if missed.

Actually, I've already had inline-data&inline-xattr combination tests in xattr testing suite, how can I misse such boundary cases?

Tiger,

Thanks for posting the cases:)

Regards,
Tristan

Quoted 18 lines

Joel

Quoted 16 lines

the first bug:
in ocfs2_mknod(), we check and found the ACL or security xattr entry could be set into inode in ocfs2_calc_xattr_init(), then don't reserve block for them. But in ocfs2_mknod_locked(), if we found ocfs2 support inline-data, then set id_count with the max_inline_data. After that, we set acl/security xattr entry in ocfs2_init_acl() or ocfs2_init_security_set(), but in there we found inode is full, then panic at ocfs2_claim_metadata in ocfs2_xattr_block_set.

the second bug:
we don't check inline xattr in ocfs2_try_to_write_inline_data(), so the inline data may overwrite the xattr entries which have already in inode.

thanks,
tiger

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel

author
#14 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Hi, all,

I found these two bugs in latest mainline kernel not other branch.

thanks,
tiger

Quoted 89 lines · tristan.ye
Quoted 8 lines · Tao Ma
Quoted 7 lines · tristan.ye
Quoted 3 lines · Tao Ma

Hi tristan,
the first bug should happen when you create a directory with acl. So do
you have the test case for that?

Yes, I can add this.

Quoted 2 lines

The second one should happen when you try to try to the inline file and
then you will lose the xattr entry you set.

Quoted 8 lines
Quoted 4 lines

Actually, I've had similar testcase, and it never failed to me, that means a previously set xattr entry which has reserved 256 bytes in inode never be affected or overwriten by the following inline-data writing attempt when i_size > MAX_INLINE_SIZE - 256.

Just go through the code and guess ;) the process should be:
1. fill in some inline data.
2. set entry
3. write i_size > MAX_INLINE_SIZE - 256.

I still can not reproduce this bug with your testing step on joel's cacheme branch, maybe it is a regression bug on mainline kernel, tiger, how did you think about it?

Quoted 60 lines

I guess your case miss step 1.

Tiger,
Can bug 2 reproduced by my guess steps?

Regards,
Tao

Quoted 53 lines

Regards,
Tristan

Quoted 46 lines

Regards,
Tao

Quoted 42 lines · tristan.ye
Quoted 4 lines · Joel Becker
Quoted 1 line · Tiger Yang

I found two serious bugs about xattr and inline-data.

Tristan,
Can you add tests for this in the xattr suite? Thanks!

Of course, I'll be looking back to my testcases, and add these if missed.

Actually, I've already had inline-data&inline-xattr combination tests in xattr testing suite, how can I misse such boundary cases?

Tiger,

Thanks for posting the cases:)

Regards,
Tristan

Quoted 18 lines

Joel

Quoted 16 lines

the first bug:
in ocfs2_mknod(), we check and found the ACL or security xattr entry could be set into inode in ocfs2_calc_xattr_init(), then don't reserve block for them. But in ocfs2_mknod_locked(), if we found ocfs2 support inline-data, then set id_count with the max_inline_data. After that, we set acl/security xattr entry in ocfs2_init_acl() or ocfs2_init_security_set(), but in there we found inode is full, then panic at ocfs2_claim_metadata in ocfs2_xattr_block_set.

the second bug:
we don't check inline xattr in ocfs2_try_to_write_inline_data(), so the inline data may overwrite the xattr entries which have already in inode.

thanks,
tiger

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel

#15 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Quoted 1 line · Tiger Yang

I found these two bugs in latest mainline kernel not other branch.

The bugs should still be in cacheme - cacheme doesn't change
the inline data code.

Joel

Signature · 9 lines
"One of the symptoms of an approaching nervous breakdown is the
 belief that one's work is terribly important."
         - Bertrand Russell 

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
#16 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Quoted 5 lines · Joel Becker
Quoted 1 line · Tiger Yang

I found these two bugs in latest mainline kernel not other branch.

The bugs should still be in cacheme - cacheme doesn't change
the inline data code.

Fairly strange, I've already done the tests on cacheme branch, no such bugs happened to me...

Tristan

Quoted 3 lines

Joel

#17 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Hi Tiger,
so could you please describe how to reproduce these 2 bugs step by
step? It would be easy for tristan to code them down and add them to the test case. And also we all can see whether we can reproduce them in our own env.

Regards,
Tao

Quoted 14 lines · tristan.ye
Quoted 4 lines · Joel Becker
Quoted 1 line · Tiger Yang

I found these two bugs in latest mainline kernel not other branch.

The bugs should still be in cacheme - cacheme doesn't change
the inline data code.

Fairly strange, I've already done the tests on cacheme branch, no such bugs happened to me...

Tristan

Quoted 2 lines

Joel

author
#18 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Hi,

I think Tristan's test script could catch these two bugs against mainline. He didn't run his test script in mainline yet.

bug1:
Just create a file in a directory which has default ACLs.

bug2:
1. touch a file in a file system which blocksize large than 512.
2. set xattr in it.
3. write i_size > (MAX_INLINE_SIZE - 256).
then you can find the inline data overwrite the xattr in inode.

thanks,
tiger

Quoted 24 lines · Tao Ma

Hi Tiger,
so could you please describe how to reproduce these 2 bugs step by
step? It would be easy for tristan to code them down and add them to the test case. And also we all can see whether we can reproduce them in our own env.

Regards,
Tao

Quoted 14 lines · tristan.ye
Quoted 4 lines · Joel Becker
Quoted 1 line · Tiger Yang

I found these two bugs in latest mainline kernel not other branch.

The bugs should still be in cacheme - cacheme doesn't change
the inline data code.

Fairly strange, I've already done the tests on cacheme branch, no such bugs happened to me...

Tristan

Quoted 2 lines

Joel

author
#19 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Hi, all,

Finally, Tristan and I found the reason why he could not reproduce bug2. It's very interesting.

He runs the command "dd if=/dev/zero of=testfile bs=1 count=3641" which can not hit the bug2. But I found "dd if=/dev/zero of=testfile bs=3641 count=1" will hit the bug2.

I trace the source code in ocfs2_try_to_write_inline_data(). Those two commands run the different way in kernel. In first situation, the codes going into "handle inodes which already have inline data 1st", then fault at ocfs2_size_fits_inline_data(), then go ocfs2_conver_inline_data_to_extents(). In second situation, It passed the wrong check about inline data size: ocfs2_max_inline_data(), then cause the fault.

As we discussed, Tristan will add the new command into his test script. Meanwhile he will reserve the old one because it cover more codes.

thanks,
tiger

Quoted 45 lines · Tiger Yang

Hi,

I think Tristan's test script could catch these two bugs against mainline. He didn't run his test script in mainline yet.

bug1:
Just create a file in a directory which has default ACLs.

bug2:
1. touch a file in a file system which blocksize large than 512.
2. set xattr in it.
3. write i_size > (MAX_INLINE_SIZE - 256).
then you can find the inline data overwrite the xattr in inode.

thanks,
tiger

Quoted 6 lines · Tao Ma

Hi Tiger,
so could you please describe how to reproduce these 2 bugs step by
step? It would be easy for tristan to code them down and add them to the test case. And also we all can see whether we can reproduce them in our own env.

Quoted 16 lines

Regards,
Tao

Quoted 12 lines · tristan.ye
Quoted 4 lines · Joel Becker
Quoted 1 line · Tiger Yang

I found these two bugs in latest mainline kernel not other branch.

The bugs should still be in cacheme - cacheme doesn't change
the inline data code.

Fairly strange, I've already done the tests on cacheme branch, no such bugs happened to me...

Tristan

Quoted 2 lines

Joel

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel

#20 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Quoted 4 lines

He runs the command "dd if=/dev/zero of=testfile bs=1 count=3641" which can not hit the bug2. But I found "dd if=/dev/zero of=testfile bs=3641 count=1" will hit the bug2.

3641, cool number!

#21 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

Quoted 5 lines · Wengang Wang
Quoted 3 lines

He runs the command "dd if=/dev/zero of=testfile bs=1 count=3641" which can not hit the bug2. But I found "dd if=/dev/zero of=testfile bs=3641 count=1" will hit the bug2.

3641, cool number!

Hey, 3641 is the max_inline_size_with_xattr + 1 when bs = 4K. ;) So you see, they create it intentionally.

Regards,
Tao

#22 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

In reply to Tiger Yang
Quoted 17 lines · Tiger Yang

Hi, all,

Finally, Tristan and I found the reason why he could not reproduce bug2. It's very interesting.

He runs the command "dd if=/dev/zero of=testfile bs=1 count=3641" which can not hit the bug2. But I found "dd if=/dev/zero of=testfile bs=3641 count=1" will hit the bug2.

I trace the source code in ocfs2_try_to_write_inline_data(). Those two commands run the different way in kernel. In first situation, the codes going into "handle inodes which already have inline data 1st", then fault at ocfs2_size_fits_inline_data(), then go ocfs2_conver_inline_data_to_extents(). In second situation, It passed the wrong check about inline data size: ocfs2_max_inline_data(), then cause the fault.

Quoted 2 lines

As we discussed, Tristan will add the new command into his test script. Meanwhile he will reserve the old one because it cover more codes.

Cool, tiger.

After testing, these 2 bugs can be reproduced both on mainline and joel's cacheme kernel tree,for bug1, acl_tests in ocfs2-test is good enough to expose. for bug2, as you suggested, I may add a extra testcase later.

Thanks,
Tristan

Quoted 55 lines

thanks,
tiger

Quoted 38 lines · Tiger Yang

Hi,

I think Tristan's test script could catch these two bugs against mainline. He didn't run his test script in mainline yet.

bug1:
Just create a file in a directory which has default ACLs.

bug2:
1. touch a file in a file system which blocksize large than 512.
2. set xattr in it.
3. write i_size > (MAX_INLINE_SIZE - 256).
then you can find the inline data overwrite the xattr in inode.

thanks,
tiger

Quoted 20 lines · Tao Ma

Hi Tiger,
so could you please describe how to reproduce these 2 bugs step by
step? It would be easy for tristan to code them down and add them to the test case. And also we all can see whether we can reproduce them in our own env.

Regards,
Tao

Quoted 10 lines · tristan.ye
Quoted 4 lines · Joel Becker
Quoted 1 line · Tiger Yang

I found these two bugs in latest mainline kernel not other branch.

The bugs should still be in cacheme - cacheme doesn't change
the inline data code.

Fairly strange, I've already done the tests on cacheme branch, no such bugs happened to me...

Tristan

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Joel

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel

#23 lore raw

cover ocfs2: two bug fixes about xattr and inline-data

In reply to Joel Becker
Quoted 17 lines · Joel Becker
Quoted 1 line · Tiger Yang

I found two serious bugs about xattr and inline-data.

Tristan,
Can you add tests for this in the xattr suite? Thanks!

Joel

Quoted 9 lines

the first bug:
in ocfs2_mknod(), we check and found the ACL or security xattr entry could be set into inode in ocfs2_calc_xattr_init(), then don't reserve block for them. But in ocfs2_mknod_locked(), if we found ocfs2 support inline-data, then set id_count with the max_inline_data. After that, we set acl/security xattr entry in ocfs2_init_acl() or ocfs2_init_security_set(), but in there we found inode is full, then panic at ocfs2_claim_metadata in ocfs2_xattr_block_set.

Actually, my acl tests have included such case in default acl test by looking back to my previous testcases. ocfs2-test/programs/acl_tests/acl_tests.sh

Quoted 4 lines
Quoted 4 lines

the second bug:
we don't check inline xattr in ocfs2_try_to_write_inline_data(), so the inline data may overwrite the xattr entries which have already in inode.

And xattr's combination test has had it already too:-)

Regards,
Tristan

Quoted 5 lines
Quoted 4 lines

thanks,
tiger