linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: Fix overflow when updating superblock backups after resize
@ 2014-10-22 14:29 Jan Kara
  2014-10-22 15:00 ` Lukáš Czerner
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2014-10-22 14:29 UTC (permalink / raw)
  To: Ted Tso; +Cc: linux-ext4, Jan Kara, stable

When there are no meta block groups update_backups() will compute the
backup block in 32-bit arithmetics thus possibly overflowing the block
number and corrupting the filesystem. OTOH filesystems without meta
block groups larger than 16 TB should be rare. Fix the problem by doing
the counting in 64-bit arithmetics.

Coverity-id: 741252
CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/resize.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index f298c60f907d..ca4588388fc3 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1081,7 +1081,7 @@ static void update_backups(struct super_block *sb, int blk_off, char *data,
 			break;
 
 		if (meta_bg == 0)
-			backup_block = group * bpg + blk_off;
+			backup_block = ((ext4_fsblk_t)group) * bpg + blk_off;
 		else
 			backup_block = (ext4_group_first_block_no(sb, group) +
 					ext4_bg_has_super(sb, group));
-- 
1.8.1.4

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

* Re: [PATCH] ext4: Fix overflow when updating superblock backups after resize
  2014-10-22 14:29 [PATCH] ext4: Fix overflow when updating superblock backups after resize Jan Kara
@ 2014-10-22 15:00 ` Lukáš Czerner
  2014-10-28 20:40   ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Lukáš Czerner @ 2014-10-22 15:00 UTC (permalink / raw)
  To: Jan Kara; +Cc: Ted Tso, linux-ext4, stable

On Wed, 22 Oct 2014, Jan Kara wrote:

> Date: Wed, 22 Oct 2014 16:29:08 +0200
> From: Jan Kara <jack@suse.cz>
> To: Ted Tso <tytso@mit.edu>
> Cc: linux-ext4@vger.kernel.org, Jan Kara <jack@suse.cz>,
>     stable@vger.kernel.org
> Subject: [PATCH] ext4: Fix overflow when updating superblock backups after
>     resize
> 
> When there are no meta block groups update_backups() will compute the
> backup block in 32-bit arithmetics thus possibly overflowing the block
> number and corrupting the filesystem. OTOH filesystems without meta
> block groups larger than 16 TB should be rare. Fix the problem by doing
> the counting in 64-bit arithmetics.

Looks good, thanks.

Reviewed-by: Lukas Czerner <lczerner@redhat.com>

> 
> Coverity-id: 741252
> CC: stable@vger.kernel.org
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
>  fs/ext4/resize.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
> index f298c60f907d..ca4588388fc3 100644
> --- a/fs/ext4/resize.c
> +++ b/fs/ext4/resize.c
> @@ -1081,7 +1081,7 @@ static void update_backups(struct super_block *sb, int blk_off, char *data,
>  			break;
>  
>  		if (meta_bg == 0)
> -			backup_block = group * bpg + blk_off;
> +			backup_block = ((ext4_fsblk_t)group) * bpg + blk_off;
>  		else
>  			backup_block = (ext4_group_first_block_no(sb, group) +
>  					ext4_bg_has_super(sb, group));
> 

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

* Re: [PATCH] ext4: Fix overflow when updating superblock backups after resize
  2014-10-22 15:00 ` Lukáš Czerner
@ 2014-10-28 20:40   ` Theodore Ts'o
  0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2014-10-28 20:40 UTC (permalink / raw)
  To: Lukáš Czerner; +Cc: Jan Kara, linux-ext4, stable

On Wed, Oct 22, 2014 at 05:00:47PM +0200, Lukáš Czerner wrote:
> On Wed, 22 Oct 2014, Jan Kara wrote:
> > When there are no meta block groups update_backups() will compute the
> > backup block in 32-bit arithmetics thus possibly overflowing the block
> > number and corrupting the filesystem. OTOH filesystems without meta
> > block groups larger than 16 TB should be rare. Fix the problem by doing
> > the counting in 64-bit arithmetics.
> 
> Looks good, thanks.
> 
> Reviewed-by: Lukas Czerner <lczerner@redhat.com>

Thanks, applied.

					- Ted

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

end of thread, other threads:[~2014-10-28 20:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-22 14:29 [PATCH] ext4: Fix overflow when updating superblock backups after resize Jan Kara
2014-10-22 15:00 ` Lukáš Czerner
2014-10-28 20:40   ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).