diff mbox

[2/4] Btrfs: just free dummy extent buffers

Message ID 1426624683-3085-3-git-send-email-jbacik@fb.com (mailing list archive)
State Accepted
Headers show

Commit Message

Josef Bacik March 17, 2015, 8:38 p.m. UTC
If we fail during our sanity tests we could get NULL deref's because we unload
the module before the dummy extent buffers are free'd via RCU.  So check for
this case and just free the things directly.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 fs/btrfs/extent_io.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

David Sterba March 18, 2015, 1:56 p.m. UTC | #1
On Tue, Mar 17, 2015 at 04:38:01PM -0400, Josef Bacik wrote:
> If we fail during our sanity tests we could get NULL deref's because we unload
> the module before the dummy extent buffers are free'd via RCU.  So check for
> this case and just free the things directly.  Thanks,
> 
> Signed-off-by: Josef Bacik <jbacik@fb.com>
> ---
>  fs/btrfs/extent_io.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 29850d4..d13cead 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -4968,6 +4968,12 @@ static int release_extent_buffer(struct extent_buffer *eb)
>  
>  		/* Should be safe to release our pages at this point */
>  		btrfs_release_extent_buffer_page(eb);
> +#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS

Please use btrfs_test_is_dummy_root, it's there to avoid the #ifdefs

> +		if (unlikely(test_bit(EXTENT_BUFFER_DUMMY, &eb->bflags))) {
> +			__free_extent_buffer(eb);
> +			return 1;
> +		}
> +#endif
>  		call_rcu(&eb->rcu_head, btrfs_release_extent_buffer_rcu);
>  		return 1;
>  	}
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Josef Bacik March 18, 2015, 1:57 p.m. UTC | #2
On 03/18/2015 09:56 AM, David Sterba wrote:
> On Tue, Mar 17, 2015 at 04:38:01PM -0400, Josef Bacik wrote:
>> If we fail during our sanity tests we could get NULL deref's because we unload
>> the module before the dummy extent buffers are free'd via RCU.  So check for
>> this case and just free the things directly.  Thanks,
>>
>> Signed-off-by: Josef Bacik <jbacik@fb.com>
>> ---
>>   fs/btrfs/extent_io.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
>> index 29850d4..d13cead 100644
>> --- a/fs/btrfs/extent_io.c
>> +++ b/fs/btrfs/extent_io.c
>> @@ -4968,6 +4968,12 @@ static int release_extent_buffer(struct extent_buffer *eb)
>>
>>   		/* Should be safe to release our pages at this point */
>>   		btrfs_release_extent_buffer_page(eb);
>> +#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
>
> Please use btrfs_test_is_dummy_root, it's there to avoid the #ifdefs

Don't have a root here.  Thanks,

Josef
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 29850d4..d13cead 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4968,6 +4968,12 @@  static int release_extent_buffer(struct extent_buffer *eb)
 
 		/* Should be safe to release our pages at this point */
 		btrfs_release_extent_buffer_page(eb);
+#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
+		if (unlikely(test_bit(EXTENT_BUFFER_DUMMY, &eb->bflags))) {
+			__free_extent_buffer(eb);
+			return 1;
+		}
+#endif
 		call_rcu(&eb->rcu_head, btrfs_release_extent_buffer_rcu);
 		return 1;
 	}