All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: Fix superblock csum type check.
@ 2015-04-28  1:06 Qu Wenruo
  2015-04-29 17:23 ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Qu Wenruo @ 2015-04-28  1:06 UTC (permalink / raw)
  To: linux-btrfs

Old csum type check is wrong and can't catch csum_type 1(not supported).

Fix it to avoid hostile 0 division.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
Changelog:
v2:
   Fix existing codes other than adding new one.
v3:
   Just remove the tailing in btrfs_csum_sizes array.
---
 fs/btrfs/ctree.h   | 2 +-
 fs/btrfs/disk-io.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index f9c89ca..745b5e7 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -174,7 +174,7 @@ struct btrfs_ordered_sum;
 /* csum types */
 #define BTRFS_CSUM_TYPE_CRC32	0
 
-static int btrfs_csum_sizes[] = { 4, 0 };
+static int btrfs_csum_sizes[] = { 4 };
 
 /* four bytes for CRC32 */
 #define BTRFS_EMPTY_DIR_SIZE 0
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 639f266..e3495b1 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -428,7 +428,7 @@ static int btrfs_check_super_csum(char *raw_disk_sb)
 
 	if (csum_type >= ARRAY_SIZE(btrfs_csum_sizes)) {
 		printk(KERN_ERR "BTRFS: unsupported checksum algorithm %u\n",
-				csum_type);
+		       csum_type);
 		ret = 1;
 	}
 
-- 
2.3.6


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

* Re: [PATCH] btrfs: Fix superblock csum type check.
  2015-04-28  1:06 [PATCH] btrfs: Fix superblock csum type check Qu Wenruo
@ 2015-04-29 17:23 ` David Sterba
  2015-04-30  0:33   ` Qu Wenruo
  0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2015-04-29 17:23 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Tue, Apr 28, 2015 at 09:06:03AM +0800, Qu Wenruo wrote:
> Old csum type check is wrong and can't catch csum_type 1(not supported).
> 
> Fix it to avoid hostile 0 division.
> 
> Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>

Reviewed-by: David Sterba <dsterba@suse.cz>

> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -428,7 +428,7 @@ static int btrfs_check_super_csum(char *raw_disk_sb)
>  
>  	if (csum_type >= ARRAY_SIZE(btrfs_csum_sizes)) {
>  		printk(KERN_ERR "BTRFS: unsupported checksum algorithm %u\n",
> -				csum_type);
> +		       csum_type);

Please avoid unrelated changes.

>  		ret = 1;
>  	}

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

* Re: [PATCH] btrfs: Fix superblock csum type check.
  2015-04-29 17:23 ` David Sterba
@ 2015-04-30  0:33   ` Qu Wenruo
  2015-05-04 16:08     ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Qu Wenruo @ 2015-04-30  0:33 UTC (permalink / raw)
  To: dsterba, linux-btrfs



-------- Original Message  --------
Subject: Re: [PATCH] btrfs: Fix superblock csum type check.
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>
Date: 2015年04月30日 01:23

> On Tue, Apr 28, 2015 at 09:06:03AM +0800, Qu Wenruo wrote:
>> Old csum type check is wrong and can't catch csum_type 1(not supported).
>>
>> Fix it to avoid hostile 0 division.
>>
>> Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
>> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
>
> Reviewed-by: David Sterba <dsterba@suse.cz>
>
>> --- a/fs/btrfs/disk-io.c
>> +++ b/fs/btrfs/disk-io.c
>> @@ -428,7 +428,7 @@ static int btrfs_check_super_csum(char *raw_disk_sb)
>>
>>   	if (csum_type >= ARRAY_SIZE(btrfs_csum_sizes)) {
>>   		printk(KERN_ERR "BTRFS: unsupported checksum algorithm %u\n",
>> -				csum_type);
>> +		       csum_type);
>
> Please avoid unrelated changes.
Thanks for reviewing.

Do I need to send a newer version to discard this format change?

Thanks,
Qu
>
>>   		ret = 1;
>>   	}

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

* Re: [PATCH] btrfs: Fix superblock csum type check.
  2015-04-30  0:33   ` Qu Wenruo
@ 2015-05-04 16:08     ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2015-05-04 16:08 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: dsterba, linux-btrfs

On Thu, Apr 30, 2015 at 08:33:26AM +0800, Qu Wenruo wrote:
> >> -				csum_type);
> >> +		       csum_type);
> >
> > Please avoid unrelated changes.
> Thanks for reviewing.
> 
> Do I need to send a newer version to discard this format change?

Yes please.

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

end of thread, other threads:[~2015-05-04 16:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-28  1:06 [PATCH] btrfs: Fix superblock csum type check Qu Wenruo
2015-04-29 17:23 ` David Sterba
2015-04-30  0:33   ` Qu Wenruo
2015-05-04 16:08     ` David Sterba

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.